[flang-commits] [flang] 9e4ab43 - [flang][OpenMP] Added support for lowering OpenMP taskyield construct
Sourabh Singh Tomar via flang-commits
flang-commits at lists.llvm.org
Wed Jul 22 18:47:49 PDT 2020
Author: Sourabh Singh Tomar
Date: 2020-07-23T07:16:34+05:30
New Revision: 9e4ab439c2ee415ef0f7b873ac25bbc63c2a4657
URL: https://github.com/llvm/llvm-project/commit/9e4ab439c2ee415ef0f7b873ac25bbc63c2a4657
DIFF: https://github.com/llvm/llvm-project/commit/9e4ab439c2ee415ef0f7b873ac25bbc63c2a4657.diff
LOG: [flang][OpenMP] Added support for lowering OpenMP taskyield construct
Summary:
This patch lower `!OMP TASKYIELD` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 5.0 spec.
Patch is carved out of following merged PR:
https://github.com/flang-compiler/f18-llvm-project/pull/297
Reviewed: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D84350
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 e839c14a2a5d..bc7cd27df320 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -39,7 +39,9 @@ static void genOMP(Fortran::lower::AbstractConverter &absConv,
absConv.getCurrentLocation());
break;
case llvm::omp::Directive::OMPD_taskyield:
- TODO();
+ absConv.getFirOpBuilder().create<mlir::omp::TaskyieldOp>(
+ absConv.getCurrentLocation());
+ break;
case llvm::omp::Directive::OMPD_target_enter_data:
TODO();
case llvm::omp::Directive::OMPD_target_exit_data:
diff --git a/flang/unittests/Lower/OpenMPLoweringTest.cpp b/flang/unittests/Lower/OpenMPLoweringTest.cpp
index 185d07105a19..fd580d71fab3 100644
--- a/flang/unittests/Lower/OpenMPLoweringTest.cpp
+++ b/flang/unittests/Lower/OpenMPLoweringTest.cpp
@@ -56,4 +56,19 @@ TEST_F(OpenMPLoweringTest, TaskWait) {
EXPECT_EQ(succeeded(taskWaitOp.verify()), true);
}
+TEST_F(OpenMPLoweringTest, TaskYield) {
+ // Construct a dummy parse tree node for `!OMP taskyield`.
+ struct Fortran::parser::OmpSimpleStandaloneDirective taskYieldDirective(
+ llvm::omp::Directive::OMPD_taskyield);
+
+ // Check and lower the `!OMP taskyield` node to `TaskYieldOp` operation of
+ // OpenMPDialect.
+ EXPECT_EQ(taskYieldDirective.v, llvm::omp::Directive::OMPD_taskyield);
+ auto taskYieldOp = mlirOpBuilder->create<mlir::omp::TaskyieldOp>(
+ mlirOpBuilder->getUnknownLoc());
+
+ EXPECT_EQ(taskYieldOp.getOperationName(), "omp.taskyield");
+ EXPECT_EQ(succeeded(taskYieldOp.verify()), true);
+}
+
// main() from gtest_main
More information about the flang-commits
mailing list