LLVM 22.0.0git
DXILOpBuilder.cpp File Reference
#include "DXILOpBuilder.h"
#include "DXILConstants.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ErrorHandling.h"
#include <optional>
#include "DXILOperation.inc"

Go to the source code of this file.

Classes

struct  OpStage
struct  OpCodeProperty

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::dxil

Macros

#define DXIL_OP_OPERATION_TABLE
#define DXIL_OP_FUNCTION_TYPE(OpCode, RetType, ...)
#define DXIL_VERSION(MAJOR, MINOR)
#define DXIL_OP_ATTRIBUTES(OpCode, VersionMajor, VersionMinor, ...)

Functions

static const chargetOverloadTypeName (OverloadKind Kind)
static OverloadKind getOverloadKind (Type *Ty)
static std::string getTypeName (OverloadKind Kind, Type *Ty)
static std::string constructOverloadName (OverloadKind Kind, Type *Ty, const OpCodeProperty &Prop)
static std::string constructOverloadTypeName (OverloadKind Kind, StringRef TypeName)
static StructTypegetOrCreateStructType (StringRef Name, ArrayRef< Type * > EltTys, LLVMContext &Ctx)
static StructTypegetResRetType (Type *ElementTy)
static StructTypegetCBufRetType (Type *ElementTy)
static StructTypegetHandleType (LLVMContext &Ctx)
static StructTypegetResBindType (LLVMContext &Context)
static StructTypegetResPropsType (LLVMContext &Context)
static StructTypegetSplitDoubleType (LLVMContext &Context)
static StructTypegetBinaryWithCarryType (LLVMContext &Context)
static TypegetTypeFromOpParamType (OpParamType Kind, LLVMContext &Ctx, Type *OverloadTy)
static ShaderKind getShaderKindEnum (Triple::EnvironmentType EnvType)
static SmallVector< Type * > getArgTypesFromOpParamTypes (ArrayRef< dxil::OpParamType > Types, LLVMContext &Context, Type *OverloadTy)
static FunctionTypegetDXILOpFunctionType (dxil::OpCode OpCode, LLVMContext &Context, Type *OverloadTy)
 Construct DXIL function type.
template<typename T>
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 DXILVer.
static constexpr uint64_t computeSwitchEnum (dxil::OpCode OpCode, uint16_t VersionMajor, uint16_t VersionMinor)
static dxil::Attributes getDXILAttributes (dxil::OpCode OpCode, VersionTuple DXILVersion)
static void setDXILAttributes (CallInst *CI, dxil::OpCode OpCode, VersionTuple DXILVersion)
static Error llvm::dxil::makeOpError (dxil::OpCode OpCode, Twine Msg)

Variables

constexpr StringLiteral DXILOpNamePrefix = "dx.op."

Macro Definition Documentation

◆ DXIL_OP_ATTRIBUTES

#define DXIL_OP_ATTRIBUTES ( OpCode,
VersionMajor,
VersionMinor,
... )
Value:
case computeSwitchEnum(OpCode, VersionMajor, VersionMinor): { \
auto Other = dxil::Attributes{__VA_ARGS__}; \
Attributes |= Other; \
break; \
};
static constexpr uint64_t computeSwitchEnum(dxil::OpCode OpCode, uint16_t VersionMajor, uint16_t VersionMinor)
@ Other
Any other memory.
Definition ModRef.h:68

◆ DXIL_OP_FUNCTION_TYPE

#define DXIL_OP_FUNCTION_TYPE ( OpCode,
RetType,
... )
Value:
case OpCode: \
return FunctionType::get( \
getTypeFromOpParamType(RetType, Context, OverloadTy), \
getArgTypesFromOpParamTypes({__VA_ARGS__}, Context, OverloadTy), \
/*isVarArg=*/false);
static Type * getTypeFromOpParamType(OpParamType Kind, LLVMContext &Ctx, Type *OverloadTy)
static SmallVector< Type * > getArgTypesFromOpParamTypes(ArrayRef< dxil::OpParamType > Types, LLVMContext &Context, Type *OverloadTy)

◆ DXIL_OP_OPERATION_TABLE

#define DXIL_OP_OPERATION_TABLE

Definition at line 162 of file DXILOpBuilder.cpp.

◆ DXIL_VERSION

#define DXIL_VERSION ( MAJOR,
MINOR )
Value:
{MAJOR, MINOR},

Function Documentation

◆ computeSwitchEnum()

constexpr uint64_t computeSwitchEnum ( dxil::OpCode OpCode,
uint16_t VersionMajor,
uint16_t VersionMinor )
staticconstexpr

Definition at line 415 of file DXILOpBuilder.cpp.

Referenced by getDXILAttributes().

◆ constructOverloadName()

std::string constructOverloadName ( OverloadKind Kind,
Type * Ty,
const OpCodeProperty & Prop )
static

Definition at line 166 of file DXILOpBuilder.cpp.

References DXILOpNamePrefix, and llvm::getTypeName().

Referenced by llvm::dxil::DXILOpBuilder::tryCreateOp().

◆ constructOverloadTypeName()

std::string constructOverloadTypeName ( OverloadKind Kind,
StringRef TypeName )
static

Definition at line 176 of file DXILOpBuilder.cpp.

References assert(), and getOverloadTypeName().

Referenced by getCBufRetType(), and getResRetType().

◆ getArgTypesFromOpParamTypes()

SmallVector< Type * > getArgTypesFromOpParamTypes ( ArrayRef< dxil::OpParamType > Types,
LLVMContext & Context,
Type * OverloadTy )
static

◆ getBinaryWithCarryType()

◆ getCBufRetType()

◆ getDXILAttributes()

dxil::Attributes getDXILAttributes ( dxil::OpCode OpCode,
VersionTuple DXILVersion )
static

Definition at line 424 of file DXILOpBuilder.cpp.

References computeSwitchEnum().

Referenced by setDXILAttributes().

◆ getDXILOpFunctionType()

FunctionType * getDXILOpFunctionType ( dxil::OpCode OpCode,
LLVMContext & Context,
Type * OverloadTy )
static

Construct DXIL function type.

This is the type of a function with the following prototype OverloadType dx.op.<opclass>.<return-type>(int opcode, ) <param-types> are constructed from types in Prop.

Definition at line 379 of file DXILOpBuilder.cpp.

References llvm_unreachable.

Referenced by llvm::dxil::DXILOpBuilder::tryCreateOp().

◆ getHandleType()

StructType * getHandleType ( LLVMContext & Ctx)
static

Definition at line 227 of file DXILOpBuilder.cpp.

References getOrCreateStructType(), and llvm::PointerType::getUnqual().

Referenced by getTypeFromOpParamType().

◆ getOrCreateStructType()

StructType * getOrCreateStructType ( StringRef Name,
ArrayRef< Type * > EltTys,
LLVMContext & Ctx )
static

◆ getOverloadKind()

◆ getOverloadTypeName()

const char * getOverloadTypeName ( OverloadKind Kind)
static

Definition at line 55 of file DXILOpBuilder.cpp.

References llvm_unreachable.

Referenced by constructOverloadTypeName(), and getTypeName().

◆ getPropIndex()

template<typename T>
std::optional< size_t > getPropIndex ( ArrayRef< T > PropList,
const VersionTuple DXILVer )
static

Get index of the property from PropList valid for the most recent DXIL version not greater than DXILVer.

PropList is expected to be sorted in ascending order of DXIL version.

Definition at line 399 of file DXILOpBuilder.cpp.

References llvm::ArrayRef< T >::rbegin(), llvm::ArrayRef< T >::rend(), llvm::ArrayRef< T >::size(), and T.

Referenced by llvm::dxil::DXILOpBuilder::tryCreateOp().

◆ getResBindType()

◆ getResPropsType()

◆ getResRetType()

◆ getShaderKindEnum()

◆ getSplitDoubleType()

StructType * getSplitDoubleType ( LLVMContext & Context)
static

◆ getTypeFromOpParamType()

◆ getTypeName()

std::string getTypeName ( OverloadKind Kind,
Type * Ty )
static

◆ setDXILAttributes()

Variable Documentation

◆ DXILOpNamePrefix

StringLiteral DXILOpNamePrefix = "dx.op."
constexpr

Definition at line 22 of file DXILOpBuilder.cpp.

Referenced by constructOverloadName().