[Mlir-commits] [mlir] [mlir][EmitC] Make pre-increment and pre-decrement return left value (PR #212391)
Jianjian Guan
llvmlistbot at llvm.org
Mon Aug 24 00:52:29 PDT 2026
jacquesguan wrote:
> > > Thanks for addressing that @jacquesguan ! Note that the pre-ops only return lvalues in C++: In C, they return rvalues. So these ops need to allow both. Their must-be-inlined behavior should also depend on that, I think.
> >
> >
> > I’m curious about the proper way to handle differences between C and C++ in EmitC. One approach would be to have pre-operations accept both lvalues and rvalues as result types. However, returning rvalues would still be considered incorrect in C++. Alternatively, we could add a flag or attribute to indicate whether the code is being executed in C++ mode.
>
> We initially implemented differentiated between C and C++ in the emitter when starting to upstream EmitC but where ask to drop this. Instead the solution discussed some time back was to implement validation passes that make sure the code complies to a specific language (version). I prototyped this a bit back but wasn't able to land it. Instead we still rely on the convention documented in https://mlir.llvm.org/docs/Dialects/EmitC/. As of today it would be indeed on the user to write conversions that use the desired operations.
As https://mlir.llvm.org/docs/Dialects/EmitC/ said, increment ops should be compatible with C99, so they should return rvalues. @aniragil, what do you think about this solution?
https://github.com/llvm/llvm-project/pull/212391
More information about the Mlir-commits
mailing list