[all-commits] [llvm/llvm-project] 1fa125: [mlir][emitc] Add a variable op
Marius Brehler via All-commits
all-commits at lists.llvm.org
Thu Feb 24 07:28:39 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1fa125111607e2e00e3ce23f69fbc0ce9bb2a207
https://github.com/llvm/llvm-project/commit/1fa125111607e2e00e3ce23f69fbc0ce9bb2a207
Author: Marius Brehler <marius.brehler at iml.fraunhofer.de>
Date: 2022-02-24 (Thu, 24 Feb 2022)
Changed paths:
M mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
M mlir/lib/Dialect/EmitC/IR/EmitC.cpp
M mlir/lib/Target/Cpp/TranslateToCpp.cpp
M mlir/test/Dialect/EmitC/invalid_ops.mlir
M mlir/test/Dialect/EmitC/ops.mlir
M mlir/test/Target/Cpp/const.mlir
A mlir/test/Target/Cpp/variable.mlir
Log Message:
-----------
[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
More information about the All-commits
mailing list