Skip to content

Commit 7718186

Browse files
committed
[flang][OpenMP] Replace modifiers in DYN_GROUPPRIVATE clause
The "prescriptiveness" modifier has been replaced with "fallback-modifier".
1 parent 24c22b7 commit 7718186

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ class ParseTreeDumper {
586586
NODE(parser, OmpExpectation)
587587
NODE_ENUM(OmpExpectation, Value)
588588
NODE(parser, OmpFailClause)
589+
NODE(parser, OmpFallbackModifier)
590+
NODE_ENUM(OmpFallbackModifier, Value)
589591
NODE(parser, OmpFromClause)
590592
NODE(OmpFromClause, Modifier)
591593
NODE(parser, OmpGrainsizeClause)

flang/include/flang/Parser/parse-tree.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3992,6 +3992,17 @@ struct OmpExpectation {
39923992
WRAPPER_CLASS_BOILERPLATE(OmpExpectation, Value);
39933993
};
39943994

3995+
// Ref: [6.1:tbd]
3996+
//
3997+
// fallback-modifier ->
3998+
// FALLBACK(fallback-mode) // since 6.1
3999+
// fallback-mode ->
4000+
// ABORT | DEFAULT_MEM | NULL // since 6.1
4001+
struct OmpFallbackModifier {
4002+
ENUM_CLASS(Value, Abort, Default_Mem, Null);
4003+
WRAPPER_CLASS_BOILERPLATE(OmpFallbackModifier, Value);
4004+
};
4005+
39954006
// REF: [5.1:217-220], [5.2:293-294]
39964007
//
39974008
// OmpInteropRuntimeIdentifier -> // since 5.2
@@ -4504,7 +4515,7 @@ struct OmpDynamicAllocatorsClause {
45044515

45054516
struct OmpDynGroupprivateClause {
45064517
TUPLE_CLASS_BOILERPLATE(OmpDynGroupprivateClause);
4507-
MODIFIER_BOILERPLATE(OmpAccessGroup, OmpPrescriptiveness);
4518+
MODIFIER_BOILERPLATE(OmpAccessGroup, OmpFallbackModifier);
45084519
std::tuple<MODIFIERS(), ScalarIntExpr> t;
45094520
};
45104521

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -797,21 +797,31 @@ DynGroupprivate make(const parser::OmpClause::DynGroupprivate &inp,
797797
semantics::SemanticsContext &semaCtx) {
798798
// imp.v -> OmpDyngroupprivateClause
799799
CLAUSET_ENUM_CONVERT( //
800-
convert, parser::OmpAccessGroup::Value, DynGroupprivate::AccessGroup,
800+
makeAccessGroup, parser::OmpAccessGroup::Value,
801+
DynGroupprivate::AccessGroup,
801802
// clang-format off
802803
MS(Cgroup, Cgroup)
803804
// clang-format on
804805
);
805806

807+
CLAUSET_ENUM_CONVERT( //
808+
makeFallback, parser::OmpFallbackModifier::Value,
809+
DynGroupprivate::Fallback,
810+
// clang-format off
811+
MS(Abort, Abort)
812+
MS(Default_Mem, Default_Mem)
813+
MS(Null, Null)
814+
// clang-format on
815+
);
816+
806817
auto &mods = semantics::OmpGetModifiers(inp.v);
807818
auto *m0 = semantics::OmpGetUniqueModifier<parser::OmpAccessGroup>(mods);
808-
auto *m1 = semantics::OmpGetUniqueModifier<parser::OmpPrescriptiveness>(mods);
819+
auto *m1 = semantics::OmpGetUniqueModifier<parser::OmpFallbackModifier>(mods);
809820
auto &size = std::get<parser::ScalarIntExpr>(inp.v.t);
810821

811-
return DynGroupprivate{
812-
{/*AccessGroup=*/maybeApplyToV(convert, m0),
813-
/*Prescriptiveness=*/maybeApplyToV(makePrescriptiveness, m1),
814-
/*Size=*/makeExpr(size, semaCtx)}};
822+
return DynGroupprivate{{/*AccessGroup=*/maybeApplyToV(makeAccessGroup, m0),
823+
/*Prescriptiveness=*/maybeApplyToV(makeFallback, m1),
824+
/*Size=*/makeExpr(size, semaCtx)}};
815825
}
816826

817827
Enter make(const parser::OmpClause::Enter &inp,

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ TYPE_PARSER(construct<OmpDirectiveNameModifier>(OmpDirectiveNameParser{}))
791791
TYPE_PARSER(construct<OmpExpectation>( //
792792
"PRESENT" >> pure(OmpExpectation::Value::Present)))
793793

794+
TYPE_PARSER(construct<OmpFallbackModifier>("FALLBACK"_tok >>
795+
parenthesized( //
796+
"ABORT" >> pure(OmpFallbackModifier::Value::Abort) ||
797+
"DEFAULT_MEM" >> pure(OmpFallbackModifier::Value::Default_Mem) ||
798+
"NULL" >> pure(OmpFallbackModifier::Value::Null))))
799+
794800
TYPE_PARSER(construct<OmpInteropRuntimeIdentifier>(
795801
construct<OmpInteropRuntimeIdentifier>(charLiteralConstant) ||
796802
construct<OmpInteropRuntimeIdentifier>(scalarIntConstantExpr)))
@@ -925,7 +931,7 @@ TYPE_PARSER( //
925931
sourced(construct<OmpDynGroupprivateClause::Modifier>(
926932
Parser<OmpAccessGroup>{})) ||
927933
sourced(construct<OmpDynGroupprivateClause::Modifier>(
928-
Parser<OmpPrescriptiveness>{})))
934+
Parser<OmpFallbackModifier>{})))
929935

930936
TYPE_PARSER(
931937
sourced(construct<OmpDeviceClause::Modifier>(Parser<OmpDeviceModifier>{})))

flang/lib/Parser/unparse.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,11 @@ class UnparseVisitor {
22812281
Walk(std::get<OmpObjectList>(x.t));
22822282
Walk(": ", std::get<std::optional<std::list<Modifier>>>(x.t));
22832283
}
2284+
void Unparse(const OmpFallbackModifier &x) {
2285+
Word("FALLBACK(");
2286+
Walk(x.v);
2287+
Put(")");
2288+
}
22842289
void Unparse(const OmpDynGroupprivateClause &x) {
22852290
using Modifier = OmpDynGroupprivateClause::Modifier;
22862291
Walk(std::get<std::optional<std::list<Modifier>>>(x.t), ": ");
@@ -2790,6 +2795,7 @@ class UnparseVisitor {
27902795
OmpDeviceTypeClause, DeviceTypeDescription) // OMP device_type
27912796
WALK_NESTED_ENUM(OmpReductionModifier, Value) // OMP reduction-modifier
27922797
WALK_NESTED_ENUM(OmpExpectation, Value) // OMP motion-expectation
2798+
WALK_NESTED_ENUM(OmpFallbackModifier, Value) // OMP fallback-modifier
27932799
WALK_NESTED_ENUM(OmpInteropType, Value) // OMP InteropType
27942800
WALK_NESTED_ENUM(OmpOrderClause, Ordering) // OMP ordering
27952801
WALK_NESTED_ENUM(OmpOrderModifier, Value) // OMP order-modifier

flang/test/Parser/OpenMP/dyn-groupprivate-clause.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ subroutine f00(n)
2626
subroutine f01(n)
2727
implicit none
2828
integer :: n
29-
!$omp target dyn_groupprivate(strict: n)
29+
!$omp target dyn_groupprivate(fallback(abort): n)
3030
!$omp end target
3131
end
3232

3333
!UNPARSE: SUBROUTINE f01 (n)
3434
!UNPARSE: IMPLICIT NONE
3535
!UNPARSE: INTEGER n
36-
!UNPARSE: !$OMP TARGET DYN_GROUPPRIVATE(STRICT: n)
36+
!UNPARSE: !$OMP TARGET DYN_GROUPPRIVATE(FALLBACK(ABORT): n)
3737
!UNPARSE: !$OMP END TARGET
3838
!UNPARSE: END SUBROUTINE
3939

4040
!PARSE-TREE: OmpBeginDirective
4141
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
4242
!PARSE-TREE: | OmpClauseList -> OmpClause -> DynGroupprivate -> OmpDynGroupprivateClause
43-
!PARSE-TREE: | | Modifier -> OmpPrescriptiveness -> Value = Strict
43+
!PARSE-TREE: | | Modifier -> OmpFallbackModifier -> Value = Abort
4444
!PARSE-TREE: | | Scalar -> Integer -> Expr = 'n'
4545
!PARSE-TREE: | | | Designator -> DataRef -> Name = 'n'
4646
!PARSE-TREE: | Flags = None
@@ -49,21 +49,21 @@ subroutine f01(n)
4949
subroutine f02(n)
5050
implicit none
5151
integer :: n
52-
!$omp target dyn_groupprivate(fallback, cgroup: n)
52+
!$omp target dyn_groupprivate(fallback(default_mem), cgroup: n)
5353
!$omp end target
5454
end
5555

5656
!UNPARSE: SUBROUTINE f02 (n)
5757
!UNPARSE: IMPLICIT NONE
5858
!UNPARSE: INTEGER n
59-
!UNPARSE: !$OMP TARGET DYN_GROUPPRIVATE(FALLBACK, CGROUP: n)
59+
!UNPARSE: !$OMP TARGET DYN_GROUPPRIVATE(FALLBACK(DEFAULT_MEM), CGROUP: n)
6060
!UNPARSE: !$OMP END TARGET
6161
!UNPARSE: END SUBROUTINE
6262

6363
!PARSE-TREE: OmpBeginDirective
6464
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
6565
!PARSE-TREE: | OmpClauseList -> OmpClause -> DynGroupprivate -> OmpDynGroupprivateClause
66-
!PARSE-TREE: | | Modifier -> OmpPrescriptiveness -> Value = Fallback
66+
!PARSE-TREE: | | Modifier -> OmpFallbackModifier -> Value = Default_Mem
6767
!PARSE-TREE: | | Modifier -> OmpAccessGroup -> Value = Cgroup
6868
!PARSE-TREE: | | Scalar -> Integer -> Expr = 'n'
6969
!PARSE-TREE: | | | Designator -> DataRef -> Name = 'n'

llvm/include/llvm/Frontend/OpenMP/ClauseT.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,10 @@ struct DynamicAllocatorsT {
587587
template <typename T, typename I, typename E> //
588588
struct DynGroupprivateT {
589589
ENUM(AccessGroup, Cgroup);
590-
using Prescriptiveness = type::Prescriptiveness;
590+
ENUM(Fallback, Abort, Default_Mem, Null);
591591
using Size = E;
592592
using TupleTrait = std::true_type;
593-
std::tuple<OPT(AccessGroup), OPT(Prescriptiveness), Size> t;
593+
std::tuple<OPT(AccessGroup), OPT(Fallback), Size> t;
594594
};
595595

596596
// V5.2: [5.8.4] `enter` clause

0 commit comments

Comments
 (0)