@@ -199,6 +199,41 @@ def OpenACC_DataClauseEnum : I64EnumAttr<"DataClause",
199
199
def OpenACC_DataClauseAttr : EnumAttr<OpenACC_Dialect, OpenACC_DataClauseEnum,
200
200
"data_clause">;
201
201
202
+ // Data clause modifiers:
203
+ // * readonly: Added in OpenACC 2.7 to copyin and cache.
204
+ // * zero: Added in OpenACC 3.0 for create and copyout.
205
+ // * always, alwaysin, alwaysout: Added in OpenACC 3.4 for
206
+ // copy, copyin, and copyout clauses.
207
+ // * capture: Added in OpenACC 3.4 for copy, copyin, copyout and create clauses.
208
+ def OpenACC_DataClauseModifierNone : I32BitEnumAttrCaseNone<"none">;
209
+ // All of the modifiers below are bit flags - so the value noted is `1 << bit`.
210
+ // Thus the `zero` modifier is `1 << 0` = 1, `readonly` is `1 << 1` = 2, etc.
211
+ def OpenACC_DataClauseModifierZero : I32BitEnumAttrCaseBit<"zero", 0>;
212
+ def OpenACC_DataClauseModifierReadonly : I32BitEnumAttrCaseBit<"readonly", 1>;
213
+ def OpenACC_DataClauseModifierAlwaysIn : I32BitEnumAttrCaseBit<"alwaysin", 2>;
214
+ def OpenACC_DataClauseModifierAlwaysOut : I32BitEnumAttrCaseBit<"alwaysout", 3>;
215
+ def OpenACC_DataClauseModifierAlways : I32BitEnumAttrCaseGroup<"always",
216
+ [OpenACC_DataClauseModifierAlwaysIn, OpenACC_DataClauseModifierAlwaysOut]>;
217
+ def OpenACC_DataClauseModifierCapture : I32BitEnumAttrCaseBit<"capture", 4>;
218
+
219
+ def OpenACC_DataClauseModifierEnum : I32BitEnumAttr<
220
+ "DataClauseModifier",
221
+ "Captures data clause modifiers",
222
+ [
223
+ OpenACC_DataClauseModifierNone, OpenACC_DataClauseModifierZero,
224
+ OpenACC_DataClauseModifierReadonly, OpenACC_DataClauseModifierAlwaysIn,
225
+ OpenACC_DataClauseModifierAlwaysOut, OpenACC_DataClauseModifierAlways,
226
+ OpenACC_DataClauseModifierCapture]> {
227
+ let separator = ",";
228
+ let cppNamespace = "::mlir::acc";
229
+ let genSpecializedAttr = 0;
230
+ let printBitEnumPrimaryGroups = 1;
231
+ }
232
+
233
+ def OpenACC_DataClauseModifierAttr : EnumAttr<OpenACC_Dialect,
234
+ OpenACC_DataClauseModifierEnum,
235
+ "data_clause_modifier">;
236
+
202
237
class OpenACC_Attr<string name, string attrMnemonic,
203
238
list<Trait> traits = [],
204
239
string baseCppClass = "::mlir::Attribute">
@@ -477,6 +512,8 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, string extraDescriptio
477
512
DefaultValuedAttr<OpenACC_DataClauseAttr, clause>:$dataClause,
478
513
DefaultValuedAttr<BoolAttr, "true">:$structured,
479
514
DefaultValuedAttr<BoolAttr, "false">:$implicit,
515
+ DefaultValuedAttr<OpenACC_DataClauseModifierAttr,
516
+ "mlir::acc::DataClauseModifier::none">:$modifiers,
480
517
OptionalAttr<StrAttr>:$name));
481
518
482
519
let description = !strconcat(extraDescription, [{
@@ -506,6 +543,7 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, string extraDescriptio
506
543
counters (2.6.7).
507
544
- `implicit`: Whether this is an implicitly generated operation, such as copies
508
545
done to satisfy "Variables with Implicitly Determined Data Attributes" in 2.6.2.
546
+ - `modifiers`: Keeps track of the data clause modifiers (eg zero, readonly, etc)
509
547
- `name`: Holds the name of variable as specified in user clause (including bounds).
510
548
511
549
The async values attached to the data entry operation imply that the data
@@ -584,7 +622,8 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, string extraDescriptio
584
622
/*asyncOperandsDeviceType=*/nullptr,
585
623
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
586
624
/*structured=*/$_builder.getBoolAttr(structured),
587
- /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
625
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
626
+ /*name=*/nullptr);
588
627
}]>,
589
628
OpBuilder<(ins "::mlir::Value":$var,
590
629
"bool":$structured, "bool":$implicit,
@@ -601,9 +640,23 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, string extraDescriptio
601
640
/*asyncOperandsDeviceType=*/nullptr,
602
641
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
603
642
/*structured=*/$_builder.getBoolAttr(structured),
604
- /*implicit=*/$_builder.getBoolAttr(implicit),
643
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
605
644
/*name=*/$_builder.getStringAttr(name));
606
- }]>];
645
+ }]>,
646
+ OpBuilder<(ins "::mlir::Type":$accVarType, "::mlir::Value":$var,
647
+ "::mlir::Type":$varType, "::mlir::Value":$varPtrPtr,
648
+ "::mlir::ValueRange":$bounds,
649
+ "::mlir::ValueRange":$asyncOperands,
650
+ "::mlir::ArrayAttr":$asyncOperandsDeviceType,
651
+ "::mlir::ArrayAttr":$asyncOnly,
652
+ "::mlir::acc::DataClause":$dataClause, "bool":$structured,
653
+ "bool":$implicit, "::mlir::StringAttr":$name),
654
+ [{
655
+ build($_builder, $_state, accVarType, var, varType, varPtrPtr, bounds,
656
+ asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause,
657
+ structured, implicit, ::mlir::acc::DataClauseModifier::none, name);
658
+ }]>,
659
+ ];
607
660
}
608
661
609
662
//===----------------------------------------------------------------------===//
@@ -817,9 +870,7 @@ def OpenACC_CacheOp : OpenACC_DataEntryOp<"cache",
817
870
818
871
let extraClassDeclaration = extraClassDeclarationBase # [{
819
872
/// Check if this is a cache with readonly modifier.
820
- bool isCacheReadonly() {
821
- return getDataClause() == acc::DataClause::acc_cache_readonly;
822
- }
873
+ bool isCacheReadonly();
823
874
}];
824
875
}
825
876
@@ -840,6 +891,8 @@ class OpenACC_DataExitOp<string mnemonic, string clause, string extraDescription
840
891
DefaultValuedAttr<OpenACC_DataClauseAttr,clause>:$dataClause,
841
892
DefaultValuedAttr<BoolAttr, "true">:$structured,
842
893
DefaultValuedAttr<BoolAttr, "false">:$implicit,
894
+ DefaultValuedAttr<OpenACC_DataClauseModifierAttr,
895
+ "mlir::acc::DataClauseModifier::none">:$modifiers,
843
896
OptionalAttr<StrAttr>:$name));
844
897
845
898
let description = !strconcat(extraDescription, [{
@@ -861,6 +914,7 @@ class OpenACC_DataExitOp<string mnemonic, string clause, string extraDescription
861
914
counters (2.6.7).
862
915
- `implicit`: Whether this is an implicitly generated operation, such as copies
863
916
done to satisfy "Variables with Implicitly Determined Data Attributes" in 2.6.2.
917
+ - `modifiers`: Keeps track of the data clause modifiers (eg zero, always, etc)
864
918
- `name`: Holds the name of variable as specified in user clause (including bounds).
865
919
866
920
The async values attached to the data exit operation imply that the data
@@ -944,7 +998,8 @@ class OpenACC_DataExitOpWithVarPtr<string mnemonic, string clause>
944
998
bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
945
999
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
946
1000
/*structured=*/$_builder.getBoolAttr(structured),
947
- /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
1001
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
1002
+ /*name=*/nullptr);
948
1003
}]>,
949
1004
OpBuilder<(ins "::mlir::Value":$accVar,
950
1005
"::mlir::Value":$var,
@@ -961,9 +1016,22 @@ class OpenACC_DataExitOpWithVarPtr<string mnemonic, string clause>
961
1016
bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
962
1017
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
963
1018
/*structured=*/$_builder.getBoolAttr(structured),
964
- /*implicit=*/$_builder.getBoolAttr(implicit),
1019
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
965
1020
/*name=*/$_builder.getStringAttr(name));
966
- }]>];
1021
+ }]>,
1022
+ OpBuilder<(ins "::mlir::Value":$accVar, "::mlir::Value":$var,
1023
+ "::mlir::Type":$varType, "::mlir::ValueRange":$bounds,
1024
+ "::mlir::ValueRange":$asyncOperands,
1025
+ "::mlir::ArrayAttr":$asyncOperandsDeviceType,
1026
+ "::mlir::ArrayAttr":$asyncOnly,
1027
+ "::mlir::acc::DataClause":$dataClause, "bool":$structured,
1028
+ "bool":$implicit, "::mlir::StringAttr":$name),
1029
+ [{
1030
+ build($_builder, $_state, accVar, var, varType, bounds,
1031
+ asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause,
1032
+ structured, implicit, ::mlir::acc::DataClauseModifier::none, name);
1033
+ }]>,
1034
+ ];
967
1035
968
1036
code extraClassDeclarationDataExit = [{
969
1037
mlir::TypedValue<mlir::acc::PointerLikeType> getVarPtr() {
@@ -998,7 +1066,8 @@ class OpenACC_DataExitOpNoVarPtr<string mnemonic, string clause> :
998
1066
bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
999
1067
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
1000
1068
/*structured=*/$_builder.getBoolAttr(structured),
1001
- /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
1069
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
1070
+ /*name=*/nullptr);
1002
1071
}]>,
1003
1072
OpBuilder<(ins "::mlir::Value":$accVar,
1004
1073
"bool":$structured, "bool":$implicit,
@@ -1009,9 +1078,20 @@ class OpenACC_DataExitOpNoVarPtr<string mnemonic, string clause> :
1009
1078
bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
1010
1079
/*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
1011
1080
/*structured=*/$_builder.getBoolAttr(structured),
1012
- /*implicit=*/$_builder.getBoolAttr(implicit),
1081
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*modifiers=*/nullptr,
1013
1082
/*name=*/$_builder.getStringAttr(name));
1014
- }]>
1083
+ }]>,
1084
+ OpBuilder<(ins "::mlir::Value":$accVar, "::mlir::ValueRange":$bounds,
1085
+ "::mlir::ValueRange":$asyncOperands,
1086
+ "::mlir::ArrayAttr":$asyncOperandsDeviceType,
1087
+ "::mlir::ArrayAttr":$asyncOnly,
1088
+ "::mlir::acc::DataClause":$dataClause, "bool":$structured,
1089
+ "bool":$implicit, "::mlir::StringAttr":$name),
1090
+ [{
1091
+ build($_builder, $_state, accVar, bounds, asyncOperands,
1092
+ asyncOperandsDeviceType, asyncOnly, dataClause, structured,
1093
+ implicit, ::mlir::acc::DataClauseModifier::none, name);
1094
+ }]>,
1015
1095
];
1016
1096
1017
1097
code extraClassDeclarationDataExit = [{
0 commit comments