Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][Parser] Add a node for individual sections in sections construct
This patch adds parser nodes for each indivudual section in sections construct. This should help with the translation to FIR. `!$omp section` was not recognized as a construct and hence needed special handling. `OpenMPSectionsConstruct` contains a list of `OpenMPConstruct`. Each such `OpenMPConstruct` wraps an `OpenMPSectionConstruct` (section, not sections). An `OpenMPSectionConstruct` is a wrapper around a `Block`. Reviewed By: kiranchandramohan, peixin Differential Revision: https://reviews.llvm.org/D121680
- Loading branch information
Showing
10 changed files
with
278 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
! REQUIRES: plugins, examples, shell | ||
|
||
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp %s -o - | FileCheck %s | ||
|
||
subroutine omp_sections() | ||
integer :: x | ||
!$omp sections private(x) | ||
!$omp section | ||
call f1() | ||
!$omp section | ||
call f2() | ||
!$omp end sections nowait | ||
end subroutine omp_sections | ||
|
||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 9 | ||
!CHECK: construct: section | ||
!CHECK: clauses: [] | ||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 11 | ||
!CHECK: construct: section | ||
!CHECK: clauses: [] | ||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 7 | ||
!CHECK: construct: sections | ||
!CHECK: clauses: | ||
!CHECK: - clause: nowait | ||
!CHECK: details: '' | ||
!CHECK: - clause: private | ||
!CHECK: details: x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
! RUN: %flang_fc1 -fdebug-pre-fir-tree -fopenmp %s | FileCheck %s | ||
|
||
subroutine openmp_sections(x, y) | ||
|
||
integer, intent(inout)::x, y | ||
|
||
!============================================================================== | ||
! empty construct | ||
!============================================================================== | ||
!$omp sections | ||
!$omp end sections | ||
|
||
!CHECK: OpenMPConstruct | ||
!CHECK: End OpenMPConstruct | ||
|
||
!============================================================================== | ||
! single section, without `!$omp section` | ||
!============================================================================== | ||
!$omp sections | ||
call F1() | ||
!$omp end sections | ||
|
||
!CHECK: OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: End OpenMPConstruct | ||
|
||
!============================================================================== | ||
! single section with `!$omp section` | ||
!============================================================================== | ||
!$omp sections | ||
!$omp section | ||
call F1 | ||
!$omp end sections | ||
|
||
!CHECK: OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: End OpenMPConstruct | ||
|
||
!============================================================================== | ||
! multiple sections | ||
!============================================================================== | ||
!$omp sections | ||
!$omp section | ||
call F1 | ||
!$omp section | ||
call F2 | ||
!$omp section | ||
call F3 | ||
!$omp end sections | ||
|
||
!CHECK: OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: End OpenMPConstruct | ||
|
||
!============================================================================== | ||
! multiple sections with clauses | ||
!============================================================================== | ||
!$omp sections PRIVATE(x) FIRSTPRIVATE(y) | ||
!$omp section | ||
call F1 | ||
!$omp section | ||
call F2 | ||
!$omp section | ||
call F3 | ||
!$omp end sections NOWAIT | ||
|
||
!CHECK: OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: OpenMPConstruct | ||
!CHECK: CallStmt | ||
!CHECK: End OpenMPConstruct | ||
!CHECK: End OpenMPConstruct | ||
|
||
end subroutine openmp_sections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s | ||
! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s | ||
|
||
subroutine openmp_sections(x, y) | ||
|
||
integer, intent(inout)::x, y | ||
|
||
!============================================================================== | ||
! empty construct | ||
!============================================================================== | ||
!CHECK: !$omp sections | ||
!$omp sections | ||
!CHECK: !$omp section | ||
!CHECK: !$omp end sections | ||
!$omp end sections | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct | ||
!PARSE-TREE: OmpBeginSectionsDirective | ||
!PARSE-TREE-NOT: ExecutionPartConstruct | ||
!PARSE-TREE: OmpEndSectionsDirective | ||
|
||
!============================================================================== | ||
! single section, without `!$omp section` | ||
!============================================================================== | ||
!CHECK: !$omp sections | ||
!$omp sections | ||
!CHECK: !$omp section | ||
!CHECK: CALL | ||
call F1() | ||
!CHECK: !$omp end sections | ||
!$omp end sections | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct | ||
!PARSE-TREE: OmpBeginSectionsDirective | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE-NOT: ExecutionPartConstruct | ||
!PARSE-TREE: OmpEndSectionsDirective | ||
|
||
!============================================================================== | ||
! single section with `!$omp section` | ||
!============================================================================== | ||
!CHECK: !$omp sections | ||
!$omp sections | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F1 | ||
call F1 | ||
!CHECK: !$omp end sections | ||
!$omp end sections | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct | ||
!PARSE-TREE: OmpBeginSectionsDirective | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE-NOT: ExecutionPartConstruct | ||
!PARSE-TREE: OmpEndSectionsDirective | ||
|
||
!============================================================================== | ||
! multiple sections | ||
!============================================================================== | ||
!CHECK: !$omp sections | ||
!$omp sections | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F1 | ||
call F1 | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F2 | ||
call F2 | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F3 | ||
call F3 | ||
!CHECK: !$omp end sections | ||
!$omp end sections | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct | ||
!PARSE-TREE: OmpBeginSectionsDirective | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE-NOT: ExecutionPartConstruct | ||
!PARSE-TREE: OmpEndSectionsDirective | ||
|
||
!============================================================================== | ||
! multiple sections with clauses | ||
!============================================================================== | ||
!CHECK: !$omp sections PRIVATE(x) FIRSTPRIVATE(y) | ||
!$omp sections PRIVATE(x) FIRSTPRIVATE(y) | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F1 | ||
call F1 | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F2 | ||
call F2 | ||
!CHECK: !$omp section | ||
!$omp section | ||
!CHECK: CALL F3 | ||
call F3 | ||
!CHECK: !$omp end sections NOWAIT | ||
!$omp end sections NOWAIT | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct | ||
!PARSE-TREE: OmpBeginSectionsDirective | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE: OpenMPConstruct -> OpenMPSectionConstruct -> Block | ||
!PARSE-TREE: CallStmt | ||
!PARSE-TREE-NOT: ExecutionPartConstruct | ||
!PARSE-TREE: OmpEndSectionsDirective | ||
|
||
END subroutine openmp_sections |