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 
12 #include "llvm/ADT/IndexedMap.h"
13 #include "llvm/CodeGen/TargetFrameLowering.h"
14 
15 namespace llvm {
16 class SystemZTargetMachine;
17 class SystemZSubtarget;
18 
19 class SystemZFrameLowering : public TargetFrameLowering {
20   IndexedMap<unsigned> RegSpillOffsets;
21 
22 public:
23   SystemZFrameLowering();
24 
25   // Override TargetFrameLowering.
26   bool isFPCloseToIncomingSP() const override { return false; }
27   bool
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;
37   bool
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   bool hasFP(const MachineFunction &MF) const override;
47   bool hasReservedCallFrame(const MachineFunction &MF) const override;
48   int getFrameIndexReference(const MachineFunction &MF, int FI,
49                              Register &FrameReg) const override;
50   MachineBasicBlock::iterator
51   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
52                                 MachineBasicBlock::iterator MI) const override;
53 
54   // Return the byte offset from the incoming stack pointer of Reg's
55   // ABI-defined save slot.  Return 0 if no slot is defined for Reg.  Adjust
56   // the offset in case MF has packed-stack.
57   unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const;
58 
59   // Get or create the frame index of where the old frame pointer is stored.
60   int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const;
61 
62   bool usePackedStack(MachineFunction &MF) const;
63 };
64 } // end namespace llvm
65 
66 #endif
67