Move callee-saved regs spills / reloads to TFI
[oota-llvm.git] / lib / Target / X86 / X86FrameInfo.h
1 //===-- X86TargetFrameInfo.h - Define TargetFrameInfo for X86 ---*- 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 //
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86_FRAMEINFO_H
15 #define X86_FRAMEINFO_H
16
17 #include "X86Subtarget.h"
18 #include "llvm/Target/TargetFrameInfo.h"
19
20 namespace llvm {
21   class MCSymbol;
22   class X86TargetMachine;
23
24 class X86FrameInfo : public TargetFrameInfo {
25   const X86TargetMachine &TM;
26   const X86Subtarget &STI;
27 public:
28   explicit X86FrameInfo(const X86TargetMachine &tm, const X86Subtarget &sti)
29     : TargetFrameInfo(StackGrowsDown,
30                       sti.getStackAlignment(),
31                       (sti.isTargetWin64() ? -40 : (sti.is64Bit() ? -8 : -4))),
32       TM(tm), STI(sti) {
33   }
34
35   void emitCalleeSavedFrameMoves(MachineFunction &MF, MCSymbol *Label,
36                                  unsigned FramePtr) const;
37
38   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
39   /// the function.
40   void emitPrologue(MachineFunction &MF) const;
41   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
42
43   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
44                                  MachineBasicBlock::iterator MI,
45                                  const std::vector<CalleeSavedInfo> &CSI,
46                                  const TargetRegisterInfo *TRI) const;
47
48 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
49                                  MachineBasicBlock::iterator MI,
50                                  const std::vector<CalleeSavedInfo> &CSI,
51                                  const TargetRegisterInfo *TRI) const;
52
53   bool hasFP(const MachineFunction &MF) const;
54   bool hasReservedCallFrame(const MachineFunction &MF) const;
55
56   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
57   int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
58 };
59
60 } // End llvm namespace
61
62 #endif