Skip to content

Commit 5d062bf

Browse files
authored
[flang][OpenMP] Replace modifiers in DYN_GROUPPRIVATE clause (#166199)
The "prescriptiveness" modifier has been replaced with "fallback-modifier". The "fallback" value has been removed from the "prescriptiveness" modifier.
1 parent 68415e2 commit 5d062bf

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ class ParseTreeDumper {
588588
NODE(parser, OmpExpectation)
589589
NODE_ENUM(OmpExpectation, Value)
590590
NODE(parser, OmpFailClause)
591+
NODE(parser, OmpFallbackModifier)
592+
NODE_ENUM(OmpFallbackModifier, Value)
591593
NODE(parser, OmpFromClause)
592594
NODE(OmpFromClause, Modifier)
593595
NODE(parser, OmpGrainsizeClause)

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,6 +4000,17 @@ struct OmpExpectation {
40004000
WRAPPER_CLASS_BOILERPLATE(OmpExpectation, Value);
40014001
};
40024002

4003+
// Ref: [6.1:tbd]
4004+
//
4005+
// fallback-modifier ->
4006+
// FALLBACK(fallback-mode) // since 6.1
4007+
// fallback-mode ->
4008+
// ABORT | DEFAULT_MEM | NULL // since 6.1
4009+
struct OmpFallbackModifier {
4010+
ENUM_CLASS(Value, Abort, Default_Mem, Null);
4011+
WRAPPER_CLASS_BOILERPLATE(OmpFallbackModifier, Value);
4012+
};
4013+
40034014
// REF: [5.1:217-220], [5.2:293-294]
40044015
//
40054016
// OmpInteropRuntimeIdentifier -> // since 5.2
@@ -4129,9 +4140,8 @@ struct OmpOrderModifier {
41294140
//
41304141
// prescriptiveness ->
41314142
// STRICT // since 5.1
4132-
// FALLBACK // since 6.1
41334143
struct OmpPrescriptiveness {
4134-
ENUM_CLASS(Value, Strict, Fallback)
4144+
ENUM_CLASS(Value, Strict)
41354145
WRAPPER_CLASS_BOILERPLATE(OmpPrescriptiveness, Value);
41364146
};
41374147

@@ -4512,7 +4522,7 @@ struct OmpDynamicAllocatorsClause {
45124522

45134523
struct OmpDynGroupprivateClause {
45144524
TUPLE_CLASS_BOILERPLATE(OmpDynGroupprivateClause);
4515-
MODIFIER_BOILERPLATE(OmpAccessGroup, OmpPrescriptiveness);
4525+
MODIFIER_BOILERPLATE(OmpAccessGroup, OmpFallbackModifier);
45164526
std::tuple<MODIFIERS(), ScalarIntExpr> t;
45174527
};
45184528

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,6 @@ makePrescriptiveness(parser::OmpPrescriptiveness::Value v) {
396396
switch (v) {
397397
case parser::OmpPrescriptiveness::Value::Strict:
398398
return clause::Prescriptiveness::Strict;
399-
case parser::OmpPrescriptiveness::Value::Fallback:
400-
return clause::Prescriptiveness::Fallback;
401399
}
402400
llvm_unreachable("Unexpected prescriptiveness");
403401
}
@@ -799,21 +797,31 @@ DynGroupprivate make(const parser::OmpClause::DynGroupprivate &inp,
799797
semantics::SemanticsContext &semaCtx) {
800798
// imp.v -> OmpDyngroupprivateClause
801799
CLAUSET_ENUM_CONVERT( //
802-
convert, parser::OmpAccessGroup::Value, DynGroupprivate::AccessGroup,
800+
makeAccessGroup, parser::OmpAccessGroup::Value,
801+
DynGroupprivate::AccessGroup,
803802
// clang-format off
804803
MS(Cgroup, Cgroup)
805804
// clang-format on
806805
);
807806

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+
808817
auto &mods = semantics::OmpGetModifiers(inp.v);
809818
auto *m0 = semantics::OmpGetUniqueModifier<parser::OmpAccessGroup>(mods);
810-
auto *m1 = semantics::OmpGetUniqueModifier<parser::OmpPrescriptiveness>(mods);
819+
auto *m1 = semantics::OmpGetUniqueModifier<parser::OmpFallbackModifier>(mods);
811820
auto &size = std::get<parser::ScalarIntExpr>(inp.v.t);
812821

813-
return DynGroupprivate{
814-
{/*AccessGroup=*/maybeApplyToV(convert, m0),
815-
/*Prescriptiveness=*/maybeApplyToV(makePrescriptiveness, m1),
816-
/*Size=*/makeExpr(size, semaCtx)}};
822+
return DynGroupprivate{{/*AccessGroup=*/maybeApplyToV(makeAccessGroup, m0),
823+
/*Fallback=*/maybeApplyToV(makeFallback, m1),
824+
/*Size=*/makeExpr(size, semaCtx)}};
817825
}
818826

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

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 8 additions & 3 deletions
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)))
@@ -857,8 +863,7 @@ TYPE_PARSER(construct<OmpOrderingModifier>(
857863
"SIMD" >> pure(OmpOrderingModifier::Value::Simd)))
858864

859865
TYPE_PARSER(construct<OmpPrescriptiveness>(
860-
"STRICT" >> pure(OmpPrescriptiveness::Value::Strict) ||
861-
"FALLBACK" >> pure(OmpPrescriptiveness::Value::Fallback)))
866+
"STRICT" >> pure(OmpPrescriptiveness::Value::Strict)))
862867

863868
TYPE_PARSER(construct<OmpPresentModifier>( //
864869
"PRESENT" >> pure(OmpPresentModifier::Value::Present)))
@@ -925,7 +930,7 @@ TYPE_PARSER( //
925930
sourced(construct<OmpDynGroupprivateClause::Modifier>(
926931
Parser<OmpAccessGroup>{})) ||
927932
sourced(construct<OmpDynGroupprivateClause::Modifier>(
928-
Parser<OmpPrescriptiveness>{})))
933+
Parser<OmpFallbackModifier>{})))
929934

930935
TYPE_PARSER(
931936
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
@@ -2286,6 +2286,11 @@ class UnparseVisitor {
22862286
Walk(std::get<OmpObjectList>(x.t));
22872287
Walk(": ", std::get<std::optional<std::list<Modifier>>>(x.t));
22882288
}
2289+
void Unparse(const OmpFallbackModifier &x) {
2290+
Word("FALLBACK(");
2291+
Walk(x.v);
2292+
Put(")");
2293+
}
22892294
void Unparse(const OmpDynGroupprivateClause &x) {
22902295
using Modifier = OmpDynGroupprivateClause::Modifier;
22912296
Walk(std::get<std::optional<std::list<Modifier>>>(x.t), ": ");
@@ -2795,6 +2800,7 @@ class UnparseVisitor {
27952800
OmpDeviceTypeClause, DeviceTypeDescription) // OMP device_type
27962801
WALK_NESTED_ENUM(OmpReductionModifier, Value) // OMP reduction-modifier
27972802
WALK_NESTED_ENUM(OmpExpectation, Value) // OMP motion-expectation
2803+
WALK_NESTED_ENUM(OmpFallbackModifier, Value) // OMP fallback-modifier
27982804
WALK_NESTED_ENUM(OmpInteropType, Value) // OMP InteropType
27992805
WALK_NESTED_ENUM(OmpOrderClause, Ordering) // OMP ordering
28002806
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ ENUM(MotionExpectation, Present);
241241
// V5.2: [15.9.1] `task-dependence-type` modifier
242242
ENUM(DependenceType, Depobj, In, Inout, Inoutset, Mutexinoutset, Out, Sink,
243243
Source);
244-
ENUM(Prescriptiveness, Strict, Fallback);
244+
ENUM(Prescriptiveness, Strict);
245245

246246
template <typename I, typename E> //
247247
struct LoopIterationT {
@@ -591,10 +591,10 @@ struct DynamicAllocatorsT {
591591
template <typename T, typename I, typename E> //
592592
struct DynGroupprivateT {
593593
ENUM(AccessGroup, Cgroup);
594-
using Prescriptiveness = type::Prescriptiveness;
594+
ENUM(Fallback, Abort, Default_Mem, Null);
595595
using Size = E;
596596
using TupleTrait = std::true_type;
597-
std::tuple<OPT(AccessGroup), OPT(Prescriptiveness), Size> t;
597+
std::tuple<OPT(AccessGroup), OPT(Fallback), Size> t;
598598
};
599599

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

0 commit comments

Comments
 (0)