[PATCH] D136907: [flang] Add atomic_and to list of intrinsics

Katherine Rasmussen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 10:23:21 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc2e8e507561: [flang] Add atomic_and to list of intrinsics (authored by ktras).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136907/new/

https://reviews.llvm.org/D136907

Files:
  flang/lib/Evaluate/intrinsics.cpp
  flang/test/Semantics/atomic02.f90


Index: flang/test/Semantics/atomic02.f90
===================================================================
--- flang/test/Semantics/atomic02.f90
+++ flang/test/Semantics/atomic02.f90
@@ -1,10 +1,9 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
-! XFAIL: *
 ! This test checks for semantic errors in atomic_and subroutine calls based on
 ! the interface defined in section 16.9.21 of the Fortran 2018 standard.
 
 program test_atomic_and
-  use iso_fortran_env, only: atomic_int_kind
+  use iso_fortran_env, only: atomic_int_kind, atomic_logical_kind
   implicit none
 
   integer(kind=atomic_int_kind) :: scalar_coarray[*], non_scalar_coarray(10)[*], val, non_coarray
@@ -13,6 +12,7 @@
   integer(kind=1) :: kind1_coarray[*]
   real :: non_integer_coarray[*]
   logical :: non_integer
+  logical(atomic_logical_kind) :: atomic_logical[*]
 
   !___ standard-conforming calls ___
   call atomic_and(scalar_coarray, val)
@@ -27,13 +27,16 @@
 
   !___ non-standard-conforming calls ___
 
-  !ERROR: 'atom=' argument must be a scalar coarray for intrinsic 'atomic_and'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
   call atomic_and(non_scalar_coarray, val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_and'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
+  call atomic_and(non_scalar_coarray[1], val)
+
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
   call atomic_and(non_coarray, val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_and'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
   call atomic_and(array, val)
 
   !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(4)'
@@ -45,6 +48,9 @@
   !ERROR: Actual argument for 'atom=' has bad type 'REAL(4)'
   call atomic_and(non_integer_coarray, val)
 
+  !ERROR: Actual argument for 'atom=' has bad type 'LOGICAL(8)'
+  call atomic_and(atomic_logical, val)
+
   !ERROR: 'value=' argument has unacceptable rank 1
   call atomic_and(scalar_coarray, array)
 
@@ -57,6 +63,7 @@
   !ERROR: 'stat=' argument has unacceptable rank 1
   call atomic_and(scalar_coarray, val, status_array)
 
+  !ERROR: 'stat' argument to 'atomic_and' may not be a coindexed object
   call atomic_and(scalar_coarray, val, coindexed_status[1])
 
   !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' must be definable
Index: flang/lib/Evaluate/intrinsics.cpp
===================================================================
--- flang/lib/Evaluate/intrinsics.cpp
+++ flang/lib/Evaluate/intrinsics.cpp
@@ -1143,6 +1143,14 @@
 
 static const IntrinsicInterface intrinsicSubroutine[]{
     {"abort", {}, {}, Rank::elemental, IntrinsicClass::impureSubroutine},
+    {"atomic_and",
+        {{"atom", AtomicInt, Rank::atom, Optionality::required,
+             common::Intent::InOut},
+            {"value", AnyInt, Rank::scalar, Optionality::required,
+                common::Intent::In},
+            {"stat", AnyInt, Rank::scalar, Optionality::optional,
+                common::Intent::Out}},
+        {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
     {"atomic_cas",
         {{"atom", SameAtom, Rank::atom, Optionality::required,
              common::Intent::InOut},
@@ -2734,6 +2742,8 @@
     }
   } else if (name == "associated") {
     return CheckAssociated(call, context);
+  } else if (name == "atomic_and") {
+    return CheckForCoindexedObject(context, call.arguments[2], name, "stat");
   } else if (name == "atomic_cas") {
     return CheckForCoindexedObject(context, call.arguments[4], name, "stat");
   } else if (name == "atomic_define") {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136907.472055.patch
Type: text/x-patch
Size: 3857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/235569a1/attachment.bin>


More information about the llvm-commits mailing list