[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue May 21 07:05:09 PDT 2024
================
@@ -3013,6 +3013,62 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
break;
}
+ case Builtin::BI__builtin_selectvector: {
+ if (checkArgCount(*this, TheCall, 3))
+ return ExprError();
+
+ ExprResult LHS = TheCall->getArg(0);
+ ExprResult RHS = TheCall->getArg(1);
+
+ QualType Result = UsualArithmeticConversions(
+ LHS, RHS, TheCall->getExprLoc(), ACK_Comparison);
+
+ ExprResult Mask = UsualUnaryConversions(TheCall->getArg(2));
+
+ if (LHS.isInvalid() || RHS.isInvalid() || Mask.isInvalid())
+ return ExprError();
+
+ QualType LHST = LHS.get()->getType();
+ QualType RHST = RHS.get()->getType();
+ QualType MaskT = Mask.get()->getType();
+
+ if (Result.isNull() || LHST.getCanonicalType() != RHST.getCanonicalType()) {
+ Diag(LHS.get()->getBeginLoc(),
+ diag::err_typecheck_call_different_arg_types)
+ << LHST << RHST;
+ return ExprError();
+ }
+
+ const auto *LHSVecT = LHST->getAs<VectorType>();
+ const auto *MaskVecT = MaskT->getAs<VectorType>();
+
+ if (!LHSVecT) {
+ Diag(LHS.get()->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ << 1 << 4 << LHST;
----------------
AaronBallman wrote:
Can you add inline comments to the magic numbers (here and below), like `/*argument*/1`
https://github.com/llvm/llvm-project/pull/91306
More information about the cfe-commits
mailing list