blob: ed0e77c48bee894cb4592ffa364d7b076b070528 [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
87 };
88
89 enum Language : uint8_t {
90 OpenCL_C = 0,
91 HCC = 1,
92 OpenMP = 2,
93 OpenCL_CPP = 3,
94};
95
96 enum LanguageVersion : uint16_t {
97 V100 = 100,
98 V110 = 110,
99 V120 = 120,
100 V200 = 200,
101 V210 = 210,
102 };
103
104 namespace KernelArg {
105 enum TypeKind : uint8_t {
106 Value = 0,
107 Pointer = 1,
108 Image = 2,
109 Sampler = 3,
110 Queue = 4,
111 };
112
113 enum ValueType : uint16_t {
114 Struct = 0,
115 I8 = 1,
116 U8 = 2,
117 I16 = 3,
118 U16 = 4,
119 F16 = 5,
120 I32 = 6,
121 U32 = 7,
122 F32 = 8,
123 I64 = 9,
124 U64 = 10,
125 F64 = 11,
126 };
127
128 enum AccessQualifer : uint8_t {
129 None = 0,
130 ReadOnly = 1,
131 WriteOnly = 2,
132 ReadWrite = 3,
133 };
Yaxun Liuc7cbd722016-08-15 16:54:25 +0000134
135 enum AddressSpaceQualifer : uint8_t {
136 Private = 0,
137 Global = 1,
138 Constant = 2,
139 Local = 3,
140 };
Yaxun Liua711cc72016-07-16 05:09:21 +0000141 } // namespace KernelArg
142} // namespace RuntimeMD
143} // namespace AMDGPU
144
145#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H