• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s
2
3//===----------------------------------------------------------------------===//
4// Test the number of regions
5//===----------------------------------------------------------------------===//
6
7func @correct_number_of_regions() {
8    // CHECK: test.two_region_op
9    "test.two_region_op"()(
10      {"work"() : () -> ()},
11      {"work"() : () -> ()}
12    ) : () -> ()
13    return
14}
15
16// -----
17
18func @missing_regions() {
19    // expected-error@+1 {{expected 2 regions}}
20    "test.two_region_op"()(
21      {"work"() : () -> ()}
22    ) : () -> ()
23    return
24}
25
26// -----
27
28func @extra_regions() {
29    // expected-error@+1 {{expected 2 regions}}
30    "test.two_region_op"()(
31      {"work"() : () -> ()},
32      {"work"() : () -> ()},
33      {"work"() : () -> ()}
34    ) : () -> ()
35    return
36}
37
38// -----
39
40//===----------------------------------------------------------------------===//
41// Test SizedRegion
42//===----------------------------------------------------------------------===//
43
44func @unnamed_region_has_wrong_number_of_blocks() {
45    // expected-error@+1 {{region #1 failed to verify constraint: region with 1 blocks}}
46    "test.sized_region_op"() (
47    {
48        "work"() : () -> ()
49        br ^next1
50      ^next1:
51        "work"() : () -> ()
52    },
53    {
54        "work"() : () -> ()
55        br ^next2
56      ^next2:
57        "work"() : () -> ()
58    }) : () -> ()
59    return
60}
61
62// -----
63
64// Test region name in error message
65func @named_region_has_wrong_number_of_blocks() {
66    // expected-error@+1 {{region #0 ('my_region') failed to verify constraint: region with 2 blocks}}
67    "test.sized_region_op"() (
68    {
69        "work"() : () -> ()
70    },
71    {
72        "work"() : () -> ()
73    }) : () -> ()
74    return
75}
76