| 1 |
//===-- lib/Parser/openmp-parsers.cpp -------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// Top-level grammar specification for OpenMP. |
| 10 |
// See OpenMP-4.5-grammar.txt for documentation. |
| 11 |
|
| 12 |
#include "basic-parsers.h" |
| 13 |
#include "expr-parsers.h" |
| 14 |
#include "misc-parsers.h" |
| 15 |
#include "stmt-parser.h" |
| 16 |
#include "token-parsers.h" |
| 17 |
#include "type-parser-implementation.h" |
| 18 |
#include "flang/Parser/parse-tree.h" |
| 19 |
|
| 20 |
// OpenMP Directives and Clauses |
| 21 |
namespace Fortran::parser { |
| 22 |
|
| 23 |
constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok; |
| 24 |
constexpr auto endOmpLine = space >> endOfLine; |
| 25 |
|
| 26 |
// OpenMP Clauses |
| 27 |
// 2.15.3.1 DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE) |
| 28 |
TYPE_PARSER(construct<OmpDefaultClause>( |
| 29 |
"PRIVATE" >> pure(OmpDefaultClause::Type::Private) || |
| 30 |
"FIRSTPRIVATE" >> pure(OmpDefaultClause::Type::Firstprivate) || |
| 31 |
"SHARED" >> pure(OmpDefaultClause::Type::Shared) || |
| 32 |
"NONE" >> pure(OmpDefaultClause::Type::None))) |
| 33 |
|
| 34 |
// 2.5 PROC_BIND (MASTER | CLOSE | PRIMARY | SPREAD ) |
| 35 |
TYPE_PARSER(construct<OmpProcBindClause>( |
| 36 |
"CLOSE" >> pure(OmpProcBindClause::Type::Close) || |
| 37 |
"MASTER" >> pure(OmpProcBindClause::Type::Master) || |
| 38 |
"PRIMARY" >> pure(OmpProcBindClause::Type::Primary) || |
| 39 |
"SPREAD" >> pure(OmpProcBindClause::Type::Spread))) |
| 40 |
|
| 41 |
// 2.15.5.1 MAP ([ [ALWAYS[,]] map-type : ] variable-name-list) |
| 42 |
// map-type -> TO | FROM | TOFROM | ALLOC | RELEASE | DELETE |
| 43 |
TYPE_PARSER(construct<OmpMapType>( |
| 44 |
maybe("ALWAYS" >> construct<OmpMapType::Always>() / maybe(","_tok)), |
| 45 |
("TO"_id >> pure(OmpMapType::Type::To) || |
| 46 |
"FROM" >> pure(OmpMapType::Type::From) || |
| 47 |
"TOFROM" >> pure(OmpMapType::Type::Tofrom) || |
| 48 |
"ALLOC" >> pure(OmpMapType::Type::Alloc) || |
| 49 |
"RELEASE" >> pure(OmpMapType::Type::Release) || |
| 50 |
"DELETE" >> pure(OmpMapType::Type::Delete)) / |
| 51 |
":")) |
| 52 |
|
| 53 |
TYPE_PARSER(construct<OmpMapClause>( |
| 54 |
maybe(Parser<OmpMapType>{}), Parser<OmpObjectList>{})) |
| 55 |
|
| 56 |
// [OpenMP 5.0] |
| 57 |
// 2.19.7.2 defaultmap(implicit-behavior[:variable-category]) |
| 58 |
// implicit-behavior -> ALLOC | TO | FROM | TOFROM | FIRSRTPRIVATE | NONE | |
| 59 |
// DEFAULT |
| 60 |
// variable-category -> SCALAR | AGGREGATE | ALLOCATABLE | POINTER |
| 61 |
TYPE_PARSER(construct<OmpDefaultmapClause>( |
| 62 |
construct<OmpDefaultmapClause::ImplicitBehavior>( |
| 63 |
"ALLOC" >> pure(OmpDefaultmapClause::ImplicitBehavior::Alloc) || |
| 64 |
"TO"_id >> pure(OmpDefaultmapClause::ImplicitBehavior::To) || |
| 65 |
"FROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::From) || |
| 66 |
"TOFROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::Tofrom) || |
| 67 |
"FIRSTPRIVATE" >> |
| 68 |
pure(OmpDefaultmapClause::ImplicitBehavior::Firstprivate) || |
| 69 |
"NONE" >> pure(OmpDefaultmapClause::ImplicitBehavior::None) || |
| 70 |
"DEFAULT" >> pure(OmpDefaultmapClause::ImplicitBehavior::Default)), |
| 71 |
maybe(":" >> |
| 72 |
construct<OmpDefaultmapClause::VariableCategory>( |
| 73 |
"SCALAR" >> pure(OmpDefaultmapClause::VariableCategory::Scalar) || |
| 74 |
"AGGREGATE" >> |
| 75 |
pure(OmpDefaultmapClause::VariableCategory::Aggregate) || |
| 76 |
"ALLOCATABLE" >> |
| 77 |
pure(OmpDefaultmapClause::VariableCategory::Allocatable) || |
| 78 |
"POINTER" >> |
| 79 |
pure(OmpDefaultmapClause::VariableCategory::Pointer))))) |
| 80 |
|
| 81 |
// 2.7.1 SCHEDULE ([modifier1 [, modifier2]:]kind[, chunk_size]) |
| 82 |
// Modifier -> MONITONIC | NONMONOTONIC | SIMD |
| 83 |
// kind -> STATIC | DYNAMIC | GUIDED | AUTO | RUNTIME |
| 84 |
// chunk_size -> ScalarIntExpr |
| 85 |
TYPE_PARSER(construct<OmpScheduleModifierType>( |
| 86 |
"MONOTONIC" >> pure(OmpScheduleModifierType::ModType::Monotonic) || |
| 87 |
"NONMONOTONIC" >> pure(OmpScheduleModifierType::ModType::Nonmonotonic) || |
| 88 |
"SIMD" >> pure(OmpScheduleModifierType::ModType::Simd))) |
| 89 |
|
| 90 |
TYPE_PARSER(construct<OmpScheduleModifier>(Parser<OmpScheduleModifierType>{}, |
| 91 |
maybe("," >> Parser<OmpScheduleModifierType>{}) / ":")) |
| 92 |
|
| 93 |
TYPE_PARSER(construct<OmpScheduleClause>(maybe(Parser<OmpScheduleModifier>{}), |
| 94 |
"STATIC" >> pure(OmpScheduleClause::ScheduleType::Static) || |
| 95 |
"DYNAMIC" >> pure(OmpScheduleClause::ScheduleType::Dynamic) || |
| 96 |
"GUIDED" >> pure(OmpScheduleClause::ScheduleType::Guided) || |
| 97 |
"AUTO" >> pure(OmpScheduleClause::ScheduleType::Auto) || |
| 98 |
"RUNTIME" >> pure(OmpScheduleClause::ScheduleType::Runtime), |
| 99 |
maybe("," >> scalarIntExpr))) |
| 100 |
|
| 101 |
// device([ device-modifier :] scalar-integer-expression) |
| 102 |
TYPE_PARSER(construct<OmpDeviceClause>( |
| 103 |
maybe( |
| 104 |
("ANCESTOR" >> pure(OmpDeviceClause::DeviceModifier::Ancestor) || |
| 105 |
"DEVICE_NUM" >> pure(OmpDeviceClause::DeviceModifier::Device_Num)) / |
| 106 |
":"), |
| 107 |
scalarIntExpr)) |
| 108 |
|
| 109 |
// device_type(any | host | nohost) |
| 110 |
TYPE_PARSER(construct<OmpDeviceTypeClause>( |
| 111 |
"ANY" >> pure(OmpDeviceTypeClause::Type::Any) || |
| 112 |
"HOST" >> pure(OmpDeviceTypeClause::Type::Host) || |
| 113 |
"NOHOST" >> pure(OmpDeviceTypeClause::Type::Nohost))) |
| 114 |
|
| 115 |
// 2.12 IF (directive-name-modifier: scalar-logical-expr) |
| 116 |
TYPE_PARSER(construct<OmpIfClause>( |
| 117 |
maybe( |
| 118 |
("PARALLEL" >> pure(OmpIfClause::DirectiveNameModifier::Parallel) || |
| 119 |
"SIMD" >> pure(OmpIfClause::DirectiveNameModifier::Simd) || |
| 120 |
"TARGET ENTER DATA" >> |
| 121 |
pure(OmpIfClause::DirectiveNameModifier::TargetEnterData) || |
| 122 |
"TARGET EXIT DATA" >> |
| 123 |
pure(OmpIfClause::DirectiveNameModifier::TargetExitData) || |
| 124 |
"TARGET DATA" >> |
| 125 |
pure(OmpIfClause::DirectiveNameModifier::TargetData) || |
| 126 |
"TARGET UPDATE" >> |
| 127 |
pure(OmpIfClause::DirectiveNameModifier::TargetUpdate) || |
| 128 |
"TARGET" >> pure(OmpIfClause::DirectiveNameModifier::Target) || |
| 129 |
"TASK"_id >> pure(OmpIfClause::DirectiveNameModifier::Task) || |
| 130 |
"TASKLOOP" >> pure(OmpIfClause::DirectiveNameModifier::Taskloop) || |
| 131 |
"TEAMS" >> pure(OmpIfClause::DirectiveNameModifier::Teams)) / |
| 132 |
":"), |
| 133 |
scalarLogicalExpr)) |
| 134 |
|
| 135 |
// 2.15.3.6 REDUCTION (reduction-identifier: variable-name-list) |
| 136 |
TYPE_PARSER(construct<OmpReductionOperator>(Parser<DefinedOperator>{}) || |
| 137 |
construct<OmpReductionOperator>(Parser<ProcedureDesignator>{})) |
| 138 |
|
| 139 |
TYPE_PARSER(construct<OmpReductionClause>( |
| 140 |
maybe( |
| 141 |
("INSCAN" >> pure(OmpReductionClause::ReductionModifier::Inscan) || |
| 142 |
"TASK" >> pure(OmpReductionClause::ReductionModifier::Task) || |
| 143 |
"DEFAULT" >> pure(OmpReductionClause::ReductionModifier::Default)) / |
| 144 |
","), |
| 145 |
Parser<OmpReductionOperator>{} / ":", Parser<OmpObjectList>{})) |
| 146 |
|
| 147 |
// OMP 5.0 2.19.5.6 IN_REDUCTION (reduction-identifier: variable-name-list) |
| 148 |
TYPE_PARSER(construct<OmpInReductionClause>( |
| 149 |
Parser<OmpReductionOperator>{} / ":", Parser<OmpObjectList>{})) |
| 150 |
|
| 151 |
// OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list) |
| 152 |
// OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier |
| 153 |
// [, allocate-modifier] :] |
| 154 |
// variable-name-list) |
| 155 |
// allocate-modifier -> allocator | align |
| 156 |
TYPE_PARSER(construct<OmpAllocateClause>( |
| 157 |
maybe( |
| 158 |
first( |
| 159 |
construct<OmpAllocateClause::AllocateModifier>("ALLOCATOR" >> |
| 160 |
construct<OmpAllocateClause::AllocateModifier::ComplexModifier>( |
| 161 |
parenthesized(construct< |
| 162 |
OmpAllocateClause::AllocateModifier::Allocator>( |
| 163 |
scalarIntExpr)) / |
| 164 |
",", |
| 165 |
"ALIGN" >> parenthesized(construct< |
| 166 |
OmpAllocateClause::AllocateModifier::Align>( |
| 167 |
scalarIntExpr)))), |
| 168 |
construct<OmpAllocateClause::AllocateModifier>("ALLOCATOR" >> |
| 169 |
parenthesized( |
| 170 |
construct<OmpAllocateClause::AllocateModifier::Allocator>( |
| 171 |
scalarIntExpr))), |
| 172 |
construct<OmpAllocateClause::AllocateModifier>("ALIGN" >> |
| 173 |
parenthesized( |
| 174 |
construct<OmpAllocateClause::AllocateModifier::Align>( |
| 175 |
scalarIntExpr))), |
| 176 |
construct<OmpAllocateClause::AllocateModifier>( |
| 177 |
construct<OmpAllocateClause::AllocateModifier::Allocator>( |
| 178 |
scalarIntExpr))) / |
| 179 |
":"), |
| 180 |
Parser<OmpObjectList>{})) |
| 181 |
|
| 182 |
// 2.13.9 DEPEND (SOURCE | SINK : vec | (IN | OUT | INOUT) : list |
| 183 |
TYPE_PARSER(construct<OmpDependSinkVecLength>( |
| 184 |
Parser<DefinedOperator>{}, scalarIntConstantExpr)) |
| 185 |
|
| 186 |
TYPE_PARSER( |
| 187 |
construct<OmpDependSinkVec>(name, maybe(Parser<OmpDependSinkVecLength>{}))) |
| 188 |
|
| 189 |
TYPE_PARSER( |
| 190 |
construct<OmpDependenceType>("IN"_id >> pure(OmpDependenceType::Type::In) || |
| 191 |
"INOUT" >> pure(OmpDependenceType::Type::Inout) || |
| 192 |
"OUT" >> pure(OmpDependenceType::Type::Out))) |
| 193 |
|
| 194 |
TYPE_CONTEXT_PARSER("Omp Depend clause"_en_US, |
| 195 |
construct<OmpDependClause>(construct<OmpDependClause::Sink>( |
| 196 |
"SINK :" >> nonemptyList(Parser<OmpDependSinkVec>{}))) || |
| 197 |
construct<OmpDependClause>( |
| 198 |
construct<OmpDependClause::Source>("SOURCE"_tok)) || |
| 199 |
construct<OmpDependClause>(construct<OmpDependClause::InOut>( |
| 200 |
Parser<OmpDependenceType>{}, ":" >> nonemptyList(designator)))) |
| 201 |
|
| 202 |
// 2.15.3.7 LINEAR (linear-list: linear-step) |
| 203 |
// linear-list -> list | modifier(list) |
| 204 |
// linear-modifier -> REF | VAL | UVAL |
| 205 |
TYPE_PARSER( |
| 206 |
construct<OmpLinearModifier>("REF" >> pure(OmpLinearModifier::Type::Ref) || |
| 207 |
"VAL" >> pure(OmpLinearModifier::Type::Val) || |
| 208 |
"UVAL" >> pure(OmpLinearModifier::Type::Uval))) |
| 209 |
|
| 210 |
TYPE_CONTEXT_PARSER("Omp LINEAR clause"_en_US, |
| 211 |
construct<OmpLinearClause>( |
| 212 |
construct<OmpLinearClause>(construct<OmpLinearClause::WithModifier>( |
| 213 |
Parser<OmpLinearModifier>{}, parenthesized(nonemptyList(name)), |
| 214 |
maybe(":" >> scalarIntConstantExpr))) || |
| 215 |
construct<OmpLinearClause>(construct<OmpLinearClause::WithoutModifier>( |
| 216 |
nonemptyList(name), maybe(":" >> scalarIntConstantExpr))))) |
| 217 |
|
| 218 |
// 2.8.1 ALIGNED (list: alignment) |
| 219 |
TYPE_PARSER(construct<OmpAlignedClause>( |
| 220 |
Parser<OmpObjectList>{}, maybe(":" >> scalarIntConstantExpr))) |
| 221 |
|
| 222 |
// 2.9.5 ORDER ([order-modifier :]concurrent) |
| 223 |
TYPE_PARSER(construct<OmpOrderModifier>( |
| 224 |
"REPRODUCIBLE" >> pure(OmpOrderModifier::Kind::Reproducible)) || |
| 225 |
construct<OmpOrderModifier>( |
| 226 |
"UNCONSTRAINED" >> pure(OmpOrderModifier::Kind::Unconstrained))) |
| 227 |
|
| 228 |
TYPE_PARSER(construct<OmpOrderClause>( |
| 229 |
maybe(Parser<OmpOrderModifier>{} / ":"), |
| 230 |
"CONCURRENT" >> pure(OmpOrderClause::Type::Concurrent))) |
| 231 |
|
| 232 |
TYPE_PARSER( |
| 233 |
construct<OmpObject>(designator) || construct<OmpObject>("/" >> name / "/")) |
| 234 |
|
| 235 |
TYPE_PARSER( |
| 236 |
"ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) || |
| 237 |
"ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) || |
| 238 |
"ALIGNED" >> construct<OmpClause>(construct<OmpClause::Aligned>( |
| 239 |
parenthesized(Parser<OmpAlignedClause>{}))) || |
| 240 |
"ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>( |
| 241 |
parenthesized(Parser<OmpAllocateClause>{}))) || |
| 242 |
"ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>( |
| 243 |
parenthesized(scalarIntExpr))) || |
| 244 |
"ATOMIC_DEFAULT_MEM_ORDER" >> |
| 245 |
construct<OmpClause>(construct<OmpClause::AtomicDefaultMemOrder>( |
| 246 |
parenthesized(Parser<OmpAtomicDefaultMemOrderClause>{}))) || |
| 247 |
"COLLAPSE" >> construct<OmpClause>(construct<OmpClause::Collapse>( |
| 248 |
parenthesized(scalarIntConstantExpr))) || |
| 249 |
"COPYIN" >> construct<OmpClause>(construct<OmpClause::Copyin>( |
| 250 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 251 |
"COPYPRIVATE" >> construct<OmpClause>(construct<OmpClause::Copyprivate>( |
| 252 |
(parenthesized(Parser<OmpObjectList>{})))) || |
| 253 |
"DEFAULT"_id >> construct<OmpClause>(construct<OmpClause::Default>( |
| 254 |
parenthesized(Parser<OmpDefaultClause>{}))) || |
| 255 |
"DEFAULTMAP" >> construct<OmpClause>(construct<OmpClause::Defaultmap>( |
| 256 |
parenthesized(Parser<OmpDefaultmapClause>{}))) || |
| 257 |
"DEPEND" >> construct<OmpClause>(construct<OmpClause::Depend>( |
| 258 |
parenthesized(Parser<OmpDependClause>{}))) || |
| 259 |
"DEVICE" >> construct<OmpClause>(construct<OmpClause::Device>( |
| 260 |
parenthesized(Parser<OmpDeviceClause>{}))) || |
| 261 |
"DEVICE_TYPE" >> construct<OmpClause>(construct<OmpClause::DeviceType>( |
| 262 |
parenthesized(Parser<OmpDeviceTypeClause>{}))) || |
| 263 |
"DIST_SCHEDULE" >> |
| 264 |
construct<OmpClause>(construct<OmpClause::DistSchedule>( |
| 265 |
parenthesized("STATIC" >> maybe("," >> scalarIntExpr)))) || |
| 266 |
"DYNAMIC_ALLOCATORS" >> |
| 267 |
construct<OmpClause>(construct<OmpClause::DynamicAllocators>()) || |
| 268 |
"ENTER" >> construct<OmpClause>(construct<OmpClause::Enter>( |
| 269 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 270 |
"FILTER" >> construct<OmpClause>(construct<OmpClause::Filter>( |
| 271 |
parenthesized(scalarIntExpr))) || |
| 272 |
"FINAL" >> construct<OmpClause>(construct<OmpClause::Final>( |
| 273 |
parenthesized(scalarLogicalExpr))) || |
| 274 |
"FULL" >> construct<OmpClause>(construct<OmpClause::Full>()) || |
| 275 |
"FIRSTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Firstprivate>( |
| 276 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 277 |
"FROM" >> construct<OmpClause>(construct<OmpClause::From>( |
| 278 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 279 |
"GRAINSIZE" >> construct<OmpClause>(construct<OmpClause::Grainsize>( |
| 280 |
parenthesized(scalarIntExpr))) || |
| 281 |
"HAS_DEVICE_ADDR" >> |
| 282 |
construct<OmpClause>(construct<OmpClause::HasDeviceAddr>( |
| 283 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 284 |
"HINT" >> construct<OmpClause>( |
| 285 |
construct<OmpClause::Hint>(parenthesized(constantExpr))) || |
| 286 |
"IF" >> construct<OmpClause>(construct<OmpClause::If>( |
| 287 |
parenthesized(Parser<OmpIfClause>{}))) || |
| 288 |
"INBRANCH" >> construct<OmpClause>(construct<OmpClause::Inbranch>()) || |
| 289 |
"IS_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::IsDevicePtr>( |
| 290 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 291 |
"LASTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Lastprivate>( |
| 292 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 293 |
"LINEAR" >> construct<OmpClause>(construct<OmpClause::Linear>( |
| 294 |
parenthesized(Parser<OmpLinearClause>{}))) || |
| 295 |
"LINK" >> construct<OmpClause>(construct<OmpClause::Link>( |
| 296 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 297 |
"MAP" >> construct<OmpClause>(construct<OmpClause::Map>( |
| 298 |
parenthesized(Parser<OmpMapClause>{}))) || |
| 299 |
"MERGEABLE" >> construct<OmpClause>(construct<OmpClause::Mergeable>()) || |
| 300 |
"NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) || |
| 301 |
"NONTEMPORAL" >> construct<OmpClause>(construct<OmpClause::Nontemporal>( |
| 302 |
parenthesized(nonemptyList(name)))) || |
| 303 |
"NOTINBRANCH" >> |
| 304 |
construct<OmpClause>(construct<OmpClause::Notinbranch>()) || |
| 305 |
"NOWAIT" >> construct<OmpClause>(construct<OmpClause::Nowait>()) || |
| 306 |
"NUM_TASKS" >> construct<OmpClause>(construct<OmpClause::NumTasks>( |
| 307 |
parenthesized(scalarIntExpr))) || |
| 308 |
"NUM_TEAMS" >> construct<OmpClause>(construct<OmpClause::NumTeams>( |
| 309 |
parenthesized(scalarIntExpr))) || |
| 310 |
"NUM_THREADS" >> construct<OmpClause>(construct<OmpClause::NumThreads>( |
| 311 |
parenthesized(scalarIntExpr))) || |
| 312 |
"ORDER" >> construct<OmpClause>(construct<OmpClause::Order>( |
| 313 |
parenthesized(Parser<OmpOrderClause>{}))) || |
| 314 |
"ORDERED" >> construct<OmpClause>(construct<OmpClause::Ordered>( |
| 315 |
maybe(parenthesized(scalarIntConstantExpr)))) || |
| 316 |
"PARTIAL" >> construct<OmpClause>(construct<OmpClause::Partial>( |
| 317 |
maybe(parenthesized(scalarIntConstantExpr)))) || |
| 318 |
"PRIORITY" >> construct<OmpClause>(construct<OmpClause::Priority>( |
| 319 |
parenthesized(scalarIntExpr))) || |
| 320 |
"PRIVATE" >> construct<OmpClause>(construct<OmpClause::Private>( |
| 321 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 322 |
"PROC_BIND" >> construct<OmpClause>(construct<OmpClause::ProcBind>( |
| 323 |
parenthesized(Parser<OmpProcBindClause>{}))) || |
| 324 |
"REDUCTION" >> construct<OmpClause>(construct<OmpClause::Reduction>( |
| 325 |
parenthesized(Parser<OmpReductionClause>{}))) || |
| 326 |
"IN_REDUCTION" >> construct<OmpClause>(construct<OmpClause::InReduction>( |
| 327 |
parenthesized(Parser<OmpInReductionClause>{}))) || |
| 328 |
"TASK_REDUCTION" >> |
| 329 |
construct<OmpClause>(construct<OmpClause::TaskReduction>( |
| 330 |
parenthesized(Parser<OmpReductionClause>{}))) || |
| 331 |
"RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) || |
| 332 |
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) || |
| 333 |
"REVERSE_OFFLOAD" >> |
| 334 |
construct<OmpClause>(construct<OmpClause::ReverseOffload>()) || |
| 335 |
"SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>( |
| 336 |
parenthesized(scalarIntConstantExpr))) || |
| 337 |
"SCHEDULE" >> construct<OmpClause>(construct<OmpClause::Schedule>( |
| 338 |
parenthesized(Parser<OmpScheduleClause>{}))) || |
| 339 |
"SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) || |
| 340 |
"SHARED" >> construct<OmpClause>(construct<OmpClause::Shared>( |
| 341 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 342 |
"SIMD"_id >> construct<OmpClause>(construct<OmpClause::Simd>()) || |
| 343 |
"SIMDLEN" >> construct<OmpClause>(construct<OmpClause::Simdlen>( |
| 344 |
parenthesized(scalarIntConstantExpr))) || |
| 345 |
"SIZES" >> construct<OmpClause>(construct<OmpClause::Sizes>( |
| 346 |
parenthesized(nonemptyList(scalarIntExpr)))) || |
| 347 |
"THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) || |
| 348 |
"THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>( |
| 349 |
parenthesized(scalarIntExpr))) || |
| 350 |
"TO" >> construct<OmpClause>(construct<OmpClause::To>( |
| 351 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 352 |
"USE_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::UseDevicePtr>( |
| 353 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 354 |
"USE_DEVICE_ADDR" >> |
| 355 |
construct<OmpClause>(construct<OmpClause::UseDeviceAddr>( |
| 356 |
parenthesized(Parser<OmpObjectList>{}))) || |
| 357 |
"UNIFIED_ADDRESS" >> |
| 358 |
construct<OmpClause>(construct<OmpClause::UnifiedAddress>()) || |
| 359 |
"UNIFIED_SHARED_MEMORY" >> |
| 360 |
construct<OmpClause>(construct<OmpClause::UnifiedSharedMemory>()) || |
| 361 |
"UNIFORM" >> construct<OmpClause>(construct<OmpClause::Uniform>( |
| 362 |
parenthesized(nonemptyList(name)))) || |
| 363 |
"UNTIED" >> construct<OmpClause>(construct<OmpClause::Untied>())) |
| 364 |
|
| 365 |
// [Clause, [Clause], ...] |
| 366 |
TYPE_PARSER(sourced(construct<OmpClauseList>( |
| 367 |
many(maybe(","_tok) >> sourced(Parser<OmpClause>{}))))) |
| 368 |
|
| 369 |
// 2.1 (variable | /common-block | array-sections) |
| 370 |
TYPE_PARSER(construct<OmpObjectList>(nonemptyList(Parser<OmpObject>{}))) |
| 371 |
|
| 372 |
// Omp directives enclosing do loop |
| 373 |
TYPE_PARSER(sourced(construct<OmpLoopDirective>(first( |
| 374 |
"DISTRIBUTE PARALLEL DO SIMD" >> |
| 375 |
pure(llvm::omp::Directive::OMPD_distribute_parallel_do_simd), |
| 376 |
"DISTRIBUTE PARALLEL DO" >> |
| 377 |
pure(llvm::omp::Directive::OMPD_distribute_parallel_do), |
| 378 |
"DISTRIBUTE SIMD" >> pure(llvm::omp::Directive::OMPD_distribute_simd), |
| 379 |
"DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_distribute), |
| 380 |
"DO SIMD" >> pure(llvm::omp::Directive::OMPD_do_simd), |
| 381 |
"DO" >> pure(llvm::omp::Directive::OMPD_do), |
| 382 |
"LOOP" >> pure(llvm::omp::Directive::OMPD_loop), |
| 383 |
"MASKED TASKLOOP SIMD" >> |
| 384 |
pure(llvm::omp::Directive::OMPD_masked_taskloop_simd), |
| 385 |
"MASKED TASKLOOP" >> pure(llvm::omp::Directive::OMPD_masked_taskloop), |
| 386 |
"PARALLEL DO SIMD" >> pure(llvm::omp::Directive::OMPD_parallel_do_simd), |
| 387 |
"PARALLEL DO" >> pure(llvm::omp::Directive::OMPD_parallel_do), |
| 388 |
"PARALLEL MASKED TASKLOOP SIMD" >> |
| 389 |
pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd), |
| 390 |
"PARALLEL MASKED TASKLOOP" >> |
| 391 |
pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop), |
| 392 |
"SIMD" >> pure(llvm::omp::Directive::OMPD_simd), |
| 393 |
"TARGET LOOP" >> pure(llvm::omp::Directive::OMPD_target_loop), |
| 394 |
"TARGET PARALLEL DO SIMD" >> |
| 395 |
pure(llvm::omp::Directive::OMPD_target_parallel_do_simd), |
| 396 |
"TARGET PARALLEL DO" >> pure(llvm::omp::Directive::OMPD_target_parallel_do), |
| 397 |
"TARGET PARALLEL LOOP" >> |
| 398 |
pure(llvm::omp::Directive::OMPD_target_parallel_loop), |
| 399 |
"TARGET SIMD" >> pure(llvm::omp::Directive::OMPD_target_simd), |
| 400 |
"TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD" >> |
| 401 |
pure(llvm::omp::Directive:: |
| 402 |
OMPD_target_teams_distribute_parallel_do_simd), |
| 403 |
"TARGET TEAMS DISTRIBUTE PARALLEL DO" >> |
| 404 |
pure(llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do), |
| 405 |
"TARGET TEAMS DISTRIBUTE SIMD" >> |
| 406 |
pure(llvm::omp::Directive::OMPD_target_teams_distribute_simd), |
| 407 |
"TARGET TEAMS DISTRIBUTE" >> |
| 408 |
pure(llvm::omp::Directive::OMPD_target_teams_distribute), |
| 409 |
"TARGET TEAMS LOOP" >> pure(llvm::omp::Directive::OMPD_target_teams_loop), |
| 410 |
"TASKLOOP SIMD" >> pure(llvm::omp::Directive::OMPD_taskloop_simd), |
| 411 |
"TASKLOOP" >> pure(llvm::omp::Directive::OMPD_taskloop), |
| 412 |
"TEAMS DISTRIBUTE PARALLEL DO SIMD" >> |
| 413 |
pure(llvm::omp::Directive::OMPD_teams_distribute_parallel_do_simd), |
| 414 |
"TEAMS DISTRIBUTE PARALLEL DO" >> |
| 415 |
pure(llvm::omp::Directive::OMPD_teams_distribute_parallel_do), |
| 416 |
"TEAMS DISTRIBUTE SIMD" >> |
| 417 |
pure(llvm::omp::Directive::OMPD_teams_distribute_simd), |
| 418 |
"TEAMS DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_teams_distribute), |
| 419 |
"TILE" >> pure(llvm::omp::Directive::OMPD_tile), |
| 420 |
"UNROLL" >> pure(llvm::omp::Directive::OMPD_unroll))))) |
| 421 |
|
| 422 |
TYPE_PARSER(sourced(construct<OmpBeginLoopDirective>( |
| 423 |
sourced(Parser<OmpLoopDirective>{}), Parser<OmpClauseList>{}))) |
| 424 |
|
| 425 |
// 2.14.1 construct-type-clause -> PARALLEL | SECTIONS | DO | TASKGROUP |
| 426 |
TYPE_PARSER(sourced(construct<OmpCancelType>( |
| 427 |
first("PARALLEL" >> pure(OmpCancelType::Type::Parallel), |
| 428 |
"SECTIONS" >> pure(OmpCancelType::Type::Sections), |
| 429 |
"DO" >> pure(OmpCancelType::Type::Do), |
| 430 |
"TASKGROUP" >> pure(OmpCancelType::Type::Taskgroup))))) |
| 431 |
|
| 432 |
// 2.14.2 Cancellation Point construct |
| 433 |
TYPE_PARSER(sourced(construct<OpenMPCancellationPointConstruct>( |
| 434 |
verbatim("CANCELLATION POINT"_tok), Parser<OmpCancelType>{}))) |
| 435 |
|
| 436 |
// 2.14.1 Cancel construct |
| 437 |
TYPE_PARSER(sourced(construct<OpenMPCancelConstruct>(verbatim("CANCEL"_tok), |
| 438 |
Parser<OmpCancelType>{}, maybe("IF" >> parenthesized(scalarLogicalExpr))))) |
| 439 |
|
| 440 |
// 2.17.7 Atomic construct/2.17.8 Flush construct [OpenMP 5.0] |
| 441 |
// memory-order-clause -> |
| 442 |
// seq_cst |
| 443 |
// acq_rel |
| 444 |
// release |
| 445 |
// acquire |
| 446 |
// relaxed |
| 447 |
TYPE_PARSER(sourced(construct<OmpMemoryOrderClause>( |
| 448 |
sourced("SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) || |
| 449 |
"ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) || |
| 450 |
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) || |
| 451 |
"ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) || |
| 452 |
"RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()))))) |
| 453 |
|
| 454 |
// 2.4 Requires construct [OpenMP 5.0] |
| 455 |
// atomic-default-mem-order-clause -> |
| 456 |
// seq_cst |
| 457 |
// acq_rel |
| 458 |
// relaxed |
| 459 |
TYPE_PARSER(construct<OmpAtomicDefaultMemOrderClause>( |
| 460 |
"SEQ_CST" >> pure(common::OmpAtomicDefaultMemOrderType::SeqCst) || |
| 461 |
"ACQ_REL" >> pure(common::OmpAtomicDefaultMemOrderType::AcqRel) || |
| 462 |
"RELAXED" >> pure(common::OmpAtomicDefaultMemOrderType::Relaxed))) |
| 463 |
|
| 464 |
// 2.17.7 Atomic construct |
| 465 |
// atomic-clause -> memory-order-clause | HINT(hint-expression) |
| 466 |
TYPE_PARSER(sourced(construct<OmpAtomicClause>( |
| 467 |
construct<OmpAtomicClause>(Parser<OmpMemoryOrderClause>{}) || |
| 468 |
construct<OmpAtomicClause>("HINT" >> |
| 469 |
sourced(construct<OmpClause>( |
| 470 |
construct<OmpClause::Hint>(parenthesized(constantExpr)))))))) |
| 471 |
|
| 472 |
// atomic-clause-list -> [atomic-clause, [atomic-clause], ...] |
| 473 |
TYPE_PARSER(sourced(construct<OmpAtomicClauseList>( |
| 474 |
many(maybe(","_tok) >> sourced(Parser<OmpAtomicClause>{}))))) |
| 475 |
|
| 476 |
TYPE_PARSER(sourced(construct<OpenMPFlushConstruct>(verbatim("FLUSH"_tok), |
| 477 |
many(maybe(","_tok) >> sourced(Parser<OmpMemoryOrderClause>{})), |
| 478 |
maybe(parenthesized(Parser<OmpObjectList>{}))))) |
| 479 |
|
| 480 |
// Simple Standalone Directives |
| 481 |
TYPE_PARSER(sourced(construct<OmpSimpleStandaloneDirective>(first( |
| 482 |
"BARRIER" >> pure(llvm::omp::Directive::OMPD_barrier), |
| 483 |
"ORDERED" >> pure(llvm::omp::Directive::OMPD_ordered), |
| 484 |
"TARGET ENTER DATA" >> pure(llvm::omp::Directive::OMPD_target_enter_data), |
| 485 |
"TARGET EXIT DATA" >> pure(llvm::omp::Directive::OMPD_target_exit_data), |
| 486 |
"TARGET UPDATE" >> pure(llvm::omp::Directive::OMPD_target_update), |
| 487 |
"TASKWAIT" >> pure(llvm::omp::Directive::OMPD_taskwait), |
| 488 |
"TASKYIELD" >> pure(llvm::omp::Directive::OMPD_taskyield))))) |
| 489 |
|
| 490 |
TYPE_PARSER(sourced(construct<OpenMPSimpleStandaloneConstruct>( |
| 491 |
Parser<OmpSimpleStandaloneDirective>{}, Parser<OmpClauseList>{}))) |
| 492 |
|
| 493 |
// Standalone Constructs |
| 494 |
TYPE_PARSER( |
| 495 |
sourced(construct<OpenMPStandaloneConstruct>( |
| 496 |
Parser<OpenMPSimpleStandaloneConstruct>{}) || |
| 497 |
construct<OpenMPStandaloneConstruct>(Parser<OpenMPFlushConstruct>{}) || |
| 498 |
construct<OpenMPStandaloneConstruct>(Parser<OpenMPCancelConstruct>{}) || |
| 499 |
construct<OpenMPStandaloneConstruct>( |
| 500 |
Parser<OpenMPCancellationPointConstruct>{})) / |
| 501 |
endOfLine) |
| 502 |
|
| 503 |
// Directives enclosing structured-block |
| 504 |
TYPE_PARSER(construct<OmpBlockDirective>(first( |
| 505 |
"MASKED" >> pure(llvm::omp::Directive::OMPD_masked), |
| 506 |
"MASTER" >> pure(llvm::omp::Directive::OMPD_master), |
| 507 |
"ORDERED" >> pure(llvm::omp::Directive::OMPD_ordered), |
| 508 |
"PARALLEL MASKED" >> pure(llvm::omp::Directive::OMPD_parallel_masked), |
| 509 |
"PARALLEL WORKSHARE" >> pure(llvm::omp::Directive::OMPD_parallel_workshare), |
| 510 |
"PARALLEL" >> pure(llvm::omp::Directive::OMPD_parallel), |
| 511 |
"SINGLE" >> pure(llvm::omp::Directive::OMPD_single), |
| 512 |
"TARGET DATA" >> pure(llvm::omp::Directive::OMPD_target_data), |
| 513 |
"TARGET PARALLEL" >> pure(llvm::omp::Directive::OMPD_target_parallel), |
| 514 |
"TARGET TEAMS" >> pure(llvm::omp::Directive::OMPD_target_teams), |
| 515 |
"TARGET" >> pure(llvm::omp::Directive::OMPD_target), |
| 516 |
"TASK"_id >> pure(llvm::omp::Directive::OMPD_task), |
| 517 |
"TASKGROUP" >> pure(llvm::omp::Directive::OMPD_taskgroup), |
| 518 |
"TEAMS" >> pure(llvm::omp::Directive::OMPD_teams), |
| 519 |
"WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare)))) |
| 520 |
|
| 521 |
TYPE_PARSER(sourced(construct<OmpBeginBlockDirective>( |
| 522 |
sourced(Parser<OmpBlockDirective>{}), Parser<OmpClauseList>{}))) |
| 523 |
|
| 524 |
TYPE_PARSER(construct<OmpReductionInitializerClause>( |
| 525 |
"INITIALIZER" >> parenthesized("OMP_PRIV =" >> expr))) |
| 526 |
|
| 527 |
// 2.16 Declare Reduction Construct |
| 528 |
TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>( |
| 529 |
verbatim("DECLARE REDUCTION"_tok), |
| 530 |
"(" >> Parser<OmpReductionOperator>{} / ":", |
| 531 |
nonemptyList(Parser<DeclarationTypeSpec>{}) / ":", |
| 532 |
Parser<OmpReductionCombiner>{} / ")", |
| 533 |
maybe(Parser<OmpReductionInitializerClause>{})))) |
| 534 |
|
| 535 |
// declare-target with list |
| 536 |
TYPE_PARSER(sourced(construct<OmpDeclareTargetWithList>( |
| 537 |
parenthesized(Parser<OmpObjectList>{})))) |
| 538 |
|
| 539 |
// declare-target with clause |
| 540 |
TYPE_PARSER( |
| 541 |
sourced(construct<OmpDeclareTargetWithClause>(Parser<OmpClauseList>{}))) |
| 542 |
|
| 543 |
// declare-target-specifier |
| 544 |
TYPE_PARSER( |
| 545 |
construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithList>{}) || |
| 546 |
construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithClause>{})) |
| 547 |
|
| 548 |
// 2.10.6 Declare Target Construct |
| 549 |
TYPE_PARSER(sourced(construct<OpenMPDeclareTargetConstruct>( |
| 550 |
verbatim("DECLARE TARGET"_tok), Parser<OmpDeclareTargetSpecifier>{}))) |
| 551 |
|
| 552 |
TYPE_PARSER(construct<OmpReductionCombiner>(Parser<AssignmentStmt>{}) || |
| 553 |
construct<OmpReductionCombiner>( |
| 554 |
construct<OmpReductionCombiner::FunctionCombiner>( |
| 555 |
construct<Call>(Parser<ProcedureDesignator>{}, |
| 556 |
parenthesized(optionalList(actualArgSpec)))))) |
| 557 |
|
| 558 |
// 2.17.7 atomic -> ATOMIC [clause [,]] atomic-clause [[,] clause] | |
| 559 |
// ATOMIC [clause] |
| 560 |
// clause -> memory-order-clause | HINT(hint-expression) |
| 561 |
// memory-order-clause -> SEQ_CST | ACQ_REL | RELEASE | ACQUIRE | RELAXED |
| 562 |
// atomic-clause -> READ | WRITE | UPDATE | CAPTURE |
| 563 |
|
| 564 |
// OMP END ATOMIC |
| 565 |
TYPE_PARSER(construct<OmpEndAtomic>(startOmpLine >> "END ATOMIC"_tok)) |
| 566 |
|
| 567 |
// OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] READ [MEMORY-ORDER-CLAUSE-LIST] |
| 568 |
TYPE_PARSER("ATOMIC" >> |
| 569 |
construct<OmpAtomicRead>(Parser<OmpAtomicClauseList>{} / maybe(","_tok), |
| 570 |
verbatim("READ"_tok), Parser<OmpAtomicClauseList>{} / endOmpLine, |
| 571 |
statement(assignmentStmt), maybe(Parser<OmpEndAtomic>{} / endOmpLine))) |
| 572 |
|
| 573 |
// OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] CAPTURE [MEMORY-ORDER-CLAUSE-LIST] |
| 574 |
TYPE_PARSER("ATOMIC" >> |
| 575 |
construct<OmpAtomicCapture>(Parser<OmpAtomicClauseList>{} / maybe(","_tok), |
| 576 |
verbatim("CAPTURE"_tok), Parser<OmpAtomicClauseList>{} / endOmpLine, |
| 577 |
statement(assignmentStmt), statement(assignmentStmt), |
| 578 |
Parser<OmpEndAtomic>{} / endOmpLine)) |
| 579 |
|
| 580 |
// OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] UPDATE [MEMORY-ORDER-CLAUSE-LIST] |
| 581 |
TYPE_PARSER("ATOMIC" >> |
| 582 |
construct<OmpAtomicUpdate>(Parser<OmpAtomicClauseList>{} / maybe(","_tok), |
| 583 |
verbatim("UPDATE"_tok), Parser<OmpAtomicClauseList>{} / endOmpLine, |
| 584 |
statement(assignmentStmt), maybe(Parser<OmpEndAtomic>{} / endOmpLine))) |
| 585 |
|
| 586 |
// OMP ATOMIC [atomic-clause-list] |
| 587 |
TYPE_PARSER(construct<OmpAtomic>(verbatim("ATOMIC"_tok), |
| 588 |
Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt), |
| 589 |
maybe(Parser<OmpEndAtomic>{} / endOmpLine))) |
| 590 |
|
| 591 |
// OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] WRITE [MEMORY-ORDER-CLAUSE-LIST] |
| 592 |
TYPE_PARSER("ATOMIC" >> |
| 593 |
construct<OmpAtomicWrite>(Parser<OmpAtomicClauseList>{} / maybe(","_tok), |
| 594 |
verbatim("WRITE"_tok), Parser<OmpAtomicClauseList>{} / endOmpLine, |
| 595 |
statement(assignmentStmt), maybe(Parser<OmpEndAtomic>{} / endOmpLine))) |
| 596 |
|
| 597 |
// Atomic Construct |
| 598 |
TYPE_PARSER(construct<OpenMPAtomicConstruct>(Parser<OmpAtomicRead>{}) || |
| 599 |
construct<OpenMPAtomicConstruct>(Parser<OmpAtomicCapture>{}) || |
| 600 |
construct<OpenMPAtomicConstruct>(Parser<OmpAtomicWrite>{}) || |
| 601 |
construct<OpenMPAtomicConstruct>(Parser<OmpAtomicUpdate>{}) || |
| 602 |
construct<OpenMPAtomicConstruct>(Parser<OmpAtomic>{})) |
| 603 |
|
| 604 |
// 2.13.2 OMP CRITICAL |
| 605 |
TYPE_PARSER(startOmpLine >> |
| 606 |
sourced(construct<OmpEndCriticalDirective>( |
| 607 |
verbatim("END CRITICAL"_tok), maybe(parenthesized(name)))) / |
| 608 |
endOmpLine) |
| 609 |
TYPE_PARSER(sourced(construct<OmpCriticalDirective>(verbatim("CRITICAL"_tok), |
| 610 |
maybe(parenthesized(name)), Parser<OmpClauseList>{})) / |
| 611 |
endOmpLine) |
| 612 |
|
| 613 |
TYPE_PARSER(construct<OpenMPCriticalConstruct>( |
| 614 |
Parser<OmpCriticalDirective>{}, block, Parser<OmpEndCriticalDirective>{})) |
| 615 |
|
| 616 |
// 2.11.3 Executable Allocate directive |
| 617 |
TYPE_PARSER( |
| 618 |
sourced(construct<OpenMPExecutableAllocate>(verbatim("ALLOCATE"_tok), |
| 619 |
maybe(parenthesized(Parser<OmpObjectList>{})), Parser<OmpClauseList>{}, |
| 620 |
maybe(nonemptyList(Parser<OpenMPDeclarativeAllocate>{})) / endOmpLine, |
| 621 |
statement(allocateStmt)))) |
| 622 |
|
| 623 |
// 6.7 Allocators construct [OpenMP 5.2] |
| 624 |
// allocators-construct -> ALLOCATORS [allocate-clause [,]] |
| 625 |
// allocate-stmt |
| 626 |
// [omp-end-allocators-construct] |
| 627 |
TYPE_PARSER(sourced(construct<OpenMPAllocatorsConstruct>( |
| 628 |
verbatim("ALLOCATORS"_tok), Parser<OmpClauseList>{} / endOmpLine, |
| 629 |
statement(allocateStmt), maybe(Parser<OmpEndAllocators>{} / endOmpLine)))) |
| 630 |
|
| 631 |
TYPE_PARSER(construct<OmpEndAllocators>(startOmpLine >> "END ALLOCATORS"_tok)) |
| 632 |
|
| 633 |
// 2.8.2 Declare Simd construct |
| 634 |
TYPE_PARSER( |
| 635 |
sourced(construct<OpenMPDeclareSimdConstruct>(verbatim("DECLARE SIMD"_tok), |
| 636 |
maybe(parenthesized(name)), Parser<OmpClauseList>{}))) |
| 637 |
|
| 638 |
// 2.4 Requires construct |
| 639 |
TYPE_PARSER(sourced(construct<OpenMPRequiresConstruct>( |
| 640 |
verbatim("REQUIRES"_tok), Parser<OmpClauseList>{}))) |
| 641 |
|
| 642 |
// 2.15.2 Threadprivate directive |
| 643 |
TYPE_PARSER(sourced(construct<OpenMPThreadprivate>( |
| 644 |
verbatim("THREADPRIVATE"_tok), parenthesized(Parser<OmpObjectList>{})))) |
| 645 |
|
| 646 |
// 2.11.3 Declarative Allocate directive |
| 647 |
TYPE_PARSER( |
| 648 |
sourced(construct<OpenMPDeclarativeAllocate>(verbatim("ALLOCATE"_tok), |
| 649 |
parenthesized(Parser<OmpObjectList>{}), Parser<OmpClauseList>{})) / |
| 650 |
lookAhead(endOmpLine / !statement(allocateStmt))) |
| 651 |
|
| 652 |
// Declarative constructs |
| 653 |
TYPE_PARSER(startOmpLine >> |
| 654 |
withMessage("expected OpenMP construct"_err_en_US, |
| 655 |
sourced(construct<OpenMPDeclarativeConstruct>( |
| 656 |
Parser<OpenMPDeclareReductionConstruct>{}) || |
| 657 |
construct<OpenMPDeclarativeConstruct>( |
| 658 |
Parser<OpenMPDeclareSimdConstruct>{}) || |
| 659 |
construct<OpenMPDeclarativeConstruct>( |
| 660 |
Parser<OpenMPDeclareTargetConstruct>{}) || |
| 661 |
construct<OpenMPDeclarativeConstruct>( |
| 662 |
Parser<OpenMPDeclarativeAllocate>{}) || |
| 663 |
construct<OpenMPDeclarativeConstruct>( |
| 664 |
Parser<OpenMPRequiresConstruct>{}) || |
| 665 |
construct<OpenMPDeclarativeConstruct>( |
| 666 |
Parser<OpenMPThreadprivate>{})) / |
| 667 |
endOmpLine)) |
| 668 |
|
| 669 |
// Block Construct |
| 670 |
TYPE_PARSER(construct<OpenMPBlockConstruct>( |
| 671 |
Parser<OmpBeginBlockDirective>{} / endOmpLine, block, |
| 672 |
Parser<OmpEndBlockDirective>{} / endOmpLine)) |
| 673 |
|
| 674 |
// OMP SECTIONS Directive |
| 675 |
TYPE_PARSER(construct<OmpSectionsDirective>(first( |
| 676 |
"SECTIONS" >> pure(llvm::omp::Directive::OMPD_sections), |
| 677 |
"PARALLEL SECTIONS" >> pure(llvm::omp::Directive::OMPD_parallel_sections)))) |
| 678 |
|
| 679 |
// OMP BEGIN and END SECTIONS Directive |
| 680 |
TYPE_PARSER(sourced(construct<OmpBeginSectionsDirective>( |
| 681 |
sourced(Parser<OmpSectionsDirective>{}), Parser<OmpClauseList>{}))) |
| 682 |
TYPE_PARSER( |
| 683 |
startOmpLine >> sourced(construct<OmpEndSectionsDirective>( |
| 684 |
sourced("END"_tok >> Parser<OmpSectionsDirective>{}), |
| 685 |
Parser<OmpClauseList>{}))) |
| 686 |
|
| 687 |
// OMP SECTION-BLOCK |
| 688 |
|
| 689 |
TYPE_PARSER(construct<OpenMPSectionConstruct>(block)) |
| 690 |
|
| 691 |
TYPE_PARSER(maybe(startOmpLine >> "SECTION"_tok / endOmpLine) >> |
| 692 |
construct<OmpSectionBlocks>(nonemptySeparated( |
| 693 |
construct<OpenMPConstruct>(sourced(Parser<OpenMPSectionConstruct>{})), |
| 694 |
startOmpLine >> "SECTION"_tok / endOmpLine))) |
| 695 |
|
| 696 |
// OMP SECTIONS (OpenMP 5.0 - 2.8.1), PARALLEL SECTIONS (OpenMP 5.0 - 2.13.3) |
| 697 |
TYPE_PARSER(construct<OpenMPSectionsConstruct>( |
| 698 |
Parser<OmpBeginSectionsDirective>{} / endOmpLine, |
| 699 |
Parser<OmpSectionBlocks>{}, Parser<OmpEndSectionsDirective>{} / endOmpLine)) |
| 700 |
|
| 701 |
TYPE_CONTEXT_PARSER("OpenMP construct"_en_US, |
| 702 |
startOmpLine >> |
| 703 |
withMessage("expected OpenMP construct"_err_en_US, |
| 704 |
first(construct<OpenMPConstruct>(Parser<OpenMPSectionsConstruct>{}), |
| 705 |
construct<OpenMPConstruct>(Parser<OpenMPLoopConstruct>{}), |
| 706 |
construct<OpenMPConstruct>(Parser<OpenMPBlockConstruct>{}), |
| 707 |
// OpenMPBlockConstruct is attempted before |
| 708 |
// OpenMPStandaloneConstruct to resolve !$OMP ORDERED |
| 709 |
construct<OpenMPConstruct>(Parser<OpenMPStandaloneConstruct>{}), |
| 710 |
construct<OpenMPConstruct>(Parser<OpenMPAtomicConstruct>{}), |
| 711 |
construct<OpenMPConstruct>(Parser<OpenMPExecutableAllocate>{}), |
| 712 |
construct<OpenMPConstruct>(Parser<OpenMPAllocatorsConstruct>{}), |
| 713 |
construct<OpenMPConstruct>(Parser<OpenMPDeclarativeAllocate>{}), |
| 714 |
construct<OpenMPConstruct>(Parser<OpenMPCriticalConstruct>{})))) |
| 715 |
|
| 716 |
// END OMP Block directives |
| 717 |
TYPE_PARSER( |
| 718 |
startOmpLine >> sourced(construct<OmpEndBlockDirective>( |
| 719 |
sourced("END"_tok >> Parser<OmpBlockDirective>{}), |
| 720 |
Parser<OmpClauseList>{}))) |
| 721 |
|
| 722 |
// END OMP Loop directives |
| 723 |
TYPE_PARSER( |
| 724 |
startOmpLine >> sourced(construct<OmpEndLoopDirective>( |
| 725 |
sourced("END"_tok >> Parser<OmpLoopDirective>{}), |
| 726 |
Parser<OmpClauseList>{}))) |
| 727 |
|
| 728 |
TYPE_PARSER(construct<OpenMPLoopConstruct>( |
| 729 |
Parser<OmpBeginLoopDirective>{} / endOmpLine)) |
| 730 |
} // namespace Fortran::parser |