refactor some code to avoid overloading the name 'usesLR' in
[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 class PPCSubtarget;
23 class TargetInstrInfo;
24 class Type;
25
26 class PPCRegisterInfo : public PPCGenRegisterInfo {
27   std::map<unsigned, unsigned> ImmToIdxMap;
28   const PPCSubtarget &Subtarget;
29   const TargetInstrInfo &TII;
30 public:
31   PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii);
32   
33   /// getRegisterNumbering - Given the enum value for some register, e.g.
34   /// PPC::F14, return the number that it corresponds to (e.g. 14).
35   static unsigned getRegisterNumbering(unsigned RegEnum);
36
37   /// Code Generation virtual methods...
38   void storeRegToStackSlot(MachineBasicBlock &MBB,
39                            MachineBasicBlock::iterator MBBI,
40                            unsigned SrcReg, bool isKill, int FrameIndex,
41                            const TargetRegisterClass *RC) const;
42
43   void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
44                       SmallVectorImpl<MachineOperand> &Addr,
45                       const TargetRegisterClass *RC,
46                       SmallVectorImpl<MachineInstr*> &NewMIs) const;
47
48   void loadRegFromStackSlot(MachineBasicBlock &MBB,
49                             MachineBasicBlock::iterator MBBI,
50                             unsigned DestReg, int FrameIndex,
51                             const TargetRegisterClass *RC) const;
52
53   void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
54                        SmallVectorImpl<MachineOperand> &Addr,
55                        const TargetRegisterClass *RC,
56                        SmallVectorImpl<MachineInstr*> &NewMIs) const;
57
58   void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
59                     unsigned DestReg, unsigned SrcReg,
60                     const TargetRegisterClass *DestRC,
61                     const TargetRegisterClass *SrcRC) const;
62
63   void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
64                      unsigned DestReg, const MachineInstr *Orig) const;
65
66   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
67   /// copy instructions, turning them into load/store instructions.
68   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
69                                           SmallVectorImpl<unsigned> &Ops,
70                                           int FrameIndex) const;
71
72   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
73                                           SmallVectorImpl<unsigned> &Ops,
74                                           MachineInstr* LoadMI) const {
75     return 0;
76   }
77
78   virtual bool canFoldMemoryOperand(MachineInstr *MI,
79                                     SmallVectorImpl<unsigned> &Ops) const;
80
81   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
82
83   const TargetRegisterClass* const*
84   getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
85
86   BitVector getReservedRegs(const MachineFunction &MF) const;
87
88   /// targetHandlesStackFrameRounding - Returns true if the target is
89   /// responsible for rounding up the stack frame (probably at emitPrologue
90   /// time).
91   bool targetHandlesStackFrameRounding() const { return true; }
92
93   bool hasFP(const MachineFunction &MF) const;
94
95   void eliminateCallFramePseudoInstr(MachineFunction &MF,
96                                      MachineBasicBlock &MBB,
97                                      MachineBasicBlock::iterator I) const;
98
99   void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
100   void eliminateFrameIndex(MachineBasicBlock::iterator II,
101                            int SPAdj, RegScavenger *RS = NULL) const;
102
103   /// determineFrameLayout - Determine the size of the frame and maximum call
104   /// frame size.
105   void determineFrameLayout(MachineFunction &MF) const;
106
107   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
108                                             RegScavenger *RS = NULL) const;
109   void emitPrologue(MachineFunction &MF) const;
110   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
111
112   // Debug information queries.
113   unsigned getRARegister() const;
114   unsigned getFrameRegister(MachineFunction &MF) const;
115   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
116
117   // Exception handling queries.
118   unsigned getEHExceptionRegister() const;
119   unsigned getEHHandlerRegister() const;
120
121   int getDwarfRegNum(unsigned RegNum, bool isEH) const;
122 };
123
124 } // end namespace llvm
125
126 #endif