[PATCH] D121118: [flang] Add OpenMP flag to bbc
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 07:28:37 PST 2022
clementval created this revision.
clementval added reviewers: jeanPerier, PeteSteinfeld, schweitz, svedanayagam, klausler, shraiysh.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
clementval requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1, jdoerfert.
Herald added a project: LLVM.
Add `-fopenmp` flag to the `bbc` tool.
This patch is part of the upstreaming effort from fir-dev branch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121118
Files:
flang/test/Lower/OpenMP/pre-fir-tree01.f90
flang/tools/bbc/bbc.cpp
Index: flang/tools/bbc/bbc.cpp
===================================================================
--- flang/tools/bbc/bbc.cpp
+++ 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<bool> 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);
Index: flang/test/Lower/OpenMP/pre-fir-tree01.f90
===================================================================
--- /dev/null
+++ flang/test/Lower/OpenMP/pre-fir-tree01.f90
@@ -0,0 +1,18 @@
+! RUN: bbc -fopenmp -pft-test -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: <<OpenMPConstruct>>
+! CHECK: <<DoConstruct>>
+! CHECK: <<End OpenMPConstruct>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121118.413469.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220307/4d9cac09/attachment.bin>
More information about the llvm-commits
mailing list