[llvm] [DXIL] Model DXIL Class and Shader Model association of DXIL Ops in DXIL.td (PR #87803)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 18:47:36 PDT 2024
================
@@ -249,16 +255,38 @@ static FunctionType *getDXILOpFunctionType(const OpCodeProperty *Prop,
ArgTys[0], ArrayRef<Type *>(&ArgTys[1], ArgTys.size() - 1), false);
}
+static uint16_t getValidOverloadMask(const OpCodeProperty *Prop,
+ uint32_t SMVer) {
+ uint16_t ValidTyMask = 0;
+ // std::vector Prop->OverloadProp 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.
+ for (auto OL : Prop->OverloadProp) {
+ if (OL.ShaderModelVer <= SMVer) {
+ ValidTyMask = OL.ValidTys;
+ } else {
+ break;
+ }
+ }
+ return ValidTyMask;
+}
+
namespace llvm {
namespace dxil {
-CallInst *DXILOpBuilder::createDXILOpCall(dxil::OpCode OpCode, Type *ReturnTy,
- Type *OverloadTy,
+CallInst *DXILOpBuilder::createDXILOpCall(dxil::OpCode OpCode, uint32_t SMVer,
+ Type *ReturnTy, Type *OverloadTy,
SmallVector<Value *> Args) {
const OpCodeProperty *Prop = getOpCodeProperty(OpCode);
+ uint16_t ValidTyMask = getValidOverloadMask(Prop, SMVer);
+ if (ValidTyMask == 0) {
+ report_fatal_error(StringRef(std::to_string(SMVer).append(
+ ": Unhandled Shader Model Version")),
+ /*gen_crash_diag*/ false);
+ }
----------------
bharadwajy wrote:
> You have this check after every call to `getValidOverloadMask` - should it be inside that function instead? Further, is this actually something we can hit because of user input, or is this a programmer error where we've made a mistake in `DXIL.td`? For the latter, this should be an assert rather than a fatal error.
Moved the check into `getValidOverloadMask()` as an `assert`.
https://github.com/llvm/llvm-project/pull/87803
More information about the llvm-commits
mailing list