Gil Rapaport 89c9f7e34c
[mlir][emitc] Inline expressions with side-effects (#161356)
So far the translator only inlined expressions having no side effects,
as rescheduling their evaluation doesn't break semantics. This patch
adds inlining of expressions containing side effects if defined just
before their use, e.g.,

```mlir
    %c = emitc.expression %a, %b : (i32, !emitc.ptr<i32>) -> i32 {
    %e = emitc.sub %a, %b : (!emitc.ptr<i32>, i32) -> !emitc.ptr<i32>
    %d = emitc.apply "*"(%e) : (!emitc.ptr<i32>) -> i32
    emitc.yield %d : i32
  }
  emitc.return %c : i32
```

This restriction is meant to keep the translator as simple as possible,
leaving it to transformations to analyze and reorder ops as needed in
more complicated cases.
The patch handles inlining into `emitc.return`, `emitc.if`,
`emitc.switch` and (to some extent) `emitc.assign`.
2025-10-13 11:01:25 +03:00
..