Skip to content

Commit 321d0b2

Browse files
d0kAlexisPerry
authored andcommitted
Revert "[mlir][Transforms] Dialect conversion: Simplify handling of dropped arguments (llvm#96207)"
This reverts commit f1e0657. It breaks SCF conversion, see test case on the PR.
1 parent 112522e commit 321d0b2

File tree

4 files changed

+156
-119
lines changed

4 files changed

+156
-119
lines changed

mlir/docs/DialectConversion.md

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,6 @@ depending on the situation.
246246
247247
- An argument materialization is used when converting the type of a block
248248
argument during a [signature conversion](#region-signature-conversion).
249-
The new block argument types are specified in a `SignatureConversion`
250-
object. An original block argument can be converted into multiple
251-
block arguments, which is not supported everywhere in the dialect
252-
conversion. (E.g., adaptors support only a single replacement value for
253-
each original value.) Therefore, an argument materialization is used to
254-
convert potentially multiple new block arguments back into a single SSA
255-
value.
256249
257250
* Source Materialization
258251
@@ -266,9 +259,6 @@ depending on the situation.
266259
* When a block argument has been converted to a different type, but
267260
the original argument still has users that will remain live after
268261
the conversion process has finished.
269-
* When a block argument has been dropped, but the argument still has
270-
users that will remain live after the conversion process has
271-
finished.
272262
* When the result type of an operation has been converted to a
273263
different type, but the original result still has users that will
274264
remain live after the conversion process is finished.
@@ -338,40 +328,36 @@ class TypeConverter {
338328
registerConversion(wrapCallback<T>(std::forward<FnT>(callback)));
339329
}
340330
341-
/// All of the following materializations require function objects that are
342-
/// convertible to the following form:
343-
/// `std::optional<Value>(OpBuilder &, T, ValueRange, Location)`,
344-
/// where `T` is any subclass of `Type`. This function is responsible for
345-
/// creating an operation, using the OpBuilder and Location provided, that
346-
/// "casts" a range of values into a single value of the given type `T`. It
347-
/// must return a Value of the converted type on success, an `std::nullopt` if
348-
/// it failed but other materialization can be attempted, and `nullptr` on
349-
/// unrecoverable failure. It will only be called for (sub)types of `T`.
350-
/// Materialization functions must be provided when a type conversion may
351-
/// persist after the conversion has finished.
352-
331+
/// Register a materialization function, which must be convertible to the
332+
/// following form:
333+
/// `Optional<Value> (OpBuilder &, T, ValueRange, Location)`,
334+
/// where `T` is any subclass of `Type`.
335+
/// This function is responsible for creating an operation, using the
336+
/// OpBuilder and Location provided, that "converts" a range of values into a
337+
/// single value of the given type `T`. It must return a Value of the
338+
/// converted type on success, an `std::nullopt` if it failed but other
339+
/// materialization can be attempted, and `nullptr` on unrecoverable failure.
340+
/// It will only be called for (sub)types of `T`.
341+
///
353342
/// This method registers a materialization that will be called when
354-
/// converting (potentially multiple) block arguments that were the result of
355-
/// a signature conversion of a single block argument, to a single SSA value
356-
/// of a legal type.
343+
/// converting an illegal block argument type, to a legal type.
357344
template <typename FnT,
358345
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
359346
void addArgumentMaterialization(FnT &&callback) {
360347
argumentMaterializations.emplace_back(
361348
wrapMaterialization<T>(std::forward<FnT>(callback)));
362349
}
363350
/// This method registers a materialization that will be called when
364-
/// converting a legal replacement value back to an illegal source type.
365-
/// This is used when some uses of the original, illegal value must persist
366-
/// beyond the main conversion.
351+
/// converting a legal type to an illegal source type. This is used when
352+
/// conversions to an illegal type must persist beyond the main conversion.
367353
template <typename FnT,
368354
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
369355
void addSourceMaterialization(FnT &&callback) {
370356
sourceMaterializations.emplace_back(
371357
wrapMaterialization<T>(std::forward<FnT>(callback)));
372358
}
373359
/// This method registers a materialization that will be called when
374-
/// converting an illegal (source) value to a legal (target) type.
360+
/// converting type from an illegal, or source, type to a legal type.
375361
template <typename FnT,
376362
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
377363
void addTargetMaterialization(FnT &&callback) {

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ class TypeConverter {
168168
registerConversion(wrapCallback<T>(std::forward<FnT>(callback)));
169169
}
170170

171-
/// All of the following materializations require function objects that are
172-
/// convertible to the following form:
171+
/// Register a materialization function, which must be convertible to the
172+
/// following form:
173173
/// `std::optional<Value>(OpBuilder &, T, ValueRange, Location)`,
174174
/// where `T` is any subclass of `Type`. This function is responsible for
175175
/// creating an operation, using the OpBuilder and Location provided, that
@@ -179,29 +179,26 @@ class TypeConverter {
179179
/// unrecoverable failure. It will only be called for (sub)types of `T`.
180180
/// Materialization functions must be provided when a type conversion may
181181
/// persist after the conversion has finished.
182-
182+
///
183183
/// This method registers a materialization that will be called when
184-
/// converting (potentially multiple) block arguments that were the result of
185-
/// a signature conversion of a single block argument, to a single SSA value
186-
/// of a legal type.
184+
/// converting an illegal block argument type, to a legal type.
187185
template <typename FnT, typename T = typename llvm::function_traits<
188186
std::decay_t<FnT>>::template arg_t<1>>
189187
void addArgumentMaterialization(FnT &&callback) {
190188
argumentMaterializations.emplace_back(
191189
wrapMaterialization<T>(std::forward<FnT>(callback)));
192190
}
193191
/// This method registers a materialization that will be called when
194-
/// converting a legal replacement value back to an illegal source type.
195-
/// This is used when some uses of the original, illegal value must persist
196-
/// beyond the main conversion.
192+
/// converting a legal type to an illegal source type. This is used when
193+
/// conversions to an illegal type must persist beyond the main conversion.
197194
template <typename FnT, typename T = typename llvm::function_traits<
198195
std::decay_t<FnT>>::template arg_t<1>>
199196
void addSourceMaterialization(FnT &&callback) {
200197
sourceMaterializations.emplace_back(
201198
wrapMaterialization<T>(std::forward<FnT>(callback)));
202199
}
203200
/// This method registers a materialization that will be called when
204-
/// converting an illegal (source) value to a legal (target) type.
201+
/// converting type from an illegal, or source, type to a legal type.
205202
template <typename FnT, typename T = typename llvm::function_traits<
206203
std::decay_t<FnT>>::template arg_t<1>>
207204
void addTargetMaterialization(FnT &&callback) {

0 commit comments

Comments
 (0)