Change the meaning of predicate hasThumb2 to mean thumb2 ISA is available, not that...
[oota-llvm.git] / lib / Target / ARM / ARMRegisterInfo.h
1 //===- ARMRegisterInfo.h - ARM Register Information Impl --------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the ARM implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMREGISTERINFO_H
15 #define ARMREGISTERINFO_H
16
17 #include "ARM.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
19 #include "ARMGenRegisterInfo.h.inc"
20
21 namespace llvm {
22   class ARMSubtarget;
23   class TargetInstrInfo;
24   class Type;
25
26 /// Register allocation hints.
27 namespace ARMRI {
28   enum {
29     RegPairOdd  = 1,
30     RegPairEven = 2
31   };
32 }
33
34 /// isARMLowRegister - Returns true if the register is low register r0-r7.
35 ///
36 static inline bool isARMLowRegister(unsigned Reg) {
37   using namespace ARM;
38   switch (Reg) {
39   case R0:  case R1:  case R2:  case R3:
40   case R4:  case R5:  case R6:  case R7:
41     return true;
42   default:
43     return false;
44   }
45 }
46
47 struct ARMBaseRegisterInfo : public ARMGenRegisterInfo {
48 protected:
49   const TargetInstrInfo &TII;
50   const ARMSubtarget &STI;
51
52   /// FramePtr - ARM physical register used as frame ptr.
53   unsigned FramePtr;
54 public:
55   ARMBaseRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI);
56
57   /// getRegisterNumbering - Given the enum value for some register, e.g.
58   /// ARM::LR, return the number that it corresponds to (e.g. 14).
59   static unsigned getRegisterNumbering(unsigned RegEnum);
60
61   /// Same as previous getRegisterNumbering except it returns true in isSPVFP
62   /// if the register is a single precision VFP register.
63   static unsigned getRegisterNumbering(unsigned RegEnum, bool &isSPVFP);
64
65   /// Code Generation virtual methods...
66   const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
67
68   const TargetRegisterClass* const*
69   getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
70
71   BitVector getReservedRegs(const MachineFunction &MF) const;
72
73   bool isReservedReg(const MachineFunction &MF, unsigned Reg) const;
74
75   const TargetRegisterClass *getPointerRegClass() const;
76
77   std::pair<TargetRegisterClass::iterator,TargetRegisterClass::iterator>
78   getAllocationOrder(const TargetRegisterClass *RC,
79                      unsigned HintType, unsigned HintReg,
80                      const MachineFunction &MF) const;
81
82   unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg,
83                                const MachineFunction &MF) const;
84
85   void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
86                           MachineFunction &MF) const;
87
88   bool hasFP(const MachineFunction &MF) const;
89
90   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
91                                             RegScavenger *RS = NULL) const;
92
93   // Debug information queries.
94   unsigned getRARegister() const;
95   unsigned getFrameRegister(MachineFunction &MF) const;
96
97   // Exception handling queries.
98   unsigned getEHExceptionRegister() const;
99   unsigned getEHHandlerRegister() const;
100
101   int getDwarfRegNum(unsigned RegNum, bool isEH) const;
102
103   bool isLowRegister(unsigned Reg) const;
104
105 private:
106   unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const;
107
108   unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const;
109 };
110
111 struct ARMRegisterInfo : public ARMBaseRegisterInfo {
112 public:
113   ARMRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI);
114
115   /// emitLoadConstPool - Emits a load from constpool to materialize the
116   /// specified immediate.
117   void emitLoadConstPool(MachineBasicBlock &MBB,
118                          MachineBasicBlock::iterator &MBBI,
119                          const TargetInstrInfo *TII, DebugLoc dl,
120                          unsigned DestReg, int Val,
121                          ARMCC::CondCodes Pred = ARMCC::AL,
122                          unsigned PredReg = 0) const;
123
124   /// Code Generation virtual methods...
125   bool isReservedReg(const MachineFunction &MF, unsigned Reg) const;
126
127   bool requiresRegisterScavenging(const MachineFunction &MF) const;
128
129   bool hasReservedCallFrame(MachineFunction &MF) const;
130
131   void eliminateCallFramePseudoInstr(MachineFunction &MF,
132                                      MachineBasicBlock &MBB,
133                                      MachineBasicBlock::iterator I) const;
134
135   void eliminateFrameIndex(MachineBasicBlock::iterator II,
136                            int SPAdj, RegScavenger *RS = NULL) const;
137
138   void emitPrologue(MachineFunction &MF) const;
139   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
140 };
141
142 } // end namespace llvm
143
144 #endif