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 unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
99 BitVector getReservedRegs(const MachineFunction &MF) const;
101 /// canCombineSubRegIndices - Given a register class and a list of
102 /// subregister indices, return true if it's possible to combine the
103 /// subregister indices into one that corresponds to a larger
104 /// subregister. Return the new subregister index by reference. Note the
105 /// new index may be zero if the given subregisters can be combined to
106 /// form the whole register.
107 virtual bool canCombineSubRegIndices(const TargetRegisterClass *RC,
108 SmallVectorImpl<unsigned> &SubIndices,
109 unsigned &NewSubIdx) const;
111 const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const;
112 const TargetRegisterClass*
113 getCrossCopyRegClass(const TargetRegisterClass *RC) const;
115 const TargetRegisterClass*
116 getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
118 unsigned getRegPressureLimit(const TargetRegisterClass *RC,
119 MachineFunction &MF) const;
121 ArrayRef<unsigned> getRawAllocationOrder(const TargetRegisterClass *RC,
122 unsigned HintType, unsigned HintReg,
123 const MachineFunction &MF) const;
125 unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg,
126 const MachineFunction &MF) const;
128 void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
129 MachineFunction &MF) const;
131 virtual bool avoidWriteAfterWrite(const TargetRegisterClass *RC) const;
133 bool hasBasePointer(const MachineFunction &MF) const;
135 bool canRealignStack(const MachineFunction &MF) const;
136 bool needsStackRealignment(const MachineFunction &MF) const;
137 int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const;
138 bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const;
139 void materializeFrameBaseRegister(MachineBasicBlock *MBB,
140 unsigned BaseReg, int FrameIdx,
141 int64_t Offset) const;
142 void resolveFrameIndex(MachineBasicBlock::iterator I,
143 unsigned BaseReg, int64_t Offset) const;
144 bool isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const;
146 bool cannotEliminateFrame(const MachineFunction &MF) const;
148 // Debug information queries.
149 unsigned getFrameRegister(const MachineFunction &MF) const;
150 unsigned getBaseRegister() const { return BasePtr; }
152 // Exception handling queries.
153 unsigned getEHExceptionRegister() const;
154 unsigned getEHHandlerRegister() const;
156 bool isLowRegister(unsigned Reg) const;
159 /// emitLoadConstPool - Emits a load from constpool to materialize the
160 /// specified immediate.
161 virtual void emitLoadConstPool(MachineBasicBlock &MBB,
162 MachineBasicBlock::iterator &MBBI,
164 unsigned DestReg, unsigned SubIdx,
166 ARMCC::CondCodes Pred = ARMCC::AL,
167 unsigned PredReg = 0,
168 unsigned MIFlags = MachineInstr::NoFlags)const;
170 /// Code Generation virtual methods...
171 virtual bool isReservedReg(const MachineFunction &MF, unsigned Reg) const;
173 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const;
175 virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const;
177 virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const;
179 virtual void eliminateCallFramePseudoInstr(MachineFunction &MF,
180 MachineBasicBlock &MBB,
181 MachineBasicBlock::iterator I) const;
183 virtual void eliminateFrameIndex(MachineBasicBlock::iterator II,
184 int SPAdj, RegScavenger *RS = NULL) const;
187 unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const;
189 unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const;
192 } // end namespace llvm