37 UserDefineType = 1 << 9,
63 case OverloadKind::HALF:
65 case OverloadKind::FLOAT:
67 case OverloadKind::DOUBLE:
69 case OverloadKind::I1:
71 case OverloadKind::I8:
73 case OverloadKind::I16:
75 case OverloadKind::I32:
77 case OverloadKind::I64:
79 case OverloadKind::VOID:
80 case OverloadKind::UNDEFINED:
82 case OverloadKind::ObjectType:
83 case OverloadKind::UserDefineType:
93 return OverloadKind::VOID;
95 return OverloadKind::HALF;
97 return OverloadKind::FLOAT;
99 return OverloadKind::DOUBLE;
105 return OverloadKind::I1;
107 return OverloadKind::I8;
109 return OverloadKind::I16;
111 return OverloadKind::I32;
113 return OverloadKind::I64;
116 return OverloadKind::VOID;
120 return OverloadKind::UserDefineType;
122 return OverloadKind::ObjectType;
125 return OverloadKind::VOID;
130 if (Kind < OverloadKind::UserDefineType) {
132 }
else if (Kind == OverloadKind::UserDefineType) {
134 return ST->getStructName().str();
135 }
else if (Kind == OverloadKind::ObjectType) {
137 return ST->getStructName().str();
165#define DXIL_OP_OPERATION_TABLE
166#include "DXILOperation.inc"
167#undef DXIL_OP_OPERATION_TABLE
171 if (Kind == OverloadKind::VOID) {
181 if (Kind == OverloadKind::VOID)
182 return TypeName.str();
184 assert(Kind < OverloadKind::UserDefineType &&
"invalid overload kind");
201 Type *FieldTypes[5] = {OverloadTy, OverloadTy, OverloadTy, OverloadTy,
214 case ParameterKind::Void:
216 case ParameterKind::Half:
218 case ParameterKind::Float:
220 case ParameterKind::Double:
222 case ParameterKind::I1:
224 case ParameterKind::I8:
226 case ParameterKind::I16:
228 case ParameterKind::I32:
230 case ParameterKind::I64:
232 case ParameterKind::Overload:
234 case ParameterKind::ResourceRet:
236 case ParameterKind::DXILHandle:
248 return ShaderKind::pixel;
250 return ShaderKind::vertex;
252 return ShaderKind::geometry;
254 return ShaderKind::hull;
256 return ShaderKind::domain;
258 return ShaderKind::compute;
260 return ShaderKind::library;
262 return ShaderKind::raygeneration;
264 return ShaderKind::intersection;
266 return ShaderKind::anyhit;
268 return ShaderKind::closesthit;
270 return ShaderKind::miss;
272 return ShaderKind::callable;
274 return ShaderKind::mesh;
276 return ShaderKind::amplification;
281 "Shader Kind Not Found - Invalid DXIL Environment Specified");
293 const ParameterKind *ParamKinds = getOpCodeParameterKind(*Prop);
307 return FunctionType::get(ReturnTy, ArgTys,
false);
317 for (
auto Iter = PropList.
rbegin(); Iter != PropList.
rend();
319 const T &Prop = *Iter;
320 if (
VersionTuple(Prop.DXILVersion.Major, Prop.DXILVersion.Minor) <=
337 DXILVersion = TT.getDXILVersion();
338 ShaderStage = TT.getEnvironment();
343 ": Unknown Compilation Target Shader Stage specified ",
349 return make_error<StringError>(
350 Twine(
"Cannot create ") + getOpCodeName(
OpCode) +
" operation: " + Msg,
359 Type *OverloadTy =
nullptr;
367 if (
static_cast<unsigned>(ArgIndex) >= Args.size())
369 OverloadTy = Args[ArgIndex]->getType();
374 std::optional<size_t> OlIndexOrErr =
376 if (!OlIndexOrErr.has_value())
390 if ((ValidTyMask != OverloadKind::UNDEFINED) &&
391 (ValidTyMask & (
uint16_t)Kind) == 0)
396 std::optional<size_t> StIndexOrErr =
398 if (!StIndexOrErr.has_value())
402 uint16_t ValidShaderKindMask = Prop->
Stages[*StIndexOrErr].ValidStages;
405 if (ValidShaderKindMask == ShaderKind::removed)
413 if (!(ValidShaderKindMask & ModuleStagekind))
422 OpArgs.
append(Args.begin(), Args.end());
430 if (
Error E = Result.takeError())
436 return ::getOpCodeName(DXILOp);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static ShaderKind getShaderKindEnum(Triple::EnvironmentType EnvType)
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 StructType * getResRetType(Type *OverloadTy, LLVMContext &Ctx)
static const char * getOverloadTypeName(OverloadKind Kind)
static OverloadKind getOverloadKind(Type *Ty)
static FunctionType * getDXILOpFunctionType(const OpCodeProperty *Prop, LLVMContext &Context, Type *OverloadTy)
Construct DXIL function type.
static Type * getTypeFromParameterKind(ParameterKind Kind, LLVMContext &Ctx, Type *OverloadTy)
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)
constexpr StringLiteral DXILOpNamePrefix
static std::string constructOverloadTypeName(OverloadKind Kind, StringRef TypeName)
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
reverse_iterator rend() const
size_t size() const
size - Get the array size.
reverse_iterator rbegin() const
This class represents a function call, abstracting a target machine's calling convention.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
Type * getReturnType() const
Common base class shared among various IRBuilders.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
Class to represent integer types.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
LLVMContext & getContext() const
Get the global data context.
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
reference emplace_back(ArgTypes &&... Args)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
static StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
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.
@ HalfTyID
16-bit floating point type
@ VoidTyID
type with no size
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ DoubleTyID
64-bit floating point type
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)
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.
Represents a version number in the form major[.minor[.subminor[.build]]].
std::string getAsString() const
Retrieve a string representation of the version number.
DXILOpBuilder(Module &M, IRBuilderBase &B)
CallInst * createOp(dxil::OpCode Op, ArrayRef< Value * > &Args, Type *RetTy=nullptr)
Create a call instruction for the given DXIL op.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
static const char * getOpCodeName(dxil::OpCode DXILOp)
Return the name of the given opcode.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Error makeOpError(dxil::OpCode OpCode, Twine Msg)
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.
llvm::SmallVector< OpOverload > Overloads
llvm::SmallVector< OpAttribute > Attributes
dxil::OpCodeClass OpCodeClass
unsigned OpCodeNameOffset
unsigned OpCodeClassNameOffset
unsigned ParameterTableOffset
llvm::SmallVector< OpStage > Stages