NODE(parser, OpenMPConstruct)
NODE(parser, OpenMPConstructDirective)
NODE(parser, OpenMPCriticalConstruct)
- NODE(parser::OpenMPCriticalConstruct, Hint)
+ NODE(parser, OpenMPCriticalConstructDirective)
+ NODE(parser::OpenMPCriticalConstructDirective, Hint)
NODE(parser, OpenMPDeclarativeConstruct)
NODE(parser::OpenMPDeclarativeConstruct, Threadprivate)
NODE(parser, OpenMPDeclareReductionConstruct)
constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok;
constexpr auto endOmpLine = space >> endOfLine;
+template<typename A> constexpr decltype(auto) OmpConstructDirective(A keyword) {
+ return sourced(construct<OpenMPConstructDirective>(
+ keyword >> Parser<OmpClauseList>{})) /
+ endOmpLine;
+}
+
// OpenMP Clauses
// DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE )
TYPE_PARSER(construct<OmpDefaultClause>(
// OMP CRITICAL
TYPE_PARSER(startOmpLine >> "END CRITICAL"_tok >>
- construct<OmpEndCritical>(maybe(parenthesized(name))))
+ construct<OmpEndCritical>(maybe(parenthesized(name))) / endOmpLine)
TYPE_PARSER(
- "CRITICAL" >> construct<OpenMPCriticalConstruct>(maybe(parenthesized(name)),
- maybe("HINT" >> construct<OpenMPCriticalConstruct::Hint>(
- parenthesized(constantExpr))) /
- endOmpLine,
- block, Parser<OmpEndCritical>{} / endOmpLine))
+ sourced(construct<OpenMPCriticalConstructDirective>(
+ "CRITICAL" >> maybe(parenthesized(name)),
+ maybe("HINT" >> construct<OpenMPCriticalConstructDirective::Hint>(
+ parenthesized(constantExpr))))) /
+ endOmpLine)
+TYPE_PARSER(construct<OpenMPCriticalConstruct>(
+ Parser<OpenMPCriticalConstructDirective>{}, block,
+ Parser<OmpEndCritical>{}))
// Declare Simd construct
-TYPE_PARSER(construct<OpenMPDeclareSimdConstruct>(
- maybe(parenthesized(name)), Parser<OmpClauseList>{}))
+TYPE_PARSER(sourced(construct<OpenMPDeclareSimdConstruct>(
+ maybe(parenthesized(name)), Parser<OmpClauseList>{})))
// Declarative construct & Threadprivate directive
TYPE_PARSER(startOmpLine >>
- ("DECLARE REDUCTION" >>
+ sourced("DECLARE REDUCTION" >>
construct<OpenMPDeclarativeConstruct>(
construct<OpenMPDeclarativeConstruct>(
- Parser<OpenMPDeclareReductionConstruct>{})) /
- endOmpLine ||
+ Parser<OpenMPDeclareReductionConstruct>{})) ||
"DECLARE SIMD" >> construct<OpenMPDeclarativeConstruct>(
- Parser<OpenMPDeclareSimdConstruct>{}) /
- endOmpLine ||
+ Parser<OpenMPDeclareSimdConstruct>{}) ||
"DECLARE TARGET" >> construct<OpenMPDeclarativeConstruct>(
construct<OpenMPDeclarativeConstruct>(
- Parser<OpenMPDeclareTargetConstruct>{})) /
- endOmpLine ||
+ Parser<OpenMPDeclareTargetConstruct>{})) ||
"THREADPRIVATE" >>
construct<OpenMPDeclarativeConstruct>(
construct<OpenMPDeclarativeConstruct::Threadprivate>(
- parenthesized(Parser<OmpObjectList>{})) /
- endOmpLine)))
+ parenthesized(Parser<OmpObjectList>{}))) /
+ endOmpLine))
+// TODO pmk
// Block Construct
TYPE_PARSER(construct<OpenMPBlockConstruct>(
sourced(Parser<OmpBlockDirective>{}), Parser<OmpClauseList>{} / endOmpLine,
// OMP SINGLE
TYPE_PARSER(startOmpLine >> "END"_tok >>
- construct<OmpEndSingle>("SINGLE" >> Parser<OmpClauseList>{}))
+ construct<OmpEndSingle>("SINGLE" >> Parser<OmpClauseList>{}) / endOmpLine)
TYPE_PARSER("SINGLE" >>
- construct<OpenMPSingleConstruct>(Parser<OmpClauseList>{} / endOmpLine,
- block, Parser<OmpEndSingle>{} / endOmpLine))
+ construct<OpenMPSingleConstruct>(
+ OmpConstructDirective("SINGLE"_tok), block, Parser<OmpEndSingle>{}))
-TYPE_PARSER(
- startOmpLine >> "END"_tok >> construct<OmpEndWorkshare>("WORKSHARE"_tok))
+TYPE_PARSER(startOmpLine >> "END"_tok >>
+ construct<OmpEndWorkshare>("WORKSHARE"_tok) / endOmpLine)
// OMP WORKSHARE
TYPE_PARSER("WORKSHARE" >>
construct<OpenMPWorkshareConstruct>(endOmpLine >> block,
- Parser<OmpEndWorkshare>{} >>
- maybe(construct<OmpNowait>("NOWAIT"_tok)) / endOmpLine))
+ Parser<OmpEndWorkshare>{} >> maybe(construct<OmpNowait>("NOWAIT"_tok))))
// OMP END DO SIMD [NOWAIT]
TYPE_PARSER(construct<OmpEndDoSimd>(maybe(construct<OmpNowait>("NOWAIT"_tok))))
construct<OmpEndSections>(
maybe("NOWAIT" >> construct<OmpNowait>()) / endOmpLine))
-template<typename A> constexpr decltype(auto) OmpConstructDirective(A keyword) {
- return sourced(construct<OpenMPConstructDirective>(
- keyword >> Parser<OmpClauseList>{})) /
- endOmpLine;
-}
-
// OMP SECTIONS
TYPE_PARSER(construct<OpenMPSectionsConstruct>(
OmpConstructDirective("SECTIONS"_tok), block, Parser<OmpEndSections>{}))
WRAPPER_CLASS(OmpEndSingle, OmpClauseList);
struct OpenMPSingleConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPSingleConstruct);
- std::tuple<OmpClauseList, Block, OmpEndSingle> t;
+ std::tuple<OpenMPConstructDirective, Block, OmpEndSingle> t;
};
// OpenMP directive beginning a block
struct OpenMPDeclareSimdConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareSimdConstruct);
+ CharBlock source;
std::tuple<std::optional<Name>, OmpClauseList> t;
};
struct OpenMPDeclarativeConstruct {
UNION_CLASS_BOILERPLATE(OpenMPDeclarativeConstruct);
WRAPPER_CLASS(Threadprivate, OmpObjectList);
+ CharBlock source;
std::variant<OpenMPDeclareReductionConstruct, OpenMPDeclareSimdConstruct,
OpenMPDeclareTargetConstruct, Threadprivate>
u;
// CRITICAL [Name] <block> END CRITICAL [Name]
WRAPPER_CLASS(OmpEndCritical, std::optional<Name>);
+struct OpenMPCriticalConstructDirective {
+ TUPLE_CLASS_BOILERPLATE(OpenMPCriticalConstructDirective);
+ WRAPPER_CLASS(Hint, ConstantExpr);
+ CharBlock source;
+ std::tuple<std::optional<Name>, std::optional<Hint>> t;
+};
struct OpenMPCriticalConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPCriticalConstruct);
- WRAPPER_CLASS(Hint, ConstantExpr);
- std::tuple<std::optional<Name>, std::optional<Hint>, Block, OmpEndCritical> t;
+ std::tuple<OpenMPCriticalConstructDirective, Block, OmpEndCritical> t;
};
// END ATOMIC
struct OmpLoopDirective {
UNION_CLASS_BOILERPLATE(OmpLoopDirective);
+ EMPTY_CLASS(Distribute);
EMPTY_CLASS(DistributeParallelDoSimd);
EMPTY_CLASS(DistributeParallelDo);
EMPTY_CLASS(DistributeSimd);
- EMPTY_CLASS(Distribute);
- EMPTY_CLASS(ParallelDoSimd);
EMPTY_CLASS(ParallelDo);
+ EMPTY_CLASS(ParallelDoSimd);
EMPTY_CLASS(Do);
EMPTY_CLASS(DoSimd);
EMPTY_CLASS(Simd);
- EMPTY_CLASS(TargetParallelDoSimd);
EMPTY_CLASS(TargetParallelDo);
- EMPTY_CLASS(TargetTeamsDistributeParallelDoSimd);
+ EMPTY_CLASS(TargetParallelDoSimd);
+ EMPTY_CLASS(TargetTeamsDistribute);
EMPTY_CLASS(TargetTeamsDistributeParallelDo);
+ EMPTY_CLASS(TargetTeamsDistributeParallelDoSimd);
EMPTY_CLASS(TargetTeamsDistributeSimd);
- EMPTY_CLASS(TargetTeamsDistribute);
EMPTY_CLASS(TargetSimd);
- EMPTY_CLASS(TaskloopSimd);
EMPTY_CLASS(Taskloop);
+ EMPTY_CLASS(TaskloopSimd);
+ EMPTY_CLASS(TeamsDistribute);
EMPTY_CLASS(TeamsDistributeParallelDoSimd);
EMPTY_CLASS(TeamsDistributeParallelDo);
EMPTY_CLASS(TeamsDistributeSimd);
- EMPTY_CLASS(TeamsDistribute);
CharBlock source;
std::variant<DistributeParallelDoSimd, DistributeParallelDo, DistributeSimd,
Distribute, ParallelDoSimd, ParallelDo, Do, DoSimd, Simd,
Walk(" (", x.v, ")");
EndOpenMP();
}
- void Unparse(const OpenMPCriticalConstruct &x) {
+ void Unparse(const OpenMPCriticalConstructDirective &x) {
BeginOpenMP();
Word("!$OMP CRITICAL");
Walk(" (", std::get<std::optional<Name>>(x.t), ")");
- Walk(" HINT(", std::get<std::optional<OpenMPCriticalConstruct::Hint>>(x.t),
+ Walk(" HINT(",
+ std::get<std::optional<OpenMPCriticalConstructDirective::Hint>>(x.t),
")");
Put("\n");
EndOpenMP();
+ }
+ void Unparse(const OpenMPCriticalConstruct &x) {
+ Walk(std::get<OpenMPCriticalConstructDirective>(x.t));
Walk(std::get<Block>(x.t), "");
BeginOpenMP();
Word("!$OMP END CRITICAL");
void Unparse(const OpenMPSingleConstruct &x) {
BeginOpenMP();
Word("!$OMP SINGLE");
- Walk(std::get<OmpClauseList>(x.t));
+ Walk(std::get<OpenMPConstructDirective>(x.t));
EndOpenMP();
Put("\n");
Walk(std::get<Block>(x.t), "");