|
31 | 31 | // Special value for * passed in device_type or gang clauses.
|
32 | 32 | static constexpr std::int64_t starCst = -1;
|
33 | 33 |
|
| 34 | +static unsigned routineCounter = 0; |
| 35 | +static constexpr llvm::StringRef accRoutinePrefix = "acc_routine_"; |
| 36 | + |
34 | 37 | /// Generate the acc.bounds operation from the descriptor information.
|
35 | 38 | static llvm::SmallVector<mlir::Value>
|
36 | 39 | genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
|
@@ -2721,6 +2724,32 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
|
2721 | 2724 | llvm_unreachable("unsupported declarative directive");
|
2722 | 2725 | }
|
2723 | 2726 |
|
| 2727 | +static void |
| 2728 | +genACC(Fortran::lower::AbstractConverter &converter, |
| 2729 | + Fortran::lower::pft::Evaluation &eval, |
| 2730 | + const Fortran::parser::OpenACCRoutineConstruct &routineConstruct) { |
| 2731 | + fir::FirOpBuilder &builder = converter.getFirOpBuilder(); |
| 2732 | + mlir::Location loc = converter.genLocation(routineConstruct.source); |
| 2733 | + std::optional<Fortran::parser::Name> name = |
| 2734 | + std::get<std::optional<Fortran::parser::Name>>(routineConstruct.t); |
| 2735 | + const auto &clauses = |
| 2736 | + std::get<Fortran::parser::AccClauseList>(routineConstruct.t); |
| 2737 | + if (name) |
| 2738 | + TODO(loc, "acc routine with name"); |
| 2739 | + if (!clauses.v.empty()) |
| 2740 | + TODO(loc, "acc routine with clauses"); |
| 2741 | + |
| 2742 | + mlir::func::FuncOp func = builder.getFunction(); |
| 2743 | + mlir::ModuleOp mod = builder.getModule(); |
| 2744 | + mlir::OpBuilder modBuilder(mod.getBodyRegion()); |
| 2745 | + std::stringstream routineOpName; |
| 2746 | + routineOpName << accRoutinePrefix.str() << routineCounter++; |
| 2747 | + modBuilder.create<mlir::acc::RoutineOp>( |
| 2748 | + loc, routineOpName.str(), func.getName(), mlir::StringAttr{}, |
| 2749 | + mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{}, |
| 2750 | + mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::IntegerAttr{}); |
| 2751 | +} |
| 2752 | + |
2724 | 2753 | void Fortran::lower::genOpenACCConstruct(
|
2725 | 2754 | Fortran::lower::AbstractConverter &converter,
|
2726 | 2755 | Fortran::semantics::SemanticsContext &semanticsContext,
|
@@ -2774,8 +2803,7 @@ void Fortran::lower::genOpenACCDeclarativeConstruct(
|
2774 | 2803 | },
|
2775 | 2804 | [&](const Fortran::parser::OpenACCRoutineConstruct
|
2776 | 2805 | &routineConstruct) {
|
2777 |
| - TODO(converter.genLocation(routineConstruct.source), |
2778 |
| - "OpenACC Routine construct not lowered yet!"); |
| 2806 | + genACC(converter, eval, routineConstruct); |
2779 | 2807 | },
|
2780 | 2808 | },
|
2781 | 2809 | accDeclConstruct.u);
|
|
0 commit comments