================
@@ -105,11 +105,67 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const 
TargetInfo &TI,
   switch (BuiltinID) {
   default:
     return false;
-  case PPC::BI__builtin_ppc_bcdsetsign:
   case PPC::BI__builtin_ppc_national2packed:
   case PPC::BI__builtin_ppc_packed2zoned:
   case PPC::BI__builtin_ppc_zoned2packed:
     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
+  case PPC::BI__builtin_ppc_bcdsetsign: {
+
+    ASTContext &Context = SemaRef.Context;
+    QualType Arg0Type = TheCall->getArg(0)->getType();
+    QualType Arg1Type = TheCall->getArg(1)->getType();
+
+    QualType VecType = Context.getVectorType(Context.UnsignedCharTy, 16,
+                                             VectorKind::AltiVecVector);
+
+    // Arg0 must be <16 x unsigned char>
+    if (!Context.hasSameType(Arg0Type, VecType))
+      return SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(),
+                          diag::err_ppc_bcd_invalid_vector_type)
+             << 0 << VecType << Arg0Type;
+
+    // Arg1 must be integer type
+    if (!Arg1Type->isIntegerType())
+      return SemaRef.Diag(TheCall->getArg(1)->getBeginLoc(),
+                          diag::err_ppc_bcd_invalid_integer_type)
+             << 1 << "integer type" << Arg1Type;
+
+    // Restrict Arg1 constant range (0–1)
+    return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
----------------
lei137 wrote:

consider using existing function: `SemaRef.BuiltinConstantArgRange()`

https://github.com/llvm/llvm-project/pull/154715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to