[Mlir-commits] [mlir] [mlir][EmitC] Refactor MLIR Translate To Cpp (PR #84973)

Weizhe Chen llvmlistbot at llvm.org
Wed Mar 13 10:13:33 PDT 2024


weizchen wrote:

Hi @marbre, thank you so much for this detailed explanation and references! I totally agree that discussion is needed on this PR's implementation. 

>  Instead of extending the emitter, we aim to further develop the dialect in a way that everything can be accomplished through conversions. To me, it seems that the proposed changes do not align with this intention.

I also discover the trend of adding more conversions to EmitC to remove direct dialect translations which totally makes sense to me. I agree that separating out dialects like Func in this PR does not align with the current emitc strategy but what I vision for this is we have a fully supported emitter from EmitC Dialect, all main dialects are first translated to EmitC and then to C code. While the `Dialects` folder is not intended for Func or CF dialects shown in this PR, but for dialects like ArmSVE or X86Vector that will require more specialized translation.

> Furthermore, there are some mechanical issues. For example the implementation in CppTranslationUtils heavily relies on EmitC ops and further pulls in the CF dialect. Hence, it not just provides shared functions as most functions are not dialect independent.

And for this, I really struggled creating such Utils file, especially as the translations are all moving towards the EmitC Dialect. The original idea was to use this file for similar op translations to avoid code duplication (like arith constant and emitc constant), and I want to keep `EmitCToCppTranslation.cpp` purely containing `printOperation`. But you are right, making these functions living with EmitC translation would make sense.

This PR actually originated from a need to translate our customized dialect to c++ where we found current emitc structure is a bit hard to inherit and reuse. So we think that with this, cpp translation might be more sustainable and extensible. I wonder what do you think of this, your idea is highly valued. Thanks!

https://github.com/llvm/llvm-project/pull/84973


More information about the Mlir-commits mailing list