[flang-commits] [flang] 079b49b - [flang][OpenMP] Added support for lowering OpenMP taskwait construct

Sourabh Singh Tomar via flang-commits flang-commits at lists.llvm.org
Fri Jul 17 07:32:39 PDT 2020


Author: Sourabh Singh Tomar
Date: 2020-07-17T20:01:54+05:30
New Revision: 079b49b3fb22b9f1f7dfd9b18ab0179d0ad7e158

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

LOG: [flang][OpenMP] Added support for lowering OpenMP taskwait construct

Summary:
This patch lower `!OMP TASKWAIT` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 4.5 spec.

Patch is carved out of following approved PR:
https://github.com/flang-compiler/f18-llvm-project/pull/280

Reviewed By: kiranchandramohan, clementval

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

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP.cpp
    flang/unittests/Lower/OpenMPLoweringTest.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index c476f1b0d7d3..e839c14a2a5d 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -35,7 +35,9 @@ static void genOMP(Fortran::lower::AbstractConverter &absConv,
         absConv.getCurrentLocation());
     break;
   case llvm::omp::Directive::OMPD_taskwait:
-    TODO();
+    absConv.getFirOpBuilder().create<mlir::omp::TaskwaitOp>(
+        absConv.getCurrentLocation());
+    break;
   case llvm::omp::Directive::OMPD_taskyield:
     TODO();
   case llvm::omp::Directive::OMPD_target_enter_data:

diff  --git a/flang/unittests/Lower/OpenMPLoweringTest.cpp b/flang/unittests/Lower/OpenMPLoweringTest.cpp
index 0942b9deab98..185d07105a19 100644
--- a/flang/unittests/Lower/OpenMPLoweringTest.cpp
+++ b/flang/unittests/Lower/OpenMPLoweringTest.cpp
@@ -41,4 +41,19 @@ TEST_F(OpenMPLoweringTest, Barrier) {
   EXPECT_EQ(succeeded(barrierOp.verify()), true);
 }
 
+TEST_F(OpenMPLoweringTest, TaskWait) {
+  // Construct a dummy parse tree node for `!OMP taskwait`.
+  struct Fortran::parser::OmpSimpleStandaloneDirective taskWaitDirective(
+      llvm::omp::Directive::OMPD_taskwait);
+
+  // Check and lower the `!OMP taskwait` node to `TaskwaitOp` operation of
+  // OpenMPDialect.
+  EXPECT_EQ(taskWaitDirective.v, llvm::omp::Directive::OMPD_taskwait);
+  auto taskWaitOp = mlirOpBuilder->create<mlir::omp::TaskwaitOp>(
+      mlirOpBuilder->getUnknownLoc());
+
+  EXPECT_EQ(taskWaitOp.getOperationName(), "omp.taskwait");
+  EXPECT_EQ(succeeded(taskWaitOp.verify()), true);
+}
+
 // main() from gtest_main


        


More information about the flang-commits mailing list