LLVM 19.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"
20#include <string>
21
22namespace llvm {
23namespace SPIRV {
24namespace OperandCategory {
25#define GET_OperandCategory_DECL
26#include "SPIRVGenTables.inc"
27} // namespace OperandCategory
28
29namespace Extension {
30#define GET_Extension_DECL
31#include "SPIRVGenTables.inc"
32} // namespace Extension
33
34namespace Capability {
35#define GET_Capability_DECL
36#include "SPIRVGenTables.inc"
37} // namespace Capability
38
39namespace SourceLanguage {
40#define GET_SourceLanguage_DECL
41#include "SPIRVGenTables.inc"
42} // namespace SourceLanguage
43
44namespace AddressingModel {
45#define GET_AddressingModel_DECL
46#include "SPIRVGenTables.inc"
47} // namespace AddressingModel
48
49namespace ExecutionModel {
50#define GET_ExecutionModel_DECL
51#include "SPIRVGenTables.inc"
52} // namespace ExecutionModel
53
54namespace MemoryModel {
55#define GET_MemoryModel_DECL
56#include "SPIRVGenTables.inc"
57} // namespace MemoryModel
58
59namespace ExecutionMode {
60#define GET_ExecutionMode_DECL
61#include "SPIRVGenTables.inc"
62} // namespace ExecutionMode
63
64namespace StorageClass {
65#define GET_StorageClass_DECL
66#include "SPIRVGenTables.inc"
67} // namespace StorageClass
68
69namespace Dim {
70#define GET_Dim_DECL
71#include "SPIRVGenTables.inc"
72} // namespace Dim
73
74namespace SamplerAddressingMode {
75#define GET_SamplerAddressingMode_DECL
76#include "SPIRVGenTables.inc"
77} // namespace SamplerAddressingMode
78
79namespace SamplerFilterMode {
80#define GET_SamplerFilterMode_DECL
81#include "SPIRVGenTables.inc"
82} // namespace SamplerFilterMode
83
84namespace ImageFormat {
85#define GET_ImageFormat_DECL
86#include "SPIRVGenTables.inc"
87} // namespace ImageFormat
88
89namespace ImageChannelOrder {
90#define GET_ImageChannelOrder_DECL
91#include "SPIRVGenTables.inc"
92} // namespace ImageChannelOrder
93
94namespace ImageChannelDataType {
95#define GET_ImageChannelDataType_DECL
96#include "SPIRVGenTables.inc"
97} // namespace ImageChannelDataType
98
99namespace ImageOperand {
100#define GET_ImageOperand_DECL
101#include "SPIRVGenTables.inc"
102} // namespace ImageOperand
103
104namespace FPFastMathMode {
105#define GET_FPFastMathMode_DECL
106#include "SPIRVGenTables.inc"
107} // namespace FPFastMathMode
108
109namespace FPRoundingMode {
110#define GET_FPRoundingMode_DECL
111#include "SPIRVGenTables.inc"
112} // namespace FPRoundingMode
113
114namespace LinkageType {
115#define GET_LinkageType_DECL
116#include "SPIRVGenTables.inc"
117} // namespace LinkageType
118
119namespace AccessQualifier {
120#define GET_AccessQualifier_DECL
121#include "SPIRVGenTables.inc"
122} // namespace AccessQualifier
123
124namespace FunctionParameterAttribute {
125#define GET_FunctionParameterAttribute_DECL
126#include "SPIRVGenTables.inc"
127} // namespace FunctionParameterAttribute
128
129namespace Decoration {
130#define GET_Decoration_DECL
131#include "SPIRVGenTables.inc"
132} // namespace Decoration
133
134namespace BuiltIn {
135#define GET_BuiltIn_DECL
136#include "SPIRVGenTables.inc"
137} // namespace BuiltIn
138
139namespace SelectionControl {
140#define GET_SelectionControl_DECL
141#include "SPIRVGenTables.inc"
142} // namespace SelectionControl
143
144namespace LoopControl {
145#define GET_LoopControl_DECL
146#include "SPIRVGenTables.inc"
147} // namespace LoopControl
148
149namespace FunctionControl {
150#define GET_FunctionControl_DECL
151#include "SPIRVGenTables.inc"
152} // namespace FunctionControl
153
154namespace MemorySemantics {
155#define GET_MemorySemantics_DECL
156#include "SPIRVGenTables.inc"
157} // namespace MemorySemantics
158
159namespace MemoryOperand {
160#define GET_MemoryOperand_DECL
161#include "SPIRVGenTables.inc"
162} // namespace MemoryOperand
163
164namespace Scope {
165#define GET_Scope_DECL
166#include "SPIRVGenTables.inc"
167} // namespace Scope
168
169namespace GroupOperation {
170#define GET_GroupOperation_DECL
171#include "SPIRVGenTables.inc"
172} // namespace GroupOperation
173
174namespace KernelEnqueueFlags {
175#define GET_KernelEnqueueFlags_DECL
176#include "SPIRVGenTables.inc"
177} // namespace KernelEnqueueFlags
178
179namespace KernelProfilingInfo {
180#define GET_KernelProfilingInfo_DECL
181#include "SPIRVGenTables.inc"
182} // namespace KernelProfilingInfo
183
184namespace InstructionSet {
185#define GET_InstructionSet_DECL
186#include "SPIRVGenTables.inc"
187} // namespace InstructionSet
188
189namespace OpenCLExtInst {
190#define GET_OpenCLExtInst_DECL
191#include "SPIRVGenTables.inc"
192} // namespace OpenCLExtInst
193
194namespace GLSLExtInst {
195#define GET_GLSLExtInst_DECL
196#include "SPIRVGenTables.inc"
197} // namespace GLSLExtInst
198
199namespace Opcode {
200#define GET_Opcode_DECL
201#include "SPIRVGenTables.inc"
202} // namespace Opcode
203
206 InstructionSet::InstructionSet Set;
208};
209} // namespace SPIRV
210
213
214std::string
215getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
216 int32_t Value);
218getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category,
221getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
224getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
227getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
229getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category,
231std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue);
232
233bool getSpirvBuiltInIdByName(StringRef Name, SPIRV::BuiltIn::BuiltIn &BI);
234
235std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set);
236SPIRV::InstructionSet::InstructionSet
237getExtInstSetFromString(std::string SetName);
238std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set,
239 uint32_t InstructionNumber);
240
241// Return a string representation of the operands from startIndex onwards.
242// Templated to allow both MachineInstr and MCInst to use the same logic.
243template <class InstType>
244std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
245 std::string s; // Iteratively append to this string.
246
247 const unsigned NumOps = MI.getNumOperands();
248 bool IsFinished = false;
249 for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
250 const auto &Op = MI.getOperand(i);
251 if (!Op.isImm()) // Stop if we hit a register operand.
252 break;
253 assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
254 const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
255 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
256 char c = (Imm >> ShiftAmount) & 0xff;
257 if (c == 0) { // Stop if we hit a null-terminator character.
258 IsFinished = true;
259 break;
260 }
261 s += c; // Otherwise, append the character to the result string.
262 }
263 }
264 return s;
265}
266} // namespace llvm
267#endif // LLVM_LIB_TARGET_SPIRV_SPIRVSYMBOLICOPERANDS_H
std::string Name
IRTranslator LLVM IR MI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This class represents an Operation in the Expression.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
StorageClass
Definition: XCOFF.h:170
SourceLanguage
Definition: Dwarf.h:204
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)
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)
uint32_t getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
uint32_t getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category, uint32_t Value)
std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue)
InstructionSet::InstructionSet Set