Commit 5f702d9e authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ir: Use ARRAY_SIZE() instead of magic numbers.

parent 94ab70c7
...@@ -222,8 +222,6 @@ static void transform_MemPerm(ir_node *node) ...@@ -222,8 +222,6 @@ static void transform_MemPerm(ir_node *node)
ir_node *sp = be_get_initial_reg_value(irg, &amd64_registers[REG_RSP]); ir_node *sp = be_get_initial_reg_value(irg, &amd64_registers[REG_RSP]);
int arity = be_get_MemPerm_entity_arity(node); int arity = be_get_MemPerm_entity_arity(node);
ir_node **pops = ALLOCAN(ir_node*, arity); ir_node **pops = ALLOCAN(ir_node*, arity);
ir_node *in[1];
ir_node *keep;
int i; int i;
/* create Pushs */ /* create Pushs */
...@@ -302,8 +300,8 @@ static void transform_MemPerm(ir_node *node) ...@@ -302,8 +300,8 @@ static void transform_MemPerm(ir_node *node)
pops[i] = pop; pops[i] = pop;
} }
in[0] = sp; ir_node *const in[] = { sp };
keep = be_new_Keep(block, 1, in); ir_node *const keep = be_new_Keep(block, ARRAY_SIZE(in), in);
sched_replace(node, keep); sched_replace(node, keep);
/* exchange memprojs */ /* exchange memprojs */
......
...@@ -1154,8 +1154,8 @@ static ir_node *gen_Load(ir_node *node) ...@@ -1154,8 +1154,8 @@ static ir_node *gen_Load(ir_node *node)
/* check for special case: the loaded value might not be used */ /* check for special case: the loaded value might not be used */
if (!get_Proj_for_pn(node, pn_Load_res)) { if (!get_Proj_for_pn(node, pn_Load_res)) {
/* add a result proj and a Keep to produce a pseudo use */ /* add a result proj and a Keep to produce a pseudo use */
ir_node *proj = new_r_Proj(new_load, arm_mode_gp, pn_arm_Ldr_res); ir_node *const in[] = { new_r_Proj(new_load, arm_mode_gp, pn_arm_Ldr_res) };
be_new_Keep(block, 1, &proj); be_new_Keep(block, ARRAY_SIZE(in), in);
} }
return new_load; return new_load;
......
...@@ -288,7 +288,7 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl, ...@@ -288,7 +288,7 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl,
return irn; return irn;
} }
ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[]) ir_node *be_new_CopyKeep(ir_node *const bl, ir_node *const src, int const n, ir_node *const *const in_keep)
{ {
ir_mode *mode = get_irn_mode(src); ir_mode *mode = get_irn_mode(src);
ir_graph *irg = get_irn_irg(bl); ir_graph *irg = get_irn_irg(bl);
...@@ -315,7 +315,8 @@ ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[]) ...@@ -315,7 +315,8 @@ ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[])
ir_node *be_new_CopyKeep_single(ir_node *bl, ir_node *src, ir_node *keep) ir_node *be_new_CopyKeep_single(ir_node *bl, ir_node *src, ir_node *keep)
{ {
return be_new_CopyKeep(bl, src, 1, &keep); ir_node *const in[] = { keep };
return be_new_CopyKeep(bl, src, ARRAY_SIZE(in), in);
} }
ir_node *be_get_CopyKeep_op(const ir_node *cpy) ir_node *be_get_CopyKeep_op(const ir_node *cpy)
......
...@@ -146,8 +146,7 @@ enum { ...@@ -146,8 +146,7 @@ enum {
n_be_CopyKeep_op, n_be_CopyKeep_op,
n_be_CopyKeep_max = n_be_CopyKeep_op n_be_CopyKeep_max = n_be_CopyKeep_op
}; };
ir_node *be_new_CopyKeep(ir_node *block, ir_node *src, ir_node *be_new_CopyKeep(ir_node *block, ir_node *src, int n, ir_node *const *in_keep);
int n, ir_node *in_keep[]);
ir_node *be_new_CopyKeep_single(ir_node *block, ir_node *src, ir_node *keep); ir_node *be_new_CopyKeep_single(ir_node *block, ir_node *src, ir_node *keep);
......
...@@ -863,8 +863,8 @@ static void permute_values(ir_nodeset_t *live_nodes, ir_node *before, ...@@ -863,8 +863,8 @@ static void permute_values(ir_nodeset_t *live_nodes, ir_node *before,
/* exchange old_r and r2; after that old_r is a fixed point */ /* exchange old_r and r2; after that old_r is a fixed point */
unsigned r2 = permutation[old_r]; unsigned r2 = permutation[old_r];
ir_node *in[2] = { assignments[r2], assignments[old_r] }; ir_node *const in[] = { assignments[r2], assignments[old_r] };
ir_node *perm = be_new_Perm(cls, block, 2, in); ir_node *const perm = be_new_Perm(cls, block, ARRAY_SIZE(in), in);
sched_add_before(before, perm); sched_add_before(before, perm);
DB((dbg, LEVEL_2, "Perm %+F (perm %+F,%+F, before %+F)\n", DB((dbg, LEVEL_2, "Perm %+F (perm %+F,%+F, before %+F)\n",
perm, in[0], in[1], before)); perm, in[0], in[1], before));
......
...@@ -1218,12 +1218,11 @@ static ir_node *add_to_keep(ir_node *last_keep, ...@@ -1218,12 +1218,11 @@ static ir_node *add_to_keep(ir_node *last_keep,
if (last_keep != NULL) { if (last_keep != NULL) {
be_Keep_add_node(last_keep, cls, node); be_Keep_add_node(last_keep, cls, node);
} else { } else {
ir_node *in[1] = { node }; ir_node *const in[] = { node };
ir_node *block = get_nodes_block(node); ir_node *const block = get_nodes_block(node);
ir_node *schedpoint; last_keep = be_new_Keep(block, ARRAY_SIZE(in), in);
last_keep = be_new_Keep(block, 1, in);
schedpoint = skip_Proj(node); ir_node *const schedpoint = skip_Proj(node);
if (sched_is_scheduled(schedpoint)) { if (sched_is_scheduled(schedpoint)) {
sched_add_after(schedpoint, last_keep); sched_add_after(schedpoint, last_keep);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "ia32_common_transform.h" #include "ia32_common_transform.h"
#include "ia32_transform.h" #include "ia32_transform.h"
#include "ia32_architecture.h" #include "ia32_architecture.h"
#include "util.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
...@@ -635,8 +636,8 @@ static ir_node *create_pop(dbg_info *dbgi, ir_node *block, ...@@ -635,8 +636,8 @@ static ir_node *create_pop(dbg_info *dbgi, ir_node *block,
sched_add_before(schedpoint, pop); sched_add_before(schedpoint, pop);
ir_node *in[1] = { val }; ir_node *const in[] = { val };
ir_node *keep = be_new_Keep(block, 1, in); ir_node *const keep = be_new_Keep(block, ARRAY_SIZE(in), in);
sched_add_before(schedpoint, keep); sched_add_before(schedpoint, keep);
return stack; return stack;
......
...@@ -319,7 +319,7 @@ ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node ...@@ -319,7 +319,7 @@ ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node
{ {
ir_graph *const irg = get_irn_irg(block); ir_graph *const irg = get_irn_irg(block);
ir_node *const in[] = { irn_mem, irn_left, irn_right }; ir_node *const in[] = { irn_mem, irn_left, irn_right };
ir_node *res = new_ir_node(dbgi, irg, block, op_Div, mode_T, 3, in); ir_node *res = new_ir_node(dbgi, irg, block, op_Div, mode_T, ARRAY_SIZE(in), in);
res->attr.div.resmode = resmode; res->attr.div.resmode = resmode;
res->attr.div.no_remainder = 1; res->attr.div.no_remainder = 1;
res->attr.div.exc.pin_state = pin_state; res->attr.div.exc.pin_state = pin_state;
......
...@@ -5767,13 +5767,10 @@ static ir_node *transform_node_shift(ir_node *n) ...@@ -5767,13 +5767,10 @@ static ir_node *transform_node_shift(ir_node *n)
/* ok, we can replace it */ /* ok, we can replace it */
assert(modulo_shf >= get_mode_size_bits(mode)); assert(modulo_shf >= get_mode_size_bits(mode));
ir_node *block = get_nodes_block(n); ir_node *const block = get_nodes_block(n);
ir_node *const val = get_binop_left(left);
ir_node *in[2]; ir_node *const amt = new_r_Const(irg, res);
in[0] = get_binop_left(left); ir_node *const irn = new_binop(n, block, val, amt);
in[1] = new_r_Const(irg, res);
ir_node *irn = new_ir_node(NULL, irg, block, get_irn_op(n), mode, 2, in);
DBG_OPT_ALGSIM0(n, irn, FS_OPT_REASSOC_SHIFT); DBG_OPT_ALGSIM0(n, irn, FS_OPT_REASSOC_SHIFT);
......
Markdown is supported
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