//===--- AMDGPUMetadata.h ---------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // /// \file /// AMDGPU metadata definitions and in-memory representations. /// // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_AMDGPUMETADATA_H #define LLVM_SUPPORT_AMDGPUMETADATA_H #include "llvm/ADT/StringRef.h" #include <cstdint> #include <string> #include <system_error> #include <vector> namespace llvm { namespace AMDGPU { //===----------------------------------------------------------------------===// // HSA metadata. //===----------------------------------------------------------------------===// namespace HSAMD { /// HSA metadata major version for code object V3. constexpr uint32_t VersionMajorV3 = …; /// HSA metadata minor version for code object V3. constexpr uint32_t VersionMinorV3 = …; /// HSA metadata major version for code object V4. constexpr uint32_t VersionMajorV4 = …; /// HSA metadata minor version for code object V4. constexpr uint32_t VersionMinorV4 = …; /// HSA metadata major version for code object V5. constexpr uint32_t VersionMajorV5 = …; /// HSA metadata minor version for code object V5. constexpr uint32_t VersionMinorV5 = …; /// HSA metadata major version for code object V6. constexpr uint32_t VersionMajorV6 = …; /// HSA metadata minor version for code object V6. constexpr uint32_t VersionMinorV6 = …; /// Old HSA metadata beginning assembler directive for V2. This is only used for /// diagnostics now. /// HSA metadata beginning assembler directive. constexpr char AssemblerDirectiveBegin[] = …; /// Access qualifiers. enum class AccessQualifier : uint8_t { … }; /// Address space qualifiers. enum class AddressSpaceQualifier : uint8_t { … }; /// Value kinds. enum class ValueKind : uint8_t { … }; /// Value types. This is deprecated and only remains for compatibility parsing /// of old metadata. enum class ValueType : uint8_t { … }; //===----------------------------------------------------------------------===// // Kernel Metadata. //===----------------------------------------------------------------------===// namespace Kernel { //===----------------------------------------------------------------------===// // Kernel Attributes Metadata. //===----------------------------------------------------------------------===// namespace Attrs { namespace Key { /// Key for Kernel::Attr::Metadata::mReqdWorkGroupSize. constexpr char ReqdWorkGroupSize[] = …; /// Key for Kernel::Attr::Metadata::mWorkGroupSizeHint. constexpr char WorkGroupSizeHint[] = …; /// Key for Kernel::Attr::Metadata::mVecTypeHint. constexpr char VecTypeHint[] = …; /// Key for Kernel::Attr::Metadata::mRuntimeHandle. constexpr char RuntimeHandle[] = …; } // end namespace Key /// In-memory representation of kernel attributes metadata. struct Metadata final { … }; } // end namespace Attrs //===----------------------------------------------------------------------===// // Kernel Argument Metadata. //===----------------------------------------------------------------------===// namespace Arg { namespace Key { /// Key for Kernel::Arg::Metadata::mName. constexpr char Name[] = …; /// Key for Kernel::Arg::Metadata::mTypeName. constexpr char TypeName[] = …; /// Key for Kernel::Arg::Metadata::mSize. constexpr char Size[] = …; /// Key for Kernel::Arg::Metadata::mOffset. constexpr char Offset[] = …; /// Key for Kernel::Arg::Metadata::mAlign. constexpr char Align[] = …; /// Key for Kernel::Arg::Metadata::mValueKind. constexpr char ValueKind[] = …; /// Key for Kernel::Arg::Metadata::mValueType. (deprecated) constexpr char ValueType[] = …; /// Key for Kernel::Arg::Metadata::mPointeeAlign. constexpr char PointeeAlign[] = …; /// Key for Kernel::Arg::Metadata::mAddrSpaceQual. constexpr char AddrSpaceQual[] = …; /// Key for Kernel::Arg::Metadata::mAccQual. constexpr char AccQual[] = …; /// Key for Kernel::Arg::Metadata::mActualAccQual. constexpr char ActualAccQual[] = …; /// Key for Kernel::Arg::Metadata::mIsConst. constexpr char IsConst[] = …; /// Key for Kernel::Arg::Metadata::mIsRestrict. constexpr char IsRestrict[] = …; /// Key for Kernel::Arg::Metadata::mIsVolatile. constexpr char IsVolatile[] = …; /// Key for Kernel::Arg::Metadata::mIsPipe. constexpr char IsPipe[] = …; } // end namespace Key /// In-memory representation of kernel argument metadata. struct Metadata final { … }; } // end namespace Arg //===----------------------------------------------------------------------===// // Kernel Code Properties Metadata. //===----------------------------------------------------------------------===// namespace CodeProps { namespace Key { /// Key for Kernel::CodeProps::Metadata::mKernargSegmentSize. constexpr char KernargSegmentSize[] = …; /// Key for Kernel::CodeProps::Metadata::mGroupSegmentFixedSize. constexpr char GroupSegmentFixedSize[] = …; /// Key for Kernel::CodeProps::Metadata::mPrivateSegmentFixedSize. constexpr char PrivateSegmentFixedSize[] = …; /// Key for Kernel::CodeProps::Metadata::mKernargSegmentAlign. constexpr char KernargSegmentAlign[] = …; /// Key for Kernel::CodeProps::Metadata::mWavefrontSize. constexpr char WavefrontSize[] = …; /// Key for Kernel::CodeProps::Metadata::mNumSGPRs. constexpr char NumSGPRs[] = …; /// Key for Kernel::CodeProps::Metadata::mNumVGPRs. constexpr char NumVGPRs[] = …; /// Key for Kernel::CodeProps::Metadata::mMaxFlatWorkGroupSize. constexpr char MaxFlatWorkGroupSize[] = …; /// Key for Kernel::CodeProps::Metadata::mIsDynamicCallStack. constexpr char IsDynamicCallStack[] = …; /// Key for Kernel::CodeProps::Metadata::mIsXNACKEnabled. constexpr char IsXNACKEnabled[] = …; /// Key for Kernel::CodeProps::Metadata::mNumSpilledSGPRs. constexpr char NumSpilledSGPRs[] = …; /// Key for Kernel::CodeProps::Metadata::mNumSpilledVGPRs. constexpr char NumSpilledVGPRs[] = …; } // end namespace Key /// In-memory representation of kernel code properties metadata. struct Metadata final { … }; } // end namespace CodeProps //===----------------------------------------------------------------------===// // Kernel Debug Properties Metadata. //===----------------------------------------------------------------------===// namespace DebugProps { namespace Key { /// Key for Kernel::DebugProps::Metadata::mDebuggerABIVersion. constexpr char DebuggerABIVersion[] = …; /// Key for Kernel::DebugProps::Metadata::mReservedNumVGPRs. constexpr char ReservedNumVGPRs[] = …; /// Key for Kernel::DebugProps::Metadata::mReservedFirstVGPR. constexpr char ReservedFirstVGPR[] = …; /// Key for Kernel::DebugProps::Metadata::mPrivateSegmentBufferSGPR. constexpr char PrivateSegmentBufferSGPR[] = …; /// Key for /// Kernel::DebugProps::Metadata::mWavefrontPrivateSegmentOffsetSGPR. constexpr char WavefrontPrivateSegmentOffsetSGPR[] = …; } // end namespace Key /// In-memory representation of kernel debug properties metadata. struct Metadata final { … }; } // end namespace DebugProps namespace Key { /// Key for Kernel::Metadata::mName. constexpr char Name[] = …; /// Key for Kernel::Metadata::mSymbolName. constexpr char SymbolName[] = …; /// Key for Kernel::Metadata::mLanguage. constexpr char Language[] = …; /// Key for Kernel::Metadata::mLanguageVersion. constexpr char LanguageVersion[] = …; /// Key for Kernel::Metadata::mAttrs. constexpr char Attrs[] = …; /// Key for Kernel::Metadata::mArgs. constexpr char Args[] = …; /// Key for Kernel::Metadata::mCodeProps. constexpr char CodeProps[] = …; /// Key for Kernel::Metadata::mDebugProps. constexpr char DebugProps[] = …; } // end namespace Key /// In-memory representation of kernel metadata. struct Metadata final { … }; } // end namespace Kernel namespace Key { /// Key for HSA::Metadata::mVersion. constexpr char Version[] = …; /// Key for HSA::Metadata::mPrintf. constexpr char Printf[] = …; /// Key for HSA::Metadata::mKernels. constexpr char Kernels[] = …; } // end namespace Key /// In-memory representation of HSA metadata. struct Metadata final { … }; /// Converts \p String to \p HSAMetadata. std::error_code fromString(StringRef String, Metadata &HSAMetadata); /// Converts \p HSAMetadata to \p String. std::error_code toString(Metadata HSAMetadata, std::string &String); //===----------------------------------------------------------------------===// // HSA metadata for v3 code object. //===----------------------------------------------------------------------===// namespace V3 { /// HSA metadata major version. constexpr uint32_t VersionMajor = …; /// HSA metadata minor version. constexpr uint32_t VersionMinor = …; /// HSA metadata beginning assembler directive. constexpr char AssemblerDirectiveBegin[] = …; /// HSA metadata ending assembler directive. constexpr char AssemblerDirectiveEnd[] = …; } // end namespace V3 } // end namespace HSAMD //===----------------------------------------------------------------------===// // PAL metadata. //===----------------------------------------------------------------------===// namespace PALMD { /// PAL metadata (old linear format) assembler directive. constexpr char AssemblerDirective[] = …; /// PAL metadata (new MsgPack format) beginning assembler directive. constexpr char AssemblerDirectiveBegin[] = …; /// PAL metadata (new MsgPack format) ending assembler directive. constexpr char AssemblerDirectiveEnd[] = …; /// PAL metadata keys. enum Key : uint32_t { … }; } // end namespace PALMD } // end namespace AMDGPU } // end namespace llvm #endif // LLVM_SUPPORT_AMDGPUMETADATA_H