[AMDGPU] Replace unsigned with Register in SIMachineScheduler. NFC
[llvm-project.git] / llvm / lib / Target / SPIRV / MCTargetDesc / SPIRVBaseInfo.h
blob2437fbb820a363513fe3b52b738e37bab5d5c1c3
1 //===-- SPIRVBaseInfo.h - Top level SPIRV definitions -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains TableGen generated enum definitions, mnemonic lookup
10 // functions, versioning/capabilities/extensions getters for symbolic/named
11 // operands for various SPIR-V instructions.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_H
16 #define LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/VersionTuple.h"
21 #include <string>
23 namespace llvm {
24 namespace SPIRV {
25 namespace OperandCategory {
26 #define GET_OperandCategory_DECL
27 #include "SPIRVGenTables.inc"
28 } // namespace OperandCategory
30 namespace Extension {
31 #define GET_Extension_DECL
32 #include "SPIRVGenTables.inc"
33 } // namespace Extension
35 namespace Capability {
36 #define GET_Capability_DECL
37 #include "SPIRVGenTables.inc"
38 } // namespace Capability
40 namespace SourceLanguage {
41 #define GET_SourceLanguage_DECL
42 #include "SPIRVGenTables.inc"
43 } // namespace SourceLanguage
45 namespace AddressingModel {
46 #define GET_AddressingModel_DECL
47 #include "SPIRVGenTables.inc"
48 } // namespace AddressingModel
50 namespace ExecutionModel {
51 #define GET_ExecutionModel_DECL
52 #include "SPIRVGenTables.inc"
53 } // namespace ExecutionModel
55 namespace MemoryModel {
56 #define GET_MemoryModel_DECL
57 #include "SPIRVGenTables.inc"
58 } // namespace MemoryModel
60 namespace ExecutionMode {
61 #define GET_ExecutionMode_DECL
62 #include "SPIRVGenTables.inc"
63 } // namespace ExecutionMode
65 namespace StorageClass {
66 #define GET_StorageClass_DECL
67 #include "SPIRVGenTables.inc"
68 } // namespace StorageClass
70 namespace Dim {
71 #define GET_Dim_DECL
72 #include "SPIRVGenTables.inc"
73 } // namespace Dim
75 namespace SamplerAddressingMode {
76 #define GET_SamplerAddressingMode_DECL
77 #include "SPIRVGenTables.inc"
78 } // namespace SamplerAddressingMode
80 namespace SamplerFilterMode {
81 #define GET_SamplerFilterMode_DECL
82 #include "SPIRVGenTables.inc"
83 } // namespace SamplerFilterMode
85 namespace ImageFormat {
86 #define GET_ImageFormat_DECL
87 #include "SPIRVGenTables.inc"
88 } // namespace ImageFormat
90 namespace ImageChannelOrder {
91 #define GET_ImageChannelOrder_DECL
92 #include "SPIRVGenTables.inc"
93 } // namespace ImageChannelOrder
95 namespace ImageChannelDataType {
96 #define GET_ImageChannelDataType_DECL
97 #include "SPIRVGenTables.inc"
98 } // namespace ImageChannelDataType
100 namespace ImageOperand {
101 #define GET_ImageOperand_DECL
102 #include "SPIRVGenTables.inc"
103 } // namespace ImageOperand
105 namespace FPFastMathMode {
106 #define GET_FPFastMathMode_DECL
107 #include "SPIRVGenTables.inc"
108 } // namespace FPFastMathMode
110 namespace FPRoundingMode {
111 #define GET_FPRoundingMode_DECL
112 #include "SPIRVGenTables.inc"
113 } // namespace FPRoundingMode
115 namespace LinkageType {
116 #define GET_LinkageType_DECL
117 #include "SPIRVGenTables.inc"
118 } // namespace LinkageType
120 namespace AccessQualifier {
121 #define GET_AccessQualifier_DECL
122 #include "SPIRVGenTables.inc"
123 } // namespace AccessQualifier
125 namespace FunctionParameterAttribute {
126 #define GET_FunctionParameterAttribute_DECL
127 #include "SPIRVGenTables.inc"
128 } // namespace FunctionParameterAttribute
130 namespace Decoration {
131 #define GET_Decoration_DECL
132 #include "SPIRVGenTables.inc"
133 } // namespace Decoration
135 namespace BuiltIn {
136 #define GET_BuiltIn_DECL
137 #include "SPIRVGenTables.inc"
138 } // namespace BuiltIn
140 namespace SelectionControl {
141 #define GET_SelectionControl_DECL
142 #include "SPIRVGenTables.inc"
143 } // namespace SelectionControl
145 namespace LoopControl {
146 #define GET_LoopControl_DECL
147 #include "SPIRVGenTables.inc"
148 } // namespace LoopControl
150 namespace FunctionControl {
151 #define GET_FunctionControl_DECL
152 #include "SPIRVGenTables.inc"
153 } // namespace FunctionControl
155 namespace MemorySemantics {
156 #define GET_MemorySemantics_DECL
157 #include "SPIRVGenTables.inc"
158 } // namespace MemorySemantics
160 namespace MemoryOperand {
161 #define GET_MemoryOperand_DECL
162 #include "SPIRVGenTables.inc"
163 } // namespace MemoryOperand
165 namespace Scope {
166 #define GET_Scope_DECL
167 #include "SPIRVGenTables.inc"
168 } // namespace Scope
170 namespace GroupOperation {
171 #define GET_GroupOperation_DECL
172 #include "SPIRVGenTables.inc"
173 } // namespace GroupOperation
175 namespace KernelEnqueueFlags {
176 #define GET_KernelEnqueueFlags_DECL
177 #include "SPIRVGenTables.inc"
178 } // namespace KernelEnqueueFlags
180 namespace KernelProfilingInfo {
181 #define GET_KernelProfilingInfo_DECL
182 #include "SPIRVGenTables.inc"
183 } // namespace KernelProfilingInfo
185 namespace InstructionSet {
186 #define GET_InstructionSet_DECL
187 #include "SPIRVGenTables.inc"
188 } // namespace InstructionSet
190 namespace OpenCLExtInst {
191 #define GET_OpenCLExtInst_DECL
192 #include "SPIRVGenTables.inc"
193 } // namespace OpenCLExtInst
195 namespace GLSLExtInst {
196 #define GET_GLSLExtInst_DECL
197 #include "SPIRVGenTables.inc"
198 } // namespace GLSLExtInst
200 namespace NonSemanticExtInst {
201 #define GET_NonSemanticExtInst_DECL
202 #include "SPIRVGenTables.inc"
203 } // namespace NonSemanticExtInst
205 namespace Opcode {
206 #define GET_Opcode_DECL
207 #include "SPIRVGenTables.inc"
208 } // namespace Opcode
210 namespace CooperativeMatrixLayout {
211 #define GET_CooperativeMatrixLayout_DECL
212 #include "SPIRVGenTables.inc"
213 } // namespace CooperativeMatrixLayout
215 namespace CooperativeMatrixOperands {
216 #define GET_CooperativeMatrixOperands_DECL
217 #include "SPIRVGenTables.inc"
218 } // namespace CooperativeMatrixOperands
220 struct ExtendedBuiltin {
221 StringRef Name;
222 InstructionSet::InstructionSet Set;
223 uint32_t Number;
225 } // namespace SPIRV
227 using CapabilityList = SmallVector<SPIRV::Capability::Capability, 8>;
228 using ExtensionList = SmallVector<SPIRV::Extension::Extension, 8>;
230 std::string
231 getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
232 int32_t Value);
233 VersionTuple
234 getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category,
235 uint32_t Value);
236 VersionTuple
237 getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
238 uint32_t Value);
239 CapabilityList
240 getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
241 uint32_t Value);
242 CapabilityList
243 getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
244 ExtensionList
245 getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category,
246 uint32_t Value);
247 std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue);
249 bool getSpirvBuiltInIdByName(StringRef Name, SPIRV::BuiltIn::BuiltIn &BI);
251 std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set);
252 SPIRV::InstructionSet::InstructionSet
253 getExtInstSetFromString(std::string SetName);
254 std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set,
255 uint32_t InstructionNumber);
257 // Return a string representation of the operands from startIndex onwards.
258 // Templated to allow both MachineInstr and MCInst to use the same logic.
259 template <class InstType>
260 std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
261 std::string s; // Iteratively append to this string.
263 const unsigned NumOps = MI.getNumOperands();
264 bool IsFinished = false;
265 for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
266 const auto &Op = MI.getOperand(i);
267 if (!Op.isImm()) // Stop if we hit a register operand.
268 break;
269 assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
270 const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
271 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
272 char c = (Imm >> ShiftAmount) & 0xff;
273 if (c == 0) { // Stop if we hit a null-terminator character.
274 IsFinished = true;
275 break;
277 s += c; // Otherwise, append the character to the result string.
280 return s;
282 } // namespace llvm
283 #endif // LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_H