brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 0a71c62 Raw
94 lines · plain
1// RUN: mlir-opt -verify-diagnostics -split-input-file %s2 3func.func @switch_missing_case_value(%flag : i32, %caseOperand : i32) {4  cf.switch %flag : i32, [5    default: ^bb1(%caseOperand : i32),6    45: ^bb2(%caseOperand : i32),7    // expected-error@+1 {{expected integer value}}8    : ^bb3(%caseOperand : i32)9  ]10 11  ^bb1(%bb1arg : i32):12    return13  ^bb2(%bb2arg : i32):14    return15  ^bb3(%bb3arg : i32):16    return17}18 19// -----20 21func.func @switch_wrong_type_case_value(%flag : i32, %caseOperand : i32) {22  cf.switch %flag : i32, [23    default: ^bb1(%caseOperand : i32),24    // expected-error@+1 {{expected integer value}}25    "hello": ^bb2(%caseOperand : i32)26  ]27 28  ^bb1(%bb1arg : i32):29    return30  ^bb2(%bb2arg : i32):31    return32  ^bb3(%bb3arg : i32):33    return34}35 36// -----37 38func.func @switch_missing_comma(%flag : i32, %caseOperand : i32) {39  cf.switch %flag : i32, [40    default: ^bb1(%caseOperand : i32),41    // expected-error@+1 {{expected ']'}}42    45: ^bb2(%caseOperand : i32)43    43: ^bb3(%caseOperand : i32)44  ]45 46  ^bb1(%bb1arg : i32):47    return48  ^bb2(%bb2arg : i32):49    return50  ^bb3(%bb3arg : i32):51    return52}53 54// -----55 56func.func @switch_missing_default(%flag : i32, %caseOperand : i32) {57  cf.switch %flag : i32, [58    // expected-error@+1 {{expected 'default'}}59    45: ^bb2(%caseOperand : i32)60    43: ^bb3(%caseOperand : i32)61  ]62 63  ^bb1(%bb1arg : i32):64    return65  ^bb2(%bb2arg : i32):66    return67  ^bb3(%bb3arg : i32):68    return69}70 71// -----72 73// CHECK-LABEL: func @wrong_weights_number74func.func @wrong_weights_number(%cond: i1) {75  // expected-error@+1 {{expects number of branch weights to match number of successors: 1 vs 2}}76  cf.cond_br %cond weights([100]), ^bb1, ^bb277  ^bb1:78    return79  ^bb2:80    return81}82 83// -----84 85// CHECK-LABEL: func @zero_weights86func.func @wrong_total_weight(%cond: i1) {87  // expected-error@+1 {{branch weights cannot all be zero}}88  cf.cond_br %cond weights([0, 0]), ^bb1, ^bb289  ^bb1:90    return91  ^bb2:92    return93}94