Commit f179e98
authored
[mlir][emitc] Fix bug in ApplyOp translation (#155171)
The translator emits `emitc.apply` incorrectly when the op is part of an
expression, as it prints the name of the operand instead of calling
emitOperand() which takes into account the expression being emitted,
leaving out the part of the expression feeding this op, e.g.
```mlir
func.func @foo(%a: i32, %p: !emitc.ptr<i32>) -> i32 {
%c = emitc.expression : i32 {
%e = emitc.sub %p, %a : (!emitc.ptr<i32>, i32) -> !emitc.ptr<i32>
%d = emitc.apply "*"(%e) : (!emitc.ptr<i32>) -> i32
emitc.yield %d : i32
}
return %c : i32
}
```
translates to:
```C
int32_t foo(int32_t v1, int32_t* v2) {
int32_t v3 = *v4;
return v3;
}
```
instead of:
```C
int32_t foo(int32_t v1, int32_t* v2) {
int32_t v3 = *(v2 - v1);
return v3;
}
```1 parent 4780bd9 commit f179e98
File tree
2 files changed
+20
-3
lines changed- mlir
- lib/Target/Cpp
- test/Target/Cpp
2 files changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
785 | | - | |
786 | | - | |
787 | | - | |
| 785 | + | |
788 | 786 | | |
789 | 787 | | |
790 | 788 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
298 | 317 | | |
299 | 318 | | |
300 | 319 | | |
| |||
0 commit comments