[Mlir-commits] [mlir] [mlir][toy] Update dialect conversion example (PR #150826)
Markus Böck
llvmlistbot at llvm.org
Sun Jul 27 04:53:17 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());
----------------
zero9178 wrote:
Was the previous code using `printOp.getInput()` not okay? My understanding was that it was fine to use the old operands of `op` as long as you are aware of it being of the old type. This is what is happening here with the use of `memref.load`. This is very useful IMO to drive recursive legalization.
https://github.com/llvm/llvm-project/pull/150826
More information about the Mlir-commits
mailing list