Commit 429d687f authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add ALLOCAN() and ALLOCANZ().

[r22985]
parent 38249b03
......@@ -116,8 +116,8 @@ ir_node *create_phi(be_ssa_construction_env_t *env, ir_node *block,
{
int i, n_preds = get_Block_n_cfgpreds(block);
ir_graph *irg = get_irn_irg(block);
ir_node *phi;
ir_node **ins = alloca(n_preds * sizeof(ins[0]));
ir_node **ins = ALLOCAN(ir_node*, n_preds);
ir_node *phi;
assert(n_preds > 1);
......
......@@ -166,12 +166,13 @@ void create_reload(minibelady_env_t *env, ir_node *state, ir_node *before,
static
void spill_phi(minibelady_env_t *env, ir_node *phi)
{
ir_graph *irg = get_irn_irg(phi);
ir_node *block = get_nodes_block(phi);
int i, arity = get_irn_arity(phi);
ir_node **in = alloca(arity * sizeof(in[0]));
ir_node *spill_to_kill = NULL;
ir_graph *irg = get_irn_irg(phi);
ir_node *block = get_nodes_block(phi);
int arity = get_irn_arity(phi);
ir_node **in = ALLOCAN(ir_node*, arity);
ir_node *spill_to_kill = NULL;
spill_info_t *spill_info;
int i;
/* does a spill exist for the phis value? */
spill_info = get_spill_info(env, phi);
......
......@@ -109,7 +109,7 @@ ir_node *be_duplicate_node(ir_node *node) {
add_irn_n(new_node, in);
}
} else {
ir_node **ins = alloca(arity * sizeof(ins[0]));
ir_node **ins = ALLOCAN(ir_node*, arity);
for (i = 0; i < arity; ++i) {
ir_node *in = get_irn_n(node, i);
ins[i] = be_transform_node(in);
......
......@@ -544,11 +544,12 @@ static void collect_spills_walker(ir_node *node, void *data) {
}
}
static void check_spillslot_interference(be_verify_spillslots_env_t *env) {
int spillcount = set_count(env->spills);
spill_t **spills = alloca(spillcount * sizeof(spills[0]));
spill_t *spill;
int i;
static void check_spillslot_interference(be_verify_spillslots_env_t *env)
{
int spillcount = set_count(env->spills);
spill_t **spills = ALLOCAN(spill_t*, spillcount);
spill_t *spill;
int i;
for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
spills[i] = spill;
......@@ -820,8 +821,7 @@ static void verify_block_register_allocation(ir_node *block, void *data) {
assert(lv->nodes && "live sets must be computed");
n_regs = arch_register_class_n_regs(regclass);
registers = alloca(n_regs * sizeof(registers[0]));
memset(registers, 0, n_regs * sizeof(registers[0]));
registers = ALLOCANZ(ir_node*, n_regs);
be_lv_foreach(lv, block, be_lv_state_end, idx) {
ir_node *node = be_lv_get_irn(lv, block, idx);
......
......@@ -1307,19 +1307,18 @@ static ir_node* create_spproj(ir_node *node, ir_node *pred, int pos)
* push/pop into/from memory cascades. This is possible without using
* any registers.
*/
static void transform_MemPerm(ia32_code_gen_t *cg, ir_node *node) {
ir_graph *irg = get_irn_irg(node);
ir_node *block = get_nodes_block(node);
ir_node *in[1];
ir_node *keep;
int i, arity;
ir_node *sp = be_abi_get_ignore_irn(cg->birg->abi, &ia32_gp_regs[REG_ESP]);
static void transform_MemPerm(ia32_code_gen_t *cg, ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
ir_node *block = get_nodes_block(node);
ir_node *sp = be_abi_get_ignore_irn(cg->birg->abi, &ia32_gp_regs[REG_ESP]);
int arity = be_get_MemPerm_entity_arity(node);
ir_node **pops = ALLOCAN(ir_node*, arity);
ir_node *in[1];
ir_node *keep;
int i;
const ir_edge_t *edge;
const ir_edge_t *next;
ir_node **pops;
arity = be_get_MemPerm_entity_arity(node);
pops = alloca(arity * sizeof(pops[0]));
/* create Pushs */
for(i = 0; i < arity; ++i) {
......
......@@ -499,8 +499,7 @@ ir_node *gen_ASM(ir_node *node)
}
arity = get_irn_arity(node);
in = alloca(arity * sizeof(in[0]));
memset(in, 0, arity * sizeof(in[0]));
in = ALLOCANZ(ir_node*, arity);
clobbers = get_ASM_clobbers(node);
n_clobbers = 0;
......
......@@ -3504,7 +3504,7 @@ static ir_node *gen_be_Return(ir_node *node)
/* create a new barrier */
arity = get_irn_arity(barrier);
in = alloca(arity * sizeof(in[0]));
in = ALLOCAN(ir_node*, arity);
for (i = 0; i < arity; ++i) {
ir_node *new_in;
......
......@@ -740,7 +740,7 @@ static void mips_get_call_abi(const void *self, ir_type *method_type,
be_abi_call_set_flags(abi, call_flags, &mips_abi_callbacks);
/* collect the mode for each type */
modes = alloca(n * sizeof(modes[0]));
modes = ALLOCAN(ir_mode*, n);
for (i = 0; i < n; i++) {
tp = get_method_param_type(method_type, i);
modes[i] = get_type_mode(tp);
......
......@@ -1252,7 +1252,7 @@ static void create_abstract_call(ir_graph *irg, proc_t *proc, eff_t *eff)
VERBOSE_PRINT((stdout, "number of args expected: %d\n",
get_method_n_params(mtype)));
}
irns = alloca(num * sizeof(ir_node*));
irns = ALLOCAN(ir_node*, num);
for(i = 0; i < num; i++) {
irns[i] = find_valueid_in_proc_effects(eff -> effect.call.args[i], proc)
-> firmnode;
......
......@@ -292,7 +292,7 @@ static void create_location_data(dbg_info *dbg, block_id_walker_data_t *wd)
pmap_insert(wd->fname_map, (void *)fname, ent);
/* initialize file name string constant */
tarval_string = alloca(sizeof(*tarval_string) * (len));
tarval_string = ALLOCAN(tarval*, len);
for (i = 0; i < len; ++i) {
tarval_string[i] = new_tarval_from_long(fname[i], mode_Bs);
}
......@@ -440,7 +440,7 @@ ir_profile_instrument(const char *filename, unsigned flags)
set_array_entity_values(bblock_counts, tarval_array, n_blocks);
/* initialize function name string constant */
tarval_string = alloca(sizeof(*tarval_string) * (filename_len));
tarval_string = ALLOCAN(tarval*, filename_len);
for (i = 0; i < filename_len; ++i) {
tarval_string[i] = new_tarval_from_long(filename[i], mode_Bs);
}
......
......@@ -99,11 +99,11 @@ static void lower_sel(ir_node *sel) {
index = get_Sel_index(sel, 0);
if (is_Array_type(owner)) {
ir_node *last_size;
ir_type *arr_ty = owner;
int dims = get_array_n_dimensions(arr_ty);
int *map = alloca(sizeof(int) * dims);
int i;
int dims = get_array_n_dimensions(arr_ty);
int *map = ALLOCAN(int, dims);
ir_node *last_size;
int i;
assert(dims == get_Sel_n_indexs(sel)
&& "array dimension must match number of indices of Sel node");
......
......@@ -166,8 +166,8 @@ static ir_node *lower_node(ir_node *node)
ir_node **in;
ir_node *unknown, *new_phi;
arity = get_irn_arity(node);
in = alloca(arity * sizeof(in[0]));
arity = get_irn_arity(node);
in = ALLOCAN(ir_node*, arity);
unknown = new_Unknown(config.lowered_mode);
for(i = 0; i < arity; ++i) {
in[i] = unknown;
......
......@@ -757,9 +757,8 @@ static void split_phi_mem_edge(ir_node *irn, env_t *env) {
irn_blk = get_nodes_block(irn);
val_arr = get_irn_link(irn_blk);
n = get_Block_n_cfgpreds(irn_blk);
in = alloca(sizeof(*in) * n);
n = get_Block_n_cfgpreds(irn_blk);
in = ALLOCAN(ir_node*, n);
for(value_ent = set_first(env->set_ent); value_ent; value_ent = set_next(env->set_ent))
if(val_arr[GET_ENT_VNUM(value_ent->ent)].access_type < 3)
......
......@@ -73,8 +73,7 @@ void normalize_one_return(ir_graph *irg) {
return;
}
returns = alloca((n + 7) >> 3);
memset(returns, 0, (n + 7) >> 3);
returns = ALLOCANZ(unsigned char, (n + 7) >> 3);
for (n_rets = i = 0; i < n; ++i) {
ir_node *node = get_Block_cfgpred(endbl, i);
......@@ -93,9 +92,9 @@ void normalize_one_return(ir_graph *irg) {
if (n_rets <= 1)
return;
in = alloca(sizeof(*in) * IMAX(n_rets, n_ret_vals));
retvals = alloca(sizeof(*retvals) * n_rets * n_ret_vals);
endbl_in = alloca(sizeof(*endbl_in) * n);
in = ALLOCAN(ir_node*, IMAX(n_rets, n_ret_vals));
retvals = ALLOCAN(ir_node*, n_rets * n_ret_vals);
endbl_in = ALLOCAN(ir_node*, n);
last_idx = 0;
for (j = i = 0; i < n; ++i) {
......@@ -268,7 +267,7 @@ void normalize_n_returns(ir_graph *irg) {
*/
end = get_irg_end(irg);
n_ret_vals = get_irn_arity(list);
in = alloca(sizeof(*in) * n_ret_vals);
in = ALLOCAN(ir_node*, n_ret_vals);
while (list) {
ir_node *ret = list;
ir_node *block = get_nodes_block(ret);
......@@ -341,7 +340,7 @@ void normalize_n_returns(ir_graph *irg) {
* Last step: Create a new endblock, with all nodes on the final
* list as predecessors.
*/
in = alloca(sizeof(*in) * n_finals);
in = ALLOCAN(ir_node*, n_finals);
for (i = 0; final; ++i, final = get_irn_link(final))
in[i] = final;
......
......@@ -329,11 +329,14 @@ static void concretize_selected_entity(ir_node *sel) {
}
}
static void concretize_Phi_type(ir_node *phi) {
int i, n_preds = get_Phi_n_preds(phi);
ir_node **pred = alloca(n_preds * sizeof(ir_node *));
ir_node *nn;
ir_type *totype, *fromtype;
static void concretize_Phi_type(ir_node *phi)
{
int n_preds = get_Phi_n_preds(phi);
ir_node **pred = ALLOCAN(ir_node*, n_preds);
ir_node *nn;
ir_type *totype;
ir_type *fromtype;
int i;
if (n_preds == 0) return;
pred[0] = get_Phi_pred(phi, 0);
......
......@@ -478,8 +478,7 @@ int equal_type(ir_type *typ1, ir_type *typ2) {
if (get_class_n_supertypes(typ1) != get_class_n_supertypes(typ2)) return 0;
if (get_class_peculiarity(typ1) != get_class_peculiarity(typ2)) return 0;
/** Compare the members **/
m = alloca(sizeof(ir_entity *) * get_class_n_members(typ1));
memset(m, 0, sizeof(ir_entity *) * get_class_n_members(typ1));
m = ALLOCANZ(ir_entity*, get_class_n_members(typ1));
/* First sort the members of typ2 */
for (i = 0; i < get_class_n_members(typ1); i++) {
ir_entity *e1 = get_class_member(typ1, i);
......@@ -495,8 +494,7 @@ int equal_type(ir_type *typ1, ir_type *typ2) {
return 0;
}
/** Compare the supertypes **/
t = alloca(sizeof(ir_entity *) * get_class_n_supertypes(typ1));
memset(t, 0, sizeof(ir_entity *) * get_class_n_supertypes(typ1));
t = ALLOCANZ(ir_type*, get_class_n_supertypes(typ1));
/* First sort the supertypes of typ2 */
for (i = 0; i < get_class_n_supertypes(typ1); i++) {
ir_type *t1 = get_class_supertype(typ1, i);
......@@ -515,8 +513,7 @@ int equal_type(ir_type *typ1, ir_type *typ2) {
case tpo_struct:
if (get_struct_n_members(typ1) != get_struct_n_members(typ2)) return 0;
m = alloca(sizeof(ir_entity *) * get_struct_n_members(typ1));
memset(m, 0, sizeof(ir_entity *) * get_struct_n_members(typ1));
m = ALLOCANZ(ir_entity*, get_struct_n_members(typ1));
/* First sort the members of lt */
for (i = 0; i < get_struct_n_members(typ1); i++) {
ir_entity *e1 = get_struct_member(typ1, i);
......@@ -563,8 +560,7 @@ int equal_type(ir_type *typ1, ir_type *typ2) {
case tpo_union:
if (get_union_n_members(typ1) != get_union_n_members(typ2)) return 0;
m = alloca(sizeof(ir_entity *) * get_union_n_members(typ1));
memset(m, 0, sizeof(ir_entity *) * get_union_n_members(typ1));
m = ALLOCANZ(ir_entity*, get_union_n_members(typ1));
/* First sort the members of lt */
for (i = 0; i < get_union_n_members(typ1); i++) {
ir_entity *e1 = get_union_member(typ1, i);
......@@ -631,8 +627,7 @@ int smaller_type(ir_type *st, ir_type *lt) {
if (n_st_members != get_struct_n_members(lt))
return 0;
m = alloca(sizeof(ir_entity *) * n_st_members);
memset(m, 0, sizeof(ir_entity *) * n_st_members);
m = ALLOCANZ(ir_entity*, n_st_members);
/* First sort the members of lt */
for (i = 0; i < n_st_members; ++i) {
ir_entity *se = get_struct_member(st, i);
......@@ -682,8 +677,7 @@ int smaller_type(ir_type *st, ir_type *lt) {
case tpo_union:
n_st_members = get_union_n_members(st);
if (n_st_members != get_union_n_members(lt)) return 0;
m = alloca(sizeof(ir_entity *) * n_st_members);
memset(m, 0, sizeof(ir_entity *) * n_st_members);
m = ALLOCANZ(ir_entity*, n_st_members);
/* First sort the members of lt */
for (i = 0; i < n_st_members; ++i) {
ir_entity *se = get_union_member(st, i);
......
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