[Mlir-commits] [mlir] [WIP][mlir][EmitC] Model lvalues as a type in EmitC (PR #91475)

Gil Rapaport llvmlistbot at llvm.org
Wed May 15 13:08:16 PDT 2024


================
@@ -2,15 +2,15 @@
 // RUN: mlir-translate -mlir-to-cpp -declare-variables-at-top %s | FileCheck %s -check-prefix=CPP-DECLTOP
 
 func.func @emitc_variable() {
-  %c0 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> i32
-  %c1 = "emitc.variable"(){value = 42 : i32} : () -> i32
-  %c2 = "emitc.variable"(){value = -1 : i32} : () -> i32
-  %c3 = "emitc.variable"(){value = -1 : si8} : () -> si8
-  %c4 = "emitc.variable"(){value = 255 : ui8} : () -> ui8
-  %c5 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.ptr<i32>
-  %c6 = "emitc.variable"(){value = #emitc.opaque<"NULL">} : () -> !emitc.ptr<i32>
-  %c7 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.array<3x7xi32>
-  %c8 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.array<5x!emitc.ptr<i8>>
+  %c0 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<i32>
+  %c1 = "emitc.variable"(){value = 42 : i32} : () -> !emitc.lvalue<i32>
+  %c2 = "emitc.variable"(){value = -1 : i32} : () -> !emitc.lvalue<i32>
+  %c3 = "emitc.variable"(){value = -1 : si8} : () -> !emitc.lvalue<si8>
+  %c4 = "emitc.variable"(){value = 255 : ui8} : () -> !emitc.lvalue<ui8>
+  %c5 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<!emitc.ptr<i32>>
+  %c6 = "emitc.variable"(){value = #emitc.opaque<"NULL">} : () -> !emitc.lvalue<!emitc.ptr<i32>>
+  %c7 = "emitc.variable"(){value = #emitc.opaque<"">} : () -> !emitc.lvalue<!emitc.array<3x7xi32>>
----------------
aniragil wrote:

IIUC the proposed `lvalue<>` type models primarily modifiable lvalues (which array names are not part of), as we use it to mark locations that can be assigned to and loaded from. Perhaps we should have a `mlvalue<>` type and a `lvalue` type trait/interface? The former would be used for variables, array subscriptions etc, and the latter for `!emitc.array`, `!emitc.mlvalue` etc.

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


More information about the Mlir-commits mailing list