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 "llvm/ADT/IndexedMap.h"
13 #include "llvm/CodeGen/TargetFrameLowering.h"
16 class SystemZTargetMachine;
17 class SystemZSubtarget;
19 class SystemZFrameLowering : public TargetFrameLowering {
20 IndexedMap<unsigned> RegSpillOffsets;
23 SystemZFrameLowering();
25 // Override TargetFrameLowering.
26 bool isFPCloseToIncomingSP() const override { return false; }
28 assignCalleeSavedSpillSlots(MachineFunction &MF,
29 const TargetRegisterInfo *TRI,
30 std::vector<CalleeSavedInfo> &CSI) const override;
31 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
32 RegScavenger *RS) const override;
33 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
34 MachineBasicBlock::iterator MBBI,
35 ArrayRef<CalleeSavedInfo> CSI,
36 const TargetRegisterInfo *TRI) const override;
38 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
39 MachineBasicBlock::iterator MBBII,
40 MutableArrayRef<CalleeSavedInfo> CSI,
41 const TargetRegisterInfo *TRI) const override;
42 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
43 RegScavenger *RS) const override;
44 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
45 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
46 void inlineStackProbe(MachineFunction &MF,
47 MachineBasicBlock &PrologMBB) const override;
48 bool hasFP(const MachineFunction &MF) const override;
49 bool hasReservedCallFrame(const MachineFunction &MF) const override;
50 int getFrameIndexReference(const MachineFunction &MF, int FI,
51 Register &FrameReg) const override;
52 MachineBasicBlock::iterator
53 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
54 MachineBasicBlock::iterator MI) const override;
56 // Return the byte offset from the incoming stack pointer of Reg's
57 // ABI-defined save slot. Return 0 if no slot is defined for Reg. Adjust
58 // the offset in case MF has packed-stack.
59 unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const;
61 // Get or create the frame index of where the old frame pointer is stored.
62 int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const;
64 bool usePackedStack(MachineFunction &MF) const;
66 } // end namespace llvm