[Mlir-commits] [mlir] [mlir][Transforms] Dialect Conversion: No target mat. for 1:N replacement (PR #117513)
Matthias Springer
llvmlistbot at llvm.org
Tue Nov 26 16:22:28 PST 2024
================
@@ -199,24 +211,34 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
// original memref type.
return builder.create<UnrealizedConversionCastOp>(loc, resultType, desc)
.getResult(0);
- });
- // Add generic source and target materializations to handle cases where
- // non-LLVM types persist after an LLVM conversion.
- addSourceMaterialization([&](OpBuilder &builder, Type resultType,
- ValueRange inputs, Location loc) {
- if (inputs.size() != 1)
- return Value();
+ };
- return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
- .getResult(0);
- });
+ // Argument materializations convert from the new block argument types
+ // (multiple SSA values that make up a memref descriptor) back to the
+ // original block argument type.
+ addArgumentMaterialization(unrakedMemRefMaterialization);
+ addArgumentMaterialization(rankedMemRefMaterialization);
+ addSourceMaterialization(unrakedMemRefMaterialization);
+ addSourceMaterialization(rankedMemRefMaterialization);
+
+ // Bare pointer -> Packed MemRef descriptor
----------------
matthias-springer wrote:
> Could you explain why it is desireable to get rid of the argument materailization?
The purpose of an argument materialization is to convert N replacement values into 1 SSA value. It is a workaround around missing 1:N support in the conversion value mapping. In case of a 1:1 conversion, that workaround is not needed because the conversion value mapping can store 1:1 mappings directly.
This is also prefetching a bit from #116524, which removes argument materializations entirely. We are going to need the same type converter setup then.
https://github.com/llvm/llvm-project/pull/117513
More information about the Mlir-commits
mailing list