@@ -1109,28 +1109,26 @@ Order make(const parser::OmpClause::Order &inp,
1109
1109
using wrapped = parser::OmpOrderClause;
1110
1110
1111
1111
CLAUSET_ENUM_CONVERT ( //
1112
- convert1, parser::OmpOrderModifier::Kind , Order::OrderModifier,
1112
+ convert1, parser::OmpOrderModifier::Value , Order::OrderModifier,
1113
1113
// clang-format off
1114
1114
MS (Reproducible, Reproducible)
1115
1115
MS (Unconstrained, Unconstrained)
1116
1116
// clang-format on
1117
1117
);
1118
1118
1119
1119
CLAUSET_ENUM_CONVERT ( //
1120
- convert2, wrapped::Type , Order::Ordering,
1120
+ convert2, wrapped::Ordering , Order::Ordering,
1121
1121
// clang-format off
1122
1122
MS (Concurrent, Concurrent)
1123
1123
// clang-format on
1124
1124
);
1125
1125
1126
- auto &t0 = std::get<std::optional<parser::OmpOrderModifier>>(inp.v .t );
1127
- auto &t1 = std::get<wrapped::Type>(inp.v .t );
1126
+ auto &mods = semantics::OmpGetModifiers (inp.v );
1127
+ auto *t0 = semantics::OmpGetUniqueModifier<parser::OmpOrderModifier>(mods);
1128
+ auto &t1 = std::get<wrapped::Ordering>(inp.v .t );
1128
1129
1129
- auto convert3 = [&](const parser::OmpOrderModifier &s) {
1130
- return convert1 (s.v );
1131
- };
1132
- return Order{
1133
- {/* OrderModifier=*/ maybeApply (convert3, t0), /* Ordering=*/ convert2 (t1)}};
1130
+ return Order{{/* OrderModifier=*/ maybeApplyToV (convert1, t0),
1131
+ /* Ordering=*/ convert2 (t1)}};
1134
1132
}
1135
1133
1136
1134
Ordered make (const parser::OmpClause::Ordered &inp,
@@ -1197,10 +1195,10 @@ Reduction make(const parser::OmpClause::Reduction &inp,
1197
1195
auto *t1 =
1198
1196
semantics::OmpGetUniqueModifier<parser::OmpReductionIdentifier>(mods);
1199
1197
auto &t2 = std::get<parser::OmpObjectList>(inp.v .t );
1198
+ assert (t1 && " OmpReductionIdentifier is required" );
1199
+
1200
1200
return Reduction{
1201
- {/* ReductionModifier=*/ t0
1202
- ? std::make_optional<Reduction::ReductionModifier>(convert (t0->v ))
1203
- : std::nullopt,
1201
+ {/* ReductionModifier=*/ maybeApplyToV (convert, t0),
1204
1202
/* ReductionIdentifiers=*/ {makeReductionOperator (*t1, semaCtx)},
1205
1203
/* List=*/ makeObjects (t2, semaCtx)}};
1206
1204
}
@@ -1221,7 +1219,7 @@ Schedule make(const parser::OmpClause::Schedule &inp,
1221
1219
using wrapped = parser::OmpScheduleClause;
1222
1220
1223
1221
CLAUSET_ENUM_CONVERT ( //
1224
- convert1, wrapped::ScheduleType , Schedule::Kind,
1222
+ convert1, wrapped::Kind , Schedule::Kind,
1225
1223
// clang-format off
1226
1224
MS (Static, Static)
1227
1225
MS (Dynamic, Dynamic)
@@ -1232,57 +1230,30 @@ Schedule make(const parser::OmpClause::Schedule &inp,
1232
1230
);
1233
1231
1234
1232
CLAUSET_ENUM_CONVERT ( //
1235
- convert2, parser::OmpScheduleModifierType::ModType,
1236
- Schedule::OrderingModifier,
1233
+ convert2, parser::OmpOrderingModifier::Value, Schedule::OrderingModifier,
1237
1234
// clang-format off
1238
1235
MS (Monotonic, Monotonic)
1239
1236
MS (Nonmonotonic, Nonmonotonic)
1240
1237
// clang-format on
1241
1238
);
1242
1239
1243
1240
CLAUSET_ENUM_CONVERT ( //
1244
- convert3, parser::OmpScheduleModifierType::ModType,
1245
- Schedule::ChunkModifier,
1241
+ convert3, parser::OmpChunkModifier::Value, Schedule::ChunkModifier,
1246
1242
// clang-format off
1247
1243
MS (Simd, Simd)
1248
1244
// clang-format on
1249
1245
);
1250
1246
1251
- auto &t0 = std::get<std::optional<parser::OmpScheduleModifier>>(inp.v .t );
1252
- auto &t1 = std::get<wrapped::ScheduleType>(inp.v .t );
1253
- auto &t2 = std::get<std::optional<parser::ScalarIntExpr>>(inp.v .t );
1254
-
1255
- if (!t0) {
1256
- return Schedule{{/* Kind=*/ convert1 (t1), /* OrderingModifier=*/ std::nullopt,
1257
- /* ChunkModifier=*/ std::nullopt,
1258
- /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t2)}};
1259
- }
1260
-
1261
- // The members of parser::OmpScheduleModifier correspond to OrderingModifier,
1262
- // and ChunkModifier, but they can appear in any order.
1263
- auto &m1 = std::get<parser::OmpScheduleModifier::Modifier1>(t0->t );
1264
- auto &m2 =
1265
- std::get<std::optional<parser::OmpScheduleModifier::Modifier2>>(t0->t );
1266
-
1267
- std::optional<Schedule::OrderingModifier> omod;
1268
- std::optional<Schedule::ChunkModifier> cmod;
1269
-
1270
- if (m1.v .v == parser::OmpScheduleModifierType::ModType::Simd) {
1271
- // m1 is chunk-modifier
1272
- cmod = convert3 (m1.v .v );
1273
- if (m2)
1274
- omod = convert2 (m2->v .v );
1275
- } else {
1276
- // m1 is ordering-modifier
1277
- omod = convert2 (m1.v .v );
1278
- if (m2)
1279
- cmod = convert3 (m2->v .v );
1280
- }
1247
+ auto &mods = semantics::OmpGetModifiers (inp.v );
1248
+ auto *t0 = semantics::OmpGetUniqueModifier<parser::OmpOrderingModifier>(mods);
1249
+ auto *t1 = semantics::OmpGetUniqueModifier<parser::OmpChunkModifier>(mods);
1250
+ auto &t2 = std::get<wrapped::Kind>(inp.v .t );
1251
+ auto &t3 = std::get<std::optional<parser::ScalarIntExpr>>(inp.v .t );
1281
1252
1282
- return Schedule{{/* Kind=*/ convert1 (t1 ),
1283
- /* OrderingModifier=*/ omod ,
1284
- /* ChunkModifier=*/ cmod ,
1285
- /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t2 )}};
1253
+ return Schedule{{/* Kind=*/ convert1 (t2 ),
1254
+ /* OrderingModifier=*/ maybeApplyToV (convert2, t0) ,
1255
+ /* ChunkModifier=*/ maybeApplyToV (convert3, t1) ,
1256
+ /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t3 )}};
1286
1257
}
1287
1258
1288
1259
// SeqCst: empty
@@ -1326,6 +1297,8 @@ TaskReduction make(const parser::OmpClause::TaskReduction &inp,
1326
1297
auto *t0 =
1327
1298
semantics::OmpGetUniqueModifier<parser::OmpReductionIdentifier>(mods);
1328
1299
auto &t1 = std::get<parser::OmpObjectList>(inp.v .t );
1300
+ assert (t0 && " OmpReductionIdentifier is required" );
1301
+
1329
1302
return TaskReduction{
1330
1303
{/* ReductionIdentifiers=*/ {makeReductionOperator (*t0, semaCtx)},
1331
1304
/* List=*/ makeObjects (t1, semaCtx)}};
0 commit comments