diff --git a/flang/test/Lower/OpenMP/pre-fir-tree01.f90 b/flang/test/Lower/OpenMP/pre-fir-tree01.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/OpenMP/pre-fir-tree01.f90 @@ -0,0 +1,19 @@ +! RUN: bbc -fopenmp -pft-test -o %t %s | FileCheck %s +! RUN: %flang_fc1 -fopenmp -fdebug-dump-pft -o %t %s | FileCheck %s + +! Test structure of the Pre-FIR tree with OpenMP + +subroutine sub1(a, b, n) + real :: a(:), b(:) + integer :: n, i + !$omp parallel do + do i = 1, n + b(i) = exp(a(i)) + end do + !$omp end parallel do +end subroutine + +! CHECK-LABEL: Subroutine sub1 +! CHECK: <> +! CHECK: <> +! CHECK: <> diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp --- a/flang/tools/bbc/bbc.cpp +++ b/flang/tools/bbc/bbc.cpp @@ -80,6 +80,10 @@ llvm::cl::desc("parse the input, create a PFT, dump it, and exit"), llvm::cl::init(false)); +static llvm::cl::opt enableOpenMP("fopenmp", + llvm::cl::desc("enable openmp"), + llvm::cl::init(false)); + #define FLANG_EXCLUDE_CODEGEN #include "flang/Tools/CLOptions.inc" @@ -241,6 +245,12 @@ options.predefinitions.emplace_back( "__flang_patchlevel__"s, std::string{FLANG_VERSION_PATCHLEVEL_STRING}); + // enable parsing of OpenMP + if (enableOpenMP) { + options.features.Enable(Fortran::common::LanguageFeature::OpenMP); + options.predefinitions.emplace_back("_OPENMP", "201511"); + } + Fortran::common::IntrinsicTypeDefaultKinds defaultKinds; Fortran::parser::AllSources allSources; Fortran::parser::AllCookedSources allCookedSources(allSources);