LLVM  16.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 SystemZSubtarget;
21 
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.
32  const MachineFunction &MF) const override {
33  // SystemZ wants normal register scavenging slots, as close to the stack or
34  // frame pointer as possible.
35  // The default implementation assumes an x86-like layout, where the frame
36  // pointer is at the opposite end of the frame from the stack pointer.
37  // This meant that when frame pointer elimination was disabled,
38  // the slots ended up being as close as possible to the incoming
39  // stack pointer, which is the opposite of what we want on SystemZ.
40  return false;
41  }
42 
43  bool hasReservedCallFrame(const MachineFunction &MF) const override;
46  MachineBasicBlock::iterator MI) const override;
47 };
48 
50  IndexedMap<unsigned> RegSpillOffsets;
51 
52 public:
54 
55  // Override TargetFrameLowering.
56  bool
58  const TargetRegisterInfo *TRI,
59  std::vector<CalleeSavedInfo> &CSI) const override;
60  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
61  RegScavenger *RS) const override;
65  const TargetRegisterInfo *TRI) const override;
66  bool
70  const TargetRegisterInfo *TRI) const override;
72  RegScavenger *RS) const override;
73  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
74  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
76  MachineBasicBlock &PrologMBB) const override;
77  bool hasFP(const MachineFunction &MF) const override;
79  Register &FrameReg) const override;
80  void
82  SmallVectorImpl<int> &ObjectsToAllocate) const override;
83 
84  // Return the byte offset from the incoming stack pointer of Reg's
85  // ABI-defined save slot. Return 0 if no slot is defined for Reg. Adjust
86  // the offset in case MF has packed-stack.
87  unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const;
88 
89  bool usePackedStack(MachineFunction &MF) const;
90 
91  // Return the offset of the backchain.
92  unsigned getBackchainOffset(MachineFunction &MF) const {
93  // The back chain is stored topmost with packed-stack.
94  return usePackedStack(MF) ? SystemZMC::ELFCallFrameSize - 8 : 0;
95  }
96 
97  // Get or create the frame index of where the old frame pointer is stored.
99 };
100 
102  IndexedMap<unsigned> RegSpillOffsets;
103 
104 public:
106 
107  bool
109  const TargetRegisterInfo *TRI,
110  std::vector<CalleeSavedInfo> &CSI) const override;
111 
112  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
113  RegScavenger *RS) const override;
114 
118  const TargetRegisterInfo *TRI) const override;
119 
120  bool
124  const TargetRegisterInfo *TRI) const override;
125 
126  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
127 
128  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
129 
131  MachineBasicBlock &PrologMBB) const override;
132 
133  bool hasFP(const MachineFunction &MF) const override;
134 
136  RegScavenger *RS) const override;
137 
138  void determineFrameLayout(MachineFunction &MF) const;
139 };
140 } // end namespace llvm
141 
142 #endif
SystemZInstrBuilder.h
IndexedMap.h
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::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:1052
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:1067
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:747
llvm::SystemZELFFrameLowering::processFunctionBeforeFrameFinalized
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: SystemZFrameLowering.cpp:441
TypeSize.h
llvm::SystemZFrameLowering::create
static std::unique_ptr< SystemZFrameLowering > create(const SystemZSubtarget &STI)
Definition: SystemZFrameLowering.cpp:62
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:237
llvm::SystemZXPLINKFrameLowering::processFunctionBeforeFrameFinalized
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: SystemZFrameLowering.cpp:1374
llvm::SystemZFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: SystemZFrameLowering.cpp:165
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:241
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:538
llvm::SystemZELFFrameLowering::usePackedStack
bool usePackedStack(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:891
llvm::SystemZXPLINKFrameLowering::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:1128
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
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:56
llvm::SystemZELFFrameLowering::getBackchainOffset
unsigned getBackchainOffset(MachineFunction &MF) const
Definition: SystemZFrameLowering.h:92
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:28
llvm::IndexedMap< unsigned >
llvm::BitVector
Definition: BitVector.h:75
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:68
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:94
llvm::SystemZELFFrameLowering::orderFrameObjects
void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override
Order the symbols in the local stack frame.
Definition: SystemZFrameLowering.cpp:96
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:847
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:31
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:1280
llvm::SystemZELFFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: SystemZFrameLowering.cpp:175
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::SystemZELFFrameLowering::getRegSpillOffset
unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const
Definition: SystemZFrameLowering.cpp:861
llvm::SystemZSubtarget
Definition: SystemZSubtarget.h:33
llvm::SystemZXPLINKFrameLowering
Definition: SystemZFrameLowering.h:101
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
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:852
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:1189
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:701
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:325
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:1370
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:385
llvm::SystemZXPLINKFrameLowering::assignCalleeSavedSpillSlots
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
Definition: SystemZFrameLowering.cpp:961
llvm::SystemZFrameLowering
Definition: SystemZFrameLowering.h:22
llvm::SystemZXPLINKFrameLowering::inlineStackProbe
void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
Replace a StackProbe stub (if any) with the actual probe code inline.
Definition: SystemZFrameLowering.cpp:1304
llvm::SystemZELFFrameLowering::getOrCreateFramePointerSaveIndex
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:878
llvm::SystemZXPLINKFrameLowering::determineFrameLayout
void determineFrameLayout(MachineFunction &MF) const
Definition: SystemZFrameLowering.cpp:1385
llvm::SmallVectorImpl< int >
llvm::SystemZELFFrameLowering::SystemZELFFrameLowering
SystemZELFFrameLowering()
Definition: SystemZFrameLowering.cpp:290
llvm::SystemZELFFrameLowering
Definition: SystemZFrameLowering.h:49
llvm::SystemZXPLINKFrameLowering::SystemZXPLINKFrameLowering
SystemZXPLINKFrameLowering()
Definition: SystemZFrameLowering.cpp:901
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::SystemZMC::ELFCallFrameSize
const int64_t ELFCallFrameSize
Definition: SystemZMCTargetDesc.h:31