[clang] 8076ee9 - [RISCV] Use getBuiltinVectorTypeInfo instead of isRVVType.

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 28 11:15:31 PST 2023


Author: Craig Topper
Date: 2023-12-28T11:15:14-08:00
New Revision: 8076ee9667198c28cfd1ef6dc8f01c3e539549a2

URL: https://github.com/llvm/llvm-project/commit/8076ee9667198c28cfd1ef6dc8f01c3e539549a2
DIFF: https://github.com/llvm/llvm-project/commit/8076ee9667198c28cfd1ef6dc8f01c3e539549a2.diff

LOG: [RISCV] Use getBuiltinVectorTypeInfo instead of isRVVType.

I'm trying to remove all uses of isRVVType.

Fix diagnostic message to report an error for the builtin instead
of the type. Though I can't seem to get a test to hit it.

Added: 
    

Modified: 
    clang/lib/Sema/SemaChecking.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2e61dafacab02d..da0570b7b0f1e6 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5388,15 +5388,17 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
     QualType Op1Type = TheCall->getArg(0)->getType();
     QualType Op2Type = TheCall->getArg(1)->getType();
     QualType Op3Type = TheCall->getArg(2)->getType();
-    uint64_t ElemSize = Op1Type->isRVVType(32, false) ? 32 : 64;
+    ASTContext::BuiltinVectorTypeInfo Info =
+        Context.getBuiltinVectorTypeInfo(Op1Type->castAs<BuiltinType>());
+    uint64_t ElemSize = Context.getTypeSize(Info.ElementType);
     if (ElemSize == 64 && !TI.hasFeature("zvknhb"))
       return Diag(TheCall->getBeginLoc(),
-                  diag::err_riscv_type_requires_extension)
-             << Op1Type << "zvknhb";
+                  diag::err_riscv_builtin_requires_extension)
+             << /* IsExtension */ true << TheCall->getSourceRange() << "zvknb";
 
-    return CheckInvalidVLENandLMUL(TI, TheCall, *this, Op1Type, ElemSize << 2) ||
-           CheckInvalidVLENandLMUL(TI, TheCall, *this, Op2Type, ElemSize << 2) ||
-           CheckInvalidVLENandLMUL(TI, TheCall, *this, Op3Type, ElemSize << 2);
+    return CheckInvalidVLENandLMUL(TI, TheCall, *this, Op1Type, ElemSize * 4) ||
+           CheckInvalidVLENandLMUL(TI, TheCall, *this, Op2Type, ElemSize * 4) ||
+           CheckInvalidVLENandLMUL(TI, TheCall, *this, Op3Type, ElemSize * 4);
   }
 
   case RISCVVector::BI__builtin_rvv_sf_vc_i_se_u8mf8:


        


More information about the cfe-commits mailing list