@@ -2379,6 +2379,18 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
2379
2379
procBindKindAttr);
2380
2380
}
2381
2381
2382
+ static mlir::omp::SectionOp
2383
+ genSectionOp (Fortran::lower::AbstractConverter &converter,
2384
+ Fortran::lower::pft::Evaluation &eval,
2385
+ mlir::Location currentLocation,
2386
+ const Fortran::parser::OmpClauseList §ionsClauseList) {
2387
+ // Currently only private/firstprivate clause is handled, and
2388
+ // all privatization is done within `omp.section` operations.
2389
+ return genOpWithBody<mlir::omp::SectionOp>(converter, eval, currentLocation,
2390
+ /* outerCombined=*/ false ,
2391
+ §ionsClauseList);
2392
+ }
2393
+
2382
2394
static mlir::omp::SingleOp
2383
2395
genSingleOp (Fortran::lower::AbstractConverter &converter,
2384
2396
Fortran::lower::pft::Evaluation &eval,
@@ -3375,35 +3387,6 @@ genOMP(Fortran::lower::AbstractConverter &converter,
3375
3387
genNestedEvaluations (converter, eval);
3376
3388
}
3377
3389
3378
- static void
3379
- genOMP (Fortran::lower::AbstractConverter &converter,
3380
- Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval,
3381
- const Fortran::parser::OpenMPSectionConstruct §ionConstruct) {
3382
- mlir::Location currentLocation = converter.getCurrentLocation ();
3383
- const Fortran::parser::OpenMPConstruct *parentOmpConstruct =
3384
- eval.parentConstruct ->getIf <Fortran::parser::OpenMPConstruct>();
3385
- assert (parentOmpConstruct &&
3386
- " No enclosing parent OpenMPConstruct on SECTION construct" );
3387
- const Fortran::parser::OpenMPSectionsConstruct *sectionsConstruct =
3388
- std::get_if<Fortran::parser::OpenMPSectionsConstruct>(
3389
- &parentOmpConstruct->u );
3390
- assert (sectionsConstruct && " SECTION construct must have parent"
3391
- " SECTIONS construct" );
3392
- const Fortran::parser::OmpClauseList §ionsClauseList =
3393
- std::get<Fortran::parser::OmpClauseList>(
3394
- std::get<Fortran::parser::OmpBeginSectionsDirective>(
3395
- sectionsConstruct->t )
3396
- .t );
3397
- // Currently only private/firstprivate clause is handled, and
3398
- // all privatization is done within `omp.section` operations.
3399
- symTable.pushScope ();
3400
- genOpWithBody<mlir::omp::SectionOp>(converter, eval, currentLocation,
3401
- /* outerCombined=*/ false ,
3402
- §ionsClauseList);
3403
- genNestedEvaluations (converter, eval);
3404
- symTable.popScope ();
3405
- }
3406
-
3407
3390
static void
3408
3391
genOMP (Fortran::lower::AbstractConverter &converter,
3409
3392
Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval,
@@ -3447,7 +3430,18 @@ genOMP(Fortran::lower::AbstractConverter &converter,
3447
3430
/* reductions=*/ nullptr , allocateOperands,
3448
3431
allocatorOperands, nowaitClauseOperand);
3449
3432
3450
- genNestedEvaluations (converter, eval);
3433
+ const auto §ionBlocks =
3434
+ std::get<Fortran::parser::OmpSectionBlocks>(sectionsConstruct.t );
3435
+ auto &firOpBuilder = converter.getFirOpBuilder ();
3436
+ auto ip = firOpBuilder.saveInsertionPoint ();
3437
+ for (const auto &[nblock, neval] :
3438
+ llvm::zip (sectionBlocks.v , eval.getNestedEvaluations ())) {
3439
+ symTable.pushScope ();
3440
+ genSectionOp (converter, neval, currentLocation, sectionsClauseList);
3441
+ genNestedEvaluations (converter, neval);
3442
+ symTable.popScope ();
3443
+ firOpBuilder.restoreInsertionPoint (ip);
3444
+ }
3451
3445
}
3452
3446
3453
3447
static void
@@ -3562,7 +3556,8 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
3562
3556
genOMP (converter, symTable, eval, sectionsConstruct);
3563
3557
},
3564
3558
[&](const Fortran::parser::OpenMPSectionConstruct §ionConstruct) {
3565
- genOMP (converter, symTable, eval, sectionConstruct);
3559
+ // SECTION constructs are handled as a part of SECTIONS.
3560
+ llvm_unreachable (" Unexpected standalone OMP SECTION" );
3566
3561
},
3567
3562
[&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) {
3568
3563
genOMP (converter, symTable, eval, semanticsContext, loopConstruct);
0 commit comments