[X86] Convert esp-relative movs of function arguments to pushes, step 2
[oota-llvm.git] / lib / Target / X86 / X86FrameLowering.h
1 //===-- X86TargetFrameLowering.h - Define frame lowering for X86 -*- C++ -*-==//\r
2 //\r
3 //                     The LLVM Compiler Infrastructure\r
4 //\r
5 // This file is distributed under the University of Illinois Open Source\r
6 // License. See LICENSE.TXT for details.\r
7 //\r
8 //===----------------------------------------------------------------------===//\r
9 //\r
10 // This class implements X86-specific bits of TargetFrameLowering class.\r
11 //\r
12 //===----------------------------------------------------------------------===//\r
13 \r
14 #ifndef LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H\r
15 #define LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H\r
16 \r
17 #include "llvm/Target/TargetFrameLowering.h"\r
18 \r
19 namespace llvm {\r
20 \r
21 class MCSymbol;\r
22 class X86TargetMachine;\r
23 class X86Subtarget;\r
24 \r
25 class X86FrameLowering : public TargetFrameLowering {\r
26 public:\r
27   explicit X86FrameLowering(StackDirection D, unsigned StackAl, int LAO)\r
28     : TargetFrameLowering(StackGrowsDown, StackAl, LAO) {}\r
29 \r
30   /// Emit a call to the target's stack probe function. This is required for all\r
31   /// large stack allocations on Windows. The caller is required to materialize\r
32   /// the number of bytes to probe in RAX/EAX.\r
33   static void emitStackProbeCall(MachineFunction &MF, MachineBasicBlock &MBB,\r
34                                  MachineBasicBlock::iterator MBBI, DebugLoc DL);\r
35 \r
36   void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,\r
37                                  MachineBasicBlock::iterator MBBI,\r
38                                  DebugLoc DL) const;\r
39 \r
40   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into\r
41   /// the function.\r
42   void emitPrologue(MachineFunction &MF) const override;\r
43   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;\r
44 \r
45   void adjustForSegmentedStacks(MachineFunction &MF) const override;\r
46 \r
47   void adjustForHiPEPrologue(MachineFunction &MF) const override;\r
48 \r
49   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,\r
50                                      RegScavenger *RS = nullptr) const override;\r
51 \r
52   bool\r
53   assignCalleeSavedSpillSlots(MachineFunction &MF,\r
54                               const TargetRegisterInfo *TRI,\r
55                               std::vector<CalleeSavedInfo> &CSI) const override;\r
56 \r
57   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,\r
58                                  MachineBasicBlock::iterator MI,\r
59                                  const std::vector<CalleeSavedInfo> &CSI,\r
60                                  const TargetRegisterInfo *TRI) const override;\r
61 \r
62   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,\r
63                                   MachineBasicBlock::iterator MI,\r
64                                   const std::vector<CalleeSavedInfo> &CSI,\r
65                                   const TargetRegisterInfo *TRI) const override;\r
66 \r
67   bool hasFP(const MachineFunction &MF) const override;\r
68   bool hasReservedCallFrame(const MachineFunction &MF) const override;\r
69   bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;\r
70   bool needsFrameIndexResolution(const MachineFunction &MF) const override;\r
71 \r
72   int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;\r
73   int getFrameIndexReference(const MachineFunction &MF, int FI,\r
74                              unsigned &FrameReg) const override;\r
75 \r
76   int getFrameIndexOffsetFromSP(const MachineFunction &MF, int FI) const;\r
77   int getFrameIndexReferenceFromSP(const MachineFunction &MF, int FI,\r
78                                    unsigned &FrameReg) const override;\r
79 \r
80   void eliminateCallFramePseudoInstr(MachineFunction &MF,\r
81                                  MachineBasicBlock &MBB,\r
82                                  MachineBasicBlock::iterator MI) const override;\r
83 \r
84 private:\r
85   /// convertArgMovsToPushes - This method tries to convert a call sequence\r
86   /// that uses sub and mov instructions to put the argument onto the stack\r
87   /// into a series of pushes.\r
88   /// Returns true if the transformation succeeded, false if not.\r
89   bool convertArgMovsToPushes(MachineFunction &MF, \r
90                               MachineBasicBlock &MBB,\r
91                               MachineBasicBlock::iterator I, \r
92                               uint64_t Amount) const;\r
93 };\r
94 \r
95 } // End llvm namespace\r
96 \r
97 #endif\r