@@ -88,11 +88,11 @@ def EmitC_ApplyOp : EmitC_Op<"apply", [CExpression]> {
88
88
89
89
```mlir
90
90
// Custom form of applying the & operator.
91
- %0 = emitc.apply "&"(%arg0) : (i32) -> !emitc.ptr<i32>
91
+ %0 = emitc.apply "&"(%arg0) : (!emitc.lvalue< i32> ) -> !emitc.ptr<i32>
92
92
93
93
// Generic form of the same operation.
94
94
%0 = "emitc.apply"(%arg0) {applicableOperator = "&"}
95
- : (i32) -> !emitc.ptr<i32>
95
+ : (!emitc.lvalue< i32> ) -> !emitc.ptr<i32>
96
96
97
97
```
98
98
}];
@@ -846,6 +846,16 @@ def EmitC_LoadOp : EmitC_Op<"load", [
846
846
This operation loads the content of a modifiable lvalue into an SSA value.
847
847
Modifications of the lvalue executed after the load are not observable on
848
848
the produced value.
849
+
850
+ Example:
851
+
852
+ ```mlir
853
+ %1 = emitc.load %0 : !emitc.lvalue<i32>
854
+ ```
855
+ ```c++
856
+ // Code emitted for the operation above.
857
+ int32_t v2 = v1;
858
+ ```
849
859
}];
850
860
851
861
let arguments = (ins
@@ -937,7 +947,7 @@ def EmitC_MemberOp : EmitC_Op<"member"> {
937
947
938
948
```mlir
939
949
%0 = "emitc.member" (%arg0) {member = "a"}
940
- : (!emitc.opaque<"mystruct">) -> i32
950
+ : (!emitc.lvalue<!emitc. opaque<"mystruct">> ) -> !emitc.lvalue< i32>
941
951
```
942
952
}];
943
953
@@ -958,7 +968,8 @@ def EmitC_MemberOfPtrOp : EmitC_Op<"member_of_ptr"> {
958
968
959
969
```mlir
960
970
%0 = "emitc.member_of_ptr" (%arg0) {member = "a"}
961
- : (!emitc.ptr<!emitc.opaque<"mystruct">>) -> i32
971
+ : (!emitc.lvalue<!emitc.ptr<!emitc.opaque<"mystruct">>>)
972
+ -> !emitc.lvalue<i32>
962
973
```
963
974
}];
964
975
@@ -1061,10 +1072,10 @@ def EmitC_VariableOp : EmitC_Op<"variable", []> {
1061
1072
As an example, it is valid to create pointers to `variable` operations
1062
1073
by using `apply` operations and pass these to a `call` operation.
1063
1074
```mlir
1064
- %0 = "emitc.variable"() {value = 0 : i32} : () -> i32
1065
- %1 = "emitc.variable"() {value = 0 : i32} : () -> i32
1066
- %2 = emitc.apply "&"(%0) : (i32) -> !emitc.ptr<i32>
1067
- %3 = emitc.apply "&"(%1) : (i32) -> !emitc.ptr<i32>
1075
+ %0 = "emitc.variable"() {value = 0 : i32} : () -> !emitc.lvalue< i32>
1076
+ %1 = "emitc.variable"() {value = 0 : i32} : () -> !emitc.lvalue< i32>
1077
+ %2 = emitc.apply "&"(%0) : (!emitc.lvalue< i32> ) -> !emitc.ptr<i32>
1078
+ %3 = emitc.apply "&"(%1) : (!emitc.lvalue< i32> ) -> !emitc.ptr<i32>
1068
1079
emitc.call_opaque "write"(%2, %3)
1069
1080
: (!emitc.ptr<i32>, !emitc.ptr<i32>) -> ()
1070
1081
```
@@ -1138,6 +1149,7 @@ def EmitC_GetGlobalOp : EmitC_Op<"get_global",
1138
1149
1139
1150
```mlir
1140
1151
%x = emitc.get_global @foo : !emitc.array<2xf32>
1152
+ %y = emitc.get_global @bar : !emitc.lvalue<i32>
1141
1153
```
1142
1154
}];
1143
1155
@@ -1192,11 +1204,11 @@ def EmitC_AssignOp : EmitC_Op<"assign", []> {
1192
1204
1193
1205
```mlir
1194
1206
// Integer variable
1195
- %0 = "emitc.variable"(){value = 42 : i32} : () -> i32
1207
+ %0 = "emitc.variable"(){value = 42 : i32} : () -> !emitc.lvalue< i32>
1196
1208
%1 = emitc.call_opaque "foo"() : () -> (i32)
1197
1209
1198
1210
// Assign emitted as `... = ...;`
1199
- "emitc.assign"(%0, %1) : (i32, i32) -> ()
1211
+ "emitc.assign"(%0, %1) : (!emitc.lvalue< i32> , i32) -> ()
1200
1212
```
1201
1213
}];
1202
1214
@@ -1298,8 +1310,10 @@ def EmitC_SubscriptOp : EmitC_Op<"subscript", []> {
1298
1310
```mlir
1299
1311
%i = index.constant 1
1300
1312
%j = index.constant 7
1301
- %0 = emitc.subscript %arg0[%i, %j] : !emitc.array<4x8xf32>, index, index
1302
- %1 = emitc.subscript %arg1[%i] : !emitc.ptr<i32>, index
1313
+ %0 = emitc.subscript %arg0[%i, %j] : (!emitc.array<4x8xf32>, index, index)
1314
+ -> !emitc.lvalue<f32>
1315
+ %1 = emitc.subscript %arg1[%i] : (!emitc.ptr<i32>, index)
1316
+ -> !emitc.lvalue<i32>
1303
1317
```
1304
1318
}];
1305
1319
let arguments = (ins Arg<AnyTypeOf<[
0 commit comments