[flang-commits] [flang] [flang][openacc] Add semantic checks for atomic constructs (PR #149579)
Andre Kuhlenschmidt via flang-commits
flang-commits at lists.llvm.org
Mon Jul 28 16:05:52 PDT 2025
================
@@ -342,21 +353,237 @@ void AccStructureChecker::Leave(const parser::OpenACCAtomicConstruct &x) {
dirContext_.pop_back();
}
-void AccStructureChecker::Enter(const parser::AccAtomicUpdate &x) {
- const parser::AssignmentStmt &assignment{
- std::get<parser::Statement<parser::AssignmentStmt>>(x.t).statement};
- const auto &var{std::get<parser::Variable>(assignment.t)};
- const auto &expr{std::get<parser::Expr>(assignment.t)};
+void AccStructureChecker::CheckAtomicStmt(
+ const parser::AssignmentStmt &assign, std::string &construct) {
+ const auto &var{std::get<parser::Variable>(assign.t)};
+ const auto &expr{std::get<parser::Expr>(assign.t)};
const auto *rhs{GetExpr(context_, expr)};
const auto *lhs{GetExpr(context_, var)};
- if (lhs && rhs) {
- if (lhs->Rank() != 0)
+
+ if (lhs) {
+ if (lhs->Rank() != 0) {
context_.Say(expr.source,
- "LHS of atomic update statement must be scalar"_err_en_US);
- if (rhs->Rank() != 0)
+ "LHS of atomic %s statement must be scalar"_err_en_US, construct);
+ }
+ // TODO: Check if lhs is intrinsic type.
+ }
+ if (rhs) {
+ if (rhs->Rank() != 0) {
context_.Say(var.GetSource(),
- "RHS of atomic update statement must be scalar"_err_en_US);
+ "RHS of atomic %s statement must be scalar"_err_en_US, construct);
+ }
+ // TODO: Check if rhs is intrinsic type.
+ }
+}
+
+static bool IsValidAtomicUpdateOperation(
+ const evaluate::operation::Operator &op) {
+ switch (op) {
+ case evaluate::operation::Operator::Add:
+ case evaluate::operation::Operator::Mul:
+ case evaluate::operation::Operator::Sub:
+ case evaluate::operation::Operator::Div:
+ case evaluate::operation::Operator::And:
+ case evaluate::operation::Operator::Or:
+ case evaluate::operation::Operator::Eqv:
+ case evaluate::operation::Operator::Neqv:
+ // 2909 intrinsic-procedure name is one of max, min, iand, ior, or ieor.
+ case evaluate::operation::Operator::Max:
+ case evaluate::operation::Operator::Min:
+ // Currently all get mapped to And, Or, and Neqv
+ // case evaluate::operation::Operator::Iand:
+ // case evaluate::operation::Operator::Ior:
+ // case evaluate::operation::Operator::Ieor:
+ return true;
+ case evaluate::operation::Operator::Convert:
+ case evaluate::operation::Operator::Identity:
+ default:
+ return false;
+ }
+}
+
+static SomeExpr GetExprModuloConversion(const SomeExpr &expr) {
----------------
akuhlens wrote:
I am not finding that function in the codebase... Am I missing something? Are you meaning `GetConvertInput(...)`?
https://github.com/llvm/llvm-project/pull/149579
More information about the flang-commits
mailing list