Skip to content

Commit 53f97f5

Browse files
ex
1 parent 6041464 commit 53f97f5

File tree

14 files changed

+227
-291
lines changed

14 files changed

+227
-291
lines changed

flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ class BoxprocTypeRewriter : public mlir::TypeConverter {
172172
addConversion([&](TypeDescType ty) {
173173
return TypeDescType::get(convertType(ty.getOfTy()));
174174
});
175-
addArgumentMaterialization(materializeProcedure);
176175
addSourceMaterialization(materializeProcedure);
177176
addTargetMaterialization(materializeProcedure);
178177
}

mlir/docs/DialectConversion.md

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,6 @@ cannot. These materializations are used by the conversion framework to ensure
242242
type safety during the conversion process. There are several types of
243243
materializations depending on the situation.
244244
245-
* Argument Materialization
246-
247-
- An argument materialization is used when converting the type of a block
248-
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. An argument materialization is also used when replacing an op
256-
result with multiple values.
257-
258245
* Source Materialization
259246
260247
- A source materialization is used when a value was replaced with a value
@@ -343,17 +330,6 @@ class TypeConverter {
343330
/// Materialization functions must be provided when a type conversion may
344331
/// persist after the conversion has finished.
345332
346-
/// This method registers a materialization that will be called when
347-
/// converting (potentially multiple) block arguments that were the result of
348-
/// a signature conversion of a single block argument, to a single SSA value
349-
/// with the old argument type.
350-
template <typename FnT,
351-
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
352-
void addArgumentMaterialization(FnT &&callback) {
353-
argumentMaterializations.emplace_back(
354-
wrapMaterialization<T>(std::forward<FnT>(callback)));
355-
}
356-
357333
/// This method registers a materialization that will be called when
358334
/// converting a replacement value back to its original source type.
359335
/// This is used when some uses of the original value persist beyond the main
@@ -406,12 +382,11 @@ done explicitly via a conversion pattern.
406382
To convert the types of block arguments within a Region, a custom hook on the
407383
`ConversionPatternRewriter` must be invoked; `convertRegionTypes`. This hook
408384
uses a provided type converter to apply type conversions to all blocks of a
409-
given region. As noted above, the conversions performed by this method use the
410-
argument materialization hook on the `TypeConverter`. This hook also takes an
411-
optional `TypeConverter::SignatureConversion` parameter that applies a custom
412-
conversion to the entry block of the region. The types of the entry block
413-
arguments are often tied semantically to the operation, e.g.,
414-
`func::FuncOp`, `AffineForOp`, etc.
385+
given region. This hook also takes an optional
386+
`TypeConverter::SignatureConversion` parameter that applies a custom conversion
387+
to the entry block of the region. The types of the entry block arguments are
388+
often tied semantically to the operation, e.g., `func::FuncOp`, `AffineForOp`,
389+
etc.
415390

416391
To convert the signature of just one given block, the
417392
`applySignatureConversion` hook can be used.

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ class TypeConverter {
181181
/// converting (potentially multiple) block arguments that were the result of
182182
/// a signature conversion of a single block argument, to a single SSA value
183183
/// with the old block argument type.
184+
///
185+
/// Note: Argument materializations are used only with the 1:N dialect
186+
/// conversion driver. The 1:N dialect conversion driver will be removed soon
187+
/// and so will be argument materializations.
184188
template <typename FnT, typename T = typename llvm::function_traits<
185189
std::decay_t<FnT>>::template arg_t<1>>
186190
void addArgumentMaterialization(FnT &&callback) {
@@ -880,15 +884,7 @@ class ConversionPatternRewriter final : public PatternRewriter {
880884
void replaceOp(Operation *op, Operation *newOp) override;
881885

882886
/// Replace the given operation with the new value ranges. The number of op
883-
/// results and value ranges must match. If an original SSA value is replaced
884-
/// by multiple SSA values (i.e., a value range has more than 1 element), the
885-
/// conversion driver will insert an argument materialization to convert the
886-
/// N SSA values back into 1 SSA value of the original type. The given
887-
/// operation is erased.
888-
///
889-
/// Note: The argument materialization is a workaround until we have full 1:N
890-
/// support in the dialect conversion. (It is going to disappear from both
891-
/// `replaceOpWithMultiple` and `applySignatureConversion`.)
887+
/// results and value ranges must match. The given operation is erased.
892888
void replaceOpWithMultiple(Operation *op, ArrayRef<ValueRange> newValues);
893889

894890
/// PatternRewriter hook for erasing a dead operation. The uses of this
@@ -1285,8 +1281,8 @@ struct ConversionConfig {
12851281
// represented at the moment.
12861282
RewriterBase::Listener *listener = nullptr;
12871283

1288-
/// If set to "true", the dialect conversion attempts to build source/target/
1289-
/// argument materializations through the type converter API in lieu of
1284+
/// If set to "true", the dialect conversion attempts to build source/target
1285+
/// materializations through the type converter API in lieu of
12901286
/// "builtin.unrealized_conversion_cast ops". The conversion process fails if
12911287
/// at least one materialization could not be built.
12921288
///

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
189189
auto unrakedMemRefMaterialization = [&](OpBuilder &builder,
190190
UnrankedMemRefType resultType,
191191
ValueRange inputs, Location loc) {
192-
// An argument materialization must return a value of type
193-
// `resultType`, so insert a cast from the memref descriptor type
194-
// (!llvm.struct) to the original memref type.
192+
// A source materialization must return a value of type `resultType`, so
193+
// insert a cast from the memref descriptor type (!llvm.struct) to the
194+
// original memref type.
195195
Value packed =
196196
packUnrankedMemRefDesc(builder, resultType, inputs, loc, *this);
197197
if (!packed)
@@ -223,7 +223,7 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
223223
auto rankedMemRefMaterialization = [&](OpBuilder &builder,
224224
MemRefType resultType,
225225
ValueRange inputs, Location loc) {
226-
// An argument materialization must return a value of type `resultType`,
226+
// A source materialization must return a value of type `resultType`,
227227
// so insert a cast from the memref descriptor type (!llvm.struct) to the
228228
// original memref type.
229229
Value packed =
@@ -234,11 +234,9 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
234234
.getResult(0);
235235
};
236236

237-
// Argument materializations convert from the new block argument types
238-
// (multiple SSA values that make up a memref descriptor) back to the
237+
// Source materializations convert from the new block argument types
238+
// (e.g., multiple SSA values that make up a memref descriptor) back to the
239239
// original block argument type.
240-
addArgumentMaterialization(unrakedMemRefMaterialization);
241-
addArgumentMaterialization(rankedMemRefMaterialization);
242240
addSourceMaterialization(unrakedMemRefMaterialization);
243241
addSourceMaterialization(rankedMemRefMaterialization);
244242

mlir/lib/Dialect/EmitC/Transforms/TypeConversions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void mlir::populateEmitCSizeTTypeConversions(TypeConverter &converter) {
3333

3434
converter.addSourceMaterialization(materializeAsUnrealizedCast);
3535
converter.addTargetMaterialization(materializeAsUnrealizedCast);
36-
converter.addArgumentMaterialization(materializeAsUnrealizedCast);
3736
}
3837

3938
/// Get an unsigned integer or size data type corresponding to \p ty.

mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ class DetensorizeTypeConverter : public TypeConverter {
154154
});
155155

156156
addSourceMaterialization(sourceMaterializationCallback);
157-
addArgumentMaterialization(sourceMaterializationCallback);
158157
}
159158
};
160159

mlir/lib/Dialect/Quant/Transforms/StripFuncQuantTypes.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class QuantizedTypeConverter : public TypeConverter {
5656
addConversion(convertQuantizedType);
5757
addConversion(convertTensorType);
5858

59-
addArgumentMaterialization(materializeConversion);
6059
addSourceMaterialization(materializeConversion);
6160
addTargetMaterialization(materializeConversion);
6261
}

mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ SparseTensorTypeToBufferConverter::SparseTensorTypeToBufferConverter() {
6969

7070
// Required by scf.for 1:N type conversion.
7171
addSourceMaterialization(materializeTuple);
72-
73-
// Required as a workaround until we have full 1:N support.
74-
addArgumentMaterialization(materializeTuple);
7572
}
7673

7774
//===----------------------------------------------------------------------===//

mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ void mlir::vector::populateVectorLinearizeTypeConversionsAndLegality(
481481

482482
return builder.create<vector::ShapeCastOp>(loc, type, inputs.front());
483483
};
484-
typeConverter.addArgumentMaterialization(materializeCast);
485484
typeConverter.addSourceMaterialization(materializeCast);
486485
typeConverter.addTargetMaterialization(materializeCast);
487486
target.markUnknownOpDynamicallyLegal(

0 commit comments

Comments
 (0)