diff options
author | Austin Kerbow <Austin.Kerbow@amd.com> | 2023-08-19 15:08:37 -0700 |
---|---|---|
committer | Austin Kerbow <Austin.Kerbow@amd.com> | 2023-09-12 08:52:30 -0700 |
commit | 343be5132e2831d856de021593cb41a0595862d3 (patch) | |
tree | c25066c28ef2c6d19848623091b1d9a3b1f66174 /llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp | |
parent | 9048aa71aff1ce942dad6bfa5224536c643f84cf (diff) | |
download | llvm-343be5132e2831d856de021593cb41a0595862d3.zip llvm-343be5132e2831d856de021593cb41a0595862d3.tar.gz llvm-343be5132e2831d856de021593cb41a0595862d3.tar.bz2 |
[AMDGPU] Add utilities to track number of user SGPRs. NFC.
Factor out and unify some common code that calculates and tracks the
number of user SGRPs.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D159439
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp | 70 |
1 files changed, 10 insertions, 60 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp index 2d0dd2b..bbee6d7 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp @@ -7,17 +7,18 @@ //===----------------------------------------------------------------------===// #include "SIMachineFunctionInfo.h" -#include "AMDGPUTargetMachine.h" #include "AMDGPUSubtarget.h" -#include "SIRegisterInfo.h" +#include "AMDGPUTargetMachine.h" +#include "GCNSubtarget.h" #include "MCTargetDesc/AMDGPUMCTargetDesc.h" +#include "SIRegisterInfo.h" #include "Utils/AMDGPUBaseInfo.h" #include "llvm/CodeGen/LiveIntervals.h" +#include "llvm/CodeGen/MIRParser/MIParser.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/CodeGen/MIRParser/MIParser.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Function.h" @@ -36,28 +37,12 @@ const GCNTargetMachine &getTM(const GCNSubtarget *STI) { SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F, const GCNSubtarget *STI) - : AMDGPUMachineFunction(F, *STI), - Mode(F), - GWSResourcePSV(getTM(STI)), - PrivateSegmentBuffer(false), - DispatchPtr(false), - QueuePtr(false), - KernargSegmentPtr(false), - DispatchID(false), - FlatScratchInit(false), - WorkGroupIDX(false), - WorkGroupIDY(false), - WorkGroupIDZ(false), - WorkGroupInfo(false), - LDSKernelId(false), - PrivateSegmentWaveByteOffset(false), - WorkItemIDX(false), - WorkItemIDY(false), - WorkItemIDZ(false), - ImplicitBufferPtr(false), - ImplicitArgPtr(false), - GITPtrHigh(0xffffffff), - HighBitsOf32BitAddress(0) { + : AMDGPUMachineFunction(F, *STI), Mode(F), GWSResourcePSV(getTM(STI)), + UserSGPRInfo(F, *STI), WorkGroupIDX(false), WorkGroupIDY(false), + WorkGroupIDZ(false), WorkGroupInfo(false), LDSKernelId(false), + PrivateSegmentWaveByteOffset(false), WorkItemIDX(false), + WorkItemIDY(false), WorkItemIDZ(false), ImplicitArgPtr(false), + GITPtrHigh(0xffffffff), HighBitsOf32BitAddress(0) { const GCNSubtarget &ST = *static_cast<const GCNSubtarget *>(STI); FlatWorkGroupSizes = ST.getFlatWorkGroupSizes(F); WavesPerEU = ST.getWavesPerEU(F); @@ -67,16 +52,10 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F, VRegFlags.reserve(1024); - // FIXME: Should have analysis or something rather than attribute to detect - // calls. - const bool HasCalls = F.hasFnAttribute("amdgpu-calls"); - const bool IsKernel = CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL; if (IsKernel) { - if (!F.arg_empty() || ST.getImplicitArgNumBytes(F) != 0) - KernargSegmentPtr = true; WorkGroupIDX = true; WorkItemIDX = true; } else if (CC == CallingConv::AMDGPU_PS) { @@ -128,12 +107,6 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F, MayNeedAGPRs = false; // We will select all MAI with VGPR operands. } - bool isAmdHsaOrMesa = ST.isAmdHsaOrMesa(F); - if (isAmdHsaOrMesa && !ST.enableFlatScratch()) - PrivateSegmentBuffer = true; - else if (ST.isMesaGfxShader(F)) - ImplicitBufferPtr = true; - if (!AMDGPU::isGraphics(CC) || (CC == CallingConv::AMDGPU_CS && ST.hasArchitectedSGPRs())) { if (IsKernel || !F.hasFnAttribute("amdgpu-no-workgroup-id-x")) @@ -158,33 +131,10 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F, ST.getMaxWorkitemID(F, 2) != 0) WorkItemIDZ = true; - if (!F.hasFnAttribute("amdgpu-no-dispatch-ptr")) - DispatchPtr = true; - - if (!F.hasFnAttribute("amdgpu-no-queue-ptr")) - QueuePtr = true; - - if (!F.hasFnAttribute("amdgpu-no-dispatch-id")) - DispatchID = true; - if (!IsKernel && !F.hasFnAttribute("amdgpu-no-lds-kernel-id")) LDSKernelId = true; } - // FIXME: This attribute is a hack, we just need an analysis on the function - // to look for allocas. - bool HasStackObjects = F.hasFnAttribute("amdgpu-stack-objects"); - - // TODO: This could be refined a lot. The attribute is a poor way of - // detecting calls or stack objects that may require it before argument - // lowering. - if (ST.hasFlatAddressSpace() && isEntryFunction() && - (isAmdHsaOrMesa || ST.enableFlatScratch()) && - (HasCalls || HasStackObjects || ST.enableFlatScratch()) && - !ST.flatScratchIsArchitected()) { - FlatScratchInit = true; - } - if (isEntryFunction()) { // X, XY, and XYZ are the only supported combinations, so make sure Y is // enabled if Z is. |