+static int verify_switch_table(const ir_node *n)
+{
+ const ir_switch_table *table = get_Switch_table(n);
+ unsigned n_outs = get_Switch_n_outs(n);
+ ir_node *selector = get_Switch_selector(n);
+ ir_mode *mode = get_irn_mode(selector);
+ size_t n_entries;
+ size_t e;
+
+ ASSERT_AND_RET(table != NULL, "switch table is NULL", 0);
+
+ n_entries = ir_switch_table_get_n_entries(table);
+ for (e = 0; e < n_entries; ++e) {
+ const ir_switch_table_entry *entry
+ = ir_switch_table_get_entry_const(table, e);
+ if (entry->pn == 0)
+ continue;
+ ASSERT_AND_RET(entry->min != NULL && entry->max != NULL,
+ "switch table entry without min+max value", 0);
+ ASSERT_AND_RET(get_tarval_mode(entry->min) == mode &&
+ get_tarval_mode(entry->max) == mode,
+ "switch table entry with wrong modes", 0);
+ ASSERT_AND_RET(tarval_cmp(entry->min, entry->max) != ir_relation_greater,
+ "switch table entry without min+max value", 0);
+ ASSERT_AND_RET(entry->pn >= 0 && entry->pn < (long)n_outs,
+ "switch table entry with invalid proj number", 0);
+ }
+ return 1;
+}
+
+static int verify_node_Switch(const ir_node *n)
+{
+ ir_mode *mymode = get_irn_mode(n);
+ ir_mode *op1mode = get_irn_mode(get_Switch_selector(n));
+ if (!verify_switch_table(n))
+ return 0;
+
+ ASSERT_AND_RET(mode_is_int(op1mode), "Switch operand not integer", 0);
+ ASSERT_AND_RET(mymode == mode_T, "Switch mode is not a tuple", 0);