LLVM API Documentation
00001 //===- X86RegisterInfo.h - X86 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 X86 implementation of the TargetRegisterInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef X86REGISTERINFO_H 00015 #define X86REGISTERINFO_H 00016 00017 #include "llvm/Target/TargetRegisterInfo.h" 00018 #include "X86GenRegisterInfo.h.inc" 00019 00020 namespace llvm { 00021 class Type; 00022 class TargetInstrInfo; 00023 class X86TargetMachine; 00024 00025 /// N86 namespace - Native X86 register numbers 00026 /// 00027 namespace N86 { 00028 enum { 00029 EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 7 00030 }; 00031 } 00032 00033 namespace X86 { 00034 /// SubregIndex - The index of various sized subregister classes. Note that 00035 /// these indices must be kept in sync with the class indices in the 00036 /// X86RegisterInfo.td file. 00037 enum SubregIndex { 00038 SUBREG_8BIT = 1, SUBREG_8BIT_HI = 2, SUBREG_16BIT = 3, SUBREG_32BIT = 4 00039 }; 00040 } 00041 00042 /// DWARFFlavour - Flavour of dwarf regnumbers 00043 /// 00044 namespace DWARFFlavour { 00045 enum { 00046 X86_64 = 0, X86_32_DarwinEH = 1, X86_32_Generic = 2 00047 }; 00048 } 00049 00050 class X86RegisterInfo : public X86GenRegisterInfo { 00051 public: 00052 X86TargetMachine &TM; 00053 const TargetInstrInfo &TII; 00054 00055 private: 00056 /// Is64Bit - Is the target 64-bits. 00057 /// 00058 bool Is64Bit; 00059 00060 /// IsWin64 - Is the target on of win64 flavours 00061 /// 00062 bool IsWin64; 00063 00064 /// SlotSize - Stack slot size in bytes. 00065 /// 00066 unsigned SlotSize; 00067 00068 /// StackAlign - Default stack alignment. 00069 /// 00070 unsigned StackAlign; 00071 00072 /// StackPtr - X86 physical register used as stack ptr. 00073 /// 00074 unsigned StackPtr; 00075 00076 /// FramePtr - X86 physical register used as frame ptr. 00077 /// 00078 unsigned FramePtr; 00079 00080 public: 00081 X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii); 00082 00083 /// getX86RegNum - Returns the native X86 register number for the given LLVM 00084 /// register identifier. 00085 static unsigned getX86RegNum(unsigned RegNo); 00086 00087 unsigned getStackAlignment() const { return StackAlign; } 00088 00089 /// getDwarfRegNum - allows modification of X86GenRegisterInfo::getDwarfRegNum 00090 /// (created by TableGen) for target dependencies. 00091 int getDwarfRegNum(unsigned RegNum, bool isEH) const; 00092 00093 /// Code Generation virtual methods... 00094 /// 00095 00096 /// getMatchingSuperRegClass - Return a subclass of the specified register 00097 /// class A so that each register in it has a sub-register of the 00098 /// specified sub-register index which is in the specified register class B. 00099 virtual const TargetRegisterClass * 00100 getMatchingSuperRegClass(const TargetRegisterClass *A, 00101 const TargetRegisterClass *B, unsigned Idx) const; 00102 00103 /// getPointerRegClass - Returns a TargetRegisterClass used for pointer 00104 /// values. 00105 const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const; 00106 00107 /// getCrossCopyRegClass - Returns a legal register class to copy a register 00108 /// in the specified class to or from. Returns NULL if it is possible to copy 00109 /// between a two registers of the specified class. 00110 const TargetRegisterClass * 00111 getCrossCopyRegClass(const TargetRegisterClass *RC) const; 00112 00113 /// getCalleeSavedRegs - Return a null-terminated list of all of the 00114 /// callee-save registers on this target. 00115 const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const; 00116 00117 /// getCalleeSavedRegClasses - Return a null-terminated list of the preferred 00118 /// register classes to spill each callee-saved register with. The order and 00119 /// length of this list match the getCalleeSavedRegs() list. 00120 const TargetRegisterClass* const* 00121 getCalleeSavedRegClasses(const MachineFunction *MF = 0) const; 00122 00123 /// getReservedRegs - Returns a bitset indexed by physical register number 00124 /// indicating if a register is a special register that has particular uses and 00125 /// should be considered unavailable at all times, e.g. SP, RA. This is used by 00126 /// register scavenger to determine what registers are free. 00127 BitVector getReservedRegs(const MachineFunction &MF) const; 00128 00129 bool hasFP(const MachineFunction &MF) const; 00130 00131 bool needsStackRealignment(const MachineFunction &MF) const; 00132 00133 bool hasReservedCallFrame(MachineFunction &MF) const; 00134 00135 bool hasReservedSpillSlot(MachineFunction &MF, unsigned Reg, 00136 int &FrameIdx) const; 00137 00138 void eliminateCallFramePseudoInstr(MachineFunction &MF, 00139 MachineBasicBlock &MBB, 00140 MachineBasicBlock::iterator MI) const; 00141 00142 void eliminateFrameIndex(MachineBasicBlock::iterator MI, 00143 int SPAdj, RegScavenger *RS = NULL) const; 00144 00145 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 00146 RegScavenger *RS = NULL) const; 00147 00148 void emitCalleeSavedFrameMoves(MachineFunction &MF, unsigned LabelId, 00149 unsigned FramePtr) const; 00150 void emitPrologue(MachineFunction &MF) const; 00151 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; 00152 00153 // Debug information queries. 00154 unsigned getRARegister() const; 00155 unsigned getFrameRegister(MachineFunction &MF) const; 00156 int getFrameIndexOffset(MachineFunction &MF, int FI) const; 00157 void getInitialFrameState(std::vector<MachineMove> &Moves) const; 00158 00159 // Exception handling queries. 00160 unsigned getEHExceptionRegister() const; 00161 unsigned getEHHandlerRegister() const; 00162 }; 00163 00164 // getX86SubSuperRegister - X86 utility function. It returns the sub or super 00165 // register of a specific X86 register. 00166 // e.g. getX86SubSuperRegister(X86::EAX, EVT::i16) return X86:AX 00167 unsigned getX86SubSuperRegister(unsigned, EVT, bool High=false); 00168 00169 } // End llvm namespace 00170 00171 #endif