1 //===-- SystemZFrameLowering.h - Frame lowering for SystemZ -----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZFRAMELOWERING_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZFRAMELOWERING_H
12 #include "MCTargetDesc/SystemZMCTargetDesc.h"
13 #include "llvm/ADT/IndexedMap.h"
14 #include "llvm/CodeGen/TargetFrameLowering.h"
15 #include "llvm/Support/TypeSize.h"
18 class SystemZTargetMachine
;
19 class SystemZSubtarget
;
21 class SystemZFrameLowering
: public TargetFrameLowering
{
22 IndexedMap
<unsigned> RegSpillOffsets
;
25 SystemZFrameLowering();
27 // Override TargetFrameLowering.
28 bool isFPCloseToIncomingSP() const override
{ return false; }
30 assignCalleeSavedSpillSlots(MachineFunction
&MF
,
31 const TargetRegisterInfo
*TRI
,
32 std::vector
<CalleeSavedInfo
> &CSI
) const override
;
33 void determineCalleeSaves(MachineFunction
&MF
, BitVector
&SavedRegs
,
34 RegScavenger
*RS
) const override
;
35 bool spillCalleeSavedRegisters(MachineBasicBlock
&MBB
,
36 MachineBasicBlock::iterator MBBI
,
37 ArrayRef
<CalleeSavedInfo
> CSI
,
38 const TargetRegisterInfo
*TRI
) const override
;
40 restoreCalleeSavedRegisters(MachineBasicBlock
&MBB
,
41 MachineBasicBlock::iterator MBBII
,
42 MutableArrayRef
<CalleeSavedInfo
> CSI
,
43 const TargetRegisterInfo
*TRI
) const override
;
44 void processFunctionBeforeFrameFinalized(MachineFunction
&MF
,
45 RegScavenger
*RS
) const override
;
46 void emitPrologue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
47 void emitEpilogue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
48 void inlineStackProbe(MachineFunction
&MF
,
49 MachineBasicBlock
&PrologMBB
) const override
;
50 bool hasFP(const MachineFunction
&MF
) const override
;
51 bool hasReservedCallFrame(const MachineFunction
&MF
) const override
;
52 StackOffset
getFrameIndexReference(const MachineFunction
&MF
, int FI
,
53 Register
&FrameReg
) const override
;
54 MachineBasicBlock::iterator
55 eliminateCallFramePseudoInstr(MachineFunction
&MF
, MachineBasicBlock
&MBB
,
56 MachineBasicBlock::iterator MI
) const override
;
58 // Return the byte offset from the incoming stack pointer of Reg's
59 // ABI-defined save slot. Return 0 if no slot is defined for Reg. Adjust
60 // the offset in case MF has packed-stack.
61 unsigned getRegSpillOffset(MachineFunction
&MF
, Register Reg
) const;
63 // Get or create the frame index of where the old frame pointer is stored.
64 int getOrCreateFramePointerSaveIndex(MachineFunction
&MF
) const;
66 bool usePackedStack(MachineFunction
&MF
) const;
68 // Return the offset of the backchain.
69 unsigned getBackchainOffset(MachineFunction
&MF
) const {
70 // The back chain is stored topmost with packed-stack.
71 return usePackedStack(MF
) ? SystemZMC::ELFCallFrameSize
- 8 : 0;
74 } // end namespace llvm