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