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 LLVM_LIB_TARGET_X86_X86REGISTERINFO_H 00015 #define LLVM_LIB_TARGET_X86_X86REGISTERINFO_H 00016 00017 #include "llvm/Target/TargetRegisterInfo.h" 00018 00019 #define GET_REGINFO_HEADER 00020 #include "X86GenRegisterInfo.inc" 00021 00022 namespace llvm { 00023 class Type; 00024 class TargetInstrInfo; 00025 class X86Subtarget; 00026 00027 class X86RegisterInfo final : public X86GenRegisterInfo { 00028 public: 00029 const X86Subtarget &Subtarget; 00030 00031 private: 00032 /// Is64Bit - Is the target 64-bits. 00033 /// 00034 bool Is64Bit; 00035 00036 /// IsWin64 - Is the target on of win64 flavours 00037 /// 00038 bool IsWin64; 00039 00040 /// SlotSize - Stack slot size in bytes. 00041 /// 00042 unsigned SlotSize; 00043 00044 /// StackPtr - X86 physical register used as stack ptr. 00045 /// 00046 unsigned StackPtr; 00047 00048 /// FramePtr - X86 physical register used as frame ptr. 00049 /// 00050 unsigned FramePtr; 00051 00052 /// BasePtr - X86 physical register used as a base ptr in complex stack 00053 /// frames. I.e., when we need a 3rd base, not just SP and FP, due to 00054 /// variable size stack objects. 00055 unsigned BasePtr; 00056 00057 public: 00058 X86RegisterInfo(const X86Subtarget &STI); 00059 00060 // FIXME: This should be tablegen'd like getDwarfRegNum is 00061 int getSEHRegNum(unsigned i) const; 00062 00063 /// Code Generation virtual methods... 00064 /// 00065 bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override; 00066 00067 /// getMatchingSuperRegClass - Return a subclass of the specified register 00068 /// class A so that each register in it has a sub-register of the 00069 /// specified sub-register index which is in the specified register class B. 00070 const TargetRegisterClass * 00071 getMatchingSuperRegClass(const TargetRegisterClass *A, 00072 const TargetRegisterClass *B, 00073 unsigned Idx) const override; 00074 00075 const TargetRegisterClass * 00076 getSubClassWithSubReg(const TargetRegisterClass *RC, 00077 unsigned Idx) const override; 00078 00079 const TargetRegisterClass* 00080 getLargestLegalSuperClass(const TargetRegisterClass *RC) const override; 00081 00082 /// getPointerRegClass - Returns a TargetRegisterClass used for pointer 00083 /// values. 00084 const TargetRegisterClass * 00085 getPointerRegClass(const MachineFunction &MF, 00086 unsigned Kind = 0) const override; 00087 00088 /// getCrossCopyRegClass - Returns a legal register class to copy a register 00089 /// in the specified class to or from. Returns NULL if it is possible to copy 00090 /// between a two registers of the specified class. 00091 const TargetRegisterClass * 00092 getCrossCopyRegClass(const TargetRegisterClass *RC) const override; 00093 00094 unsigned getRegPressureLimit(const TargetRegisterClass *RC, 00095 MachineFunction &MF) const override; 00096 00097 /// getCalleeSavedRegs - Return a null-terminated list of all of the 00098 /// callee-save registers on this target. 00099 const MCPhysReg * 00100 getCalleeSavedRegs(const MachineFunction* MF) const override; 00101 const uint32_t *getCallPreservedMask(CallingConv::ID) const override; 00102 const uint32_t *getNoPreservedMask() const; 00103 00104 /// getReservedRegs - Returns a bitset indexed by physical register number 00105 /// indicating if a register is a special register that has particular uses and 00106 /// should be considered unavailable at all times, e.g. SP, RA. This is used by 00107 /// register scavenger to determine what registers are free. 00108 BitVector getReservedRegs(const MachineFunction &MF) const override; 00109 00110 bool hasBasePointer(const MachineFunction &MF) const; 00111 00112 bool canRealignStack(const MachineFunction &MF) const; 00113 00114 bool needsStackRealignment(const MachineFunction &MF) const override; 00115 00116 bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, 00117 int &FrameIdx) const override; 00118 00119 void eliminateFrameIndex(MachineBasicBlock::iterator MI, 00120 int SPAdj, unsigned FIOperandNum, 00121 RegScavenger *RS = nullptr) const override; 00122 00123 // Debug information queries. 00124 unsigned getFrameRegister(const MachineFunction &MF) const override; 00125 unsigned getStackRegister() const { return StackPtr; } 00126 unsigned getBaseRegister() const { return BasePtr; } 00127 // FIXME: Move to FrameInfok 00128 unsigned getSlotSize() const { return SlotSize; } 00129 }; 00130 00131 // getX86SubSuperRegister - X86 utility function. It returns the sub or super 00132 // register of a specific X86 register. 00133 // e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX 00134 unsigned getX86SubSuperRegister(unsigned, MVT::SimpleValueType, bool High=false); 00135 00136 //get512BitRegister - X86 utility - returns 512-bit super register 00137 unsigned get512BitSuperRegister(unsigned Reg); 00138 00139 } // End llvm namespace 00140 00141 #endif