• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
isFPCloseToIncomingSP()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                                  const std::vector<CalleeSavedInfo> &CSI,
36                                  const TargetRegisterInfo *TRI) const override;
37   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
38                                    MachineBasicBlock::iterator MBBII,
39                                    std::vector<CalleeSavedInfo> &CSI,
40                                    const TargetRegisterInfo *TRI) const
41     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                              unsigned &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.
getRegSpillOffset(unsigned Reg)56   unsigned getRegSpillOffset(unsigned Reg) const {
57     return RegSpillOffsets[Reg];
58   }
59 
60   // Get or create the frame index of where the old frame pointer is stored.
61   int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const;
62 };
63 } // end namespace llvm
64 
65 #endif
66