[clang] [HLSL] Implement HLSL splatting (PR #118992)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 15:30:25 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 2feced1df0aa01f78501720b98faa985bcec846a cadd309a7d7c61a592d11cb306d44139df8d15ee --extensions cpp,h -- clang/include/clang/Sema/SemaHLSL.h clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaHLSL.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 36557ccb15..69e7766764 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -996,7 +996,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
Address DestVal = Dest.getAddress();
SourceLocation Loc = E->getExprLoc();
- assert (RV.isScalar() && "RHS of HLSL splat cast must be a scalar.");
+ assert(RV.isScalar() && "RHS of HLSL splat cast must be a scalar.");
llvm::Value *SrcVal = RV.getScalarVal();
EmitHLSLSplatCast(CGF, DestVal, DestTy, SrcVal, SrcTy, Loc);
break;
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index b09c18f4a1..cd7d9c243f 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2797,7 +2797,8 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
}
case CK_HLSLSplatCast: {
// This cast should only handle splatting from vectors of length 1.
- // But in Sema a cast should have been inserted to convert the vec1 to a scalar
+ // But in Sema a cast should have been inserted to convert the vec1 to a
+ // scalar
assert(DestTy->isVectorType() && "Destination type must be a vector.");
auto *DestVecTy = DestTy->getAs<VectorType>();
QualType SrcTy = E->getType();
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index a60bc06874..d045870b58 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2785,7 +2785,8 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
// change splat from vec1 case to splat from scalar
if (VT && VT->getNumElements() == 1)
SrcExpr = Self.ImpCastExprToType(SrcExpr.get(), VT->getElementType(),
- CK_HLSLVectorTruncation, VK_PRValue, nullptr, CCK);
+ CK_HLSLVectorTruncation, VK_PRValue,
+ nullptr, CCK);
Kind = CK_HLSLSplatCast;
return;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/118992
More information about the cfe-commits
mailing list