diff options
author | Marius Brehler <marius.brehler@iml.fraunhofer.de> | 2022-02-17 09:57:09 +0000 |
---|---|---|
committer | Marius Brehler <marius.brehler@iml.fraunhofer.de> | 2022-02-24 15:25:21 +0000 |
commit | 1fa125111607e2e00e3ce23f69fbc0ce9bb2a207 (patch) | |
tree | cf94988bc5efb86c15ebb7176c93537b52d7a75b /llvm/lib/Transforms/Utils/ModuleUtils.cpp | |
parent | 70b1f6de539867353940d3dcb8b25786d5082d63 (diff) | |
download | llvm-1fa125111607e2e00e3ce23f69fbc0ce9bb2a207.zip llvm-1fa125111607e2e00e3ce23f69fbc0ce9bb2a207.tar.gz llvm-1fa125111607e2e00e3ce23f69fbc0ce9bb2a207.tar.bz2 |
[mlir][emitc] Add a variable op
This adds a variable op, emitted as C/C++ locale variable, which can be
used if the `emitc.constant` op is not sufficient.
As an example, the canonicalization pass would transform
```mlir
%0 = "emitc.constant"() {value = 0 : i32} : () -> i32
%1 = "emitc.constant"() {value = 0 : i32} : () -> i32
%2 = emitc.apply "&"(%0) : (i32) -> !emitc.ptr<i32>
%3 = emitc.apply "&"(%1) : (i32) -> !emitc.ptr<i32>
emitc.call "write"(%2, %3) : (!emitc.ptr<i32>, !emitc.ptr<i32>) -> ()
```
into
```mlir
%0 = "emitc.constant"() {value = 0 : i32} : () -> i32
%1 = emitc.apply "&"(%0) : (i32) -> !emitc.ptr<i32>
%2 = emitc.apply "&"(%0) : (i32) -> !emitc.ptr<i32>
emitc.call "write"(%1, %2) : (!emitc.ptr<i32>, !emitc.ptr<i32>) -> ()
```
resulting in pointer aliasing, as %1 and %2 point to the same address.
In such a case, the `emitc.variable` operation can be used instead.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D120098
Diffstat (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp')
0 files changed, 0 insertions, 0 deletions