[Mlir-commits] [mlir] [mlir][emitc] Deferred emission as expressions (PR #159975)

Gil Rapaport llvmlistbot at llvm.org
Sun Apr 26 03:21:33 PDT 2026


================
@@ -493,6 +494,15 @@ def EmitC_DereferenceOp : EmitC_Op<"dereference", [
     $pointer `:` qualified(type($pointer)) attr-dict
   }];
   let hasVerifier = 1;
+
+  let extraClassDeclaration = [{
----------------
aniragil wrote:

> would a mixin `AlwaysInlineCExpression` make sense here?
> 
> to set this in a single place:
> 
> ```
>       bool hasSideEffects() { return false; }
>       bool alwaysInline()   { return true;  }
> ```
> 
> Something like `EmitC_UnaryOp` is doing

Hmmm ... good question.
Technically (even though it currently follows) we don't enforce no-side-effects on always-inline ops: as its a translation directive, it might be useful for ops that do have side effects and were placed such that the side effect is movable to the user. So we could have such a convenience trait, but it won't necessarily be used in all cases (which might be misleading).
There's also a small subtlety with LiteralOp compared to the others - it is always inlined by design, not by C's limitation. It doesn't make a difference at this point, but if we add C++ reference support, the others would actually become "conditionally-must-be-inlined", depending on whether we emit C or C++. It then might make sense to have different traits for these cases.
I can add a concrete implementation in this PR, or merge it as-is and open a new PR for this discussion. WDYT?

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


More information about the Mlir-commits mailing list