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 LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H 15 #define LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H 16 17 #include "llvm/Target/TargetFrameLowering.h" 18 19 namespace llvm { 20 21 class X86FrameLowering : public TargetFrameLowering { 22 public: 23 explicit X86FrameLowering(StackDirection D, unsigned StackAl, int LAO) 24 : TargetFrameLowering(StackGrowsDown, StackAl, LAO) {} 25 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); 31 32 void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, 33 MachineBasicBlock::iterator MBBI, 34 DebugLoc DL) const; 35 36 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 37 /// the function. 38 void emitPrologue(MachineFunction &MF) const override; 39 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 40 41 void adjustForSegmentedStacks(MachineFunction &MF) const override; 42 43 void adjustForHiPEPrologue(MachineFunction &MF) const override; 44 45 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 46 RegScavenger *RS = nullptr) const override; 47 48 bool 49 assignCalleeSavedSpillSlots(MachineFunction &MF, 50 const TargetRegisterInfo *TRI, 51 std::vector<CalleeSavedInfo> &CSI) const override; 52 53 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 54 MachineBasicBlock::iterator MI, 55 const std::vector<CalleeSavedInfo> &CSI, 56 const TargetRegisterInfo *TRI) const override; 57 58 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 59 MachineBasicBlock::iterator MI, 60 const std::vector<CalleeSavedInfo> &CSI, 61 const TargetRegisterInfo *TRI) const override; 62 63 bool hasFP(const MachineFunction &MF) const override; 64 bool hasReservedCallFrame(const MachineFunction &MF) const override; 65 bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; 66 bool needsFrameIndexResolution(const MachineFunction &MF) const override; 67 68 int getFrameIndexOffset(const MachineFunction &MF, int FI) const override; 69 int getFrameIndexReference(const MachineFunction &MF, int FI, 70 unsigned &FrameReg) const override; 71 72 int getFrameIndexOffsetFromSP(const MachineFunction &MF, int FI) const; 73 int getFrameIndexReferenceFromSP(const MachineFunction &MF, int FI, 74 unsigned &FrameReg) const override; 75 76 void eliminateCallFramePseudoInstr(MachineFunction &MF, 77 MachineBasicBlock &MBB, 78 MachineBasicBlock::iterator MI) const override; 79 80 private: 81 /// convertArgMovsToPushes - This method tries to convert a call sequence 82 /// that uses sub and mov instructions to put the argument onto the stack 83 /// into a series of pushes. 84 /// Returns true if the transformation succeeded, false if not. 85 bool convertArgMovsToPushes(MachineFunction &MF, 86 MachineBasicBlock &MBB, 87 MachineBasicBlock::iterator I, 88 uint64_t Amount) const; 89 }; 90 91 } // End llvm namespace 92 93 #endif 94