xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIFrameLowering.h (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1 //===--------------------- SIFrameLowering.h --------------------*- 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_AMDGPU_SIFRAMELOWERING_H
10 #define LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H
11 
12 #include "AMDGPUFrameLowering.h"
13 
14 namespace llvm {
15 
16 class SIFrameLowering final : public AMDGPUFrameLowering {
17 public:
18   SIFrameLowering(StackDirection D, Align StackAl, int LAO,
19                   Align TransAl = Align(1))
20       : AMDGPUFrameLowering(D, StackAl, LAO, TransAl) {}
21   ~SIFrameLowering() override = default;
22 
23   void emitEntryFunctionPrologue(MachineFunction &MF,
24                                  MachineBasicBlock &MBB) const;
25   void emitPrologue(MachineFunction &MF,
26                     MachineBasicBlock &MBB) const override;
27   void emitEpilogue(MachineFunction &MF,
28                     MachineBasicBlock &MBB) const override;
29   StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
30                                      Register &FrameReg) const override;
31 
32   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
33                             RegScavenger *RS = nullptr) const override;
34   void determineCalleeSavesSGPR(MachineFunction &MF, BitVector &SavedRegs,
35                                 RegScavenger *RS = nullptr) const;
36   bool
37   assignCalleeSavedSpillSlots(MachineFunction &MF,
38                               const TargetRegisterInfo *TRI,
39                               std::vector<CalleeSavedInfo> &CSI) const override;
40 
41   bool allocateScavengingFrameIndexesNearIncomingSP(
42     const MachineFunction &MF) const override;
43 
44   bool isSupportedStackID(TargetStackID::Value ID) const override;
45 
46   void processFunctionBeforeFrameFinalized(
47     MachineFunction &MF,
48     RegScavenger *RS = nullptr) const override;
49 
50   void processFunctionBeforeFrameIndicesReplaced(
51       MachineFunction &MF, RegScavenger *RS = nullptr) const override;
52 
53   MachineBasicBlock::iterator
54   eliminateCallFramePseudoInstr(MachineFunction &MF,
55                                 MachineBasicBlock &MBB,
56                                 MachineBasicBlock::iterator MI) const override;
57 
58 private:
59   void emitEntryFunctionFlatScratchInit(MachineFunction &MF,
60                                         MachineBasicBlock &MBB,
61                                         MachineBasicBlock::iterator I,
62                                         const DebugLoc &DL,
63                                         Register ScratchWaveOffsetReg) const;
64 
65   Register getEntryFunctionReservedScratchRsrcReg(MachineFunction &MF) const;
66 
67   void emitEntryFunctionScratchRsrcRegSetup(
68       MachineFunction &MF, MachineBasicBlock &MBB,
69       MachineBasicBlock::iterator I, const DebugLoc &DL,
70       Register PreloadedPrivateBufferReg, Register ScratchRsrcReg,
71       Register ScratchWaveOffsetReg) const;
72 
73 public:
74   bool hasFP(const MachineFunction &MF) const override;
75 
76   bool requiresStackPointerReference(const MachineFunction &MF) const;
77 };
78 
79 } // end namespace llvm
80 
81 #endif // LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H
82