[clang] [OpenACC] Implement Atomic construct variants (PR #73015)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 09:24:12 PST 2023


================
@@ -59,9 +60,21 @@ OpenACCDirectiveKindEx getOpenACCDirectiveKind(StringRef Name) {
   return llvm::StringSwitch<OpenACCDirectiveKindEx>(Name)
       .Case("enter", OpenACCDirectiveKindEx::Enter)
       .Case("exit", OpenACCDirectiveKindEx::Exit)
+      .Case("atomic", OpenACCDirectiveKindEx::Atomic)
       .Default(OpenACCDirectiveKindEx::Invalid);
 }
 
+// Since 'atomic' is effectively a compound directive, this will decode the
+// second part of the directive.
+OpenACCDirectiveKind getOpenACCAtomicDirectiveKind(StringRef Name) {
+  return llvm::StringSwitch<OpenACCDirectiveKind>(Name)
+      .Case("read", OpenACCDirectiveKind::AtomicRead)
+      .Case("write", OpenACCDirectiveKind::AtomicWrite)
+      .Case("update", OpenACCDirectiveKind::AtomicUpdate)
+      .Case("capture", OpenACCDirectiveKind::AtomicCapture)
----------------
erichkeane wrote:

So they are considered in the language to be 'atomic clauses', but they act more like constructs/directives, in that they have their own rules as far as appertainment and other clause legality.

Note they aren't listed as a 'clause' in the standard like the REST of the 'clauses', so they are kind of a special case that applies to atomic only.

Since atomic REQUIRES this 'atomic-clause' (again, clause is misleading here IMO), and they are so different, it seems to make the most sense to me to represent them as their own directives here.

So to answer your question succinctly: "They are basically neither".

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


More information about the cfe-commits mailing list