================
@@ -1107,6 +1107,124 @@ bool SemaARM::CheckARMBuiltinFunctionCall(const
TargetInfo &TI,
}
}
+static bool CheckAArch64AtomicStoreWithStshhCall(SemaARM &S,
+ CallExpr *TheCall) {
+ Sema &SemaRef = S.SemaRef;
+ ASTContext &Context = S.getASTContext();
+ DeclRefExpr *DRE =
+ cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
+ SourceLocation Loc = DRE->getBeginLoc();
+
+ // Ensure we have the proper number of arguments.
+ if (SemaRef.checkArgCount(TheCall, 4))
+ return true;
+
+ // Normalize arg0/arg1 into value form, and check valid
+ ExprResult PtrRes =
+ SemaRef.DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
+ ExprResult ValRes =
+ SemaRef.DefaultFunctionArrayLvalueConversion(TheCall->getArg(1));
+
+ if (PtrRes.isInvalid())
+ return true;
+
+ if (ValRes.isInvalid())
+ return true;
+
+ TheCall->setArg(0, PtrRes.get());
+ Expr *PointerArg = PtrRes.get();
+ QualType PtrType = PointerArg->getType();
+
+ // Check arg 0 is a pointer type, err out if not
+ const PointerType *PointerTy = PtrType->getAs<PointerType>();
+ if (!PointerTy) {
+ SemaRef.Diag(Loc, diag::err_atomic_builtin_must_be_pointer)
+ << PtrType << 0 << PointerArg->getSourceRange();
+ return true;
+ }
+
+ // Reject const-qualified pointee types
+ QualType ValType = PointerTy->getPointeeType();
+ if (ValType.isConstQualified()) {
+ SemaRef.Diag(Loc, diag::err_atomic_builtin_cannot_be_const)
+ << PtrType << PointerArg->getSourceRange();
+ return true;
+ }
+
+ ValType = ValType.getUnqualifiedType();
+ bool BadInt = true;
+ if (ValType->isIntegerType()) {
+ unsigned Bits = Context.getTypeSize(ValType);
+ switch (Bits) {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ BadInt = false;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Only 8/16/32/64-bit integers are supported
+ if (BadInt) {
+ SemaRef.Diag(Loc, diag::err_arm_atomic_store_with_stshh_bad_type)
+ << PtrType << PointerArg->getSourceRange();
+ return true;
+ }
----------------
kmclaughlin-arm wrote:
This could either be included in the default case above, or alternatively just
check for the exact sizes expected? With either approach, I think `BadInt` can
be removed.
https://github.com/llvm/llvm-project/pull/181386
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits