Commit 7274fb57 authored by yb9976's avatar yb9976
Browse files

Cleanup using C99.

parent 36bdf621
...@@ -1208,28 +1208,25 @@ static void loop_inversion(ir_graph *const irg) ...@@ -1208,28 +1208,25 @@ static void loop_inversion(ir_graph *const irg)
/* Fix the original loop_heads ins for invariant unrolling case. */ /* Fix the original loop_heads ins for invariant unrolling case. */
static void unrolling_fix_loop_head_inv(void) static void unrolling_fix_loop_head_inv(void)
{ {
ir_node *ins[2];
/* Original loop_heads ins are: /* Original loop_heads ins are:
* duff block and the own backedge */ * duff block and the own backedge */
ir_node *const proj = new_r_Proj(loop_info.duff_cond, mode_X, 0); ir_node *const proj = new_r_Proj(loop_info.duff_cond, mode_X, 0);
ir_node *const head_pred = get_Block_cfgpred(loop_head, loop_info.be_src_pos); ir_node *const head_pred = get_Block_cfgpred(loop_head, loop_info.be_src_pos);
ir_node *const loop_condition = get_unroll_copy(head_pred, unroll_nr - 1); ir_node *const loop_condition = get_unroll_copy(head_pred, unroll_nr - 1);
ins[0] = loop_condition; ir_node *const loop_head_ins[] = { loop_condition, proj };
ins[1] = proj; set_irn_in(loop_head, ARRAY_SIZE(loop_head_ins), loop_head_ins);
set_irn_in(loop_head, 2, ins); DB((dbg, LEVEL_4, "Rewire ins of block loophead %N to pred %N and duffs entry %N \n" , loop_head, loop_head_ins[0], loop_head_ins[1]));
DB((dbg, LEVEL_4, "Rewire ins of block loophead %N to pred %N and duffs entry %N \n" , loop_head, ins[0], ins[1]));
for_each_phi(loop_head, phi) { for_each_phi(loop_head, phi) {
ir_node *const pred = get_Phi_pred(phi, loop_info.be_src_pos); ir_node *const pred = get_Phi_pred(phi, loop_info.be_src_pos);
/* TODO we think it is a phi, but for Mergesort it is not the case.*/ /* TODO we think it is a phi, but for Mergesort it is not the case.*/
ir_node *const last_pred = get_unroll_copy(pred, unroll_nr - 1); ir_node *const last_pred = get_unroll_copy(pred, unroll_nr - 1);
ins[0] = last_pred; ir_node *const phi_ins[] = { last_pred, (ir_node*)get_irn_link(phi) };
ins[1] = (ir_node*)get_irn_link(phi); set_irn_in(phi, ARRAY_SIZE(phi_ins), phi_ins);
set_irn_in(phi, 2, ins); DB((dbg, LEVEL_4, "Rewire ins of loophead phi %N to pred %N and duffs entry %N \n" , phi, phi_ins[0], phi_ins[1]));
DB((dbg, LEVEL_4, "Rewire ins of loophead phi %N to pred %N and duffs entry %N \n" , phi, ins[0], ins[1]));
} }
} }
...@@ -1272,9 +1269,8 @@ static void place_copies(int const copies) ...@@ -1272,9 +1269,8 @@ static void place_copies(int const copies)
DB((dbg, LEVEL_5, "topmost be block %N \n", topmost_be_block)); DB((dbg, LEVEL_5, "topmost be block %N \n", topmost_be_block));
if (loop_info.unroll_kind == constant) { if (loop_info.unroll_kind == constant) {
ir_node *ins[1]; ir_node *ins[] = { new_jmp };
ins[0] = new_jmp; set_irn_in(lower, ARRAY_SIZE(ins), ins);
set_irn_in(lower, 1, ins);
for_each_phi(loophead, phi) { for_each_phi(loophead, phi) {
ir_node *const topmost_def = get_Phi_pred(phi, be_src_pos); ir_node *const topmost_def = get_Phi_pred(phi, be_src_pos);
...@@ -1288,21 +1284,19 @@ static void place_copies(int const copies) ...@@ -1288,21 +1284,19 @@ static void place_copies(int const copies)
else else
ins[0] = topmost_def; ins[0] = topmost_def;
set_irn_in(lower_phi, 1, ins); set_irn_in(lower_phi, ARRAY_SIZE(ins), ins);
/* Need to replace phis with 1 in later. */ /* Need to replace phis with 1 in later. */
} }
} else { } else {
/* Invariant case */
/* Every node has 2 ins. One from the duff blocks
* and one from the previously unrolled loop. */
ir_node *ins[2];
/* Calculate corresponding projection of mod result for this copy c */ /* Calculate corresponding projection of mod result for this copy c */
ir_node *proj = new_r_Proj(loop_info.duff_cond, mode_X, unroll_nr - c - 1); ir_node *proj = new_r_Proj(loop_info.duff_cond, mode_X, unroll_nr - c - 1);
DB((dbg, LEVEL_4, "New duff proj %N\n" , proj)); DB((dbg, LEVEL_4, "New duff proj %N\n" , proj));
ins[0] = new_jmp; /* Invariant case */
ins[1] = proj; /* Every node has 2 ins. One from the duff blocks
set_irn_in(lower, 2, ins); * and one from the previously unrolled loop. */
ir_node *ins[] = { new_jmp, proj };
set_irn_in(lower, ARRAY_SIZE(ins), ins);
DB((dbg, LEVEL_4, "Rewire ins of Block %N to pred %N and duffs entry %N \n" , lower, ins[0], ins[1])); DB((dbg, LEVEL_4, "Rewire ins of Block %N to pred %N and duffs entry %N \n" , lower, ins[0], ins[1]));
for_each_phi(loophead, phi) { for_each_phi(loophead, phi) {
...@@ -1314,10 +1308,9 @@ static void place_copies(int const copies) ...@@ -1314,10 +1308,9 @@ static void place_copies(int const copies)
ir_node *const upper_phi_pred = is_in_loop(topmost_phi_pred) ? ir_node *const upper_phi_pred = is_in_loop(topmost_phi_pred) ?
get_unroll_copy(topmost_phi_pred, c) : topmost_phi_pred; get_unroll_copy(topmost_phi_pred, c) : topmost_phi_pred;
ins[0] = upper_phi_pred; ir_node *phi_ins[] = { upper_phi_pred, duff_phi };
ins[1] = duff_phi; set_irn_in(lower_phi, ARRAY_SIZE(phi_ins), phi_ins);
set_irn_in(lower_phi, 2, ins); DB((dbg, LEVEL_4, "Rewire ins of %N to pred %N and duffs entry %N \n" , lower_phi, phi_ins[0], phi_ins[1]));
DB((dbg, LEVEL_4, "Rewire ins of %N to pred %N and duffs entry %N \n" , lower_phi, ins[0], ins[1]));
} }
} }
} }
...@@ -1431,8 +1424,6 @@ static ir_node *new_Abs(ir_node *const op, ir_mode *const mode) ...@@ -1431,8 +1424,6 @@ static ir_node *new_Abs(ir_node *const op, ir_mode *const mode)
* TODO split */ * TODO split */
static void create_duffs_block(ir_graph *const irg) static void create_duffs_block(ir_graph *const irg)
{ {
ir_node *ins[2];
/* TODO naming /* TODO naming
* 1. Calculate first approach to count. * 1. Calculate first approach to count.
* Condition: (end - start) % step == 0 */ * Condition: (end - start) % step == 0 */
...@@ -1479,9 +1470,8 @@ static void create_duffs_block(ir_graph *const irg) ...@@ -1479,9 +1470,8 @@ static void create_duffs_block(ir_graph *const irg)
* decreasing: count < 0 * decreasing: count < 0
* increasing: count > 0 * increasing: count > 0
*/ */
ins[0] = x_true; ir_node *const count_block_ins[] = { x_true, x_false };
ins[1] = x_false; ir_node *const count_block = new_r_Block(irg, ARRAY_SIZE(count_block_ins), count_block_ins);
ir_node *const count_block = new_r_Block(irg, ARRAY_SIZE(ins), ins);
DB((dbg, LEVEL_4, "Duff block 2 %N\n", count_block)); DB((dbg, LEVEL_4, "Duff block 2 %N\n", count_block));
...@@ -1502,9 +1492,8 @@ static void create_duffs_block(ir_graph *const irg) ...@@ -1502,9 +1492,8 @@ static void create_duffs_block(ir_graph *const irg)
false_val = new_r_Const_long(irg, mode, 2); false_val = new_r_Const_long(irg, mode, 2);
} }
ins[0] = true_val; ir_node *const correction_ins[] = { true_val, false_val };
ins[1] = false_val; ir_node *const correction = new_r_Phi(count_block, ARRAY_SIZE(correction_ins), correction_ins, mode);
ir_node *const correction = new_r_Phi(count_block, ARRAY_SIZE(ins), ins, mode);
/* (end - start) / step + correction */ /* (end - start) / step + correction */
ir_node *const count = new_r_Add(count_block ,div_res, correction, mode); ir_node *const count = new_r_Add(count_block ,div_res, correction, mode);
...@@ -1525,16 +1514,15 @@ static void create_duffs_block(ir_graph *const irg) ...@@ -1525,16 +1514,15 @@ static void create_duffs_block(ir_graph *const irg)
/* 3. Duff Block /* 3. Duff Block
* Contains module to decide which loop to start from. */ * Contains module to decide which loop to start from. */
ins[0] = good_count; ir_node *const duff_block_ins[] = { good_count, bad_count };
ins[1] = bad_count; ir_node *const duff_block = new_r_Block(irg, ARRAY_SIZE(duff_block_ins), duff_block_ins);
ir_node *const duff_block = new_r_Block(irg, ARRAY_SIZE(ins), ins);
DB((dbg, LEVEL_4, "Duff block 3 %N\n", duff_block)); DB((dbg, LEVEL_4, "Duff block 3 %N\n", duff_block));
/* Get absolute value */ /* Get absolute value */
ins[0] = new_Abs(count, mode); ir_node *const abs = new_Abs(count, mode);
/* Manually feed the aforementioned count = 1 (bad case)*/ /* Manually feed the aforementioned count = 1 (bad case)*/
ins[1] = one; ir_node *const count_phi_ins[] = { abs, one };
ir_node *const count_phi = new_r_Phi(duff_block, ARRAY_SIZE(ins), ins, mode); ir_node *const count_phi = new_r_Phi(duff_block, ARRAY_SIZE(count_phi_ins), count_phi_ins, mode);
/* count % unroll_nr */ /* count % unroll_nr */
ir_node *const unroll_c = new_r_Const_long(irg, mode, (long)unroll_nr); ir_node *const unroll_c = new_r_Const_long(irg, mode, (long)unroll_nr);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment