@@ -286,16 +286,39 @@ class OpenACCClauseCIREmitter final
286
286
std::move (bounds)};
287
287
}
288
288
289
+ mlir::acc::DataClauseModifier
290
+ convertModifiers (OpenACCModifierKind modifiers) {
291
+ using namespace mlir ::acc;
292
+ static_assert (static_cast <int >(OpenACCModifierKind::Zero) ==
293
+ static_cast <int >(DataClauseModifier::zero) &&
294
+ static_cast <int >(OpenACCModifierKind::Readonly) ==
295
+ static_cast <int >(DataClauseModifier::readonly) &&
296
+ static_cast <int >(OpenACCModifierKind::AlwaysIn) ==
297
+ static_cast <int >(DataClauseModifier::alwaysin) &&
298
+ static_cast <int >(OpenACCModifierKind::AlwaysOut) ==
299
+ static_cast <int >(DataClauseModifier::alwaysout) &&
300
+ static_cast <int >(OpenACCModifierKind::Capture) ==
301
+ static_cast <int >(DataClauseModifier::capture));
302
+
303
+ DataClauseModifier mlirModifiers{};
304
+
305
+ // The MLIR representation of this represents `always` as `alwaysin` +
306
+ // `alwaysout`. So do a small fixup here.
307
+ if (isOpenACCModifierBitSet (modifiers, OpenACCModifierKind::Always)) {
308
+ mlirModifiers = mlirModifiers | DataClauseModifier::always;
309
+ modifiers &= ~OpenACCModifierKind::Always;
310
+ }
311
+
312
+ mlirModifiers = mlirModifiers | static_cast <DataClauseModifier>(modifiers);
313
+ return mlirModifiers;
314
+ }
315
+
289
316
template <typename BeforeOpTy, typename AfterOpTy>
290
317
void addDataOperand (const Expr *varOperand, mlir::acc::DataClause dataClause,
291
- bool structured, bool implicit) {
318
+ OpenACCModifierKind modifiers, bool structured,
319
+ bool implicit) {
292
320
DataOperandInfo opInfo = getDataOperandInfo (dirKind, varOperand);
293
321
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
-
299
322
auto beforeOp =
300
323
builder.create <BeforeOpTy>(opInfo.beginLoc , opInfo.varValue , structured,
301
324
implicit, opInfo.name , opInfo.bounds );
@@ -323,6 +346,8 @@ class OpenACCClauseCIREmitter final
323
346
// Set the 'rest' of the info for both operations.
324
347
beforeOp.setDataClause (dataClause);
325
348
afterOp.setDataClause (dataClause);
349
+ beforeOp.setModifiers (convertModifiers (modifiers));
350
+ afterOp.setModifiers (convertModifiers (modifiers));
326
351
327
352
// Make sure we record these, so 'async' values can be updated later.
328
353
dataOperands.push_back (beforeOp.getOperation ());
@@ -331,7 +356,8 @@ class OpenACCClauseCIREmitter final
331
356
332
357
template <typename BeforeOpTy>
333
358
void addDataOperand (const Expr *varOperand, mlir::acc::DataClause dataClause,
334
- bool structured, bool implicit) {
359
+ OpenACCModifierKind modifiers, bool structured,
360
+ bool implicit) {
335
361
DataOperandInfo opInfo = getDataOperandInfo (dirKind, varOperand);
336
362
auto beforeOp =
337
363
builder.create <BeforeOpTy>(opInfo.beginLoc , opInfo.varValue , structured,
@@ -340,6 +366,8 @@ class OpenACCClauseCIREmitter final
340
366
341
367
// Set the 'rest' of the info for the operation.
342
368
beforeOp.setDataClause (dataClause);
369
+ beforeOp.setModifiers (convertModifiers (modifiers));
370
+
343
371
// Make sure we record these, so 'async' values can be updated later.
344
372
dataOperands.push_back (beforeOp.getOperation ());
345
373
}
@@ -818,7 +846,8 @@ class OpenACCClauseCIREmitter final
818
846
mlir::acc::KernelsOp>) {
819
847
for (auto var : clause.getVarList ())
820
848
addDataOperand<mlir::acc::CopyinOp, mlir::acc::CopyoutOp>(
821
- var, mlir::acc::DataClause::acc_copy, /* structured=*/ true ,
849
+ var, mlir::acc::DataClause::acc_copy, clause.getModifierList (),
850
+ /* structured=*/ true ,
822
851
/* implicit=*/ false );
823
852
} else if constexpr (isCombinedType<OpTy>) {
824
853
applyToComputeOp (clause);
@@ -833,8 +862,8 @@ class OpenACCClauseCIREmitter final
833
862
if constexpr (isOneOfTypes<OpTy, mlir::acc::HostDataOp>) {
834
863
for (auto var : clause.getVarList ())
835
864
addDataOperand<mlir::acc::UseDeviceOp>(
836
- var, mlir::acc::DataClause::acc_use_device,
837
- /* structured= */ true , /* implicit=*/ false );
865
+ var, mlir::acc::DataClause::acc_use_device, {}, /* structured= */ true ,
866
+ /* implicit=*/ false );
838
867
} else {
839
868
llvm_unreachable (" Unknown construct kind in VisitUseDeviceClause" );
840
869
}
@@ -845,7 +874,8 @@ class OpenACCClauseCIREmitter final
845
874
mlir::acc::KernelsOp>) {
846
875
for (auto var : clause.getVarList ())
847
876
addDataOperand<mlir::acc::DevicePtrOp>(
848
- var, mlir::acc::DataClause::acc_deviceptr, /* structured=*/ true ,
877
+ var, mlir::acc::DataClause::acc_deviceptr, {},
878
+ /* structured=*/ true ,
849
879
/* implicit=*/ false );
850
880
} else if constexpr (isCombinedType<OpTy>) {
851
881
applyToComputeOp (clause);
@@ -861,7 +891,7 @@ class OpenACCClauseCIREmitter final
861
891
mlir::acc::KernelsOp>) {
862
892
for (auto var : clause.getVarList ())
863
893
addDataOperand<mlir::acc::NoCreateOp, mlir::acc::DeleteOp>(
864
- var, mlir::acc::DataClause::acc_no_create, /* structured=*/ true ,
894
+ var, mlir::acc::DataClause::acc_no_create, {}, /* structured=*/ true ,
865
895
/* implicit=*/ false );
866
896
} else if constexpr (isCombinedType<OpTy>) {
867
897
applyToComputeOp (clause);
@@ -877,7 +907,7 @@ class OpenACCClauseCIREmitter final
877
907
mlir::acc::KernelsOp>) {
878
908
for (auto var : clause.getVarList ())
879
909
addDataOperand<mlir::acc::PresentOp, mlir::acc::DeleteOp>(
880
- var, mlir::acc::DataClause::acc_present, /* structured=*/ true ,
910
+ var, mlir::acc::DataClause::acc_present, {}, /* structured=*/ true ,
881
911
/* implicit=*/ false );
882
912
} else if constexpr (isCombinedType<OpTy>) {
883
913
applyToComputeOp (clause);
@@ -893,7 +923,7 @@ class OpenACCClauseCIREmitter final
893
923
mlir::acc::KernelsOp>) {
894
924
for (auto var : clause.getVarList ())
895
925
addDataOperand<mlir::acc::AttachOp, mlir::acc::DetachOp>(
896
- var, mlir::acc::DataClause::acc_attach, /* structured=*/ true ,
926
+ var, mlir::acc::DataClause::acc_attach, {}, /* structured=*/ true ,
897
927
/* implicit=*/ false );
898
928
} else if constexpr (isCombinedType<OpTy>) {
899
929
applyToComputeOp (clause);
0 commit comments