@@ -286,16 +286,28 @@ class OpenACCClauseCIREmitter final
286286 std::move (bounds)};
287287 }
288288
289+ mlir::acc::DataClauseModifier
290+ convertModifiers (OpenACCModifierKind modifiers) {
291+ using namespace mlir ::acc;
292+ DataClauseModifier mlirModifiers{};
293+
294+ // The MLIR representation of this represents `always` as `alwaysin` +
295+ // `alwaysout`. So do a small fixup here.
296+ if (isOpenACCModifierBitSet (modifiers, OpenACCModifierKind::Always)) {
297+ mlirModifiers = mlirModifiers | DataClauseModifier::always;
298+ modifiers &= ~OpenACCModifierKind::Always;
299+ }
300+
301+ mlirModifiers = mlirModifiers | static_cast <DataClauseModifier>(modifiers);
302+ return mlirModifiers;
303+ }
304+
289305 template <typename BeforeOpTy, typename AfterOpTy>
290306 void addDataOperand (const Expr *varOperand, mlir::acc::DataClause dataClause,
291- bool structured, bool implicit) {
307+ OpenACCModifierKind modifiers, bool structured,
308+ bool implicit) {
292309 DataOperandInfo opInfo = getDataOperandInfo (dirKind, varOperand);
293310
294- // TODO: OpenACC: we should comprehend the 'modifier-list' here for the data
295- // operand. At the moment, we don't have a uniform way to assign these
296- // properly, and the dialect cannot represent anything other than 'readonly'
297- // and 'zero' on copyin/copyout/create, so for now, we skip it.
298-
299311 auto beforeOp =
300312 builder.create <BeforeOpTy>(opInfo.beginLoc , opInfo.varValue , structured,
301313 implicit, opInfo.name , opInfo.bounds );
@@ -323,6 +335,8 @@ class OpenACCClauseCIREmitter final
323335 // Set the 'rest' of the info for both operations.
324336 beforeOp.setDataClause (dataClause);
325337 afterOp.setDataClause (dataClause);
338+ beforeOp.setModifiers (convertModifiers (modifiers));
339+ afterOp.setModifiers (convertModifiers (modifiers));
326340
327341 // Make sure we record these, so 'async' values can be updated later.
328342 dataOperands.push_back (beforeOp.getOperation ());
@@ -331,7 +345,8 @@ class OpenACCClauseCIREmitter final
331345
332346 template <typename BeforeOpTy>
333347 void addDataOperand (const Expr *varOperand, mlir::acc::DataClause dataClause,
334- bool structured, bool implicit) {
348+ OpenACCModifierKind modifiers, bool structured,
349+ bool implicit) {
335350 DataOperandInfo opInfo = getDataOperandInfo (dirKind, varOperand);
336351 auto beforeOp =
337352 builder.create <BeforeOpTy>(opInfo.beginLoc , opInfo.varValue , structured,
@@ -340,6 +355,8 @@ class OpenACCClauseCIREmitter final
340355
341356 // Set the 'rest' of the info for the operation.
342357 beforeOp.setDataClause (dataClause);
358+ beforeOp.setModifiers (convertModifiers (modifiers));
359+
343360 // Make sure we record these, so 'async' values can be updated later.
344361 dataOperands.push_back (beforeOp.getOperation ());
345362 }
@@ -818,7 +835,8 @@ class OpenACCClauseCIREmitter final
818835 mlir::acc::KernelsOp>) {
819836 for (auto var : clause.getVarList ())
820837 addDataOperand<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
821- var, mlir::acc::DataClause::acc_copy, /* structured=*/ true ,
838+ var, mlir::acc::DataClause::acc_copy, clause.getModifierList (),
839+ /* structured=*/ true ,
822840 /* implicit=*/ false );
823841 } else if constexpr (isCombinedType<OpTy>) {
824842 applyToComputeOp (clause);
@@ -833,8 +851,8 @@ class OpenACCClauseCIREmitter final
833851 if constexpr (isOneOfTypes<OpTy, mlir::acc::HostDataOp>) {
834852 for (auto var : clause.getVarList ())
835853 addDataOperand<mlir::acc::UseDeviceOp>(
836- var, mlir::acc::DataClause::acc_use_device,
837- /* structured= */ true , /* implicit=*/ false );
854+ var, mlir::acc::DataClause::acc_use_device, {}, /* structured= */ true ,
855+ /* implicit=*/ false );
838856 } else {
839857 llvm_unreachable (" Unknown construct kind in VisitUseDeviceClause" );
840858 }
@@ -845,7 +863,8 @@ class OpenACCClauseCIREmitter final
845863 mlir::acc::KernelsOp>) {
846864 for (auto var : clause.getVarList ())
847865 addDataOperand<mlir::acc::DevicePtrOp>(
848- var, mlir::acc::DataClause::acc_deviceptr, /* structured=*/ true ,
866+ var, mlir::acc::DataClause::acc_deviceptr, {},
867+ /* structured=*/ true ,
849868 /* implicit=*/ false );
850869 } else if constexpr (isCombinedType<OpTy>) {
851870 applyToComputeOp (clause);
@@ -861,7 +880,7 @@ class OpenACCClauseCIREmitter final
861880 mlir::acc::KernelsOp>) {
862881 for (auto var : clause.getVarList ())
863882 addDataOperand<mlir::acc::NoCreateOp, mlir::acc::DeleteOp>(
864- var, mlir::acc::DataClause::acc_no_create, /* structured=*/ true ,
883+ var, mlir::acc::DataClause::acc_no_create, {}, /* structured=*/ true ,
865884 /* implicit=*/ false );
866885 } else if constexpr (isCombinedType<OpTy>) {
867886 applyToComputeOp (clause);
@@ -877,7 +896,7 @@ class OpenACCClauseCIREmitter final
877896 mlir::acc::KernelsOp>) {
878897 for (auto var : clause.getVarList ())
879898 addDataOperand<mlir::acc::PresentOp, mlir::acc::DeleteOp>(
880- var, mlir::acc::DataClause::acc_present, /* structured=*/ true ,
899+ var, mlir::acc::DataClause::acc_present, {}, /* structured=*/ true ,
881900 /* implicit=*/ false );
882901 } else if constexpr (isCombinedType<OpTy>) {
883902 applyToComputeOp (clause);
@@ -893,7 +912,7 @@ class OpenACCClauseCIREmitter final
893912 mlir::acc::KernelsOp>) {
894913 for (auto var : clause.getVarList ())
895914 addDataOperand<mlir::acc::AttachOp, mlir::acc::DetachOp>(
896- var, mlir::acc::DataClause::acc_attach, /* structured=*/ true ,
915+ var, mlir::acc::DataClause::acc_attach, {}, /* structured=*/ true ,
897916 /* implicit=*/ false );
898917 } else if constexpr (isCombinedType<OpTy>) {
899918 applyToComputeOp (clause);
0 commit comments