[flang-commits] [flang] 32899e1 - [flang][openacc] Lower default clause to acc.data operation attributes
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Fri Jun 30 11:21:53 PDT 2023
Author: Valentin Clement
Date: 2023-06-30T11:21:48-07:00
New Revision: 32899e14afdc453882b50a8bcd291310920c55bd
URL: https://github.com/llvm/llvm-project/commit/32899e14afdc453882b50a8bcd291310920c55bd
DIFF: https://github.com/llvm/llvm-project/commit/32899e14afdc453882b50a8bcd291310920c55bd.diff
LOG: [flang][openacc] Lower default clause to acc.data operation attributes
Lowering of the default clause was missing on the acc.data operation. This
patch lowers the default clause to its corresponding attribute.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D154162
Added:
Modified:
flang/lib/Lower/OpenACC.cpp
flang/test/Lower/OpenACC/acc-data.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index c281b8f8734de..d79afa03117e3 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -1379,6 +1379,9 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
bool addAsyncAttr = false;
bool addWaitAttr = false;
+ bool hasDefaultNone = false;
+ bool hasDefaultPresent = false;
+
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
// Lower clauses values mapped to operands.
@@ -1466,6 +1469,12 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
std::get_if<Fortran::parser::AccClause::Wait>(&clause.u)) {
genWaitClause(converter, waitClause, waitOperands, waitDevnum,
addWaitAttr, stmtCtx);
+ } else if(const auto *defaultClause =
+ std::get_if<Fortran::parser::AccClause::Default>(&clause.u)) {
+ if ((defaultClause->v).v == llvm::acc::DefaultValue::ACC_Default_none)
+ hasDefaultNone = true;
+ else if ((defaultClause->v).v == llvm::acc::DefaultValue::ACC_Default_present)
+ hasDefaultPresent = true;
}
}
@@ -1484,6 +1493,11 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
dataOp.setAsyncAttr(addAsyncAttr);
dataOp.setWaitAttr(addWaitAttr);
+ if (hasDefaultNone)
+ dataOp.setDefaultAttr(mlir::acc::ClauseDefaultValue::None);
+ if (hasDefaultPresent)
+ dataOp.setDefaultAttr(mlir::acc::ClauseDefaultValue::Present);
+
auto insPt = builder.saveInsertionPoint();
builder.setInsertionPointAfter(dataOp);
diff --git a/flang/test/Lower/OpenACC/acc-data.f90 b/flang/test/Lower/OpenACC/acc-data.f90
index 7b880d76bd369..955e85c9fd2c2 100644
--- a/flang/test/Lower/OpenACC/acc-data.f90
+++ b/flang/test/Lower/OpenACC/acc-data.f90
@@ -174,5 +174,19 @@ subroutine acc_data
! CHECK: acc.data dataOperands(%{{.*}}) wait_devnum(%{{.*}} : i32) wait(%{{.*}} : i32) {
! CHECK: }{{$}}
+ !$acc data default(none)
+ !$acc end data
+
+! CHECK: acc.data {
+! CHECK: acc.terminator
+! CHECK: } attributes {defaultAttr = #acc<defaultvalue none>}
+
+ !$acc data default(present)
+ !$acc end data
+
+! CHECK: acc.data {
+! CHECK: acc.terminator
+! CHECK: } attributes {defaultAttr = #acc<defaultvalue present>}
+
end subroutine acc_data
More information about the flang-commits
mailing list