[clang] [llvm] Add cross builtins and cross HLSL function to DirectX and SPIR-V backend (PR #109180)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 10:12:22 PDT 2024
================
@@ -1828,6 +1828,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
return true;
break;
}
+ case Builtin::BI__builtin_hlsl_cross: {
+ if (SemaRef.checkArgCount(TheCall, 2))
+ return true;
+ if (CheckVectorElementCallArgs(&SemaRef, TheCall))
+ return true;
+ if (CheckFloatOrHalfRepresentations(&SemaRef, TheCall))
+ return true;
+ // ensure both args have 3 elements
+ int NumElementsArg1 =
+ TheCall->getArg(0)->getType()->getAs<VectorType>()->getNumElements();
+ int NumElementsArg2 =
+ TheCall->getArg(1)->getType()->getAs<VectorType>()->getNumElements();
+
+ if (NumElementsArg1 != 3) {
+ int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;
+ SemaRef.Diag(TheCall->getBeginLoc(),
+ diag::err_vector_incorrect_num_initializers)
+ << LessOrMore << 3 << NumElementsArg1 << 1;
+ return true;
+ }
+ if (NumElementsArg2 != 3) {
+ int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;
----------------
bob80905 wrote:
Good catch!
https://github.com/llvm/llvm-project/pull/109180
More information about the llvm-commits
mailing list