LLVM 23.0.0git
SPIRVBaseInfo.h
Go to the documentation of this file.
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.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
16#define LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
17
18#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/StringRef.h"
23#include <string>
24
25namespace llvm {
26namespace SPIRV {
27namespace OperandCategory {
28#define GET_OperandCategory_DECL
29#include "SPIRVGenTables.inc"
30} // namespace OperandCategory
31
32namespace Extension {
33#define GET_Extension_DECL
34#include "SPIRVGenTables.inc"
35} // namespace Extension
36
37namespace Capability {
38#define GET_Capability_DECL
39#include "SPIRVGenTables.inc"
40} // namespace Capability
41
42namespace Environment {
43#define GET_Environment_DECL
44#include "SPIRVGenTables.inc"
45} // namespace Environment
46
47namespace SourceLanguage {
48#define GET_SourceLanguage_DECL
49#include "SPIRVGenTables.inc"
50} // namespace SourceLanguage
51
52namespace AddressingModel {
53#define GET_AddressingModel_DECL
54#include "SPIRVGenTables.inc"
55} // namespace AddressingModel
56
57namespace ExecutionModel {
58#define GET_ExecutionModel_DECL
59#include "SPIRVGenTables.inc"
60} // namespace ExecutionModel
61
62namespace MemoryModel {
63#define GET_MemoryModel_DECL
64#include "SPIRVGenTables.inc"
65} // namespace MemoryModel
66
68#define GET_MatrixMultiplyAccumulateOperands_DECL
69#include "SPIRVGenTables.inc"
70} // namespace MatrixMultiplyAccumulateOperands
71
72namespace ExecutionMode {
73#define GET_ExecutionMode_DECL
74#include "SPIRVGenTables.inc"
75} // namespace ExecutionMode
76
77namespace StorageClass {
78#define GET_StorageClass_DECL
79#include "SPIRVGenTables.inc"
80} // namespace StorageClass
81
82namespace Dim {
83#define GET_Dim_DECL
84#include "SPIRVGenTables.inc"
85} // namespace Dim
86
88#define GET_SamplerAddressingMode_DECL
89#include "SPIRVGenTables.inc"
90} // namespace SamplerAddressingMode
91
93#define GET_SamplerFilterMode_DECL
94#include "SPIRVGenTables.inc"
95} // namespace SamplerFilterMode
96
97namespace ImageFormat {
98#define GET_ImageFormat_DECL
99#include "SPIRVGenTables.inc"
100} // namespace ImageFormat
101
103#define GET_ImageChannelOrder_DECL
104#include "SPIRVGenTables.inc"
105} // namespace ImageChannelOrder
106
108#define GET_ImageChannelDataType_DECL
109#include "SPIRVGenTables.inc"
110} // namespace ImageChannelDataType
111
112namespace ImageOperand {
113#define GET_ImageOperand_DECL
114#include "SPIRVGenTables.inc"
115} // namespace ImageOperand
116
117namespace FPFastMathMode {
118#define GET_FPFastMathMode_DECL
119#include "SPIRVGenTables.inc"
120} // namespace FPFastMathMode
121
122namespace FPRoundingMode {
123#define GET_FPRoundingMode_DECL
124#include "SPIRVGenTables.inc"
125} // namespace FPRoundingMode
126
127namespace LinkageType {
128#define GET_LinkageType_DECL
129#include "SPIRVGenTables.inc"
130} // namespace LinkageType
131
133#define GET_AccessQualifier_DECL
134#include "SPIRVGenTables.inc"
135} // namespace AccessQualifier
136
138#define GET_FunctionParameterAttribute_DECL
139#include "SPIRVGenTables.inc"
140} // namespace FunctionParameterAttribute
141
142namespace Decoration {
143#define GET_Decoration_DECL
144#include "SPIRVGenTables.inc"
145} // namespace Decoration
146
147namespace BuiltIn {
148#define GET_BuiltIn_DECL
149#include "SPIRVGenTables.inc"
150} // namespace BuiltIn
151
153#define GET_SelectionControl_DECL
154#include "SPIRVGenTables.inc"
155} // namespace SelectionControl
156
157namespace LoopControl {
158#define GET_LoopControl_DECL
159#include "SPIRVGenTables.inc"
160} // namespace LoopControl
161
163#define GET_FunctionControl_DECL
164#include "SPIRVGenTables.inc"
165} // namespace FunctionControl
166
168#define GET_MemorySemantics_DECL
169#include "SPIRVGenTables.inc"
170} // namespace MemorySemantics
171
172namespace MemoryOperand {
173#define GET_MemoryOperand_DECL
174#include "SPIRVGenTables.inc"
175} // namespace MemoryOperand
176
177namespace Scope {
178#define GET_Scope_DECL
179#include "SPIRVGenTables.inc"
180} // namespace Scope
181
182namespace GroupOperation {
183#define GET_GroupOperation_DECL
184#include "SPIRVGenTables.inc"
185} // namespace GroupOperation
186
188#define GET_KernelEnqueueFlags_DECL
189#include "SPIRVGenTables.inc"
190} // namespace KernelEnqueueFlags
191
193#define GET_KernelProfilingInfo_DECL
194#include "SPIRVGenTables.inc"
195} // namespace KernelProfilingInfo
196
197namespace InstructionSet {
198#define GET_InstructionSet_DECL
199#include "SPIRVGenTables.inc"
200} // namespace InstructionSet
201
202namespace OpenCLExtInst {
203#define GET_OpenCLExtInst_DECL
204#include "SPIRVGenTables.inc"
205} // namespace OpenCLExtInst
206
207namespace GLSLExtInst {
208#define GET_GLSLExtInst_DECL
209#include "SPIRVGenTables.inc"
210} // namespace GLSLExtInst
211
213#define GET_NonSemanticExtInst_DECL
214#include "SPIRVGenTables.inc"
215} // namespace NonSemanticExtInst
216
217namespace Opcode {
218#define GET_Opcode_DECL
219#include "SPIRVGenTables.inc"
220} // namespace Opcode
221
223#define GET_CooperativeMatrixLayout_DECL
224#include "SPIRVGenTables.inc"
225} // namespace CooperativeMatrixLayout
226
228#define GET_CooperativeMatrixOperands_DECL
229#include "SPIRVGenTables.inc"
230} // namespace CooperativeMatrixOperands
231
233#define GET_SpecConstantOpOperands_DECL
234#include "SPIRVGenTables.inc"
235} // namespace SpecConstantOpOperands
236
237namespace FPEncoding {
238#define GET_FPEncoding_DECL
239#include "SPIRVGenTables.inc"
240} // namespace FPEncoding
241
244 InstructionSet::InstructionSet Set;
246};
247
249 // It is a half type
251 // It is a 64-bit type
253
254};
255} // namespace SPIRV
256
260
262
263std::string
264getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
265 int32_t Value);
267getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category,
270getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
273getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
276 SPIRV::OperandCategory::OperandCategory Category, uint32_t Value);
278getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
280getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category,
282std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue);
283
284bool getSpirvBuiltInIdByName(StringRef Name, SPIRV::BuiltIn::BuiltIn &BI);
285
286std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set);
287SPIRV::InstructionSet::InstructionSet
288getExtInstSetFromString(std::string SetName);
289std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set,
290 uint32_t InstructionNumber);
291
292// Return a string representation of the operands from startIndex onwards.
293// Templated to allow both MachineInstr and MCInst to use the same logic.
294template <class InstType>
295std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
296 std::string s; // Iteratively append to this string.
297
298 const unsigned NumOps = MI.getNumOperands();
299 bool IsFinished = false;
300 for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
301 const auto &Op = MI.getOperand(i);
302 if (!Op.isImm()) // Stop if we hit a register operand.
303 break;
304 assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
305 const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
306 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
307 char c = (Imm >> ShiftAmount) & 0xff;
308 if (c == 0) { // Stop if we hit a null-terminator character.
309 IsFinished = true;
310 break;
311 }
312 s += c; // Otherwise, append the character to the result string.
313 }
314 }
315 return s;
316}
317} // namespace llvm
318#endif // LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseSet and SmallDenseSet classes.
IRTranslator LLVM IR MI
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
This file defines the SmallVector class.
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Implements a dense probed hash-table based set.
Definition DenseSet.h:289
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
Represents a version number in the form major[.minor[.subminor[.build]]].
This is an optimization pass for GlobalISel generic memory operations.
SmallVector< SPIRV::Environment::Environment, 8 > EnvironmentList
ExtensionList getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set, uint32_t InstructionNumber)
CapabilityList getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
DenseSet< SPIRV::Extension::Extension > ExtensionSet
SmallVector< SPIRV::Extension::Extension, 8 > ExtensionList
std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set)
bool getSpirvBuiltInIdByName(llvm::StringRef Name, SPIRV::BuiltIn::BuiltIn &BI)
VersionTuple getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
EnvironmentList getSymbolicOperandAllowedEnvironments(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex)
CapabilityList getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension)
SPIRV::InstructionSet::InstructionSet getExtInstSetFromString(std::string SetName)
std::string getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category, int32_t Value)
DWARFExpression::Operation Op
VersionTuple getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
SmallVector< SPIRV::Capability::Capability, 8 > CapabilityList
std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue)
InstructionSet::InstructionSet Set