1 //==-- ARMTargetFrameLowering.h - Define frame lowering for ARM --*- 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 // 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H 15 #define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H 16 17 #include "llvm/Target/TargetFrameLowering.h" 18 19 namespace llvm { 20 class ARMSubtarget; 21 22 class ARMFrameLowering : public TargetFrameLowering { 23 protected: 24 const ARMSubtarget &STI; 25 26 public: 27 explicit ARMFrameLowering(const ARMSubtarget &sti); 28 29 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 30 /// the function. 31 void emitPrologue(MachineFunction &MF) const override; 32 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 33 34 void fixTCReturn(MachineFunction &MF, MachineBasicBlock &MBB) const; 35 36 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 37 MachineBasicBlock::iterator MI, 38 const std::vector<CalleeSavedInfo> &CSI, 39 const TargetRegisterInfo *TRI) const override; 40 41 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 42 MachineBasicBlock::iterator MI, 43 const std::vector<CalleeSavedInfo> &CSI, 44 const TargetRegisterInfo *TRI) const override; 45 46 bool hasFP(const MachineFunction &MF) const override; 47 bool hasReservedCallFrame(const MachineFunction &MF) const override; 48 bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; 49 int getFrameIndexReference(const MachineFunction &MF, int FI, 50 unsigned &FrameReg) const override; 51 int ResolveFrameIndexReference(const MachineFunction &MF, int FI, 52 unsigned &FrameReg, int SPAdj) const; 53 int getFrameIndexOffset(const MachineFunction &MF, int FI) const override; 54 55 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 56 RegScavenger *RS) const override; 57 58 void adjustForSegmentedStacks(MachineFunction &MF) const override; 59 60 private: 61 void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, 62 const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc, 63 unsigned StrOpc, bool NoGap, 64 bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs, 65 unsigned MIFlags = 0) const; 66 void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, 67 const std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc, 68 unsigned LdrOpc, bool isVarArg, bool NoGap, 69 bool(*Func)(unsigned, bool), 70 unsigned NumAlignedDPRCS2Regs) const; 71 72 void 73 eliminateCallFramePseudoInstr(MachineFunction &MF, 74 MachineBasicBlock &MBB, 75 MachineBasicBlock::iterator MI) const override; 76 }; 77 78 } // End llvm namespace 79 80 #endif 81