[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 Dec 12 10:47:32 PST 2025


================
@@ -104,6 +104,35 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo &TI,
     return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
            << TheCall->getSourceRange();
 
+  // Common BCD type-validation helpers
+  // Emit diagnostics and return true on failure
+  //  - VerifyVectorType: enforces vector unsigned char
+  //  - VerifyIntType: enforces any integer type
+  // Lambdas centralize type checks for BCD builtin handlers
+  QualType VecType = Context.getVectorType(Context.UnsignedCharTy, 16,
+                                           VectorKind::AltiVecVector);
+  // Lambda 1: verify vector type
+  auto VerifyVectorType = [&](QualType ArgTy, SourceLocation Loc,
+                              unsigned ArgIndex) -> bool {
+    if (!Context.hasSameType(ArgTy, VecType)) {
+      Diag(Loc, diag::err_ppc_invalid_vector_type)
----------------
lei137 wrote:

I don't we need to pass in a `Loc` each time we call these lambdas.
Just code it into the func same way it's being used all through this functions

```suggestion
      Diag(TheCall->getBeginLoc(), diag::err_ppc_invalid_vector_type)
```

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


More information about the llvm-commits mailing list