LLVM API Documentation

X86RegisterInfo.h

Go to the documentation of this file.
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_16BIT = 2, SUBREG_32BIT = 3
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   /// getCrossCopyRegClass - Returns a legal register class to copy a register
00097   /// in the specified class to or from. Returns NULL if it is possible to copy
00098   /// between a two registers of the specified class.
00099   const TargetRegisterClass *
00100   getCrossCopyRegClass(const TargetRegisterClass *RC) const;
00101 
00102   /// getCalleeSavedRegs - Return a null-terminated list of all of the
00103   /// callee-save registers on this target.
00104   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
00105 
00106   /// getCalleeSavedRegClasses - Return a null-terminated list of the preferred
00107   /// register classes to spill each callee-saved register with.  The order and
00108   /// length of this list match the getCalleeSavedRegs() list.
00109   const TargetRegisterClass* const*
00110   getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
00111 
00112   /// getReservedRegs - Returns a bitset indexed by physical register number
00113   /// indicating if a register is a special register that has particular uses and
00114   /// should be considered unavailable at all times, e.g. SP, RA. This is used by
00115   /// register scavenger to determine what registers are free.
00116   BitVector getReservedRegs(const MachineFunction &MF) const;
00117 
00118   bool hasFP(const MachineFunction &MF) const;
00119 
00120   bool needsStackRealignment(const MachineFunction &MF) const;
00121 
00122   bool hasReservedCallFrame(MachineFunction &MF) const;
00123 
00124   void eliminateCallFramePseudoInstr(MachineFunction &MF,
00125                                      MachineBasicBlock &MBB,
00126                                      MachineBasicBlock::iterator MI) const;
00127 
00128   void eliminateFrameIndex(MachineBasicBlock::iterator MI,
00129                            int SPAdj, RegScavenger *RS = NULL) const;
00130 
00131   void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
00132   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
00133                                             RegScavenger *RS = NULL) const;
00134 
00135   void emitPrologue(MachineFunction &MF) const;
00136   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
00137 
00138   void emitFrameMoves(MachineFunction &MF,
00139                       unsigned FrameLabelId, unsigned ReadyLabelId) const;
00140 
00141   // Debug information queries.
00142   unsigned getRARegister() const;
00143   unsigned getFrameRegister(MachineFunction &MF) const;
00144   int getFrameIndexOffset(MachineFunction &MF, int FI) const;
00145   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
00146 
00147   // Exception handling queries.
00148   unsigned getEHExceptionRegister() const;
00149   unsigned getEHHandlerRegister() const;
00150 };
00151 
00152 // getX86SubSuperRegister - X86 utility function. It returns the sub or super
00153 // register of a specific X86 register.
00154 // e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
00155 unsigned getX86SubSuperRegister(unsigned, MVT, bool High=false);
00156 
00157 } // End llvm namespace
00158 
00159 #endif