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 MachineBasicBlock::iterator 51 eliminateCallFramePseudoInstr(MachineFunction &MF, 52 MachineBasicBlock &MBB, 53 MachineBasicBlock::iterator MI) const override; 54 55 private: 56 void emitEntryFunctionFlatScratchInit(MachineFunction &MF, 57 MachineBasicBlock &MBB, 58 MachineBasicBlock::iterator I, 59 const DebugLoc &DL, 60 Register ScratchWaveOffsetReg) const; 61 62 Register getEntryFunctionReservedScratchRsrcReg(MachineFunction &MF) const; 63 64 void emitEntryFunctionScratchRsrcRegSetup( 65 MachineFunction &MF, MachineBasicBlock &MBB, 66 MachineBasicBlock::iterator I, const DebugLoc &DL, 67 Register PreloadedPrivateBufferReg, Register ScratchRsrcReg, 68 Register ScratchWaveOffsetReg) const; 69 70 public: 71 bool hasFP(const MachineFunction &MF) const override; 72 73 bool requiresStackPointerReference(const MachineFunction &MF) const; 74 }; 75 76 } // end namespace llvm 77 78 #endif // LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H 79