LLVM  10.0.0svn
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 #include <vector>
15 
16 namespace llvm {
17 
18 class ARMSubtarget;
19 class CalleeSavedInfo;
20 class MachineFunction;
21 
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, MachineBasicBlock &MBB) const override;
32  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
33 
36  const std::vector<CalleeSavedInfo> &CSI,
37  const TargetRegisterInfo *TRI) const override;
38 
41  std::vector<CalleeSavedInfo> &CSI,
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;
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;
55 
56  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
57  RegScavenger *RS) const override;
58 
60  MachineBasicBlock &MBB) const override;
61 
62  /// Returns true if the target will correctly handle shrink wrapping.
63  bool enableShrinkWrapping(const MachineFunction &MF) const override {
64  return true;
65  }
66  bool isProfitableForNoCSROpt(const Function &F) const override {
67  // The no-CSR optimisation is bad for code size on ARM, because we can save
68  // many registers with a single PUSH/POP pair.
69  return false;
70  }
71 
72 private:
73  void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
74  const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc,
75  unsigned StrOpc, bool NoGap,
76  bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs,
77  unsigned MIFlags = 0) const;
78  void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
79  std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc,
80  unsigned LdrOpc, bool isVarArg, bool NoGap,
81  bool(*Func)(unsigned, bool),
82  unsigned NumAlignedDPRCS2Regs) const;
83 
85  eliminateCallFramePseudoInstr(MachineFunction &MF,
86  MachineBasicBlock &MBB,
87  MachineBasicBlock::iterator MI) const override;
88 };
89 
90 } // end namespace llvm
91 
92 #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
unsigned const TargetRegisterInfo * TRI
F(f)
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
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 enableCalleeSaveSkip(const MachineFunction &MF) const override
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functi...
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
Information about stack frame layout on the target.
ARMFrameLowering(const ARMSubtarget &sti)
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
bool isProfitableForNoCSROpt(const Function &F) const override
Check if the no-CSR optimisation is profitable for the given function.
IRTranslator LLVM IR MI
const ARMSubtarget & STI