Michael Kuperstein | e86aa9a | 2015-02-01 16:15:07 +0000 | [diff] [blame] | 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 MCSymbol; |
| 22 | class X86TargetMachine; |
| 23 | class X86Subtarget; |
| 24 | |
| 25 | class X86FrameLowering : public TargetFrameLowering { |
| 26 | public: |
| 27 | explicit X86FrameLowering(StackDirection D, unsigned StackAl, int LAO) |
| 28 | : TargetFrameLowering(StackGrowsDown, StackAl, LAO) {} |
| 29 | |
| 30 | /// Emit a call to the target's stack probe function. This is required for all |
| 31 | /// large stack allocations on Windows. The caller is required to materialize |
| 32 | /// the number of bytes to probe in RAX/EAX. |
| 33 | static void emitStackProbeCall(MachineFunction &MF, MachineBasicBlock &MBB, |
| 34 | MachineBasicBlock::iterator MBBI, DebugLoc DL); |
| 35 | |
| 36 | void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, |
| 37 | MachineBasicBlock::iterator MBBI, |
| 38 | DebugLoc DL) const; |
| 39 | |
| 40 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 41 | /// the function. |
| 42 | void emitPrologue(MachineFunction &MF) const override; |
| 43 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 44 | |
| 45 | void adjustForSegmentedStacks(MachineFunction &MF) const override; |
| 46 | |
| 47 | void adjustForHiPEPrologue(MachineFunction &MF) const override; |
| 48 | |
| 49 | void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, |
| 50 | RegScavenger *RS = nullptr) const override; |
| 51 | |
| 52 | bool |
| 53 | assignCalleeSavedSpillSlots(MachineFunction &MF, |
| 54 | const TargetRegisterInfo *TRI, |
| 55 | std::vector<CalleeSavedInfo> &CSI) const override; |
| 56 | |
| 57 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 58 | MachineBasicBlock::iterator MI, |
| 59 | const std::vector<CalleeSavedInfo> &CSI, |
| 60 | const TargetRegisterInfo *TRI) const override; |
| 61 | |
| 62 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 63 | MachineBasicBlock::iterator MI, |
| 64 | const std::vector<CalleeSavedInfo> &CSI, |
| 65 | const TargetRegisterInfo *TRI) const override; |
| 66 | |
| 67 | bool hasFP(const MachineFunction &MF) const override; |
| 68 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
Michael Kuperstein | 13fbd45 | 2015-02-01 16:56:04 +0000 | [diff] [blame^] | 69 | bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; |
| 70 | bool needsFrameIndexResolution(const MachineFunction &MF) const override; |
Michael Kuperstein | e86aa9a | 2015-02-01 16:15:07 +0000 | [diff] [blame] | 71 | |
| 72 | int getFrameIndexOffset(const MachineFunction &MF, int FI) const override; |
| 73 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
| 74 | unsigned &FrameReg) const override; |
| 75 | |
| 76 | int getFrameIndexOffsetFromSP(const MachineFunction &MF, int FI) const; |
| 77 | int getFrameIndexReferenceFromSP(const MachineFunction &MF, int FI, |
| 78 | unsigned &FrameReg) const override; |
| 79 | |
| 80 | void eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 81 | MachineBasicBlock &MBB, |
| 82 | MachineBasicBlock::iterator MI) const override; |
| 83 | |
| 84 | private: |
| 85 | /// convertArgMovsToPushes - This method tries to convert a call sequence |
| 86 | /// that uses sub and mov instructions to put the argument onto the stack |
| 87 | /// into a series of pushes. |
| 88 | /// Returns true if the transformation succeeded, false if not. |
| 89 | bool convertArgMovsToPushes(MachineFunction &MF, |
| 90 | MachineBasicBlock &MBB, |
| 91 | MachineBasicBlock::iterator I, |
| 92 | uint64_t Amount) const; |
| 93 | }; |
| 94 | |
| 95 | } // End llvm namespace |
| 96 | |
| 97 | #endif |