diff options
Diffstat (limited to 'flang/lib/Parser/unparse.cpp')
-rw-r--r-- | flang/lib/Parser/unparse.cpp | 120 |
1 files changed, 33 insertions, 87 deletions
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index fc15d46..44f31ca 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2250,6 +2250,11 @@ public: Walk(std::get<OmpObjectList>(x.t)); Walk(": ", std::get<std::optional<std::list<Modifier>>>(x.t)); } + void Unparse(const OmpEnterClause &x) { + using Modifier = OmpEnterClause::Modifier; + Walk(std::get<std::optional<std::list<Modifier>>>(x.t), ": "); + Walk(std::get<OmpObjectList>(x.t)); + } void Unparse(const OmpFromClause &x) { using Modifier = OmpFromClause::Modifier; Walk(std::get<std::optional<std::list<Modifier>>>(x.t), ": "); @@ -2508,87 +2513,39 @@ public: } } void Unparse(const OmpObjectList &x) { Walk(x.v, ","); } - void Unparse(const OmpBlockDirective &x) { - switch (x.v) { - case llvm::omp::Directive::OMPD_masked: - Word("MASKED"); - break; - case llvm::omp::Directive::OMPD_master: - Word("MASTER"); - break; - case llvm::omp::Directive::OMPD_ordered: - Word("ORDERED "); - break; - case llvm::omp::Directive::OMPD_parallel_masked: - Word("PARALLEL MASKED"); - break; - case llvm::omp::Directive::OMPD_parallel_master: - Word("PARALLEL MASTER"); - break; - case llvm::omp::Directive::OMPD_parallel_workshare: - Word("PARALLEL WORKSHARE "); - break; - case llvm::omp::Directive::OMPD_parallel: - Word("PARALLEL "); - break; - case llvm::omp::Directive::OMPD_scope: - Word("SCOPE "); - break; - case llvm::omp::Directive::OMPD_single: - Word("SINGLE "); - break; - case llvm::omp::Directive::OMPD_target_data: - Word("TARGET DATA "); - break; - case llvm::omp::Directive::OMPD_target_parallel: - Word("TARGET PARALLEL "); - break; - case llvm::omp::Directive::OMPD_target_teams: - Word("TARGET TEAMS "); - break; - case llvm::omp::Directive::OMPD_target: - Word("TARGET "); - break; - case llvm::omp::Directive::OMPD_taskgroup: - Word("TASKGROUP "); - break; - case llvm::omp::Directive::OMPD_task: - Word("TASK "); - break; - case llvm::omp::Directive::OMPD_teams: - Word("TEAMS "); - break; - case llvm::omp::Directive::OMPD_workshare: - Word("WORKSHARE "); - break; - default: - // Nothing to be done - break; - } - } void Unparse(const common::OmpMemoryOrderType &x) { Word(ToUpperCaseLetters(common::EnumToString(x))); } - template <typename Construct> void UnparseBlockConstruct(const Construct &x) { + void Unparse(const OmpBeginDirective &x) { BeginOpenMP(); Word("!$OMP "); - Walk(std::get<OmpDirectiveSpecification>(x.t)); + Walk(static_cast<const OmpDirectiveSpecification &>(x)); + Put("\n"); + EndOpenMP(); + } + + void Unparse(const OmpEndDirective &x) { + BeginOpenMP(); + Word("!$OMP END "); + Walk(static_cast<const OmpDirectiveSpecification &>(x)); Put("\n"); EndOpenMP(); + } + + void Unparse(const OmpBlockConstruct &x) { + Walk(std::get<OmpBeginDirective>(x.t)); Walk(std::get<Block>(x.t), ""); - if (auto &end{std::get<std::optional<OmpDirectiveSpecification>>(x.t)}) { - BeginOpenMP(); - Word("!$OMP END "); + if (auto &end{std::get<std::optional<OmpEndDirective>>(x.t)}) { Walk(*end); + } else { Put("\n"); - EndOpenMP(); } } void Unparse(const OpenMPAtomicConstruct &x) { // - UnparseBlockConstruct(x); + Unparse(static_cast<const OmpBlockConstruct &>(x)); } void Unparse(const OpenMPExecutableAllocate &x) { @@ -2619,7 +2576,7 @@ public: EndOpenMP(); } void Unparse(const OpenMPAllocatorsConstruct &x) { // - UnparseBlockConstruct(x); + Unparse(static_cast<const OmpBlockConstruct &>(x)); } void Unparse(const OmpAssumeDirective &x) { BeginOpenMP(); @@ -2759,7 +2716,7 @@ public: EndOpenMP(); } void Unparse(const OpenMPDispatchConstruct &x) { // - UnparseBlockConstruct(x); + Unparse(static_cast<const OmpBlockConstruct &>(x)); } void Unparse(const OpenMPRequiresConstruct &y) { BeginOpenMP(); @@ -2801,16 +2758,16 @@ public: break; } } - void Unparse(const OmpSectionBlocks &x) { - for (const auto &y : x.v) { + void Unparse(const OpenMPSectionConstruct &x) { + if (auto &&dirSpec{ + std::get<std::optional<OmpDirectiveSpecification>>(x.t)}) { BeginOpenMP(); - Word("!$OMP SECTION"); + Word("!$OMP "); + Walk(*dirSpec); Put("\n"); EndOpenMP(); - // y.u is an OpenMPSectionConstruct - // (y.u).v is Block - Walk(std::get<OpenMPSectionConstruct>(y.u).v, ""); } + Walk(std::get<Block>(x.t), ""); } void Unparse(const OpenMPSectionsConstruct &x) { BeginOpenMP(); @@ -2818,7 +2775,7 @@ public: Walk(std::get<OmpBeginSectionsDirective>(x.t)); Put("\n"); EndOpenMP(); - Walk(std::get<OmpSectionBlocks>(x.t)); + Walk(std::get<std::list<OpenMPConstruct>>(x.t), ""); BeginOpenMP(); Word("!$OMP END "); Walk(std::get<OmpEndSectionsDirective>(x.t)); @@ -2892,19 +2849,7 @@ public: EndOpenMP(); } void Unparse(const OpenMPBlockConstruct &x) { - BeginOpenMP(); - Word("!$OMP "); - Walk(std::get<OmpBeginBlockDirective>(x.t)); - Put("\n"); - EndOpenMP(); - Walk(std::get<Block>(x.t), ""); - if (auto &&end{std::get<std::optional<OmpEndBlockDirective>>(x.t)}) { - BeginOpenMP(); - Word("!$OMP END "); - Walk(*end); - Put("\n"); - EndOpenMP(); - } + Unparse(static_cast<const OmpBlockConstruct &>(x)); } void Unparse(const OpenMPLoopConstruct &x) { BeginOpenMP(); @@ -2986,6 +2931,7 @@ public: WALK_NESTED_ENUM(UseStmt, ModuleNature) // R1410 WALK_NESTED_ENUM(OmpAdjustArgsClause::OmpAdjustOp, Value) // OMP adjustop WALK_NESTED_ENUM(OmpAtClause, ActionTime) // OMP at + WALK_NESTED_ENUM(OmpAutomapModifier, Value) // OMP automap-modifier WALK_NESTED_ENUM(OmpBindClause, Binding) // OMP bind WALK_NESTED_ENUM(OmpProcBindClause, AffinityPolicy) // OMP proc_bind WALK_NESTED_ENUM(OmpDefaultClause, DataSharingAttribute) // OMP default |