Commit 1209ae49 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

array: Add and use NEW_ARR_DZ().

parent 5933e03f
...@@ -109,6 +109,12 @@ ...@@ -109,6 +109,12 @@
? (type *)ir_new_arr_d((obstack), (nelts), sizeof(type) * (nelts)) \ ? (type *)ir_new_arr_d((obstack), (nelts), sizeof(type) * (nelts)) \
: (type *)arr_mt_descr.elts) : (type *)arr_mt_descr.elts)
/**
* Create a dynamic array on an obstack and null its contents.
*/
#define NEW_ARR_DZ(type, obstack, nelts) \
((type*)memset(NEW_ARR_D(type, (obstack), (nelts)), 0, sizeof(type) * (nelts)))
/** /**
* Creates a new dynamic array with the same number of elements as a * Creates a new dynamic array with the same number of elements as a
* given one. * given one.
......
...@@ -108,8 +108,7 @@ static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags, ...@@ -108,8 +108,7 @@ static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
arch_set_irn_register_reqs_in(node, in_reqs); arch_set_irn_register_reqs_in(node, in_reqs);
info = be_get_info(node); info = be_get_info(node);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
} }
static void set_TEMPLATE_value(ir_node *node, ir_tarval *value) static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
......
...@@ -130,8 +130,7 @@ static void init_amd64_attributes(ir_node *node, arch_irn_flags_t flags, ...@@ -130,8 +130,7 @@ static void init_amd64_attributes(ir_node *node, arch_irn_flags_t flags,
arch_set_irn_register_reqs_in(node, in_reqs); arch_set_irn_register_reqs_in(node, in_reqs);
info = be_get_info(node); info = be_get_info(node);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
attr->data.ins_permuted = 0; attr->data.ins_permuted = 0;
attr->data.cmp_unsigned = 0; attr->data.cmp_unsigned = 0;
......
...@@ -323,8 +323,7 @@ static void init_arm_attributes(ir_node *node, arch_irn_flags_t flags, ...@@ -323,8 +323,7 @@ static void init_arm_attributes(ir_node *node, arch_irn_flags_t flags,
attr->is_load_store = false; attr->is_load_store = false;
info = be_get_info(node); info = be_get_info(node);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
} }
static void init_arm_load_store_attributes(ir_node *res, ir_mode *ls_mode, static void init_arm_load_store_attributes(ir_node *res, ir_mode *ls_mode,
......
...@@ -72,8 +72,7 @@ void be_info_new_node(ir_graph *irg, ir_node *node) ...@@ -72,8 +72,7 @@ void be_info_new_node(ir_graph *irg, ir_node *node)
info->flags |= arch_irn_flags_not_scheduled; info->flags |= arch_irn_flags_not_scheduled;
/* FALLTHROUGH */ /* FALLTHROUGH */
case iro_Phi: case iro_Phi:
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
info->out_infos[0].req = arch_no_register_req; info->out_infos[0].req = arch_no_register_req;
break; break;
default: default:
......
...@@ -231,8 +231,7 @@ static void init_node_attr(ir_node *node, int n_inputs, int n_outputs) ...@@ -231,8 +231,7 @@ static void init_node_attr(ir_node *node, int n_inputs, int n_outputs)
} }
info->in_reqs = in_reqs; info->in_reqs = in_reqs;
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_outputs); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_outputs);
memset(info->out_infos, 0, n_outputs * sizeof(info->out_infos[0]));
for (int i = 0; i < n_outputs; ++i) { for (int i = 0; i < n_outputs; ++i) {
info->out_infos[i].req = arch_no_register_req; info->out_infos[i].req = arch_no_register_req;
} }
...@@ -1047,9 +1046,8 @@ ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode, ...@@ -1047,9 +1046,8 @@ ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
ir_node *phi = new_ir_node(NULL, irg, block, op_Phi, mode, n_ins, ins); ir_node *phi = new_ir_node(NULL, irg, block, op_Phi, mode, n_ins, ins);
phi->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), n_ins); phi->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), n_ins);
info = be_get_info(phi); info = be_get_info(phi);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0])); info->in_reqs = OALLOCN(obst, const arch_register_req_t*, n_ins);
info->in_reqs = OALLOCN(obst, const arch_register_req_t*, n_ins);
info->out_infos[0].req = req; info->out_infos[0].req = req;
for (i = 0; i < n_ins; ++i) { for (i = 0; i < n_ins; ++i) {
......
...@@ -457,9 +457,7 @@ ir_node *ia32_gen_ASM(ir_node *node) ...@@ -457,9 +457,7 @@ ir_node *ia32_gen_ASM(ir_node *node)
reg_map_size = constraint->pos+1; reg_map_size = constraint->pos+1;
} }
ia32_asm_reg_t *register_map ia32_asm_reg_t *const register_map = NEW_ARR_DZ(ia32_asm_reg_t, obst, reg_map_size);
= NEW_ARR_D(ia32_asm_reg_t, obst, reg_map_size);
memset(register_map, 0, reg_map_size * sizeof(register_map[0]));
/* construct output constraints */ /* construct output constraints */
size_t out_size = out_arity + 1; size_t out_size = out_arity + 1;
......
...@@ -790,8 +790,7 @@ static void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, ...@@ -790,8 +790,7 @@ static void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
#endif #endif
info = be_get_info(node); info = be_get_info(node);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
} }
static void init_ia32_x87_attributes(ir_node *res) static void init_ia32_x87_attributes(ir_node *res)
......
...@@ -235,8 +235,7 @@ static void init_sparc_attributes(ir_node *node, arch_irn_flags_t flags, ...@@ -235,8 +235,7 @@ static void init_sparc_attributes(ir_node *node, arch_irn_flags_t flags,
arch_set_irn_register_reqs_in(node, in_reqs); arch_set_irn_register_reqs_in(node, in_reqs);
info = be_get_info(node); info = be_get_info(node);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res); info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
} }
static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode, static void init_sparc_load_store_attributes(ir_node *res, ir_mode *ls_mode,
......
...@@ -444,8 +444,7 @@ ir_node *new_rd_immBlock(dbg_info *dbgi, ir_graph *irg) ...@@ -444,8 +444,7 @@ ir_node *new_rd_immBlock(dbg_info *dbgi, ir_graph *irg)
set_Block_block_visited(res, 0); set_Block_block_visited(res, 0);
/* Create and initialize array for Phi-node construction. */ /* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), irg->n_loc); res->attr.block.graph_arr = NEW_ARR_DZ(ir_node*, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, sizeof(ir_node*) * irg->n_loc);
/* Immature block may not be optimized! */ /* Immature block may not be optimized! */
irn_verify_irg(res, irg); irn_verify_irg(res, irg);
...@@ -718,8 +717,7 @@ ir_node *new_r_Block_noopt(ir_graph *irg, int arity, ir_node *in[]) ...@@ -718,8 +717,7 @@ ir_node *new_r_Block_noopt(ir_graph *irg, int arity, ir_node *in[])
set_Block_matured(res, 1); set_Block_matured(res, 1);
/* Create and initialize array for Phi-node construction. */ /* Create and initialize array for Phi-node construction. */
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) { if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
res->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), irg->n_loc); res->attr.block.graph_arr = NEW_ARR_DZ(ir_node*, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
} }
irn_verify_irg(res, irg); irn_verify_irg(res, irg);
return res; return res;
......
...@@ -44,8 +44,7 @@ static void prepare_blocks(ir_node *block, void *env) ...@@ -44,8 +44,7 @@ static void prepare_blocks(ir_node *block, void *env)
(void)env; (void)env;
/* reset mature flag */ /* reset mature flag */
set_Block_matured(block, 0); set_Block_matured(block, 0);
block->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), n_loc); block->attr.block.graph_arr = NEW_ARR_DZ(ir_node*, get_irg_obstack(irg), n_loc);
memset(block->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc);
set_Block_phis(block, NULL); set_Block_phis(block, NULL);
} }
......
...@@ -493,8 +493,7 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp) ...@@ -493,8 +493,7 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp)
info = ir_nodemap_get(unrolling_node_info, &map, n); info = ir_nodemap_get(unrolling_node_info, &map, n);
if (! info) { if (! info) {
ir_node **arr = NEW_ARR_D(ir_node*, &obst, unroll_nr); ir_node **const arr = NEW_ARR_DZ(ir_node*, &obst, unroll_nr);
memset(arr, 0, unroll_nr * sizeof(ir_node*));
info = OALLOCZ(&obst, unrolling_node_info); info = OALLOCZ(&obst, unrolling_node_info);
info->copies = arr; info->copies = arr;
......
...@@ -2138,22 +2138,19 @@ void opt_ldst(ir_graph *irg) ...@@ -2138,22 +2138,19 @@ void opt_ldst(ir_graph *irg)
/* create the current set */ /* create the current set */
env.curr_set = rbitset_obstack_alloc(&env.obst, env.rbs_size); env.curr_set = rbitset_obstack_alloc(&env.obst, env.rbs_size);
rbitset_set(env.curr_set, env.rbs_size - 1); rbitset_set(env.curr_set, env.rbs_size - 1);
env.curr_id_2_memop = NEW_ARR_D(memop_t *, &env.obst, env.rbs_size); env.curr_id_2_memop = NEW_ARR_DZ(memop_t*, &env.obst, env.rbs_size);
memset(env.curr_id_2_memop, 0, env.rbs_size * sizeof(env.curr_id_2_memop[0]));
for (bl = env.forward; bl != NULL; bl = bl->forward_next) { for (bl = env.forward; bl != NULL; bl = bl->forward_next) {
/* set sentinel bits */ /* set sentinel bits */
bl->avail_out = rbitset_obstack_alloc(&env.obst, env.rbs_size); bl->avail_out = rbitset_obstack_alloc(&env.obst, env.rbs_size);
rbitset_set(bl->avail_out, env.rbs_size - 1); rbitset_set(bl->avail_out, env.rbs_size - 1);
bl->id_2_memop_avail = NEW_ARR_D(memop_t *, &env.obst, env.rbs_size); bl->id_2_memop_avail = NEW_ARR_DZ(memop_t*, &env.obst, env.rbs_size);
memset(bl->id_2_memop_avail, 0, env.rbs_size * sizeof(bl->id_2_memop_avail[0]));
bl->anticL_in = rbitset_obstack_alloc(&env.obst, env.rbs_size); bl->anticL_in = rbitset_obstack_alloc(&env.obst, env.rbs_size);
rbitset_set(bl->anticL_in, env.rbs_size - 1); rbitset_set(bl->anticL_in, env.rbs_size - 1);
bl->id_2_memop_antic = NEW_ARR_D(memop_t *, &env.obst, env.rbs_size); bl->id_2_memop_antic = NEW_ARR_DZ(memop_t*, &env.obst, env.rbs_size);
memset(bl->id_2_memop_antic, 0, env.rbs_size * sizeof(bl->id_2_memop_antic[0]));
} }
(void) dump_block_list; (void) dump_block_list;
......
...@@ -234,8 +234,7 @@ class Block: ...@@ -234,8 +234,7 @@ class Block:
/* Create and initialize array for Phi-node construction. */ /* Create and initialize array for Phi-node construction. */
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) { if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, get_irg_obstack(irg), irg->n_loc); res->attr.block.graph_arr = NEW_ARR_DZ(ir_node*, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
} }
''' '''
......
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