[clang] [llvm] [HLSL][DirectX] Implement HLSL `mul` function and DXIL lowering of `llvm.matrix.multiply` (PR #184882)
Steven Perron via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 6 10:11:32 PST 2026
================
@@ -3875,6 +3875,53 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
return true;
break;
}
+ case Builtin::BI__builtin_hlsl_mul: {
+ if (SemaRef.checkArgCount(TheCall, 2))
+ return true;
+
+ Expr *Arg0 = TheCall->getArg(0);
+ Expr *Arg1 = TheCall->getArg(1);
+ QualType Ty0 = Arg0->getType();
+ QualType Ty1 = Arg1->getType();
+
+ auto getElemType = [](QualType T) -> QualType {
+ if (const auto *VTy = T->getAs<VectorType>())
+ return VTy->getElementType();
+ if (const auto *MTy = T->getAs<ConstantMatrixType>())
+ return MTy->getElementType();
+ return T;
+ };
+
+ QualType EltTy0 = getElemType(Ty0);
+
+ bool IsVec0 = Ty0->isVectorType();
+ bool IsMat0 = Ty0->isConstantMatrixType();
+ bool IsVec1 = Ty1->isVectorType();
+ bool IsMat1 = Ty1->isConstantMatrixType();
+
+ QualType RetTy;
+
+ // Only matrix-involved cases reach the builtin (cases 6, 8, 9).
----------------
s-perron wrote:
I don't think we should have comments that are tied to the provenance of the call to the builtin. In the future is could get called from other situation unrelated to the HLSL `mul` function. We can just define this builtin function and check that it matches that defintion. No need to reference the cases for `mul`. I would remove this comment, and the "Case <n>: " from the comments below.
https://github.com/llvm/llvm-project/pull/184882
More information about the cfe-commits
mailing list