mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 12:25:46 +08:00
[flang] Eliminate a lot of needless indirection in OMP data structures
Original-commit: flang-compiler/f18@47c6cb0ba9 Reviewed-on: https://github.com/flang-compiler/f18/pull/569 Tree-same-pre-rewrite: false
This commit is contained in:
@@ -109,8 +109,7 @@ TYPE_PARSER(construct<OmpIfClause>(
|
||||
":"),
|
||||
scalarLogicalExpr))
|
||||
|
||||
TYPE_PARSER(
|
||||
construct<OmpReductionOperator>(indirect(Parser<DefinedOperator>{})) ||
|
||||
TYPE_PARSER(construct<OmpReductionOperator>(Parser<DefinedOperator>{}) ||
|
||||
construct<OmpReductionOperator>(Parser<ProcedureDesignator>{}))
|
||||
|
||||
TYPE_PARSER(construct<OmpReductionClause>(
|
||||
@@ -118,7 +117,7 @@ TYPE_PARSER(construct<OmpReductionClause>(
|
||||
|
||||
// DEPEND(SOURCE | SINK : vec | (IN | OUT | INOUT) : list
|
||||
TYPE_PARSER(construct<OmpDependSinkVecLength>(
|
||||
indirect(Parser<DefinedOperator>{}), scalarIntConstantExpr))
|
||||
Parser<DefinedOperator>{}, scalarIntConstantExpr))
|
||||
|
||||
TYPE_PARSER(
|
||||
construct<OmpDependSinkVec>(name, maybe(Parser<OmpDependSinkVecLength>{})))
|
||||
@@ -357,7 +356,7 @@ TYPE_PARSER("MASTER" >>
|
||||
construct<OmpBlockDirective>(construct<OmpBlockDirective::Teams>()))
|
||||
|
||||
TYPE_PARSER(construct<OmpReductionInitializerClause>(
|
||||
"INITIALIZER" >> parenthesized("OMP_PRIV =" >> indirect(expr))))
|
||||
"INITIALIZER" >> parenthesized("OMP_PRIV =" >> expr)))
|
||||
|
||||
// Declare Reduction Construct
|
||||
TYPE_PARSER(construct<OpenMPDeclareReductionConstruct>(
|
||||
@@ -473,7 +472,7 @@ TYPE_PARSER(startOmpLine >>
|
||||
// Block Construct
|
||||
TYPE_PARSER(construct<OpenMPBlockConstruct>(
|
||||
sourced(Parser<OmpBlockDirective>{}), Parser<OmpClauseList>{} / endOmpLine,
|
||||
block, Parser<OmpEndBlockDirective>{} / endOmpLine))
|
||||
block, Parser<OmpEndBlockDirective>{}))
|
||||
|
||||
TYPE_PARSER(construct<OpenMPStandaloneConstruct>(
|
||||
Parser<OmpStandaloneDirective>{}, Parser<OmpClauseList>{} / endOmpLine))
|
||||
@@ -531,57 +530,42 @@ TYPE_PARSER(startOmpLine >> "END PARALLEL SECTIONS"_tok >>
|
||||
maybe("NOWAIT" >> construct<OmpNowait>()) / endOmpLine))
|
||||
|
||||
// OMP PARALLEL SECTIONS
|
||||
TYPE_PARSER("PARALLEL SECTIONS" >> construct<OpenMPParallelSectionsConstruct>(
|
||||
Parser<OmpClauseList>{} / endOmpLine,
|
||||
block, Parser<OmpEndParallelSections>{}))
|
||||
TYPE_PARSER(construct<OpenMPParallelSectionsConstruct>(
|
||||
OmpConstructDirective("PARALLEL SECTIONS"_tok), block,
|
||||
Parser<OmpEndParallelSections>{}))
|
||||
|
||||
TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
|
||||
startOmpLine >>
|
||||
(construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPStandaloneConstruct>{})) ||
|
||||
(construct<OpenMPConstruct>(Parser<OpenMPStandaloneConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPBarrierConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPTaskwaitConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPTaskyieldConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPSingleConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPSectionsConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPBarrierConstruct>{})) ||
|
||||
Parser<OpenMPParallelSectionsConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPWorkshareConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPLoopConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPBlockConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPAtomicConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPCriticalConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPCancelConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPTaskwaitConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPTaskyieldConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPSingleConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPSectionsConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPParallelSectionsConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPWorkshareConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPLoopConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPBlockConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPAtomicConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPCriticalConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPCancelConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPCancellationPointConstruct>{})) ||
|
||||
construct<OpenMPConstruct>(
|
||||
indirect(Parser<OpenMPFlushConstruct>{})) ||
|
||||
Parser<OpenMPCancellationPointConstruct>{}) ||
|
||||
construct<OpenMPConstruct>(Parser<OpenMPFlushConstruct>{}) ||
|
||||
"SECTION" >> endOmpLine >>
|
||||
construct<OpenMPConstruct>(construct<OmpSection>())))
|
||||
|
||||
// END OMP Block directives
|
||||
TYPE_PARSER(startOmpLine >> "END"_tok >>
|
||||
construct<OmpEndBlockDirective>(indirect(Parser<OmpBlockDirective>{})))
|
||||
construct<OmpEndBlockDirective>(Parser<OmpBlockDirective>{}) / endOmpLine)
|
||||
|
||||
// END OMP Loop directives
|
||||
TYPE_PARSER(startOmpLine >> "END"_tok >>
|
||||
(construct<OpenMPEndLoopDirective>(
|
||||
"DO SIMD" >> indirect(Parser<OmpEndDoSimd>{}) / endOmpLine) ||
|
||||
construct<OpenMPEndLoopDirective>(
|
||||
"DO" >> indirect(Parser<OmpEndDo>{}) / endOmpLine) ||
|
||||
construct<OpenMPEndLoopDirective>(
|
||||
indirect(Parser<OmpLoopDirective>{}) / endOmpLine)))
|
||||
(construct<OpenMPEndLoopDirective>("DO SIMD" >> Parser<OmpEndDoSimd>{}) ||
|
||||
construct<OpenMPEndLoopDirective>("DO" >> Parser<OmpEndDo>{}) ||
|
||||
construct<OpenMPEndLoopDirective>(Parser<OmpLoopDirective>{}) /
|
||||
endOmpLine))
|
||||
|
||||
TYPE_PARSER(construct<OpenMPLoopConstruct>(
|
||||
sourced(Parser<OmpLoopDirective>{}), Parser<OmpClauseList>{} / endOmpLine))
|
||||
|
||||
@@ -3368,7 +3368,7 @@ struct OmpLinearClause {
|
||||
// min, max, iand, ior, ieor
|
||||
struct OmpReductionOperator {
|
||||
UNION_CLASS_BOILERPLATE(OmpReductionOperator);
|
||||
std::variant<common::Indirection<DefinedOperator>, ProcedureDesignator> u;
|
||||
std::variant<DefinedOperator, ProcedureDesignator> u;
|
||||
};
|
||||
|
||||
// REDUCTION(reduction-identifier: list)
|
||||
@@ -3380,7 +3380,7 @@ struct OmpReductionClause {
|
||||
// depend-vec-length -> +/- non-negative-constant
|
||||
struct OmpDependSinkVecLength {
|
||||
TUPLE_CLASS_BOILERPLATE(OmpDependSinkVecLength);
|
||||
std::tuple<common::Indirection<DefinedOperator>, ScalarIntConstantExpr> t;
|
||||
std::tuple<DefinedOperator, ScalarIntConstantExpr> t;
|
||||
};
|
||||
|
||||
// depend-vec -> iterator_variable [+/- depend-vec-length]
|
||||
@@ -3459,7 +3459,7 @@ struct OmpClause {
|
||||
|
||||
WRAPPER_CLASS(OmpClauseList, std::list<OmpClause>);
|
||||
|
||||
// Common representation for construct-starting directives
|
||||
// Common representation for directives that begin multi-line constructs
|
||||
struct OpenMPConstructDirective {
|
||||
BOILERPLATE(OpenMPConstructDirective);
|
||||
explicit OpenMPConstructDirective(OmpClauseList &&list)
|
||||
@@ -3480,7 +3480,7 @@ struct OpenMPSectionsConstruct {
|
||||
|
||||
struct OpenMPParallelSectionsConstruct {
|
||||
TUPLE_CLASS_BOILERPLATE(OpenMPParallelSectionsConstruct);
|
||||
std::tuple<OmpClauseList, Block, OmpEndParallelSections> t;
|
||||
std::tuple<OpenMPConstructDirective, Block, OmpEndParallelSections> t;
|
||||
};
|
||||
|
||||
// WORKSHARE
|
||||
@@ -3497,13 +3497,13 @@ struct OpenMPSingleConstruct {
|
||||
std::tuple<OmpClauseList, Block, OmpEndSingle> t;
|
||||
};
|
||||
|
||||
// OpenMP directive enclosing block
|
||||
// OpenMP directive beginning a block
|
||||
struct OmpBlockDirective {
|
||||
UNION_CLASS_BOILERPLATE(OmpBlockDirective);
|
||||
EMPTY_CLASS(Master);
|
||||
EMPTY_CLASS(Ordered);
|
||||
EMPTY_CLASS(ParallelWorkshare);
|
||||
EMPTY_CLASS(Parallel);
|
||||
EMPTY_CLASS(ParallelWorkshare);
|
||||
EMPTY_CLASS(TargetData);
|
||||
EMPTY_CLASS(TargetParallel);
|
||||
EMPTY_CLASS(TargetTeams);
|
||||
@@ -3546,7 +3546,7 @@ struct OmpReductionCombiner {
|
||||
std::variant<AssignmentStmt, FunctionCombiner> u;
|
||||
};
|
||||
|
||||
WRAPPER_CLASS(OmpReductionInitializerClause, common::Indirection<Expr>);
|
||||
WRAPPER_CLASS(OmpReductionInitializerClause, Expr);
|
||||
|
||||
struct OpenMPDeclareReductionConstruct {
|
||||
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareReductionConstruct);
|
||||
@@ -3703,16 +3703,14 @@ struct OmpStandaloneDirective {
|
||||
EMPTY_CLASS(OpenMPTaskyieldConstruct);
|
||||
EMPTY_CLASS(OpenMPTaskwaitConstruct);
|
||||
EMPTY_CLASS(OpenMPBarrierConstruct);
|
||||
WRAPPER_CLASS(OmpEndBlockDirective, common::Indirection<OmpBlockDirective>);
|
||||
WRAPPER_CLASS(OmpEndBlockDirective, OmpBlockDirective);
|
||||
|
||||
// DO / DO SIMD
|
||||
WRAPPER_CLASS(OmpEndDoSimd, std::optional<OmpNowait>);
|
||||
WRAPPER_CLASS(OmpEndDo, std::optional<OmpNowait>);
|
||||
struct OpenMPEndLoopDirective {
|
||||
UNION_CLASS_BOILERPLATE(OpenMPEndLoopDirective);
|
||||
std::variant<common::Indirection<OmpEndDoSimd>, common::Indirection<OmpEndDo>,
|
||||
common::Indirection<OmpLoopDirective>>
|
||||
u;
|
||||
std::variant<OmpEndDoSimd, OmpEndDo, OmpLoopDirective> u;
|
||||
};
|
||||
|
||||
struct OpenMPBlockConstruct {
|
||||
@@ -3732,21 +3730,13 @@ struct OpenMPStandaloneConstruct {
|
||||
|
||||
struct OpenMPConstruct {
|
||||
UNION_CLASS_BOILERPLATE(OpenMPConstruct);
|
||||
std::variant<common::Indirection<OpenMPStandaloneConstruct>,
|
||||
common::Indirection<OpenMPBarrierConstruct>,
|
||||
common::Indirection<OpenMPTaskwaitConstruct>,
|
||||
common::Indirection<OpenMPTaskyieldConstruct>,
|
||||
common::Indirection<OpenMPSingleConstruct>,
|
||||
common::Indirection<OpenMPSectionsConstruct>,
|
||||
common::Indirection<OpenMPParallelSectionsConstruct>,
|
||||
common::Indirection<OpenMPWorkshareConstruct>,
|
||||
common::Indirection<OpenMPLoopConstruct>,
|
||||
common::Indirection<OpenMPBlockConstruct>,
|
||||
common::Indirection<OpenMPCancellationPointConstruct>,
|
||||
common::Indirection<OpenMPCancelConstruct>,
|
||||
common::Indirection<OpenMPFlushConstruct>,
|
||||
common::Indirection<OpenMPAtomicConstruct>,
|
||||
common::Indirection<OpenMPCriticalConstruct>, OmpSection>
|
||||
std::variant<OpenMPStandaloneConstruct, OpenMPBarrierConstruct,
|
||||
OpenMPTaskwaitConstruct, OpenMPTaskyieldConstruct, OpenMPSingleConstruct,
|
||||
OpenMPSectionsConstruct, OpenMPParallelSectionsConstruct,
|
||||
OpenMPWorkshareConstruct, OpenMPLoopConstruct, OpenMPBlockConstruct,
|
||||
OpenMPCancellationPointConstruct, OpenMPCancelConstruct,
|
||||
OpenMPFlushConstruct, OpenMPAtomicConstruct, OpenMPCriticalConstruct,
|
||||
OmpSection>
|
||||
u;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1809,7 +1809,7 @@ public:
|
||||
Put(")");
|
||||
}
|
||||
void Unparse(const OmpDependSinkVecLength &x) {
|
||||
Walk(std::get<common::Indirection<DefinedOperator>>(x.t));
|
||||
Walk(std::get<DefinedOperator>(x.t));
|
||||
Walk(std::get<ScalarIntConstantExpr>(x.t));
|
||||
}
|
||||
void Unparse(const OmpDependSinkVec &x) {
|
||||
@@ -2292,7 +2292,7 @@ public:
|
||||
void Unparse(const OpenMPParallelSectionsConstruct &x) {
|
||||
BeginOpenMP();
|
||||
Word("!$OMP PARALLEL SECTIONS");
|
||||
Walk(std::get<OmpClauseList>(x.t));
|
||||
Walk(std::get<OpenMPConstructDirective>(x.t));
|
||||
Put("\n");
|
||||
EndOpenMP();
|
||||
Walk(std::get<Block>(x.t), "");
|
||||
|
||||
Reference in New Issue
Block a user