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 "SystemZInstrBuilder.h"
15 #include "llvm/ADT/IndexedMap.h"
17 #include "llvm/Support/TypeSize.h"
18 
19 namespace llvm {
20 class SystemZTargetMachine;
21 class SystemZSubtarget;
22 
24 public:
25  SystemZFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl,
26  bool StackReal);
27 
28  static std::unique_ptr<SystemZFrameLowering>
29  create(const SystemZSubtarget &STI);
30 
31  // Override TargetFrameLowering.
33  const MachineFunction &MF) const override {
34  // SystemZ wants normal register scavenging slots, as close to the stack or
35  // frame pointer as possible.
36  // The default implementation assumes an x86-like layout, where the frame
37  // pointer is at the opposite end of the frame from the stack pointer.
38  // This meant that when frame pointer elimination was disabled,
39  // the slots ended up being as close as possible to the incoming
40  // stack pointer, which is the opposite of what we want on SystemZ.
41  return false;
42  }
43 
44  bool hasReservedCallFrame(const MachineFunction &MF) const override;
47  MachineBasicBlock::iterator MI) const override;
48 };
49 
51  IndexedMap<unsigned> RegSpillOffsets;
52 
53 public:
55 
56  // Override TargetFrameLowering.
57  bool
59  const TargetRegisterInfo *TRI,
60  std::vector<CalleeSavedInfo> &CSI) const override;
61  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
62  RegScavenger *RS) const override;
66  const TargetRegisterInfo *TRI) const override;
67  bool
71  const TargetRegisterInfo *TRI) const override;
73  RegScavenger *RS) const override;
74  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
75  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
77  MachineBasicBlock &PrologMBB) const override;
78  bool hasFP(const MachineFunction &MF) const override;
80  Register &FrameReg) const override;
81 
82  // Return the byte offset from the incoming stack pointer of Reg's
83  // ABI-defined save slot. Return 0 if no slot is defined for Reg. Adjust
84  // the offset in case MF has packed-stack.
85  unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const;
86 
87  bool usePackedStack(MachineFunction &MF) const;
88 
89  // Return the offset of the backchain.
90  unsigned getBackchainOffset(MachineFunction &MF) const {
91  // The back chain is stored topmost with packed-stack.
92  return usePackedStack(MF) ? SystemZMC::ELFCallFrameSize - 8 : 0;
93  }
94 
95  // Get or create the frame index of where the old frame pointer is stored.
97 };
98 
100  IndexedMap<unsigned> RegSpillOffsets;
101 
102 public:
104 
105  bool
107  const TargetRegisterInfo *TRI,
108  std::vector<CalleeSavedInfo> &CSI) const override;
109 
110  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
111  RegScavenger *RS) const override;
112 
116  const TargetRegisterInfo *TRI) const override;
117 
118  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
119 
120  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
121 
122  bool hasFP(const MachineFunction &MF) const override;
123 };
124 } // end namespace llvm
125 
126 #endif
SystemZInstrBuilder.h
IndexedMap.h
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1558
TargetFrameLowering.h
llvm::SystemZXPLINKFrameLowering::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:910
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::SystemZXPLINKFrameLowering::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:932
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:665
llvm::SystemZELFFrameLowering::processFunctionBeforeFrameFinalized
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: SystemZFrameLowering.cpp:359
TypeSize.h
llvm::SystemZFrameLowering::create
static std::unique_ptr< SystemZFrameLowering > create(const SystemZSubtarget &STI)
Definition: SystemZFrameLowering.cpp:61
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:83
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:159
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:456
llvm::SystemZELFFrameLowering::usePackedStack
bool usePackedStack(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:810
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1559
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:55
llvm::SystemZELFFrameLowering::getBackchainOffset
unsigned getBackchainOffset(MachineFunction &MF) const
Definition: SystemZFrameLowering.h:90
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:305
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:67
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::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:765
llvm::SystemZFrameLowering::allocateScavengingFrameIndexesNearIncomingSP
bool allocateScavengingFrameIndexesNearIncomingSP(const MachineFunction &MF) const override
Control the placement of special register scavenging spill slots when allocating a stack frame.
Definition: SystemZFrameLowering.h:32
SystemZMachineFunctionInfo.h
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:996
llvm::SystemZELFFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: SystemZFrameLowering.cpp:93
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::SystemZELFFrameLowering::getRegSpillOffset
unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const
Definition: SystemZFrameLowering.cpp:780
llvm::SystemZSubtarget
Definition: SystemZSubtarget.h:33
llvm::SystemZXPLINKFrameLowering
Definition: SystemZFrameLowering.h:99
llvm::MachineFunction
Definition: MachineFunction.h:234
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:771
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:993
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:619
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:243
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:999
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:303
llvm::SystemZXPLINKFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: SystemZFrameLowering.cpp:833
llvm::SystemZFrameLowering
Definition: SystemZFrameLowering.h:23
llvm::SystemZELFFrameLowering::getOrCreateFramePointerSaveIndex
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:797
llvm::SystemZELFFrameLowering::SystemZELFFrameLowering
SystemZELFFrameLowering()
Definition: SystemZFrameLowering.cpp:208
llvm::SystemZELFFrameLowering
Definition: SystemZFrameLowering.h:50
llvm::SystemZXPLINKFrameLowering::SystemZXPLINKFrameLowering
SystemZXPLINKFrameLowering()
Definition: SystemZFrameLowering.cpp:820
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::SystemZMC::ELFCallFrameSize
const int64_t ELFCallFrameSize
Definition: SystemZMCTargetDesc.h:35