================ @@ -2266,6 +2266,87 @@ static bool BuiltinCountZeroBitsGeneric(Sema &S, CallExpr *TheCall) { return false; } +static ExprResult BuiltinMaskedLoad(Sema &S, CallExpr *TheCall) { + if (S.checkArgCount(TheCall, 2)) + return ExprError(); + + Expr *MaskArg = TheCall->getArg(0); + Expr *PtrArg = TheCall->getArg(1); + + QualType MaskTy = MaskArg->getType(); + if (!MaskTy->isExtVectorBoolType()) + return ExprError( + S.Diag(MaskArg->getBeginLoc(), diag::err_builtin_invalid_arg_type) + << 1 << /* vector of */ 4 << /* booleans */ 6 << /* no fp */ 0 + << MaskTy); + + QualType PtrTy = PtrArg->getType(); + if (!PtrTy->isPointerType() || !PtrTy->getPointeeType()->isVectorType()) + return ExprError( + S.Diag(PtrArg->getExprLoc(), diag::err_vec_masked_load_store_ptr) + << 2 << "pointer to vector"); + + QualType PointeeTy = PtrTy->getPointeeType(); + const VectorType *MaskVecTy = MaskTy->getAs<VectorType>(); + const VectorType *DataVecTy = PointeeTy->getAs<VectorType>(); + if (MaskVecTy->getNumElements() != DataVecTy->getNumElements()) + return ExprError( + S.Diag(TheCall->getBeginLoc(), diag::err_vec_masked_load_store_size) + << "__builtin_masked_load" << MaskTy << PointeeTy); + + TheCall->setType(PointeeTy); + return TheCall; +} + +static ExprResult BuiltinMaskedStore(Sema &S, CallExpr *TheCall) { + if (S.checkArgCount(TheCall, 3)) ---------------- jhuber6 wrote:
The only common check is the pointer argument, I didn't think it was worth combining them since the code is more readable separate in my opinion. https://github.com/llvm/llvm-project/pull/154464 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits