13#ifndef FORTRAN_PARSER_OPENMP_UTILS_H
14#define FORTRAN_PARSER_OPENMP_UTILS_H
16#include "flang/Common/indirection.h"
17#include "flang/Parser/parse-tree.h"
18#include "llvm/Frontend/OpenMP/OMP.h"
27namespace Fortran::parser::omp {
29template <
typename T>
constexpr auto addr_if(std::optional<T> &x) {
30 return x ? &*x :
nullptr;
32template <
typename T>
constexpr auto addr_if(
const std::optional<T> &x) {
33 return x ? &*x :
nullptr;
39 llvm::omp::Directive
id = llvm::omp::Directive::OMPD_unknown) {
55 if (
auto &spec{std::get<std::optional<OmpDirectiveSpecification>>(x.t)}) {
56 return spec->DirName();
58 return MakeName({}, llvm::omp::Directive::OMPD_section);
69 if constexpr (WrapperTrait<T>) {
70 if constexpr (std::is_same_v<T, OpenMPCancelConstruct> ||
71 std::is_same_v<T, OpenMPCancellationPointConstruct> ||
72 std::is_same_v<T, OpenMPDepobjConstruct> ||
73 std::is_same_v<T, OpenMPFlushConstruct> ||
74 std::is_same_v<T, OpenMPInteropConstruct> ||
75 std::is_same_v<T, OpenMPSimpleStandaloneConstruct> ||
76 std::is_same_v<T, OpenMPGroupprivate>) {
79 return GetOmpDirectiveName(x.v);
81 }
else if constexpr (TupleTrait<T>) {
82 if constexpr (std::is_base_of_v<OmpBlockConstruct, T>) {
83 return std::get<OmpBeginDirective>(x.t).DirName();
86 x.t, std::make_index_sequence<std::tuple_size_v<
decltype(x.t)>>{});
88 }
else if constexpr (UnionTrait<T>) {
90 [](
auto &&s) {
return GetOmpDirectiveName(s); }, x.u);
96 template <
typename... Ts,
size_t... Is>
98 const std::tuple<Ts...> &t, std::index_sequence<Is...>) {
101 if (name.v == llvm::omp::Directive::OMPD_unknown) {
105 n.v == llvm::omp::Directive::OMPD_unknown &&
"Conflicting names");
108 (accumulate(GetOmpDirectiveName(std::get<Is>(t))), ...);
112 template <
typename T>
114 return GetOmpDirectiveName(x.value());
120 return detail::DirectiveNameScope::GetOmpDirectiveName(x);
131 static constexpr bool value{
false};
134 static constexpr bool value{
true};
144 for (
const OmpArgument &arg : spec.Arguments().v) {
145 if (
auto *t{std::get_if<T>(&arg.u)}) {
152const BlockConstruct *GetFortranBlockConstruct(
153 const ExecutionPartConstruct &epc);
154const Block &GetInnermostExecPart(
const Block &block);
155bool IsStrictlyStructuredBlock(
const Block &block);
157const OmpCombinerExpression *GetCombinerExpr(
158 const OmpReductionSpecifier &rspec);
159const OmpInitializerExpression *GetInitializerExpr(
const OmpClause &init);
162 std::vector<const OmpAllocateDirective *> dirs;
Definition indirection.h:31
Definition char-block.h:28
Definition parse-tree.h:433
Definition parse-tree.h:2342
Definition parse-tree.h:548
Definition parse-tree.h:5200
Definition parse-tree.h:5337
Definition parse-tree.h:5065
Definition parse-tree.h:4949
Definition parse-tree.h:3504
Definition parse-tree.h:4972
Definition parse-tree.h:3549
Definition parse-tree.h:5372
Definition parse-tree.h:5204
Definition parse-tree.h:5346
Definition parse-tree.h:5079
Definition parse-tree.h:357
Definition parse-tree.h:3668
Definition openmp-utils.h:130
Definition openmp-utils.h:161
Definition openmp-utils.h:37