[flang] [llvm] [flang][OpenMP] Overhaul implementation of ATOMIC construct (PR #137852)

Tom Eccles via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 03:34:35 PDT 2025


================
@@ -777,5 +777,22 @@ inline bool checkForSymbolMatch(const Fortran::semantics::SomeExpr *lhs,
   }
   return false;
 }
+
+/// If the top-level operation (ignoring parentheses) is either an
+/// evaluate::FunctionRef, or a specialization of evaluate::Operation,
+/// then return the list of arguments (wrapped in SomeExpr). Otherwise,
+/// return the "expr" but with top-level parentheses stripped.
+std::vector<SomeExpr> GetOpenMPTopLevelArguments(const SomeExpr &expr);
+
+/// Check if expr is same as x, or a sequence of Convert operations on x.
+bool IsSameOrConvertOf(const SomeExpr &expr, const SomeExpr &x);
+
+/// Strip away any top-level Convert operations (if any exist) and return
+/// the input value. A ComplexConstructor(x, 0) is also considered as a
+/// convert operation.
+/// If the input is not Operation, Designator, FunctionRef or Constant,
+/// is returns std::nullopt.
+MaybeExpr GetConvertInput(const SomeExpr &x);
+
----------------
tblah wrote:

I just thought it was confusing declaring them in a header with one name then defining them in a different cpp file. But you're right, it doesn't make a lot of sense putting them in check-omp-structure.h either.

I think these functions do not look very specific to atomic so it should be okay to extract them if you don't mind. Otherwise I am open to other ideas or if you feel strongly they can stay where they are. I don't think there's an actual style guide rule saying these can't be in a different header and cpp file. 

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


More information about the llvm-commits mailing list