Skip to content

Commit 8d85dd6

Browse files
committed
review comments
1 parent 731eb8e commit 8d85dd6

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

mlir/include/mlir/Dialect/EmitC/IR/EmitC.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,11 +1169,11 @@ def EmitC_SubscriptOp : EmitC_Op<"subscript",
11691169
```mlir
11701170
%i = index.constant 1
11711171
%j = index.constant 7
1172-
%0 = emitc.subscript %arg0[%i][%j] : (!emitc.array<4x8xf32>) -> f32
1172+
%0 = emitc.subscript %arg0[%i, %j] : <4x8xf32>, index, index
11731173
```
11741174
}];
11751175
let arguments = (ins Arg<EmitC_ArrayType, "the reference to load from">:$array,
1176-
Variadic<Index>:$indices);
1176+
Variadic<IntegerIndexOrOpaqueType>:$indices);
11771177
let results = (outs AnyType:$result);
11781178

11791179
let builders = [
@@ -1183,7 +1183,7 @@ def EmitC_SubscriptOp : EmitC_Op<"subscript",
11831183
];
11841184

11851185
let hasVerifier = 1;
1186-
let assemblyFormat = "$array `[` $indices `]` attr-dict `:` type($array)";
1186+
let assemblyFormat = "$array `[` $indices `]` attr-dict `:` type($array) `,` type($indices)";
11871187
}
11881188

11891189

mlir/test/Dialect/EmitC/invalid_ops.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func.func @test_misplaced_yield() {
235235
// -----
236236

237237
func.func @test_assign_to_non_variable(%arg1: f32, %arg2: f32) {
238-
// expected-error @+1 {{'emitc.assign' op requires first operand (<block argument> of type 'f32' at index: 1) to be a Variable}}
238+
// expected-error @+1 {{'emitc.assign' op requires first operand (<block argument> of type 'f32' at index: 1) to be a Variable or subscript}}
239239
emitc.assign %arg1 : f32 to %arg2 : f32
240240
return
241241
}
@@ -392,6 +392,6 @@ func.func @logical_or_resulterror(%arg0: i32, %arg1: i32) {
392392

393393
func.func @test_subscript_indices_mismatch(%arg0: !emitc.array<4x8xf32>, %arg2: index) {
394394
// expected-error @+1 {{'emitc.subscript' op requires number of indices (1) to match the rank of the array type (2)}}
395-
%0 = emitc.subscript %arg0[%arg2] : <4x8xf32>
395+
%0 = emitc.subscript %arg0[%arg2] : <4x8xf32>, index
396396
return
397397
}

mlir/test/Target/Cpp/subscript.mlir

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@
22
// RUN: mlir-translate -mlir-to-cpp -declare-variables-at-top %s | FileCheck %s
33

44
func.func @load_store(%arg0: !emitc.array<4x8xf32>, %arg1: !emitc.array<3x5xf32>, %arg2: index, %arg3: index) {
5-
%0 = emitc.subscript %arg0[%arg2, %arg3] : <4x8xf32>
6-
%1 = emitc.subscript %arg1[%arg2, %arg3] : <3x5xf32>
5+
%0 = emitc.subscript %arg0[%arg2, %arg3] : <4x8xf32>, index, index
6+
%1 = emitc.subscript %arg1[%arg2, %arg3] : <3x5xf32>, index, index
77
emitc.assign %0 : f32 to %1 : f32
88
return
99
}
1010
// CHECK: void load_store(float [[ARR1:[^ ]*]][4][8], float [[ARR2:[^ ]*]][3][5],
1111
// CHECK-SAME: size_t [[I:[^ ]*]], size_t [[J:[^ ]*]])
1212
// CHECK-NEXT: [[ARR2]][[[I]]][[[J]]] = [[ARR1]][[[I]]][[[J]]];
13+
14+
emitc.func @func1(%arg0 : f32) {
15+
emitc.return
16+
}
17+
18+
emitc.func @call_arg(%arg0: !emitc.array<4x8xf32>, %i: i32, %j: i16,
19+
%k: i8) {
20+
%0 = emitc.subscript %arg0[%i, %j] : <4x8xf32>, i32, i16
21+
%1 = emitc.subscript %arg0[%j, %k] : <4x8xf32>, i16, i8
22+
23+
emitc.call @func1 (%0) : (f32) -> ()
24+
emitc.call_opaque "func2" (%1) : (f32) -> ()
25+
emitc.call_opaque "func3" (%0, %1) { args = [1 : index, 0 : index] } : (f32, f32) -> ()
26+
emitc.return
27+
}
28+
// CHECK: void call_arg(float [[ARR1:[^ ]*]][4][8], int32_t [[I:[^ ]*]],
29+
// CHECK-SAME: int16_t [[J:[^ ]*]], int8_t [[K:[^ ]*]])
30+
// CHECK-NEXT: func1([[ARR1]][[[I]]][[[J]]]);
31+
// CHECK-NEXT: func2([[ARR1]][[[J]]][[[K]]]);
32+
// CHECK-NEXT: func3([[ARR1]][[[J]]][[[K]]], [[ARR1]][[[I]]][[[J]]]);

0 commit comments

Comments
 (0)