Move some knowledge about registers out of the code emitter into the register info.
[oota-llvm.git] / lib / Target / PowerPC / PPCRegisterInfo.h
1 //===- PPCRegisterInfo.h - PowerPC Register Information Impl -----*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the PowerPC implementation of the MRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef POWERPC32_REGISTERINFO_H
15 #define POWERPC32_REGISTERINFO_H
16
17 #include "PPC.h"
18 #include "PPCGenRegisterInfo.h.inc"
19 #include <map>
20
21 namespace llvm {
22
23 class Type;
24
25 class PPCRegisterInfo : public PPCGenRegisterInfo {
26   std::map<unsigned, unsigned> ImmToIdxMap;
27 public:
28   PPCRegisterInfo();
29   
30   /// getRegisterNumbering - Given the enum value for some register, e.g.
31   /// PPC::F14, return the number that it corresponds to (e.g. 14).
32   static unsigned getRegisterNumbering(unsigned RegEnum);
33
34   /// Code Generation virtual methods...
35   void storeRegToStackSlot(MachineBasicBlock &MBB,
36                            MachineBasicBlock::iterator MBBI,
37                            unsigned SrcReg, int FrameIndex,
38                            const TargetRegisterClass *RC) const;
39
40   void loadRegFromStackSlot(MachineBasicBlock &MBB,
41                             MachineBasicBlock::iterator MBBI,
42                             unsigned DestReg, int FrameIndex,
43                             const TargetRegisterClass *RC) const;
44
45   void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
46                     unsigned DestReg, unsigned SrcReg,
47                     const TargetRegisterClass *RC) const;
48
49   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
50   /// copy instructions, turning them into load/store instructions.
51   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
52                                           int FrameIndex) const;
53   
54   void eliminateCallFramePseudoInstr(MachineFunction &MF,
55                                      MachineBasicBlock &MBB,
56                                      MachineBasicBlock::iterator I) const;
57
58   void eliminateFrameIndex(MachineBasicBlock::iterator II) const;
59
60   void emitPrologue(MachineFunction &MF) const;
61   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
62
63   // Debug information queries.
64   unsigned getRARegister() const;
65   unsigned getFrameRegister(MachineFunction &MF) const;
66   void getInitialFrameState(std::vector<MachineMove *> &Moves) const;
67 };
68
69 } // end namespace llvm
70
71 #endif