2018-07-15 14:06:24 +08:00
|
|
|
// TODO(andydavis) Resolve relative path issue w.r.t invoking mlir-opt in RUN
|
|
|
|
// statements (perhaps through using lit config substitutions).
|
|
|
|
//
|
|
|
|
// RUN: %S/../../mlir-opt %s -o - | FileCheck %s
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-07-18 07:56:54 +08:00
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2, d3, d4) [s0] -> (d0, d1, d2, d3, d4)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map0 = (d0, d1, d2, d3, d4) [s0] -> (d0, d1, d2, d3, d4)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0) -> (d0)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map1 = (d0) -> (d0)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d0, d1, d2)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map2 = (d0, d1, d2) -> (d0, d1, d2)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d1, d0, d2)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map3 = (d0, d1, d2) -> (d1, d0, d2)
|
2018-07-18 07:56:54 +08:00
|
|
|
|
|
|
|
// CHECK-DAG: #map{{[0-9]+}} = (d0, d1, d2) -> (d2, d1, d0)
|
2018-07-17 00:45:22 +08:00
|
|
|
#map4 = (d0, d1, d2) -> (d2, d1, d0)
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @foo(i32, i64) -> f32
|
2018-06-23 06:52:02 +08:00
|
|
|
extfunc @foo(i32, i64) -> f32
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @bar()
|
2018-06-23 06:52:02 +08:00
|
|
|
extfunc @bar() -> ()
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @baz() -> (i1, affineint, f32)
|
2018-06-30 13:08:05 +08:00
|
|
|
extfunc @baz() -> (i1, affineint, f32)
|
2018-06-23 01:39:19 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @missingReturn()
|
2018-06-23 06:52:02 +08:00
|
|
|
extfunc @missingReturn()
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @int_types(i1, i2, i4, i7, i87) -> (i1, affineint, i19)
|
2018-06-30 13:08:05 +08:00
|
|
|
extfunc @int_types(i1, i2, i4, i7, i87) -> (i1, affineint, i19)
|
|
|
|
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @vectors(vector<1xf32>, vector<2x4xf32>)
|
2018-06-23 06:52:02 +08:00
|
|
|
extfunc @vectors(vector<1 x f32>, vector<2x4xf32>)
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: extfunc @tensors(tensor<??f32>, tensor<??vector<2x4xf32>>, tensor<1x?x4x?x?xaffineint>, tensor<i8>)
|
2018-06-23 06:52:02 +08:00
|
|
|
extfunc @tensors(tensor<?? f32>, tensor<?? vector<2x4xf32>>,
|
2018-06-30 13:08:05 +08:00
|
|
|
tensor<1x?x4x?x?xaffineint>, tensor<i8>)
|
2018-06-23 06:52:02 +08:00
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
// CHECK: extfunc @memrefs(memref<1x?x4x?x?xaffineint, #map{{[0-9]+}}>, memref<i8, #map{{[0-9]+}}>)
|
|
|
|
extfunc @memrefs(memref<1x?x4x?x?xaffineint, #map0>, memref<i8, #map1>)
|
2018-06-23 13:03:48 +08:00
|
|
|
|
2018-07-17 00:45:22 +08:00
|
|
|
// Test memref affine map compositions.
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2018-07-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs2(memref<2x4x8xi8, #map{{[0-9]+}}, 1>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs2(memref<2x4x8xi8, #map2, 1>)
|
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
// CHECK: extfunc @memrefs23(memref<2x4x8xi8, #map{{[0-9]+}}, #map{{[0-9]+}}>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs23(memref<2x4x8xi8, #map2, #map3, 0>)
|
|
|
|
|
2018-07-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs234(memref<2x4x8xi8, #map{{[0-9]+}}, #map{{[0-9]+}}, #map{{[0-9]+}}, 3>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs234(memref<2x4x8xi8, #map2, #map3, #map4, 3>)
|
|
|
|
|
|
|
|
// Test memref inline affine map compositions.
|
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
// CHECK: extfunc @memrefs2(memref<2x4x8xi8, #map{{[0-9]+}}>)
|
|
|
|
extfunc @memrefs2(memref<2x4x8xi8, (d0, d1, d2) -> (d0, d1, d2)>)
|
2018-07-17 00:45:22 +08:00
|
|
|
|
2018-07-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs23(memref<2x4x8xi8, #map{{[0-9]+}}, #map{{[0-9]+}}, 1>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs23(memref<2x4x8xi8, (d0, d1, d2) -> (d0, d1, d2), (d0, d1, d2) -> (d1, d0, d2), 1>)
|
|
|
|
|
2018-07-26 03:55:50 +08:00
|
|
|
// CHECK: extfunc @functions((memref<1x?x4x?x?xaffineint, #map0>, memref<i8, #map1>) -> (), () -> ())
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @functions((memref<1x?x4x?x?xaffineint, #map0, 0>, memref<i8, #map1, 0>) -> (), ()->())
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2018-07-23 23:42:19 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @simpleCFG(i32, f32) -> i1 {
|
|
|
|
cfgfunc @simpleCFG(i32, f32) -> i1 {
|
2018-07-23 06:45:24 +08:00
|
|
|
// CHECK: bb0(%0: i32, %1: f32):
|
|
|
|
bb42 (%0: i32, %f: f32):
|
|
|
|
// CHECK: %2 = "foo"() : () -> i64
|
2018-07-19 23:35:28 +08:00
|
|
|
%1 = "foo"() : ()->i64
|
2018-07-23 06:45:24 +08:00
|
|
|
// CHECK: "bar"(%2) : (i64) -> (i1, i1, i1)
|
2018-07-21 00:28:54 +08:00
|
|
|
%2 = "bar"(%1) : (i64) -> (i1,i1,i1)
|
2018-07-23 23:42:19 +08:00
|
|
|
// CHECK: return %3#1
|
|
|
|
return %2#1 : i1
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: }
|
|
|
|
}
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2018-07-23 06:45:24 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @simpleCFGUsingBBArgs(i32, i64) {
|
|
|
|
cfgfunc @simpleCFGUsingBBArgs(i32, i64) {
|
|
|
|
// CHECK: bb0(%0: i32, %1: i64):
|
|
|
|
bb42 (%0: i32, %f: i64):
|
|
|
|
// CHECK: "bar"(%1) : (i64) -> (i1, i1, i1)
|
|
|
|
%2 = "bar"(%f) : (i64) -> (i1,i1,i1)
|
|
|
|
// CHECK: return
|
|
|
|
return
|
|
|
|
// CHECK: }
|
|
|
|
}
|
|
|
|
|
2018-07-22 05:32:09 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @multiblock() {
|
|
|
|
cfgfunc @multiblock() {
|
2018-07-15 14:06:24 +08:00
|
|
|
bb0: // CHECK: bb0:
|
|
|
|
return // CHECK: return
|
|
|
|
bb1: // CHECK: bb1:
|
|
|
|
br bb4 // CHECK: br bb3
|
|
|
|
bb2: // CHECK: bb2:
|
|
|
|
br bb2 // CHECK: br bb2
|
|
|
|
bb4: // CHECK: bb3:
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
2018-07-17 02:47:09 +08:00
|
|
|
// CHECK-LABEL: mlfunc @emptyMLF() {
|
|
|
|
mlfunc @emptyMLF() {
|
2018-07-15 14:06:24 +08:00
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
2018-06-29 08:02:32 +08:00
|
|
|
|
2018-07-20 00:52:39 +08:00
|
|
|
// CHECK-LABEL: mlfunc @mlfunc_with_args(f16) {
|
|
|
|
mlfunc @mlfunc_with_args(%a : f16) {
|
|
|
|
return %a // CHECK: return
|
|
|
|
}
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK-LABEL: mlfunc @loops() {
|
2018-07-04 08:51:28 +08:00
|
|
|
mlfunc @loops() {
|
2018-07-20 00:52:39 +08:00
|
|
|
// CHECK: for x = 1 to 100 step 2 {
|
|
|
|
for %i = 1 to 100 step 2 {
|
|
|
|
// CHECK: for x = 1 to 200 {
|
|
|
|
for %j = 1 to 200 {
|
2018-07-15 14:06:24 +08:00
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
|
|
|
// CHECK-LABEL: mlfunc @ifstmt() {
|
2018-07-04 08:51:28 +08:00
|
|
|
mlfunc @ifstmt() {
|
2018-07-20 00:52:39 +08:00
|
|
|
for %i = 1 to 10 { // CHECK for x = 1 to 10 {
|
|
|
|
if () { // CHECK if () {
|
|
|
|
} else if () { // CHECK } else if () {
|
|
|
|
} else { // CHECK } else {
|
|
|
|
} // CHECK }
|
|
|
|
} // CHECK }
|
|
|
|
return // CHECK return
|
|
|
|
} // CHECK }
|
2018-07-15 14:06:24 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @attributes() {
|
2018-07-05 11:45:39 +08:00
|
|
|
cfgfunc @attributes() {
|
2018-07-15 14:06:24 +08:00
|
|
|
bb42: // CHECK: bb0:
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: "foo"()
|
2018-07-19 06:31:25 +08:00
|
|
|
"foo"(){} : ()->()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: "foo"(){a: 1, b: -423, c: [true, false]} : () -> ()
|
|
|
|
"foo"(){a: 1, b: -423, c: [true, false] } : () -> ()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-19 07:29:21 +08:00
|
|
|
// CHECK: "foo"(){map1: #map{{[0-9]+}}}
|
|
|
|
"foo"(){map1: #map1} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo"(){map2: #map{{[0-9]+}}}
|
|
|
|
"foo"(){map2: (d0, d1, d2) -> (d0, d1, d2)} : () -> ()
|
|
|
|
|
|
|
|
// CHECK: "foo"(){map12: [#map{{[0-9]+}}, #map{{[0-9]+}}]}
|
|
|
|
"foo"(){map12: [#map1, #map2]} : () -> ()
|
|
|
|
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: "foo"(){cfgfunc: [], i123: 7, if: "foo"} : () -> ()
|
|
|
|
"foo"(){if: "foo", cfgfunc: [], i123: 7} : () -> ()
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-06 00:12:11 +08:00
|
|
|
return
|
2018-07-05 11:45:39 +08:00
|
|
|
}
|
2018-07-21 09:41:34 +08:00
|
|
|
|
2018-07-22 05:32:09 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @ssa_values() -> (i16, i8) {
|
|
|
|
cfgfunc @ssa_values() -> (i16, i8) {
|
2018-07-21 09:41:34 +08:00
|
|
|
bb0: // CHECK: bb0:
|
|
|
|
// CHECK: %0 = "foo"() : () -> (i1, i17)
|
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
|
|
|
br bb2
|
|
|
|
|
|
|
|
bb1: // CHECK: bb1:
|
2018-07-22 05:32:09 +08:00
|
|
|
// CHECK: %1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
|
|
|
|
%1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
|
2018-07-25 01:41:30 +08:00
|
|
|
|
2018-07-25 06:01:27 +08:00
|
|
|
// CHECK: return %1#0, %1#1 : i16, i8
|
2018-07-24 02:56:17 +08:00
|
|
|
return %1#0, %1#1 : i16, i8
|
2018-07-21 09:41:34 +08:00
|
|
|
|
|
|
|
bb2: // CHECK: bb2:
|
|
|
|
// CHECK: %2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
|
|
|
|
%2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
|
|
|
|
br bb1
|
2018-07-23 23:42:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @bbargs() -> (i16, i8) {
|
|
|
|
cfgfunc @bbargs() -> (i16, i8) {
|
|
|
|
bb0: // CHECK: bb0:
|
|
|
|
// CHECK: %0 = "foo"() : () -> (i1, i17)
|
|
|
|
%0 = "foo"() : () -> (i1, i17)
|
2018-07-25 06:01:27 +08:00
|
|
|
br bb1(%0#1, %0#0 : i17, i1)
|
2018-07-23 23:42:19 +08:00
|
|
|
|
|
|
|
bb1(%x: i17, %y: i1): // CHECK: bb1(%1: i17, %2: i1):
|
|
|
|
// CHECK: %3 = "baz"(%1, %2, %0#1) : (i17, i1, i17) -> (i16, i8)
|
|
|
|
%1 = "baz"(%x, %y, %0#1) : (i17, i1, i17) -> (i16, i8)
|
2018-07-24 02:56:17 +08:00
|
|
|
return %1#0, %1#1 : i16, i8
|
2018-07-23 23:42:19 +08:00
|
|
|
}
|
2018-07-25 06:01:27 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @condbr_simple
|
|
|
|
cfgfunc @condbr_simple() -> (i32) {
|
|
|
|
bb0:
|
|
|
|
%cond = "foo"() : () -> i1
|
|
|
|
%a = "bar"() : () -> i32
|
|
|
|
%b = "bar"() : () -> i64
|
|
|
|
// CHECK: cond_br %0, bb1(%1 : i32), bb2(%2 : i64)
|
|
|
|
cond_br %cond, bb1(%a : i32), bb2(%b : i64)
|
|
|
|
|
|
|
|
bb1(%x : i32):
|
|
|
|
return %x : i32
|
|
|
|
|
|
|
|
bb2(%y : i64):
|
|
|
|
%z = "foo"() : () -> i32
|
|
|
|
return %z : i32
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: cfgfunc @condbr_moarargs
|
|
|
|
cfgfunc @condbr_moarargs() -> (i32) {
|
|
|
|
bb0:
|
|
|
|
%cond = "foo"() : () -> i1
|
|
|
|
%a = "bar"() : () -> i32
|
|
|
|
%b = "bar"() : () -> i64
|
|
|
|
// CHECK: cond_br %0, bb1(%1, %2 : i32, i64), bb2(%2, %1, %1 : i64, i32, i32)
|
|
|
|
cond_br %cond, bb1(%a, %b : i32, i64), bb2(%b, %a, %a : i64, i32, i32)
|
|
|
|
|
|
|
|
bb1(%x : i32, %y : i64):
|
|
|
|
return %x : i32
|
|
|
|
|
|
|
|
bb2(%x2 : i64, %y2 : i32, %z2 : i32):
|
|
|
|
%z = "foo"() : () -> i32
|
|
|
|
return %z : i32
|
|
|
|
}
|