@@ -65,6 +65,74 @@ def OpenACC_ReductionOperatorAttr : EnumAttr<OpenACC_Dialect,
65
65
let assemblyFormat = [{ ```<` $value `>` }];
66
66
}
67
67
68
+ // OpenACC variable type categorization. This is needed because OpenACC
69
+ // dialect is used with other dialects, and each dialect defines its own
70
+ // types. Thus, in order to be able to classify types and apply right semantics,
71
+ // it is needed to ensure the types can be categorized.
72
+ def OpenACC_VariableTypeUncategorized : I32BitEnumAttrCaseNone<"uncategorized">;
73
+
74
+ // The OpenACC spec definition of scalar type is as follows (from 3.3 spec,
75
+ // line 5454):
76
+ // Scalar datatype - an intrinsic or built-in datatype that is not an array or
77
+ // aggregate datatype. In Fortran, scalar datatypes are integer, real, double
78
+ // precision, complex, or logical. In C, scalar datatypes are char (signed or
79
+ // unsigned), int (signed or unsigned, with optional short, long or long long
80
+ // attribute), enum, float, double, long double, Complex (with optional float
81
+ // or long attribute), or any pointer datatype. In C++, scalar datatypes are
82
+ // char (signed or unsigned), wchar t, int (signed or unsigned, with optional
83
+ // short, long or long long attribute), enum, bool, float, double, long double,
84
+ // or any pointer datatype. Not all implementations or targets will support all
85
+ // of these datatypes.
86
+ // From an MLIR type perspective, the types that those language types map to
87
+ // will be categorized as scalar.
88
+ def OpenACC_VariableTypeScalar : I32BitEnumAttrCaseBit<"scalar", 0>;
89
+
90
+ // Not in OpenACC spec glossary as its own definition but used throughout the
91
+ // spec. One definition of array that can be assumed for purposes of type
92
+ // categorization is that it is a collection of elements of same type.
93
+ def OpenACC_VariableTypeArray : I32BitEnumAttrCaseBit<"array", 1>;
94
+
95
+ // The OpenACC spec definition of composite type is as follows (from 3.3 spec,
96
+ // line 5354):
97
+ // Composite datatype - a derived type in Fortran, or a struct or union type in
98
+ // C, or a class, struct, or union type in C++. (This is different from the use
99
+ // of the term composite data type in the C and C++ languages.)
100
+ def OpenACC_VariableTypeComposite : I32BitEnumAttrCaseBit<"composite", 2>;
101
+
102
+ // The OpenACC spec uses the type category "aggregate" to capture both arrays
103
+ // and composite types. However, it includes types which do not fall in either
104
+ // of those categories. Thus create a case for the others.
105
+ // For example, reading the definition of "Aggregate Variables" in the 3.3
106
+ // spec line 5346 shows this distinction:
107
+ // Aggregate variables - a variable of any non-scalar datatype, including array
108
+ // or composite variables. In Fortran, this includes any variable with
109
+ // allocatable or pointer attribute and character variables
110
+ def OpenACC_VariableTypeOtherNonScalar : I32BitEnumAttrCaseBit<"nonscalar", 3>;
111
+
112
+ // The OpenACC spec definition of aggregate type is as follows (from 3.3 spec,
113
+ // line 5342):
114
+ // Aggregate datatype - any non-scalar datatype such as array and composite
115
+ // datatypes. In Fortran, aggregate datatypes include arrays, derived types,
116
+ // character types. In C, aggregate datatypes include arrays, targets of
117
+ // pointers, structs, and unions. In C++, aggregate datatypes include arrays,
118
+ // targets of pointers, classes, structs, and unions.
119
+ def OpenACC_VariableTypeAggregate : I32BitEnumAttrCaseGroup<"aggregate",
120
+ [OpenACC_VariableTypeArray, OpenACC_VariableTypeComposite,
121
+ OpenACC_VariableTypeOtherNonScalar]>;
122
+
123
+ def OpenACC_VariableTypeCategory : I32BitEnumAttr<
124
+ "VariableTypeCategory",
125
+ "Captures different type categories described in OpenACC spec",
126
+ [
127
+ OpenACC_VariableTypeUncategorized, OpenACC_VariableTypeScalar,
128
+ OpenACC_VariableTypeArray, OpenACC_VariableTypeComposite,
129
+ OpenACC_VariableTypeOtherNonScalar, OpenACC_VariableTypeAggregate]> {
130
+ let separator = ",";
131
+ let cppNamespace = "::mlir::acc";
132
+ let genSpecializedAttr = 0;
133
+ let printBitEnumPrimaryGroups = 1;
134
+ }
135
+
68
136
// Type used in operation below.
69
137
def IntOrIndex : AnyTypeOf<[AnyInteger, Index]>;
70
138
0 commit comments