13 #ifndef LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H 14 #define LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H 39 class MachineFrameInfo;
40 class MachineFunction;
41 class TargetRegisterClass;
131 ::new ((
void *)std::addressof(RegisterName))
140 ::new ((
void *)std::addressof(RegisterName))
149 RegisterName.~StringValue();
166 if (YamlIO.outputting()) {
172 auto Keys = YamlIO.keys();
174 A = SIArgument::createArgument(
true);
179 YamlIO.setError(
"missing required key 'reg' or 'offset'");
181 YamlIO.mapOptional(
"mask", A.
Mask);
183 static const bool flow =
true;
213 YamlIO.mapOptional(
"queuePtr", AI.
QueuePtr);
215 YamlIO.mapOptional(
"dispatchID", AI.
DispatchID);
223 YamlIO.mapOptional(
"privateSegmentWaveByteOffset",
238 bool DX10Clamp =
true;
239 bool FP32Denormals =
true;
240 bool FP64FP16Denormals =
true;
252 return IEEE == Other.
IEEE &&
261 YamlIO.mapOptional(
"ieee", Mode.
IEEE,
true);
262 YamlIO.mapOptional(
"dx10-clamp", Mode.
DX10Clamp,
true);
263 YamlIO.mapOptional(
"fp32-denormals", Mode.
FP32Denormals,
true);
269 uint64_t ExplicitKernArgSize = 0;
270 unsigned MaxKernArgAlign = 0;
271 unsigned LDSSize = 0;
272 bool IsEntryFunction =
false;
273 bool NoSignedZerosFPMath =
false;
274 bool MemoryBound =
false;
275 bool WaveLimiter =
false;
290 void mappingImpl(yaml::IO &
YamlIO)
override;
299 YamlIO.mapOptional(
"ldsSize", MFI.
LDSSize, 0u);
302 YamlIO.mapOptional(
"memoryBound", MFI.
MemoryBound,
false);
303 YamlIO.mapOptional(
"waveLimiter", MFI.
WaveLimiter,
false);
312 YamlIO.mapOptional(
"argumentInfo", MFI.
ArgInfo);
313 YamlIO.mapOptional(
"mode", MFI.
Mode,
SIMode());
314 YamlIO.mapOptional(
"highBitsOf32BitAddress",
326 unsigned TIDReg = AMDGPU::NoRegister;
330 unsigned ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG;
331 unsigned ScratchWaveOffsetReg = AMDGPU::SCRATCH_WAVE_OFFSET_REG;
336 unsigned FrameOffsetReg = AMDGPU::FP_REG;
339 unsigned StackPtrOffsetReg = AMDGPU::SP_REG;
344 unsigned PSInputAddr = 0;
345 unsigned PSInputEnable = 0;
356 unsigned BytesInStackArgArea = 0;
358 bool ReturnsVoid =
true;
362 std::pair<unsigned, unsigned> FlatWorkGroupSizes = {0, 0};
366 std::pair<unsigned, unsigned> WavesPerEU = {0, 0};
369 std::unique_ptr<const AMDGPUBufferPseudoSourceValue>> BufferPSVs;
371 std::unique_ptr<const AMDGPUImagePseudoSourceValue>> ImagePSVs;
372 std::unique_ptr<const AMDGPUGWSResourcePseudoSourceValue> GWSResourcePSV;
375 unsigned LDSWaveSpillSize = 0;
376 unsigned NumUserSGPRs = 0;
377 unsigned NumSystemSGPRs = 0;
379 bool HasSpilledSGPRs =
false;
380 bool HasSpilledVGPRs =
false;
381 bool HasNonSpillStackObjects =
false;
382 bool IsStackRealigned =
false;
388 bool PrivateSegmentBuffer : 1;
389 bool DispatchPtr : 1;
391 bool KernargSegmentPtr : 1;
393 bool FlatScratchInit : 1;
396 bool WorkGroupIDX : 1;
397 bool WorkGroupIDY : 1;
398 bool WorkGroupIDZ : 1;
399 bool WorkGroupInfo : 1;
400 bool PrivateSegmentWaveByteOffset : 1;
402 bool WorkItemIDX : 1;
403 bool WorkItemIDY : 1;
404 bool WorkItemIDZ : 1;
409 bool ImplicitBufferPtr : 1;
413 bool ImplicitArgPtr : 1;
420 unsigned HighBitsOf32BitAddress;
455 bool FullyAllocated =
false;
464 using SpillRegMask = std::pair<unsigned, unsigned>;
469 unsigned NumVGPRSpillLanes = 0;
483 unsigned SGPRForFPSaveRestoreCopy = 0;
492 auto I = SGPRToVGPRSpills.
find(FrameIndex);
493 return (
I == SGPRToVGPRSpills.
end()) ?
510 auto I = VGPRToAGPRSpills.
find(FrameIndex);
511 return (
I == VGPRToAGPRSpills.
end()) ? (
MCPhysReg)AMDGPU::NoRegister
512 :
I->second.Lanes[Lane];
516 unsigned NumLane)
const;
518 bool allocateVGPRSpillToAGPR(
MachineFunction &MF,
int FI,
bool isAGPRtoVGPR);
526 return BytesInStackArgArea;
530 BytesInStackArgArea = Bytes;
592 return PrivateSegmentBuffer;
604 return KernargSegmentPtr;
612 return FlatScratchInit;
628 return WorkGroupInfo;
632 return PrivateSegmentWaveByteOffset;
648 return ImplicitArgPtr;
652 return ImplicitBufferPtr;
663 std::pair<const ArgDescriptor *, const TargetRegisterClass *>
678 return HighBitsOf32BitAddress;
690 return NumUserSGPRs + NumSystemSGPRs;
700 return ScratchRSrcReg;
704 assert(Reg != 0 &&
"Should never be unset");
705 ScratchRSrcReg =
Reg;
709 return ScratchWaveOffsetReg;
713 return FrameOffsetReg;
717 assert(Reg != 0 &&
"Should never be unset");
718 FrameOffsetReg =
Reg;
722 assert(Reg != 0 &&
"Should never be unset");
723 StackPtrOffsetReg =
Reg;
731 return StackPtrOffsetReg;
735 assert(Reg != 0 &&
"Should never be unset");
736 ScratchWaveOffsetReg =
Reg;
748 return HasSpilledSGPRs;
752 HasSpilledSGPRs = Spill;
756 return HasSpilledVGPRs;
760 HasSpilledVGPRs = Spill;
764 return HasNonSpillStackObjects;
768 HasNonSpillStackObjects = StackObject;
772 return IsStackRealigned;
776 IsStackRealigned = Realigned;
788 NumSpilledSGPRs += num;
792 NumSpilledVGPRs += num;
800 return PSInputEnable;
804 return PSInputAddr & (1 <<
Index);
808 PSInputAddr |= 1 <<
Index;
812 PSInputEnable |= 1 <<
Index;
826 return FlatWorkGroupSizes;
831 return FlatWorkGroupSizes.first;
836 return FlatWorkGroupSizes.second;
847 return WavesPerEU.first;
852 return WavesPerEU.second;
859 assert(hasWorkGroupIDX());
862 assert(hasWorkGroupIDY());
865 assert(hasWorkGroupIDZ());
872 return LDSWaveSpillSize;
876 const Value *BufferRsrc) {
878 auto PSV = BufferPSVs.try_emplace(
880 std::make_unique<AMDGPUBufferPseudoSourceValue>(TII));
881 return PSV.first->second.get();
885 const Value *ImgRsrc) {
887 auto PSV = ImagePSVs.try_emplace(
889 std::make_unique<AMDGPUImagePseudoSourceValue>(TII));
890 return PSV.first->second.get();
894 if (!GWSResourcePSV) {
896 std::make_unique<AMDGPUGWSResourcePseudoSourceValue>(
TII);
899 return GWSResourcePSV.get();
907 if (!isMemoryBound() && !needsWaveLimiter())
909 return (Occupancy < 4) ? Occupancy : 4;
915 if (Occupancy > Limit)
920 if (Occupancy < Limit)
928 #endif // LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H unsigned getFrameOffsetReg() const
unsigned getScratchWaveOffsetReg() const
void setWorkItemIDX(ArgDescriptor Arg)
bool hasDispatchPtr() const
Optional< SIArgument > PrivateSegmentWaveByteOffset
StringValue FrameOffsetReg
static void mapping(IO &YamlIO, SIArgumentInfo &AI)
MCPhysReg getVGPRToAGPRSpill(int FrameIndex, unsigned Lane) const
Interface definition for SIRegisterInfo.
Register getRegister() const
bool hasPrivateSegmentBuffer() const
ArgDescriptor WorkGroupInfo
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
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
SmallVector< MCPhysReg, 32 > Lanes
unsigned getMaxFlatWorkGroupSize() const
Optional< SIArgument > KernargSegmentPtr
bool hasImplicitBufferPtr() const
ArgDescriptor WorkItemIDX
unsigned addWorkGroupIDY()
Optional< SIArgument > PrivateSegmentSize
ArgDescriptor WorkItemIDY
ArgDescriptor WorkGroupIDX
unsigned getPSInputAddr() const
bool hasWorkItemIDZ() const
static SIArgument createArgument(bool IsReg)
unsigned const TargetRegisterInfo * TRI
void markPSInputEnabled(unsigned Index)
void setIsStackRealigned(bool Realigned=true)
static void mapping(IO &YamlIO, SIMode &Mode)
bool hasSpilledVGPRs() const
bool hasDispatchID() const
Optional< SIArgument > WorkItemIDY
constexpr char NumSpilledSGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSpilledSGPRs.
bool hasWorkItemIDX() const
bool hasFlatScratchInit() const
void setPrivateSegmentWaveByteOffset(unsigned Reg)
AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII)
ArrayRef< MCPhysReg > getAGPRSpillVGPRs() const
void setScratchRSrcReg(unsigned Reg)
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
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 setIfReturnsVoid(bool Value)
StringValue StackPtrOffsetReg
bool IEEE
Floating point opcodes that support exception flag gathering quiet and propagate signaling NaN inputs...
Optional< SIArgument > DispatchPtr
void setHasSpilledVGPRs(bool Spill=true)
void setTIDReg(unsigned Reg)
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...
static bool IsRegister(const MCParsedAsmOperand &op)
ArrayRef< SpilledReg > getSGPRToVGPRSpills(int FrameIndex) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
ArgDescriptor WorkGroupIDY
AMDGPUPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
ArgDescriptor WorkGroupIDZ
Optional< SIArgument > ImplicitArgPtr
unsigned getGITPtrHigh() const
SIMode(const AMDGPU::SIModeRegisterDefaults &Mode)
SGPRSpillVGPRCSR(unsigned V, Optional< int > F)
SIArgument & operator=(const SIArgument &Other)
Optional< SIArgument > FlatScratchInit
void setStackPtrOffsetReg(unsigned Reg)
void increaseOccupancy(const MachineFunction &MF, unsigned Limit)
uint32_t get32BitAddressHighBits() const
unsigned getNumSpilledSGPRs() const
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
ArgDescriptor PrivateSegmentWaveByteOffset
StringValue ScratchWaveOffsetReg
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getMaxWavesPerEU() const
bool FP32Denormals
If this is set, neither input or output denormals are flushed for most f32 instructions.
void markPSInputAllocated(unsigned Index)
bool hasWorkGroupIDX() const
unsigned getMinAllowedOccupancy() const
std::pair< unsigned, unsigned > getFlatWorkGroupSizes() const
Optional< SIArgumentInfo > ArgInfo
TargetInstrInfo - Interface to description of machine instruction set.
Optional< SIArgument > WorkItemIDX
iterator find(const_arg_type_t< KeyT > Val)
const AMDGPUGWSResourcePseudoSourceValue * getGWSPSV(const SIInstrInfo &TII)
void setFrameOffsetReg(unsigned Reg)
static void mapping(IO &YamlIO, SIMachineFunctionInfo &MFI)
Optional< SIArgument > QueuePtr
unsigned addWorkGroupInfo()
unsigned getOccupancy() const
SIArgument(const SIArgument &Other)
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(PreloadedValue Value) const
Optional< SIArgument > DispatchID
const AMDGPUBufferPseudoSourceValue * getBufferPSV(const SIInstrInfo &TII, const Value *BufferRsrc)
bool DX10Clamp
Used by the vector ALU to force DX10-style treatment of NaNs: when set, clamp NaN to zero; otherwise...
bool hasWorkItemIDY() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
std::pair< unsigned, unsigned > getWavesPerEU() const
bool hasWorkGroupIDY() const
AMDGPUFunctionArgInfo & getArgInfo()
static bool classof(const PseudoSourceValue *V)
Optional< SIArgument > WorkGroupIDZ
void limitOccupancy(unsigned Limit)
void setHasSpilledSGPRs(bool Spill=true)
ArrayRef< SGPRSpillVGPRCSR > getSGPRSpillVGPRs() const
void setScratchWaveOffsetReg(unsigned Reg)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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...
#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 mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
bool hasKernargSegmentPtr() const
static bool classof(const PseudoSourceValue *V)
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...
Optional< unsigned > Mask
bool isStackRealigned() const
Promote Memory to Register
static bool classof(const PseudoSourceValue *V)
Optional< SIArgument > PrivateSegmentBuffer
void setWorkItemIDZ(ArgDescriptor Arg)
unsigned getNumSpilledVGPRs() const
StringValue ScratchRSrcReg
unsigned getPrivateSegmentWaveByteOffsetSystemSGPR() const
SparseBitVector WWMReservedRegs
Special value supplied for machine level alias analysis.
Optional< SIArgument > WorkItemIDZ
Optional< SIArgument > WorkGroupIDY
void ReserveWWMRegister(unsigned reg)
A wrapper around std::string which contains a source range that's being set during parsing...
unsigned getLDSWaveSpillSize() const
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(AMDGPUFunctionArgInfo::PreloadedValue Value) const
unsigned getPSInputEnable() const
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
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.
Optional< SIArgument > ImplicitBufferPtr
constexpr char NumSpilledVGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSpilledVGPRs.
unsigned getImplicitBufferPtrUserSGPR() const
SpilledReg(unsigned R, int L)
bool hasCalculatedTID() const
unsigned getMinWavesPerEU() const
AMDGPUGWSResourcePseudoSourceValue(const TargetInstrInfo &TII)
unsigned addWorkGroupIDZ()
bool FP64FP16Denormals
If this is set, neither input or output denormals are flushed for both f64 and f16/v2f16 instructions...
uint32_t HighBitsOf32BitAddress
static void mapping(IO &YamlIO, SIArgument &A)
Optional< SIArgument > WorkGroupInfo
uint64_t ExplicitKernArgSize
bool hasWorkGroupInfo() const
unsigned addPrivateSegmentWaveByteOffset()
unsigned getNumUserSGPRs() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
const AMDGPUImagePseudoSourceValue * getImagePSV(const SIInstrInfo &TII, const Value *ImgRsrc)
unsigned getGDSSize() const
unsigned getNumPreloadedSGPRs() const
This class implements an extremely fast bulk output stream that can only output to a stream...
bool hasWorkGroupIDZ() const
unsigned getTIDReg() const
ArgDescriptor ImplicitBufferPtr
void setWorkItemIDY(ArgDescriptor Arg)
bool operator==(uint64_t V1, const APInt &V2)
ArrayRef< MCPhysReg > getVGPRSpillAGPRs() const
void setBytesInStackArgArea(unsigned Bytes)
unsigned addWorkGroupIDX()
AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII)
unsigned getWorkGroupIDSGPR(unsigned Dim) const
Optional< int > FramePointerSaveIndex
Wrapper class representing virtual and physical registers.
Optional< SIArgument > WorkGroupIDX
IEEE-754 denormal numbers preserved.
bool hasNonSpillStackObjects() const
Register getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.