[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

Kaitlin Peng via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 18 14:48:48 PDT 2025


================
@@ -105,35 +136,27 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
     if (SemaRef.checkArgCount(TheCall, 3))
       return true;
 
-    // check if the all arguments have floating representation
-    for (unsigned i = 0; i < TheCall->getNumArgs(); ++i) {
-      ExprResult Arg = TheCall->getArg(i);
-      QualType ArgTy = Arg.get()->getType();
-      if (!ArgTy->hasFloatingRepresentation()) {
-        SemaRef.Diag(Arg.get()->getBeginLoc(),
-                     diag::err_builtin_invalid_arg_type)
-            << i + 1 << /* scalar or vector */ 5 << /* no int */ 0 << /* fp */ 1
-            << ArgTy;
-        return true;
-      }
-    }
+    if (CheckAllArgsHaveFloatRepresentation(&SemaRef, TheCall))
+      return true;
 
-    // check if all arguments are of the same type
-    ExprResult A = TheCall->getArg(0);
-    ExprResult B = TheCall->getArg(1);
-    ExprResult C = TheCall->getArg(2);
-    if (!(SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(),
-                                                         B.get()->getType()) &&
-          SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(),
-                                                         C.get()->getType()))) {
-      SemaRef.Diag(TheCall->getBeginLoc(),
-                   diag::err_vec_builtin_incompatible_vector)
-          << TheCall->getDirectCallee() << /*useAllTerminology*/ true
-          << SourceRange(A.get()->getBeginLoc(), C.get()->getEndLoc());
+    if (CheckAllArgsHaveSameType(&SemaRef, TheCall))
----------------
kmpeng wrote:

Code updated to only check the first value for float representation

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


More information about the llvm-commits mailing list