Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
10 changes: 5 additions & 5 deletions flang/examples/FeatureList/FeatureList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,16 @@ struct NodeVisitor {
READ_FEATURE(OmpDefaultClause::Type)
READ_FEATURE(OmpDefaultmapClause)
READ_FEATURE(OmpDefaultmapClause::ImplicitBehavior)
READ_FEATURE(OmpDefaultmapClause::VariableCategory)
READ_FEATURE(OmpVariableCategory::Value)
READ_FEATURE(OmpDependClause)
READ_FEATURE(OmpDependClause::TaskDep)
READ_FEATURE(OmpDoacross::Sink)
READ_FEATURE(OmpDoacross::Source)
READ_FEATURE(OmpDoacrossClause)
READ_FEATURE(OmpDependenceType)
READ_FEATURE(OmpDependenceType::Type)
READ_FEATURE(OmpDependenceType::Value)
READ_FEATURE(OmpTaskDependenceType)
READ_FEATURE(OmpTaskDependenceType::Type)
READ_FEATURE(OmpTaskDependenceType::Value)
READ_FEATURE(OmpIteration)
READ_FEATURE(OmpIterationOffset)
READ_FEATURE(OmpIterationVector)
Expand All @@ -495,7 +495,7 @@ struct NodeVisitor {
READ_FEATURE(OmpLinearClause::WithModifier)
READ_FEATURE(OmpLinearClause::WithoutModifier)
READ_FEATURE(OmpLinearModifier)
READ_FEATURE(OmpLinearModifier::Type)
READ_FEATURE(OmpLinearModifier::Value)
READ_FEATURE(OmpLoopDirective)
READ_FEATURE(OmpMapClause)
READ_FEATURE(OmpMapClause::TypeModifier)
Expand All @@ -515,7 +515,7 @@ struct NodeVisitor {
READ_FEATURE(OmpReductionCombiner)
READ_FEATURE(OmpReductionCombiner::FunctionCombiner)
READ_FEATURE(OmpReductionInitializerClause)
READ_FEATURE(OmpReductionOperator)
READ_FEATURE(OmpReductionIdentifier)
READ_FEATURE(OmpAllocateClause)
READ_FEATURE(OmpAllocateClause::AllocateModifier)
READ_FEATURE(OmpAllocateClause::AllocateModifier::Allocator)
Expand Down
9 changes: 4 additions & 5 deletions flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,20 @@ void OpenMPCounterVisitor::Post(
"implicit_behavior=" + std::string{OmpDefaultmapClause::EnumToString(c)} +
";";
}
void OpenMPCounterVisitor::Post(
const OmpDefaultmapClause::VariableCategory &c) {
void OpenMPCounterVisitor::Post(const OmpVariableCategory::Value &c) {
clauseDetails +=
"variable_category=" + std::string{OmpDefaultmapClause::EnumToString(c)} +
"variable_category=" + std::string{OmpVariableCategory::EnumToString(c)} +
";";
}
void OpenMPCounterVisitor::Post(const OmpScheduleModifierType::ModType &c) {
clauseDetails +=
"modifier=" + std::string{OmpScheduleModifierType::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpLinearModifier::Type &c) {
void OpenMPCounterVisitor::Post(const OmpLinearModifier::Value &c) {
clauseDetails +=
"modifier=" + std::string{OmpLinearModifier::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpTaskDependenceType::Type &c) {
void OpenMPCounterVisitor::Post(const OmpTaskDependenceType::Value &c) {
clauseDetails +=
"type=" + std::string{OmpTaskDependenceType::EnumToString(c)} + ";";
}
Expand Down
6 changes: 3 additions & 3 deletions flang/examples/FlangOmpReport/FlangOmpReportVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ struct OpenMPCounterVisitor {
void Post(const OmpProcBindClause::Type &c);
void Post(const OmpDefaultClause::Type &c);
void Post(const OmpDefaultmapClause::ImplicitBehavior &c);
void Post(const OmpDefaultmapClause::VariableCategory &c);
void Post(const OmpVariableCategory::Value &c);
void Post(const OmpDeviceTypeClause::Type &c);
void Post(const OmpScheduleModifierType::ModType &c);
void Post(const OmpLinearModifier::Type &c);
void Post(const OmpTaskDependenceType::Type &c);
void Post(const OmpLinearModifier::Value &c);
void Post(const OmpTaskDependenceType::Value &c);
void Post(const OmpMapClause::Type &c);
void Post(const OmpScheduleClause::ScheduleType &c);
void Post(const OmpIfClause::DirectiveNameModifier &c);
Expand Down
18 changes: 11 additions & 7 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ class ParseTreeDumper {
NODE(parser, ObjectDecl)
NODE(parser, OldParameterStmt)
NODE(parser, OmpIteratorSpecifier)
NODE(parser, OmpIteratorModifier)
NODE(parser, OmpIterator)
NODE(parser, OmpAffinityClause)
NODE(parser, OmpAlignedClause)
NODE(parser, OmpAtomic)
Expand Down Expand Up @@ -509,13 +509,15 @@ class ParseTreeDumper {
NODE(parser, OmpDeclareMapperSpecifier)
NODE(parser, OmpDefaultClause)
NODE_ENUM(OmpDefaultClause, Type)
NODE(parser, OmpVariableCategory)
NODE_ENUM(OmpVariableCategory, Value)
NODE(parser, OmpDefaultmapClause)
NODE_ENUM(OmpDefaultmapClause, ImplicitBehavior)
NODE_ENUM(OmpDefaultmapClause, VariableCategory)
NODE(OmpDefaultmapClause, Modifier)
NODE(parser, OmpDependenceType)
NODE_ENUM(OmpDependenceType, Type)
NODE_ENUM(OmpDependenceType, Value)
NODE(parser, OmpTaskDependenceType)
NODE_ENUM(OmpTaskDependenceType, Type)
NODE_ENUM(OmpTaskDependenceType, Value)
NODE(parser, OmpIterationOffset)
NODE(parser, OmpIteration)
NODE(parser, OmpIterationVector)
Expand Down Expand Up @@ -543,7 +545,7 @@ class ParseTreeDumper {
NODE(OmpLinearClause, WithModifier)
NODE(OmpLinearClause, WithoutModifier)
NODE(parser, OmpLinearModifier)
NODE_ENUM(OmpLinearModifier, Type)
NODE_ENUM(OmpLinearModifier, Value)
NODE(parser, OmpLoopDirective)
NODE(parser, OmpMapClause)
NODE_ENUM(OmpMapClause, TypeModifier)
Expand All @@ -567,13 +569,15 @@ class ParseTreeDumper {
NODE_ENUM(OmpBindClause, Type)
NODE(parser, OmpProcBindClause)
NODE_ENUM(OmpProcBindClause, Type)
NODE_ENUM(OmpReductionClause, ReductionModifier)
NODE(parser, OmpReductionModifier)
NODE_ENUM(OmpReductionModifier, Value)
NODE(parser, OmpReductionClause)
NODE(OmpReductionClause, Modifier)
NODE(parser, OmpInReductionClause)
NODE(parser, OmpReductionCombiner)
NODE(OmpReductionCombiner, FunctionCombiner)
NODE(parser, OmpReductionInitializerClause)
NODE(parser, OmpReductionOperator)
NODE(parser, OmpReductionIdentifier)
NODE(parser, OmpAllocateClause)
NODE(OmpAllocateClause, AllocateModifier)
NODE(OmpAllocateClause::AllocateModifier, Allocator)
Expand Down
158 changes: 108 additions & 50 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3440,13 +3440,43 @@ struct OmpObject {

WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>);

#define MODIFIER_BOILERPLATE(...) \
struct Modifier { \
using Variant = std::variant<__VA_ARGS__>; \
UNION_CLASS_BOILERPLATE(Modifier); \
CharBlock source; \
Variant u; \
}

#define MODIFIERS() std::optional<std::list<Modifier>>

inline namespace modifier {
// For uniformity, in all keyword modifiers the name of the type defined
// by ENUM_CLASS is "Value", e.g.
// struct Foo {
// ENUM_CLASS(Value, Keyword1, Keyword2);
// };

// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
//
// iterator-specifier ->
// [iterator-type] iterator-identifier
// = range-specification | // since 5.0
// [iterator-type ::] iterator-identifier
// = range-specification // since 5.2
struct OmpIteratorSpecifier {
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
CharBlock source;
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
};

// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289]
//
// dependence-type ->
// SINK | SOURCE | // since 4.5
// IN | OUT | INOUT | // since 4.5, until 5.1
// MUTEXINOUTSET | DEPOBJ | // since 5.0, until 5.1
// INOUTSET // since 5.1, until 5.1
// SINK | SOURCE | // since 4.5
// IN | OUT | INOUT | // since 4.5, until 5.1
// MUTEXINOUTSET | DEPOBJ | // since 5.0, until 5.1
// INOUTSET // since 5.1, until 5.1
//
// All of these, except SINK and SOURCE became task-dependence-type in 5.2.
//
Expand All @@ -3457,45 +3487,78 @@ WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>);
// vector). This would accept the vector "i, j, k" (although interpreted
// incorrectly), while flagging a syntax error for "i+1, j, k".
struct OmpDependenceType {
ENUM_CLASS(Type, Sink, Source);
WRAPPER_CLASS_BOILERPLATE(OmpDependenceType, Type);
ENUM_CLASS(Value, Sink, Source);
WRAPPER_CLASS_BOILERPLATE(OmpDependenceType, Value);
};

// Ref: [4.5:169-170], [5.0:254-256], [5.1:287-289], [5.2:321]
// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
//
// task-dependence-type -> // "dependence-type" in 5.1 and before
// IN | OUT | INOUT | // since 4.5
// MUTEXINOUTSET | DEPOBJ | // since 5.0
// INOUTSET // since 5.2
struct OmpTaskDependenceType {
ENUM_CLASS(Type, In, Out, Inout, Inoutset, Mutexinoutset, Depobj)
WRAPPER_CLASS_BOILERPLATE(OmpTaskDependenceType, Type);
// iterator-modifier ->
// ITERATOR(iterator-specifier [, ...]) // since 5.0
struct OmpIterator {
WRAPPER_CLASS_BOILERPLATE(OmpIterator, std::list<OmpIteratorSpecifier>);
};

// [5.0] 2.1.6 iterator-specifier -> type-declaration-stmt = subscript-triple
// iterator-modifier -> iterator-specifier-list
struct OmpIteratorSpecifier {
TUPLE_CLASS_BOILERPLATE(OmpIteratorSpecifier);
CharBlock source;
std::tuple<TypeDeclarationStmt, SubscriptTriplet> t;
// Ref: [4.5:207-210], [5.0:290-293], [5.1:323-325], [5.2:117-120]
//
// linear-modifier ->
// REF | UVAL | VAL // since 4.5
struct OmpLinearModifier {
ENUM_CLASS(Value, Ref, Uval, Val);
WRAPPER_CLASS_BOILERPLATE(OmpLinearModifier, Value);
};

WRAPPER_CLASS(OmpIteratorModifier, std::list<OmpIteratorSpecifier>);

// 2.15.3.6 reduction-identifier -> + | - | * | .AND. | .OR. | .EQV. | .NEQV. |
// MAX | MIN | IAND | IOR | IEOR
struct OmpReductionOperator {
UNION_CLASS_BOILERPLATE(OmpReductionOperator);
// Ref: [4.5:201-207], [5.0:293-299], [5.1:325-331], [5.2:124]
//
// reduction-identifier ->
// base-language-identifier | // since 4.5
// - | // since 4.5, until 5.2
// + | * | .AND. | .OR. | .EQV. | .NEQV. | // since 4.5
// MIN | MAX | IAND | IOR | IEOR // since 4.5
struct OmpReductionIdentifier {
UNION_CLASS_BOILERPLATE(OmpReductionIdentifier);
std::variant<DefinedOperator, ProcedureDesignator> u;
};

// Ref: [5.0:300-302], [5.1:332-334], [5.2:134-137]
//
// reduction-modifier ->
// DEFAULT | INSCAN | TASK // since 5.0
struct OmpReductionModifier {
ENUM_CLASS(Value, Default, Inscan, Task);
WRAPPER_CLASS_BOILERPLATE(OmpReductionModifier, Value);
};

// Ref: [4.5:169-170], [5.0:254-256], [5.1:287-289], [5.2:321]
//
// task-dependence-type -> // "dependence-type" in 5.1 and before
// IN | OUT | INOUT | // since 4.5
// MUTEXINOUTSET | DEPOBJ | // since 5.0
// INOUTSET // since 5.2
struct OmpTaskDependenceType {
ENUM_CLASS(Value, In, Out, Inout, Inoutset, Mutexinoutset, Depobj)
WRAPPER_CLASS_BOILERPLATE(OmpTaskDependenceType, Value);
};

// Ref: [4.5:229-230], [5.0:324-325], [5.1:357-358], [5.2:161-162]
//
// variable-category ->
// SCALAR | // since 4.5
// AGGREGATE | ALLOCATABLE | POINTER | // since 5.0
// ALL // since 5.2
struct OmpVariableCategory {
ENUM_CLASS(Value, Aggregate, All, Allocatable, Pointer, Scalar)
WRAPPER_CLASS_BOILERPLATE(OmpVariableCategory, Value);
};
} // namespace modifier

// --- Clauses

// OMP 5.0 2.10.1 affinity([aff-modifier:] locator-list)
// aff-modifier: interator-modifier
struct OmpAffinityClause {
TUPLE_CLASS_BOILERPLATE(OmpAffinityClause);
std::tuple<std::optional<OmpIteratorModifier>, OmpObjectList> t;
std::tuple<std::optional<OmpIterator>, OmpObjectList> t;
};

// 2.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
Expand Down Expand Up @@ -3544,8 +3607,8 @@ struct OmpDefaultmapClause {
TUPLE_CLASS_BOILERPLATE(OmpDefaultmapClause);
ENUM_CLASS(
ImplicitBehavior, Alloc, To, From, Tofrom, Firstprivate, None, Default)
ENUM_CLASS(VariableCategory, All, Scalar, Aggregate, Allocatable, Pointer)
std::tuple<ImplicitBehavior, std::optional<VariableCategory>> t;
MODIFIER_BOILERPLATE(OmpVariableCategory);
std::tuple<ImplicitBehavior, MODIFIERS()> t;
};

// 2.13.9 iteration-offset -> +/- non-negative-constant
Expand All @@ -3566,7 +3629,7 @@ WRAPPER_CLASS(OmpIterationVector, std::list<OmpIteration>);
// OmpDoacrossClause), so that the context in TYPE_CONTEXT_PARSER can be set
// separately for OmpDependClause and OmpDoacrossClause.
struct OmpDoacross {
OmpDependenceType::Type GetDepType() const;
OmpDependenceType::Value GetDepType() const;

WRAPPER_CLASS(Sink, OmpIterationVector);
EMPTY_CLASS(Source);
Expand All @@ -3586,10 +3649,9 @@ struct OmpDoacross {
struct OmpDependClause {
UNION_CLASS_BOILERPLATE(OmpDependClause);
struct TaskDep {
OmpTaskDependenceType::Type GetTaskDepType() const;
OmpTaskDependenceType::Value GetTaskDepType() const;
TUPLE_CLASS_BOILERPLATE(TaskDep);
std::tuple<std::optional<OmpIteratorModifier>, OmpTaskDependenceType,
OmpObjectList>
std::tuple<std::optional<OmpIterator>, OmpTaskDependenceType, OmpObjectList>
t;
};
std::variant<TaskDep, OmpDoacross> u;
Expand Down Expand Up @@ -3632,7 +3694,7 @@ struct OmpFromClause {
// As in the case of MAP, modifiers are parsed as lists, even if they
// are unique. These restrictions will be checked in semantic checks.
std::tuple<std::optional<std::list<Expectation>>,
std::optional<std::list<OmpIteratorModifier>>, OmpObjectList,
std::optional<std::list<OmpIterator>>, OmpObjectList,
bool> // were the modifiers comma-separated?
t;
};
Expand Down Expand Up @@ -3661,7 +3723,7 @@ struct OmpDetachClause {
// variable-name-list)
struct OmpInReductionClause {
TUPLE_CLASS_BOILERPLATE(OmpInReductionClause);
std::tuple<OmpReductionOperator, OmpObjectList> t;
std::tuple<OmpReductionIdentifier, OmpObjectList> t;
};

// OMP 5.0 2.19.4.5 lastprivate-clause ->
Expand All @@ -3673,12 +3735,6 @@ struct OmpLastprivateClause {
std::tuple<std::optional<LastprivateModifier>, OmpObjectList> t;
};

// 2.15.3.7 linear-modifier -> REF | VAL | UVAL
struct OmpLinearModifier {
ENUM_CLASS(Type, Ref, Val, Uval)
WRAPPER_CLASS_BOILERPLATE(OmpLinearModifier, Type);
};

// 2.15.3.7 linear-clause -> LINEAR (linear-list[ : linear-step])
// linear-list -> list | linear-modifier(list)
struct OmpLinearClause {
Expand Down Expand Up @@ -3719,7 +3775,7 @@ struct OmpMapClause {
// In OpenMP 5.2 the non-comma syntax has been deprecated: keep the
// information about separator presence to emit a diagnostic if needed.
std::tuple<std::optional<std::list<TypeModifier>>,
std::optional<std::list<OmpIteratorModifier>>, // unique
std::optional<std::list<OmpIterator>>, // unique
std::optional<std::list<Type>>, // unique
OmpObjectList,
bool> // were the modifiers comma-separated?
Expand All @@ -3744,14 +3800,16 @@ struct OmpProcBindClause {
WRAPPER_CLASS_BOILERPLATE(OmpProcBindClause, Type);
};

// 2.15.3.6 reduction-clause -> REDUCTION (reduction-identifier:
// variable-name-list)
// Ref: [4.5:201-207], [5.0:300-302], [5.1:332-334], [5.2:134-137]
//
// reduction-clause ->
// REDUCTION(reduction-identifier: list) | // since 4.5
// REDUCTION([reduction-modifier,]
// reduction-identifier: list) // since 5.0
struct OmpReductionClause {
TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
ENUM_CLASS(ReductionModifier, Inscan, Task, Default)
std::tuple<std::optional<ReductionModifier>, OmpReductionOperator,
OmpObjectList>
t;
MODIFIER_BOILERPLATE(OmpReductionModifier, OmpReductionIdentifier);
std::tuple<MODIFIERS(), OmpObjectList> t;
};

// 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
Expand Down Expand Up @@ -3794,7 +3852,7 @@ struct OmpToClause {
// As in the case of MAP, modifiers are parsed as lists, even if they
// are unique. These restrictions will be checked in semantic checks.
std::tuple<std::optional<std::list<Expectation>>,
std::optional<std::list<OmpIteratorModifier>>, OmpObjectList,
std::optional<std::list<OmpIterator>>, OmpObjectList,
bool> // were the modifiers comma-separated?
t;
};
Expand Down Expand Up @@ -3942,7 +4000,7 @@ WRAPPER_CLASS(OmpReductionInitializerClause, Expr);
struct OpenMPDeclareReductionConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareReductionConstruct);
CharBlock source;
std::tuple<Verbatim, OmpReductionOperator, std::list<DeclarationTypeSpec>,
std::tuple<Verbatim, OmpReductionIdentifier, std::list<DeclarationTypeSpec>,
OmpReductionCombiner, std::optional<OmpReductionInitializerClause>>
t;
};
Expand Down
Loading
Loading