[llvm] [DXIL] Add constraint specification and backend implementation of DXIL Ops (PR #97593)
Xiang Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 09:03:43 PDT 2024
================
@@ -249,19 +191,59 @@ static FunctionType *getDXILOpFunctionType(const OpCodeProperty *Prop,
ArgTys[0], ArrayRef<Type *>(&ArgTys[1], ArgTys.size() - 1), false);
}
+static int getValidConstraintIndex(const OpCodeProperty *Prop,
+ const VersionTuple SMVer) {
+ // std::vector Prop->SMConstraints is in ascending order of SM Version
+ // Overloads of highest SM version that is not greater than SMVer
+ // are the ones that are valid for SMVer.
+ auto Size = Prop->SMConstraints.size();
+ for (unsigned I = Size - 1; I >= 0; I--) {
+ auto OL = Prop->SMConstraints[I];
+ if (VersionTuple(OL.ShaderModelVer.Major, OL.ShaderModelVer.Minor) <=
+ SMVer) {
+ return I;
+ }
+ }
+ report_fatal_error(
+ StringRef(SMVer.getAsString().append(": Unhandled Shader Model Version")),
+ /*gen_crash_diag*/ false);
+
+ return -1;
+}
+
namespace llvm {
namespace dxil {
-CallInst *DXILOpBuilder::createDXILOpCall(dxil::OpCode OpCode, Type *ReturnTy,
+CallInst *DXILOpBuilder::createDXILOpCall(dxil::OpCode OpCode,
+ VersionTuple SMVer,
+ StringRef StageKind, Type *ReturnTy,
Type *OverloadTy,
SmallVector<Value *> Args) {
const OpCodeProperty *Prop = getOpCodeProperty(OpCode);
+ int Index = getValidConstraintIndex(Prop, SMVer);
+ uint16_t ValidTyMask = Prop->SMConstraints[Index].ValidTys;
OverloadKind Kind = getOverloadKind(OverloadTy);
- if ((Prop->OverloadTys & (uint16_t)Kind) == 0) {
+ if ((ValidTyMask & (uint16_t)Kind) == 0) {
report_fatal_error("Invalid Overload Type", /* gen_crash_diag=*/false);
}
+ // Ensure Opcode is valid in the targetted shader kind
+
+ uint16_t ValidShaderKindMask = Prop->SMConstraints[Index].ValidShaderKinds;
+
+ if (ValidShaderKindMask == ShaderKind::Unknown) {
+ report_fatal_error(
+ StringRef(SMVer.getAsString().append(": Unhandled Shader Kind")),
----------------
python3kgae wrote:
Is this Unhandled Shader Kind in current SMVer?
Like use mesh shader in shader model 6.0?
https://github.com/llvm/llvm-project/pull/97593
More information about the llvm-commits
mailing list