[flang-commits] [flang] e18672a - [flang][openacc] Add routine info attribute to the function

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Tue Aug 15 22:19:15 PDT 2023


Author: Valentin Clement
Date: 2023-08-15T22:19:03-07:00
New Revision: e18672ad3a8797355979e5a0a9f1d8c71c9c53be

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

LOG: [flang][openacc] Add routine info attribute to the function

Attch the routine info attribute to the func operation.

Reviewed By: razvanlupusoru

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

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp
    flang/test/Lower/OpenACC/acc-routine.f90
    mlir/include/mlir/Dialect/OpenACC/OpenACC.h

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 0658ad773d4510..b00b719bb66714 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -2748,6 +2748,19 @@ genACC(Fortran::lower::AbstractConverter &converter,
       loc, routineOpName.str(), func.getName(), mlir::StringAttr{},
       mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{},
       mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::IntegerAttr{});
+
+  llvm::SmallVector<mlir::SymbolRefAttr> routines;
+  if (func.getOperation()->hasAttr(mlir::acc::getRoutineInfoAttrName())) {
+    auto routineInfo =
+        func.getOperation()->getAttrOfType<mlir::acc::RoutineInfoAttr>(
+            mlir::acc::getRoutineInfoAttrName());
+    routines.append(routineInfo.getAccRoutines().begin(),
+                    routineInfo.getAccRoutines().end());
+  }
+  routines.push_back(builder.getSymbolRefAttr(routineOpName.str()));
+  func.getOperation()->setAttr(
+      mlir::acc::getRoutineInfoAttrName(),
+      mlir::acc::RoutineInfoAttr::get(builder.getContext(), routines));
 }
 
 void Fortran::lower::genOpenACCConstruct(

diff  --git a/flang/test/Lower/OpenACC/acc-routine.f90 b/flang/test/Lower/OpenACC/acc-routine.f90
index c25629024642fe..c123c766d7925a 100644
--- a/flang/test/Lower/OpenACC/acc-routine.f90
+++ b/flang/test/Lower/OpenACC/acc-routine.f90
@@ -7,4 +7,4 @@ subroutine acc_routine1()
 end subroutine
 
 ! CHECK: acc.routine @acc_routine_0 func(@_QPacc_routine1)
-! CHECK-LABEL: func.func @_QPacc_routine1()
+! CHECK-LABEL: func.func @_QPacc_routine1() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}

diff  --git a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
index 602aa505903248..dce61ee54e96ff 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
@@ -82,6 +82,10 @@ static constexpr StringLiteral getDeclareActionAttrName() {
   return StringLiteral("acc.declare_action");
 }
 
+static constexpr StringLiteral getRoutineInfoAttrName() {
+  return StringLiteral("acc.routine_info");
+}
+
 } // namespace acc
 } // namespace mlir
 


        


More information about the flang-commits mailing list