CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
192 lines
9.2 KiB
C++
192 lines
9.2 KiB
C++
//===--------------------- SIFrameLowering.h --------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H
|
|
#define LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H
|
|
|
|
#include "AMDGPUFrameLowering.h"
|
|
#include "SIRegisterInfo.h"
|
|
|
|
namespace llvm {
|
|
|
|
class SIInstrInfo;
|
|
|
|
class SIFrameLowering final : public AMDGPUFrameLowering {
|
|
public:
|
|
SIFrameLowering(StackDirection D, Align StackAl, int LAO,
|
|
Align TransAl = Align(1))
|
|
: AMDGPUFrameLowering(D, StackAl, LAO, TransAl) {}
|
|
~SIFrameLowering() override = default;
|
|
|
|
void emitEntryFunctionPrologue(MachineFunction &MF,
|
|
MachineBasicBlock &MBB) const;
|
|
void emitPrologue(MachineFunction &MF,
|
|
MachineBasicBlock &MBB) const override;
|
|
void emitEpilogue(MachineFunction &MF,
|
|
MachineBasicBlock &MBB) const override;
|
|
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
|
|
Register &FrameReg) const override;
|
|
|
|
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
|
|
RegScavenger *RS = nullptr) const override;
|
|
void determineCalleeSavesSGPR(MachineFunction &MF, BitVector &SavedRegs,
|
|
RegScavenger *RS = nullptr) const;
|
|
void determinePrologEpilogSGPRSaves(MachineFunction &MF, BitVector &SavedRegs,
|
|
bool NeedExecCopyReservedReg) const;
|
|
void emitCSRSpillStores(MachineFunction &MF, MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI, const DebugLoc &DL,
|
|
LiveRegUnits &LiveUnits, Register FrameReg,
|
|
Register FramePtrRegScratchCopy,
|
|
const bool NeedsFrameMoves) const;
|
|
void emitCSRSpillRestores(MachineFunction &MF, MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, LiveRegUnits &LiveUnits,
|
|
Register FrameReg,
|
|
Register FramePtrRegScratchCopy) const;
|
|
bool
|
|
assignCalleeSavedSpillSlots(MachineFunction &MF,
|
|
const TargetRegisterInfo *TRI,
|
|
std::vector<CalleeSavedInfo> &CSI) const override;
|
|
|
|
bool assignCalleeSavedSpillSlotsImpl(MachineFunction &MF,
|
|
const TargetRegisterInfo *TRI,
|
|
std::vector<CalleeSavedInfo> &CSI) const;
|
|
|
|
private:
|
|
/// Spill a single CSR according to @p CS
|
|
///
|
|
/// This is a separate method so it an be shared between the block-ops enabled
|
|
/// and disabled paths. Even when block-ops are enabled we may not have a
|
|
/// viable block for a specific register, so it will fall back to this
|
|
/// implementation.
|
|
///
|
|
/// @p LiveInRoots conveys whether we are tracking liveness, and if we are
|
|
/// it captures the original live-ins before spilling in a way that can be
|
|
/// (relatively) efficiently checked without enumerating all register aliases.
|
|
/// See @c buildLiveInRoots in the implementation.
|
|
void spillCalleeSavedRegisterWithoutBlockOps(
|
|
MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
const CalleeSavedInfo &CS, const SIInstrInfo *TII,
|
|
const SIRegisterInfo &TRI,
|
|
const std::optional<SparseBitVector<>> &LiveInRoots) const;
|
|
|
|
public:
|
|
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MI,
|
|
ArrayRef<CalleeSavedInfo> CSI,
|
|
const TargetRegisterInfo *TRI) const override;
|
|
|
|
bool
|
|
restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MI,
|
|
MutableArrayRef<CalleeSavedInfo> CSI,
|
|
const TargetRegisterInfo *TRI) const override;
|
|
|
|
bool allocateScavengingFrameIndexesNearIncomingSP(
|
|
const MachineFunction &MF) const override;
|
|
|
|
bool isSupportedStackID(TargetStackID::Value ID) const override;
|
|
|
|
void processFunctionBeforeFrameFinalized(
|
|
MachineFunction &MF,
|
|
RegScavenger *RS = nullptr) const override;
|
|
|
|
void processFunctionBeforeFrameIndicesReplaced(
|
|
MachineFunction &MF, RegScavenger *RS = nullptr) const override;
|
|
|
|
MachineBasicBlock::iterator
|
|
eliminateCallFramePseudoInstr(MachineFunction &MF,
|
|
MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MI) const override;
|
|
|
|
protected:
|
|
bool hasFPImpl(const MachineFunction &MF) const override;
|
|
|
|
private:
|
|
void emitEntryFunctionFlatScratchInit(MachineFunction &MF,
|
|
MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator I,
|
|
const DebugLoc &DL,
|
|
Register ScratchWaveOffsetReg) const;
|
|
|
|
Register getEntryFunctionReservedScratchRsrcReg(MachineFunction &MF) const;
|
|
|
|
void emitEntryFunctionScratchRsrcRegSetup(
|
|
MachineFunction &MF, MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator I, const DebugLoc &DL,
|
|
Register PreloadedPrivateBufferReg, Register ScratchRsrcReg,
|
|
Register ScratchWaveOffsetReg) const;
|
|
|
|
void emitPrologueEntryCFI(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL) const;
|
|
|
|
void emitDefCFA(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
|
DebugLoc const &DL, MCRegister StackPtrReg,
|
|
bool AspaceAlreadyDefined,
|
|
MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const;
|
|
|
|
public:
|
|
bool requiresStackPointerReference(const MachineFunction &MF) const;
|
|
|
|
/// Create a CFI index for CFIInst and build a MachineInstr around it.
|
|
MachineInstr *
|
|
buildCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, const MCCFIInstruction &CFIInst,
|
|
MachineInstr::MIFlag flag = MachineInstr::FrameSetup) const;
|
|
|
|
/// Create a CFI index describing a spill of the VGPR/AGPR \p Reg to another
|
|
/// VGPR/AGPR \p RegCopy and build a MachineInstr around it.
|
|
MachineInstr *buildCFIForVRegToVRegSpill(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL,
|
|
const MCRegister Reg,
|
|
const MCRegister RegCopy) const;
|
|
/// Create a CFI index describing a spill of an SGPR to a single lane of
|
|
/// a VGPR and build a MachineInstr around it.
|
|
MachineInstr *buildCFIForSGPRToVGPRSpill(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL,
|
|
const MCRegister SGPR,
|
|
const MCRegister VGPR,
|
|
const int Lane) const;
|
|
/// Create a CFI index describing a spill of an SGPR to multiple lanes of
|
|
/// VGPRs and build a MachineInstr around it.
|
|
MachineInstr *buildCFIForSGPRToVGPRSpill(
|
|
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, MCRegister SGPR,
|
|
ArrayRef<SIRegisterInfo::SpilledReg> VGPRSpills) const;
|
|
/// Create a CFI index describing a spill of a SGPR to VMEM and
|
|
/// build a MachineInstr around it.
|
|
MachineInstr *buildCFIForSGPRToVMEMSpill(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, MCRegister SGPR,
|
|
int64_t Offset) const;
|
|
/// Create a CFI index describing a spill of a VGPR to VMEM and
|
|
/// build a MachineInstr around it.
|
|
MachineInstr *buildCFIForVGPRToVMEMSpill(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, MCRegister VGPR,
|
|
int64_t Offset) const;
|
|
MachineInstr *buildCFIForRegToSGPRPairSpill(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL,
|
|
MCRegister Reg,
|
|
MCRegister SGPRPair) const;
|
|
MachineInstr *buildCFIForSameValue(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator MBBI,
|
|
const DebugLoc &DL, MCRegister Reg) const;
|
|
// Returns true if the function may need to reserve space on the stack for the
|
|
// CWSR trap handler.
|
|
bool mayReserveScratchForCWSR(const MachineFunction &MF) const;
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_SIFRAMELOWERING_H
|