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