LLVM  14.0.0git
SystemZFrameLowering.h
Go to the documentation of this file.
1 //===-- SystemZFrameLowering.h - Frame lowering for SystemZ -----*- 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_SYSTEMZ_SYSTEMZFRAMELOWERING_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZFRAMELOWERING_H
11 
13 #include "llvm/ADT/IndexedMap.h"
15 #include "llvm/Support/TypeSize.h"
16 
17 namespace llvm {
18 class SystemZTargetMachine;
19 class SystemZSubtarget;
20 
22 
23 public:
24  SystemZFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl,
25  bool StackReal);
26 
27  static std::unique_ptr<SystemZFrameLowering>
28  create(const SystemZSubtarget &STI);
29 
30  // Override TargetFrameLowering.
31  bool isFPCloseToIncomingSP() const override { return false; }
32  bool hasReservedCallFrame(const MachineFunction &MF) const override;
35  MachineBasicBlock::iterator MI) const override;
36 };
37 
39  IndexedMap<unsigned> RegSpillOffsets;
40 
41 public:
43 
44  // Override TargetFrameLowering.
45  bool isFPCloseToIncomingSP() const override { return false; }
46  bool
48  const TargetRegisterInfo *TRI,
49  std::vector<CalleeSavedInfo> &CSI) const override;
50  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
51  RegScavenger *RS) const override;
55  const TargetRegisterInfo *TRI) const override;
56  bool
60  const TargetRegisterInfo *TRI) const override;
62  RegScavenger *RS) const override;
63  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
64  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
66  MachineBasicBlock &PrologMBB) const override;
67  bool hasFP(const MachineFunction &MF) const override;
69  Register &FrameReg) const override;
70 
71  // Return the byte offset from the incoming stack pointer of Reg's
72  // ABI-defined save slot. Return 0 if no slot is defined for Reg. Adjust
73  // the offset in case MF has packed-stack.
74  unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const;
75 
76  bool usePackedStack(MachineFunction &MF) const;
77 
78  // Return the offset of the backchain.
79  unsigned getBackchainOffset(MachineFunction &MF) const {
80  // The back chain is stored topmost with packed-stack.
81  return usePackedStack(MF) ? SystemZMC::ELFCallFrameSize - 8 : 0;
82  }
83 
84  // Get or create the frame index of where the old frame pointer is stored.
86 };
87 
89 public:
91 
92  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
93 
94  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
95 
96  bool hasFP(const MachineFunction &MF) const override;
97 };
98 } // end namespace llvm
99 
100 #endif
IndexedMap.h
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm::SystemZFrameLowering::isFPCloseToIncomingSP
bool isFPCloseToIncomingSP() const override
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer,...
Definition: SystemZFrameLowering.h:31
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
TargetFrameLowering.h
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::SystemZELFFrameLowering::inlineStackProbe
void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
Replace a StackProbe stub (if any) with the actual probe code inline.
Definition: SystemZFrameLowering.cpp:658
llvm::SystemZELFFrameLowering::processFunctionBeforeFrameFinalized
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: SystemZFrameLowering.cpp:352
TypeSize.h
llvm::SystemZFrameLowering::create
static std::unique_ptr< SystemZFrameLowering > create(const SystemZSubtarget &STI)
Definition: SystemZFrameLowering.cpp:55
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::SystemZFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: SystemZFrameLowering.cpp:77
SystemZMCTargetDesc.h
llvm::SystemZELFFrameLowering::determineCalleeSaves
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition: SystemZFrameLowering.cpp:153
llvm::SystemZELFFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition: SystemZFrameLowering.cpp:449
llvm::SystemZELFFrameLowering::usePackedStack
bool usePackedStack(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:803
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::TargetFrameLowering::StackDirection
StackDirection
Definition: TargetFrameLowering.h:45
llvm::SystemZFrameLowering::SystemZFrameLowering
SystemZFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl, bool StackReal)
Definition: SystemZFrameLowering.cpp:49
llvm::SystemZELFFrameLowering::getBackchainOffset
unsigned getBackchainOffset(MachineFunction &MF) const
Definition: SystemZFrameLowering.h:79
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
llvm::IndexedMap< unsigned >
llvm::BitVector
Definition: BitVector.h:74
llvm::SystemZFrameLowering::eliminateCallFramePseudoInstr
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Definition: SystemZFrameLowering.cpp:61
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::SystemZELFFrameLowering::isFPCloseToIncomingSP
bool isFPCloseToIncomingSP() const override
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer,...
Definition: SystemZFrameLowering.h:45
llvm::SystemZELFFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition: SystemZFrameLowering.cpp:758
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::SystemZXPLINKFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: SystemZFrameLowering.cpp:820
llvm::SystemZELFFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: SystemZFrameLowering.cpp:87
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::SystemZELFFrameLowering::getRegSpillOffset
unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const
Definition: SystemZFrameLowering.cpp:773
llvm::SystemZSubtarget
Definition: SystemZSubtarget.h:33
llvm::SystemZXPLINKFrameLowering
Definition: SystemZFrameLowering.h:88
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
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm::SystemZELFFrameLowering::getFrameIndexReference
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
Definition: SystemZFrameLowering.cpp:764
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::SystemZXPLINKFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition: SystemZFrameLowering.cpp:817
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::SystemZELFFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: SystemZFrameLowering.cpp:612
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::SystemZELFFrameLowering::spillCalleeSavedRegisters
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
Definition: SystemZFrameLowering.cpp:236
llvm::SystemZXPLINKFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition: SystemZFrameLowering.cpp:823
llvm::SystemZELFFrameLowering::restoreCalleeSavedRegisters
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBII, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
Definition: SystemZFrameLowering.cpp:296
llvm::SystemZFrameLowering
Definition: SystemZFrameLowering.h:21
llvm::SystemZELFFrameLowering::getOrCreateFramePointerSaveIndex
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:790
llvm::SystemZELFFrameLowering::SystemZELFFrameLowering
SystemZELFFrameLowering()
Definition: SystemZFrameLowering.cpp:202
llvm::SystemZELFFrameLowering
Definition: SystemZFrameLowering.h:38
llvm::SystemZXPLINKFrameLowering::SystemZXPLINKFrameLowering
SystemZXPLINKFrameLowering()
Definition: SystemZFrameLowering.cpp:813
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::SystemZMC::ELFCallFrameSize
const int64_t ELFCallFrameSize
Definition: SystemZMCTargetDesc.h:35