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_SPIRVSYMBOLICOPERANDS_H
16#define LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_H
17
18#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/StringRef.h"
22#include <string>
23
24namespace llvm {
25namespace SPIRV {
26namespace OperandCategory {
27#define GET_OperandCategory_DECL
28#include "SPIRVGenTables.inc"
29} // namespace OperandCategory
30
31namespace Extension {
32#define GET_Extension_DECL
33#include "SPIRVGenTables.inc"
34} // namespace Extension
35
36namespace Capability {
37#define GET_Capability_DECL
38#include "SPIRVGenTables.inc"
39} // namespace Capability
40
41namespace Environment {
42#define GET_Environment_DECL
43#include "SPIRVGenTables.inc"
44} // namespace Environment
45
46namespace SourceLanguage {
47#define GET_SourceLanguage_DECL
48#include "SPIRVGenTables.inc"
49} // namespace SourceLanguage
50
51namespace AddressingModel {
52#define GET_AddressingModel_DECL
53#include "SPIRVGenTables.inc"
54} // namespace AddressingModel
55
56namespace ExecutionModel {
57#define GET_ExecutionModel_DECL
58#include "SPIRVGenTables.inc"
59} // namespace ExecutionModel
60
61namespace MemoryModel {
62#define GET_MemoryModel_DECL
63#include "SPIRVGenTables.inc"
64} // namespace MemoryModel
65
67#define GET_MatrixMultiplyAccumulateOperands_DECL
68#include "SPIRVGenTables.inc"
69} // namespace MatrixMultiplyAccumulateOperands
70
71namespace ExecutionMode {
72#define GET_ExecutionMode_DECL
73#include "SPIRVGenTables.inc"
74} // namespace ExecutionMode
75
76namespace StorageClass {
77#define GET_StorageClass_DECL
78#include "SPIRVGenTables.inc"
79} // namespace StorageClass
80
81namespace Dim {
82#define GET_Dim_DECL
83#include "SPIRVGenTables.inc"
84} // namespace Dim
85
87#define GET_SamplerAddressingMode_DECL
88#include "SPIRVGenTables.inc"
89} // namespace SamplerAddressingMode
90
92#define GET_SamplerFilterMode_DECL
93#include "SPIRVGenTables.inc"
94} // namespace SamplerFilterMode
95
96namespace ImageFormat {
97#define GET_ImageFormat_DECL
98#include "SPIRVGenTables.inc"
99} // namespace ImageFormat
100
102#define GET_ImageChannelOrder_DECL
103#include "SPIRVGenTables.inc"
104} // namespace ImageChannelOrder
105
107#define GET_ImageChannelDataType_DECL
108#include "SPIRVGenTables.inc"
109} // namespace ImageChannelDataType
110
111namespace ImageOperand {
112#define GET_ImageOperand_DECL
113#include "SPIRVGenTables.inc"
114} // namespace ImageOperand
115
116namespace FPFastMathMode {
117#define GET_FPFastMathMode_DECL
118#include "SPIRVGenTables.inc"
119} // namespace FPFastMathMode
120
121namespace FPRoundingMode {
122#define GET_FPRoundingMode_DECL
123#include "SPIRVGenTables.inc"
124} // namespace FPRoundingMode
125
126namespace LinkageType {
127#define GET_LinkageType_DECL
128#include "SPIRVGenTables.inc"
129} // namespace LinkageType
130
132#define GET_AccessQualifier_DECL
133#include "SPIRVGenTables.inc"
134} // namespace AccessQualifier
135
137#define GET_FunctionParameterAttribute_DECL
138#include "SPIRVGenTables.inc"
139} // namespace FunctionParameterAttribute
140
141namespace Decoration {
142#define GET_Decoration_DECL
143#include "SPIRVGenTables.inc"
144} // namespace Decoration
145
146namespace BuiltIn {
147#define GET_BuiltIn_DECL
148#include "SPIRVGenTables.inc"
149} // namespace BuiltIn
150
152#define GET_SelectionControl_DECL
153#include "SPIRVGenTables.inc"
154} // namespace SelectionControl
155
156namespace LoopControl {
157#define GET_LoopControl_DECL
158#include "SPIRVGenTables.inc"
159} // namespace LoopControl
160
162#define GET_FunctionControl_DECL
163#include "SPIRVGenTables.inc"
164} // namespace FunctionControl
165
167#define GET_MemorySemantics_DECL
168#include "SPIRVGenTables.inc"
169} // namespace MemorySemantics
170
171namespace MemoryOperand {
172#define GET_MemoryOperand_DECL
173#include "SPIRVGenTables.inc"
174} // namespace MemoryOperand
175
176namespace Scope {
177#define GET_Scope_DECL
178#include "SPIRVGenTables.inc"
179} // namespace Scope
180
181namespace GroupOperation {
182#define GET_GroupOperation_DECL
183#include "SPIRVGenTables.inc"
184} // namespace GroupOperation
185
187#define GET_KernelEnqueueFlags_DECL
188#include "SPIRVGenTables.inc"
189} // namespace KernelEnqueueFlags
190
192#define GET_KernelProfilingInfo_DECL
193#include "SPIRVGenTables.inc"
194} // namespace KernelProfilingInfo
195
196namespace InstructionSet {
197#define GET_InstructionSet_DECL
198#include "SPIRVGenTables.inc"
199} // namespace InstructionSet
200
201namespace OpenCLExtInst {
202#define GET_OpenCLExtInst_DECL
203#include "SPIRVGenTables.inc"
204} // namespace OpenCLExtInst
205
206namespace GLSLExtInst {
207#define GET_GLSLExtInst_DECL
208#include "SPIRVGenTables.inc"
209} // namespace GLSLExtInst
210
212#define GET_NonSemanticExtInst_DECL
213#include "SPIRVGenTables.inc"
214} // namespace NonSemanticExtInst
215
216namespace Opcode {
217#define GET_Opcode_DECL
218#include "SPIRVGenTables.inc"
219} // namespace Opcode
220
222#define GET_CooperativeMatrixLayout_DECL
223#include "SPIRVGenTables.inc"
224} // namespace CooperativeMatrixLayout
225
227#define GET_CooperativeMatrixOperands_DECL
228#include "SPIRVGenTables.inc"
229} // namespace CooperativeMatrixOperands
230
232#define GET_SpecConstantOpOperands_DECL
233#include "SPIRVGenTables.inc"
234} // namespace SpecConstantOpOperands
235
236namespace FPEncoding {
237#define GET_FPEncoding_DECL
238#include "SPIRVGenTables.inc"
239} // namespace FPEncoding
240
243 InstructionSet::InstructionSet Set;
245};
246
248 // It is a half type
250 // It is a 64-bit type
252
253};
254} // namespace SPIRV
255
259
261
262std::string
263getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
264 int32_t Value);
266getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category,
269getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
272getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
275 SPIRV::OperandCategory::OperandCategory Category, uint32_t Value);
277getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
279getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category,
281std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue);
282
283bool getSpirvBuiltInIdByName(StringRef Name, SPIRV::BuiltIn::BuiltIn &BI);
284
285std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set);
286SPIRV::InstructionSet::InstructionSet
287getExtInstSetFromString(std::string SetName);
288std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set,
289 uint32_t InstructionNumber);
290
291// Return a string representation of the operands from startIndex onwards.
292// Templated to allow both MachineInstr and MCInst to use the same logic.
293template <class InstType>
294std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
295 std::string s; // Iteratively append to this string.
296
297 const unsigned NumOps = MI.getNumOperands();
298 bool IsFinished = false;
299 for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
300 const auto &Op = MI.getOperand(i);
301 if (!Op.isImm()) // Stop if we hit a register operand.
302 break;
303 assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
304 const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
305 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
306 char c = (Imm >> ShiftAmount) & 0xff;
307 if (c == 0) { // Stop if we hit a null-terminator character.
308 IsFinished = true;
309 break;
310 }
311 s += c; // Otherwise, append the character to the result string.
312 }
313 }
314 return s;
315}
316} // namespace llvm
317#endif // LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_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:279
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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.
Definition Types.h:26
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