[flang][OpenMP] Parse GROUPPRIVATE directive by kparzysz · Pull Request #153807 · llvm/llvm-project (original) (raw)

Conversation

This file contains hidden or 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

[ Show hidden characters]({{ revealButtonHref }})

@kparzysz

No semantic checks or lowering yet.

@kparzysz

This is the common point for clang and flang implementations.

@kparzysz

No semantic checks or lowering yet.

@llvmbot

@llvm/pr-subscribers-flang-semantics
@llvm/pr-subscribers-flang-fir-hlfir

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

Changes

No semantic checks or lowering yet.


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

9 Files Affected:

diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h index 2c666a6d09a7b..8fbc6ccc639bf 100644 --- a/flang/include/flang/Parser/dump-parse-tree.h +++ b/flang/include/flang/Parser/dump-parse-tree.h @@ -729,6 +729,7 @@ class ParseTreeDumper { NODE(parser, OpenMPLoopConstruct) NODE(parser, OpenMPExecutableAllocate) NODE(parser, OpenMPAllocatorsConstruct)

+// ref: [6.0:301-303] +// +// groupprivate-directive -> +// GROUPPRIVATE (variable-list-item...) // since 6.0 +struct OpenMPGroupprivate {

};

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index fef64ccc15015..ec2ec37e623f8 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -3593,6 +3593,13 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable, } }

+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,

diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 46b14861096f1..41c16212f5771 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -1773,6 +1773,12 @@ TYPE_PARSER(sourced(construct( verbatim("DECLARE SIMD"_tok) || verbatim("DECLARE_SIMD"_tok), maybe(parenthesized(name)), Parser{})))

+TYPE_PARSER(sourced( //

@@ -1808,6 +1814,8 @@ TYPE_PARSER( Parser{}) || construct( Parser{}) ||

diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index 4f8d498972807..4294a6d491648 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2716,6 +2716,13 @@ class UnparseVisitor { void Unparse(const OpenMPDispatchConstruct &x) { // Unparse(static_cast<const OmpBlockConstruct &>(x)); }

@@ -1189,6 +1193,15 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar( } }

+void OmpStructureChecker::Enter(const parser::OpenMPGroupprivate &x) {

+} + +void OmpStructureChecker::Leave(const parser::OpenMPGroupprivate &x) {

diff --git a/flang/test/Lower/OpenMP/Todo/groupprivate.f90 b/flang/test/Lower/OpenMP/Todo/groupprivate.f90 new file mode 100644 index 0000000000000..9ad9b9382760c --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/groupprivate.f90 @@ -0,0 +1,9 @@ +!RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 -o - %s 2>&1 | FileCheck %s + +!CHECK: not yet implemented: GROUPPRIVATE + +module m +implicit none +integer :: x +!$omp groupprivate(x) +end module diff --git a/flang/test/Parser/OpenMP/groupprivate.f90 b/flang/test/Parser/OpenMP/groupprivate.f90 new file mode 100644 index 0000000000000..8bd840147a2dd --- /dev/null +++ b/flang/test/Parser/OpenMP/groupprivate.f90 @@ -0,0 +1,30 @@ +!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s +!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s + +module m +implicit none + +integer :: x, y(10), z +!$omp groupprivate(x, y) device_type(nohost) +!$omp groupprivate(z) + +end module + +!UNPARSE: MODULE m +!UNPARSE: IMPLICIT NONE +!UNPARSE: INTEGER x, y(10_4), z +!UNPARSE: !$OMP GROUPPRIVATE(x, y) DEVICE_TYPE(NOHOST) +!UNPARSE: !$OMP GROUPPRIVATE(z) +!UNPARSE: END MODULE + +!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPGroupprivate -> OmpDirectiveSpecification +!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = groupprivate +!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'y' +!PARSE-TREE: | OmpClauseList -> OmpClause -> DeviceType -> OmpDeviceTypeClause -> DeviceTypeDescription = Nohost +!PARSE-TREE: | Flags = None +!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPGroupprivate -> OmpDirectiveSpecification +!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = groupprivate +!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'z' +!PARSE-TREE: | OmpClauseList -> +!PARSE-TREE: | Flags = None

@llvmbot

@llvm/pr-subscribers-flang-parser

Author: Krzysztof Parzyszek (kparzysz)

Changes

No semantic checks or lowering yet.


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

9 Files Affected:

diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h index 2c666a6d09a7b..8fbc6ccc639bf 100644 --- a/flang/include/flang/Parser/dump-parse-tree.h +++ b/flang/include/flang/Parser/dump-parse-tree.h @@ -729,6 +729,7 @@ class ParseTreeDumper { NODE(parser, OpenMPLoopConstruct) NODE(parser, OpenMPExecutableAllocate) NODE(parser, OpenMPAllocatorsConstruct)

+// ref: [6.0:301-303] +// +// groupprivate-directive -> +// GROUPPRIVATE (variable-list-item...) // since 6.0 +struct OpenMPGroupprivate {

};

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index fef64ccc15015..ec2ec37e623f8 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -3593,6 +3593,13 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable, } }

+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,

diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 46b14861096f1..41c16212f5771 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -1773,6 +1773,12 @@ TYPE_PARSER(sourced(construct( verbatim("DECLARE SIMD"_tok) || verbatim("DECLARE_SIMD"_tok), maybe(parenthesized(name)), Parser{})))

+TYPE_PARSER(sourced( //

@@ -1808,6 +1814,8 @@ TYPE_PARSER( Parser{}) || construct( Parser{}) ||

diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index 4f8d498972807..4294a6d491648 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2716,6 +2716,13 @@ class UnparseVisitor { void Unparse(const OpenMPDispatchConstruct &x) { // Unparse(static_cast<const OmpBlockConstruct &>(x)); }

@@ -1189,6 +1193,15 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar( } }

+void OmpStructureChecker::Enter(const parser::OpenMPGroupprivate &x) {

+} + +void OmpStructureChecker::Leave(const parser::OpenMPGroupprivate &x) {

diff --git a/flang/test/Lower/OpenMP/Todo/groupprivate.f90 b/flang/test/Lower/OpenMP/Todo/groupprivate.f90 new file mode 100644 index 0000000000000..9ad9b9382760c --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/groupprivate.f90 @@ -0,0 +1,9 @@ +!RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 -o - %s 2>&1 | FileCheck %s + +!CHECK: not yet implemented: GROUPPRIVATE + +module m +implicit none +integer :: x +!$omp groupprivate(x) +end module diff --git a/flang/test/Parser/OpenMP/groupprivate.f90 b/flang/test/Parser/OpenMP/groupprivate.f90 new file mode 100644 index 0000000000000..8bd840147a2dd --- /dev/null +++ b/flang/test/Parser/OpenMP/groupprivate.f90 @@ -0,0 +1,30 @@ +!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s +!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s + +module m +implicit none + +integer :: x, y(10), z +!$omp groupprivate(x, y) device_type(nohost) +!$omp groupprivate(z) + +end module + +!UNPARSE: MODULE m +!UNPARSE: IMPLICIT NONE +!UNPARSE: INTEGER x, y(10_4), z +!UNPARSE: !$OMP GROUPPRIVATE(x, y) DEVICE_TYPE(NOHOST) +!UNPARSE: !$OMP GROUPPRIVATE(z) +!UNPARSE: END MODULE + +!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPGroupprivate -> OmpDirectiveSpecification +!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = groupprivate +!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'y' +!PARSE-TREE: | OmpClauseList -> OmpClause -> DeviceType -> OmpDeviceTypeClause -> DeviceTypeDescription = Nohost +!PARSE-TREE: | Flags = None +!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPGroupprivate -> OmpDirectiveSpecification +!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = groupprivate +!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'z' +!PARSE-TREE: | OmpClauseList -> +!PARSE-TREE: | Flags = None

@kparzysz

@kparzysz

tblah

Choose a reason for hiding this comment

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

Thanks

Base automatically changed from users/kparzysz/g01-groupprivate-def to main

August 19, 2025 13:27

@kparzysz kparzysz deleted the users/kparzysz/g02-groupprivate-parse branch

August 19, 2025 13:32

Labels