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-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs(memref<1x?x4x?x?xaffineint, #map{{[0-9]+}}, 0>, memref<i8, #map{{[0-9]+}}, 0>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs(memref<1x?x4x?x?xaffineint, #map0, 0>, memref<i8, #map1, 0>)
|
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-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs23(memref<2x4x8xi8, #map{{[0-9]+}}, #map{{[0-9]+}}, 0>)
|
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-18 07:56:54 +08:00
|
|
|
// CHECK: extfunc @memrefs2(memref<2x4x8xi8, #map{{[0-9]+}}, 0>)
|
2018-07-17 00:45:22 +08:00
|
|
|
extfunc @memrefs2(memref<2x4x8xi8, (d0, d1, d2) -> (d0, d1, d2), 0>)
|
|
|
|
|
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>)
|
|
|
|
|
|
|
|
// CHECK: extfunc @functions((memref<1x?x4x?x?xaffineint, (d0, d1, d2, d3, d4) [s0] -> (d0, d1, d2, d3, d4), 0>, memref<i8, (d0) -> (d0), 0>) -> (), () -> ())
|
|
|
|
extfunc @functions((memref<1x?x4x?x?xaffineint, #map0, 0>, memref<i8, #map1, 0>) -> (), ()->())
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @simpleCFG(i32, f32) {
|
2018-07-08 06:48:26 +08:00
|
|
|
cfgfunc @simpleCFG(i32, f32) {
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: bb0:
|
2018-07-19 23:35:28 +08:00
|
|
|
bb42: // (%0: i32, %f: f32): TODO(clattner): implement bbargs.
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: "foo"() : () -> i64
|
2018-07-19 23:35:28 +08:00
|
|
|
%1 = "foo"() : ()->i64
|
|
|
|
// CHECK: "bar"() : (i64) -> (i1, i1, i1)
|
|
|
|
"bar"(%1) : (i64) -> (i1,i1,i1)
|
2018-07-19 06:31:25 +08:00
|
|
|
// CHECK: return
|
|
|
|
return
|
|
|
|
// CHECK: }
|
|
|
|
}
|
2018-06-24 07:03:42 +08:00
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @multiblock() -> i32 {
|
2018-06-24 07:03:42 +08:00
|
|
|
cfgfunc @multiblock() -> i32 {
|
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-19 23:35:28 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @cfgfunc_with_ops() {
|
|
|
|
cfgfunc @cfgfunc_with_ops() {
|
|
|
|
bb0:
|
|
|
|
%t = "getTensor"() : () -> tensor<4x4x?xf32>
|
2018-07-17 02:47:09 +08:00
|
|
|
// CHECK: dim xxx, 2 : sometype
|
2018-07-19 23:35:28 +08:00
|
|
|
%a = "dim"(%t){index: 2} : (tensor<4x4x?xf32>) -> affineint
|
2018-07-17 02:47:09 +08:00
|
|
|
|
|
|
|
// CHECK: addf xx, yy : sometype
|
2018-07-19 06:31:25 +08:00
|
|
|
"addf"() : () -> ()
|
2018-07-17 02:47:09 +08:00
|
|
|
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-15 14:06:24 +08:00
|
|
|
for { // CHECK: for {
|
|
|
|
for { // CHECK: for {
|
|
|
|
} // CHECK: }
|
|
|
|
} // CHECK: }
|
|
|
|
return // CHECK: return
|
|
|
|
} // CHECK: }
|
|
|
|
|
|
|
|
// CHECK-LABEL: mlfunc @ifstmt() {
|
2018-07-04 08:51:28 +08:00
|
|
|
mlfunc @ifstmt() {
|
2018-07-15 14:06:24 +08:00
|
|
|
for { // CHECK for {
|
|
|
|
if () { // CHECK if () {
|
|
|
|
} else if () { // CHECK } else if () {
|
|
|
|
} else { // CHECK } else {
|
|
|
|
} // CHECK }
|
|
|
|
} // CHECK }
|
|
|
|
return // CHECK return
|
|
|
|
} // CHECK }
|
|
|
|
|
|
|
|
// 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-15 14:06:24 +08:00
|
|
|
// CHECK-LABEL: cfgfunc @standard_instrs() {
|
2018-07-06 00:12:11 +08:00
|
|
|
cfgfunc @standard_instrs() {
|
2018-07-15 14:06:24 +08:00
|
|
|
bb42: // CHECK: bb0:
|
2018-07-19 23:35:28 +08:00
|
|
|
%42 = "getTensor"() : () -> tensor<4x4x?xf32>
|
|
|
|
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: dim xxx, 2 : sometype
|
2018-07-19 23:35:28 +08:00
|
|
|
%a = "dim"(%42){index: 2} : (tensor<4x4x?xf32>) -> affineint
|
2018-07-05 11:45:39 +08:00
|
|
|
|
2018-07-19 23:35:28 +08:00
|
|
|
%f = "Const"(){value: 1} : () -> f32
|
2018-07-15 14:06:24 +08:00
|
|
|
// CHECK: addf xx, yy : sometype
|
2018-07-19 23:35:28 +08:00
|
|
|
"addf"(%f, %f) : (f32,f32) -> f32
|
2018-07-05 11:45:39 +08:00
|
|
|
return
|
|
|
|
}
|