1 //===-- ARMBaseRegisterInfo.h - ARM Register Information Impl ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the base ARM implementation of TargetRegisterInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMBASEREGISTERINFO_H
15 #define ARMBASEREGISTERINFO_H
18 #include "llvm/Target/TargetRegisterInfo.h"
20 #define GET_REGINFO_HEADER
21 #include "ARMGenRegisterInfo.inc"
25 class ARMBaseInstrInfo;
28 /// Register allocation hints.
36 /// isARMArea1Register - Returns true if the register is a low register (r0-r7)
37 /// or a stack/pc register that we should push/pop.
38 static inline bool isARMArea1Register(unsigned Reg, bool isIOS) {
41 case R0: case R1: case R2: case R3:
42 case R4: case R5: case R6: case R7:
43 case LR: case SP: case PC:
45 case R8: case R9: case R10: case R11:
46 // For iOS we want r7 and lr to be next to each other.
53 static inline bool isARMArea2Register(unsigned Reg, bool isIOS) {
56 case R8: case R9: case R10: case R11:
57 // iOS has this second area.
64 static inline bool isARMArea3Register(unsigned Reg, bool isIOS) {
67 case D15: case D14: case D13: case D12:
68 case D11: case D10: case D9: case D8:
75 class ARMBaseRegisterInfo : public ARMGenRegisterInfo {
77 const ARMBaseInstrInfo &TII;
78 const ARMSubtarget &STI;
80 /// FramePtr - ARM physical register used as frame ptr.
83 /// BasePtr - ARM physical register used as a base ptr in complex stack
84 /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
85 /// variable size stack objects.
88 // Can be only subclassed.
89 explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii,
90 const ARMSubtarget &STI);
92 // Return the opcode that implements 'Op', or 0 if no opcode
93 unsigned getOpcode(int Op) const;
96 /// Code Generation virtual methods...
97 const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
98 const uint32_t *getCallPreservedMask(CallingConv::ID) const;
99 const uint32_t *getThisReturnPreservedMask(CallingConv::ID) const;
100 const uint32_t *getNoPreservedMask() const;
102 BitVector getReservedRegs(const MachineFunction &MF) const;
104 const TargetRegisterClass*
105 getPointerRegClass(const MachineFunction &MF, unsigned Kind = 0) const;
106 const TargetRegisterClass*
107 getCrossCopyRegClass(const TargetRegisterClass *RC) const;
109 const TargetRegisterClass*
110 getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
112 unsigned getRegPressureLimit(const TargetRegisterClass *RC,
113 MachineFunction &MF) const;
115 void getRegAllocationHints(unsigned VirtReg,
116 ArrayRef<MCPhysReg> Order,
117 SmallVectorImpl<MCPhysReg> &Hints,
118 const MachineFunction &MF,
119 const VirtRegMap *VRM) const;
121 void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
122 MachineFunction &MF) const;
124 virtual bool avoidWriteAfterWrite(const TargetRegisterClass *RC) const;
126 bool hasBasePointer(const MachineFunction &MF) const;
128 bool canRealignStack(const MachineFunction &MF) const;
129 bool needsStackRealignment(const MachineFunction &MF) const;
130 int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const;
131 bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const;
132 void materializeFrameBaseRegister(MachineBasicBlock *MBB,
133 unsigned BaseReg, int FrameIdx,
134 int64_t Offset) const;
135 void resolveFrameIndex(MachineBasicBlock::iterator I,
136 unsigned BaseReg, int64_t Offset) const;
137 bool isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const;
139 bool cannotEliminateFrame(const MachineFunction &MF) const;
141 // Debug information queries.
142 unsigned getFrameRegister(const MachineFunction &MF) const;
143 unsigned getBaseRegister() const { return BasePtr; }
145 // Exception handling queries.
146 unsigned getEHExceptionRegister() const;
147 unsigned getEHHandlerRegister() const;
149 bool isLowRegister(unsigned Reg) const;
152 /// emitLoadConstPool - Emits a load from constpool to materialize the
153 /// specified immediate.
154 virtual void emitLoadConstPool(MachineBasicBlock &MBB,
155 MachineBasicBlock::iterator &MBBI,
157 unsigned DestReg, unsigned SubIdx,
159 ARMCC::CondCodes Pred = ARMCC::AL,
160 unsigned PredReg = 0,
161 unsigned MIFlags = MachineInstr::NoFlags)const;
163 /// Code Generation virtual methods...
164 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const;
166 virtual bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const;
168 virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const;
170 virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const;
172 virtual void eliminateFrameIndex(MachineBasicBlock::iterator II,
173 int SPAdj, unsigned FIOperandNum,
174 RegScavenger *RS = NULL) const;
177 } // end namespace llvm