LLVM 20.0.0git
ARMFrameLowering.h
Go to the documentation of this file.
1//===- ARMTargetFrameLowering.h - Define frame lowering for ARM -*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
10#define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
11
14
15namespace llvm {
16
17class ARMSubtarget;
18class CalleeSavedInfo;
19class MachineFunction;
20
22protected:
24
25public:
26 explicit ARMFrameLowering(const ARMSubtarget &sti);
27
28 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
29 /// the function.
30 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32
36 const TargetRegisterInfo *TRI) const override;
37
38 bool
42 const TargetRegisterInfo *TRI) const override;
43
44 bool keepFramePointer(const MachineFunction &MF) const override;
45
46 bool enableCalleeSaveSkip(const MachineFunction &MF) const override;
47
48 bool hasFP(const MachineFunction &MF) const override;
49 bool isFPReserved(const MachineFunction &MF) const;
50 bool requiresAAPCSFrameRecord(const MachineFunction &MF) const;
51 bool hasReservedCallFrame(const MachineFunction &MF) const override;
52 bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
54 Register &FrameReg) const override;
55 int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
56 Register &FrameReg, int SPAdj) const;
57
58 void getCalleeSaves(const MachineFunction &MF,
59 BitVector &SavedRegs) const override;
61 RegScavenger *RS) const override;
62
63 /// Update the IsRestored flag on LR if it is spilled, based on the return
64 /// instructions.
65 static void updateLRRestored(MachineFunction &MF);
66
68 MachineFunction &MF, RegScavenger *RS = nullptr) const override;
69
71 MachineBasicBlock &MBB) const override;
72
73 /// Returns true if the target will correctly handle shrink wrapping.
74 bool enableShrinkWrapping(const MachineFunction &MF) const override;
75
76 bool isProfitableForNoCSROpt(const Function &F) const override {
77 // The no-CSR optimisation is bad for code size on ARM, because we can save
78 // many registers with a single PUSH/POP pair.
79 return false;
80 }
81
82 bool
85 std::vector<CalleeSavedInfo> &CSI) const override;
86
87 const SpillSlot *
88 getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
89
90private:
92 ArrayRef<CalleeSavedInfo> CSI, unsigned StmOpc,
93 unsigned StrOpc, bool NoGap, bool (*Func)(unsigned, bool),
94 unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const;
96 MutableArrayRef<CalleeSavedInfo> CSI, unsigned LdmOpc,
97 unsigned LdrOpc, bool isVarArg, bool NoGap,
98 bool (*Func)(unsigned, bool),
99 unsigned NumAlignedDPRCS2Regs) const;
100
102 eliminateCallFramePseudoInstr(MachineFunction &MF,
104 MachineBasicBlock::iterator MI) const override;
105};
106
107} // end namespace llvm
108
109#endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
MachineBasicBlock & MBB
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
unsigned const TargetRegisterInfo * TRI
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
static void updateLRRestored(MachineFunction &MF)
Update the IsRestored flag on LR if it is spilled, based on the return instructions.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
bool keepFramePointer(const MachineFunction &MF) const override
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame...
bool isProfitableForNoCSROpt(const Function &F) const override
Check if the no-CSR optimisation is profitable for the given function.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool requiresAAPCSFrameRecord(const MachineFunction &MF) const
bool isFPReserved(const MachineFunction &MF) const
isFPReserved - Return true if the frame pointer register should be considered a reserved register on ...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const override
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, int SPAdj) const
void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const override
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
const ARMSubtarget & STI
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool enableCalleeSaveSkip(const MachineFunction &MF) const override
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functi...
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:33
Information about stack frame layout on the target.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18