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