@@ -2380,6 +2380,18 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
2380
2380
procBindKindAttr);
2381
2381
}
2382
2382
2383
+ static mlir::omp::SectionOp
2384
+ genSectionOp (Fortran::lower::AbstractConverter &converter,
2385
+ Fortran::lower::pft::Evaluation &eval,
2386
+ mlir::Location currentLocation,
2387
+ const Fortran::parser::OmpClauseList §ionsClauseList) {
2388
+ // Currently only private/firstprivate clause is handled, and
2389
+ // all privatization is done within `omp.section` operations.
2390
+ return genOpWithBody<mlir::omp::SectionOp>(converter, eval, currentLocation,
2391
+ /* outerCombined=*/ false ,
2392
+ §ionsClauseList);
2393
+ }
2394
+
2383
2395
static mlir::omp::SingleOp
2384
2396
genSingleOp (Fortran::lower::AbstractConverter &converter,
2385
2397
Fortran::lower::pft::Evaluation &eval,
@@ -3382,37 +3394,6 @@ genOMP(Fortran::lower::AbstractConverter &converter,
3382
3394
genNestedEvaluations (converter, eval);
3383
3395
}
3384
3396
3385
- static void
3386
- genOMP (Fortran::lower::AbstractConverter &converter,
3387
- Fortran::lower::SymMap &symTable,
3388
- Fortran::semantics::SemanticsContext &semanticsContext,
3389
- Fortran::lower::pft::Evaluation &eval,
3390
- const Fortran::parser::OpenMPSectionConstruct §ionConstruct) {
3391
- mlir::Location currentLocation = converter.getCurrentLocation ();
3392
- const Fortran::parser::OpenMPConstruct *parentOmpConstruct =
3393
- eval.parentConstruct ->getIf <Fortran::parser::OpenMPConstruct>();
3394
- assert (parentOmpConstruct &&
3395
- " No enclosing parent OpenMPConstruct on SECTION construct" );
3396
- const Fortran::parser::OpenMPSectionsConstruct *sectionsConstruct =
3397
- std::get_if<Fortran::parser::OpenMPSectionsConstruct>(
3398
- &parentOmpConstruct->u );
3399
- assert (sectionsConstruct && " SECTION construct must have parent"
3400
- " SECTIONS construct" );
3401
- const Fortran::parser::OmpClauseList §ionsClauseList =
3402
- std::get<Fortran::parser::OmpClauseList>(
3403
- std::get<Fortran::parser::OmpBeginSectionsDirective>(
3404
- sectionsConstruct->t )
3405
- .t );
3406
- // Currently only private/firstprivate clause is handled, and
3407
- // all privatization is done within `omp.section` operations.
3408
- symTable.pushScope ();
3409
- genOpWithBody<mlir::omp::SectionOp>(converter, eval, currentLocation,
3410
- /* outerCombined=*/ false ,
3411
- §ionsClauseList);
3412
- genNestedEvaluations (converter, eval);
3413
- symTable.popScope ();
3414
- }
3415
-
3416
3397
static void
3417
3398
genOMP (Fortran::lower::AbstractConverter &converter,
3418
3399
Fortran::lower::SymMap &symTable,
@@ -3458,7 +3439,18 @@ genOMP(Fortran::lower::AbstractConverter &converter,
3458
3439
/* reductions=*/ nullptr , allocateOperands,
3459
3440
allocatorOperands, nowaitClauseOperand);
3460
3441
3461
- genNestedEvaluations (converter, eval);
3442
+ const auto §ionBlocks =
3443
+ std::get<Fortran::parser::OmpSectionBlocks>(sectionsConstruct.t );
3444
+ auto &firOpBuilder = converter.getFirOpBuilder ();
3445
+ auto ip = firOpBuilder.saveInsertionPoint ();
3446
+ for (const auto &[nblock, neval] :
3447
+ llvm::zip (sectionBlocks.v , eval.getNestedEvaluations ())) {
3448
+ symTable.pushScope ();
3449
+ genSectionOp (converter, neval, currentLocation, sectionsClauseList);
3450
+ genNestedEvaluations (converter, neval);
3451
+ symTable.popScope ();
3452
+ firOpBuilder.restoreInsertionPoint (ip);
3453
+ }
3462
3454
}
3463
3455
3464
3456
static void
@@ -3578,8 +3570,8 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
3578
3570
sectionsConstruct);
3579
3571
},
3580
3572
[&](const Fortran::parser::OpenMPSectionConstruct §ionConstruct) {
3581
- genOMP (converter, symTable, semanticsContext, eval,
3582
- sectionConstruct );
3573
+ // SECTION constructs are handled as a part of SECTIONS.
3574
+ llvm_unreachable ( " Unexpected standalone OMP SECTION " );
3583
3575
},
3584
3576
[&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) {
3585
3577
genOMP (converter, symTable, semanticsContext, eval, loopConstruct);
0 commit comments