10b57cec5SDimitry Andric //===--------------------- SIFrameLowering.h --------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H 100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "AMDGPUFrameLowering.h" 13bdd1243dSDimitry Andric #include "SIRegisterInfo.h" 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric namespace llvm { 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric class SIFrameLowering final : public AMDGPUFrameLowering { 180b57cec5SDimitry Andric public: 198bcb0991SDimitry Andric SIFrameLowering(StackDirection D, Align StackAl, int LAO, 205ffd83dbSDimitry Andric Align TransAl = Align(1)) 218bcb0991SDimitry Andric : AMDGPUFrameLowering(D, StackAl, LAO, TransAl) {} 220b57cec5SDimitry Andric ~SIFrameLowering() override = default; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric void emitEntryFunctionPrologue(MachineFunction &MF, 250b57cec5SDimitry Andric MachineBasicBlock &MBB) const; 260b57cec5SDimitry Andric void emitPrologue(MachineFunction &MF, 270b57cec5SDimitry Andric MachineBasicBlock &MBB) const override; 280b57cec5SDimitry Andric void emitEpilogue(MachineFunction &MF, 290b57cec5SDimitry Andric MachineBasicBlock &MBB) const override; 30e8d8bef9SDimitry Andric StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, 315ffd83dbSDimitry Andric Register &FrameReg) const override; 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, 340b57cec5SDimitry Andric RegScavenger *RS = nullptr) const override; 350b57cec5SDimitry Andric void determineCalleeSavesSGPR(MachineFunction &MF, BitVector &SavedRegs, 360b57cec5SDimitry Andric RegScavenger *RS = nullptr) const; 3706c3fb27SDimitry Andric void determinePrologEpilogSGPRSaves(MachineFunction &MF, BitVector &SavedRegs, 3806c3fb27SDimitry Andric bool NeedExecCopyReservedReg) const; 39bdd1243dSDimitry Andric void emitCSRSpillStores(MachineFunction &MF, MachineBasicBlock &MBB, 40bdd1243dSDimitry Andric MachineBasicBlock::iterator MBBI, DebugLoc &DL, 41*5f757f3fSDimitry Andric LiveRegUnits &LiveUnits, Register FrameReg, 42bdd1243dSDimitry Andric Register FramePtrRegScratchCopy) const; 43bdd1243dSDimitry Andric void emitCSRSpillRestores(MachineFunction &MF, MachineBasicBlock &MBB, 44bdd1243dSDimitry Andric MachineBasicBlock::iterator MBBI, DebugLoc &DL, 45*5f757f3fSDimitry Andric LiveRegUnits &LiveUnits, Register FrameReg, 46bdd1243dSDimitry Andric Register FramePtrRegScratchCopy) const; 470b57cec5SDimitry Andric bool 480b57cec5SDimitry Andric assignCalleeSavedSpillSlots(MachineFunction &MF, 490b57cec5SDimitry Andric const TargetRegisterInfo *TRI, 500b57cec5SDimitry Andric std::vector<CalleeSavedInfo> &CSI) const override; 510b57cec5SDimitry Andric 524824e7fdSDimitry Andric bool allocateScavengingFrameIndexesNearIncomingSP( 534824e7fdSDimitry Andric const MachineFunction &MF) const override; 544824e7fdSDimitry Andric 550b57cec5SDimitry Andric bool isSupportedStackID(TargetStackID::Value ID) const override; 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric void processFunctionBeforeFrameFinalized( 580b57cec5SDimitry Andric MachineFunction &MF, 590b57cec5SDimitry Andric RegScavenger *RS = nullptr) const override; 600b57cec5SDimitry Andric 6181ad6265SDimitry Andric void processFunctionBeforeFrameIndicesReplaced( 6281ad6265SDimitry Andric MachineFunction &MF, RegScavenger *RS = nullptr) const override; 6381ad6265SDimitry Andric 640b57cec5SDimitry Andric MachineBasicBlock::iterator 650b57cec5SDimitry Andric eliminateCallFramePseudoInstr(MachineFunction &MF, 660b57cec5SDimitry Andric MachineBasicBlock &MBB, 670b57cec5SDimitry Andric MachineBasicBlock::iterator MI) const override; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric private: 705ffd83dbSDimitry Andric void emitEntryFunctionFlatScratchInit(MachineFunction &MF, 715ffd83dbSDimitry Andric MachineBasicBlock &MBB, 725ffd83dbSDimitry Andric MachineBasicBlock::iterator I, 735ffd83dbSDimitry Andric const DebugLoc &DL, 745ffd83dbSDimitry Andric Register ScratchWaveOffsetReg) const; 750b57cec5SDimitry Andric 765ffd83dbSDimitry Andric Register getEntryFunctionReservedScratchRsrcReg(MachineFunction &MF) const; 770b57cec5SDimitry Andric 785ffd83dbSDimitry Andric void emitEntryFunctionScratchRsrcRegSetup( 795ffd83dbSDimitry Andric MachineFunction &MF, MachineBasicBlock &MBB, 805ffd83dbSDimitry Andric MachineBasicBlock::iterator I, const DebugLoc &DL, 815ffd83dbSDimitry Andric Register PreloadedPrivateBufferReg, Register ScratchRsrcReg, 825ffd83dbSDimitry Andric Register ScratchWaveOffsetReg) const; 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric public: 850b57cec5SDimitry Andric bool hasFP(const MachineFunction &MF) const override; 86e8d8bef9SDimitry Andric 87e8d8bef9SDimitry Andric bool requiresStackPointerReference(const MachineFunction &MF) const; 880b57cec5SDimitry Andric }; 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric } // end namespace llvm 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H 93