32 PrivateSegmentBuffer(
false),
35 KernargSegmentPtr(
false),
37 FlatScratchInit(
false),
42 PrivateSegmentWaveByteOffset(
false),
46 ImplicitBufferPtr(
false),
47 ImplicitArgPtr(
false),
48 GITPtrHigh(0xffffffff),
49 HighBitsOf32BitAddress(0) {
61 KernargSegmentPtr =
true;
71 ScratchRSrcReg = AMDGPU::SGPR0_SGPR1_SGPR2_SGPR3;
72 ScratchWaveOffsetReg = AMDGPU::SGPR4;
73 FrameOffsetReg = AMDGPU::SGPR5;
74 StackPtrOffsetReg = AMDGPU::SGPR32;
81 if (F.hasFnAttribute(
"amdgpu-implicitarg-ptr"))
82 ImplicitArgPtr =
true;
84 if (F.hasFnAttribute(
"amdgpu-implicitarg-ptr")) {
85 KernargSegmentPtr =
true;
100 if (F.hasFnAttribute(
"amdgpu-work-group-id-x"))
103 if (F.hasFnAttribute(
"amdgpu-work-group-id-y"))
106 if (F.hasFnAttribute(
"amdgpu-work-group-id-z"))
109 if (F.hasFnAttribute(
"amdgpu-work-item-id-x"))
112 if (F.hasFnAttribute(
"amdgpu-work-item-id-y"))
115 if (F.hasFnAttribute(
"amdgpu-work-item-id-z"))
129 if (HasStackObjects || MaySpill) {
130 PrivateSegmentWaveByteOffset =
true;
142 if (HasStackObjects || MaySpill)
143 PrivateSegmentBuffer =
true;
145 if (F.hasFnAttribute(
"amdgpu-dispatch-ptr"))
148 if (F.hasFnAttribute(
"amdgpu-queue-ptr"))
151 if (F.hasFnAttribute(
"amdgpu-dispatch-id"))
154 if (HasStackObjects || MaySpill)
155 ImplicitBufferPtr =
true;
158 if (F.hasFnAttribute(
"amdgpu-kernarg-segment-ptr"))
159 KernargSegmentPtr =
true;
164 if (HasStackObjects || F.hasFnAttribute(
"amdgpu-flat-scratch"))
165 FlatScratchInit =
true;
168 Attribute A = F.getFnAttribute(
"amdgpu-git-ptr-high");
173 A = F.getFnAttribute(
"amdgpu-32bit-address-high-bits");
190 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_128RegClass));
197 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
204 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
212 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
219 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
226 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
233 getNextUserSGPR(), AMDGPU::sub0, &AMDGPU::SReg_64RegClass));
239 for (
unsigned I = 0; CSRegs[
I]; ++
I) {
240 if (CSRegs[
I] == Reg)
250 std::vector<SpilledReg> &SpillLanes = SGPRToVGPRSpills[FI];
253 if (!SpillLanes.empty())
263 assert(Size >= 4 && Size <= 64 &&
"invalid sgpr spill size");
264 assert(TRI->spillSGPRToVGPR() &&
"not spilling SGPRs to VGPRs");
266 int NumLanes = Size / 4;
268 const MCPhysReg *CSRegs = TRI->getCalleeSavedRegs(&MF);
272 for (
int I = 0;
I < NumLanes; ++
I, ++NumVGPRSpillLanes) {
274 unsigned VGPRIndex = (NumVGPRSpillLanes % WaveSize);
276 if (VGPRIndex == 0) {
277 LaneVGPR = TRI->findUnusedRegister(MRI, &AMDGPU::VGPR_32RegClass, MF);
278 if (LaneVGPR == AMDGPU::NoRegister) {
281 SGPRToVGPRSpills.erase(FI);
282 NumVGPRSpillLanes -=
I;
297 BB.addLiveIn(LaneVGPR);
299 LaneVGPR = SpillVGPRs.back().VGPR;
302 SpillLanes.push_back(
SpilledReg(LaneVGPR, VGPRIndex));
309 for (
auto &R : SGPRToVGPRSpills)
319 return AMDGPU::VGPR0;
322 return AMDGPU::VGPR1;
325 return AMDGPU::VGPR2;
330 MCPhysReg SIMachineFunctionInfo::getNextUserSGPR()
const {
331 assert(NumSystemSGPRs == 0 &&
"System SGPRs must be added after user SGPRs");
332 return AMDGPU::SGPR0 + NumUserSGPRs;
335 MCPhysReg SIMachineFunctionInfo::getNextSystemSGPR()
const {
336 return AMDGPU::SGPR0 + NumUserSGPRs + NumSystemSGPRs;
unsigned addImplicitBufferPtr(const SIRegisterInfo &TRI)
ArgDescriptor DispatchPtr
Interface definition for SIRegisterInfo.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
AMDGPU specific subclass of TargetSubtarget.
Compute iterated dominance frontiers using a linear time algorithm.
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const
Inverse of getMaxLocalMemWithWaveCount.
bool hasStackObjects() const
Return true if there are any stack objects in this function.
void removeSGPRToVGPRFrameIndices(MachineFrameInfo &MFI)
unsigned addKernargSegmentPtr(const SIRegisterInfo &TRI)
bool hasWorkItemIDZ() const
bool isAmdCodeObjectV2(const Function &F) const
unsigned const TargetRegisterInfo * TRI
SIMachineFunctionInfo(const MachineFunction &MF)
bool hasWorkItemIDX() const
Calling convention used for Mesa/AMDPAL pixel shaders.
bool isMesaGfxShader(const Function &F) const
unsigned addDispatchID(const SIRegisterInfo &TRI)
bool isEntryFunction() const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
SPIR_KERNEL - Calling convention for SPIR kernel functions.
void limitOccupancy(const MachineFunction &MF)
ArgDescriptor PrivateSegmentWaveByteOffset
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
unsigned getMaxWavesPerEU() const
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool allocateSGPRSpillToVGPR(MachineFunction &MF, int FI)
Reserve a slice of a VGPR to support spilling for FrameIndex FI.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool debuggerEmitPrologue() const
std::pair< unsigned, unsigned > getWavesPerEU(const Function &F) const
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static ArgDescriptor createRegister(unsigned Reg)
unsigned addQueuePtr(const SIRegisterInfo &TRI)
bool hasWorkItemIDY() const
Generation getGeneration() const
int CreateSpillStackObject(uint64_t Size, unsigned Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned addDispatchPtr(const SIRegisterInfo &TRI)
bool hasFlatAddressSpace() const
unsigned getWavefrontSize() const
unsigned getLDSSize() const
unsigned getAlignmentForImplicitArgPtr() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool isVGPRSpillingEnabled(const Function &F) const
Calling convention for AMDGPU code object kernels.
ArgDescriptor PrivateSegmentBuffer
unsigned addPrivateSegmentBuffer(const SIRegisterInfo &TRI)
unsigned addFlatScratchInit(const SIRegisterInfo &TRI)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
unsigned getInitialPSInputAddr(const Function &F)
Provides AMDGPU specific target descriptions.
Calling convention used for Mesa/AMDPAL geometry shaders.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
StringRef getValueAsString() const
Return the attribute's value as a string.
ArgDescriptor KernargSegmentPtr
static bool isCalleeSavedReg(const MCPhysReg *CSRegs, MCPhysReg Reg)
unsigned getRegister() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArgDescriptor FlatScratchInit
unsigned getWorkItemIDVGPR(unsigned Dim) const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
StringRef - Represent a constant reference to a string, i.e.
ArgDescriptor ImplicitBufferPtr
std::pair< unsigned, unsigned > getFlatWorkGroupSizes(const Function &F) const
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
bool hasCalls() const
Return true if the current function has any function calls.
const SIRegisterInfo * getRegisterInfo() const override