@@ -86,24 +86,35 @@ class OpWithOffsetSizesAndStridesConstantArgumentFolder final
86
86
}
87
87
};
88
88
89
- // / Printer hook for custom directive in assemblyFormat.
89
+ // / Printer hooks for custom directive in assemblyFormat.
90
90
// /
91
91
// / custom<DynamicIndexList>($values, $integers)
92
92
// / custom<DynamicIndexList>($values, $integers, type($values))
93
93
// /
94
- // / where `values` is of ODS type `Variadic<*>` and `integers` is of ODS
95
- // / type `I64ArrayAttr`. Prints a list with either (1) the static integer value
96
- // / in `integers` is `kDynamic` or (2) the next value otherwise. If `valueTypes`
97
- // / is non-empty, it is expected to contain as many elements as `values`
98
- // / indicating their types. This allows idiomatic printing of mixed value and
99
- // / integer attributes in a list. E.g.
100
- // / `[%arg0 : index, 7, 42, %arg42 : i32]`.
94
+ // / where `values` is of ODS type `Variadic<*>` and `integers` is of ODS type
95
+ // / `I64ArrayAttr`. Print a list where each element is either:
96
+ // / 1. the static integer value in `integers`, if it's not `kDynamic` or,
97
+ // / 2. the next value in `values` with its corresponding type, otherwise.
98
+ // /
99
+ // / The type for integer elements is `i64` by default and not printed.
100
+ // /
101
+ // / If `valueTypes` is provided, verify that each type matches the type of the
102
+ // / corresponding `values`. Providing `valueTypes` is redundant for printing so
103
+ // / we don't use `valueTypes` after the verification.
104
+ // /
105
+ // / Integer indices can also be scalable, denoted with square brackets (e.g.,
106
+ // / "[2, [4], 8]"). For each value in `integers`, the corresponding `bool` in
107
+ // / `scalables` encodes whether it's a scalable index. If `scalables` is empty
108
+ // / then assume that all indices are non-scalable.
109
+ // /
110
+ // / Examples:
111
+ // / * For `integers = [kDynamic, 7, 42, kDynamic]`,
112
+ // / `values = [%arg0, %arg42]`,Using the default type for integers and
113
+ // / `valueTypes` for `values`:
114
+ // / `[%arg0 : index, 7, 42, %arg42 : i32]`
115
+ // / * Using `scalables`:
116
+ // / `[2, [4], 8]`
101
117
// /
102
- // / Indices can be scalable. For example, "4" in "[2, [4], 8]" is scalable.
103
- // / This notation is similar to how scalable dims are marked when defining
104
- // / Vectors. For each value in `integers`, the corresponding `bool` in
105
- // / `scalables` encodes whether it's a scalable index. If `scalableVals` is
106
- // / empty then assume that all indices are non-scalable.
107
118
void printDynamicIndexList (
108
119
OpAsmPrinter &printer, Operation *op, OperandRange values,
109
120
ArrayRef<int64_t > integers, ArrayRef<bool > scalables,
@@ -113,64 +124,71 @@ inline void printDynamicIndexList(
113
124
OpAsmPrinter &printer, Operation *op, OperandRange values,
114
125
ArrayRef<int64_t > integers, TypeRange valueTypes = TypeRange(),
115
126
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
116
- return printDynamicIndexList (printer, op, values, integers, {}, valueTypes ,
117
- delimiter);
127
+ return printDynamicIndexList (printer, op, values, integers, /* scalables= */ {} ,
128
+ valueTypes, delimiter);
118
129
}
119
130
120
- // / Parser hook for custom directive in assemblyFormat.
131
+ // / Parser hooks for custom directive in assemblyFormat.
121
132
// /
122
133
// / custom<DynamicIndexList>($values, $integers)
123
134
// / custom<DynamicIndexList>($values, $integers, type($values))
124
135
// /
125
136
// / where `values` is of ODS type `Variadic<*>` and `integers` is of ODS
126
- // / type `I64ArrayAttr`. Parse a mixed list with either (1) static integer
127
- // / values or (2) SSA values. Fill `integers` with the integer ArrayAttr, where
128
- // / `kDynamic` encodes the position of SSA values. Add the parsed SSA values
129
- // / to `values` in-order. If `valueTypes` is non-null, fill it with types
130
- // / corresponding to values; otherwise the caller must handle the types.
137
+ // / type `I64ArrayAttr`. Parse a mixed list where each element is either a
138
+ // / static integer or an SSA value. Fill `integers` with the integer ArrayAttr,
139
+ // / where `kDynamic` encodes the position of SSA values. Add the parsed SSA
140
+ // / values to `values` in-order.
131
141
// /
132
- // / E.g. after parsing "[%arg0 : index, 7, 42, %arg42 : i32]":
133
- // / 1. `result` is filled with the i64 ArrayAttr "[`kDynamic`, 7, 42,
134
- // / `kDynamic`]"
135
- // / 2. `ssa` is filled with "[%arg0, %arg1]".
142
+ // / If `valueTypes` is provided, fill it with the types corresponding to each
143
+ // / value in `values`. Otherwise, the caller must handle the types.
136
144
// /
137
- // / Indices can be scalable. For example, "4" in "[2, [4], 8]" is scalable.
138
- // / This notation is similar to how scalable dims are marked when defining
139
- // / Vectors. For each value in `integers`, the corresponding `bool` in
140
- // / `scalableVals` encodes whether it's a scalable index.
145
+ // / Integer indices can also be scalable, denoted by the square bracket (e.g.,
146
+ // / "[2, [4], 8]"). For each value in `integers`, the corresponding `bool` in
147
+ // / `scalables` encodes whether it's a scalable index.
148
+ // /
149
+ // / Examples:
150
+ // / * After parsing "[%arg0 : index, 7, 42, %arg42 : i32]":
151
+ // / 1. `result` is filled with the i64 ArrayAttr `[kDynamic, 7, 42,
152
+ // / kDynamic]`
153
+ // / 2. `values` is filled with "[%arg0, %arg1]".
154
+ // / 3. `scalables` is filled with `[false, true, false]`.
155
+ // /
156
+ // / * After parsing `[2, [4], 8]`:
157
+ // / 1. `result` is filled with the i64 ArrayAttr `[2, 4, 8]`
158
+ // / 2. `values` is empty.
159
+ // / 3. `scalables` is filled with `[false, true, false]`.
141
160
ParseResult parseDynamicIndexList (
142
161
OpAsmParser &parser,
143
162
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
144
- DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalableVals ,
163
+ DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalables ,
145
164
SmallVectorImpl<Type> *valueTypes = nullptr ,
146
165
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square);
147
166
inline ParseResult parseDynamicIndexList (
148
167
OpAsmParser &parser,
149
168
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
150
169
DenseI64ArrayAttr &integers, SmallVectorImpl<Type> *valueTypes = nullptr ,
151
170
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
152
- DenseBoolArrayAttr scalableVals = {} ;
153
- return parseDynamicIndexList (parser, values, integers, scalableVals ,
154
- valueTypes, delimiter);
171
+ DenseBoolArrayAttr scalables ;
172
+ return parseDynamicIndexList (parser, values, integers, scalables, valueTypes ,
173
+ delimiter);
155
174
}
156
175
inline ParseResult parseDynamicIndexList (
157
176
OpAsmParser &parser,
158
177
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
159
178
DenseI64ArrayAttr &integers, SmallVectorImpl<Type> &valueTypes,
160
179
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
161
- DenseBoolArrayAttr scalableVals = {} ;
162
- return parseDynamicIndexList (parser, values, integers, scalableVals ,
163
- &valueTypes, delimiter);
180
+ DenseBoolArrayAttr scalables ;
181
+ return parseDynamicIndexList (parser, values, integers, scalables, &valueTypes ,
182
+ delimiter);
164
183
}
165
184
inline ParseResult parseDynamicIndexList (
166
185
OpAsmParser &parser,
167
186
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
168
187
DenseI64ArrayAttr &integers, SmallVectorImpl<Type> &valueTypes,
169
- DenseBoolArrayAttr &scalableVals ,
188
+ DenseBoolArrayAttr &scalables ,
170
189
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
171
-
172
- return parseDynamicIndexList (parser, values, integers, scalableVals,
173
- &valueTypes, delimiter);
190
+ return parseDynamicIndexList (parser, values, integers, scalables, &valueTypes,
191
+ delimiter);
174
192
}
175
193
176
194
// / Verify that a the `values` has as many elements as the number of entries in
0 commit comments