diff options
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Lower/OpenACC.cpp | 27 | ||||
-rw-r--r-- | flang/test/Lower/OpenACC/acc-data.f90 | 6 |
2 files changed, 23 insertions, 10 deletions
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 00cca5d4e6f3..1dbc92770efd 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -1053,10 +1053,13 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, genIfClause(converter, clauseLocation, ifClause, ifCond, stmtCtx); } else if (const auto *copyClause = std::get_if<Fortran::parser::AccClause::Copy>(&clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations<mlir::acc::CopyinOp>( copyClause->v, converter, semanticsContext, stmtCtx, - copyEntryOperands, mlir::acc::DataClause::acc_copy, + dataClauseOperands, mlir::acc::DataClause::acc_copy, /*structured=*/true); + copyEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *copyinClause = std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u)) { genDataOperandOperationsWithModifier<mlir::acc::CopyinOp, @@ -1068,20 +1071,26 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, } else if (const auto *copyoutClause = std::get_if<Fortran::parser::AccClause::Copyout>( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperationsWithModifier<mlir::acc::CreateOp, Fortran::parser::AccClause::Copyout>( copyoutClause, converter, semanticsContext, stmtCtx, - Fortran::parser::AccDataModifier::Modifier::Zero, - copyoutEntryOperands, mlir::acc::DataClause::acc_copyout, + Fortran::parser::AccDataModifier::Modifier::Zero, dataClauseOperands, + mlir::acc::DataClause::acc_copyout, mlir::acc::DataClause::acc_copyout_zero); + copyoutEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *createClause = std::get_if<Fortran::parser::AccClause::Create>(&clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperationsWithModifier<mlir::acc::CreateOp, Fortran::parser::AccClause::Create>( createClause, converter, semanticsContext, stmtCtx, - Fortran::parser::AccDataModifier::Modifier::Zero, createEntryOperands, + Fortran::parser::AccDataModifier::Modifier::Zero, dataClauseOperands, mlir::acc::DataClause::acc_create, mlir::acc::DataClause::acc_create_zero); + createEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *noCreateClause = std::get_if<Fortran::parser::AccClause::NoCreate>( &clause.u)) { @@ -1105,18 +1114,16 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, /*structured=*/true); } else if (const auto *attachClause = std::get_if<Fortran::parser::AccClause::Attach>(&clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations<mlir::acc::AttachOp>( attachClause->v, converter, semanticsContext, stmtCtx, - attachEntryOperands, mlir::acc::DataClause::acc_attach, + dataClauseOperands, mlir::acc::DataClause::acc_attach, /*structured=*/true); + attachEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } } - dataClauseOperands.append(attachEntryOperands); - dataClauseOperands.append(copyEntryOperands); - dataClauseOperands.append(copyoutEntryOperands); - dataClauseOperands.append(createEntryOperands); - // Prepare the operand segment size attribute and the operands value range. llvm::SmallVector<mlir::Value> operands; llvm::SmallVector<int32_t> operandSegments; diff --git a/flang/test/Lower/OpenACC/acc-data.f90 b/flang/test/Lower/OpenACC/acc-data.f90 index c8f44affea37..32af8039af7c 100644 --- a/flang/test/Lower/OpenACC/acc-data.f90 +++ b/flang/test/Lower/OpenACC/acc-data.f90 @@ -96,6 +96,12 @@ subroutine acc_data ! CHECK: acc.delete accPtr(%[[CREATE_B]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) {dataClause = 7 : i64, name = "b"} ! CHECK: acc.delete accPtr(%[[CREATE_C]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) {dataClause = 8 : i64, name = "c"} + !$acc data create(c) copy(b) create(a) + !$acc end data +!CHECK: %[[CREATE_C:.*]] = acc.create varPtr(%[[C]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {name = "c"} +!CHECK: %[[COPY_B:.*]] = acc.copyin varPtr(%[[B]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = 3 : i64, name = "b"} +!CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {name = "a"} +!CHECK: acc.data dataOperands(%[[CREATE_C]], %[[COPY_B]], %[[CREATE_A]] : !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>, !fir.ref<!fir.array<10x10xf32>>) { !$acc data no_create(a, b) create(zero: c) !$acc end data |