diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -39,7 +39,9 @@ absConv.getCurrentLocation()); break; case llvm::omp::Directive::OMPD_taskyield: - TODO(); + absConv.getFirOpBuilder().create( + 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 --- a/flang/unittests/Lower/OpenMPLoweringTest.cpp +++ b/flang/unittests/Lower/OpenMPLoweringTest.cpp @@ -56,4 +56,19 @@ 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( + mlirOpBuilder->getUnknownLoc()); + + EXPECT_EQ(taskYieldOp.getOperationName(), "omp.taskyield"); + EXPECT_EQ(succeeded(taskYieldOp.verify()), true); +} + // main() from gtest_main