[Mlir-commits] [mlir] Moving CppEmitter to header file. (PR #106201)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Aug 27 08:02:52 PDT 2024
ddubov100 wrote:
@marbre First of all thanks a lot for such a quick response and comprehensive explanation.
I get your approach, it makes total sense.
We do plan to lower our ops to EmitC and contribute to the dialect and CppEmitter where we can, but it will take time. Would be nice to have solution for in between state and maybe there are other projects in similar situation.
I took a look at emitc.verbatim op. It might be useful in some cases we have.
For any case I will put here an example representing the issue it doesn't cover as I understand it:
`
// CHECK: void arith_minimumf_maximumf(float v1, float v2){
// CHECK: float v3 = (v1 > v2) ? v1 : v2;
// CHECK: float v4 = v1 + v3;
// CHECK: float v5 = (v4 < v2) ? v4 : v2;
// CHECK: return;
// CHECK: }
func.func @arith_minimumf_maximumf(%arg0 : f32, %arg1 : f32) {
%1 = arith.maximumf %arg0, %arg1 : f32
%2 = "emitc.add" (%arg0, %1) : (f32, f32) -> f32
%3 = arith.minimumf %2, %arg1 : f32
return
}
`
Lets say arith ops above can't be lowered today to EmitC dialect and are actually some custom complicated ops.
The translator, which generates code for arith ops and CppEmitter must use same value-to-name map in order to generate valid code. As I understood it emitc.verbatim op doesn't help me with that. In POC I implemented in our project I was able to generate above code using CppEmitter::getOrCreateName when CppEmitter internals were accessible to me.
Will be glad to hear your thoughts.
https://github.com/llvm/llvm-project/pull/106201
More information about the Mlir-commits
mailing list