2020-03-30 06:35:38 +08:00
|
|
|
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s
|
2019-05-28 23:03:46 +08:00
|
|
|
|
2019-05-31 07:50:16 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test the number of regions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-05-28 23:03:46 +08:00
|
|
|
func @correct_number_of_regions() {
|
|
|
|
// CHECK: test.two_region_op
|
|
|
|
"test.two_region_op"()(
|
|
|
|
{"work"() : () -> ()},
|
|
|
|
{"work"() : () -> ()}
|
|
|
|
) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-05-31 07:50:16 +08:00
|
|
|
func @missing_regions() {
|
2020-04-05 16:03:24 +08:00
|
|
|
// expected-error@+1 {{expected 2 regions}}
|
2019-05-28 23:03:46 +08:00
|
|
|
"test.two_region_op"()(
|
|
|
|
{"work"() : () -> ()}
|
|
|
|
) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @extra_regions() {
|
2020-04-05 16:03:24 +08:00
|
|
|
// expected-error@+1 {{expected 2 regions}}
|
2019-05-28 23:03:46 +08:00
|
|
|
"test.two_region_op"()(
|
|
|
|
{"work"() : () -> ()},
|
|
|
|
{"work"() : () -> ()},
|
|
|
|
{"work"() : () -> ()}
|
|
|
|
) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
2019-05-31 07:50:16 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test SizedRegion
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @unnamed_region_has_wrong_number_of_blocks() {
|
|
|
|
// expected-error@+1 {{region #1 failed to verify constraint: region with 1 blocks}}
|
|
|
|
"test.sized_region_op"() (
|
|
|
|
{
|
|
|
|
"work"() : () -> ()
|
|
|
|
br ^next1
|
|
|
|
^next1:
|
|
|
|
"work"() : () -> ()
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"work"() : () -> ()
|
|
|
|
br ^next2
|
|
|
|
^next2:
|
|
|
|
"work"() : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test region name in error message
|
|
|
|
func @named_region_has_wrong_number_of_blocks() {
|
|
|
|
// expected-error@+1 {{region #0 ('my_region') failed to verify constraint: region with 2 blocks}}
|
|
|
|
"test.sized_region_op"() (
|
|
|
|
{
|
|
|
|
"work"() : () -> ()
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"work"() : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
2021-03-12 07:58:02 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Region with single block and not terminator.
|
|
|
|
// CHECK: unregistered_without_terminator
|
2022-01-18 15:47:25 +08:00
|
|
|
"test.unregistered_without_terminator"() ({
|
2022-01-20 04:18:30 +08:00
|
|
|
^bb0:
|
2021-03-12 07:58:02 +08:00
|
|
|
}) : () -> ()
|
2021-03-25 20:02:41 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK: test.single_no_terminator_op
|
|
|
|
"test.single_no_terminator_op"() (
|
|
|
|
{
|
|
|
|
func @foo1() { return }
|
|
|
|
func @foo2() { return }
|
|
|
|
}
|
|
|
|
) : () -> ()
|
|
|
|
|
|
|
|
// CHECK: test.variadic_no_terminator_op
|
|
|
|
"test.variadic_no_terminator_op"() (
|
|
|
|
{
|
|
|
|
func @foo1() { return }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
func @foo2() { return }
|
|
|
|
}
|
|
|
|
) : () -> ()
|
2021-05-28 19:21:41 +08:00
|
|
|
|
|
|
|
// CHECK: test.single_no_terminator_custom_asm_op
|
|
|
|
// CHECK-NEXT: important_dont_drop
|
|
|
|
test.single_no_terminator_custom_asm_op {
|
|
|
|
"important_dont_drop"() : () -> ()
|
|
|
|
}
|