Replace PROLOG_LABEL with a new CFI_INSTRUCTION.
[oota-llvm.git] / lib / Target / X86 / X86FrameLowering.h
1 //===-- X86TargetFrameLowering.h - Define frame lowering 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 // This class implements X86-specific bits of TargetFrameLowering class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86_FRAMELOWERING_H
15 #define X86_FRAMELOWERING_H
16
17 #include "X86Subtarget.h"
18 #include "llvm/MC/MCDwarf.h"
19 #include "llvm/Target/TargetFrameLowering.h"
20
21 namespace llvm {
22
23 class MCSymbol;
24 class X86TargetMachine;
25
26 class X86FrameLowering : public TargetFrameLowering {
27   const X86TargetMachine &TM;
28   const X86Subtarget &STI;
29 public:
30   explicit X86FrameLowering(const X86TargetMachine &tm, const X86Subtarget &sti)
31     : TargetFrameLowering(StackGrowsDown,
32                           sti.getStackAlignment(),
33                           (sti.is64Bit() ? -8 : -4)),
34       TM(tm), STI(sti) {
35   }
36
37   void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
38                                  MachineBasicBlock::iterator MBBI, DebugLoc DL,
39                                  unsigned FramePtr) const;
40
41   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
42   /// the function.
43   void emitPrologue(MachineFunction &MF) const;
44   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
45
46   void adjustForSegmentedStacks(MachineFunction &MF) const;
47
48   void adjustForHiPEPrologue(MachineFunction &MF) const;
49
50   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
51                                             RegScavenger *RS = NULL) const;
52
53   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
54                                  MachineBasicBlock::iterator MI,
55                                  const std::vector<CalleeSavedInfo> &CSI,
56                                  const TargetRegisterInfo *TRI) const;
57
58   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
59                                    MachineBasicBlock::iterator MI,
60                                    const std::vector<CalleeSavedInfo> &CSI,
61                                    const TargetRegisterInfo *TRI) const;
62
63   bool hasFP(const MachineFunction &MF) const;
64   bool hasReservedCallFrame(const MachineFunction &MF) const;
65
66   int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
67   int getFrameIndexReference(const MachineFunction &MF, int FI,
68                              unsigned &FrameReg) const;
69
70   void eliminateCallFramePseudoInstr(MachineFunction &MF,
71                                      MachineBasicBlock &MBB,
72                                      MachineBasicBlock::iterator MI) const;
73 };
74
75 } // End llvm namespace
76
77 #endif