[Mlir-commits] [mlir] [mlir][toy] Update dialect conversion example (PR #150826)
Mehdi Amini
llvmlistbot at llvm.org
Sun Jul 27 11:23:40 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());
----------------
joker-eph wrote:
How is it safe? Is the driver automatically remapping it when constructing a new operation? Or am I misunderstanding what you mean by "using the operand to construct new IR"?
https://github.com/llvm/llvm-project/pull/150826
More information about the Mlir-commits
mailing list