LLVM 20.0.0git
SPIRVUtils.h
Go to the documentation of this file.
1//===--- SPIRVUtils.h ---- SPIR-V Utility Functions -------------*- 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 miscellaneous utility functions.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H
14#define LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H
15
19#include "llvm/IR/Dominators.h"
21#include "llvm/IR/IRBuilder.h"
23#include <queue>
24#include <string>
25#include <unordered_set>
26
27namespace llvm {
28class MCInst;
29class MachineFunction;
30class MachineInstr;
31class MachineInstrBuilder;
32class MachineIRBuilder;
33class MachineRegisterInfo;
34class Register;
35class StringRef;
36class SPIRVInstrInfo;
37class SPIRVSubtarget;
38class SPIRVGlobalRegistry;
39
40// This class implements a partial ordering visitor, which visits a cyclic graph
41// in natural topological-like ordering. Topological ordering is not defined for
42// directed graphs with cycles, so this assumes cycles are a single node, and
43// ignores back-edges. The cycle is visited from the entry in the same
44// topological-like ordering.
45//
46// Note: this visitor REQUIRES a reducible graph.
47//
48// This means once we visit a node, we know all the possible ancestors have been
49// visited.
50//
51// clang-format off
52//
53// Given this graph:
54//
55// ,-> B -\
56// A -+ +---> D ----> E -> F -> G -> H
57// `-> C -/ ^ |
58// +-----------------+
59//
60// Visit order is:
61// A, [B, C in any order], D, E, F, G, H
62//
63// clang-format on
64//
65// Changing the function CFG between the construction of the visitor and
66// visiting is undefined. The visitor can be reused, but if the CFG is updated,
67// the visitor must be rebuilt.
70 LoopInfo LI;
71
72 std::unordered_set<BasicBlock *> Queued = {};
73 std::queue<BasicBlock *> ToVisit = {};
74
75 struct OrderInfo {
76 size_t Rank;
77 size_t TraversalIndex;
78 };
79
80 using BlockToOrderInfoMap = std::unordered_map<BasicBlock *, OrderInfo>;
81 BlockToOrderInfoMap BlockToOrder;
82 std::vector<BasicBlock *> Order = {};
83
84 // Get all basic-blocks reachable from Start.
85 std::unordered_set<BasicBlock *> getReachableFrom(BasicBlock *Start);
86
87 // Internal function used to determine the partial ordering.
88 // Visits |BB| with the current rank being |Rank|.
89 size_t visit(BasicBlock *BB, size_t Rank);
90
91 bool CanBeVisited(BasicBlock *BB) const;
92
93public:
94 size_t GetNodeRank(BasicBlock *BB) const;
95
96 // Build the visitor to operate on the function F.
98
99 // Returns true is |LHS| comes before |RHS| in the partial ordering.
100 // If |LHS| and |RHS| have the same rank, the traversal order determines the
101 // order (order is stable).
102 bool compare(const BasicBlock *LHS, const BasicBlock *RHS) const;
103
104 // Visit the function starting from the basic block |Start|, and calling |Op|
105 // on each visited BB. This traversal ignores back-edges, meaning this won't
106 // visit a node to which |Start| is not an ancestor.
107 // If Op returns |true|, the visitor continues. If |Op| returns false, the
108 // visitor will stop at that rank. This means if 2 nodes share the same rank,
109 // and Op returns false when visiting the first, the second will be visited
110 // afterwards. But none of their successors will.
111 void partialOrderVisit(BasicBlock &Start,
112 std::function<bool(BasicBlock *)> Op);
113};
114
115// Add the given string as a series of integer operand, inserting null
116// terminators and padding to make sure the operands all have 32-bit
117// little-endian words.
118void addStringImm(const StringRef &Str, MCInst &Inst);
119void addStringImm(const StringRef &Str, MachineInstrBuilder &MIB);
120void addStringImm(const StringRef &Str, IRBuilder<> &B,
121 std::vector<Value *> &Args);
122
123// Read the series of integer operands back as a null-terminated string using
124// the reverse of the logic in addStringImm.
125std::string getStringImm(const MachineInstr &MI, unsigned StartIndex);
126
127// Add the given numerical immediate to MIB.
128void addNumImm(const APInt &Imm, MachineInstrBuilder &MIB);
129
130// Add an OpName instruction for the given target register.
132 MachineIRBuilder &MIRBuilder);
134 const SPIRVInstrInfo &TII);
135
136// Add an OpDecorate instruction for the given Reg.
138 SPIRV::Decoration::Decoration Dec,
139 const std::vector<uint32_t> &DecArgs,
140 StringRef StrImm = "");
142 SPIRV::Decoration::Decoration Dec,
143 const std::vector<uint32_t> &DecArgs,
144 StringRef StrImm = "");
145
146// Add an OpDecorate instruction by "spirv.Decorations" metadata node.
148 const MDNode *GVarMD);
149
150// Return a valid position for the OpVariable instruction inside a function,
151// i.e., at the beginning of the first block of the function.
153
154// Return a valid position for the instruction at the end of the block before
155// terminators and debug instructions.
157
158// Convert a SPIR-V storage class to the corresponding LLVM IR address space.
159// TODO: maybe the following two functions should be handled in the subtarget
160// to allow for different OpenCL vs Vulkan handling.
161constexpr unsigned
162storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC) {
163 switch (SC) {
164 case SPIRV::StorageClass::Function:
165 return 0;
166 case SPIRV::StorageClass::CrossWorkgroup:
167 return 1;
168 case SPIRV::StorageClass::UniformConstant:
169 return 2;
170 case SPIRV::StorageClass::Workgroup:
171 return 3;
172 case SPIRV::StorageClass::Generic:
173 return 4;
174 case SPIRV::StorageClass::DeviceOnlyINTEL:
175 return 5;
176 case SPIRV::StorageClass::HostOnlyINTEL:
177 return 6;
178 case SPIRV::StorageClass::Input:
179 return 7;
180 case SPIRV::StorageClass::Output:
181 return 8;
182 case SPIRV::StorageClass::CodeSectionINTEL:
183 return 9;
184 case SPIRV::StorageClass::Private:
185 return 10;
186 default:
187 report_fatal_error("Unable to get address space id");
188 }
189}
190
191// Convert an LLVM IR address space to a SPIR-V storage class.
192SPIRV::StorageClass::StorageClass
193addressSpaceToStorageClass(unsigned AddrSpace, const SPIRVSubtarget &STI);
194
195SPIRV::MemorySemantics::MemorySemantics
196getMemSemanticsForStorageClass(SPIRV::StorageClass::StorageClass SC);
197
198SPIRV::MemorySemantics::MemorySemantics getMemSemantics(AtomicOrdering Ord);
199
200SPIRV::Scope::Scope getMemScope(LLVMContext &Ctx, SyncScope::ID Id);
201
202// Find def instruction for the given ConstReg, walking through
203// spv_track_constant and ASSIGN_TYPE instructions. Updates ConstReg by def
204// of OpConstant instruction.
205MachineInstr *getDefInstrMaybeConstant(Register &ConstReg,
206 const MachineRegisterInfo *MRI);
207
208// Get constant integer value of the given ConstReg.
209uint64_t getIConstVal(Register ConstReg, const MachineRegisterInfo *MRI);
210
211// Check if MI is a SPIR-V specific intrinsic call.
212bool isSpvIntrinsic(const MachineInstr &MI, Intrinsic::ID IntrinsicID);
213// Check if it's a SPIR-V specific intrinsic call.
214bool isSpvIntrinsic(const Value *Arg);
215
216// Get type of i-th operand of the metadata node.
217Type *getMDOperandAsType(const MDNode *N, unsigned I);
218
219// If OpenCL or SPIR-V builtin function name is recognized, return a demangled
220// name, otherwise return an empty string.
221std::string getOclOrSpirvBuiltinDemangledName(StringRef Name);
222
223// Check if a string contains a builtin prefix.
224bool hasBuiltinTypePrefix(StringRef Name);
225
226// Check if given LLVM type is a special opaque builtin type.
227bool isSpecialOpaqueType(const Type *Ty);
228
229// Check if the function is an SPIR-V entry point
230bool isEntryPoint(const Function &F);
231
232// Parse basic scalar type name, substring TypeName, and return LLVM type.
233Type *parseBasicTypeName(StringRef &TypeName, LLVMContext &Ctx);
234
235// Sort blocks in a partial ordering, so each block is after all its
236// dominators. This should match both the SPIR-V and the MIR requirements.
237// Returns true if the function was changed.
238bool sortBlocks(Function &F);
239
240inline bool hasInitializer(const GlobalVariable *GV) {
241 return GV->hasInitializer() && !isa<UndefValue>(GV->getInitializer());
242}
243
244// True if this is an instance of TypedPointerType.
245inline bool isTypedPointerTy(const Type *T) {
246 return T && T->getTypeID() == Type::TypedPointerTyID;
247}
248
249// True if this is an instance of PointerType.
250inline bool isUntypedPointerTy(const Type *T) {
251 return T && T->getTypeID() == Type::PointerTyID;
252}
253
254// True if this is an instance of PointerType or TypedPointerType.
255inline bool isPointerTy(const Type *T) {
257}
258
259// Get the address space of this pointer or pointer vector type for instances of
260// PointerType or TypedPointerType.
261inline unsigned getPointerAddressSpace(const Type *T) {
262 Type *SubT = T->getScalarType();
263 return SubT->getTypeID() == Type::PointerTyID
264 ? cast<PointerType>(SubT)->getAddressSpace()
265 : cast<TypedPointerType>(SubT)->getAddressSpace();
266}
267
268// Return true if the Argument is decorated with a pointee type
269inline bool hasPointeeTypeAttr(Argument *Arg) {
270 return Arg->hasByValAttr() || Arg->hasByRefAttr() || Arg->hasStructRetAttr();
271}
272
273// Return the pointee type of the argument or nullptr otherwise
275 if (Arg->hasByValAttr())
276 return Arg->getParamByValType();
277 if (Arg->hasStructRetAttr())
278 return Arg->getParamStructRetType();
279 if (Arg->hasByRefAttr())
280 return Arg->getParamByRefType();
281 return nullptr;
282}
283
285 SmallVector<Type *> ArgTys;
286 for (unsigned i = 0; i < F->arg_size(); ++i)
287 ArgTys.push_back(F->getArg(i)->getType());
288 return FunctionType::get(F->getReturnType(), ArgTys, F->isVarArg());
289}
290
291#define TYPED_PTR_TARGET_EXT_NAME "spirv.$TypedPointerType"
292inline Type *getTypedPointerWrapper(Type *ElemTy, unsigned AS) {
294 {ElemTy}, {AS});
295}
296
297inline bool isTypedPointerWrapper(const TargetExtType *ExtTy) {
298 return ExtTy->getName() == TYPED_PTR_TARGET_EXT_NAME &&
299 ExtTy->getNumIntParameters() == 1 &&
300 ExtTy->getNumTypeParameters() == 1;
301}
302
303// True if this is an instance of PointerType or TypedPointerType.
304inline bool isPointerTyOrWrapper(const Type *Ty) {
305 if (auto *ExtTy = dyn_cast<TargetExtType>(Ty))
306 return isTypedPointerWrapper(ExtTy);
307 return isPointerTy(Ty);
308}
309
310inline Type *applyWrappers(Type *Ty) {
311 if (auto *ExtTy = dyn_cast<TargetExtType>(Ty)) {
312 if (isTypedPointerWrapper(ExtTy))
313 return TypedPointerType::get(applyWrappers(ExtTy->getTypeParameter(0)),
314 ExtTy->getIntParameter(0));
315 } else if (auto *VecTy = dyn_cast<VectorType>(Ty)) {
316 Type *ElemTy = VecTy->getElementType();
317 Type *NewElemTy = ElemTy->isTargetExtTy() ? applyWrappers(ElemTy) : ElemTy;
318 if (NewElemTy != ElemTy)
319 return VectorType::get(NewElemTy, VecTy->getElementCount());
320 }
321 return Ty;
322}
323
324inline Type *getPointeeType(const Type *Ty) {
325 if (Ty) {
326 if (auto PType = dyn_cast<TypedPointerType>(Ty))
327 return PType->getElementType();
328 else if (auto *ExtTy = dyn_cast<TargetExtType>(Ty))
329 if (isTypedPointerWrapper(ExtTy))
330 return ExtTy->getTypeParameter(0);
331 }
332 return nullptr;
333}
334
335inline bool isUntypedEquivalentToTyExt(Type *Ty1, Type *Ty2) {
336 if (!isUntypedPointerTy(Ty1) || !Ty2)
337 return false;
338 if (auto *ExtTy = dyn_cast<TargetExtType>(Ty2))
339 if (isTypedPointerWrapper(ExtTy) &&
340 ExtTy->getTypeParameter(0) ==
342 ExtTy->getIntParameter(0) == cast<PointerType>(Ty1)->getAddressSpace())
343 return true;
344 return false;
345}
346
347inline bool isEquivalentTypes(Type *Ty1, Type *Ty2) {
348 return isUntypedEquivalentToTyExt(Ty1, Ty2) ||
350}
351
353 if (Type *NewTy = applyWrappers(Ty); NewTy != Ty)
354 return NewTy;
355 return isUntypedPointerTy(Ty)
358 : Ty;
359}
360
362 Type *OrigRetTy = FTy->getReturnType();
363 Type *RetTy = toTypedPointer(OrigRetTy);
364 bool IsUntypedPtr = false;
365 for (Type *PTy : FTy->params()) {
366 if (isUntypedPointerTy(PTy)) {
367 IsUntypedPtr = true;
368 break;
369 }
370 }
371 if (!IsUntypedPtr && RetTy == OrigRetTy)
372 return FTy;
373 SmallVector<Type *> ParamTys;
374 for (Type *PTy : FTy->params())
375 ParamTys.push_back(toTypedPointer(PTy));
376 return FunctionType::get(RetTy, ParamTys, FTy->isVarArg());
377}
378
379inline const Type *unifyPtrType(const Type *Ty) {
380 if (auto FTy = dyn_cast<FunctionType>(Ty))
381 return toTypedFunPointer(const_cast<FunctionType *>(FTy));
382 return toTypedPointer(const_cast<Type *>(Ty));
383}
384
385MachineInstr *getVRegDef(MachineRegisterInfo &MRI, Register Reg);
386
387#define SPIRV_BACKEND_SERVICE_FUN_NAME "__spirv_backend_service_fun"
388bool getVacantFunctionName(Module &M, std::string &Name);
389
390void setRegClassType(Register Reg, const Type *Ty, SPIRVGlobalRegistry *GR,
391 MachineIRBuilder &MIRBuilder, bool Force = false);
394 const MachineFunction &MF, bool Force = false);
398 const MachineFunction &MF);
401 MachineIRBuilder &MIRBuilder);
403 MachineIRBuilder &MIRBuilder);
404
405// Return true if there is an opaque pointer type nested in the argument.
406bool isNestedPointer(const Type *Ty);
407
409
410inline FPDecorationId demangledPostfixToDecorationId(const std::string &S) {
411 static std::unordered_map<std::string, FPDecorationId> Mapping = {
412 {"rte", FPDecorationId::RTE},
413 {"rtz", FPDecorationId::RTZ},
414 {"rtp", FPDecorationId::RTP},
415 {"rtn", FPDecorationId::RTN},
416 {"sat", FPDecorationId::SAT}};
417 auto It = Mapping.find(S);
418 return It == Mapping.end() ? FPDecorationId::NONE : It->second;
419}
420
421} // namespace llvm
422#endif // LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock & MBB
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
return RetTy
std::string Name
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned Reg
Promote Memory to Register
Definition: Mem2Reg.cpp:110
#define TYPED_PTR_TARGET_EXT_NAME
Definition: SPIRVUtils.h:291
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition: APInt.h:78
This class represents an incoming formal argument to a Function.
Definition: Argument.h:31
Type * getParamByRefType() const
If this is a byref argument, return its type.
Definition: Function.cpp:245
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
Definition: Function.cpp:149
Type * getParamStructRetType() const
If this is an sret argument, return its type.
Definition: Function.cpp:240
bool hasByValAttr() const
Return true if this argument has the byval attribute.
Definition: Function.cpp:144
Type * getParamByValType() const
If this is a byval argument, return its type.
Definition: Function.cpp:235
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
Definition: Function.cpp:298
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
This class represents an Operation in the Expression.
Core dominator tree base class.
Class to represent function types.
Definition: DerivedTypes.h:105
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:132
bool isVarArg() const
Definition: DerivedTypes.h:125
Type * getReturnType() const
Definition: DerivedTypes.h:126
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2699
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
Metadata node.
Definition: Metadata.h:1069
Helper class to build MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:69
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
size_t GetNodeRank(BasicBlock *BB) const
Definition: SPIRVUtils.cpp:558
void partialOrderVisit(BasicBlock &Start, std::function< bool(BasicBlock *)> Op)
Definition: SPIRVUtils.cpp:649
bool compare(const BasicBlock *LHS, const BasicBlock *RHS) const
Definition: SPIRVUtils.cpp:640
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:744
unsigned getNumIntParameters() const
Definition: DerivedTypes.h:802
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Definition: Type.cpp:895
unsigned getNumTypeParameters() const
Definition: DerivedTypes.h:793
StringRef getName() const
Return the name for this target extension type.
Definition: DerivedTypes.h:778
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition: Type.h:77
@ PointerTyID
Pointers.
Definition: Type.h:72
bool isTargetExtTy() const
Return true if this is a target extension type.
Definition: Type.h:203
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
static IntegerType * getInt8Ty(LLVMContext &C)
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
static TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void buildOpName(Register Target, const StringRef &Name, MachineIRBuilder &MIRBuilder)
Definition: SPIRVUtils.cpp:103
bool getVacantFunctionName(Module &M, std::string &Name)
Definition: SPIRVUtils.cpp:711
std::string getStringImm(const MachineInstr &MI, unsigned StartIndex)
Definition: SPIRVUtils.cpp:79
bool isTypedPointerWrapper(const TargetExtType *ExtTy)
Definition: SPIRVUtils.h:297
unsigned getPointerAddressSpace(const Type *T)
Definition: SPIRVUtils.h:261
void addNumImm(const APInt &Imm, MachineInstrBuilder &MIB)
Definition: SPIRVUtils.cpp:83
FPDecorationId demangledPostfixToDecorationId(const std::string &S)
Definition: SPIRVUtils.h:410
bool sortBlocks(Function &F)
Definition: SPIRVUtils.cpp:679
Type * toTypedFunPointer(FunctionType *FTy)
Definition: SPIRVUtils.h:361
FPDecorationId
Definition: SPIRVUtils.h:408
@ RTP
Definition: SPIRVUtils.h:408
@ RTE
Definition: SPIRVUtils.h:408
@ RTN
Definition: SPIRVUtils.h:408
@ NONE
Definition: Attributor.h:6475
@ SAT
Definition: SPIRVUtils.h:408
@ RTZ
Definition: SPIRVUtils.h:408
uint64_t getIConstVal(Register ConstReg, const MachineRegisterInfo *MRI)
Definition: SPIRVUtils.cpp:326
SPIRV::MemorySemantics::MemorySemantics getMemSemanticsForStorageClass(SPIRV::StorageClass::StorageClass SC)
Definition: SPIRVUtils.cpp:245
constexpr unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
Definition: SPIRVUtils.h:162
bool isNestedPointer(const Type *Ty)
Definition: SPIRVUtils.cpp:774
std::string getOclOrSpirvBuiltinDemangledName(StringRef Name)
Definition: SPIRVUtils.cpp:392
bool isTypedPointerTy(const Type *T)
Definition: SPIRVUtils.h:245
bool isUntypedEquivalentToTyExt(Type *Ty1, Type *Ty2)
Definition: SPIRVUtils.h:335
void buildOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, SPIRV::Decoration::Decoration Dec, const std::vector< uint32_t > &DecArgs, StringRef StrImm)
Definition: SPIRVUtils.cpp:130
MachineBasicBlock::iterator getOpVariableMBBIt(MachineInstr &I)
Definition: SPIRVUtils.cpp:177
Register createVirtualRegister(SPIRVType *SpvType, SPIRVGlobalRegistry *GR, MachineRegisterInfo *MRI, const MachineFunction &MF)
Definition: SPIRVUtils.cpp:748
Type * getTypedPointerWrapper(Type *ElemTy, unsigned AS)
Definition: SPIRVUtils.h:292
Type * reconstructFunctionType(Function *F)
Definition: SPIRVUtils.h:284
Type * toTypedPointer(Type *Ty)
Definition: SPIRVUtils.h:352
bool isSpecialOpaqueType(const Type *Ty)
Definition: SPIRVUtils.cpp:436
void setRegClassType(Register Reg, SPIRVType *SpvType, SPIRVGlobalRegistry *GR, MachineRegisterInfo *MRI, const MachineFunction &MF, bool Force)
Definition: SPIRVUtils.cpp:727
bool isPointerTy(const Type *T)
Definition: SPIRVUtils.h:255
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
MachineBasicBlock::iterator getInsertPtValidEnd(MachineBasicBlock *MBB)
Definition: SPIRVUtils.cpp:197
const Type * unifyPtrType(const Type *Ty)
Definition: SPIRVUtils.h:379
bool isEntryPoint(const Function &F)
Definition: SPIRVUtils.cpp:445
SPIRV::StorageClass::StorageClass addressSpaceToStorageClass(unsigned AddrSpace, const SPIRVSubtarget &STI)
Definition: SPIRVUtils.cpp:211
AtomicOrdering
Atomic ordering for LLVM's memory model.
SPIRV::Scope::Scope getMemScope(LLVMContext &Ctx, SyncScope::ID Id)
Definition: SPIRVUtils.cpp:281
Type * parseBasicTypeName(StringRef &TypeName, LLVMContext &Ctx)
Definition: SPIRVUtils.cpp:459
Type * getPointeeTypeByAttr(Argument *Arg)
Definition: SPIRVUtils.h:274
bool hasPointeeTypeAttr(Argument *Arg)
Definition: SPIRVUtils.h:269
MachineInstr * getDefInstrMaybeConstant(Register &ConstReg, const MachineRegisterInfo *MRI)
Definition: SPIRVUtils.cpp:307
bool isEquivalentTypes(Type *Ty1, Type *Ty2)
Definition: SPIRVUtils.h:347
bool hasBuiltinTypePrefix(StringRef Name)
Definition: SPIRVUtils.cpp:429
Type * getMDOperandAsType(const MDNode *N, unsigned I)
Definition: SPIRVUtils.cpp:338
bool hasInitializer(const GlobalVariable *GV)
Definition: SPIRVUtils.h:240
Type * applyWrappers(Type *Ty)
Definition: SPIRVUtils.h:310
bool isPointerTyOrWrapper(const Type *Ty)
Definition: SPIRVUtils.h:304
bool isSpvIntrinsic(const MachineInstr &MI, Intrinsic::ID IntrinsicID)
Definition: SPIRVUtils.cpp:332
Type * getPointeeType(const Type *Ty)
Definition: SPIRVUtils.h:324
void addStringImm(const StringRef &Str, MCInst &Inst)
Definition: SPIRVUtils.cpp:54
MachineInstr * getVRegDef(MachineRegisterInfo &MRI, Register Reg)
Definition: SPIRVUtils.cpp:704
void buildOpSpirvDecorations(Register Reg, MachineIRBuilder &MIRBuilder, const MDNode *GVarMD)
Definition: SPIRVUtils.cpp:149
bool isUntypedPointerTy(const Type *T)
Definition: SPIRVUtils.h:250
SPIRV::MemorySemantics::MemorySemantics getMemSemantics(AtomicOrdering Ord)
Definition: SPIRVUtils.cpp:263
#define N