64 lines · plain
1// RUN: mlir-opt -test-generic-ir-visitors -allow-unregistered-dialect -split-input-file %s | FileCheck %s2// RUN: mlir-opt -test-generic-ir-visitors-interrupt -allow-unregistered-dialect -split-input-file %s | FileCheck %s3 4// Verify the different configurations of generic IR visitors.5 6func.func @structured_cfg() {7 %c0 = arith.constant 0 : index8 %c1 = arith.constant 1 : index9 %c10 = arith.constant 10 : index10 scf.for %i = %c1 to %c10 step %c1 {11 %cond = "use0"(%i) : (index) -> (i1)12 scf.if %cond {13 "use1"(%i) : (index) -> ()14 } else {15 "use2"(%i) : (index) -> ()16 }17 "use3"(%i) : (index) -> ()18 }19 return20}21 22// CHECK: step 0 op 'builtin.module' before all regions23// CHECK: step 1 op 'func.func' before all regions24// CHECK: step 2 op 'arith.constant' before all regions25// CHECK: step 3 op 'arith.constant' before all regions26// CHECK: step 4 op 'arith.constant' before all regions27// CHECK: step 5 op 'scf.for' before all regions28// CHECK: step 6 op 'use0' before all regions29// CHECK: step 7 op 'scf.if' before all regions30// CHECK: step 8 op 'use1' before all regions31// CHECK: step 9 op 'scf.yield' before all regions32// CHECK: step 10 op 'scf.if' before region #133// CHECK: step 11 op 'use2' before all regions34// CHECK: step 12 op 'scf.yield' before all regions35// CHECK: step 13 op 'scf.if' after all regions36// CHECK: step 14 op 'use3' before all regions37// CHECK: step 15 op 'scf.yield' before all regions38// CHECK: step 16 op 'scf.for' after all regions39// CHECK: step 17 op 'func.return' before all regions40// CHECK: step 18 op 'func.func' after all regions41// CHECK: step 19 op 'builtin.module' after all regions42 43// -----44// Test the specific operation type visitor.45 46func.func @correct_number_of_regions() {47 %c0 = arith.constant 0 : index48 %c1 = arith.constant 1 : index49 %c10 = arith.constant 10 : index50 scf.for %i = %c1 to %c10 step %c1 {51 "test.two_region_op"()(52 {"work"() : () -> ()},53 {"work"() : () -> ()}54 ) : () -> ()55 }56 return57}58 59// CHECK: step 0 op 'builtin.module' before all regions60// CHECK: step 15 op 'builtin.module' after all regions61// CHECK: step 16 op 'test.two_region_op' before all regions62// CHECK: step 17 op 'test.two_region_op' before region #163// CHECK: step 18 op 'test.two_region_op' after all regions64