[clang] [llvm] [PowerPC] Add Support for BCDSHIFT, BCDSHIFTR, BCDTRUNC, BCDUTRUNC, and BCDUSHIFT instruction support (PR #154715)

Lei Huang via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 28 07:03:40 PST 2025


================
@@ -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;
----------------
lei137 wrote:

Since this is repeated below, please consider putting this into a function to be called for checking for vector types.  eg isVecType(ArgNum, VectorTypeExpected).

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


More information about the llvm-commits mailing list