[clang] [HLSL][Matrix] Add support for ICK_HLSL_Matrix_Splat to add splat cast of scalars (PR #170885)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 5 12:29:17 PST 2025
================
@@ -7806,6 +7806,39 @@ ExprResult Sema::prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr) {
return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
}
+ExprResult Sema::prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr) {
+ QualType DestElemTy = MatrixTy->castAs<MatrixType>()->getElementType();
+
+ if (DestElemTy == SplattedExpr->getType())
+ return SplattedExpr;
+
+ assert(DestElemTy->isFloatingType() ||
+ DestElemTy->isIntegralOrEnumerationType());
+
+ CastKind CK;
+ if (SplattedExpr->getType()->isBooleanType()) {
+ // As with vectors, we want `true` to become -1 when splatting, and we
+ // need a two-step cast if the destination element type is floating.
----------------
farzonl wrote:
I'm going to remove this block. I actually can't test booleans yet because we did not implement them in `clang/lib/Headers/hlsl/hlsl_basic_types.h`.
https://github.com/llvm/llvm-project/pull/170885
More information about the cfe-commits
mailing list