LLVM  16.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 
13 #include "llvm/Support/TypeSize.h"
14 
15 namespace llvm {
16 
17 class ARMSubtarget;
18 class CalleeSavedInfo;
19 class MachineFunction;
20 
22 protected:
23  const ARMSubtarget &STI;
24 
25 public:
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 hasReservedCallFrame(const MachineFunction &MF) const override;
51  bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
53  Register &FrameReg) const override;
54  int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
55  Register &FrameReg, int SPAdj) const;
56 
57  void getCalleeSaves(const MachineFunction &MF,
58  BitVector &SavedRegs) const override;
59  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
60  RegScavenger *RS) const override;
61 
63  MachineBasicBlock &MBB) const override;
64 
65  /// Returns true if the target will correctly handle shrink wrapping.
66  bool enableShrinkWrapping(const MachineFunction &MF) const override;
67 
68  bool isProfitableForNoCSROpt(const Function &F) const override {
69  // The no-CSR optimisation is bad for code size on ARM, because we can save
70  // many registers with a single PUSH/POP pair.
71  return false;
72  }
73 
74  bool
76  const TargetRegisterInfo *TRI,
77  std::vector<CalleeSavedInfo> &CSI) const override;
78 
79  const SpillSlot *
80  getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
81 
82 private:
84  ArrayRef<CalleeSavedInfo> CSI, unsigned StmOpc,
85  unsigned StrOpc, bool NoGap, bool (*Func)(unsigned, bool),
86  unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const;
88  MutableArrayRef<CalleeSavedInfo> CSI, unsigned LdmOpc,
89  unsigned LdrOpc, bool isVarArg, bool NoGap,
90  bool (*Func)(unsigned, bool),
91  unsigned NumAlignedDPRCS2Regs) const;
92 
94  eliminateCallFramePseudoInstr(MachineFunction &MF,
96  MachineBasicBlock::iterator MI) const override;
97 };
98 
99 } // end namespace llvm
100 
101 #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
llvm::ARMFrameLowering::canSimplifyCallFramePseudos
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
Definition: ARMFrameLowering.cpp:244
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
TargetFrameLowering.h
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::ARMFrameLowering::getFrameIndexReference
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
Definition: ARMFrameLowering.cpp:1407
llvm::ARMSubtarget
Definition: ARMSubtarget.h:47
llvm::Function
Definition: Function.h:60
TypeSize.h
llvm::ARMFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: ARMFrameLowering.cpp:2758
llvm::ARMFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: ARMFrameLowering.cpp:226
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:237
llvm::ARMFrameLowering::enableShrinkWrapping
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
Definition: ARMFrameLowering.cpp:2192
llvm::ARMFrameLowering::enableCalleeSaveSkip
bool enableCalleeSaveSkip(const MachineFunction &MF) const override
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functi...
Definition: ARMFrameLowering.cpp:189
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::ARMFrameLowering::getCalleeSaves
void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const override
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
Definition: ARMFrameLowering.cpp:2746
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::ARMFrameLowering::keepFramePointer
bool keepFramePointer(const MachineFunction &MF) const override
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame...
Definition: ARMFrameLowering.cpp:180
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:28
llvm::ARMFrameLowering::isProfitableForNoCSROpt
bool isProfitableForNoCSROpt(const Function &F) const override
Check if the no-CSR optimisation is profitable for the given function.
Definition: ARMFrameLowering.h:68
llvm::ARMFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition: ARMFrameLowering.cpp:705
llvm::ARMFrameLowering::restoreCalleeSavedRegisters
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...
Definition: ARMFrameLowering.cpp:2006
llvm::BitVector
Definition: BitVector.h:75
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::ARMFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition: ARMFrameLowering.cpp:202
llvm::ARMFrameLowering::adjustForSegmentedStacks
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
Definition: ARMFrameLowering.cpp:2910
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::ARMFrameLowering::ARMFrameLowering
ARMFrameLowering(const ARMSubtarget &sti)
Definition: ARMFrameLowering.cpp:176
llvm::ARMFrameLowering::ResolveFrameIndexReference
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, int SPAdj) const
Definition: ARMFrameLowering.cpp:1413
llvm::ARMFrameLowering::getCalleeSavedSpillSlots
const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const override
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
Definition: ARMFrameLowering.cpp:2793
llvm::ARMFrameLowering
Definition: ARMFrameLowering.h:21
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::ARMFrameLowering::determineCalleeSaves
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition: ARMFrameLowering.cpp:2237
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::ARMFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: ARMFrameLowering.cpp:1246
llvm::ARMFrameLowering::STI
const ARMSubtarget & STI
Definition: ARMFrameLowering.h:23
llvm::ARMFrameLowering::spillCalleeSavedRegisters
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...
Definition: ARMFrameLowering.cpp:1952
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::ARMFrameLowering::isFPReserved
bool isFPReserved(const MachineFunction &MF) const
isFPReserved - Return true if the frame pointer register should be considered a reserved register on ...
Definition: ARMFrameLowering.cpp:217