1 // RUN: mlir-opt -test-generic-ir-visitors -allow-unregistered-dialect -split-input-file %s | FileCheck %s
2 // RUN: mlir-opt -test-generic-ir-visitors-interrupt -allow-unregistered-dialect -split-input-file %s | FileCheck %s
4 // Verify the different configurations of generic IR visitors.
6 func.func @structured_cfg() {
7 %c0 = arith.constant 0 : index
8 %c1 = arith.constant 1 : index
9 %c10 = arith.constant 10 : index
10 scf.for %i = %c1 to %c10 step %c1 {
11 %cond = "use0"(%i) : (index) -> (i1)
13 "use1"(%i) : (index) -> ()
15 "use2"(%i) : (index) -> ()
17 "use3"(%i) : (index) -> ()
22 // CHECK: step 0 op 'builtin.module' before all regions
23 // CHECK: step 1 op 'func.func' before all regions
24 // CHECK: step 2 op 'arith.constant' before all regions
25 // CHECK: step 3 op 'arith.constant' before all regions
26 // CHECK: step 4 op 'arith.constant' before all regions
27 // CHECK: step 5 op 'scf.for' before all regions
28 // CHECK: step 6 op 'use0' before all regions
29 // CHECK: step 7 op 'scf.if' before all regions
30 // CHECK: step 8 op 'use1' before all regions
31 // CHECK: step 9 op 'scf.yield' before all regions
32 // CHECK: step 10 op 'scf.if' before region #1
33 // CHECK: step 11 op 'use2' before all regions
34 // CHECK: step 12 op 'scf.yield' before all regions
35 // CHECK: step 13 op 'scf.if' after all regions
36 // CHECK: step 14 op 'use3' before all regions
37 // CHECK: step 15 op 'scf.yield' before all regions
38 // CHECK: step 16 op 'scf.for' after all regions
39 // CHECK: step 17 op 'func.return' before all regions
40 // CHECK: step 18 op 'func.func' after all regions
41 // CHECK: step 19 op 'builtin.module' after all regions
44 // Test the specific operation type visitor.
46 func.func @correct_number_of_regions() {
47 %c0 = arith.constant 0 : index
48 %c1 = arith.constant 1 : index
49 %c10 = arith.constant 10 : index
50 scf.for %i = %c1 to %c10 step %c1 {
51 "test.two_region_op"()(
52 {"work"() : () -> ()},
59 // CHECK: step 0 op 'builtin.module' before all regions
60 // CHECK: step 15 op 'builtin.module' after all regions
61 // CHECK: step 16 op 'test.two_region_op' before all regions
62 // CHECK: step 17 op 'test.two_region_op' before region #1
63 // CHECK: step 18 op 'test.two_region_op' after all regions