Index: flang/include/flang/Lower/OpenACC.h =================================================================== --- flang/include/flang/Lower/OpenACC.h +++ flang/include/flang/Lower/OpenACC.h @@ -16,6 +16,7 @@ namespace Fortran { namespace parser { struct OpenACCConstruct; +struct OpenACCDeclarativeConstruct; } // namespace parser namespace lower { @@ -28,6 +29,9 @@ void genOpenACCConstruct(AbstractConverter &, pft::Evaluation &, const parser::OpenACCConstruct &); +void genOpenACCDeclarativeConstruct( + AbstractConverter &, pft::Evaluation &, + const parser::OpenACCDeclarativeConstruct &); } // namespace lower } // namespace Fortran Index: flang/include/flang/Lower/OpenMP.h =================================================================== --- flang/include/flang/Lower/OpenMP.h +++ flang/include/flang/Lower/OpenMP.h @@ -16,6 +16,7 @@ namespace Fortran { namespace parser { struct OpenMPConstruct; +struct OpenMPDeclarativeConstruct; } // namespace parser namespace lower { @@ -28,6 +29,8 @@ void genOpenMPConstruct(AbstractConverter &, pft::Evaluation &, const parser::OpenMPConstruct &); +void genOpenMPDeclarativeConstruct(AbstractConverter &, pft::Evaluation &, + const parser::OpenMPDeclarativeConstruct &); } // namespace lower } // namespace Fortran Index: flang/lib/Lower/Bridge.cpp =================================================================== --- flang/lib/Lower/Bridge.cpp +++ flang/lib/Lower/Bridge.cpp @@ -1186,8 +1186,12 @@ builder->restoreInsertionPoint(insertPt); } - void genFIR(const Fortran::parser::OpenACCDeclarativeConstruct &) { - TODO(toLocation(), "OpenACCDeclarativeConstruct lowering"); + void genFIR(const Fortran::parser::OpenACCDeclarativeConstruct &accDecl) { + mlir::OpBuilder::InsertPoint insertPt = builder->saveInsertionPoint(); + genOpenACCDeclarativeConstruct(*this, getEval(), accDecl); + for (Fortran::lower::pft::Evaluation &e : getEval().getNestedEvaluations()) + genFIR(e); + builder->restoreInsertionPoint(insertPt); } void genFIR(const Fortran::parser::OpenMPConstruct &omp) { @@ -1202,7 +1206,11 @@ } void genFIR(const Fortran::parser::OpenMPDeclarativeConstruct &ompDecl) { - TODO(toLocation(), "OpenMPDeclarativeConstruct lowering"); + mlir::OpBuilder::InsertPoint insertPt = builder->saveInsertionPoint(); + genOpenMPDeclarativeConstruct(*this, getEval(), ompDecl); + for (Fortran::lower::pft::Evaluation &e : getEval().getNestedEvaluations()) + genFIR(e); + builder->restoreInsertionPoint(insertPt); } /// Generate FIR for a SELECT CASE statement. Index: flang/lib/Lower/OpenACC.cpp =================================================================== --- flang/lib/Lower/OpenACC.cpp +++ flang/lib/Lower/OpenACC.cpp @@ -979,11 +979,6 @@ &standaloneConstruct) { genACC(converter, eval, standaloneConstruct); }, - [&](const Fortran::parser::OpenACCRoutineConstruct - &routineConstruct) { - TODO(converter.getCurrentLocation(), - "OpenACC Routine construct not lowered yet!"); - }, [&](const Fortran::parser::OpenACCCacheConstruct &cacheConstruct) { TODO(converter.getCurrentLocation(), "OpenACC Cache construct not lowered yet!"); @@ -998,3 +993,24 @@ }, accConstruct.u); } + +void Fortran::lower::genOpenACCDeclarativeConstruct( + Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + const Fortran::parser::OpenACCDeclarativeConstruct &accDeclConstruct) { + + std::visit( + common::visitors{ + [&](const Fortran::parser::OpenACCStandaloneDeclarativeConstruct + &standaloneDeclarativeConstruct) { + TODO(converter.getCurrentLocation(), + "OpenACC Standalone Declarative construct not lowered yet!"); + }, + [&](const Fortran::parser::OpenACCRoutineConstruct + &routineConstruct) { + TODO(converter.getCurrentLocation(), + "OpenACC Routine construct not lowered yet!"); + }, + }, + accDeclConstruct.u); +} Index: flang/lib/Lower/OpenMP.cpp =================================================================== --- flang/lib/Lower/OpenMP.cpp +++ flang/lib/Lower/OpenMP.cpp @@ -633,3 +633,35 @@ }, ompConstruct.u); } + +void Fortran::lower::genOpenMPDeclarativeConstruct( + Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + const Fortran::parser::OpenMPDeclarativeConstruct &ompDeclConstruct) { + + std::visit( + common::visitors{ + [&](const Fortran::parser::OpenMPDeclarativeAllocate + &declarativeAllocate) { + TODO(converter.getCurrentLocation(), "OpenMPDeclarativeAllocate"); + }, + [&](const Fortran::parser::OpenMPDeclareReductionConstruct + &declareReductionConstruct) { + TODO(converter.getCurrentLocation(), + "OpenMPDeclareReductionConstruct"); + }, + [&](const Fortran::parser::OpenMPDeclareSimdConstruct + &declareSimdConstruct) { + TODO(converter.getCurrentLocation(), "OpenMPDeclareSimdConstruct"); + }, + [&](const Fortran::parser::OpenMPDeclareTargetConstruct + &declareTargetConstruct) { + TODO(converter.getCurrentLocation(), + "OpenMPDeclareTargetConstruct"); + }, + [&](const Fortran::parser::OpenMPThreadprivate &threadprivate) { + TODO(converter.getCurrentLocation(), "OpenMPThreadprivate"); + }, + }, + ompDeclConstruct.u); +} Index: flang/test/Lower/OpenACC/Todo/acc-declare.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenACC/Todo/acc-declare.f90 @@ -0,0 +1,10 @@ +! This test checks lowering of OpenACC declare Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenacc %s 2>&1 | FileCheck %s + +program main + real, dimension(10) :: aa, bb + + // CHECK: not yet implemented: OpenACC Standalone Declarative construct + !$acc declare present(aa, bb) +end Index: flang/test/Lower/OpenACC/Todo/acc-routine.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenACC/Todo/acc-routine.f90 @@ -0,0 +1,12 @@ +! This test checks lowering of OpenACC routine Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenacc %s 2>&1 | FileCheck %s + +program main + // CHECK: not yet implemented: OpenACC Routine construct not lowered yet! + !$acc routine(sub) seq +contains + subroutine sub(a) + real :: a(:) + end +end Index: flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90 @@ -0,0 +1,10 @@ +! This test checks lowering of OpenMP allocate Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s + +program main + integer :: x, y + + // CHECK: not yet implemented: OpenMPDeclarativeAllocate + !$omp allocate(x, y) +end Index: flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90 @@ -0,0 +1,10 @@ +! This test checks lowering of OpenMP declare reduction Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s + +subroutine declare_red() + integer :: my_var + // CHECK: not yet implemented: OpenMPDeclareReductionConstruct + !$omp declare reduction (my_red : integer : omp_out = omp_in) initializer (omp_priv = 0) + my_var = 0 +end subroutine declare_red Index: flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90 @@ -0,0 +1,11 @@ +! This test checks lowering of OpenMP declare simd Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s + +subroutine sub(x, y) + real, intent(inout) :: x, y + + // CHECK: not yet implemented: OpenMPDeclareSimdConstruct + !$omp declare simd(sub) aligned(x) + x = 3.14 + y +end Index: flang/test/Lower/OpenMP/Todo/omp-declare-target.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/Todo/omp-declare-target.f90 @@ -0,0 +1,12 @@ +! This test checks lowering of OpenMP declare target Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s + +module mod1 +contains + subroutine sub() + integer :: x, y + // CHECK: not yet implemented: OpenMPDeclareTargetConstruct + !$omp declare target + end +end module Index: flang/test/Lower/OpenMP/Todo/omp-threadprivate.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/Todo/omp-threadprivate.f90 @@ -0,0 +1,10 @@ +! This test checks lowering of OpenMP threadprivate Directive. + +// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s + +program main + integer, save :: x, y + +// CHECK: not yet implemented: OpenMPThreadprivate + !$omp threadprivate(x, y) +end