1 //===- ARMTargetFrameLowering.h - Define frame lowering for ARM -*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
10 #define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
12 #include "llvm/CodeGen/MachineBasicBlock.h"
13 #include "llvm/CodeGen/TargetFrameLowering.h"
19 class CalleeSavedInfo;
20 class MachineFunction;
22 class ARMFrameLowering : public TargetFrameLowering {
24 const ARMSubtarget &STI;
27 explicit ARMFrameLowering(const ARMSubtarget &sti);
29 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
31 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
34 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
35 MachineBasicBlock::iterator MI,
36 const std::vector<CalleeSavedInfo> &CSI,
37 const TargetRegisterInfo *TRI) const override;
39 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
40 MachineBasicBlock::iterator MI,
41 std::vector<CalleeSavedInfo> &CSI,
42 const TargetRegisterInfo *TRI) const override;
44 bool keepFramePointer(const MachineFunction &MF) const override;
46 bool enableCalleeSaveSkip(const MachineFunction &MF) const override;
48 bool hasFP(const MachineFunction &MF) const override;
49 bool hasReservedCallFrame(const MachineFunction &MF) const override;
50 bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
51 int getFrameIndexReference(const MachineFunction &MF, int FI,
52 unsigned &FrameReg) const override;
53 int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
54 unsigned &FrameReg, int SPAdj) const;
56 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
57 RegScavenger *RS) const override;
59 void adjustForSegmentedStacks(MachineFunction &MF,
60 MachineBasicBlock &MBB) const override;
62 /// Returns true if the target will correctly handle shrink wrapping.
63 bool enableShrinkWrapping(const MachineFunction &MF) const override {
68 void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
69 const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc,
70 unsigned StrOpc, bool NoGap,
71 bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs,
72 unsigned MIFlags = 0) const;
73 void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
74 std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc,
75 unsigned LdrOpc, bool isVarArg, bool NoGap,
76 bool(*Func)(unsigned, bool),
77 unsigned NumAlignedDPRCS2Regs) const;
79 MachineBasicBlock::iterator
80 eliminateCallFramePseudoInstr(MachineFunction &MF,
81 MachineBasicBlock &MBB,
82 MachineBasicBlock::iterator MI) const override;
85 } // end namespace llvm
87 #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H