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 #include "llvm/Support/TypeSize.h" 14 15 namespace llvm { 16 17 class SIInstrInfo; 18 class SIMachineFunctionInfo; 19 class SIRegisterInfo; 20 class GCNSubtarget; 21 22 class SIFrameLowering final : public AMDGPUFrameLowering { 23 public: 24 SIFrameLowering(StackDirection D, Align StackAl, int LAO, 25 Align TransAl = Align(1)) 26 : AMDGPUFrameLowering(D, StackAl, LAO, TransAl) {} 27 ~SIFrameLowering() override = default; 28 29 void emitEntryFunctionPrologue(MachineFunction &MF, 30 MachineBasicBlock &MBB) const; 31 void emitPrologue(MachineFunction &MF, 32 MachineBasicBlock &MBB) const override; 33 void emitEpilogue(MachineFunction &MF, 34 MachineBasicBlock &MBB) const override; 35 StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, 36 Register &FrameReg) const override; 37 38 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, 39 RegScavenger *RS = nullptr) const override; 40 void determineCalleeSavesSGPR(MachineFunction &MF, BitVector &SavedRegs, 41 RegScavenger *RS = nullptr) const; 42 bool 43 assignCalleeSavedSpillSlots(MachineFunction &MF, 44 const TargetRegisterInfo *TRI, 45 std::vector<CalleeSavedInfo> &CSI) const override; 46 47 bool isSupportedStackID(TargetStackID::Value ID) const override; 48 49 void processFunctionBeforeFrameFinalized( 50 MachineFunction &MF, 51 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