14 #ifndef LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H 15 #define LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H 37 class MachineFrameInfo;
38 class MachineFunction;
39 class TargetRegisterClass;
85 unsigned TIDReg = AMDGPU::NoRegister;
89 unsigned ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG;
90 unsigned ScratchWaveOffsetReg = AMDGPU::SCRATCH_WAVE_OFFSET_REG;
95 unsigned FrameOffsetReg = AMDGPU::FP_REG;
98 unsigned StackPtrOffsetReg = AMDGPU::SP_REG;
103 unsigned PSInputAddr = 0;
104 unsigned PSInputEnable = 0;
115 unsigned BytesInStackArgArea = 0;
117 bool ReturnsVoid =
true;
121 std::pair<unsigned, unsigned> FlatWorkGroupSizes = {0, 0};
125 std::pair<unsigned, unsigned> WavesPerEU = {0, 0};
128 std::array<int, 3> DebuggerWorkGroupIDStackObjectIndices = {{0, 0, 0}};
131 std::array<int, 3> DebuggerWorkItemIDStackObjectIndices = {{0, 0, 0}};
134 std::unique_ptr<const AMDGPUBufferPseudoSourceValue>> BufferPSVs;
136 std::unique_ptr<const AMDGPUImagePseudoSourceValue>> ImagePSVs;
139 unsigned LDSWaveSpillSize = 0;
140 unsigned NumUserSGPRs = 0;
141 unsigned NumSystemSGPRs = 0;
143 bool HasSpilledSGPRs =
false;
144 bool HasSpilledVGPRs =
false;
145 bool HasNonSpillStackObjects =
false;
146 bool IsStackRealigned =
false;
152 bool PrivateSegmentBuffer : 1;
153 bool DispatchPtr : 1;
155 bool KernargSegmentPtr : 1;
157 bool FlatScratchInit : 1;
160 bool WorkGroupIDX : 1;
161 bool WorkGroupIDY : 1;
162 bool WorkGroupIDZ : 1;
163 bool WorkGroupInfo : 1;
164 bool PrivateSegmentWaveByteOffset : 1;
166 bool WorkItemIDX : 1;
167 bool WorkItemIDY : 1;
168 bool WorkItemIDZ : 1;
173 bool ImplicitBufferPtr : 1;
177 bool ImplicitArgPtr : 1;
184 unsigned HighBitsOf32BitAddress;
218 using SpillRegMask = std::pair<unsigned, unsigned>;
223 unsigned NumVGPRSpillLanes = 0;
230 auto I = SGPRToVGPRSpills.
find(FrameIndex);
231 return (
I == SGPRToVGPRSpills.
end()) ?
247 return BytesInStackArgArea;
251 BytesInStackArgArea = Bytes;
313 return PrivateSegmentBuffer;
325 return KernargSegmentPtr;
333 return FlatScratchInit;
349 return WorkGroupInfo;
353 return PrivateSegmentWaveByteOffset;
369 return ImplicitArgPtr;
373 return ImplicitBufferPtr;
384 std::pair<const ArgDescriptor *, const TargetRegisterClass *>
398 return HighBitsOf32BitAddress;
406 return NumUserSGPRs + NumSystemSGPRs;
416 return ScratchRSrcReg;
420 assert(Reg != 0 &&
"Should never be unset");
421 ScratchRSrcReg =
Reg;
425 return ScratchWaveOffsetReg;
429 return FrameOffsetReg;
433 assert(Reg != 0 &&
"Should never be unset");
434 StackPtrOffsetReg =
Reg;
442 return StackPtrOffsetReg;
446 assert(Reg != 0 &&
"Should never be unset");
447 ScratchWaveOffsetReg =
Reg;
448 if (isEntryFunction())
449 FrameOffsetReg = ScratchWaveOffsetReg;
461 return HasSpilledSGPRs;
465 HasSpilledSGPRs = Spill;
469 return HasSpilledVGPRs;
473 HasSpilledVGPRs = Spill;
477 return HasNonSpillStackObjects;
481 HasNonSpillStackObjects = StackObject;
485 return IsStackRealigned;
489 IsStackRealigned = Realigned;
501 NumSpilledSGPRs += num;
505 NumSpilledVGPRs += num;
513 return PSInputEnable;
517 return PSInputAddr & (1 <<
Index);
521 PSInputAddr |= 1 <<
Index;
525 PSInputEnable |= 1 <<
Index;
539 return FlatWorkGroupSizes;
544 return FlatWorkGroupSizes.first;
549 return FlatWorkGroupSizes.second;
560 return WavesPerEU.first;
565 return WavesPerEU.second;
571 return DebuggerWorkGroupIDStackObjectIndices[Dim];
577 DebuggerWorkGroupIDStackObjectIndices[Dim] = ObjectIdx;
583 return DebuggerWorkItemIDStackObjectIndices[Dim];
589 DebuggerWorkItemIDStackObjectIndices[Dim] = ObjectIdx;
596 assert(hasWorkGroupIDX());
599 assert(hasWorkGroupIDY());
602 assert(hasWorkGroupIDZ());
609 unsigned getWorkItemIDVGPR(
unsigned Dim)
const;
612 return LDSWaveSpillSize;
616 const Value *BufferRsrc) {
618 auto PSV = BufferPSVs.try_emplace(
620 llvm::make_unique<AMDGPUBufferPseudoSourceValue>(TII));
621 return PSV.first->second.get();
625 const Value *ImgRsrc) {
627 auto PSV = ImagePSVs.try_emplace(
629 llvm::make_unique<AMDGPUImagePseudoSourceValue>(TII));
630 return PSV.first->second.get();
638 if (!isMemoryBound() && !needsWaveLimiter())
640 return (Occupancy < 4) ? Occupancy : 4;
646 if (Occupancy > Limit)
651 if (Occupancy < Limit)
659 #endif // LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H unsigned getFrameOffsetReg() const
unsigned getScratchWaveOffsetReg() const
void setWorkItemIDX(ArgDescriptor Arg)
bool hasDispatchPtr() const
Interface definition for SIRegisterInfo.
bool hasPrivateSegmentBuffer() const
ArgDescriptor WorkGroupInfo
ArgDescriptor WorkItemIDZ
bool isPSInputAllocated(unsigned Index) const
void addToSpilledSGPRs(unsigned num)
bool hasPrivateSegmentWaveByteOffset() const
This class represents lattice values for constants.
void addToSpilledVGPRs(unsigned num)
unsigned getStackPtrOffsetReg() const
unsigned getMaxFlatWorkGroupSize() const
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool hasImplicitBufferPtr() const
ArgDescriptor WorkItemIDX
unsigned addWorkGroupIDY()
ArgDescriptor WorkItemIDY
ArgDescriptor WorkGroupIDX
unsigned getPSInputAddr() const
bool hasWorkItemIDZ() const
unsigned const TargetRegisterInfo * TRI
void markPSInputEnabled(unsigned Index)
void setIsStackRealigned(bool Realigned=true)
bool hasSpilledVGPRs() const
bool hasDispatchID() const
constexpr char NumSpilledSGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSpilledSGPRs.
bool hasWorkItemIDX() const
int getDebuggerWorkGroupIDStackObjectIndex(unsigned Dim) const
bool hasFlatScratchInit() const
void setPrivateSegmentWaveByteOffset(unsigned Reg)
void setDebuggerWorkGroupIDStackObjectIndex(unsigned Dim, int ObjectIdx)
Sets stack object index for Dim's work group ID to ObjectIdx.
AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII)
void setScratchRSrcReg(unsigned Reg)
unsigned getBytesInStackArgArea() const
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getMinFlatWorkGroupSize() const
void setHasNonSpillStackObjects(bool StackObject=true)
const AMDGPUFunctionArgInfo & getArgInfo() const
void setDebuggerWorkItemIDStackObjectIndex(unsigned Dim, int ObjectIdx)
Sets stack object index for Dim's work item ID to ObjectIdx.
void setIfReturnsVoid(bool Value)
unsigned get32BitAddressHighBits() const
void setHasSpilledVGPRs(bool Spill=true)
void setTIDReg(unsigned Reg)
ArrayRef< SpilledReg > getSGPRToVGPRSpills(int FrameIndex) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
ArgDescriptor WorkGroupIDY
ArgDescriptor WorkGroupIDZ
unsigned getGITPtrHigh() const
SGPRSpillVGPRCSR(unsigned V, Optional< int > F)
void setStackPtrOffsetReg(unsigned Reg)
void increaseOccupancy(const MachineFunction &MF, unsigned Limit)
unsigned getNumSpilledSGPRs() const
ArgDescriptor PrivateSegmentWaveByteOffset
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getMaxWavesPerEU() const
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
void markPSInputAllocated(unsigned Index)
bool hasWorkGroupIDX() const
unsigned getMinAllowedOccupancy() const
std::pair< unsigned, unsigned > getFlatWorkGroupSizes() const
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
unsigned addWorkGroupInfo()
unsigned getOccupancy() const
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(PreloadedValue Value) const
const AMDGPUBufferPseudoSourceValue * getBufferPSV(const SIInstrInfo &TII, const Value *BufferRsrc)
static ArgDescriptor createRegister(unsigned Reg)
bool hasWorkItemIDY() const
std::pair< unsigned, unsigned > getWavesPerEU() const
bool hasWorkGroupIDY() const
AMDGPUFunctionArgInfo & getArgInfo()
void limitOccupancy(unsigned Limit)
void setHasSpilledSGPRs(bool Spill=true)
ArrayRef< SGPRSpillVGPRCSR > getSGPRSpillVGPRs() const
void setScratchWaveOffsetReg(unsigned Reg)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool hasImplicitArgPtr() const
unsigned getQueuePtrUserSGPR() const
bool hasSpilledSGPRs() const
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
bool hasKernargSegmentPtr() const
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
bool isStackRealigned() const
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
void setWorkItemIDZ(ArgDescriptor Arg)
unsigned getNumSpilledVGPRs() const
unsigned getPrivateSegmentWaveByteOffsetSystemSGPR() const
Special value supplied for machine level alias analysis.
amdgpu Simplify well known AMD library false Value Value * Arg
unsigned getLDSWaveSpillSize() const
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(AMDGPUFunctionArgInfo::PreloadedValue Value) const
unsigned getPSInputEnable() const
Provides AMDGPU specific target descriptions.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
unsigned getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
constexpr char NumSpilledVGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSpilledVGPRs.
unsigned getImplicitBufferPtrUserSGPR() const
SpilledReg(unsigned R, int L)
bool hasCalculatedTID() const
unsigned getMinWavesPerEU() const
unsigned addWorkGroupIDZ()
bool hasWorkGroupInfo() const
unsigned addPrivateSegmentWaveByteOffset()
unsigned getRegister() const
unsigned getNumUserSGPRs() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
const AMDGPUImagePseudoSourceValue * getImagePSV(const SIInstrInfo &TII, const Value *ImgRsrc)
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
unsigned getNumPreloadedSGPRs() const
bool hasWorkGroupIDZ() const
unsigned getTIDReg() const
ArgDescriptor ImplicitBufferPtr
int getDebuggerWorkItemIDStackObjectIndex(unsigned Dim) const
void setWorkItemIDY(ArgDescriptor Arg)
void setBytesInStackArgArea(unsigned Bytes)
unsigned addWorkGroupIDX()
AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII)
unsigned getWorkGroupIDSGPR(unsigned Dim) const
bool hasNonSpillStackObjects() const