blob: 9050b442b3bcd43dde20f47461a0533fe6cb64a6 [file] [log] [blame]
Yaxun Liua711cc72016-07-16 05:09:21 +00001//===-- AMDGPURuntimeMetadata.h - AMDGPU Runtime Metadata -------*- 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///
12/// Enums and structure types used by runtime metadata.
13///
14/// Runtime requests certain information (metadata) about kernels to be able
15/// to execute the kernels and answer the queries about the kernels.
16/// The metadata is represented as a byte stream in an ELF section of a
17/// binary (code object). The byte stream consists of key-value pairs.
18/// Each key is an 8 bit unsigned integer. Each value can be an integer,
19/// a string, or a stream of key-value pairs. There are 3 levels of key-value
20/// pair streams. At the beginning of the ELF section is the top level
21/// key-value pair stream. A kernel-level key-value pair stream starts after
22/// encountering KeyKernelBegin and ends immediately before encountering
23/// KeyKernelEnd. A kernel-argument-level key-value pair stream starts
24/// after encountering KeyArgBegin and ends immediately before encountering
25/// KeyArgEnd. A kernel-level key-value pair stream can only appear in a top
26/// level key-value pair stream. A kernel-argument-level key-value pair stream
27/// can only appear in a kernel-level key-value pair stream.
28///
29/// The format should be kept backward compatible. New enum values and bit
30/// fields should be appended at the end. It is suggested to bump up the
31/// revision number whenever the format changes and document the change
32/// in the revision in this header.
33///
34//
35//===----------------------------------------------------------------------===//
36//
37#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
38#define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
39
40#include <stdint.h>
41
42namespace AMDGPU {
43
44namespace RuntimeMD {
45
46 // Version and revision of runtime metadata
47 const unsigned char MDVersion = 1;
48 const unsigned char MDRevision = 0;
49
50 // ELF section name containing runtime metadata
51 const char SectionName[] = ".AMDGPU.runtime_metadata";
52
53 // Enumeration values of keys in runtime metadata.
54 enum Key {
55 KeyNull = 0, // Place holder. Ignored when encountered
56 KeyMDVersion = 1, // Runtime metadata version
57 KeyLanguage = 2, // Language
58 KeyLanguageVersion = 3, // Language version
59 KeyKernelBegin = 4, // Beginning of kernel-level stream
60 KeyKernelEnd = 5, // End of kernel-level stream
61 KeyKernelName = 6, // Kernel name
62 KeyArgBegin = 7, // Beginning of kernel-arg-level stream
63 KeyArgEnd = 8, // End of kernel-arg-level stream
64 KeyArgSize = 9, // Kernel arg size
65 KeyArgAlign = 10, // Kernel arg alignment
66 KeyArgTypeName = 11, // Kernel type name
67 KeyArgName = 12, // Kernel name
68 KeyArgTypeKind = 13, // Kernel argument type kind
69 KeyArgValueType = 14, // Kernel argument value type
70 KeyArgAddrQual = 15, // Kernel argument address qualifier
71 KeyArgAccQual = 16, // Kernel argument access qualifier
72 KeyArgIsConst = 17, // Kernel argument is const qualified
73 KeyArgIsRestrict = 18, // Kernel argument is restrict qualified
74 KeyArgIsVolatile = 19, // Kernel argument is volatile qualified
75 KeyArgIsPipe = 20, // Kernel argument is pipe qualified
76 KeyReqdWorkGroupSize = 21, // Required work group size
77 KeyWorkGroupSizeHint = 22, // Work group size hint
78 KeyVecTypeHint = 23, // Vector type hint
79 KeyKernelIndex = 24, // Kernel index for device enqueue
80 KeySGPRs = 25, // Number of SGPRs
81 KeyVGPRs = 26, // Number of VGPRs
82 KeyMinWavesPerSIMD = 27, // Minimum number of waves per SIMD
83 KeyMaxWavesPerSIMD = 28, // Maximum number of waves per SIMD
84 KeyFlatWorkGroupSizeLimits = 29, // Flat work group size limits
85 KeyMaxWorkGroupSize = 30, // Maximum work group size
86 KeyNoPartialWorkGroups = 31, // No partial work groups
Yaxun Liuadd05a82016-09-01 18:46:49 +000087 KeyArgPointeeAlign = 32, // Alignment of pointee type
Yaxun Liua711cc72016-07-16 05:09:21 +000088 };
89
90 enum Language : uint8_t {
91 OpenCL_C = 0,
92 HCC = 1,
93 OpenMP = 2,
94 OpenCL_CPP = 3,
95};
96
97 enum LanguageVersion : uint16_t {
98 V100 = 100,
99 V110 = 110,
100 V120 = 120,
101 V200 = 200,
102 V210 = 210,
103 };
104
105 namespace KernelArg {
106 enum TypeKind : uint8_t {
107 Value = 0,
108 Pointer = 1,
109 Image = 2,
110 Sampler = 3,
111 Queue = 4,
112 };
113
114 enum ValueType : uint16_t {
115 Struct = 0,
116 I8 = 1,
117 U8 = 2,
118 I16 = 3,
119 U16 = 4,
120 F16 = 5,
121 I32 = 6,
122 U32 = 7,
123 F32 = 8,
124 I64 = 9,
125 U64 = 10,
126 F64 = 11,
127 };
128
129 enum AccessQualifer : uint8_t {
130 None = 0,
131 ReadOnly = 1,
132 WriteOnly = 2,
133 ReadWrite = 3,
134 };
Yaxun Liuc7cbd722016-08-15 16:54:25 +0000135
136 enum AddressSpaceQualifer : uint8_t {
137 Private = 0,
138 Global = 1,
139 Constant = 2,
140 Local = 3,
141 };
Yaxun Liua711cc72016-07-16 05:09:21 +0000142 } // namespace KernelArg
143} // namespace RuntimeMD
144} // namespace AMDGPU
145
146#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H