30 "amdgpu-dump-hsa-metadata",
31 cl::desc(
"Dump AMDGPU HSA Metadata"));
33 "amdgpu-verify-hsa-metadata",
34 cl::desc(
"Verify AMDGPU HSA Metadata"));
42 void MetadataStreamerV2::dump(StringRef HSAMetadataString)
const {
43 errs() <<
"AMDGPU HSA Metadata:\n" << HSAMetadataString <<
'\n';
46 void MetadataStreamerV2::verify(StringRef HSAMetadataString)
const {
47 errs() <<
"AMDGPU HSA Metadata Parser Test: ";
49 HSAMD::Metadata FromHSAMetadataString;
50 if (
fromString(HSAMetadataString, FromHSAMetadataString)) {
55 std::string ToHSAMetadataString;
56 if (
toString(FromHSAMetadataString, ToHSAMetadataString)) {
61 errs() << (HSAMetadataString == ToHSAMetadataString ?
"PASS" :
"FAIL")
63 if (HSAMetadataString != ToHSAMetadataString) {
64 errs() <<
"Original input: " << HSAMetadataString <<
'\n' 65 <<
"Produced output: " << ToHSAMetadataString <<
'\n';
70 MetadataStreamerV2::getAccessQualifier(StringRef
AccQual)
const {
74 return StringSwitch<AccessQualifier>(
AccQual)
82 MetadataStreamerV2::getAddressSpaceQualifier(
84 switch (AddressSpace) {
102 ValueKind MetadataStreamerV2::getValueKind(Type *Ty, StringRef TypeQual,
103 StringRef BaseTypeName)
const {
107 return StringSwitch<ValueKind>(BaseTypeName)
122 .Default(isa<PointerType>(Ty) ?
123 (Ty->getPointerAddressSpace() ==
131 switch (Ty->getTypeID()) {
133 auto Signed = !TypeName.startswith(
"u");
134 switch (Ty->getIntegerBitWidth()) {
154 return getValueType(Ty->getPointerElementType(),
TypeName);
156 return getValueType(Ty->getVectorElementType(),
TypeName);
162 std::string MetadataStreamerV2::getTypeName(Type *Ty,
bool Signed)
const {
163 switch (Ty->getTypeID()) {
166 return (Twine(
'u') + getTypeName(Ty,
true)).str();
168 auto BitWidth = Ty->getIntegerBitWidth();
179 return (Twine(
'i') + Twine(BitWidth)).str();
189 auto VecTy = cast<VectorType>(Ty);
190 auto ElTy = VecTy->getElementType();
191 auto NumElements = VecTy->getVectorNumElements();
192 return (Twine(getTypeName(ElTy, Signed)) + Twine(NumElements)).str();
199 std::vector<uint32_t>
200 MetadataStreamerV2::getWorkGroupDimensions(MDNode *
Node)
const {
201 std::vector<uint32_t> Dims;
202 if (Node->getNumOperands() != 3)
205 for (
auto &
Op : Node->operands())
206 Dims.push_back(mdconst::extract<ConstantInt>(
Op)->getZExtValue());
210 Kernel::CodeProps::Metadata
211 MetadataStreamerV2::getHSACodeProps(
const MachineFunction &MF,
212 const SIProgramInfo &ProgramInfo)
const {
213 const GCNSubtarget &STM = MF.getSubtarget<GCNSubtarget>();
214 const SIMachineFunctionInfo &MFI = *MF.getInfo<SIMachineFunctionInfo>();
215 HSAMD::Kernel::CodeProps::Metadata HSACodeProps;
221 Align MaxKernArgAlign;
222 HSACodeProps.mKernargSegmentSize = STM.getKernArgSegmentSize(F,
224 HSACodeProps.mGroupSegmentFixedSize = ProgramInfo.LDSSize;
225 HSACodeProps.mPrivateSegmentFixedSize = ProgramInfo.ScratchSize;
226 HSACodeProps.mKernargSegmentAlign =
228 HSACodeProps.mWavefrontSize = STM.getWavefrontSize();
229 HSACodeProps.mNumSGPRs = ProgramInfo.NumSGPR;
230 HSACodeProps.mNumVGPRs = ProgramInfo.NumVGPR;
231 HSACodeProps.mMaxFlatWorkGroupSize = MFI.getMaxFlatWorkGroupSize();
232 HSACodeProps.mIsDynamicCallStack = ProgramInfo.DynamicCallStack;
233 HSACodeProps.mIsXNACKEnabled = STM.isXNACKEnabled();
234 HSACodeProps.mNumSpilledSGPRs = MFI.getNumSpilledSGPRs();
235 HSACodeProps.mNumSpilledVGPRs = MFI.getNumSpilledVGPRs();
240 Kernel::DebugProps::Metadata
241 MetadataStreamerV2::getHSADebugProps(
const MachineFunction &MF,
242 const SIProgramInfo &ProgramInfo)
const {
243 return HSAMD::Kernel::DebugProps::Metadata();
246 void MetadataStreamerV2::emitVersion() {
253 void MetadataStreamerV2::emitPrintf(
const Module &Mod) {
256 auto Node = Mod.getNamedMetadata(
"llvm.printf.fmts");
260 for (
auto Op : Node->operands())
261 if (
Op->getNumOperands())
262 Printf.push_back(cast<MDString>(
Op->getOperand(0))->getString());
265 void MetadataStreamerV2::emitKernelLanguage(
const Function &Func) {
269 auto Node = Func.getParent()->getNamedMetadata(
"opencl.ocl.version");
270 if (!Node || !Node->getNumOperands())
272 auto Op0 = Node->getOperand(0);
273 if (Op0->getNumOperands() <= 1)
276 Kernel.mLanguage =
"OpenCL C";
277 Kernel.mLanguageVersion.push_back(
278 mdconst::extract<ConstantInt>(Op0->getOperand(0))->getZExtValue());
279 Kernel.mLanguageVersion.push_back(
280 mdconst::extract<ConstantInt>(Op0->getOperand(1))->getZExtValue());
283 void MetadataStreamerV2::emitKernelAttrs(
const Function &Func) {
286 if (
auto Node = Func.getMetadata(
"reqd_work_group_size"))
287 Attrs.mReqdWorkGroupSize = getWorkGroupDimensions(Node);
288 if (
auto Node = Func.getMetadata(
"work_group_size_hint"))
289 Attrs.mWorkGroupSizeHint = getWorkGroupDimensions(Node);
290 if (
auto Node = Func.getMetadata(
"vec_type_hint")) {
291 Attrs.mVecTypeHint = getTypeName(
292 cast<ValueAsMetadata>(Node->getOperand(0))->
getType(),
293 mdconst::extract<ConstantInt>(Node->getOperand(1))->getZExtValue());
295 if (Func.hasFnAttribute(
"runtime-handle")) {
296 Attrs.mRuntimeHandle =
297 Func.getFnAttribute(
"runtime-handle").getValueAsString().str();
301 void MetadataStreamerV2::emitKernelArgs(
const Function &Func) {
302 for (
auto &
Arg : Func.args())
305 emitHiddenKernelArgs(Func);
308 void MetadataStreamerV2::emitKernelArg(
const Argument &
Arg) {
309 auto Func = Arg.getParent();
310 auto ArgNo = Arg.getArgNo();
314 Node = Func->getMetadata(
"kernel_arg_name");
315 if (Node && ArgNo < Node->getNumOperands())
316 Name = cast<MDString>(Node->getOperand(ArgNo))->getString();
317 else if (Arg.hasName())
318 Name = Arg.getName();
321 Node = Func->getMetadata(
"kernel_arg_type");
322 if (Node && ArgNo < Node->getNumOperands())
323 TypeName = cast<MDString>(Node->getOperand(ArgNo))->getString();
325 StringRef BaseTypeName;
326 Node = Func->getMetadata(
"kernel_arg_base_type");
327 if (Node && ArgNo < Node->getNumOperands())
328 BaseTypeName = cast<MDString>(Node->getOperand(ArgNo))->getString();
331 if (Arg.getType()->isPointerTy() && Arg.onlyReadsMemory() &&
332 Arg.hasNoAliasAttr()) {
333 AccQual =
"read_only";
335 Node = Func->getMetadata(
"kernel_arg_access_qual");
336 if (Node && ArgNo < Node->getNumOperands())
337 AccQual = cast<MDString>(Node->getOperand(ArgNo))->getString();
341 Node = Func->getMetadata(
"kernel_arg_type_qual");
342 if (Node && ArgNo < Node->getNumOperands())
343 TypeQual = cast<MDString>(Node->getOperand(ArgNo))->getString();
345 Type *Ty = Arg.getType();
346 const DataLayout &DL = Func->getParent()->getDataLayout();
349 if (
auto PtrTy = dyn_cast<PointerType>(Ty)) {
351 PointeeAlign = Arg.getParamAlignment();
352 if (PointeeAlign == 0)
353 PointeeAlign = DL.getABITypeAlignment(PtrTy->getElementType());
357 emitKernelArg(DL, Ty, getValueKind(Arg.getType(), TypeQual, BaseTypeName),
358 PointeeAlign, Name, TypeName, BaseTypeName, AccQual, TypeQual);
361 void MetadataStreamerV2::emitKernelArg(
const DataLayout &DL, Type *Ty,
363 unsigned PointeeAlign, StringRef Name,
365 StringRef BaseTypeName,
366 StringRef AccQual, StringRef TypeQual) {
367 HSAMetadata.
mKernels.back().mArgs.push_back(Kernel::Arg::Metadata());
368 auto &Arg = HSAMetadata.
mKernels.back().mArgs.back();
372 Arg.mSize = DL.getTypeAllocSize(Ty);
373 Arg.mAlign = DL.getABITypeAlignment(Ty);
375 Arg.mValueType = getValueType(Ty, BaseTypeName);
378 if (
auto PtrTy = dyn_cast<PointerType>(Ty))
379 Arg.mAddrSpaceQual = getAddressSpaceQualifier(PtrTy->getAddressSpace());
381 Arg.mAccQual = getAccessQualifier(AccQual);
385 SmallVector<StringRef, 1> SplitTypeQuals;
386 TypeQual.split(SplitTypeQuals,
" ", -1,
false);
387 for (StringRef
Key : SplitTypeQuals) {
388 auto P = StringSwitch<bool*>(
Key)
389 .Case(
"const", &Arg.mIsConst)
390 .Case(
"restrict", &Arg.mIsRestrict)
391 .Case(
"volatile", &Arg.mIsVolatile)
392 .Case(
"pipe", &Arg.mIsPipe)
399 void MetadataStreamerV2::emitHiddenKernelArgs(
const Function &Func) {
400 int HiddenArgNumBytes =
403 if (!HiddenArgNumBytes)
406 auto &DL = Func.getParent()->getDataLayout();
409 if (HiddenArgNumBytes >= 8)
411 if (HiddenArgNumBytes >= 16)
413 if (HiddenArgNumBytes >= 24)
421 if (HiddenArgNumBytes >= 32) {
422 if (Func.getParent()->getNamedMetadata(
"llvm.printf.fmts"))
424 else if (Func.getParent()->getFunction(
"__ockl_hostcall_internal")) {
427 assert(!Func.getParent()->getNamedMetadata(
"llvm.printf.fmts"));
435 if (HiddenArgNumBytes >= 48) {
436 if (Func.hasFnAttribute(
"calls-enqueue-kernel")) {
446 if (HiddenArgNumBytes >= 56)
460 std::string HSAMetadataString;
461 if (
toString(HSAMetadata, HSAMetadataString))
465 dump(HSAMetadataString);
467 verify(HSAMetadataString);
476 auto CodeProps = getHSACodeProps(MF, ProgramInfo);
477 auto DebugProps = getHSADebugProps(MF, ProgramInfo);
482 Kernel.mName = Func.getName();
484 emitKernelLanguage(Func);
485 emitKernelAttrs(Func);
486 emitKernelArgs(Func);
495 void MetadataStreamerV3::dump(
StringRef HSAMetadataString)
const {
496 errs() <<
"AMDGPU HSA Metadata:\n" << HSAMetadataString <<
'\n';
499 void MetadataStreamerV3::verify(
StringRef HSAMetadataString)
const {
500 errs() <<
"AMDGPU HSA Metadata Parser Test: ";
504 if (!FromHSAMetadataString.
fromYAML(HSAMetadataString)) {
509 std::string ToHSAMetadataString;
511 FromHSAMetadataString.
toYAML(StrOS);
513 errs() << (HSAMetadataString == StrOS.
str() ?
"PASS" :
"FAIL") <<
'\n';
514 if (HSAMetadataString != ToHSAMetadataString) {
515 errs() <<
"Original input: " << HSAMetadataString <<
'\n' 516 <<
"Produced output: " << StrOS.
str() <<
'\n';
521 MetadataStreamerV3::getAccessQualifier(
StringRef AccQual)
const {
523 .Case(
"read_only",
StringRef(
"read_only"))
524 .Case(
"write_only",
StringRef(
"write_only"))
525 .Case(
"read_write",
StringRef(
"read_write"))
530 MetadataStreamerV3::getAddressSpaceQualifier(
unsigned AddressSpace)
const {
531 switch (AddressSpace) {
555 .Case(
"image1d_t",
"image")
556 .
Case(
"image1d_array_t",
"image")
557 .
Case(
"image1d_buffer_t",
"image")
558 .
Case(
"image2d_t",
"image")
559 .
Case(
"image2d_array_t",
"image")
560 .
Case(
"image2d_array_depth_t",
"image")
561 .
Case(
"image2d_array_msaa_t",
"image")
562 .
Case(
"image2d_array_msaa_depth_t",
"image")
563 .
Case(
"image2d_depth_t",
"image")
564 .
Case(
"image2d_msaa_t",
"image")
565 .
Case(
"image2d_msaa_depth_t",
"image")
566 .
Case(
"image3d_t",
"image")
567 .
Case(
"sampler_t",
"sampler")
568 .
Case(
"queue_t",
"queue")
571 ?
"dynamic_shared_pointer" 582 return Signed ?
"i8" :
"u8";
584 return Signed ?
"i16" :
"u16";
586 return Signed ?
"i32" :
"u32";
588 return Signed ?
"i64" :
"u64";
608 std::string MetadataStreamerV3::getTypeName(
Type *Ty,
bool Signed)
const {
612 return (
Twine(
'u') + getTypeName(Ty,
true)).str();
635 auto VecTy = cast<VectorType>(Ty);
636 auto ElTy = VecTy->getElementType();
637 auto NumElements = VecTy->getVectorNumElements();
638 return (
Twine(getTypeName(ElTy, Signed)) +
Twine(NumElements)).str();
646 MetadataStreamerV3::getWorkGroupDimensions(
MDNode *Node)
const {
647 auto Dims = HSAMetadataDoc->getArrayNode();
652 Dims.
push_back(Dims.getDocument()->getNode(
653 uint64_t(mdconst::extract<ConstantInt>(
Op)->getZExtValue())));
657 void MetadataStreamerV3::emitVersion() {
658 auto Version = HSAMetadataDoc->getArrayNode();
661 getRootMetadata(
"amdhsa.version") =
Version;
664 void MetadataStreamerV3::emitPrintf(
const Module &Mod) {
669 auto Printf = HSAMetadataDoc->getArrayNode();
671 if (
Op->getNumOperands())
673 cast<MDString>(
Op->getOperand(0))->getString(),
true));
674 getRootMetadata(
"amdhsa.printf") =
Printf;
677 void MetadataStreamerV3::emitKernelLanguage(
const Function &Func,
684 if (Op0->getNumOperands() <= 1)
690 mdconst::extract<ConstantInt>(Op0->getOperand(0))->getZExtValue()));
692 mdconst::extract<ConstantInt>(Op0->getOperand(1))->getZExtValue()));
696 void MetadataStreamerV3::emitKernelAttrs(
const Function &Func,
699 if (
auto Node = Func.
getMetadata(
"reqd_work_group_size"))
700 Kern[
".reqd_workgroup_size"] = getWorkGroupDimensions(Node);
701 if (
auto Node = Func.
getMetadata(
"work_group_size_hint"))
702 Kern[
".workgroup_size_hint"] = getWorkGroupDimensions(Node);
703 if (
auto Node = Func.
getMetadata(
"vec_type_hint")) {
707 mdconst::extract<ConstantInt>(Node->
getOperand(1))->getZExtValue()),
717 void MetadataStreamerV3::emitKernelArgs(
const Function &Func,
720 auto Args = HSAMetadataDoc->getArrayNode();
721 for (
auto &Arg : Func.
args())
722 emitKernelArg(Arg, Offset,
Args);
724 emitHiddenKernelArgs(Func, Offset,
Args);
726 Kern[
".args"] =
Args;
729 void MetadataStreamerV3::emitKernelArg(
const Argument &Arg,
unsigned &
Offset,
737 if (Node && ArgNo < Node->getNumOperands())
738 Name = cast<MDString>(Node->
getOperand(ArgNo))->getString();
744 if (Node && ArgNo < Node->getNumOperands())
745 TypeName = cast<MDString>(Node->
getOperand(ArgNo))->getString();
749 if (Node && ArgNo < Node->getNumOperands())
750 BaseTypeName = cast<MDString>(Node->
getOperand(ArgNo))->getString();
755 AccQual =
"read_only";
757 Node = Func->
getMetadata(
"kernel_arg_access_qual");
758 if (Node && ArgNo < Node->getNumOperands())
759 AccQual = cast<MDString>(Node->
getOperand(ArgNo))->getString();
764 if (Node && ArgNo < Node->getNumOperands())
765 TypeQual = cast<MDString>(Node->
getOperand(ArgNo))->getString();
770 unsigned PointeeAlign = 0;
771 if (
auto PtrTy = dyn_cast<PointerType>(Ty)) {
774 if (PointeeAlign == 0)
780 getValueKind(Arg.
getType(), TypeQual, BaseTypeName), Offset,
781 Args, PointeeAlign, Name, TypeName, BaseTypeName, AccQual,
785 void MetadataStreamerV3::emitKernelArg(
const DataLayout &DL,
Type *Ty,
795 Arg[
".name"] = Arg.getDocument()->getNode(Name,
true);
796 if (!TypeName.
empty())
797 Arg[
".type_name"] = Arg.getDocument()->getNode(TypeName,
true);
800 Arg[
".size"] = Arg.getDocument()->getNode(
Size);
802 Arg[
".offset"] = Arg.getDocument()->getNode(Offset);
804 Arg[
".value_kind"] = Arg.getDocument()->getNode(ValueKind,
true);
806 Arg.getDocument()->getNode(getValueType(Ty, BaseTypeName),
true);
808 Arg[
".pointee_align"] = Arg.getDocument()->getNode(PointeeAlign);
810 if (
auto PtrTy = dyn_cast<PointerType>(Ty))
811 if (
auto Qualifier = getAddressSpaceQualifier(PtrTy->getAddressSpace()))
812 Arg[
".address_space"] = Arg.getDocument()->getNode(*Qualifier,
true);
814 if (
auto AQ = getAccessQualifier(AccQual))
815 Arg[
".access"] = Arg.getDocument()->getNode(*AQ,
true);
820 TypeQual.
split(SplitTypeQuals,
" ", -1,
false);
823 Arg[
".is_const"] = Arg.getDocument()->getNode(
true);
824 else if (
Key ==
"restrict")
825 Arg[
".is_restrict"] = Arg.getDocument()->getNode(
true);
826 else if (
Key ==
"volatile")
827 Arg[
".is_volatile"] = Arg.getDocument()->getNode(
true);
828 else if (
Key ==
"pipe")
829 Arg[
".is_pipe"] = Arg.getDocument()->getNode(
true);
835 void MetadataStreamerV3::emitHiddenKernelArgs(
const Function &Func,
838 int HiddenArgNumBytes =
841 if (!HiddenArgNumBytes)
847 if (HiddenArgNumBytes >= 8)
848 emitKernelArg(DL, Int64Ty,
"hidden_global_offset_x", Offset, Args);
849 if (HiddenArgNumBytes >= 16)
850 emitKernelArg(DL, Int64Ty,
"hidden_global_offset_y", Offset, Args);
851 if (HiddenArgNumBytes >= 24)
852 emitKernelArg(DL, Int64Ty,
"hidden_global_offset_z", Offset, Args);
859 if (HiddenArgNumBytes >= 32) {
861 emitKernelArg(DL, Int8PtrTy,
"hidden_printf_buffer", Offset, Args);
866 emitKernelArg(DL, Int8PtrTy,
"hidden_hostcall_buffer", Offset, Args);
868 emitKernelArg(DL, Int8PtrTy,
"hidden_none", Offset, Args);
873 if (HiddenArgNumBytes >= 48) {
875 emitKernelArg(DL, Int8PtrTy,
"hidden_default_queue", Offset, Args);
876 emitKernelArg(DL, Int8PtrTy,
"hidden_completion_action", Offset, Args);
878 emitKernelArg(DL, Int8PtrTy,
"hidden_none", Offset, Args);
879 emitKernelArg(DL, Int8PtrTy,
"hidden_none", Offset, Args);
884 if (HiddenArgNumBytes >= 56)
885 emitKernelArg(DL, Int8PtrTy,
"hidden_multigrid_sync_arg", Offset, Args);
895 auto Kern = HSAMetadataDoc->getMapNode();
897 Align MaxKernArgAlign;
900 Kern[
".group_segment_fixed_size"] =
902 Kern[
".private_segment_fixed_size"] =
904 Kern[
".kernarg_segment_align"] =
906 Kern[
".wavefront_size"] =
910 Kern[
".max_flat_workgroup_size"] =
912 Kern[
".sgpr_spill_count"] =
914 Kern[
".vgpr_spill_count"] =
927 getRootMetadata(
"amdhsa.kernels") = HSAMetadataDoc->getArrayNode();
931 std::string HSAMetadataString;
933 HSAMetadataDoc->toYAML(StrOS);
944 auto Kern = getHSAKernelProps(MF, ProgramInfo);
950 getRootMetadata(
"amdhsa.kernels").getArray(
true);
956 emitKernelLanguage(Func, Kern);
957 emitKernelAttrs(Func, Kern);
958 emitKernelArgs(Func, Kern);
961 Kernels.push_back(Kern);
Type * getVectorElementType() const
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents an incoming formal argument to a Function.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
2: 32-bit floating point type
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Document * getDocument() const
constexpr char PointeeAlign[]
Key for Kernel::Arg::Metadata::mPointeeAlign.
void toYAML(raw_ostream &OS)
Convert MsgPack Document to YAML text.
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Address space for global memory (RAT0, VTX0).
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
const MDOperand & getOperand(unsigned I) const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
unsigned getKernArgSegmentSize(const Function &F, Align &MaxAlign) const
1: 16-bit floating point type
static IntegerType * getInt64Ty(LLVMContext &C)
Address space for flat memory.
StringSwitch & Case(StringLiteral S, T Value)
Track resource usage for kernels / entry functions.
A DocNode that is an array.
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Type * getPointerElementType() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
TypeID getTypeID() const
Return the type id for the type.
constexpr char Printf[]
Key for HSA::Metadata::mPrintf.
Defines struct to track resource usage for kernels and entry functions.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
LLVM_NODISCARD R Default(T Value)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
bool fromYAML(StringRef S)
Read YAML text into the MsgPack document. Returns false on failure.
std::error_code fromString(std::string String, Metadata &HSAMetadata)
Converts String to HSAMetadata.
Address space for region memory. (GDS)
Type * getType() const
All values are typed, get the type of this value.
static cl::opt< bool > VerifyHSAMetadata("amdgpu-verify-hsa-metadata", cl::desc("Verify AMDGPU HSA Metadata"))
DocNode getNode()
Create a nil node associated with this Document.
op_range operands() const
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
uint64_t value() const
This is a hole in the type system and should not be abused.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
ArrayDocNode getArrayNode()
Create an empty Array node associated with this Document.
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
void push_back(DocNode N)
11: Arbitrary bit width integers
A switch()-like statement whose cases are string literals.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
static cl::opt< bool > DumpHSAMetadata("amdgpu-dump-hsa-metadata", cl::desc("Dump AMDGPU HSA Metadata"))
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static wasm::ValType getType(const TargetRegisterClass *RC)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
MapDocNode getMapNode()
Create an empty Map node associated with this Document.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
This struct is a compact representation of a valid (non-zero power of two) alignment.
AccessQualifier
Access qualifiers.
unsigned getWavefrontSize() const
Align max(MaybeAlign Lhs, Align Rhs)
16: SIMD 'packed' format, or other vector type
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned getParamAlignment() const
If this is a byval or inalloca argument, return its alignment.
Address space for local memory.
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
constexpr char CodeProps[]
Key for Kernel::Metadata::mCodeProps.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
constexpr char LanguageVersion[]
Key for Kernel::Metadata::mLanguageVersion.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
constexpr uint32_t VersionMinor
HSA metadata minor version.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Simple in-memory representation of a document of msgpack objects with ability to find and create arra...
constexpr char Kernels[]
Key for HSA::Metadata::mKernels.
std::error_code toString(Metadata HSAMetadata, std::string &String)
Converts HSAMetadata to String.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const Function * getParent() const
unsigned getIntegerBitWidth() const
StringRef getValueAsString() const
Return the attribute's value as a string.
constexpr char DebugProps[]
Key for Kernel::Metadata::mDebugProps.
AddressSpaceQualifier
Address space qualifiers.
StringRef getName() const
Return a constant reference to the value's name.
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
constexpr char AccQual[]
Key for Kernel::Arg::Metadata::mAccQual.
Address space for private memory.
3: 64-bit floating point type
virtual bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict)=0
Emit HSA Metadata.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
Module * getParent()
Get the module that this global value is contained inside of...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumOperands() const
Return number of MDNode operands.
Calling convention for AMDGPU code object kernels.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Address space for constant memory (VTX2).
constexpr uint32_t VersionMajor
HSA metadata major version.
iterator_range< arg_iterator > args()