@@ -1144,7 +1144,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
1144
1144
if (isOpenMPLoopBoundSharingDirective (Kind))
1145
1145
return CombinedDistributeEnd;
1146
1146
if (isOpenMPWorksharingDirective (Kind) || isOpenMPTaskLoopDirective (Kind) ||
1147
- isOpenMPDistributeDirective (Kind))
1147
+ isOpenMPGenericLoopDirective (Kind) || isOpenMPDistributeDirective (Kind))
1148
1148
return WorksharingEnd;
1149
1149
return DefaultEnd;
1150
1150
}
@@ -1176,55 +1176,63 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
1176
1176
}
1177
1177
void setIsLastIterVariable (Expr *IL) {
1178
1178
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1179
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1179
1180
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1180
1181
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1181
1182
" expected worksharing loop directive" );
1182
1183
Data->getChildren ()[IsLastIterVariableOffset] = IL;
1183
1184
}
1184
1185
void setLowerBoundVariable (Expr *LB) {
1185
1186
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1187
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1186
1188
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1187
1189
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1188
1190
" expected worksharing loop directive" );
1189
1191
Data->getChildren ()[LowerBoundVariableOffset] = LB;
1190
1192
}
1191
1193
void setUpperBoundVariable (Expr *UB) {
1192
1194
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1195
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1193
1196
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1194
1197
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1195
1198
" expected worksharing loop directive" );
1196
1199
Data->getChildren ()[UpperBoundVariableOffset] = UB;
1197
1200
}
1198
1201
void setStrideVariable (Expr *ST) {
1199
1202
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1203
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1200
1204
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1201
1205
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1202
1206
" expected worksharing loop directive" );
1203
1207
Data->getChildren ()[StrideVariableOffset] = ST;
1204
1208
}
1205
1209
void setEnsureUpperBound (Expr *EUB) {
1206
1210
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1211
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1207
1212
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1208
1213
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1209
1214
" expected worksharing loop directive" );
1210
1215
Data->getChildren ()[EnsureUpperBoundOffset] = EUB;
1211
1216
}
1212
1217
void setNextLowerBound (Expr *NLB) {
1213
1218
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1219
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1214
1220
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1215
1221
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1216
1222
" expected worksharing loop directive" );
1217
1223
Data->getChildren ()[NextLowerBoundOffset] = NLB;
1218
1224
}
1219
1225
void setNextUpperBound (Expr *NUB) {
1220
1226
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1227
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1221
1228
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1222
1229
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1223
1230
" expected worksharing loop directive" );
1224
1231
Data->getChildren ()[NextUpperBoundOffset] = NUB;
1225
1232
}
1226
1233
void setNumIterations (Expr *NI) {
1227
1234
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1235
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1228
1236
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1229
1237
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1230
1238
" expected worksharing loop directive" );
@@ -1327,55 +1335,63 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
1327
1335
Stmt *getPreInits () { return Data->getChildren ()[PreInitsOffset]; }
1328
1336
Expr *getIsLastIterVariable () const {
1329
1337
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1338
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1330
1339
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1331
1340
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1332
1341
" expected worksharing loop directive" );
1333
1342
return cast<Expr>(Data->getChildren ()[IsLastIterVariableOffset]);
1334
1343
}
1335
1344
Expr *getLowerBoundVariable () const {
1336
1345
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1346
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1337
1347
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1338
1348
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1339
1349
" expected worksharing loop directive" );
1340
1350
return cast<Expr>(Data->getChildren ()[LowerBoundVariableOffset]);
1341
1351
}
1342
1352
Expr *getUpperBoundVariable () const {
1343
1353
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1354
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1344
1355
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1345
1356
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1346
1357
" expected worksharing loop directive" );
1347
1358
return cast<Expr>(Data->getChildren ()[UpperBoundVariableOffset]);
1348
1359
}
1349
1360
Expr *getStrideVariable () const {
1350
1361
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1362
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1351
1363
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1352
1364
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1353
1365
" expected worksharing loop directive" );
1354
1366
return cast<Expr>(Data->getChildren ()[StrideVariableOffset]);
1355
1367
}
1356
1368
Expr *getEnsureUpperBound () const {
1357
1369
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1370
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1358
1371
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1359
1372
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1360
1373
" expected worksharing loop directive" );
1361
1374
return cast<Expr>(Data->getChildren ()[EnsureUpperBoundOffset]);
1362
1375
}
1363
1376
Expr *getNextLowerBound () const {
1364
1377
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1378
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1365
1379
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1366
1380
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1367
1381
" expected worksharing loop directive" );
1368
1382
return cast<Expr>(Data->getChildren ()[NextLowerBoundOffset]);
1369
1383
}
1370
1384
Expr *getNextUpperBound () const {
1371
1385
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1386
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1372
1387
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1373
1388
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1374
1389
" expected worksharing loop directive" );
1375
1390
return cast<Expr>(Data->getChildren ()[NextUpperBoundOffset]);
1376
1391
}
1377
1392
Expr *getNumIterations () const {
1378
1393
assert ((isOpenMPWorksharingDirective (getDirectiveKind ()) ||
1394
+ isOpenMPGenericLoopDirective (getDirectiveKind ()) ||
1379
1395
isOpenMPTaskLoopDirective (getDirectiveKind ()) ||
1380
1396
isOpenMPDistributeDirective (getDirectiveKind ())) &&
1381
1397
" expected worksharing loop directive" );
@@ -1509,6 +1525,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
1509
1525
T->getStmtClass () == OMPTaskLoopSimdDirectiveClass ||
1510
1526
T->getStmtClass () == OMPMasterTaskLoopDirectiveClass ||
1511
1527
T->getStmtClass () == OMPMasterTaskLoopSimdDirectiveClass ||
1528
+ T->getStmtClass () == OMPGenericLoopDirectiveClass ||
1512
1529
T->getStmtClass () == OMPParallelMasterTaskLoopDirectiveClass ||
1513
1530
T->getStmtClass () == OMPParallelMasterTaskLoopSimdDirectiveClass ||
1514
1531
T->getStmtClass () == OMPDistributeDirectiveClass ||
@@ -5461,6 +5478,69 @@ class OMPMetaDirective final : public OMPExecutableDirective {
5461
5478
}
5462
5479
};
5463
5480
5481
+ // / This represents '#pragma omp loop' directive.
5482
+ // /
5483
+ // / \code
5484
+ // / #pragma omp loop private(a,b) binding(parallel) order(concurrent)
5485
+ // / \endcode
5486
+ // / In this example directive '#pragma omp loop' has
5487
+ // / clauses 'private' with the variables 'a' and 'b', 'binding' with
5488
+ // / modifier 'parallel' and 'order(concurrent).
5489
+ // /
5490
+ class OMPGenericLoopDirective final : public OMPLoopDirective {
5491
+ friend class ASTStmtReader ;
5492
+ friend class OMPExecutableDirective ;
5493
+ // / Build directive with the given start and end location.
5494
+ // /
5495
+ // / \param StartLoc Starting location of the directive kind.
5496
+ // / \param EndLoc Ending location of the directive.
5497
+ // / \param CollapsedNum Number of collapsed nested loops.
5498
+ // /
5499
+ OMPGenericLoopDirective (SourceLocation StartLoc, SourceLocation EndLoc,
5500
+ unsigned CollapsedNum)
5501
+ : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop,
5502
+ StartLoc, EndLoc, CollapsedNum) {}
5503
+
5504
+ // / Build an empty directive.
5505
+ // /
5506
+ // / \param CollapsedNum Number of collapsed nested loops.
5507
+ // /
5508
+ explicit OMPGenericLoopDirective (unsigned CollapsedNum)
5509
+ : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop,
5510
+ SourceLocation (), SourceLocation(), CollapsedNum) {}
5511
+
5512
+ public:
5513
+ // / Creates directive with a list of \p Clauses.
5514
+ // /
5515
+ // / \param C AST context.
5516
+ // / \param StartLoc Starting location of the directive kind.
5517
+ // / \param EndLoc Ending Location of the directive.
5518
+ // / \param CollapsedNum Number of collapsed loops.
5519
+ // / \param Clauses List of clauses.
5520
+ // / \param AssociatedStmt Statement, associated with the directive.
5521
+ // / \param Exprs Helper expressions for CodeGen.
5522
+ // /
5523
+ static OMPGenericLoopDirective *
5524
+ Create (const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5525
+ unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5526
+ Stmt *AssociatedStmt, const HelperExprs &Exprs);
5527
+
5528
+ // / Creates an empty directive with a place for \a NumClauses clauses.
5529
+ // /
5530
+ // / \param C AST context.
5531
+ // / \param NumClauses Number of clauses.
5532
+ // / \param CollapsedNum Number of collapsed nested loops.
5533
+ // /
5534
+ static OMPGenericLoopDirective *CreateEmpty (const ASTContext &C,
5535
+ unsigned NumClauses,
5536
+ unsigned CollapsedNum,
5537
+ EmptyShell);
5538
+
5539
+ static bool classof (const Stmt *T) {
5540
+ return T->getStmtClass () == OMPGenericLoopDirectiveClass;
5541
+ }
5542
+ };
5543
+
5464
5544
} // end namespace clang
5465
5545
5466
5546
#endif
0 commit comments