Skip to content

Commit 2cdd157

Browse files
Sair Teamcopybara-github
authored andcommitted
Rename all uses of removed standard ops to arithmetic ops.
PiperOrigin-RevId: 401622615
1 parent 518972a commit 2cdd157

25 files changed

+177
-174
lines changed

test/canonicalization.mlir

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func @deduplicate_map_input(%arg0: f32) {
1414
// CHECK: ^bb0(%[[V1:.*]]: f32):
1515
^bb0(%arg1: f32, %arg2: f32):
1616
// CHECK: addf %[[V1]], %[[V1]] : f32
17-
%1 = addf %arg1, %arg2 : f32
17+
%1 = arith.addf %arg1, %arg2 : f32
1818
call @use(%1) : (f32) -> ()
1919
sair.return
2020
// CHECK: } : #sair.shape<()>, (f32) -> ()
@@ -39,7 +39,7 @@ func @deduplicate_map_input_instances(%arg0: f32) {
3939
]
4040
} {
4141
^bb0(%arg1: f32, %arg2: f32):
42-
%1 = addf %arg1, %arg2 : f32
42+
%1 = arith.addf %arg1, %arg2 : f32
4343
call @use(%1) : (f32) -> ()
4444
sair.return
4545
} : #sair.shape<()>, (f32, f32) -> ()
@@ -54,8 +54,8 @@ func @deduplicate_map_output() {
5454
// CHECK: %[[V0:.*]] = sair.map
5555
%0, %1 = sair.map {
5656
^bb0:
57-
// CHECK: %[[V1:.*]] = constant
58-
%2 = constant 1.0 : f32
57+
// CHECK: %[[V1:.*]] = arith.constant
58+
%2 = arith.constant 1.0 : f32
5959
// CHECK: sair.return %[[V1]] : f32
6060
sair.return %2, %2 : f32, f32
6161
// CHECK: #sair.shape<()>, () -> f32
@@ -68,7 +68,7 @@ func @deduplicate_map_output() {
6868

6969
// CHECK-LABEL: @fold_empty_proj
7070
func @fold_empty_proj(%arg0: f32) {
71-
%n = constant 8 : index
71+
%n = arith.constant 8 : index
7272
%0 = sair.program {
7373
%sn = sair.from_scalar %n : !sair.value<(), index>
7474
%1 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -86,7 +86,7 @@ func @fold_empty_proj(%arg0: f32) {
8686

8787
// CHECK-LABEL: @fold_empty_fby
8888
func @fold_empty_fby(%arg0: f32) {
89-
%n = constant 8 : index
89+
%n = arith.constant 8 : index
9090
%0 = sair.program {
9191
%sn = sair.from_scalar %n : !sair.value<(), index>
9292
%1 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -104,7 +104,7 @@ func @fold_empty_fby(%arg0: f32) {
104104

105105
// CHECK-LABEL: @merge_proj
106106
func @merge_proj(%arg0: f32) {
107-
%n = constant 8 : index
107+
%n = arith.constant 8 : index
108108
%0 = sair.program {
109109
%sn = sair.from_scalar %n : !sair.value<(), index>
110110
%1 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -124,7 +124,7 @@ func @merge_proj(%arg0: f32) {
124124

125125
// CHECK-LABEL: @remove_cyclic_fby
126126
func @remove_cyclic_fby(%arg0: f32, %arg1: memref<?x?x?xf32>) {
127-
%n = constant 8 : index
127+
%n = arith.constant 8 : index
128128
sair.program {
129129
%sn = sair.from_scalar %n : !sair.value<(), index>
130130
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -145,7 +145,7 @@ func @remove_cyclic_fby(%arg0: f32, %arg1: memref<?x?x?xf32>) {
145145

146146
// CHECK-LABEL: @remove_useless_dims_fby
147147
func @remove_useless_dims_fby(%arg0: f32) {
148-
%n = constant 8 : index
148+
%n = arith.constant 8 : index
149149
%0 = sair.program {
150150
%sn = sair.from_scalar %n : !sair.value<(), index>
151151
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -167,7 +167,7 @@ func @remove_useless_dims_fby(%arg0: f32) {
167167

168168
// CHECK-LABEL: @remove_useless_dims_proj
169169
func @remove_useless_dims_proj(%arg0: f32) {
170-
%n = constant 8 : index
170+
%n = arith.constant 8 : index
171171
%0 = sair.program {
172172
%sn = sair.from_scalar %n : !sair.value<(), index>
173173
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -189,7 +189,7 @@ func @remove_useless_dims_proj(%arg0: f32) {
189189

190190
// CHECK-LABEL: @remove_useless_dims_proj_dependent
191191
func @remove_useless_dims_proj_dependent(%arg0: f32, %arg1: index) {
192-
%n = constant 8 : index
192+
%n = arith.constant 8 : index
193193
%0 = sair.program {
194194
%sn = sair.from_scalar %n : !sair.value<(), index>
195195
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -217,7 +217,7 @@ func @remove_useless_dims_proj_dependent(%arg0: f32, %arg1: index) {
217217

218218
// CHECK-LABEL: @mappings
219219
func @mappings(%arg0: f32) {
220-
%n = constant 8 : index
220+
%n = arith.constant 8 : index
221221
%0 = sair.program {
222222
%sn = sair.from_scalar %n : !sair.value<(), index>
223223
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>

test/default_expansion.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ func @map() {
77
// CHECK-SAME: expansion = "map"
88
%0 = sair.map attributes {instances = [{}]} {
99
^bb0:
10-
%c0 = constant 1.0 : f32
10+
%c0 = arith.constant 1.0 : f32
1111
sair.return %c0 : f32
1212
} : #sair.shape<()>, () -> (f32)
1313
sair.exit

test/default_storage.mlir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ func @memory_space_is_set() {
77
// CHECK: storage = [{layout = #sair.named_mapping<[] -> ()>, space = "register"}]
88
%0 = sair.map attributes {instances = [{loop_nest = []}]} {
99
^bb0:
10-
%c1 = constant 1.0 : f32
10+
%c1 = arith.constant 1.0 : f32
1111
sair.return %c1 : f32
1212
} : #sair.shape<()>, () -> f32
1313
sair.exit
@@ -27,7 +27,7 @@ func @preserve_memory_space() {
2727
}]
2828
} {
2929
^bb0:
30-
%c1 = constant 1.0 : f32
30+
%c1 = arith.constant 1.0 : f32
3131
sair.return %c1 : f32
3232
} : #sair.shape<()>, () -> f32
3333
sair.exit
@@ -37,7 +37,7 @@ func @preserve_memory_space() {
3737

3838
// CHECK-LABEL: @multi_dim
3939
func @multi_dim(%arg0: f32, %arg1: memref<8x8xf32>) {
40-
%n = constant 8 : index
40+
%n = arith.constant 8 : index
4141
sair.program {
4242
%sn = sair.from_scalar %n : !sair.value<(), index>
4343
%0 = sair.dyn_range %sn : !sair.dyn_range
@@ -80,7 +80,7 @@ func @multi_dim(%arg0: f32, %arg1: memref<8x8xf32>) {
8080

8181
// CHECK-LABEL: @to_memref_proj_fby
8282
func @to_memref_proj_fby(%arg0: f32, %arg1: memref<f32>) {
83-
%n = constant 8 : index
83+
%n = arith.constant 8 : index
8484
sair.program {
8585
%sn = sair.from_scalar %n : !sair.value<(), index>
8686
%0 = sair.dyn_range %sn : !sair.dyn_range
@@ -117,7 +117,7 @@ func @to_memref_proj_fby(%arg0: f32, %arg1: memref<f32>) {
117117

118118
// CHECK-LABEL: @propagate_storage
119119
func @propagate_storage(%arg0: f32) {
120-
%n = constant 8 : index
120+
%n = arith.constant 8 : index
121121
sair.program {
122122
%sn = sair.from_scalar %n : !sair.value<(), index>
123123
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -137,7 +137,7 @@ func @propagate_storage(%arg0: f32) {
137137

138138
// CHECK-LABEL: @non_rectangular
139139
func @non_rectangular_shape(%arg0: f32, %arg1: index) {
140-
%n = constant 8 : index
140+
%n = arith.constant 8 : index
141141
sair.program {
142142
%sn = sair.from_scalar %n : !sair.value<(), index>
143143
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>
@@ -171,7 +171,7 @@ func @non_rectangular_shape(%arg0: f32, %arg1: index) {
171171

172172
// CHECK-LABEL: @buffer_reuse
173173
func @buffer_reuse(%arg0: f32) {
174-
%n = constant 8 : index
174+
%n = arith.constant 8 : index
175175
sair.program {
176176
%sn = sair.from_scalar %n : !sair.value<(), index>
177177
%0 = sair.from_scalar %arg0 : !sair.value<(), f32>

test/default_storage_invalid.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func @non_rectangular_shape(%arg0: f32, %arg1: index) {
6868
// -----
6969

7070
func @incomplete_loop_nest(%arg0: memref<4xf32>, %arg1: index) {
71-
%c = constant 42.0 : f32
71+
%c = arith.constant 42.0 : f32
7272
sair.program {
7373
%n = sair.from_scalar %arg1 : !sair.value<(), index>
7474
%r = sair.dyn_range %n : !sair.dyn_range

test/from_linalg.mlir

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func @pointwise(%arg0: memref<1x2x3xf32>, %arg1: memref<2x3x1xf32>) {
3838
outs(%arg1 : memref<2x3x1xf32>) {
3939
// CHECK: ^{{.*}}(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index, %{{.*}}: f32, %{{.*}}: f32):
4040
^bb(%a0: f32, %a1: f32):
41-
%1 = addf %a0, %a1 : f32
41+
%1 = arith.addf %a0, %a1 : f32
4242
// CHECK: sair.return %{{.*}} f32
4343
linalg.yield %1 : f32
4444
// CHECK: #sair.shape<d0:static_range<1> x d1:static_range<3> x d2:static_range<2>>, (f32, f32) -> f32
@@ -89,7 +89,7 @@ func @dynamic(%arg0: memref<?x2x?xf32>, %arg1: memref<2x?x?xf32>) {
8989
ins(%arg0 : memref<?x2x?xf32>)
9090
outs(%arg1 : memref<2x?x?xf32>) {
9191
^bb(%a0: f32, %a1: f32):
92-
%1 = addf %a0, %a1 : f32
92+
%1 = arith.addf %a0, %a1 : f32
9393
linalg.yield %1 : f32
9494
}
9595

@@ -139,8 +139,8 @@ func @reductions(%arg0: memref<2x3x4x5x6xf32>, %arg1: memref<2x4x6xf32>) {
139139
// Expecting the operands to be swapped because of block argument
140140
// reordering that places the partial reduction first to comply with Sair
141141
// conventions.
142-
// CHECK: %[[v0:.*]] = addf %[[reduce]], %[[arg]]
143-
%0 = addf %a1, %a0 : f32
142+
// CHECK: %[[v0:.*]] = arith.addf %[[reduce]], %[[arg]]
143+
%0 = arith.addf %a1, %a0 : f32
144144
// CHECK: sair.return %[[v0]]
145145
linalg.yield %0 : f32
146146
// CHECK: } : #sair.shape<d0:static_range<2> x d1:static_range<4> x
@@ -164,12 +164,12 @@ func @indices(%arg0: memref<1x2x3xf32>, %arg1: memref<2x3x1xf32>) {
164164
%0 = linalg.index 0 : index
165165
%1 = linalg.index 2 : index
166166
%2 = linalg.index 1 : index
167-
// CHECK: = addi %[[I0]], %[[I2]]
168-
// CHECK: = addi %{{.*}}, %[[I1]]
169-
%3 = addi %0, %1 : index
170-
%4 = addi %3, %2 : index
171-
%5 = index_cast %4 : index to i32
172-
%6 = sitofp %5 : i32 to f32
167+
// CHECK: = arith.addi %[[I0]], %[[I2]]
168+
// CHECK: = arith.addi %{{.*}}, %[[I1]]
169+
%3 = arith.addi %0, %1 : index
170+
%4 = arith.addi %3, %2 : index
171+
%5 = arith.index_cast %4 : index to i32
172+
%6 = arith.sitofp %5 : i32 to f32
173173
linalg.yield %6 : f32
174174
}
175175
return

test/from_linalg_invalid.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func @reductions(%arg0: memref<2x3x4x5x6xf32>, %arg1: memref<2x4x6xf32>) {
1616
ins(%arg0 : memref<2x3x4x5x6xf32>)
1717
outs(%arg1 : memref<2x4x6xf32>) {
1818
^bb0(%a0: f32, %a1: f32):
19-
%0 = addf %a1, %a0 : f32
19+
%0 = arith.addf %a1, %a0 : f32
2020
linalg.yield %0 : f32
2121
}
2222

@@ -39,7 +39,7 @@ func @shape_mismatch(%arg0: memref<?xf32>, %arg1: memref<2xf32>) {
3939
ins(%arg0 : memref<?xf32>)
4040
outs(%arg1 : memref<2xf32>) {
4141
^bb(%a0: f32, %a1: f32):
42-
%1 = addf %a0, %a1 : f32
42+
%1 = arith.addf %a0, %a1 : f32
4343
linalg.yield %1 : f32
4444
}
4545
return

test/inline_trivial_sair_ops.mlir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
// CHECK-LABEL: @one_map
44
func @one_map() -> f32 {
5-
// CHECK: %[[v0:.*]] = constant 1.0
6-
%0 = constant 1.0 : f32
5+
// CHECK: %[[v0:.*]] = arith.constant 1.0
6+
%0 = arith.constant 1.0 : f32
77
// CHECK-NOT: sair.program
88
%1 = sair.program {
99
// CHECK-NOT: from_scalar
1010
%2 = sair.from_scalar %0 : !sair.value<(), f32>
1111
// CHECK-NOT: sair.map
1212
%3 = sair.map %2 {
1313
^bb0(%arg0: f32):
14-
// CHECK: %[[v3:.*]] = addf %[[v0]], %[[v0]]
15-
%4 = addf %arg0, %arg0 : f32
14+
// CHECK: %[[v3:.*]] = arith.addf %[[v0]], %[[v0]]
15+
%4 = arith.addf %arg0, %arg0 : f32
1616
// CHECK-NOT: sair.return
1717
sair.return %4 : f32
1818
} : #sair.shape<()>, (f32) -> f32
@@ -25,17 +25,17 @@ func @one_map() -> f32 {
2525

2626
// CHECK-LABEL: @sequence
2727
func @sequence() -> f32 {
28-
// CHECK: %[[v0:.*]] = constant 1.0
29-
%0 = constant 1.0 : f32
28+
// CHECK: %[[v0:.*]] = arith.constant 1.0
29+
%0 = arith.constant 1.0 : f32
3030
// CHECK-NOT: sair.program
3131
%6 = sair.program {
3232
// CHECK-NOT: from_scalar
3333
%1 = sair.from_scalar %0 : !sair.value<(), f32>
3434
// CHECK-NOT: sair.map
3535
%2 = sair.map %1 {
3636
^bb0(%arg0: f32):
37-
// CHECK: %[[v3:.*]] = addf %[[v0]], %[[v0]]
38-
%3 = addf %arg0, %arg0 : f32
37+
// CHECK: %[[v3:.*]] = arith.addf %[[v0]], %[[v0]]
38+
%3 = arith.addf %arg0, %arg0 : f32
3939
// CHECK-NOT: sair.return
4040
sair.return %3 : f32
4141
} : #sair.shape<()>, (f32) -> f32
@@ -48,7 +48,7 @@ func @sequence() -> f32 {
4848

4949
// CHECK-LABEL: @do_nothing
5050
func @do_nothing() {
51-
%0 = constant 1.0 : f32
51+
%0 = arith.constant 1.0 : f32
5252
sair.program {
5353
%1 = sair.static_range : !sair.static_range<8>
5454
%2 = sair.from_scalar %0 : !sair.value<(), f32>

test/integration/sair_to_llvm.mlir

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
// Helper function that returns 1.0 if the two memrefs are equal and 0.0
88
// otherwise.
99
func @check_memrefs_equal(%lhs: memref<8xi32>, %rhs: memref<8xi32>) -> f32 {
10-
%c0 = constant 0 : index
11-
%c1 = constant 1 : index
12-
%c8 = constant 8 : index
13-
%c0f = constant 0.0 : f32
14-
%c1f = constant 1.0 : f32
10+
%c0 = arith.constant 0 : index
11+
%c1 = arith.constant 1 : index
12+
%c8 = arith.constant 8 : index
13+
%c0f = arith.constant 0.0 : f32
14+
%c1f = arith.constant 1.0 : f32
1515
br ^bb0(%c0 : index)
1616

1717
// Loop on the memrefs.
1818
^bb0(%0: index):
19-
%1 = cmpi slt, %0, %c8 : index
19+
%1 = arith.cmpi slt, %0, %c8 : index
2020
// Return 1.0 if we reached the end without error.
2121
cond_br %1, ^bb1(%0 : index), ^bb2(%c1f : f32)
2222
^bb1(%2: index):
2323
%4 = memref.load %lhs[%2] : memref<8xi32>
2424
%5 = memref.load %rhs[%2] : memref<8xi32>
25-
%3 = addi %2, %c1 : index
26-
%6 = cmpi eq, %4, %5 : i32
25+
%3 = arith.addi %2, %c1 : index
26+
%6 = arith.cmpi eq, %4, %5 : i32
2727
// Returns 0.0 if we found an error.
2828
cond_br %6, ^bb0(%3 : index), ^bb2(%c0f : f32)
2929

@@ -32,7 +32,7 @@ func @check_memrefs_equal(%lhs: memref<8xi32>, %rhs: memref<8xi32>) -> f32 {
3232
}
3333

3434
func @from_scalar() -> f32 {
35-
%0 = constant 1.0 : f32
35+
%0 = arith.constant 1.0 : f32
3636
%2 = sair.program {
3737
%1 = sair.from_scalar %0 : !sair.value<(), f32>
3838
sair.exit %1 : f32
@@ -41,16 +41,16 @@ func @from_scalar() -> f32 {
4141
}
4242

4343
func @from_to_memref() -> f32 {
44-
%c0 = constant 0 : index
45-
%c1 = constant 1 : index
46-
%c8 = constant 8 : index
44+
%c0 = arith.constant 0 : index
45+
%c1 = arith.constant 1 : index
46+
%c8 = arith.constant 8 : index
4747

4848
// Create two memrefs such that %0[i] = 2*%1[i].
4949
%0 = memref.alloca() : memref<8xi32>
5050
%1 = memref.alloca() : memref<8xi32>
5151
scf.for %i = %c0 to %c8 step %c1 {
52-
%2 = index_cast %i : index to i32
53-
%3 = addi %2, %2 : i32
52+
%2 = arith.index_cast %i : index to i32
53+
%3 = arith.addi %2, %2 : i32
5454
memref.store %2, %0[%i] : memref<8xi32>
5555
memref.store %3, %1[%i] : memref<8xi32>
5656
}
@@ -64,7 +64,7 @@ func @from_to_memref() -> f32 {
6464
} : #sair.shape<d0:static_range<8>>, memref<8xi32>
6565
%4 = sair.map[d0:%2] %3(d0) {
6666
^bb0(%arg0: index, %arg1: i32):
67-
%5 = addi %arg1, %arg1 : i32
67+
%5 = arith.addi %arg1, %arg1 : i32
6868
sair.return %5 : i32
6969
} : #sair.shape<d0:static_range<8>>, (i32) -> i32
7070
sair.to_memref %6 memref[d0:%2] %4(d0) {

0 commit comments

Comments
 (0)