LLVM API Documentation
00001 //===- ARMBaseRegisterInfo.h - ARM Register Information Impl ----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the base ARM implementation of TargetRegisterInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef ARMBASEREGISTERINFO_H 00015 #define ARMBASEREGISTERINFO_H 00016 00017 #include "ARM.h" 00018 #include "llvm/Target/TargetRegisterInfo.h" 00019 #include "ARMGenRegisterInfo.h.inc" 00020 00021 namespace llvm { 00022 class ARMSubtarget; 00023 class ARMBaseInstrInfo; 00024 class Type; 00025 00026 /// Register allocation hints. 00027 namespace ARMRI { 00028 enum { 00029 RegPairOdd = 1, 00030 RegPairEven = 2 00031 }; 00032 } 00033 00034 /// isARMLowRegister - Returns true if the register is low register r0-r7. 00035 /// 00036 static inline bool isARMLowRegister(unsigned Reg) { 00037 using namespace ARM; 00038 switch (Reg) { 00039 case R0: case R1: case R2: case R3: 00040 case R4: case R5: case R6: case R7: 00041 return true; 00042 default: 00043 return false; 00044 } 00045 } 00046 00047 struct ARMBaseRegisterInfo : public ARMGenRegisterInfo { 00048 protected: 00049 const ARMBaseInstrInfo &TII; 00050 const ARMSubtarget &STI; 00051 00052 /// FramePtr - ARM physical register used as frame ptr. 00053 unsigned FramePtr; 00054 00055 // Can be only subclassed. 00056 explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii, 00057 const ARMSubtarget &STI); 00058 00059 // Return the opcode that implements 'Op', or 0 if no opcode 00060 unsigned getOpcode(int Op) const; 00061 00062 public: 00063 /// getRegisterNumbering - Given the enum value for some register, e.g. 00064 /// ARM::LR, return the number that it corresponds to (e.g. 14). It 00065 /// also returns true in isSPVFP if the register is a single precision 00066 /// VFP register. 00067 static unsigned getRegisterNumbering(unsigned RegEnum, bool *isSPVFP = 0); 00068 00069 /// Code Generation virtual methods... 00070 const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const; 00071 00072 const TargetRegisterClass* const* 00073 getCalleeSavedRegClasses(const MachineFunction *MF = 0) const; 00074 00075 BitVector getReservedRegs(const MachineFunction &MF) const; 00076 00077 const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const; 00078 00079 std::pair<TargetRegisterClass::iterator,TargetRegisterClass::iterator> 00080 getAllocationOrder(const TargetRegisterClass *RC, 00081 unsigned HintType, unsigned HintReg, 00082 const MachineFunction &MF) const; 00083 00084 unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, 00085 const MachineFunction &MF) const; 00086 00087 void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, 00088 MachineFunction &MF) const; 00089 00090 bool hasFP(const MachineFunction &MF) const; 00091 00092 bool cannotEliminateFrame(const MachineFunction &MF) const; 00093 00094 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 00095 RegScavenger *RS = NULL) const; 00096 00097 // Debug information queries. 00098 unsigned getRARegister() const; 00099 unsigned getFrameRegister(MachineFunction &MF) const; 00100 00101 // Exception handling queries. 00102 unsigned getEHExceptionRegister() const; 00103 unsigned getEHHandlerRegister() const; 00104 00105 int getDwarfRegNum(unsigned RegNum, bool isEH) const; 00106 00107 bool isLowRegister(unsigned Reg) const; 00108 00109 00110 /// emitLoadConstPool - Emits a load from constpool to materialize the 00111 /// specified immediate. 00112 virtual void emitLoadConstPool(MachineBasicBlock &MBB, 00113 MachineBasicBlock::iterator &MBBI, 00114 DebugLoc dl, 00115 unsigned DestReg, unsigned SubIdx, 00116 int Val, 00117 ARMCC::CondCodes Pred = ARMCC::AL, 00118 unsigned PredReg = 0) const; 00119 00120 /// Code Generation virtual methods... 00121 virtual bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; 00122 00123 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const; 00124 00125 virtual bool hasReservedCallFrame(MachineFunction &MF) const; 00126 00127 virtual void eliminateCallFramePseudoInstr(MachineFunction &MF, 00128 MachineBasicBlock &MBB, 00129 MachineBasicBlock::iterator I) const; 00130 00131 virtual void eliminateFrameIndex(MachineBasicBlock::iterator II, 00132 int SPAdj, RegScavenger *RS = NULL) const; 00133 00134 virtual void emitPrologue(MachineFunction &MF) const; 00135 virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; 00136 00137 private: 00138 unsigned estimateRSStackSizeLimit(MachineFunction &MF) const; 00139 00140 unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; 00141 00142 unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const; 00143 }; 00144 00145 } // end namespace llvm 00146 00147 #endif