Commit 8ca4adce authored by yb9976's avatar yb9976
Browse files

Clean up dca code (using C99).

parent 58f73478
...@@ -65,8 +65,7 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -65,8 +65,7 @@ static void dca_transfer(ir_node *irn, pdeq *q)
DBG((dbg, LEVEL_2, "analysing %+F\n", irn)); DBG((dbg, LEVEL_2, "analysing %+F\n", irn));
if (is_Block(irn)) { if (is_Block(irn)) {
int i; for (int i = 0; i < get_Block_n_cfgpreds(irn); i++)
for (i = 0; i < get_Block_n_cfgpreds(irn); i++)
care_for(get_Block_cfgpred(irn, i), care, q); care_for(get_Block_cfgpred(irn, i), care, q);
return; return;
} }
...@@ -74,50 +73,40 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -74,50 +73,40 @@ static void dca_transfer(ir_node *irn, pdeq *q)
if (mode == mode_X) { if (mode == mode_X) {
care_for(get_nodes_block(irn), 0, q); care_for(get_nodes_block(irn), 0, q);
switch (get_irn_opcode(irn)) { switch (get_irn_opcode(irn)) {
case iro_Return: { case iro_Return:
int i; for (int i = 0; i < get_Return_n_ress(irn); i++)
for (i = 0; i < get_Return_n_ress(irn); i++)
care_for(get_Return_res(irn, i), care, q); care_for(get_Return_res(irn, i), care, q);
care_for(get_Return_mem(irn), care, q); care_for(get_Return_mem(irn), care, q);
} return;
return; case iro_Call:
case iro_Call: { for (int i = 0; i < get_Call_n_params(irn); i++)
int i;
for (i = 0; i < get_Call_n_params(irn); i++)
care_for(get_Call_param(irn, i), care, q); care_for(get_Call_param(irn, i), care, q);
care_for(get_Call_mem(irn), care, q); care_for(get_Call_mem(irn), care, q);
} return;
return;
case iro_Jmp: case iro_Jmp:
default: { default:
int i; for (int i = 0; i < get_irn_arity(irn); i++)
for (i = 0; i < get_irn_arity(irn); i++)
care_for(get_irn_n(irn, i), 0, q); care_for(get_irn_n(irn, i), 0, q);
care_for(get_nodes_block(irn), 0, q); care_for(get_nodes_block(irn), 0, q);
} return;
return;
} }
} }
switch (get_irn_opcode(irn)) { if (is_Phi(irn)) {
case iro_Phi: {
int i;
int npreds = get_Phi_n_preds(irn); int npreds = get_Phi_n_preds(irn);
for (i = 0; i < npreds; i++) for (int i = 0; i < npreds; i++)
care_for(get_Phi_pred(irn, i), care, q); care_for(get_Phi_pred(irn, i), care, q);
care_for(get_nodes_block(irn), 0, q); care_for(get_nodes_block(irn), 0, q);
return; return;
} }
}
if (mode_is_int(mode) || mode==mode_b) { if (mode_is_int(mode) || mode==mode_b) {
switch (get_irn_opcode(irn)) { switch (get_irn_opcode(irn)) {
case iro_Conv: { case iro_Conv: {
ir_node *pred = get_irn_n(irn, 0); ir_node *pred = get_Conv_op(irn);
ir_mode *pred_mode = get_irn_mode(pred); ir_mode *pred_mode = get_irn_mode(pred);
unsigned pred_bits = get_mode_size_bits(pred_mode); unsigned pred_bits = get_mode_size_bits(pred_mode);
...@@ -143,18 +132,18 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -143,18 +132,18 @@ static void dca_transfer(ir_node *irn, pdeq *q)
return; return;
} }
case iro_And: { case iro_And: {
ir_node *arg0 = get_irn_n(irn, 0); ir_node *left = get_And_left(irn);
ir_node *arg1 = get_irn_n(irn, 1); ir_node *right = get_And_right(irn);
if (is_Const(arg0)) { if (is_Const(left)) {
care_for(arg1, tarval_and(care, get_Const_tarval(arg0)), q); care_for(right, tarval_and(care, get_Const_tarval(left)), q);
care_for(arg0, care, q); care_for(left, care, q);
} else if (is_Const(arg1)) { } else if (is_Const(right)) {
care_for(arg0, tarval_and(care, get_Const_tarval(arg1)), q); care_for(left, tarval_and(care, get_Const_tarval(right)), q);
care_for(arg1, care, q); care_for(right, care, q);
} else { } else {
care_for(arg0, care, q); care_for(left, care, q);
care_for(arg1, care, q); care_for(right, care, q);
} }
return; return;
} }
...@@ -165,7 +154,7 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -165,7 +154,7 @@ static void dca_transfer(ir_node *irn, pdeq *q)
return; return;
} }
case iro_Or: { case iro_Or: {
ir_node *left = get_binop_left(irn); ir_node *left = get_binop_left(irn);
ir_node *right = get_binop_right(irn); ir_node *right = get_binop_right(irn);
if (is_Const(left)) { if (is_Const(left)) {
...@@ -188,7 +177,7 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -188,7 +177,7 @@ static void dca_transfer(ir_node *irn, pdeq *q)
return; return;
case iro_Add: case iro_Add:
case iro_Sub: { case iro_Sub: {
ir_node *left = get_binop_left(irn); ir_node *left = get_binop_left(irn);
ir_node *right = get_binop_right(irn); ir_node *right = get_binop_right(irn);
care_for(right, care, q); care_for(right, care, q);
care_for(left, care, q); care_for(left, care, q);
...@@ -203,7 +192,7 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -203,7 +192,7 @@ static void dca_transfer(ir_node *irn, pdeq *q)
return; return;
case iro_Shrs: case iro_Shrs:
case iro_Shr: { case iro_Shr: {
ir_node *left= get_binop_left(irn); ir_node *left = get_binop_left(irn);
ir_node *right = get_binop_right(irn); ir_node *right = get_binop_right(irn);
if (is_Const(right)) { if (is_Const(right)) {
...@@ -223,54 +212,49 @@ static void dca_transfer(ir_node *irn, pdeq *q) ...@@ -223,54 +212,49 @@ static void dca_transfer(ir_node *irn, pdeq *q)
return; return;
} }
case iro_Shl: { case iro_Shl: {
ir_node *arg0 = get_irn_n(irn, 0); ir_node *left = get_Shl_left(irn);
ir_node *arg1 = get_irn_n(irn, 1); ir_node *right = get_Shl_right(irn);
if (is_Const(arg1)) if (is_Const(right))
care_for(arg0, tarval_shr(care, get_Const_tarval(arg1)), q); care_for(left, tarval_shr(care, get_Const_tarval(right)), q);
else else
care_for(arg0, care, q); care_for(left, care, q);
care_for(arg1, 0, q); care_for(right, 0, q);
return; return;
} }
case iro_Mul: { case iro_Mul: {
ir_node *arg0 = get_irn_n(irn, 0); ir_node *left = get_Mul_left(irn);
ir_node *arg1 = get_irn_n(irn, 1); ir_node *right = get_Mul_right(irn);
if (is_Const(arg1)) if (is_Const(right))
care_for( care_for(
arg0, left,
tarval_shr( tarval_shr(
care, care,
new_tarval_from_long( new_tarval_from_long(
get_tarval_lowest_bit( get_tarval_lowest_bit(
get_Const_tarval(arg1)), mode)), get_Const_tarval(right)), mode)),
q); q);
else else
care_for(arg0, care, q); care_for(left, care, q);
care_for(arg1, 0, q); care_for(right, 0, q);
return; return;
} }
} }
} }
if (mode == mode_M || mode == mode_T) { if (mode == mode_M || mode == mode_T) {
int i; for (int i = 0; i < get_irn_arity(irn); i++)
for (i = 0; i < get_irn_arity(irn); i++)
care_for(get_irn_n(irn, i), care, q); care_for(get_irn_n(irn, i), care, q);
return; return;
} }
/* Assume worst case on other nodes */ /* Assume worst case on other nodes */
{ for (int i = 0; i < get_irn_arity(irn); i++)
int i; care_for(get_irn_n(irn, i), 0, q);
for (i = 0; i < get_irn_arity(irn); i++)
care_for(get_irn_n(irn, i), 0, q);
return;
}
} }
static void dca_init_node(ir_node *n, void *data) static void dca_init_node(ir_node *n, void *data)
...@@ -318,12 +302,11 @@ void dca_analyze(ir_graph *irg) ...@@ -318,12 +302,11 @@ void dca_analyze(ir_graph *irg)
void dca_add_fuzz(ir_node *node, void *data) void dca_add_fuzz(ir_node *node, void *data)
{ {
(void) data; (void) data;
int i;
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
if (is_Eor(node)) return; if (is_Eor(node)) return;
for (i = 0; i < get_irn_arity(node); i++) { for (int i = 0; i < get_irn_arity(node); i++) {
ir_node *pred = get_irn_n(node, i); ir_node *pred = get_irn_n(node, i);
ir_mode *pred_mode = get_irn_mode(pred); ir_mode *pred_mode = get_irn_mode(pred);
ir_tarval *dc = get_irn_link(pred); ir_tarval *dc = get_irn_link(pred);
......
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