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