Move getPreferredAlignmentLog from AsmPrinter to TargetData
[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 struct X86RegisterInfo : public X86GenRegisterInfo {
26   X86TargetMachine &TM;
27   const TargetInstrInfo &TII;
28 private:
29   /// Is64Bit - Is the target 64-bits.
30   bool Is64Bit;
31
32   /// SlotSize - Stack slot size in bytes.
33   unsigned SlotSize;
34
35   /// StackPtr - X86 physical register used as stack ptr.
36   unsigned StackPtr;
37
38   /// FramePtr - X86 physical register used as frame ptr.
39   unsigned FramePtr;
40
41 public:
42   X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
43
44   /// Code Generation virtual methods...
45   void storeRegToStackSlot(MachineBasicBlock &MBB,
46                            MachineBasicBlock::iterator MI,
47                            unsigned SrcReg, int FrameIndex,
48                            const TargetRegisterClass *RC) const;
49
50   void loadRegFromStackSlot(MachineBasicBlock &MBB,
51                             MachineBasicBlock::iterator MI,
52                             unsigned DestReg, int FrameIndex,
53                             const TargetRegisterClass *RC) const;
54
55   void copyRegToReg(MachineBasicBlock &MBB,
56                     MachineBasicBlock::iterator MI,
57                     unsigned DestReg, unsigned SrcReg,
58                     const TargetRegisterClass *RC) const;
59
60   /// foldMemoryOperand - If this target supports it, fold a load or store of
61   /// the specified stack slot into the specified machine instruction for the
62   /// specified operand.  If this is possible, the target should perform the
63   /// folding and return true, otherwise it should return false.  If it folds
64   /// the instruction, it is likely that the MachineInstruction the iterator
65   /// references has been changed.
66   MachineInstr* foldMemoryOperand(MachineInstr* MI,
67                                   unsigned OpNum,
68                                   int FrameIndex) const;
69
70   /// getCalleeSaveRegs - Return a null-terminated list of all of the
71   /// callee-save registers on this target.
72   const unsigned *getCalleeSaveRegs() const;
73
74   /// getCalleeSaveRegClasses - Return a null-terminated list of the preferred
75   /// register classes to spill each callee-saved register with.  The order and
76   /// length of this list match the getCalleeSaveRegs() list.
77   const TargetRegisterClass* const* getCalleeSaveRegClasses() const;
78
79   void eliminateCallFramePseudoInstr(MachineFunction &MF,
80                                      MachineBasicBlock &MBB,
81                                      MachineBasicBlock::iterator MI) const;
82
83   void eliminateFrameIndex(MachineBasicBlock::iterator MI) const;
84
85   void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
86
87   void emitPrologue(MachineFunction &MF) const;
88   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
89
90   // Debug information queries.
91   unsigned getRARegister() const;
92   unsigned getFrameRegister(MachineFunction &MF) const;
93 };
94
95 // getX86SubSuperRegister - X86 utility function. It returns the sub or super
96 // register of a specific X86 register.
97 // e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
98 unsigned getX86SubSuperRegister(unsigned, MVT::ValueType, bool High=false);
99
100 } // End llvm namespace
101
102 #endif