[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

Joshua Batista via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 17:06:31 PDT 2024


================
@@ -1079,6 +1079,28 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
       return true;
     break;
   }
+  case Builtin::BI__builtin_hlsl_elementwise_length: {
+    if (SemaRef.checkArgCount(TheCall, 1))
+      return true;
+    if (SemaRef.PrepareBuiltinElementwiseMathOneArgCall(TheCall))
+      return true;   
+
+    ExprResult A = TheCall->getArg(0);
+    QualType ArgTyA = A.get()->getType();
+    QualType RetTy;
+
+    if (auto *VTy = ArgTyA->getAs<VectorType>()) 
+      RetTy = VTy->getElementType();
+		else 
+      RetTy = TheCall->getArg(0)->getType();
+
+    TheCall->setType(RetTy);     
+
+
+    if (CheckFloatOrHalfRepresentations(&SemaRef, TheCall))
----------------
bob80905 wrote:

Discussed offline, due to the content inside the case block, it is insufficient to move this case down there.

https://github.com/llvm/llvm-project/pull/101256


More information about the llvm-commits mailing list