41 #define GET_INSTRINFO_NAMED_OPS
42 #include "AMDGPUGenInstrInfo.inc"
43 #undef GET_INSTRINFO_NAMED_OPS
48 unsigned getBitMask(
unsigned Shift,
unsigned Width) {
49 return ((1 << Width) - 1) << Shift;
55 unsigned packBits(
unsigned Src,
unsigned Dst,
unsigned Shift,
unsigned Width) {
56 Dst &= ~(1 << Shift) & ~getBitMask(Shift, Width);
57 Dst |= (Src << Shift) & getBitMask(Shift, Width);
64 unsigned unpackBits(
unsigned Src,
unsigned Shift,
unsigned Width) {
65 return (Src & getBitMask(Shift, Width)) >> Shift;
69 unsigned getVmcntBitShiftLo() {
return 0; }
72 unsigned getVmcntBitWidthLo() {
return 4; }
75 unsigned getExpcntBitShift() {
return 4; }
78 unsigned getExpcntBitWidth() {
return 3; }
81 unsigned getLgkmcntBitShift() {
return 8; }
84 unsigned getLgkmcntBitWidth() {
return 4; }
87 unsigned getVmcntBitShiftHi() {
return 14; }
90 unsigned getVmcntBitWidthHi() {
return 2; }
97 "enable-packed-inlinable-literals",
98 cl::desc(
"Enable packed inlinable literals (v2f16, v2i16)"),
107 if (Features.test(FeatureISAVersion6_0_0))
109 if (Features.test(FeatureISAVersion6_0_1))
112 if (Features.test(FeatureISAVersion7_0_0))
114 if (Features.test(FeatureISAVersion7_0_1))
116 if (Features.test(FeatureISAVersion7_0_2))
118 if (Features.test(FeatureISAVersion7_0_3))
122 if (Features.test(FeatureISAVersion8_0_0))
124 if (Features.test(FeatureISAVersion8_0_1))
126 if (Features.test(FeatureISAVersion8_0_2))
128 if (Features.test(FeatureISAVersion8_0_3))
130 if (Features.test(FeatureISAVersion8_0_4))
132 if (Features.test(FeatureISAVersion8_1_0))
136 if (Features.test(FeatureISAVersion9_0_0))
138 if (Features.test(FeatureISAVersion9_0_1))
140 if (Features.test(FeatureISAVersion9_0_2))
142 if (Features.test(FeatureISAVersion9_0_3))
145 if (!Features.test(FeatureGCN) || Features.test(FeatureSouthernIslands))
151 if (Features.test(FeatureWavefrontSize16))
153 if (Features.test(FeatureWavefrontSize32))
160 if (Features.test(FeatureLocalMemorySize32768))
162 if (Features.test(FeatureLocalMemorySize65536))
173 unsigned FlatWorkGroupSize) {
174 if (!Features.test(FeatureGCN))
188 unsigned FlatWorkGroupSize) {
197 if (!Features.test(FeatureGCN))
204 unsigned FlatWorkGroupSize) {
218 unsigned FlatWorkGroupSize) {
225 if (Version.
Major >= 8)
236 if (Version.
Major >= 8)
242 if (Features.test(FeatureSGPRInitBug))
246 if (Version.
Major >= 8)
256 unsigned MinNumSGPRs =
270 if (Version.
Major >= 8 && !Addressable)
271 AddressableNumSGPRs = 112;
272 return std::min(MaxNumSGPRs, AddressableNumSGPRs);
296 unsigned MinNumVGPRs =
308 return std::min(MaxNumVGPRs, AddressableNumVGPRs);
317 memset(&Header, 0,
sizeof(Header));
358 int Result = Default;
364 Ctx.
emitError(
"can't parse integer attribute " + Name);
373 std::pair<int, int> Default,
374 bool OnlyFirstRequired) {
380 std::pair<int, int> Ints = Default;
382 if (Strs.first.trim().getAsInteger(0, Ints.first)) {
383 Ctx.
emitError(
"can't parse first integer attribute " + Name);
386 if (Strs.second.trim().getAsInteger(0, Ints.second)) {
387 if (!OnlyFirstRequired || !Strs.second.trim().empty()) {
388 Ctx.
emitError(
"can't parse second integer attribute " + Name);
397 unsigned VmcntLo = (1 << getVmcntBitWidthLo()) - 1;
398 if (Version.
Major < 9)
401 unsigned VmcntHi = ((1 << getVmcntBitWidthHi()) - 1) << getVmcntBitWidthLo();
402 return VmcntLo | VmcntHi;
406 return (1 << getExpcntBitWidth()) - 1;
410 return (1 << getLgkmcntBitWidth()) - 1;
414 unsigned VmcntLo = getBitMask(getVmcntBitShiftLo(), getVmcntBitWidthLo());
415 unsigned Expcnt = getBitMask(getExpcntBitShift(), getExpcntBitWidth());
416 unsigned Lgkmcnt = getBitMask(getLgkmcntBitShift(), getLgkmcntBitWidth());
417 unsigned Waitcnt = VmcntLo | Expcnt | Lgkmcnt;
418 if (Version.
Major < 9)
421 unsigned VmcntHi = getBitMask(getVmcntBitShiftHi(), getVmcntBitWidthHi());
422 return Waitcnt | VmcntHi;
427 unpackBits(Waitcnt, getVmcntBitShiftLo(), getVmcntBitWidthLo());
428 if (Version.
Major < 9)
432 unpackBits(Waitcnt, getVmcntBitShiftHi(), getVmcntBitWidthHi());
433 VmcntHi <<= getVmcntBitWidthLo();
434 return VmcntLo | VmcntHi;
438 return unpackBits(Waitcnt, getExpcntBitShift(), getExpcntBitWidth());
442 return unpackBits(Waitcnt, getLgkmcntBitShift(), getLgkmcntBitWidth());
446 unsigned &Vmcnt,
unsigned &Expcnt,
unsigned &Lgkmcnt) {
455 packBits(Vmcnt, Waitcnt, getVmcntBitShiftLo(), getVmcntBitWidthLo());
456 if (Version.
Major < 9)
459 Vmcnt >>= getVmcntBitWidthLo();
460 return packBits(Vmcnt, Waitcnt, getVmcntBitShiftHi(), getVmcntBitWidthHi());
465 return packBits(Expcnt, Waitcnt, getExpcntBitShift(), getExpcntBitWidth());
470 return packBits(Lgkmcnt, Waitcnt, getLgkmcntBitShift(), getLgkmcntBitWidth());
474 unsigned Vmcnt,
unsigned Expcnt,
unsigned Lgkmcnt) {
536 const unsigned FirstSubReg = TRI->
getSubReg(Reg, 1);
537 return SGPRClass.
contains(FirstSubReg != 0 ? FirstSubReg : Reg) ||
543 if (*R == Reg1)
return true;
552 case AMDGPU::FLAT_SCR:
554 return isCI(STI) ? AMDGPU::FLAT_SCR_ci : AMDGPU::FLAT_SCR_vi;
556 case AMDGPU::FLAT_SCR_LO:
558 return isCI(STI) ? AMDGPU::FLAT_SCR_LO_ci : AMDGPU::FLAT_SCR_LO_vi;
560 case AMDGPU::FLAT_SCR_HI:
562 return isCI(STI) ? AMDGPU::FLAT_SCR_HI_ci : AMDGPU::FLAT_SCR_HI_vi;
569 case AMDGPU::FLAT_SCR_ci:
570 case AMDGPU::FLAT_SCR_vi:
573 case AMDGPU::FLAT_SCR_LO_ci:
574 case AMDGPU::FLAT_SCR_LO_vi:
575 return AMDGPU::FLAT_SCR_LO;
577 case AMDGPU::FLAT_SCR_HI_ci:
578 case AMDGPU::FLAT_SCR_HI_vi:
579 return AMDGPU::FLAT_SCR_HI;
621 case AMDGPU::SGPR_32RegClassID:
622 case AMDGPU::VGPR_32RegClassID:
623 case AMDGPU::VS_32RegClassID:
624 case AMDGPU::SReg_32RegClassID:
625 case AMDGPU::SReg_32_XM0RegClassID:
627 case AMDGPU::SGPR_64RegClassID:
628 case AMDGPU::VS_64RegClassID:
629 case AMDGPU::SReg_64RegClassID:
630 case AMDGPU::VReg_64RegClassID:
632 case AMDGPU::VReg_96RegClassID:
634 case AMDGPU::SGPR_128RegClassID:
635 case AMDGPU::SReg_128RegClassID:
636 case AMDGPU::VReg_128RegClassID:
638 case AMDGPU::SReg_256RegClassID:
639 case AMDGPU::VReg_256RegClassID:
641 case AMDGPU::SReg_512RegClassID:
642 case AMDGPU::VReg_512RegClassID:
661 if (Literal >= -16 && Literal <= 64)
664 uint64_t Val =
static_cast<uint64_t
>(Literal);
674 (Val == 0x3fc45f306dc9c882 && HasInv2Pi);
678 if (Literal >= -16 && Literal <= 64)
700 (Val == 0x3e22f983 && HasInv2Pi);
707 if (Literal >= -16 && Literal <= 64)
710 uint16_t Val =
static_cast<uint16_t
>(Literal);
711 return Val == 0x3C00 ||
728 int16_t Lo16 =
static_cast<int16_t
>(Literal);
729 int16_t Hi16 =
static_cast<int16_t
>(Literal >> 16);
739 if (!Ptr || isa<UndefValue>(Ptr) || isa<Argument>(Ptr) ||
740 isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
749 return ByteOffset >> 2;
757 isUInt<20>(EncodedOffset);
792 if (Env ==
"amdgiz" || Env ==
"amdgizcl") {
Calling convention used for Mesa compute shaders.
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
static const unsigned UNKNOWN_ADDRESS_SPACE
static const unsigned CONSTANT_BUFFER_3
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
unsigned getMinNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
static const unsigned CONSTANT_BUFFER_12
unsigned mc2PseudoReg(unsigned Reg)
Convert hardware register Reg to a pseudo register.
unsigned getAddressableNumVGPRs(const FeatureBitset &Features)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static const unsigned CONSTANT_BUFFER_8
static const unsigned CONSTANT_BUFFER_5
A Module instance is used to store all the information related to an LLVM module. ...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool isGroupSegment(const GlobalValue *GV, AMDGPUAS AS)
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
unsigned getMaxWorkGroupsPerCU(const FeatureBitset &Features, unsigned FlatWorkGroupSize)
AMDGPUAS getAMDGPUAS(const Module &M)
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
Calling convention used for Mesa geometry shaders.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
unsigned getTotalNumVGPRs(const FeatureBitset &Features)
unsigned getMinWavesPerEU(const FeatureBitset &Features)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
unsigned getWavesPerWorkGroup(const FeatureBitset &Features, unsigned FlatWorkGroupSize)
static const unsigned LOCAL_ADDRESS
Address space for local memory.
std::pair< int, int > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< int, int > Default, bool OnlyFirstRequired)
unsigned getVGPREncodingGranule(const FeatureBitset &Features)
const Triple & getTargetTriple() const
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi)
uint32_t amd_kernel_code_version_major
unsigned getEUsPerCU(const FeatureBitset &Features)
uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the largest uint64_t less than or equal to Value and is Skew mod Align.
A description of a memory reference used in the backend.
unsigned getWavefrontSize(const FeatureBitset &Features)
bool isGlobalSegment(const GlobalValue *GV, AMDGPUAS AS)
unsigned getVGPRAllocGranule(const FeatureBitset &Features)
bool isRegIntersect(unsigned Reg0, unsigned Reg1, const MCRegisterInfo *TRI)
Is there any intersection between registers.
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
static const unsigned CONSTANT_BUFFER_15
AMD Kernel Code Object (amd_kernel_code_t).
unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc, unsigned OpNo)
Get size of register operand.
uint16_t amd_machine_version_major
Reg
All possible values of the reg field in the ModR/M byte.
This file contains the simple types necessary to represent the attributes associated with functions a...
unsigned getMinFlatWorkGroupSize(const FeatureBitset &Features)
unsigned encodeLgkmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt, unsigned Lgkmcnt)
unsigned decodeLgkmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
unsigned encodeExpcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt, unsigned Expcnt)
unsigned getMaxWavesPerCU(const FeatureBitset &Features)
Calling convention used for Mesa hull shaders.
unsigned getMaxNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU, bool Addressable)
unsigned getWaitcntBitMask(const IsaInfo::IsaVersion &Version)
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
uint8_t OperandType
Information about the type of the operand.
static const unsigned CONSTANT_BUFFER_9
uint8_t kernarg_segment_alignment
The maximum byte alignment of variables used by the kernel in the specified memory segment...
uint8_t group_segment_alignment
unsigned getMaxWavesPerEU(const FeatureBitset &Features)
static cl::opt< bool > EnablePackedInlinableLiterals("enable-packed-inlinable-literals", cl::desc("Enable packed inlinable literals (v2f16, v2i16)"), cl::init(false))
uint16_t amd_machine_version_minor
static const unsigned CONSTANT_BUFFER_7
unsigned getMaxFlatWorkGroupSize(const FeatureBitset &Features)
unsigned getID() const
getID() - Return the register class ID number.
uint32_t amd_kernel_code_version_minor
MCRegisterClass - Base class of TargetRegisterClass.
unsigned short NumOperands
uint32_t FloatToBits(float Float)
This function takes a float and returns the bit equivalent 32-bit integer.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
SPIR_KERNEL - Calling convention for SPIR kernel functions.
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
static const unsigned CONSTANT_BUFFER_4
initializer< Ty > init(const Ty &Val)
int64_t getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool isCompute(CallingConv::ID cc)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
bool isSI(const MCSubtargetInfo &STI)
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
Container class for subtarget features.
This is an important class for using LLVM in a threaded context.
void decodeWaitcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt)
Decodes Vmcnt, Expcnt and Lgkmcnt from given Waitcnt for given isa Version, and writes decoded values...
unsigned getTotalNumSGPRs(const FeatureBitset &Features)
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
bool isEntryFunctionCC(CallingConv::ID CC)
unsigned getMinNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
uint8_t private_segment_alignment
MCRegAliasIterator enumerates all registers aliasing Reg.
Instruction set architecture version.
static const unsigned PARAM_D_ADDRESS
Address space for direct addressible parameter memory (CONST0)
static const unsigned MAX_COMMON_ADDRESS
bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
unsigned REGION_ADDRESS
Address space for region memory.
bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo)
Does this opearnd support only inlinable literals?
Calling convention used for Mesa vertex shaders.
void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header, const FeatureBitset &Features)
Triple - Helper class for working with autoconf configuration names.
static const unsigned CONSTANT_BUFFER_13
unsigned decodeVmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
static const unsigned CONSTANT_BUFFER_0
unsigned getLgkmcntBitMask(const IsaInfo::IsaVersion &Version)
bool contains(unsigned Reg) const
contains - Return true if the specified register is included in this register class.
Calling convention used for Mesa pixel shaders.
Module.h This file contains the declarations for the Module class.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
static const unsigned CONSTANT_BUFFER_10
uint16_t amd_machine_version_stepping
static const unsigned CONSTANT_BUFFER_14
unsigned getExpcntBitMask(const IsaInfo::IsaVersion &Version)
uint8_t wavefront_size
Wavefront size expressed as a power of two.
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
static const unsigned CONSTANT_BUFFER_6
uint64_t DoubleToBits(double Double)
This function takes a double and returns the bit equivalent 64-bit integer.
static const unsigned CONSTANT_BUFFER_2
unsigned encodeVmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt, unsigned Vmcnt)
static const unsigned PARAM_I_ADDRESS
Address space for indirect addressible parameter memory (VTX1)
const Value * getValue() const
Return the base address of the memory access.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool isShader(CallingConv::ID cc)
static const unsigned CONSTANT_BUFFER_11
bool isCI(const MCSubtargetInfo &STI)
llvm_unreachable("Unknown RegBank!")
unsigned getInitialPSInputAddr(const Function &F)
bool isGFX9(const MCSubtargetInfo &STI)
Provides AMDGPU specific target descriptions.
PointerType * getType() const
Global values are always pointers.
static const unsigned CONSTANT_BUFFER_1
bool isVI(const MCSubtargetInfo &STI)
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
unsigned decodeExpcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt)
unsigned encodeWaitcnt(const IsaInfo::IsaVersion &Version, unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt)
Encodes Vmcnt, Expcnt and Lgkmcnt into Waitcnt for given isa Version.
unsigned FLAT_ADDRESS
Address space for flat memory.
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
MCSubtargetInfo - Generic base class for all target subtargets.
bool shouldEmitConstantsToTextSection(const Triple &TT)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getVmcntBitMask(const IsaInfo::IsaVersion &Version)
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
bool isUniformMMO(const MachineMemOperand *MMO)
static const unsigned CONSTANT_ADDRESS
Address space for constant memory (VTX2)
unsigned getAddressableNumSGPRs(const FeatureBitset &Features)
unsigned getSGPREncodingGranule(const FeatureBitset &Features)
int64_t kernel_code_entry_byte_offset
Byte offset (possibly negative) from start of amd_kernel_code_t object to kernel's entry point instru...
static const unsigned GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo)
Can this operand also contain immediate values?
StringRef getValueAsString() const
Return the attribute's value as a string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
LLVM Value Representation.
bool isReadOnlySegment(const GlobalValue *GV, AMDGPUAS AS)
const FeatureBitset Features
const MCOperandInfo * OpInfo
unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg...
uint16_t amd_machine_kind
unsigned getSGPRAllocGranule(const FeatureBitset &Features)
Primary interface to the complete machine description for the target machine.
unsigned getLocalMemorySize(const FeatureBitset &Features)
StringRef - Represent a constant reference to a string, i.e.
bool isSGPR(unsigned Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
unsigned getMaxNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
Calling convention for AMDGPU code object kernels.
IsaVersion getIsaVersion(const FeatureBitset &Features)
unsigned PRIVATE_ADDRESS
Address space for private memory.