@@ -12896,6 +12896,23 @@ static void DiagnoseReachableSERCall(Sema &S, CallExpr *CE,
1289612896 S.Diag(EntryLoc, diag::note_hlsl_entry_defined_here);
1289712897}
1289812898
12899+ // Some LinAlg builtins are not available in all shader stages
12900+ // Detect those use cases and raise a Diagnostic
12901+ static void DiagnoseReachableLimitedLinAlgCall(Sema &S, CallExpr *CE,
12902+ DXIL::ShaderKind EntrySK,
12903+ const FunctionDecl *EntryDecl) {
12904+ if (EntrySK == DXIL::ShaderKind::Compute ||
12905+ EntrySK == DXIL::ShaderKind::Mesh ||
12906+ EntrySK == DXIL::ShaderKind::Amplification)
12907+ return;
12908+
12909+ SourceLocation EntryLoc = EntryDecl->getLocation();
12910+ SourceLocation Loc = CE->getExprLoc();
12911+ S.Diag(Loc, diag::err_hlsl_linalg_unsupported_stage)
12912+ << ShaderModel::FullNameFromKind(EntrySK);
12913+ S.Diag(EntryLoc, diag::note_hlsl_entry_defined_here);
12914+ }
12915+
1289912916// Check HLSL member call constraints for used functions.
1290012917// locallyVisited is true if this call has been visited already from any other
1290112918// entry function. Used to avoid duplicate diagnostics when not dependent on
@@ -12946,6 +12963,21 @@ void Sema::DiagnoseReachableHLSLCall(CallExpr *CE, const hlsl::ShaderModel *SM,
1294612963 case hlsl::IntrinsicOp::IOP_DxMaybeReorderThread:
1294712964 DiagnoseReachableSERCall(*this, CE, EntrySK, EntryDecl, true);
1294812965 break;
12966+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_FillMatrix:
12967+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_CopyConvertMatrix:
12968+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixLength:
12969+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixGetCoordinate:
12970+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixGetElement:
12971+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixSetElement:
12972+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixStoreToDescriptor:
12973+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixLoadFromMemory:
12974+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixStoreToMemory:
12975+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulateToMemory:
12976+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixMatrixMultiply:
12977+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixMatrixMultiplyAccumulate:
12978+ case hlsl::IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulate:
12979+ DiagnoseReachableLimitedLinAlgCall(*this, CE, EntrySK, EntryDecl);
12980+ break;
1294912981 default:
1295012982 break;
1295112983 }
0 commit comments