36 UserDefineType = 1 << 9,
62 case OverloadKind::HALF:
64 case OverloadKind::FLOAT:
66 case OverloadKind::DOUBLE:
68 case OverloadKind::I1:
70 case OverloadKind::I8:
72 case OverloadKind::I16:
74 case OverloadKind::I32:
76 case OverloadKind::I64:
78 case OverloadKind::VOID:
79 case OverloadKind::UNDEFINED:
81 case OverloadKind::ObjectType:
82 case OverloadKind::UserDefineType:
90 return OverloadKind::VOID;
95 return OverloadKind::VOID;
97 return OverloadKind::HALF;
99 return OverloadKind::FLOAT;
101 return OverloadKind::DOUBLE;
107 return OverloadKind::I1;
109 return OverloadKind::I8;
111 return OverloadKind::I16;
113 return OverloadKind::I32;
115 return OverloadKind::I64;
118 return OverloadKind::VOID;
122 return OverloadKind::UserDefineType;
130 return OverloadKind::UNDEFINED;
135 if (Kind < OverloadKind::UserDefineType) {
137 }
else if (Kind == OverloadKind::UserDefineType) {
139 return ST->getStructName().str();
140 }
else if (Kind == OverloadKind::ObjectType) {
142 return ST->getStructName().str();
168#define DXIL_OP_OPERATION_TABLE
169#include "DXILOperation.inc"
170#undef DXIL_OP_OPERATION_TABLE
174 if (Kind == OverloadKind::VOID) {
184 if (Kind == OverloadKind::VOID)
185 return TypeName.str();
187 assert(Kind < OverloadKind::UserDefineType &&
"invalid overload kind");
205 Type *FieldTypes[5] = {ElementTy, ElementTy, ElementTy, ElementTy,
242 case OpParamType::VoidTy:
244 case OpParamType::HalfTy:
246 case OpParamType::FloatTy:
248 case OpParamType::DoubleTy:
250 case OpParamType::Int1Ty:
252 case OpParamType::Int8Ty:
254 case OpParamType::Int16Ty:
256 case OpParamType::Int32Ty:
258 case OpParamType::Int64Ty:
260 case OpParamType::OverloadTy:
262 case OpParamType::ResRetHalfTy:
264 case OpParamType::ResRetFloatTy:
266 case OpParamType::ResRetInt16Ty:
268 case OpParamType::ResRetInt32Ty:
270 case OpParamType::HandleTy:
272 case OpParamType::ResBindTy:
274 case OpParamType::ResPropsTy:
276 case OpParamType::SplitDoubleTy:
286 return ShaderKind::pixel;
288 return ShaderKind::vertex;
290 return ShaderKind::geometry;
292 return ShaderKind::hull;
294 return ShaderKind::domain;
296 return ShaderKind::compute;
298 return ShaderKind::library;
300 return ShaderKind::raygeneration;
302 return ShaderKind::intersection;
304 return ShaderKind::anyhit;
306 return ShaderKind::closesthit;
308 return ShaderKind::miss;
310 return ShaderKind::callable;
312 return ShaderKind::mesh;
314 return ShaderKind::amplification;
319 "Shader Kind Not Found - Invalid DXIL Environment Specified");
341#define DXIL_OP_FUNCTION_TYPE(OpCode, RetType, ...) \
343 return FunctionType::get( \
344 getTypeFromOpParamType(RetType, Context, OverloadTy), \
345 getArgTypesFromOpParamTypes({__VA_ARGS__}, Context, OverloadTy), \
347#include "DXILOperation.inc"
358 size_t Index = PropList.
size() - 1;
359 for (
auto Iter = PropList.
rbegin(); Iter != PropList.
rend();
361 const T &Prop = *Iter;
362 if (
VersionTuple(Prop.DXILVersion.Major, Prop.DXILVersion.Minor) <=
379 DXILVersion = TT.getDXILVersion();
380 ShaderStage = TT.getEnvironment();
385 ": Unknown Compilation Target Shader Stage specified ",
391 return make_error<StringError>(
392 Twine(
"Cannot create ") + getOpCodeName(
OpCode) +
" operation: " + Msg,
402 Type *OverloadTy =
nullptr;
410 if (
static_cast<unsigned>(ArgIndex) >= Args.size())
412 OverloadTy = Args[ArgIndex]->getType();
418 std::optional<size_t> OlIndexOrErr =
420 if (!OlIndexOrErr.has_value())
430 if ((ValidTyMask != OverloadKind::UNDEFINED) &&
431 (ValidTyMask & (
uint16_t)Kind) == 0)
436 std::optional<size_t> StIndexOrErr =
438 if (!StIndexOrErr.has_value())
442 uint16_t ValidShaderKindMask = Prop->
Stages[*StIndexOrErr].ValidStages;
445 if (ValidShaderKindMask == ShaderKind::removed)
453 if (!(ValidShaderKindMask & ModuleStagekind))
462 OpArgs.
append(Args.begin(), Args.end());
470 if (
Error E = Result.takeError())
476 return ::getResRetType(ElementTy);
480 return ::getSplitDoubleType(Context);
493 {ConstantInt::get(Int32Ty, LowerBound),
494 ConstantInt::get(Int32Ty, UpperBound),
495 ConstantInt::get(Int32Ty, SpaceID),
496 ConstantInt::get(Int8Ty, llvm::to_underlying(RC))});
503 {ConstantInt::get(Int32Ty, Word0), ConstantInt::get(Int32Ty, Word1)});
507 return ::getOpCodeName(DXILOp);
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)
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.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
This is an important base class in LLVM.
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.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
LLVMContext & getContext() const
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
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)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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.
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.
#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
llvm::SmallVector< OpStage > Stages