LLVM  14.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 hasReservedCallFrame(const MachineFunction &MF) const override;
50  bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
52  Register &FrameReg) const override;
53  int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
54  Register &FrameReg, int SPAdj) const;
55 
56  void getCalleeSaves(const MachineFunction &MF,
57  BitVector &SavedRegs) const override;
58  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
59  RegScavenger *RS) const override;
60 
62  MachineBasicBlock &MBB) const override;
63 
64  /// Returns true if the target will correctly handle shrink wrapping.
65  bool enableShrinkWrapping(const MachineFunction &MF) const override;
66 
67  bool isProfitableForNoCSROpt(const Function &F) const override {
68  // The no-CSR optimisation is bad for code size on ARM, because we can save
69  // many registers with a single PUSH/POP pair.
70  return false;
71  }
72 
73  bool
75  const TargetRegisterInfo *TRI,
76  std::vector<CalleeSavedInfo> &CSI) const override;
77 
78  const SpillSlot *
79  getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
80 
81 private:
83  ArrayRef<CalleeSavedInfo> CSI, unsigned StmOpc,
84  unsigned StrOpc, bool NoGap, bool (*Func)(unsigned, bool),
85  unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const;
87  MutableArrayRef<CalleeSavedInfo> CSI, unsigned LdmOpc,
88  unsigned LdrOpc, bool isVarArg, bool NoGap,
89  bool (*Func)(unsigned, bool),
90  unsigned NumAlignedDPRCS2Regs) const;
91 
93  eliminateCallFramePseudoInstr(MachineFunction &MF,
95  MachineBasicBlock::iterator MI) const override;
96 };
97 
98 } // end namespace llvm
99 
100 #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:236
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
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:1026
llvm::ARMSubtarget
Definition: ARMSubtarget.h:46
llvm::Function
Definition: Function.h:62
TypeSize.h
llvm::ARMFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: ARMFrameLowering.cpp:2307
llvm::ARMFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: ARMFrameLowering.cpp:218
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::ARMFrameLowering::enableShrinkWrapping
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
Definition: ARMFrameLowering.cpp:1785
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:187
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
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:2295
F
#define F(x, y, z)
Definition: MD5.cpp:56
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:178
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
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:67
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:466
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:1609
llvm::BitVector
Definition: BitVector.h:74
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
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:200
llvm::ARMFrameLowering::adjustForSegmentedStacks
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
Definition: ARMFrameLowering.cpp:2439
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::ARMFrameLowering::ARMFrameLowering
ARMFrameLowering(const ARMSubtarget &sti)
Definition: ARMFrameLowering.cpp:174
llvm::ARMFrameLowering::ResolveFrameIndexReference
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, int SPAdj) const
Definition: ARMFrameLowering.cpp:1032
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:2322
llvm::ARMFrameLowering
Definition: ARMFrameLowering.h:21
llvm::MachineFunction
Definition: MachineFunction.h:230
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:1795
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:895
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:1569
llvm::MachineInstrBundleIterator< MachineInstr >