Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 1 | //===--- AMDGPUCodeObjectMetadata.h -----------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | /// \file |
| 11 | /// \brief AMDGPU Code Object Metadata definitions and in-memory |
| 12 | /// representations. |
| 13 | /// |
| 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATA_H |
| 18 | #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATA_H |
| 19 | |
| 20 | #include <cstdint> |
| 21 | #include <string> |
| 22 | #include <system_error> |
| 23 | #include <vector> |
| 24 | |
| 25 | namespace llvm { |
| 26 | namespace AMDGPU { |
| 27 | |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | // Code Object Metadata. |
| 30 | //===----------------------------------------------------------------------===// |
| 31 | namespace CodeObject { |
| 32 | |
| 33 | /// \brief Code object metadata major version. |
| 34 | constexpr uint32_t MetadataVersionMajor = 1; |
| 35 | /// \brief Code object metadata minor version. |
| 36 | constexpr uint32_t MetadataVersionMinor = 0; |
| 37 | |
| 38 | /// \brief Code object metadata beginning assembler directive. |
| 39 | constexpr char MetadataAssemblerDirectiveBegin[] = |
| 40 | ".amdgpu_code_object_metadata"; |
| 41 | /// \brief Code object metadata ending assembler directive. |
| 42 | constexpr char MetadataAssemblerDirectiveEnd[] = |
| 43 | ".end_amdgpu_code_object_metadata"; |
| 44 | |
| 45 | /// \brief Access qualifiers. |
| 46 | enum class AccessQualifier : uint8_t { |
| 47 | Default = 0, |
| 48 | ReadOnly = 1, |
| 49 | WriteOnly = 2, |
| 50 | ReadWrite = 3, |
| 51 | Unknown = 0xff |
| 52 | }; |
| 53 | |
| 54 | /// \brief Address space qualifiers. |
| 55 | enum class AddressSpaceQualifier : uint8_t { |
| 56 | Private = 0, |
| 57 | Global = 1, |
| 58 | Constant = 2, |
| 59 | Local = 3, |
| 60 | Generic = 4, |
| 61 | Region = 5, |
| 62 | Unknown = 0xff |
| 63 | }; |
| 64 | |
| 65 | /// \brief Value kinds. |
| 66 | enum class ValueKind : uint8_t { |
| 67 | ByValue = 0, |
| 68 | GlobalBuffer = 1, |
| 69 | DynamicSharedPointer = 2, |
| 70 | Sampler = 3, |
| 71 | Image = 4, |
| 72 | Pipe = 5, |
| 73 | Queue = 6, |
| 74 | HiddenGlobalOffsetX = 7, |
| 75 | HiddenGlobalOffsetY = 8, |
| 76 | HiddenGlobalOffsetZ = 9, |
| 77 | HiddenNone = 10, |
| 78 | HiddenPrintfBuffer = 11, |
| 79 | HiddenDefaultQueue = 12, |
| 80 | HiddenCompletionAction = 13, |
| 81 | Unknown = 0xff |
| 82 | }; |
| 83 | |
| 84 | /// \brief Value types. |
| 85 | enum class ValueType : uint8_t { |
| 86 | Struct = 0, |
| 87 | I8 = 1, |
| 88 | U8 = 2, |
| 89 | I16 = 3, |
| 90 | U16 = 4, |
| 91 | F16 = 5, |
| 92 | I32 = 6, |
| 93 | U32 = 7, |
| 94 | F32 = 8, |
| 95 | I64 = 9, |
| 96 | U64 = 10, |
| 97 | F64 = 11, |
| 98 | Unknown = 0xff |
| 99 | }; |
| 100 | |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | // Instruction Set Architecture Metadata (ISA). |
| 103 | //===----------------------------------------------------------------------===// |
| 104 | namespace Isa { |
| 105 | |
| 106 | namespace Key { |
| 107 | /// \brief Key for Isa::Metadata::mWavefrontSize. |
| 108 | constexpr char WavefrontSize[] = "WavefrontSize"; |
| 109 | /// \brief Key for Isa::Metadata::mLocalMemorySize. |
| 110 | constexpr char LocalMemorySize[] = "LocalMemorySize"; |
| 111 | /// \brief Key for Isa::Metadata::mEUsPerCU. |
| 112 | constexpr char EUsPerCU[] = "EUsPerCU"; |
| 113 | /// \brief Key for Isa::Metadata::mMaxWavesPerEU. |
| 114 | constexpr char MaxWavesPerEU[] = "MaxWavesPerEU"; |
| 115 | /// \brief Key for Isa::Metadata::mMaxFlatWorkGroupSize. |
| 116 | constexpr char MaxFlatWorkGroupSize[] = "MaxFlatWorkGroupSize"; |
| 117 | /// \brief Key for Isa::Metadata::mSGPRAllocGranule. |
| 118 | constexpr char SGPRAllocGranule[] = "SGPRAllocGranule"; |
| 119 | /// \brief Key for Isa::Metadata::mTotalNumSGPRs. |
| 120 | constexpr char TotalNumSGPRs[] = "TotalNumSGPRs"; |
| 121 | /// \brief Key for Isa::Metadata::mAddressableNumSGPRs. |
| 122 | constexpr char AddressableNumSGPRs[] = "AddressableNumSGPRs"; |
| 123 | /// \brief Key for Isa::Metadata::mVGPRAllocGranule. |
| 124 | constexpr char VGPRAllocGranule[] = "VGPRAllocGranule"; |
| 125 | /// \brief Key for Isa::Metadata::mTotalNumVGPRs. |
| 126 | constexpr char TotalNumVGPRs[] = "TotalNumVGPRs"; |
| 127 | /// \brief Key for Isa::Metadata::mAddressableNumVGPRs. |
| 128 | constexpr char AddressableNumVGPRs[] = "AddressableNumVGPRs"; |
| 129 | } // end namespace Key |
| 130 | |
| 131 | /// \brief In-memory representation of instruction set architecture metadata. |
| 132 | struct Metadata final { |
| 133 | /// \brief Wavefront size. Required. |
| 134 | uint32_t mWavefrontSize = 0; |
| 135 | /// \brief Local memory size in bytes. Required. |
| 136 | uint32_t mLocalMemorySize = 0; |
| 137 | /// \brief Number of execution units per compute unit. Required. |
| 138 | uint32_t mEUsPerCU = 0; |
| 139 | /// \brief Maximum number of waves per execution unit. Required. |
| 140 | uint32_t mMaxWavesPerEU = 0; |
| 141 | /// \brief Maximum flat work group size. Required. |
| 142 | uint32_t mMaxFlatWorkGroupSize = 0; |
| 143 | /// \brief SGPR allocation granularity. Required. |
| 144 | uint32_t mSGPRAllocGranule = 0; |
| 145 | /// \brief Total number of SGPRs. Required. |
| 146 | uint32_t mTotalNumSGPRs = 0; |
| 147 | /// \brief Addressable number of SGPRs. Required. |
| 148 | uint32_t mAddressableNumSGPRs = 0; |
| 149 | /// \brief VGPR allocation granularity. Required. |
| 150 | uint32_t mVGPRAllocGranule = 0; |
| 151 | /// \brief Total number of VGPRs. Required. |
| 152 | uint32_t mTotalNumVGPRs = 0; |
| 153 | /// \brief Addressable number of VGPRs. Required. |
| 154 | uint32_t mAddressableNumVGPRs = 0; |
| 155 | |
| 156 | /// \brief Default constructor. |
| 157 | Metadata() = default; |
| 158 | }; |
| 159 | |
| 160 | } // end namespace Isa |
| 161 | |
| 162 | //===----------------------------------------------------------------------===// |
| 163 | // Kernel Metadata. |
| 164 | //===----------------------------------------------------------------------===// |
| 165 | namespace Kernel { |
| 166 | |
| 167 | //===----------------------------------------------------------------------===// |
| 168 | // Kernel Attributes Metadata. |
| 169 | //===----------------------------------------------------------------------===// |
| 170 | namespace Attrs { |
| 171 | |
| 172 | namespace Key { |
| 173 | /// \brief Key for Kernel::Attr::Metadata::mReqdWorkGroupSize. |
| 174 | constexpr char ReqdWorkGroupSize[] = "ReqdWorkGroupSize"; |
| 175 | /// \brief Key for Kernel::Attr::Metadata::mWorkGroupSizeHint. |
| 176 | constexpr char WorkGroupSizeHint[] = "WorkGroupSizeHint"; |
| 177 | /// \brief Key for Kernel::Attr::Metadata::mVecTypeHint. |
| 178 | constexpr char VecTypeHint[] = "VecTypeHint"; |
| 179 | } // end namespace Key |
| 180 | |
| 181 | /// \brief In-memory representation of kernel attributes metadata. |
| 182 | struct Metadata final { |
| 183 | /// \brief 'reqd_work_group_size' attribute. Optional. |
| 184 | std::vector<uint32_t> mReqdWorkGroupSize = std::vector<uint32_t>(); |
| 185 | /// \brief 'work_group_size_hint' attribute. Optional. |
| 186 | std::vector<uint32_t> mWorkGroupSizeHint = std::vector<uint32_t>(); |
| 187 | /// \brief 'vec_type_hint' attribute. Optional. |
| 188 | std::string mVecTypeHint = std::string(); |
| 189 | |
| 190 | /// \brief Default constructor. |
| 191 | Metadata() = default; |
| 192 | |
| 193 | /// \returns True if kernel attributes metadata is empty, false otherwise. |
| 194 | bool empty() const { |
| 195 | return mReqdWorkGroupSize.empty() && |
| 196 | mWorkGroupSizeHint.empty() && |
| 197 | mVecTypeHint.empty(); |
| 198 | } |
| 199 | |
| 200 | /// \returns True if kernel attributes metadata is not empty, false otherwise. |
| 201 | bool notEmpty() const { |
| 202 | return !empty(); |
| 203 | } |
| 204 | }; |
| 205 | |
| 206 | } // end namespace Attrs |
| 207 | |
| 208 | //===----------------------------------------------------------------------===// |
| 209 | // Kernel Argument Metadata. |
| 210 | //===----------------------------------------------------------------------===// |
| 211 | namespace Arg { |
| 212 | |
| 213 | namespace Key { |
| 214 | /// \brief Key for Kernel::Arg::Metadata::mSize. |
| 215 | constexpr char Size[] = "Size"; |
| 216 | /// \brief Key for Kernel::Arg::Metadata::mAlign. |
| 217 | constexpr char Align[] = "Align"; |
| 218 | /// \brief Key for Kernel::Arg::Metadata::mValueKind. |
| 219 | constexpr char Kind[] = "Kind"; |
| 220 | /// \brief Key for Kernel::Arg::Metadata::mValueType. |
| 221 | constexpr char ValueType[] = "ValueType"; |
| 222 | /// \brief Key for Kernel::Arg::Metadata::mPointeeAlign. |
| 223 | constexpr char PointeeAlign[] = "PointeeAlign"; |
| 224 | /// \brief Key for Kernel::Arg::Metadata::mAccQual. |
| 225 | constexpr char AccQual[] = "AccQual"; |
| 226 | /// \brief Key for Kernel::Arg::Metadata::mAddrSpaceQual. |
| 227 | constexpr char AddrSpaceQual[] = "AddrSpaceQual"; |
| 228 | /// \brief Key for Kernel::Arg::Metadata::mIsConst. |
| 229 | constexpr char IsConst[] = "IsConst"; |
| 230 | /// \brief Key for Kernel::Arg::Metadata::mIsPipe. |
| 231 | constexpr char IsPipe[] = "IsPipe"; |
| 232 | /// \brief Key for Kernel::Arg::Metadata::mIsRestrict. |
| 233 | constexpr char IsRestrict[] = "IsRestrict"; |
| 234 | /// \brief Key for Kernel::Arg::Metadata::mIsVolatile. |
| 235 | constexpr char IsVolatile[] = "IsVolatile"; |
| 236 | /// \brief Key for Kernel::Arg::Metadata::mName. |
| 237 | constexpr char Name[] = "Name"; |
| 238 | /// \brief Key for Kernel::Arg::Metadata::mTypeName. |
| 239 | constexpr char TypeName[] = "TypeName"; |
| 240 | } // end namespace Key |
| 241 | |
| 242 | /// \brief In-memory representation of kernel argument metadata. |
| 243 | struct Metadata final { |
| 244 | /// \brief Size in bytes. Required. |
| 245 | uint32_t mSize = 0; |
| 246 | /// \brief Alignment in bytes. Required. |
| 247 | uint32_t mAlign = 0; |
| 248 | /// \brief Value kind. Required. |
| 249 | ValueKind mValueKind = ValueKind::Unknown; |
| 250 | /// \brief Value type. Required. |
| 251 | ValueType mValueType = ValueType::Unknown; |
| 252 | /// \brief Pointee alignment in bytes. Optional. |
| 253 | uint32_t mPointeeAlign = 0; |
| 254 | /// \brief Access qualifier. Optional. |
| 255 | AccessQualifier mAccQual = AccessQualifier::Unknown; |
| 256 | /// \brief Address space qualifier. Optional. |
| 257 | AddressSpaceQualifier mAddrSpaceQual = AddressSpaceQualifier::Unknown; |
| 258 | /// \brief True if 'const' qualifier is specified. Optional. |
| 259 | bool mIsConst = false; |
| 260 | /// \brief True if 'pipe' qualifier is specified. Optional. |
| 261 | bool mIsPipe = false; |
| 262 | /// \brief True if 'restrict' qualifier is specified. Optional. |
| 263 | bool mIsRestrict = false; |
| 264 | /// \brief True if 'volatile' qualifier is specified. Optional. |
| 265 | bool mIsVolatile = false; |
| 266 | /// \brief Name. Optional. |
| 267 | std::string mName = std::string(); |
| 268 | /// \brief Type name. Optional. |
| 269 | std::string mTypeName = std::string(); |
| 270 | |
| 271 | /// \brief Default constructor. |
| 272 | Metadata() = default; |
| 273 | }; |
| 274 | |
| 275 | } // end namespace Arg |
| 276 | |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 277 | //===----------------------------------------------------------------------===// |
| 278 | // Kernel Code Properties Metadata. |
| 279 | //===----------------------------------------------------------------------===// |
| 280 | namespace CodeProps { |
| 281 | |
| 282 | namespace Key { |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 283 | /// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentSize. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 284 | constexpr char KernargSegmentSize[] = "KernargSegmentSize"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 285 | /// \brief Key for Kernel::CodeProps::Metadata::mWorkgroupGroupSegmentSize. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 286 | constexpr char WorkgroupGroupSegmentSize[] = "WorkgroupGroupSegmentSize"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 287 | /// \brief Key for Kernel::CodeProps::Metadata::mWorkitemPrivateSegmentSize. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 288 | constexpr char WorkitemPrivateSegmentSize[] = "WorkitemPrivateSegmentSize"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 289 | /// \brief Key for Kernel::CodeProps::Metadata::mWavefrontNumSGPRs. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 290 | constexpr char WavefrontNumSGPRs[] = "WavefrontNumSGPRs"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 291 | /// \brief Key for Kernel::CodeProps::Metadata::mWorkitemNumVGPRs. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 292 | constexpr char WorkitemNumVGPRs[] = "WorkitemNumVGPRs"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 293 | /// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentAlign. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 294 | constexpr char KernargSegmentAlign[] = "KernargSegmentAlign"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 295 | /// \brief Key for Kernel::CodeProps::Metadata::mGroupSegmentAlign. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 296 | constexpr char GroupSegmentAlign[] = "GroupSegmentAlign"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 297 | /// \brief Key for Kernel::CodeProps::Metadata::mPrivateSegmentAlign. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 298 | constexpr char PrivateSegmentAlign[] = "PrivateSegmentAlign"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 299 | /// \brief Key for Kernel::CodeProps::Metadata::mWavefrontSize. |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 300 | constexpr char WavefrontSize[] = "WavefrontSize"; |
| 301 | } // end namespace Key |
| 302 | |
| 303 | /// \brief In-memory representation of kernel code properties metadata. |
| 304 | struct Metadata final { |
| 305 | /// \brief Size in bytes of the kernarg segment memory. Kernarg segment memory |
| 306 | /// holds the values of the arguments to the kernel. Optional. |
| 307 | uint64_t mKernargSegmentSize = 0; |
| 308 | /// \brief Size in bytes of the group segment memory required by a workgroup. |
| 309 | /// This value does not include any dynamically allocated group segment memory |
| 310 | /// that may be added when the kernel is dispatched. Optional. |
| 311 | uint32_t mWorkgroupGroupSegmentSize = 0; |
| 312 | /// \brief Size in bytes of the private segment memory required by a workitem. |
| 313 | /// Private segment memory includes arg, spill and private segments. Optional. |
| 314 | uint32_t mWorkitemPrivateSegmentSize = 0; |
| 315 | /// \brief Total number of SGPRs used by a wavefront. Optional. |
| 316 | uint16_t mWavefrontNumSGPRs = 0; |
| 317 | /// \brief Total number of VGPRs used by a workitem. Optional. |
| 318 | uint16_t mWorkitemNumVGPRs = 0; |
| 319 | /// \brief Maximum byte alignment of variables used by the kernel in the |
| 320 | /// kernarg memory segment. Expressed as a power of two. Optional. |
| 321 | uint8_t mKernargSegmentAlign = 0; |
| 322 | /// \brief Maximum byte alignment of variables used by the kernel in the |
| 323 | /// group memory segment. Expressed as a power of two. Optional. |
| 324 | uint8_t mGroupSegmentAlign = 0; |
| 325 | /// \brief Maximum byte alignment of variables used by the kernel in the |
| 326 | /// private memory segment. Expressed as a power of two. Optional. |
| 327 | uint8_t mPrivateSegmentAlign = 0; |
| 328 | /// \brief Wavefront size. Expressed as a power of two. Optional. |
| 329 | uint8_t mWavefrontSize = 0; |
| 330 | |
| 331 | /// \brief Default constructor. |
| 332 | Metadata() = default; |
| 333 | |
| 334 | /// \returns True if kernel code properties metadata is empty, false |
| 335 | /// otherwise. |
| 336 | bool empty() const { |
| 337 | return !notEmpty(); |
| 338 | } |
| 339 | |
| 340 | /// \returns True if kernel code properties metadata is not empty, false |
| 341 | /// otherwise. |
| 342 | bool notEmpty() const { |
| 343 | return mKernargSegmentSize || mWorkgroupGroupSegmentSize || |
| 344 | mWorkitemPrivateSegmentSize || mWavefrontNumSGPRs || |
| 345 | mWorkitemNumVGPRs || mKernargSegmentAlign || mGroupSegmentAlign || |
| 346 | mPrivateSegmentAlign || mWavefrontSize; |
| 347 | } |
| 348 | }; |
| 349 | |
| 350 | } // end namespace CodeProps |
| 351 | |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 352 | //===----------------------------------------------------------------------===// |
| 353 | // Kernel Debug Properties Metadata. |
| 354 | //===----------------------------------------------------------------------===// |
| 355 | namespace DebugProps { |
| 356 | |
| 357 | namespace Key { |
| 358 | /// \brief Key for Kernel::DebugProps::Metadata::mDebuggerABIVersion. |
| 359 | constexpr char DebuggerABIVersion[] = "DebuggerABIVersion"; |
| 360 | /// \brief Key for Kernel::DebugProps::Metadata::mReservedNumVGPRs. |
| 361 | constexpr char ReservedNumVGPRs[] = "ReservedNumVGPRs"; |
| 362 | /// \brief Key for Kernel::DebugProps::Metadata::mReservedFirstVGPR. |
| 363 | constexpr char ReservedFirstVGPR[] = "ReservedFirstVGPR"; |
| 364 | /// \brief Key for Kernel::DebugProps::Metadata::mPrivateSegmentBufferSGPR. |
| 365 | constexpr char PrivateSegmentBufferSGPR[] = "PrivateSegmentBufferSGPR"; |
| 366 | /// \brief Key for |
| 367 | /// Kernel::DebugProps::Metadata::mWavefrontPrivateSegmentOffsetSGPR. |
| 368 | constexpr char WavefrontPrivateSegmentOffsetSGPR[] = |
| 369 | "WavefrontPrivateSegmentOffsetSGPR"; |
| 370 | } // end namespace Key |
| 371 | |
| 372 | /// \brief In-memory representation of kernel debug properties metadata. |
| 373 | struct Metadata final { |
| 374 | /// \brief Debugger ABI version. Optional. |
| 375 | std::vector<uint32_t> mDebuggerABIVersion = std::vector<uint32_t>(); |
| 376 | /// \brief Consecutive number of VGPRs reserved for debugger use. Must be 0 if |
| 377 | /// mDebuggerABIVersion is not set. Optional. |
| 378 | uint16_t mReservedNumVGPRs = 0; |
| 379 | /// \brief First fixed VGPR reserved. Must be uint16_t(-1) if |
| 380 | /// mDebuggerABIVersion is not set or mReservedFirstVGPR is 0. Optional. |
| 381 | uint16_t mReservedFirstVGPR = uint16_t(-1); |
| 382 | /// \brief Fixed SGPR of the first of 4 SGPRs used to hold the scratch V# used |
| 383 | /// for the entire kernel execution. Must be uint16_t(-1) if |
| 384 | /// mDebuggerABIVersion is not set or SGPR not used or not known. Optional. |
| 385 | uint16_t mPrivateSegmentBufferSGPR = uint16_t(-1); |
| 386 | /// \brief Fixed SGPR used to hold the wave scratch offset for the entire |
| 387 | /// kernel execution. Must be uint16_t(-1) if mDebuggerABIVersion is not set |
| 388 | /// or SGPR is not used or not known. Optional. |
| 389 | uint16_t mWavefrontPrivateSegmentOffsetSGPR = uint16_t(-1); |
| 390 | |
| 391 | /// \brief Default constructor. |
| 392 | Metadata() = default; |
| 393 | |
| 394 | /// \returns True if kernel debug properties metadata is empty, false |
| 395 | /// otherwise. |
| 396 | bool empty() const { |
| 397 | return !notEmpty(); |
| 398 | } |
| 399 | |
| 400 | /// \returns True if kernel debug properties metadata is not empty, false |
| 401 | /// otherwise. |
| 402 | bool notEmpty() const { |
| 403 | return !mDebuggerABIVersion.empty(); |
| 404 | } |
| 405 | }; |
| 406 | |
| 407 | } // end namespace DebugProps |
| 408 | |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 409 | namespace Key { |
| 410 | /// \brief Key for Kernel::Metadata::mName. |
| 411 | constexpr char Name[] = "Name"; |
| 412 | /// \brief Key for Kernel::Metadata::mLanguage. |
| 413 | constexpr char Language[] = "Language"; |
| 414 | /// \brief Key for Kernel::Metadata::mLanguageVersion. |
| 415 | constexpr char LanguageVersion[] = "LanguageVersion"; |
| 416 | /// \brief Key for Kernel::Metadata::mAttrs. |
| 417 | constexpr char Attrs[] = "Attrs"; |
| 418 | /// \brief Key for Kernel::Metadata::mArgs. |
| 419 | constexpr char Args[] = "Args"; |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 420 | /// \brief Key for Kernel::Metadata::mCodeProps. |
| 421 | constexpr char CodeProps[] = "CodeProps"; |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 422 | /// \brief Key for Kernel::Metadata::mDebugProps. |
| 423 | constexpr char DebugProps[] = "DebugProps"; |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 424 | } // end namespace Key |
| 425 | |
| 426 | /// \brief In-memory representation of kernel metadata. |
| 427 | struct Metadata final { |
| 428 | /// \brief Name. Required. |
| 429 | std::string mName = std::string(); |
| 430 | /// \brief Language. Optional. |
| 431 | std::string mLanguage = std::string(); |
| 432 | /// \brief Language version. Optional. |
| 433 | std::vector<uint32_t> mLanguageVersion = std::vector<uint32_t>(); |
| 434 | /// \brief Attributes metadata. Optional. |
| 435 | Attrs::Metadata mAttrs = Attrs::Metadata(); |
| 436 | /// \brief Arguments metadata. Optional. |
| 437 | std::vector<Arg::Metadata> mArgs = std::vector<Arg::Metadata>(); |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 438 | /// \brief Code properties metadata. Optional. |
| 439 | CodeProps::Metadata mCodeProps = CodeProps::Metadata(); |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame^] | 440 | /// \brief Debug properties metadata. Optional. |
| 441 | DebugProps::Metadata mDebugProps = DebugProps::Metadata(); |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 442 | |
| 443 | /// \brief Default constructor. |
| 444 | Metadata() = default; |
| 445 | }; |
| 446 | |
| 447 | } // end namespace Kernel |
| 448 | |
| 449 | namespace Key { |
| 450 | /// \brief Key for CodeObject::Metadata::mVersion. |
| 451 | constexpr char Version[] = "Version"; |
| 452 | /// \brief Key for CodeObject::Metadata::mIsa. |
| 453 | constexpr char Isa[] = "Isa"; |
| 454 | /// \brief Key for CodeObject::Metadata::mPrintf. |
| 455 | constexpr char Printf[] = "Printf"; |
| 456 | /// \brief Key for CodeObject::Metadata::mKernels. |
| 457 | constexpr char Kernels[] = "Kernels"; |
| 458 | } // end namespace Key |
| 459 | |
| 460 | /// \brief In-memory representation of code object metadata. |
| 461 | struct Metadata final { |
| 462 | /// \brief Code object metadata version. Required. |
| 463 | std::vector<uint32_t> mVersion = std::vector<uint32_t>(); |
| 464 | /// \brief Instruction set architecture metadata. Optional. |
| 465 | Isa::Metadata mIsa = Isa::Metadata(); |
| 466 | /// \brief Printf metadata. Optional. |
| 467 | std::vector<std::string> mPrintf = std::vector<std::string>(); |
| 468 | /// \brief Kernels metadata. Optional. |
| 469 | std::vector<Kernel::Metadata> mKernels = std::vector<Kernel::Metadata>(); |
| 470 | |
| 471 | /// \brief Default constructor. |
| 472 | Metadata() = default; |
| 473 | |
| 474 | /// \brief Converts \p YamlString to \p CodeObjectMetadata. |
| 475 | static std::error_code fromYamlString(std::string YamlString, |
| 476 | Metadata &CodeObjectMetadata); |
| 477 | |
| 478 | /// \brief Converts \p CodeObjectMetadata to \p YamlString. |
| 479 | static std::error_code toYamlString(Metadata CodeObjectMetadata, |
| 480 | std::string &YamlString); |
| 481 | }; |
| 482 | |
| 483 | } // end namespace CodeObject |
| 484 | } // end namespace AMDGPU |
| 485 | } // end namespace llvm |
| 486 | |
| 487 | #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATA_H |