[Mlir-commits] [mlir] [mlir][toy] Update dialect conversion example (PR #150826)
Matthias Springer
llvmlistbot at llvm.org
Sun Jul 27 10:51:57 PDT 2025
================
@@ -223,8 +221,11 @@ void ToyToLLVMLoweringPass::runOnOperation() {
populateFuncToLLVMConversionPatterns(typeConverter, patterns);
// The only remaining operation to lower from the `toy` dialect, is the
- // PrintOp.
- patterns.add<PrintOpLowering>(&getContext());
+ // PrintOp. An identity converter is needed because the PrintOp lowering
+ // operates on MemRefType instead of the lowered LLVM struct type.
+ TypeConverter identityConverter;
+ identityConverter.addConversion([](Type type) { return type; });
+ patterns.add<PrintOpLowering>(identityConverter, &getContext());
----------------
matthias-springer wrote:
Good point. I always thought only taking the type of the original operand would be allowed. But using the operand to construct new IR seems to work fine in the conversion driver. (And it will also work fine in the new One-Shot driver.)
https://github.com/llvm/llvm-project/pull/150826
More information about the Mlir-commits
mailing list