LLVM 20.0.0git
DXILOpBuilder.cpp
Go to the documentation of this file.
1//===- DXILOpBuilder.cpp - Helper class for build DIXLOp functions --------===//
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/// \file This file contains class to help build DXIL op functions.
10//===----------------------------------------------------------------------===//
11
12#include "DXILOpBuilder.h"
13#include "DXILConstants.h"
14#include "llvm/IR/Module.h"
17#include <optional>
18
19using namespace llvm;
20using namespace llvm::dxil;
21
22constexpr StringLiteral DXILOpNamePrefix = "dx.op.";
23
24namespace {
25enum OverloadKind : uint16_t {
26 UNDEFINED = 0,
27 VOID = 1,
28 HALF = 1 << 1,
29 FLOAT = 1 << 2,
30 DOUBLE = 1 << 3,
31 I1 = 1 << 4,
32 I8 = 1 << 5,
33 I16 = 1 << 6,
34 I32 = 1 << 7,
35 I64 = 1 << 8,
36 UserDefineType = 1 << 9,
37 ObjectType = 1 << 10,
38};
39struct Version {
40 unsigned Major = 0;
41 unsigned Minor = 0;
42};
43
44struct OpOverload {
45 Version DXILVersion;
46 uint16_t ValidTys;
47};
48} // namespace
49
50struct OpStage {
51 Version DXILVersion;
53};
54
56 Version DXILVersion;
58};
59
60static const char *getOverloadTypeName(OverloadKind Kind) {
61 switch (Kind) {
62 case OverloadKind::HALF:
63 return "f16";
64 case OverloadKind::FLOAT:
65 return "f32";
66 case OverloadKind::DOUBLE:
67 return "f64";
68 case OverloadKind::I1:
69 return "i1";
70 case OverloadKind::I8:
71 return "i8";
72 case OverloadKind::I16:
73 return "i16";
74 case OverloadKind::I32:
75 return "i32";
76 case OverloadKind::I64:
77 return "i64";
78 case OverloadKind::VOID:
79 case OverloadKind::UNDEFINED:
80 return "void";
81 case OverloadKind::ObjectType:
82 case OverloadKind::UserDefineType:
83 break;
84 }
85 llvm_unreachable("invalid overload type for name");
86}
87
88static OverloadKind getOverloadKind(Type *Ty) {
89 if (!Ty)
90 return OverloadKind::VOID;
91
92 Type::TypeID T = Ty->getTypeID();
93 switch (T) {
94 case Type::VoidTyID:
95 return OverloadKind::VOID;
96 case Type::HalfTyID:
97 return OverloadKind::HALF;
98 case Type::FloatTyID:
99 return OverloadKind::FLOAT;
100 case Type::DoubleTyID:
101 return OverloadKind::DOUBLE;
102 case Type::IntegerTyID: {
103 IntegerType *ITy = cast<IntegerType>(Ty);
104 unsigned Bits = ITy->getBitWidth();
105 switch (Bits) {
106 case 1:
107 return OverloadKind::I1;
108 case 8:
109 return OverloadKind::I8;
110 case 16:
111 return OverloadKind::I16;
112 case 32:
113 return OverloadKind::I32;
114 case 64:
115 return OverloadKind::I64;
116 default:
117 llvm_unreachable("invalid overload type");
118 return OverloadKind::VOID;
119 }
120 }
122 return OverloadKind::UserDefineType;
123 case Type::StructTyID: {
124 // TODO: This is a hack. As described in DXILEmitter.cpp, we need to rework
125 // how we're handling overloads and remove the `OverloadKind` proxy enum.
126 StructType *ST = cast<StructType>(Ty);
127 return getOverloadKind(ST->getElementType(0));
128 }
129 default:
130 return OverloadKind::UNDEFINED;
131 }
132}
133
134static std::string getTypeName(OverloadKind Kind, Type *Ty) {
135 if (Kind < OverloadKind::UserDefineType) {
136 return getOverloadTypeName(Kind);
137 } else if (Kind == OverloadKind::UserDefineType) {
138 StructType *ST = cast<StructType>(Ty);
139 return ST->getStructName().str();
140 } else if (Kind == OverloadKind::ObjectType) {
141 StructType *ST = cast<StructType>(Ty);
142 return ST->getStructName().str();
143 } else {
144 std::string Str;
146 Ty->print(OS);
147 return OS.str();
148 }
149}
150
151// Static properties.
154 // Offset in DXILOpCodeNameTable.
157 // Offset in DXILOpCodeClassNameTable.
162 int OverloadParamIndex; // parameter index which control the overload.
163 // When < 0, should be only 1 overload type.
164};
165
166// Include getOpCodeClassName getOpCodeProperty, getOpCodeName and
167// getOpCodeParameterKind which generated by tableGen.
168#define DXIL_OP_OPERATION_TABLE
169#include "DXILOperation.inc"
170#undef DXIL_OP_OPERATION_TABLE
171
172static std::string constructOverloadName(OverloadKind Kind, Type *Ty,
173 const OpCodeProperty &Prop) {
174 if (Kind == OverloadKind::VOID) {
175 return (Twine(DXILOpNamePrefix) + getOpCodeClassName(Prop)).str();
176 }
177 return (Twine(DXILOpNamePrefix) + getOpCodeClassName(Prop) + "." +
178 getTypeName(Kind, Ty))
179 .str();
180}
181
182static std::string constructOverloadTypeName(OverloadKind Kind,
183 StringRef TypeName) {
184 if (Kind == OverloadKind::VOID)
185 return TypeName.str();
186
187 assert(Kind < OverloadKind::UserDefineType && "invalid overload kind");
188 return (Twine(TypeName) + getOverloadTypeName(Kind)).str();
189}
190
192 ArrayRef<Type *> EltTys,
193 LLVMContext &Ctx) {
195 if (ST)
196 return ST;
197
198 return StructType::create(Ctx, EltTys, Name);
199}
200
201static StructType *getResRetType(Type *ElementTy) {
202 LLVMContext &Ctx = ElementTy->getContext();
203 OverloadKind Kind = getOverloadKind(ElementTy);
204 std::string TypeName = constructOverloadTypeName(Kind, "dx.types.ResRet.");
205 Type *FieldTypes[5] = {ElementTy, ElementTy, ElementTy, ElementTy,
206 Type::getInt32Ty(Ctx)};
207 return getOrCreateStructType(TypeName, FieldTypes, Ctx);
208}
209
211 return getOrCreateStructType("dx.types.Handle", PointerType::getUnqual(Ctx),
212 Ctx);
213}
214
216 if (auto *ST = StructType::getTypeByName(Context, "dx.types.ResBind"))
217 return ST;
218 Type *Int32Ty = Type::getInt32Ty(Context);
219 Type *Int8Ty = Type::getInt8Ty(Context);
220 return StructType::create({Int32Ty, Int32Ty, Int32Ty, Int8Ty},
221 "dx.types.ResBind");
222}
223
225 if (auto *ST =
226 StructType::getTypeByName(Context, "dx.types.ResourceProperties"))
227 return ST;
228 Type *Int32Ty = Type::getInt32Ty(Context);
229 return StructType::create({Int32Ty, Int32Ty}, "dx.types.ResourceProperties");
230}
231
233 if (auto *ST = StructType::getTypeByName(Context, "dx.types.splitdouble"))
234 return ST;
235 Type *Int32Ty = Type::getInt32Ty(Context);
236 return StructType::create({Int32Ty, Int32Ty}, "dx.types.splitdouble");
237}
238
240 Type *OverloadTy) {
241 switch (Kind) {
242 case OpParamType::VoidTy:
243 return Type::getVoidTy(Ctx);
244 case OpParamType::HalfTy:
245 return Type::getHalfTy(Ctx);
246 case OpParamType::FloatTy:
247 return Type::getFloatTy(Ctx);
248 case OpParamType::DoubleTy:
249 return Type::getDoubleTy(Ctx);
250 case OpParamType::Int1Ty:
251 return Type::getInt1Ty(Ctx);
252 case OpParamType::Int8Ty:
253 return Type::getInt8Ty(Ctx);
254 case OpParamType::Int16Ty:
255 return Type::getInt16Ty(Ctx);
256 case OpParamType::Int32Ty:
257 return Type::getInt32Ty(Ctx);
258 case OpParamType::Int64Ty:
259 return Type::getInt64Ty(Ctx);
260 case OpParamType::OverloadTy:
261 return OverloadTy;
262 case OpParamType::ResRetHalfTy:
263 return getResRetType(Type::getHalfTy(Ctx));
264 case OpParamType::ResRetFloatTy:
265 return getResRetType(Type::getFloatTy(Ctx));
266 case OpParamType::ResRetDoubleTy:
267 return getResRetType(Type::getDoubleTy(Ctx));
268 case OpParamType::ResRetInt16Ty:
269 return getResRetType(Type::getInt16Ty(Ctx));
270 case OpParamType::ResRetInt32Ty:
271 return getResRetType(Type::getInt32Ty(Ctx));
272 case OpParamType::ResRetInt64Ty:
273 return getResRetType(Type::getInt64Ty(Ctx));
274 case OpParamType::HandleTy:
275 return getHandleType(Ctx);
276 case OpParamType::ResBindTy:
277 return getResBindType(Ctx);
278 case OpParamType::ResPropsTy:
279 return getResPropsType(Ctx);
280 case OpParamType::SplitDoubleTy:
281 return getSplitDoubleType(Ctx);
282 }
283 llvm_unreachable("Invalid parameter kind");
284 return nullptr;
285}
286
287static ShaderKind getShaderKindEnum(Triple::EnvironmentType EnvType) {
288 switch (EnvType) {
289 case Triple::Pixel:
290 return ShaderKind::pixel;
291 case Triple::Vertex:
292 return ShaderKind::vertex;
293 case Triple::Geometry:
294 return ShaderKind::geometry;
295 case Triple::Hull:
296 return ShaderKind::hull;
297 case Triple::Domain:
298 return ShaderKind::domain;
299 case Triple::Compute:
300 return ShaderKind::compute;
301 case Triple::Library:
302 return ShaderKind::library;
304 return ShaderKind::raygeneration;
306 return ShaderKind::intersection;
307 case Triple::AnyHit:
308 return ShaderKind::anyhit;
310 return ShaderKind::closesthit;
311 case Triple::Miss:
312 return ShaderKind::miss;
313 case Triple::Callable:
314 return ShaderKind::callable;
315 case Triple::Mesh:
316 return ShaderKind::mesh;
318 return ShaderKind::amplification;
319 default:
320 break;
321 }
323 "Shader Kind Not Found - Invalid DXIL Environment Specified");
324}
325
328 LLVMContext &Context, Type *OverloadTy) {
329 SmallVector<Type *> ArgTys;
330 ArgTys.emplace_back(Type::getInt32Ty(Context));
331 for (dxil::OpParamType Ty : Types)
332 ArgTys.emplace_back(getTypeFromOpParamType(Ty, Context, OverloadTy));
333 return ArgTys;
334}
335
336/// Construct DXIL function type. This is the type of a function with
337/// the following prototype
338/// OverloadType dx.op.<opclass>.<return-type>(int opcode, <param types>)
339/// <param-types> are constructed from types in Prop.
341 LLVMContext &Context,
342 Type *OverloadTy) {
343
344 switch (OpCode) {
345#define DXIL_OP_FUNCTION_TYPE(OpCode, RetType, ...) \
346 case OpCode: \
347 return FunctionType::get( \
348 getTypeFromOpParamType(RetType, Context, OverloadTy), \
349 getArgTypesFromOpParamTypes({__VA_ARGS__}, Context, OverloadTy), \
350 /*isVarArg=*/false);
351#include "DXILOperation.inc"
352 }
353 llvm_unreachable("Invalid OpCode?");
354}
355
356/// Get index of the property from PropList valid for the most recent
357/// DXIL version not greater than DXILVer.
358/// PropList is expected to be sorted in ascending order of DXIL version.
359template <typename T>
360static std::optional<size_t> getPropIndex(ArrayRef<T> PropList,
361 const VersionTuple DXILVer) {
362 size_t Index = PropList.size() - 1;
363 for (auto Iter = PropList.rbegin(); Iter != PropList.rend();
364 Iter++, Index--) {
365 const T &Prop = *Iter;
366 if (VersionTuple(Prop.DXILVersion.Major, Prop.DXILVersion.Minor) <=
367 DXILVer) {
368 return Index;
369 }
370 }
371 return std::nullopt;
372}
373
374namespace llvm {
375namespace dxil {
376
377// No extra checks on TargetTriple need be performed to verify that the
378// Triple is well-formed or that the target is supported since these checks
379// would have been done at the time the module M is constructed in the earlier
380// stages of compilation.
381DXILOpBuilder::DXILOpBuilder(Module &M) : M(M), IRB(M.getContext()) {
382 Triple TT(Triple(M.getTargetTriple()));
383 DXILVersion = TT.getDXILVersion();
384 ShaderStage = TT.getEnvironment();
385 // Ensure Environment type is known
386 if (ShaderStage == Triple::UnknownEnvironment) {
388 Twine(DXILVersion.getAsString()) +
389 ": Unknown Compilation Target Shader Stage specified ",
390 /*gen_crash_diag*/ false);
391 }
392}
393
395 return make_error<StringError>(
396 Twine("Cannot create ") + getOpCodeName(OpCode) + " operation: " + Msg,
398}
399
402 const Twine &Name,
403 Type *RetTy) {
404 const OpCodeProperty *Prop = getOpCodeProperty(OpCode);
405
406 Type *OverloadTy = nullptr;
407 if (Prop->OverloadParamIndex == 0) {
408 if (!RetTy)
409 return makeOpError(OpCode, "Op overloaded on unknown return type");
410 OverloadTy = RetTy;
411 } else if (Prop->OverloadParamIndex > 0) {
412 // The index counts including the return type
413 unsigned ArgIndex = Prop->OverloadParamIndex - 1;
414 if (static_cast<unsigned>(ArgIndex) >= Args.size())
415 return makeOpError(OpCode, "Wrong number of arguments");
416 OverloadTy = Args[ArgIndex]->getType();
417 }
418
419 FunctionType *DXILOpFT =
420 getDXILOpFunctionType(OpCode, M.getContext(), OverloadTy);
421
422 std::optional<size_t> OlIndexOrErr =
423 getPropIndex(ArrayRef(Prop->Overloads), DXILVersion);
424 if (!OlIndexOrErr.has_value())
425 return makeOpError(OpCode, Twine("No valid overloads for DXIL version ") +
426 DXILVersion.getAsString());
427
428 uint16_t ValidTyMask = Prop->Overloads[*OlIndexOrErr].ValidTys;
429
430 OverloadKind Kind = getOverloadKind(OverloadTy);
431
432 // Check if the operation supports overload types and OverloadTy is valid
433 // per the specified types for the operation
434 if ((ValidTyMask != OverloadKind::UNDEFINED) &&
435 (ValidTyMask & (uint16_t)Kind) == 0)
436 return makeOpError(OpCode, "Invalid overload type");
437
438 // Perform necessary checks to ensure Opcode is valid in the targeted shader
439 // kind
440 std::optional<size_t> StIndexOrErr =
441 getPropIndex(ArrayRef(Prop->Stages), DXILVersion);
442 if (!StIndexOrErr.has_value())
443 return makeOpError(OpCode, Twine("No valid stage for DXIL version ") +
444 DXILVersion.getAsString());
445
446 uint16_t ValidShaderKindMask = Prop->Stages[*StIndexOrErr].ValidStages;
447
448 // Ensure valid shader stage properties are specified
449 if (ValidShaderKindMask == ShaderKind::removed)
450 return makeOpError(OpCode, "Operation has been removed");
451
452 // Shader stage need not be validated since getShaderKindEnum() fails
453 // for unknown shader stage.
454
455 // Verify the target shader stage is valid for the DXIL operation
456 ShaderKind ModuleStagekind = getShaderKindEnum(ShaderStage);
457 if (!(ValidShaderKindMask & ModuleStagekind))
458 return makeOpError(OpCode, "Invalid stage");
459
460 std::string DXILFnName = constructOverloadName(Kind, OverloadTy, *Prop);
461 FunctionCallee DXILFn = M.getOrInsertFunction(DXILFnName, DXILOpFT);
462
463 // We need to inject the opcode as the first argument.
466 OpArgs.append(Args.begin(), Args.end());
467
468 return IRB.CreateCall(DXILFn, OpArgs, Name);
469}
470
472 const Twine &Name, Type *RetTy) {
474 if (Error E = Result.takeError())
475 llvm_unreachable("Invalid arguments for operation");
476 return *Result;
477}
478
480 return ::getResRetType(ElementTy);
481}
482
484 return ::getSplitDoubleType(Context);
485}
486
488 return ::getHandleType(IRB.getContext());
489}
490
492 uint32_t SpaceID, dxil::ResourceClass RC) {
493 Type *Int32Ty = IRB.getInt32Ty();
494 Type *Int8Ty = IRB.getInt8Ty();
495 return ConstantStruct::get(
497 {ConstantInt::get(Int32Ty, LowerBound),
498 ConstantInt::get(Int32Ty, UpperBound),
499 ConstantInt::get(Int32Ty, SpaceID),
500 ConstantInt::get(Int8Ty, llvm::to_underlying(RC))});
501}
502
504 Type *Int32Ty = IRB.getInt32Ty();
505 return ConstantStruct::get(
507 {ConstantInt::get(Int32Ty, Word0), ConstantInt::get(Int32Ty, Word1)});
508}
509
511 return ::getOpCodeName(DXILOp);
512}
513} // namespace dxil
514} // namespace llvm
static StructType * getResRetType(Type *ElementTy)
static ShaderKind getShaderKindEnum(Triple::EnvironmentType EnvType)
static Type * getTypeFromOpParamType(OpParamType Kind, LLVMContext &Ctx, Type *OverloadTy)
static std::optional< size_t > getPropIndex(ArrayRef< T > PropList, const VersionTuple DXILVer)
Get index of the property from PropList valid for the most recent DXIL version not greater than DXILV...
static SmallVector< Type * > getArgTypesFromOpParamTypes(ArrayRef< dxil::OpParamType > Types, LLVMContext &Context, Type *OverloadTy)
static const char * getOverloadTypeName(OverloadKind Kind)
static StructType * getSplitDoubleType(LLVMContext &Context)
static OverloadKind getOverloadKind(Type *Ty)
static StructType * getOrCreateStructType(StringRef Name, ArrayRef< Type * > EltTys, LLVMContext &Ctx)
static StructType * getHandleType(LLVMContext &Ctx)
static std::string constructOverloadName(OverloadKind Kind, Type *Ty, const OpCodeProperty &Prop)
static FunctionType * getDXILOpFunctionType(dxil::OpCode OpCode, LLVMContext &Context, Type *OverloadTy)
Construct DXIL function type.
constexpr StringLiteral DXILOpNamePrefix
static std::string constructOverloadTypeName(OverloadKind Kind, StringRef TypeName)
static StructType * getResPropsType(LLVMContext &Context)
static StructType * getResBindType(LLVMContext &Context)
return RetTy
std::string Name
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
@ UNDEFINED
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
reverse_iterator rend() const
Definition: ArrayRef.h:160
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:168
reverse_iterator rbegin() const
Definition: ArrayRef.h:159
This class represents a function call, abstracting a target machine's calling convention.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1378
This is an important base class in LLVM.
Definition: Constant.h:42
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:170
Class to represent function types.
Definition: DerivedTypes.h:105
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:545
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:505
LLVMContext & getContext() const
Definition: IRBuilder.h:195
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2448
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Definition: IRBuilder.h:535
Class to represent integer types.
Definition: DerivedTypes.h:42
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:74
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:302
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
Definition: Module.cpp:204
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:683
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
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:853
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Class to represent struct types.
Definition: DerivedTypes.h:218
static StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
Definition: Type.cpp:731
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition: Type.cpp:612
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ RayGeneration
Definition: Triple.h:292
@ UnknownEnvironment
Definition: Triple.h:245
@ ClosestHit
Definition: Triple.h:295
@ Amplification
Definition: Triple.h:299
@ Intersection
Definition: Triple.h:293
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
@ VoidTyID
type with no size
Definition: Type.h:63
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
@ StructTyID
Structures.
Definition: Type.h:73
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:70
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
@ PointerTyID
Pointers.
Definition: Type.h:72
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
std::string getAsString() const
Retrieve a string representation of the version number.
StructType * getResRetType(Type *ElementTy)
Get a dx.types.ResRet type with the given element type.
StructType * getSplitDoubleType(LLVMContext &Context)
Get the dx.types.splitdouble type.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
CallInst * createOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Create a call instruction for the given DXIL op.
Constant * getResBind(uint32_t LowerBound, uint32_t UpperBound, uint32_t SpaceID, dxil::ResourceClass RC)
Get a constant dx.types.ResBind value.
static const char * getOpCodeName(dxil::OpCode DXILOp)
Return the name of the given opcode.
Constant * getResProps(uint32_t Word0, uint32_t Word1)
Get a constant dx.types.ResourceProperties value.
StructType * getHandleType()
Get the dx.types.Handle type.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ResourceClass
Definition: DXILABI.h:25
static Error makeOpError(dxil::OpCode OpCode, Twine Msg)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
Definition: TypeName.h:63
Version DXILVersion
uint32_t ValidAttrs
llvm::SmallVector< OpOverload > Overloads
llvm::SmallVector< OpAttribute > Attributes
dxil::OpCodeClass OpCodeClass
unsigned OpCodeNameOffset
unsigned OpCodeClassNameOffset
llvm::SmallVector< OpStage > Stages
dxil::OpCode OpCode
uint32_t ValidStages
Version DXILVersion