diff --git a/flang/test/Lower/OpenACC/pre-fir-tree01.f90 b/flang/test/Lower/OpenACC/pre-fir-tree01.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/OpenACC/pre-fir-tree01.f90 @@ -0,0 +1,18 @@ +! RUN: bbc -fopenacc -pft-test -o %t %s | FileCheck %s +! RUN: %flang_fc1 -fopenacc -fdebug-dump-pft -o %t %s | FileCheck %s + +! Test structure of the Pre-FIR tree with OpenACC + +subroutine sub1(a, b, n) + real :: a(:), b(:) + integer :: n, i + !$acc parallel loop present(a, b) + do i = 1, n + b(i) = exp(a(i)) + end 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 enableOpenACC("fopenacc", + llvm::cl::desc("enable openacc"), + 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 OpenACC + if (enableOpenACC) { + options.features.Enable(Fortran::common::LanguageFeature::OpenACC); + options.predefinitions.emplace_back("_OPENACC", "201911"); + } + Fortran::common::IntrinsicTypeDefaultKinds defaultKinds; Fortran::parser::AllSources allSources; Fortran::parser::AllCookedSources allCookedSources(allSources);