[flang-commits] [flang] b82c259 - [flang][openacc] Add lowering support for the link clause on OpenACC declare

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Thu Aug 3 10:22:51 PDT 2023


Author: Valentin Clement
Date: 2023-08-03T10:22:32-07:00
New Revision: b82c259370436170da0128d78802fddd474247d7

URL: https://github.com/llvm/llvm-project/commit/b82c259370436170da0128d78802fddd474247d7
DIFF: https://github.com/llvm/llvm-project/commit/b82c259370436170da0128d78802fddd474247d7.diff

LOG: [flang][openacc] Add lowering support for the link clause on OpenACC declare

Lower link clause with data entry operation.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156913

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp
    flang/test/Lower/OpenACC/acc-declare.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index c9fe64e0eabc2a..9bc8fe79df035b 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -2465,6 +2465,12 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
           devicePtrClause->v, converter, semanticsContext, stmtCtx,
           dataClauseOperands, mlir::acc::DataClause::acc_deviceptr,
           /*structured=*/true);
+    } else if (const auto *linkClause =
+                   std::get_if<Fortran::parser::AccClause::Link>(&clause.u)) {
+      genDataOperandOperations<mlir::acc::DeclareLinkOp>(
+          linkClause->v, converter, semanticsContext, stmtCtx,
+          dataClauseOperands, mlir::acc::DataClause::acc_declare_link,
+          /*structured=*/true);
     } else {
       mlir::Location clauseLocation = converter.genLocation(clause.source);
       TODO(clauseLocation, "clause on declare directive");

diff  --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90
index bf873971a40509..cb0043d5e8e335 100644
--- a/flang/test/Lower/OpenACC/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/acc-declare.f90
@@ -187,6 +187,22 @@ subroutine acc_declare_deviceptr(a)
 ! CHECK: %[[DEVICEPTR:.*]] = acc.deviceptr varPtr(%[[ARG0]] : !fir.ref<!fir.array<100xi32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<100xi32>> {name = "a"}
 ! CHECK: acc.declare_enter dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100xi32>>)
 ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32)
+! CHECK-NOT: acc.declare_exit
+
+  subroutine acc_declare_link(a)
+    integer :: a(100), i
+    !$acc declare link(a)
+
+    do i = 1, 100
+      a(i) = i
+    end do
+  end subroutine
+
+! CHECK-LABEL: func.func @_QMacc_declarePacc_declare_link(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<100xi32>> {fir.bindc_name = "a"})
+! CHECK: %[[LINK:.*]] = acc.declare_link varPtr(%[[ARG0]] : !fir.ref<!fir.array<100xi32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<100xi32>> {name = "a"}
+! CHECK: acc.declare_enter dataOperands(%[[LINK]] : !fir.ref<!fir.array<100xi32>>)
+! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32)
 ! CHECK-NOT: acc.declare_exit
 
 end module


        


More information about the flang-commits mailing list