Sink getDwarfRegNum, getLLVMRegNum, getSEHRegNum from TargetRegisterInfo down
[oota-llvm.git] / lib / Target / X86 / X86RegisterInfo.h
1 //===- X86RegisterInfo.h - X86 Register Information Impl --------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the X86 implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86REGISTERINFO_H
15 #define X86REGISTERINFO_H
16
17 #include "llvm/Target/TargetRegisterInfo.h"
18
19 #define GET_REGINFO_HEADER
20 #include "X86GenRegisterInfo.inc"
21
22 namespace llvm {
23   class Type;
24   class TargetInstrInfo;
25   class X86TargetMachine;
26
27 class X86RegisterInfo : public X86GenRegisterInfo {
28 public:
29   X86TargetMachine &TM;
30   const TargetInstrInfo &TII;
31
32 private:
33   /// Is64Bit - Is the target 64-bits.
34   ///
35   bool Is64Bit;
36
37   /// IsWin64 - Is the target on of win64 flavours
38   ///
39   bool IsWin64;
40
41   /// SlotSize - Stack slot size in bytes.
42   ///
43   unsigned SlotSize;
44
45   /// StackPtr - X86 physical register used as stack ptr.
46   ///
47   unsigned StackPtr;
48
49   /// FramePtr - X86 physical register used as frame ptr.
50   ///
51   unsigned FramePtr;
52
53 public:
54   X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
55
56   /// getX86RegNum - Returns the native X86 register number for the given LLVM
57   /// register identifier.
58   static unsigned getX86RegNum(unsigned RegNo);
59
60   // FIXME: This should be tablegen'd like getDwarfRegNum is
61   int getSEHRegNum(unsigned i) const;
62
63   /// getCompactUnwindRegNum - This function maps the register to the number for
64   /// compact unwind encoding. Return -1 if the register isn't valid.
65   int getCompactUnwindRegNum(unsigned RegNum, bool isEH) const;
66
67   /// Code Generation virtual methods...
68   /// 
69
70   /// getMatchingSuperRegClass - Return a subclass of the specified register
71   /// class A so that each register in it has a sub-register of the
72   /// specified sub-register index which is in the specified register class B.
73   virtual const TargetRegisterClass *
74   getMatchingSuperRegClass(const TargetRegisterClass *A,
75                            const TargetRegisterClass *B, unsigned Idx) const;
76
77   const TargetRegisterClass*
78   getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
79
80   /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
81   /// values.
82   const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const;
83
84   /// getCrossCopyRegClass - Returns a legal register class to copy a register
85   /// in the specified class to or from. Returns NULL if it is possible to copy
86   /// between a two registers of the specified class.
87   const TargetRegisterClass *
88   getCrossCopyRegClass(const TargetRegisterClass *RC) const;
89
90   unsigned getRegPressureLimit(const TargetRegisterClass *RC,
91                                MachineFunction &MF) const;
92
93   /// getCalleeSavedRegs - Return a null-terminated list of all of the
94   /// callee-save registers on this target.
95   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
96
97   /// getReservedRegs - Returns a bitset indexed by physical register number
98   /// indicating if a register is a special register that has particular uses and
99   /// should be considered unavailable at all times, e.g. SP, RA. This is used by
100   /// register scavenger to determine what registers are free.
101   BitVector getReservedRegs(const MachineFunction &MF) const;
102
103   bool canRealignStack(const MachineFunction &MF) const;
104
105   bool needsStackRealignment(const MachineFunction &MF) const;
106
107   bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
108                             int &FrameIdx) const;
109
110   void eliminateCallFramePseudoInstr(MachineFunction &MF,
111                                      MachineBasicBlock &MBB,
112                                      MachineBasicBlock::iterator MI) const;
113
114   void eliminateFrameIndex(MachineBasicBlock::iterator MI,
115                            int SPAdj, RegScavenger *RS = NULL) const;
116
117   // Debug information queries.
118   unsigned getFrameRegister(const MachineFunction &MF) const;
119   unsigned getStackRegister() const { return StackPtr; }
120   // FIXME: Move to FrameInfok
121   unsigned getSlotSize() const { return SlotSize; }
122
123   // Exception handling queries.
124   unsigned getEHExceptionRegister() const;
125   unsigned getEHHandlerRegister() const;
126 };
127
128 // getX86SubSuperRegister - X86 utility function. It returns the sub or super
129 // register of a specific X86 register.
130 // e.g. getX86SubSuperRegister(X86::EAX, EVT::i16) return X86:AX
131 unsigned getX86SubSuperRegister(unsigned, EVT, bool High=false);
132
133 } // End llvm namespace
134
135 #endif