Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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: 9 additions & 9 deletions flang/examples/FeatureList/FeatureList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ 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)
Expand Down Expand Up @@ -505,9 +505,9 @@ struct NodeVisitor {
READ_FEATURE(OmpObject)
READ_FEATURE(OmpObjectList)
READ_FEATURE(OmpOrderClause)
READ_FEATURE(OmpOrderClause::Type)
READ_FEATURE(OmpOrderClause::Ordering)
READ_FEATURE(OmpOrderModifier)
READ_FEATURE(OmpOrderModifier::Kind)
READ_FEATURE(OmpOrderModifier::Value)
READ_FEATURE(OmpProcBindClause)
READ_FEATURE(OmpProcBindClause::Type)
READ_FEATURE(OmpReductionClause)
Expand All @@ -522,16 +522,16 @@ struct NodeVisitor {
READ_FEATURE(OmpAllocateClause::AllocateModifier::ComplexModifier)
READ_FEATURE(OmpAllocateClause::AllocateModifier::Align)
READ_FEATURE(OmpScheduleClause)
READ_FEATURE(OmpScheduleClause::ScheduleType)
READ_FEATURE(OmpScheduleClause::Kind)
READ_FEATURE(OmpScheduleClause::Modifier)
READ_FEATURE(OmpDeviceClause)
READ_FEATURE(OmpDeviceClause::DeviceModifier)
READ_FEATURE(OmpDeviceTypeClause)
READ_FEATURE(OmpDeviceTypeClause::Type)
READ_FEATURE(OmpScheduleModifier)
READ_FEATURE(OmpScheduleModifier::Modifier1)
READ_FEATURE(OmpScheduleModifier::Modifier2)
READ_FEATURE(OmpScheduleModifierType)
READ_FEATURE(OmpScheduleModifierType::ModType)
READ_FEATURE(OmpChunkModifier)
READ_FEATURE(OmpChunkModifier::Value)
READ_FEATURE(OmpOrderingModifier)
READ_FEATURE(OmpOrderingModifier::Value)
READ_FEATURE(OmpSectionBlocks)
READ_FEATURE(OmpSectionsDirective)
READ_FEATURE(OmpSimpleStandaloneDirective)
Expand Down
15 changes: 9 additions & 6 deletions flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,28 +208,31 @@ 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) {
void OpenMPCounterVisitor::Post(const OmpChunkModifier::Value &c) {
clauseDetails +=
"modifier=" + std::string{OmpScheduleModifierType::EnumToString(c)} + ";";
"modifier=" + std::string{OmpChunkModifier::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpLinearModifier::Value &c) {
clauseDetails +=
"modifier=" + std::string{OmpLinearModifier::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpOrderingModifier::Value &c) {
clauseDetails +=
"modifier=" + std::string{OmpOrderingModifier::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpTaskDependenceType::Value &c) {
clauseDetails +=
"type=" + std::string{OmpTaskDependenceType::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpMapClause::Type &c) {
clauseDetails += "type=" + std::string{OmpMapClause::EnumToString(c)} + ";";
}
void OpenMPCounterVisitor::Post(const OmpScheduleClause::ScheduleType &c) {
void OpenMPCounterVisitor::Post(const OmpScheduleClause::Kind &c) {
clauseDetails +=
"type=" + std::string{OmpScheduleClause::EnumToString(c)} + ";";
}
Expand Down
7 changes: 4 additions & 3 deletions flang/examples/FlangOmpReport/FlangOmpReportVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ 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 OmpChunkModifier::Value &c);
void Post(const OmpLinearModifier::Value &c);
void Post(const OmpOrderingModifier::Value &c);
void Post(const OmpTaskDependenceType::Value &c);
void Post(const OmpMapClause::Type &c);
void Post(const OmpScheduleClause::ScheduleType &c);
void Post(const OmpScheduleClause::Kind &c);
void Post(const OmpIfClause::DirectiveNameModifier &c);
void Post(const OmpCancelType::Type &c);
void Post(const OmpClause &c);
Expand Down
25 changes: 15 additions & 10 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ 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, Value)
NODE(parser, OmpTaskDependenceType)
Expand Down Expand Up @@ -557,9 +559,10 @@ class ParseTreeDumper {
NODE(parser, OmpObject)
NODE(parser, OmpObjectList)
NODE(parser, OmpOrderClause)
NODE_ENUM(OmpOrderClause, Type)
NODE(OmpOrderClause, Modifier)
NODE_ENUM(OmpOrderClause, Ordering)
NODE(parser, OmpOrderModifier)
NODE_ENUM(OmpOrderModifier, Kind)
NODE_ENUM(OmpOrderModifier, Value)
NODE(parser, OmpGrainsizeClause)
NODE_ENUM(OmpGrainsizeClause, Prescriptiveness)
NODE(parser, OmpNumTasksClause)
Expand All @@ -568,8 +571,10 @@ 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)
Expand All @@ -581,17 +586,17 @@ class ParseTreeDumper {
NODE(OmpAllocateClause::AllocateModifier, ComplexModifier)
NODE(OmpAllocateClause::AllocateModifier, Align)
NODE(parser, OmpScheduleClause)
NODE_ENUM(OmpScheduleClause, ScheduleType)
NODE(OmpScheduleClause, Modifier)
NODE_ENUM(OmpScheduleClause, Kind)
NODE(parser, OmpDeviceClause)
NODE_ENUM(OmpDeviceClause, DeviceModifier)
NODE(parser, OmpDeviceTypeClause)
NODE_ENUM(OmpDeviceTypeClause, Type)
NODE(parser, OmpUpdateClause)
NODE(parser, OmpScheduleModifier)
NODE(OmpScheduleModifier, Modifier1)
NODE(OmpScheduleModifier, Modifier2)
NODE(parser, OmpScheduleModifierType)
NODE_ENUM(OmpScheduleModifierType, ModType)
NODE(parser, OmpChunkModifier)
NODE_ENUM(OmpChunkModifier, Value)
NODE(parser, OmpOrderingModifier)
NODE_ENUM(OmpOrderingModifier, Value)
NODE(parser, OmpSectionBlocks)
NODE(parser, OmpSectionsDirective)
NODE(parser, OmpSimpleStandaloneDirective)
Expand Down
130 changes: 94 additions & 36 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3440,13 +3440,34 @@ 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.2:252-254]
//
// chunk-modifier ->
// SIMD // since 5.2
//
// Prior to 5.2 "chunk-modifier" was a part of "modifier" on SCHEDULE clause.
struct OmpChunkModifier {
ENUM_CLASS(Value, Simd)
WRAPPER_CLASS_BOILERPLATE(OmpChunkModifier, Value);
};

// Ref: [5.0:47-49], [5.1:49-51], [5.2:67-69]
//
// iterator-specifier ->
Expand Down Expand Up @@ -3498,19 +3519,51 @@ struct OmpLinearModifier {
WRAPPER_CLASS_BOILERPLATE(OmpLinearModifier, Value);
};

// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
//
// modifier ->
// MONOTONIC | NONMONOTONIC | SIMD // since 4.5, until 5.1
// ordering-modifier ->
// MONOTONIC | NONMONOTONIC // since 5.2
//
// Until 5.1, the SCHEDULE clause accepted up to two instances of "modifier".
// Since 5.2 "modifier" was replaced with "ordering-modifier" and "chunk-
// modifier".
struct OmpOrderingModifier {
ENUM_CLASS(Value, Monotonic, Nonmonotonic, Simd)
WRAPPER_CLASS_BOILERPLATE(OmpOrderingModifier, Value);
};

// Ref: [5.1:125-126], [5.2:233-234]
//
// order-modifier ->
// REPRODUCIBLE | UNCONSTRAINED // since 5.1
struct OmpOrderModifier {
ENUM_CLASS(Value, Reproducible, Unconstrained)
WRAPPER_CLASS_BOILERPLATE(OmpOrderModifier, Value);
};

// 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
Expand All @@ -3521,6 +3574,17 @@ 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
Expand Down Expand Up @@ -3578,8 +3642,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 Down Expand Up @@ -3757,16 +3821,16 @@ struct OmpMapClause {
t;
};

// 2.9.5 order-clause -> ORDER ([order-modifier :]concurrent)
struct OmpOrderModifier {
ENUM_CLASS(Kind, Reproducible, Unconstrained)
WRAPPER_CLASS_BOILERPLATE(OmpOrderModifier, Kind);
};

// Ref: [5.0:101-109], [5.1:126-134], [5.2:233-234]
//
// order-clause ->
// ORDER(CONCURRENT) | // since 5.0
// ORDER([order-modifier:] CONCURRENT) // since 5.1
struct OmpOrderClause {
TUPLE_CLASS_BOILERPLATE(OmpOrderClause);
ENUM_CLASS(Type, Concurrent)
std::tuple<std::optional<OmpOrderModifier>, Type> t;
ENUM_CLASS(Ordering, Concurrent)
MODIFIER_BOILERPLATE(OmpOrderModifier);
std::tuple<MODIFIERS(), Ordering> t;
};

// 2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
Expand All @@ -3775,37 +3839,31 @@ 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>, OmpReductionIdentifier,
OmpObjectList>
t;
};

// 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
struct OmpScheduleModifierType {
ENUM_CLASS(ModType, Monotonic, Nonmonotonic, Simd)
WRAPPER_CLASS_BOILERPLATE(OmpScheduleModifierType, ModType);
MODIFIER_BOILERPLATE(OmpReductionModifier, OmpReductionIdentifier);
std::tuple<MODIFIERS(), OmpObjectList> t;
};

struct OmpScheduleModifier {
TUPLE_CLASS_BOILERPLATE(OmpScheduleModifier);
WRAPPER_CLASS(Modifier1, OmpScheduleModifierType);
WRAPPER_CLASS(Modifier2, OmpScheduleModifierType);
std::tuple<Modifier1, std::optional<Modifier2>> t;
};

// 2.7.1 schedule-clause -> SCHEDULE ([sched-modifier1] [, sched-modifier2]:]
// kind[, chunk_size])
// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
//
// schedule-clause ->
// SCHEDULE([modifier[, modifier]:]
// kind[, chunk-size]) // since 4.5, until 5.1
// schedule-clause ->
// SCHEDULE([ordering-modifier], chunk-modifier],
// kind[, chunk_size]) // since 5.2
struct OmpScheduleClause {
TUPLE_CLASS_BOILERPLATE(OmpScheduleClause);
ENUM_CLASS(ScheduleType, Static, Dynamic, Guided, Auto, Runtime)
std::tuple<std::optional<OmpScheduleModifier>, ScheduleType,
std::optional<ScalarIntExpr>>
t;
ENUM_CLASS(Kind, Static, Dynamic, Guided, Auto, Runtime)
MODIFIER_BOILERPLATE(OmpOrderingModifier, OmpChunkModifier);
std::tuple<MODIFIERS(), Kind, std::optional<ScalarIntExpr>> t;
};

// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
Expand Down
10 changes: 10 additions & 0 deletions flang/include/flang/Semantics/openmp-modifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,26 @@ struct OmpModifierDescriptor {

template <typename SpecificTy> const OmpModifierDescriptor &OmpGetDescriptor();

template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpChunkModifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpDependenceType>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpIterator>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpLinearModifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpOrderModifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpOrderingModifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpReductionIdentifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpReductionModifier>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpTaskDependenceType>();
template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpVariableCategory>();

// Explanation of terminology:
//
Expand Down
Loading
Loading