Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,8 @@ std::string OpenMPCounterVisitor::getName(const OmpWrapperType &w) {
return getName(*std::get<const OpenMPDeclarativeConstruct *>(w));
}
std::string OpenMPCounterVisitor::getName(const OpenMPDeclarativeConstruct &c) {
return std::visit( //
Fortran::common::visitors{
[&](const OpenMPUtilityConstruct &o) -> std::string {
const CharBlock &source{o.source};
return normalize_construct_name(source.ToString());
},
[&](const OmpMetadirectiveDirective &o) -> std::string {
const CharBlock &source{o.source};
return normalize_construct_name(source.ToString());
},
[&](const auto &o) -> std::string {
const CharBlock &source{std::get<Verbatim>(o.t).source};
return normalize_construct_name(source.ToString());
},
},
c.u);
return normalize_construct_name(
omp::GetOmpDirectiveName(c).source.ToString());
}
std::string OpenMPCounterVisitor::getName(const OpenMPConstruct &c) {
return normalize_construct_name(
Expand Down
1 change: 1 addition & 0 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ class ParseTreeDumper {
NODE(parser, OpenMPLoopConstruct)
NODE(parser, OpenMPExecutableAllocate)
NODE(parser, OpenMPAllocatorsConstruct)
NODE(parser, OpenMPGroupprivate)
NODE(parser, OpenMPRequiresConstruct)
NODE(parser, OpenMPSimpleStandaloneConstruct)
NODE(parser, OpenMPStandaloneConstruct)
Expand Down
3 changes: 2 additions & 1 deletion flang/include/flang/Parser/openmp-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ struct DirectiveNameScope {
std::is_same_v<T, OpenMPDepobjConstruct> ||
std::is_same_v<T, OpenMPFlushConstruct> ||
std::is_same_v<T, OpenMPInteropConstruct> ||
std::is_same_v<T, OpenMPSimpleStandaloneConstruct>) {
std::is_same_v<T, OpenMPSimpleStandaloneConstruct> ||
std::is_same_v<T, OpenMPGroupprivate>) {
return x.v.DirName();
} else {
return GetOmpDirectiveName(x.v);
Expand Down
14 changes: 12 additions & 2 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4943,6 +4943,15 @@ struct OpenMPDeclareSimdConstruct {
std::tuple<Verbatim, std::optional<Name>, OmpClauseList> t;
};

// ref: [6.0:301-303]
//
// groupprivate-directive ->
// GROUPPRIVATE (variable-list-item...) // since 6.0
struct OpenMPGroupprivate {
WRAPPER_CLASS_BOILERPLATE(OpenMPGroupprivate, OmpDirectiveSpecification);
CharBlock source;
};

// 2.4 requires -> REQUIRES requires-clause[ [ [,] requires-clause]...]
struct OpenMPRequiresConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPRequiresConstruct);
Expand Down Expand Up @@ -4970,8 +4979,9 @@ struct OpenMPDeclarativeConstruct {
std::variant<OpenMPDeclarativeAllocate, OpenMPDeclarativeAssumes,
OpenMPDeclareMapperConstruct, OpenMPDeclareReductionConstruct,
OpenMPDeclareSimdConstruct, OpenMPDeclareTargetConstruct,
OmpDeclareVariantDirective, OpenMPThreadprivate, OpenMPRequiresConstruct,
OpenMPUtilityConstruct, OmpMetadirectiveDirective>
OmpDeclareVariantDirective, OpenMPGroupprivate, OpenMPThreadprivate,
OpenMPRequiresConstruct, OpenMPUtilityConstruct,
OmpMetadirectiveDirective>
u;
};

Expand Down
7 changes: 7 additions & 0 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3593,6 +3593,13 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
}
}

static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx,
lower::pft::Evaluation &eval,
const parser::OpenMPGroupprivate &directive) {
TODO(converter.getCurrentLocation(), "GROUPPRIVATE");
}

static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx,
lower::pft::Evaluation &eval,
Expand Down
8 changes: 8 additions & 0 deletions flang/lib/Parser/openmp-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,12 @@ TYPE_PARSER(sourced(construct<OpenMPDeclareSimdConstruct>(
verbatim("DECLARE SIMD"_tok) || verbatim("DECLARE_SIMD"_tok),
maybe(parenthesized(name)), Parser<OmpClauseList>{})))

TYPE_PARSER(sourced( //
construct<OpenMPGroupprivate>(
predicated(OmpDirectiveNameParser{},
IsDirective(llvm::omp::Directive::OMPD_groupprivate)) >=
Parser<OmpDirectiveSpecification>{})))

// 2.4 Requires construct
TYPE_PARSER(sourced(construct<OpenMPRequiresConstruct>(
verbatim("REQUIRES"_tok), Parser<OmpClauseList>{})))
Expand Down Expand Up @@ -1808,6 +1814,8 @@ TYPE_PARSER(
Parser<OmpDeclareVariantDirective>{}) ||
construct<OpenMPDeclarativeConstruct>(
Parser<OpenMPDeclarativeAllocate>{}) ||
construct<OpenMPDeclarativeConstruct>(
Parser<OpenMPGroupprivate>{}) ||
construct<OpenMPDeclarativeConstruct>(
Parser<OpenMPRequiresConstruct>{}) ||
construct<OpenMPDeclarativeConstruct>(
Expand Down
7 changes: 7 additions & 0 deletions flang/lib/Parser/unparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,13 @@ class UnparseVisitor {
void Unparse(const OpenMPDispatchConstruct &x) { //
Unparse(static_cast<const OmpBlockConstruct &>(x));
}
void Unparse(const OpenMPGroupprivate &x) {
BeginOpenMP();
Word("!$OMP ");
Walk(x.v);
Put("\n");
EndOpenMP();
}
void Unparse(const OpenMPRequiresConstruct &y) {
BeginOpenMP();
Word("!$OMP REQUIRES ");
Expand Down
13 changes: 13 additions & 0 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ template <typename Checker> struct DirectiveSpellingVisitor {
Directive::OMPD_declare_variant);
return false;
}
bool Pre(const parser::OpenMPGroupprivate &x) {
checker_(x.v.DirName().source, Directive::OMPD_groupprivate);
return false;
}
bool Pre(const parser::OpenMPThreadprivate &x) {
checker_(
std::get<parser::Verbatim>(x.t).source, Directive::OMPD_threadprivate);
Expand Down Expand Up @@ -1189,6 +1193,15 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
}
}

void OmpStructureChecker::Enter(const parser::OpenMPGroupprivate &x) {
PushContextAndClauseSets(
x.v.DirName().source, llvm::omp::Directive::OMPD_groupprivate);
}

void OmpStructureChecker::Leave(const parser::OpenMPGroupprivate &x) {
dirContext_.pop_back();
}

void OmpStructureChecker::Enter(const parser::OpenMPThreadprivate &c) {
const auto &dir{std::get<parser::Verbatim>(c.t)};
PushContextAndClauseSets(
Expand Down
2 changes: 2 additions & 0 deletions flang/lib/Semantics/check-omp-structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class OmpStructureChecker
void Leave(const parser::OpenMPAllocatorsConstruct &);
void Enter(const parser::OpenMPRequiresConstruct &);
void Leave(const parser::OpenMPRequiresConstruct &);
void Enter(const parser::OpenMPGroupprivate &);
void Leave(const parser::OpenMPGroupprivate &);
void Enter(const parser::OpenMPThreadprivate &);
void Leave(const parser::OpenMPThreadprivate &);

Expand Down
9 changes: 9 additions & 0 deletions flang/test/Lower/OpenMP/Todo/groupprivate.f90
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions flang/test/Parser/OpenMP/groupprivate.f90
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions llvm/include/llvm/Frontend/OpenMP/OMP.td
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,14 @@ def OMP_For : Directive<[Spelling<"for">]> {
let category = CA_Executable;
let languages = [L_C];
}
def OMP_Groupprivate : Directive<[Spelling<"groupprivate">]> {
let allowedOnceClauses = [
VersionedClause<OMPC_DeviceType>,
];
let association = AS_None;
let category = CA_Declarative;
let languages = [L_C, L_Fortran];
}
def OMP_Interchange : Directive<[Spelling<"interchange">]> {
let allowedOnceClauses = [
VersionedClause<OMPC_Permutation>,
Expand Down