@@ -86,24 +86,46 @@ 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]`.
101
- // /
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.
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`, otherwise.
98
+ // /
99
+ // / If `valueTypes` is provided, the corresponding type of each dynamic value is
100
+ // / printed. Otherwise, the type is not printed. Each type must match the type
101
+ // / of the corresponding value in `values`. The type for integer elements is
102
+ // / `i64` by default and never printed.
103
+ // /
104
+ // / Integer indices can also be scalable, denoted with square brackets (e.g.,
105
+ // / "[2, [4], 8]"). For each value in `integers`, the corresponding `bool` in
106
+ // / `scalables` encodes whether it's a scalable index. If `scalables` is empty
107
+ // / then assume that all indices are non-scalable.
108
+ // /
109
+ // / Examples:
110
+ // /
111
+ // / * Input: `integers = [kDynamic, 7, 42, kDynamic]`,
112
+ // / `values = [%arg0, %arg42]` and
113
+ // / `valueTypes = [index, index]`
114
+ // / prints:
115
+ // / `[%arg0 : index, 7, 42, %arg42 : i32]`
116
+ // /
117
+ // / * Input: `integers = [kDynamic, 7, 42, kDynamic]`,
118
+ // / `values = [%arg0, %arg42]` and
119
+ // / `valueTypes = []`
120
+ // / prints:
121
+ // / `[%arg0, 7, 42, %arg42]`
122
+ // /
123
+ // / * Input: `integers = [2, 4, 8]`,
124
+ // / `values = []` and
125
+ // / `scalables = [false, true, false]`
126
+ // / prints:
127
+ // / `[2, [4], 8]`
128
+ // /
107
129
void printDynamicIndexList (
108
130
OpAsmPrinter &printer, Operation *op, OperandRange values,
109
131
ArrayRef<int64_t > integers, ArrayRef<bool > scalables,
@@ -113,45 +135,54 @@ inline void printDynamicIndexList(
113
135
OpAsmPrinter &printer, Operation *op, OperandRange values,
114
136
ArrayRef<int64_t > integers, TypeRange valueTypes = TypeRange(),
115
137
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
116
- return printDynamicIndexList (printer, op, values, integers, {}, valueTypes ,
117
- delimiter);
138
+ return printDynamicIndexList (printer, op, values, integers, /* scalables= */ {} ,
139
+ valueTypes, delimiter);
118
140
}
119
141
120
- // / Parser hook for custom directive in assemblyFormat.
142
+ // / Parser hooks for custom directive in assemblyFormat.
121
143
// /
122
144
// / custom<DynamicIndexList>($values, $integers)
123
145
// / custom<DynamicIndexList>($values, $integers, type($values))
124
146
// /
125
147
// / 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.
131
- // /
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]".
136
- // /
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.
148
+ // / type `I64ArrayAttr`. Parse a mixed list where each element is either a
149
+ // / static integer or an SSA value. Fill `integers` with the integer ArrayAttr,
150
+ // / where `kDynamic` encodes the position of SSA values. Add the parsed SSA
151
+ // / values to `values` in-order.
152
+ // /
153
+ // / If `valueTypes` is provided, fill it with the types corresponding to each
154
+ // / value in `values`. Otherwise, the caller must handle the types.
155
+ // /
156
+ // / Integer indices can also be scalable, denoted by the square bracket (e.g.,
157
+ // / "[2, [4], 8]"). For each value in `integers`, the corresponding `bool` in
158
+ // / `scalables` encodes whether it's a scalable index.
159
+ // /
160
+ // / Examples:
161
+ // /
162
+ // / * After parsing "[%arg0 : index, 7, 42, %arg42 : i32]":
163
+ // / 1. `result` is filled with `[kDynamic, 7, 42, kDynamic]`
164
+ // / 2. `values` is filled with "[%arg0, %arg1]".
165
+ // / 3. `scalables` is filled with `[false, true, false]`.
166
+ // /
167
+ // / * After parsing `[2, [4], 8]`:
168
+ // / 1. `result` is filled with `[2, 4, 8]`
169
+ // / 2. `values` is empty.
170
+ // / 3. `scalables` is filled with `[false, true, false]`.
171
+ // /
141
172
ParseResult parseDynamicIndexList (
142
173
OpAsmParser &parser,
143
174
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
144
- DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalableVals ,
175
+ DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalables ,
145
176
SmallVectorImpl<Type> *valueTypes = nullptr ,
146
177
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square);
147
178
inline ParseResult parseDynamicIndexList (
148
179
OpAsmParser &parser,
149
180
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
150
181
DenseI64ArrayAttr &integers, SmallVectorImpl<Type> *valueTypes = nullptr ,
151
182
AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) {
152
- DenseBoolArrayAttr scalableVals = {} ;
153
- return parseDynamicIndexList (parser, values, integers, scalableVals ,
154
- valueTypes, delimiter);
183
+ DenseBoolArrayAttr scalables ;
184
+ return parseDynamicIndexList (parser, values, integers, scalables, valueTypes ,
185
+ delimiter);
155
186
}
156
187
157
188
// / Verify that a the `values` has as many elements as the number of entries in
0 commit comments