Skip to content

[flang][OpenMP] Add unparsing of BIND clause argument #117776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

kparzysz
Copy link
Contributor

Currently the argument of the BIND clause is not printed. This is likely an omission in the original implementation.

Currently the argument of the BIND clause is not printed. This is likely
an omission in the original implementation.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:parser labels Nov 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2024

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

Changes

Currently the argument of the BIND clause is not printed. This is likely an omission in the original implementation.


Full diff: https://github.com/llvm/llvm-project/pull/117776.diff

2 Files Affected:

  • (modified) flang/lib/Parser/unparse.cpp (+1)
  • (added) flang/test/Parser/OpenMP/bind-clause.f90 (+25)
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index fe3f6ce7aa6291..e1708157b63dc2 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2834,6 +2834,7 @@ class UnparseVisitor {
   WALK_NESTED_ENUM(InquireSpec::LogVar, Kind)
   WALK_NESTED_ENUM(ProcedureStmt, Kind) // R1506
   WALK_NESTED_ENUM(UseStmt, ModuleNature) // R1410
+  WALK_NESTED_ENUM(OmpBindClause, Type) // OMP bind
   WALK_NESTED_ENUM(OmpProcBindClause, Type) // OMP PROC_BIND
   WALK_NESTED_ENUM(OmpDefaultClause, Type) // OMP DEFAULT
   WALK_NESTED_ENUM(OmpDefaultmapClause, ImplicitBehavior) // OMP DEFAULTMAP
diff --git a/flang/test/Parser/OpenMP/bind-clause.f90 b/flang/test/Parser/OpenMP/bind-clause.f90
new file mode 100644
index 00000000000000..332e5fe26ed8a8
--- /dev/null
+++ b/flang/test/Parser/OpenMP/bind-clause.f90
@@ -0,0 +1,25 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=50 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=50 %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+subroutine f00
+  !$omp loop bind(parallel)
+  do i = 1, 10
+    continue
+  enddo
+  !$omp end loop
+end
+
+!UNPARSE: SUBROUTINE f00
+!UNPARSE: !$OMP LOOP  BIND(PARALLEL)
+!UNPARSE:  DO i=1_4,10_4
+!UNPARSE:   CONTINUE
+!UNPARSE:  END DO
+!UNPARSE: !$OMP END LOOP
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
+!PARSE-TREE: | OmpBeginLoopDirective
+!PARSE-TREE: | | OmpLoopDirective -> llvm::omp::Directive = loop
+!PARSE-TREE: | | OmpClauseList -> OmpClause -> Bind -> OmpBindClause -> Type = Parallel
+!PARSE-TREE: | DoConstruct
+

@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2024

@llvm/pr-subscribers-flang-parser

Author: Krzysztof Parzyszek (kparzysz)

Changes

Currently the argument of the BIND clause is not printed. This is likely an omission in the original implementation.


Full diff: https://github.com/llvm/llvm-project/pull/117776.diff

2 Files Affected:

  • (modified) flang/lib/Parser/unparse.cpp (+1)
  • (added) flang/test/Parser/OpenMP/bind-clause.f90 (+25)
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index fe3f6ce7aa6291..e1708157b63dc2 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2834,6 +2834,7 @@ class UnparseVisitor {
   WALK_NESTED_ENUM(InquireSpec::LogVar, Kind)
   WALK_NESTED_ENUM(ProcedureStmt, Kind) // R1506
   WALK_NESTED_ENUM(UseStmt, ModuleNature) // R1410
+  WALK_NESTED_ENUM(OmpBindClause, Type) // OMP bind
   WALK_NESTED_ENUM(OmpProcBindClause, Type) // OMP PROC_BIND
   WALK_NESTED_ENUM(OmpDefaultClause, Type) // OMP DEFAULT
   WALK_NESTED_ENUM(OmpDefaultmapClause, ImplicitBehavior) // OMP DEFAULTMAP
diff --git a/flang/test/Parser/OpenMP/bind-clause.f90 b/flang/test/Parser/OpenMP/bind-clause.f90
new file mode 100644
index 00000000000000..332e5fe26ed8a8
--- /dev/null
+++ b/flang/test/Parser/OpenMP/bind-clause.f90
@@ -0,0 +1,25 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=50 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=50 %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+subroutine f00
+  !$omp loop bind(parallel)
+  do i = 1, 10
+    continue
+  enddo
+  !$omp end loop
+end
+
+!UNPARSE: SUBROUTINE f00
+!UNPARSE: !$OMP LOOP  BIND(PARALLEL)
+!UNPARSE:  DO i=1_4,10_4
+!UNPARSE:   CONTINUE
+!UNPARSE:  END DO
+!UNPARSE: !$OMP END LOOP
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
+!PARSE-TREE: | OmpBeginLoopDirective
+!PARSE-TREE: | | OmpLoopDirective -> llvm::omp::Directive = loop
+!PARSE-TREE: | | OmpClauseList -> OmpClause -> Bind -> OmpBindClause -> Type = Parallel
+!PARSE-TREE: | DoConstruct
+

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG.

@kparzysz kparzysz merged commit 2d90af5 into llvm:main Nov 26, 2024
12 checks passed
@kparzysz kparzysz deleted the users/kparzysz/spr/bind-unparse branch November 26, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:parser flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants