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"
19 #include "ARMGenRegisterInfo.h.inc"
23 class ARMBaseInstrInfo;
26 /// Register allocation hints.
34 /// isARMLowRegister - Returns true if the register is low register r0-r7.
36 static inline bool isARMLowRegister(unsigned Reg) {
39 case R0: case R1: case R2: case R3:
40 case R4: case R5: case R6: case R7:
47 class ARMBaseRegisterInfo : public ARMGenRegisterInfo {
49 const ARMBaseInstrInfo &TII;
50 const ARMSubtarget &STI;
52 /// FramePtr - ARM physical register used as frame ptr.
55 // Can be only subclassed.
56 explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii,
57 const ARMSubtarget &STI);
59 // Return the opcode that implements 'Op', or 0 if no opcode
60 unsigned getOpcode(int Op) const;
63 /// getRegisterNumbering - Given the enum value for some register, e.g.
64 /// ARM::LR, return the number that it corresponds to (e.g. 14). It
65 /// also returns true in isSPVFP if the register is a single precision
67 static unsigned getRegisterNumbering(unsigned RegEnum, bool *isSPVFP = 0);
69 /// Code Generation virtual methods...
70 const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
72 BitVector getReservedRegs(const MachineFunction &MF) const;
74 /// getMatchingSuperRegClass - Return a subclass of the specified register
75 /// class A so that each register in it has a sub-register of the
76 /// specified sub-register index which is in the specified register class B.
77 virtual const TargetRegisterClass *
78 getMatchingSuperRegClass(const TargetRegisterClass *A,
79 const TargetRegisterClass *B, unsigned Idx) const;
81 /// canCombineSubRegIndices - Given a register class and a list of
82 /// subregister indices, return true if it's possible to combine the
83 /// subregister indices into one that corresponds to a larger
84 /// subregister. Return the new subregister index by reference. Note the
85 /// new index may be zero if the given subregisters can be combined to
86 /// form the whole register.
87 virtual bool canCombineSubRegIndices(const TargetRegisterClass *RC,
88 SmallVectorImpl<unsigned> &SubIndices,
89 unsigned &NewSubIdx) const;
91 const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const;
93 std::pair<TargetRegisterClass::iterator,TargetRegisterClass::iterator>
94 getAllocationOrder(const TargetRegisterClass *RC,
95 unsigned HintType, unsigned HintReg,
96 const MachineFunction &MF) const;
98 unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg,
99 const MachineFunction &MF) const;
101 void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
102 MachineFunction &MF) const;
104 bool hasFP(const MachineFunction &MF) const;
106 bool canRealignStack(const MachineFunction &MF) const;
107 bool needsStackRealignment(const MachineFunction &MF) const;
108 bool needsFrameBaseReg(MachineInstr *MI, unsigned operand) const;
110 bool cannotEliminateFrame(const MachineFunction &MF) const;
112 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
113 RegScavenger *RS = NULL) const;
115 // Debug information queries.
116 unsigned getRARegister() const;
117 unsigned getFrameRegister(const MachineFunction &MF) const;
118 int getFrameIndexReference(const MachineFunction &MF, int FI,
119 unsigned &FrameReg) const;
120 int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
121 unsigned &FrameReg, int SPAdj) const;
122 int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
124 // Exception handling queries.
125 unsigned getEHExceptionRegister() const;
126 unsigned getEHHandlerRegister() const;
128 int getDwarfRegNum(unsigned RegNum, bool isEH) const;
130 bool isLowRegister(unsigned Reg) const;
133 /// emitLoadConstPool - Emits a load from constpool to materialize the
134 /// specified immediate.
135 virtual void emitLoadConstPool(MachineBasicBlock &MBB,
136 MachineBasicBlock::iterator &MBBI,
138 unsigned DestReg, unsigned SubIdx,
140 ARMCC::CondCodes Pred = ARMCC::AL,
141 unsigned PredReg = 0) const;
143 /// Code Generation virtual methods...
144 virtual bool isReservedReg(const MachineFunction &MF, unsigned Reg) const;
146 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const;
148 virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const;
150 virtual bool hasReservedCallFrame(const MachineFunction &MF) const;
151 virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const;
153 virtual void eliminateCallFramePseudoInstr(MachineFunction &MF,
154 MachineBasicBlock &MBB,
155 MachineBasicBlock::iterator I) const;
157 virtual unsigned eliminateFrameIndex(MachineBasicBlock::iterator II,
158 int SPAdj, FrameIndexValue *Value = NULL,
159 RegScavenger *RS = NULL) const;
161 virtual void emitPrologue(MachineFunction &MF) const;
162 virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
165 unsigned estimateRSStackSizeLimit(MachineFunction &MF) const;
167 unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const;
169 unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const;
172 } // end namespace llvm