Skip to content

Commit 2aa1e54

Browse files
authored
[flang][OpenMP] Parse OpenMP 6.0 map modifiers (#149134)
OpenMP 6.0 has changed the modifiers on the MAP clause: - map-type-modifier has been split into individual modifiers, - map-type "delete" has become a modifier, - new modifiers have been added. This patch adds parsing support for all of the OpenMP 6.0 modifiers. The old "map-type-modifier" is retained, but is no longer created in parsing. It will remain to take advantage of the preexisting modifier validation for older versions: when the OpenMP version is < 6.0, the modifiers will be rewritten back as map-type-modifiers (or map- type in case of "delete"). In this patch the modifiers will always be rewritten in the older format to isolate these changes to parsing as much as possible.
1 parent c33c978 commit 2aa1e54

File tree

10 files changed

+458
-34
lines changed

10 files changed

+458
-34
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ class ParseTreeDumper {
529529
NODE(parser, OmpAlignClause)
530530
NODE(parser, OmpAlignedClause)
531531
NODE(OmpAlignedClause, Modifier)
532+
NODE(parser, OmpAlwaysModifier)
533+
NODE_ENUM(OmpAlwaysModifier, Value)
532534
NODE(parser, OmpAtClause)
533535
NODE_ENUM(OmpAtClause, ActionTime)
534536
NODE_ENUM(OmpSeverityClause, Severity)
@@ -546,6 +548,8 @@ class ParseTreeDumper {
546548
#include "llvm/Frontend/OpenMP/OMP.inc"
547549
NODE(parser, OmpClauseList)
548550
NODE(parser, OmpCancellationConstructTypeClause)
551+
NODE(parser, OmpCloseModifier)
552+
NODE_ENUM(OmpCloseModifier, Value)
549553
NODE(parser, OmpContainsClause)
550554
NODE(parser, OmpCriticalDirective)
551555
NODE(parser, OmpErrorDirective)
@@ -561,6 +565,8 @@ class ParseTreeDumper {
561565
NODE(parser, OmpDefaultmapClause)
562566
NODE_ENUM(OmpDefaultmapClause, ImplicitBehavior)
563567
NODE(OmpDefaultmapClause, Modifier)
568+
NODE(parser, OmpDeleteModifier)
569+
NODE_ENUM(OmpDeleteModifier, Value)
564570
NODE(parser, OmpDependenceType)
565571
NODE_ENUM(OmpDependenceType, Value)
566572
NODE(parser, OmpTaskDependenceType)
@@ -628,6 +634,8 @@ class ParseTreeDumper {
628634
NODE(OmpNumTasksClause, Modifier)
629635
NODE(parser, OmpBindClause)
630636
NODE_ENUM(OmpBindClause, Binding)
637+
NODE(parser, OmpPresentModifier)
638+
NODE_ENUM(OmpPresentModifier, Value)
631639
NODE(parser, OmpProcBindClause)
632640
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
633641
NODE(parser, OmpReductionModifier)
@@ -637,6 +645,10 @@ class ParseTreeDumper {
637645
NODE(parser, OmpInReductionClause)
638646
NODE(OmpInReductionClause, Modifier)
639647
NODE(parser, OmpReductionCombiner)
648+
NODE(parser, OmpRefModifier)
649+
NODE_ENUM(OmpRefModifier, Value)
650+
NODE(parser, OmpSelfModifier)
651+
NODE_ENUM(OmpSelfModifier, Value)
640652
NODE(parser, OmpTaskReductionClause)
641653
NODE(OmpTaskReductionClause, Modifier)
642654
NODE(parser, OmpInitializerProc)
@@ -673,6 +685,8 @@ class ParseTreeDumper {
673685
NODE(parser, OmpSectionsDirective)
674686
NODE(parser, OmpToClause)
675687
NODE(OmpToClause, Modifier)
688+
NODE(parser, OmpxHoldModifier)
689+
NODE_ENUM(OmpxHoldModifier, Value)
676690
NODE(parser, Only)
677691
NODE(parser, OpenACCAtomicConstruct)
678692
NODE(parser, OpenACCBlockConstruct)

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

Lines changed: 121 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,19 @@ struct OmpAllocatorComplexModifier {
37563756
WRAPPER_CLASS_BOILERPLATE(OmpAllocatorComplexModifier, ScalarIntExpr);
37573757
};
37583758

3759+
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3760+
// [6.0:279-288]
3761+
//
3762+
// always-modifier ->
3763+
// ALWAYS // since 4.5
3764+
//
3765+
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3766+
// map-type-modifier has been split into individual modifiers.
3767+
struct OmpAlwaysModifier {
3768+
ENUM_CLASS(Value, Always)
3769+
WRAPPER_CLASS_BOILERPLATE(OmpAlwaysModifier, Value);
3770+
};
3771+
37593772
// Ref: [5.2:252-254]
37603773
//
37613774
// chunk-modifier ->
@@ -3767,17 +3780,29 @@ struct OmpChunkModifier {
37673780
WRAPPER_CLASS_BOILERPLATE(OmpChunkModifier, Value);
37683781
};
37693782

3770-
// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
3783+
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3784+
// [6.0:279-288]
37713785
//
3772-
// iterator-specifier ->
3773-
// [iterator-type] iterator-identifier
3774-
// = range-specification | // since 5.0
3775-
// [iterator-type ::] iterator-identifier
3776-
// = range-specification // since 5.2
3777-
struct OmpIteratorSpecifier {
3778-
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
3779-
CharBlock source;
3780-
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
3786+
// close-modifier ->
3787+
// CLOSE // since 5.0
3788+
//
3789+
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
3790+
// map-type-modifier has been split into individual modifiers.
3791+
struct OmpCloseModifier {
3792+
ENUM_CLASS(Value, Close)
3793+
WRAPPER_CLASS_BOILERPLATE(OmpCloseModifier, Value);
3794+
};
3795+
3796+
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3797+
// [6.0:279-288]
3798+
//
3799+
// delete-modifier ->
3800+
// DELETE // since 6.0
3801+
//
3802+
// Until 5.2, it was a part of map-type.
3803+
struct OmpDeleteModifier {
3804+
ENUM_CLASS(Value, Delete)
3805+
WRAPPER_CLASS_BOILERPLATE(OmpDeleteModifier, Value);
37813806
};
37823807

37833808
// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289]
@@ -3867,6 +3892,19 @@ struct OmpInteropType {
38673892
WRAPPER_CLASS_BOILERPLATE(OmpInteropType, Value);
38683893
};
38693894

3895+
// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
3896+
//
3897+
// iterator-specifier ->
3898+
// [iterator-type] iterator-identifier
3899+
// = range-specification | // since 5.0
3900+
// [iterator-type ::] iterator-identifier
3901+
// = range-specification // since 5.2
3902+
struct OmpIteratorSpecifier {
3903+
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
3904+
CharBlock source;
3905+
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
3906+
};
3907+
38703908
// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
38713909
//
38723910
// iterator-modifier ->
@@ -3901,21 +3939,28 @@ struct OmpMapper {
39013939
WRAPPER_CLASS_BOILERPLATE(OmpMapper, Name);
39023940
};
39033941

3904-
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
3942+
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
3943+
// [6.0:279-288]
39053944
//
39063945
// map-type ->
3907-
// ALLOC | DELETE | FROM | RELEASE | TO | TOFROM // since 4.5
3946+
// ALLOC | DELETE | RELEASE | // since 4.5, until 5.2
3947+
// FROM | TO | TOFROM | // since 4.5
3948+
// STORAGE // since 6.0
3949+
//
3950+
// Since 6.0 DELETE is a separate delete-modifier.
39083951
struct OmpMapType {
3909-
ENUM_CLASS(Value, Alloc, Delete, From, Release, To, Tofrom);
3952+
ENUM_CLASS(Value, Alloc, Delete, From, Release, Storage, To, Tofrom);
39103953
WRAPPER_CLASS_BOILERPLATE(OmpMapType, Value);
39113954
};
39123955

39133956
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
39143957
//
39153958
// map-type-modifier ->
3916-
// ALWAYS | // since 4.5
3917-
// CLOSE | // since 5.0
3918-
// PRESENT // since 5.1
3959+
// ALWAYS | // since 4.5, until 5.2
3960+
// CLOSE | // since 5.0, until 5.2
3961+
// PRESENT // since 5.1, until 5.2
3962+
// Since 6.0 the map-type-modifier has been split into individual modifiers.
3963+
//
39193964
struct OmpMapTypeModifier {
39203965
ENUM_CLASS(Value, Always, Close, Present, Ompx_Hold)
39213966
WRAPPER_CLASS_BOILERPLATE(OmpMapTypeModifier, Value);
@@ -3954,6 +3999,19 @@ struct OmpPrescriptiveness {
39543999
WRAPPER_CLASS_BOILERPLATE(OmpPrescriptiveness, Value);
39554000
};
39564001

4002+
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158],
4003+
// [6.0:279-288]
4004+
//
4005+
// present-modifier ->
4006+
// PRESENT // since 5.1
4007+
//
4008+
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4009+
// map-type-modifier has been split into individual modifiers.
4010+
struct OmpPresentModifier {
4011+
ENUM_CLASS(Value, Present)
4012+
WRAPPER_CLASS_BOILERPLATE(OmpPresentModifier, Value);
4013+
};
4014+
39574015
// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
39584016
//
39594017
// reduction-modifier ->
@@ -3963,6 +4021,26 @@ struct OmpReductionModifier {
39634021
WRAPPER_CLASS_BOILERPLATE(OmpReductionModifier, Value);
39644022
};
39654023

4024+
// Ref: [6.0:279-288]
4025+
//
4026+
// ref-modifier ->
4027+
// REF_PTEE | REF_PTR | REF_PTR_PTEE // since 6.0
4028+
//
4029+
struct OmpRefModifier {
4030+
ENUM_CLASS(Value, Ref_Ptee, Ref_Ptr, Ref_Ptr_Ptee)
4031+
WRAPPER_CLASS_BOILERPLATE(OmpRefModifier, Value);
4032+
};
4033+
4034+
// Ref: [6.0:279-288]
4035+
//
4036+
// self-modifier ->
4037+
// SELF // since 6.0
4038+
//
4039+
struct OmpSelfModifier {
4040+
ENUM_CLASS(Value, Self)
4041+
WRAPPER_CLASS_BOILERPLATE(OmpSelfModifier, Value);
4042+
};
4043+
39664044
// Ref: [5.2:117-120]
39674045
//
39684046
// step-complex-modifier ->
@@ -4001,6 +4079,19 @@ struct OmpVariableCategory {
40014079
WRAPPER_CLASS_BOILERPLATE(OmpVariableCategory, Value);
40024080
};
40034081

4082+
// Extension:
4083+
// https://openmp.llvm.org//openacc/OpenMPExtensions.html#ompx-hold
4084+
//
4085+
// ompx-hold-modifier ->
4086+
// OMPX_HOLD // since 4.5
4087+
//
4088+
// Until 5.2, it was a part of map-type-modifier. Since 6.0 the
4089+
// map-type-modifier has been split into individual modifiers.
4090+
struct OmpxHoldModifier {
4091+
ENUM_CLASS(Value, Ompx_Hold)
4092+
WRAPPER_CLASS_BOILERPLATE(OmpxHoldModifier, Value);
4093+
};
4094+
40044095
// context-selector
40054096
using OmpContextSelector = traits::OmpContextSelectorSpecification;
40064097
} // namespace modifier
@@ -4376,13 +4467,25 @@ struct OmpLinearClause {
43764467
// map-clause ->
43774468
// MAP([modifier...:] locator-list) // since 4.5
43784469
// modifier ->
4379-
// map-type-modifier | // since 4.5
4470+
// map-type-modifier [replaced] | // since 4.5, until 5.2
4471+
// always-modifier | // since 6.0
4472+
// close-modifier | // since 6.0
4473+
// delete-modifier | // since 6.0
4474+
// present-modifier | // since 6.0
4475+
// ref-modifier | // since 6.0
4476+
// self-modifier | // since 6.0
43804477
// mapper | // since 5.0
43814478
// iterator | // since 5.1
43824479
// map-type // since 4.5
4480+
// ompx-hold-modifier | // since 6.0
4481+
//
4482+
// Since 6.0 the map-type-modifier has been split into individual modifiers,
4483+
// and delete-modifier has been split from map-type.
43834484
struct OmpMapClause {
43844485
TUPLE_CLASS_BOILERPLATE(OmpMapClause);
4385-
MODIFIER_BOILERPLATE(OmpMapTypeModifier, OmpMapper, OmpIterator, OmpMapType);
4486+
MODIFIER_BOILERPLATE(OmpAlwaysModifier, OmpCloseModifier, OmpDeleteModifier,
4487+
OmpMapTypeModifier, OmpPresentModifier, OmpRefModifier, OmpSelfModifier,
4488+
OmpMapper, OmpIterator, OmpMapType, OmpxHoldModifier);
43864489
std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
43874490
};
43884491

flang/include/flang/Semantics/openmp-modifiers.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ DECLARE_DESCRIPTOR(parser::OmpAlignment);
7171
DECLARE_DESCRIPTOR(parser::OmpAlignModifier);
7272
DECLARE_DESCRIPTOR(parser::OmpAllocatorComplexModifier);
7373
DECLARE_DESCRIPTOR(parser::OmpAllocatorSimpleModifier);
74+
DECLARE_DESCRIPTOR(parser::OmpAlwaysModifier);
7475
DECLARE_DESCRIPTOR(parser::OmpChunkModifier);
76+
DECLARE_DESCRIPTOR(parser::OmpCloseModifier);
7577
DECLARE_DESCRIPTOR(parser::OmpContextSelector);
78+
DECLARE_DESCRIPTOR(parser::OmpDeleteModifier);
7679
DECLARE_DESCRIPTOR(parser::OmpDependenceType);
7780
DECLARE_DESCRIPTOR(parser::OmpDeviceModifier);
7881
DECLARE_DESCRIPTOR(parser::OmpDirectiveNameModifier);
@@ -88,12 +91,16 @@ DECLARE_DESCRIPTOR(parser::OmpMapTypeModifier);
8891
DECLARE_DESCRIPTOR(parser::OmpOrderModifier);
8992
DECLARE_DESCRIPTOR(parser::OmpOrderingModifier);
9093
DECLARE_DESCRIPTOR(parser::OmpPrescriptiveness);
94+
DECLARE_DESCRIPTOR(parser::OmpPresentModifier);
9195
DECLARE_DESCRIPTOR(parser::OmpReductionIdentifier);
9296
DECLARE_DESCRIPTOR(parser::OmpReductionModifier);
97+
DECLARE_DESCRIPTOR(parser::OmpRefModifier);
98+
DECLARE_DESCRIPTOR(parser::OmpSelfModifier);
9399
DECLARE_DESCRIPTOR(parser::OmpStepComplexModifier);
94100
DECLARE_DESCRIPTOR(parser::OmpStepSimpleModifier);
95101
DECLARE_DESCRIPTOR(parser::OmpTaskDependenceType);
96102
DECLARE_DESCRIPTOR(parser::OmpVariableCategory);
103+
DECLARE_DESCRIPTOR(parser::OmpxHoldModifier);
97104

98105
#undef DECLARE_DESCRIPTOR
99106

0 commit comments

Comments
 (0)