- ia32_emitf(node, "\tcmov%P %#AR, %#R\n", pnc, in_true, out);
-}
-
-/*********************************************************
- * _ _ _
- * (_) | (_)
- * ___ _ __ ___ _| |_ _ _ _ _ __ ___ _ __ ___
- * / _ \ '_ ` _ \| | __| | | | | | '_ ` _ \| '_ \/ __|
- * | __/ | | | | | | |_ | | |_| | | | | | | |_) \__ \
- * \___|_| |_| |_|_|\__| | |\__,_|_| |_| |_| .__/|___/
- * _/ | | |
- * |__/ |_|
- *********************************************************/
-
-/* jump table entry (target and corresponding number) */
-typedef struct _branch_t {
- ir_node *target;
- int value;
-} branch_t;
-
-/* jump table for switch generation */
-typedef struct _jmp_tbl_t {
- ir_node *defProj; /**< default target */
- long min_value; /**< smallest switch case */
- long max_value; /**< largest switch case */
- long num_branches; /**< number of jumps */
- char label[SNPRINTF_BUF_LEN]; /**< label of the jump table */
- branch_t *branches; /**< jump array */
-} jmp_tbl_t;
-
-/**
- * Compare two variables of type branch_t. Used to sort all switch cases
- */
-static int ia32_cmp_branch_t(const void *a, const void *b)
-{
- branch_t *b1 = (branch_t *)a;
- branch_t *b2 = (branch_t *)b;
-
- if (b1->value <= b2->value)
- return -1;
- else
- return 1;
-}
-
-static void generate_jump_table(jmp_tbl_t *tbl, const ir_node *node)
-{
- int i;
- long pnc;
- long default_pn;
- ir_node *proj;
- const ir_edge_t *edge;
-
- /* fill the table structure */
- get_unique_label(tbl->label, SNPRINTF_BUF_LEN, ".TBL_");
- tbl->defProj = NULL;
- tbl->num_branches = get_irn_n_edges(node) - 1;
- tbl->branches = XMALLOCNZ(branch_t, tbl->num_branches);
- tbl->min_value = LONG_MAX;
- tbl->max_value = LONG_MIN;
-
- default_pn = get_ia32_condcode(node);
- i = 0;
- /* go over all proj's and collect them */
- foreach_out_edge(node, edge) {
- proj = get_edge_src_irn(edge);
- assert(is_Proj(proj) && "Only proj allowed at SwitchJmp");
-
- pnc = get_Proj_proj(proj);
-
- /* check for default proj */
- if (pnc == default_pn) {
- assert(tbl->defProj == NULL && "found two default Projs at SwitchJmp");
- tbl->defProj = proj;
- } else {
- tbl->min_value = pnc < tbl->min_value ? pnc : tbl->min_value;
- tbl->max_value = pnc > tbl->max_value ? pnc : tbl->max_value;
-
- /* create branch entry */
- tbl->branches[i].target = proj;
- tbl->branches[i].value = pnc;
- ++i;
- }
-
- }
- assert(i == tbl->num_branches);
-
- /* sort the branches by their number */
- qsort(tbl->branches, tbl->num_branches, sizeof(tbl->branches[0]), ia32_cmp_branch_t);