Only adjust esp around calls in presence of alloca.
[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 was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the X86 implementation of the MRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86REGISTERINFO_H
15 #define X86REGISTERINFO_H
16
17 #include "llvm/Target/MRegisterInfo.h"
18 #include "X86GenRegisterInfo.h.inc"
19
20 namespace llvm {
21   class Type;
22   class TargetInstrInfo;
23   class X86TargetMachine;
24
25 class X86RegisterInfo : public X86GenRegisterInfo {
26 public:
27   X86TargetMachine &TM;
28   const TargetInstrInfo &TII;
29
30 private:
31   /// Is64Bit - Is the target 64-bits.
32   bool Is64Bit;
33
34   /// SlotSize - Stack slot size in bytes.
35   unsigned SlotSize;
36
37   /// StackPtr - X86 physical register used as stack ptr.
38   unsigned StackPtr;
39
40   /// FramePtr - X86 physical register used as frame ptr.
41   unsigned FramePtr;
42
43 public:
44   X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
45
46   /// Code Generation virtual methods...
47   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
48                                  MachineBasicBlock::iterator MI,
49                                  const std::vector<CalleeSavedInfo> &CSI) const;
50
51   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
52                                    MachineBasicBlock::iterator MI,
53                                  const std::vector<CalleeSavedInfo> &CSI) const;
54
55   void storeRegToStackSlot(MachineBasicBlock &MBB,
56                            MachineBasicBlock::iterator MI,
57                            unsigned SrcReg, int FrameIndex,
58                            const TargetRegisterClass *RC) const;
59
60   void loadRegFromStackSlot(MachineBasicBlock &MBB,
61                             MachineBasicBlock::iterator MI,
62                             unsigned DestReg, int FrameIndex,
63                             const TargetRegisterClass *RC) const;
64
65   void copyRegToReg(MachineBasicBlock &MBB,
66                     MachineBasicBlock::iterator MI,
67                     unsigned DestReg, unsigned SrcReg,
68                     const TargetRegisterClass *RC) const;
69  
70   void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
71                      unsigned DestReg, const MachineInstr *Orig) const;
72
73   /// foldMemoryOperand - If this target supports it, fold a load or store of
74   /// the specified stack slot into the specified machine instruction for the
75   /// specified operand.  If this is possible, the target should perform the
76   /// folding and return true, otherwise it should return false.  If it folds
77   /// the instruction, it is likely that the MachineInstruction the iterator
78   /// references has been changed.
79   MachineInstr* foldMemoryOperand(MachineInstr* MI,
80                                   unsigned OpNum,
81                                   int FrameIndex) const;
82
83   /// getCalleeSavedRegs - Return a null-terminated list of all of the
84   /// callee-save registers on this target.
85   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
86
87   /// getCalleeSavedRegClasses - Return a null-terminated list of the preferred
88   /// register classes to spill each callee-saved register with.  The order and
89   /// length of this list match the getCalleeSavedRegs() list.
90   const TargetRegisterClass* const* getCalleeSavedRegClasses(
91                                      const MachineFunction *MF = 0) const;
92
93   /// getReservedRegs - Returns a bitset indexed by physical register number
94   /// indicating if a register is a special register that has particular uses and
95   /// should be considered unavailable at all times, e.g. SP, RA. This is used by
96   /// register scavenger to determine what registers are free.
97   BitVector getReservedRegs(const MachineFunction &MF) const;
98
99   bool hasFP(const MachineFunction &MF) const;
100
101   bool hasReservedCallFrame(MachineFunction &MF) const;
102
103   void eliminateCallFramePseudoInstr(MachineFunction &MF,
104                                      MachineBasicBlock &MBB,
105                                      MachineBasicBlock::iterator MI) const;
106
107   void eliminateFrameIndex(MachineBasicBlock::iterator MI,
108                            int SPAdj, RegScavenger *RS = NULL) const;
109
110   void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
111
112   void emitPrologue(MachineFunction &MF) const;
113   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
114
115   // Debug information queries.
116   unsigned getRARegister() const;
117   unsigned getFrameRegister(MachineFunction &MF) const;
118   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
119
120   // Exception handling queries.
121   unsigned getEHExceptionRegister() const;
122   unsigned getEHHandlerRegister() const;
123 };
124
125 // getX86SubSuperRegister - X86 utility function. It returns the sub or super
126 // register of a specific X86 register.
127 // e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
128 unsigned getX86SubSuperRegister(unsigned, MVT::ValueType, bool High=false);
129
130 } // End llvm namespace
131
132 #endif