File tree Expand file tree Collapse file tree 5 files changed +32
-30
lines changed
Expand file tree Collapse file tree 5 files changed +32
-30
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ const T *GetFirstArgument(const OmpDirectiveSpecification &spec) {
137137
138138const BlockConstruct *GetFortranBlockConstruct (
139139 const ExecutionPartConstruct &epc);
140+ const Block &GetInnermostExecPart (const Block &block);
141+ bool IsStrictlyStructuredBlock (const Block &block);
140142
141143const OmpCombinerExpression *GetCombinerExpr (
142144 const OmpReductionSpecifier &rspec);
Original file line number Diff line number Diff line change @@ -97,8 +97,6 @@ const SomeExpr *HasStorageOverlap(
9797 const SomeExpr &base, llvm::ArrayRef<SomeExpr> exprs);
9898bool IsAssignment (const parser::ActionStmt *x);
9999bool IsPointerAssignment (const evaluate::Assignment &x);
100- const parser::Block &GetInnermostExecPart (const parser::Block &block);
101- bool IsStrictlyStructuredBlock (const parser::Block &block);
102100} // namespace omp
103101} // namespace Fortran::semantics
104102
Original file line number Diff line number Diff line change @@ -93,6 +93,34 @@ const BlockConstruct *GetFortranBlockConstruct(
9393 return nullptr ;
9494}
9595
96+ // / parser::Block is a list of executable constructs, parser::BlockConstruct
97+ // / is Fortran's BLOCK/ENDBLOCK construct.
98+ // / Strip the outermost BlockConstructs, return the reference to the Block
99+ // / in the executable part of the innermost of the stripped constructs.
100+ // / Specifically, if the given `block` has a single entry (it's a list), and
101+ // / the entry is a BlockConstruct, get the Block contained within. Repeat
102+ // / this step as many times as possible.
103+ const Block &GetInnermostExecPart (const Block &block) {
104+ const Block *iter{&block};
105+ while (iter->size () == 1 ) {
106+ const ExecutionPartConstruct &ep{iter->front ()};
107+ if (auto *bc{GetFortranBlockConstruct (ep)}) {
108+ iter = &std::get<Block>(bc->t );
109+ } else {
110+ break ;
111+ }
112+ }
113+ return *iter;
114+ }
115+
116+ bool IsStrictlyStructuredBlock (const Block &block) {
117+ if (block.size () == 1 ) {
118+ return GetFortranBlockConstruct (block.front ()) != nullptr ;
119+ } else {
120+ return false ;
121+ }
122+ }
123+
96124const OmpCombinerExpression *GetCombinerExpr (
97125 const OmpReductionSpecifier &rspec) {
98126 return addr_if (std::get<std::optional<OmpCombinerExpression>>(rspec.t ));
Original file line number Diff line number Diff line change 1919#include " flang/Evaluate/rewrite.h"
2020#include " flang/Evaluate/tools.h"
2121#include " flang/Parser/char-block.h"
22+ #include " flang/Parser/openmp-utils.h"
2223#include " flang/Parser/parse-tree.h"
2324#include " flang/Semantics/openmp-utils.h"
2425#include " flang/Semantics/symbol.h"
4142
4243namespace Fortran ::semantics {
4344
45+ using namespace Fortran ::parser::omp;
4446using namespace Fortran ::semantics::omp;
4547
4648namespace operation = Fortran::evaluate::operation;
Original file line number Diff line number Diff line change @@ -496,32 +496,4 @@ bool IsPointerAssignment(const evaluate::Assignment &x) {
496496 return std::holds_alternative<evaluate::Assignment::BoundsSpec>(x.u ) ||
497497 std::holds_alternative<evaluate::Assignment::BoundsRemapping>(x.u );
498498}
499-
500- // / parser::Block is a list of executable constructs, parser::BlockConstruct
501- // / is Fortran's BLOCK/ENDBLOCK construct.
502- // / Strip the outermost BlockConstructs, return the reference to the Block
503- // / in the executable part of the innermost of the stripped constructs.
504- // / Specifically, if the given `block` has a single entry (it's a list), and
505- // / the entry is a BlockConstruct, get the Block contained within. Repeat
506- // / this step as many times as possible.
507- const parser::Block &GetInnermostExecPart (const parser::Block &block) {
508- const parser::Block *iter{&block};
509- while (iter->size () == 1 ) {
510- const parser::ExecutionPartConstruct &ep{iter->front ()};
511- if (auto *bc{GetFortranBlockConstruct (ep)}) {
512- iter = &std::get<parser::Block>(bc->t );
513- } else {
514- break ;
515- }
516- }
517- return *iter;
518- }
519-
520- bool IsStrictlyStructuredBlock (const parser::Block &block) {
521- if (block.size () == 1 ) {
522- return GetFortranBlockConstruct (block.front ()) != nullptr ;
523- } else {
524- return false ;
525- }
526- }
527499} // namespace Fortran::semantics::omp
You can’t perform that action at this time.
0 commit comments