*/
#define XMALLOCFZ(type, member, n) ((type*)memset(xmalloc(offsetof(type, member) + sizeof(((type*)0)->member) * (n)), 0, offsetof(type, member) + sizeof(((type*)0)->member) * (n)))
+/**
+ * Allocate n objects of a certain type on the stack
+ */
+#define ALLOCAN(type, n) ((type*)alloca(sizeof(type) * (n)))
+
+/**
+ * Allocate n objects of a certain type on the stack and zero them
+ */
+#define ALLOCANZ(type, n) ((type*)memset((type*)alloca(sizeof(type) * (n)), 0, sizeof(type) * (n)))
+
/* Includes for alloca() */
#if defined(__FreeBSD__)
/* search the greatest result proj number */
- res_projs = alloca(n_res * sizeof(res_projs[0]));
- memset(res_projs, 0, n_res * sizeof(res_projs[0]));
+ res_projs = ALLOCANZ(ir_node*, n_res);
foreach_out_edge(irn, edge) {
const ir_edge_t *res_edge;
n_regs = env->cls->n_regs;
bs = bitset_alloca(n_regs);
- alloc_nodes = alloca(n_regs * sizeof(alloc_nodes[0]));
+ alloc_nodes = ALLOCAN(ir_node*, n_regs);
//bp = hungarian_new(n_regs, n_regs, 2, HUNGARIAN_MATCH_PERFECT);
bp = bipartite_new(n_regs, n_regs);
- assignment = alloca(n_regs * sizeof(assignment[0]));
+ assignment = ALLOCAN(int, n_regs);
partners = pmap_create();
/*
/* the backend has its own spiller */
m = arch_env_get_n_reg_class(arch_env);
- pse = alloca(m * sizeof(pse[0]));
+ pse = ALLOCAN(post_spill_env_t, m);
for (j = 0; j < m; ++j) {
memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
* safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference
*/
- safe = alloca((ou->node_count-1) * sizeof(*safe));
- safe_costs = 0;
- safe_count = 0;
- unsafe = alloca((ou->node_count-1) * sizeof(*unsafe));
- unsafe_costs = alloca((ou->node_count-1) * sizeof(*unsafe_costs));
+ safe = ALLOCAN(ir_node*, ou->node_count - 1);
+ safe_costs = 0;
+ safe_count = 0;
+ unsafe = ALLOCAN(ir_node*, ou->node_count - 1);
+ unsafe_costs = ALLOCAN(int, ou->node_count - 1);
unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) {
int is_safe = 1;
/* The node has the color it should not have _and_ has not been visited yet. */
if(!color_is_fix(env, irn)) {
int n_regs = env->co->cls->n_regs;
- col_cost_pair_t *csts = alloca(n_regs * sizeof(csts[0]));
+ col_cost_pair_t *csts = ALLOCAN(col_cost_pair_t, n_regs);
/* Get the costs for giving the node a specific color. */
determine_color_costs(env, ci, csts);
if(!color_is_fix(env, irn) && is_color_admissible(env, ci, tgt_col)) {
int n_regs = env->co->cls->n_regs;
- col_cost_pair_t *seq = alloca(n_regs * sizeof(seq[0]));
+ col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, n_regs);
/* Get the costs for giving the node a specific color. */
single_color_cost(env, ci, tgt_col, seq);
static int coalesce_top_down(co2_cloud_irn_t *ci, int child_nr, int depth)
{
co2_t *env = ci->cloud->env;
- col_cost_pair_t *seq = alloca(env->n_regs * sizeof(seq[0]));
+ col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, env->n_regs);
int is_root = ci->mst_parent == ci;
col_t parent_col = is_root ? (col_t) -1 : get_col(env, ci->mst_parent->inh.irn);
int min_badness = INT_MAX;
/**
* Determines the costs for each color if it would be assigned to node @p node.
*/
-static void determine_color_costs(co_mst_env_t *env, co_mst_irn_t *node, col_cost_t *costs) {
- int *neigh_cols = alloca(env->n_regs * sizeof(*neigh_cols));
- int n_loose = 0;
+static void determine_color_costs(co_mst_env_t *env, co_mst_irn_t *node, col_cost_t *costs)
+{
+ int *neigh_cols = ALLOCAN(int, env->n_regs);
+ int n_loose = 0;
real_t coeff;
- int i;
+ int i;
for (i = 0; i < env->n_regs; ++i) {
neigh_cols[i] = 0;
/* The node has the color it should not have _and_ has not been visited yet. */
if (is_loose(node)) {
- col_cost_t *costs = alloca(env->n_regs * sizeof(costs[0]));
+ col_cost_t *costs = ALLOCAN(col_cost_t, env->n_regs);
/* Get the costs for giving the node a specific color. */
determine_color_costs(env, node, costs);
int n_int_chunks = 0;
waitq *tmp_chunks = new_waitq();
waitq *best_starts = NULL;
- col_cost_t *order = alloca(env->n_regs * sizeof(order[0]));
+ col_cost_t *order = ALLOCANZ(col_cost_t, env->n_regs);
bitset_t *visited;
int idx, len, i, nidx, pos;
struct list_head changed;
++env->chunk_visited;
/* compute color preference */
- memset(order, 0, env->n_regs * sizeof(order[0]));
-
for (pos = 0, len = ARR_LEN(c->interfere); pos < len; ++pos) {
const ir_node *n = c->interfere[pos];
co_mst_irn_t *node = get_co_mst_irn(env, n);
/**
* Checks if a node is simplicial in the graph heeding the already removed nodes.
*/
-static inline int sr_is_simplicial(size_red_t *sr, const ir_node *ifn) {
- int i, o, size = 0;
- ir_node **all, *curr;
- be_ifg_t *ifg = sr->co->cenv->ifg;
- void *iter = be_ifg_neighbours_iter_alloca(ifg);
-
- all = alloca(be_ifg_degree(ifg, ifn) * sizeof(*all));
+static inline int sr_is_simplicial(size_red_t *sr, const ir_node *ifn)
+{
+ be_ifg_t *ifg = sr->co->cenv->ifg;
+ void *iter = be_ifg_neighbours_iter_alloca(ifg);
+ ir_node **all = ALLOCAN(ir_node*, be_ifg_degree(ifg, ifn));
+ ir_node *curr;
+ int size = 0;
+ int i;
+ int o;
/* get all non-removed neighbors */
be_ifg_foreach_neighbour(ifg, iter, ifn, curr)
}
}
-static void build_interference_cstr(ilp_env_t *ienv) {
- lpp_t *lpp = ienv->lp;
- local_env_t *lenv = ienv->env;
- be_ifg_t *ifg = ienv->co->cenv->ifg;
- int n_colors = lenv->n_colors;
- int i, col;
-
- void *iter = be_ifg_cliques_iter_alloca(ifg);
- ir_node **clique = alloca(sizeof(*clique) * n_colors);
- int size;
+static void build_interference_cstr(ilp_env_t *ienv)
+{
+ lpp_t *lpp = ienv->lp;
+ local_env_t *lenv = ienv->env;
+ be_ifg_t *ifg = ienv->co->cenv->ifg;
+ int n_colors = lenv->n_colors;
+ void *iter = be_ifg_cliques_iter_alloca(ifg);
+ ir_node **clique = ALLOCAN(ir_node*, n_colors);
+ int size;
+ int col;
+ int i;
char buf[16];
/* check for forbidden interferences */
- len = pdeq_len(path);
- curr_path = alloca(len * sizeof(*curr_path));
+ len = pdeq_len(path);
+ curr_path = ALLOCAN(ir_node*, len);
pdeq_copyl(path, (const void **)curr_path);
for (i=1; i<len; ++i)
* safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference
*/
- safe = alloca((ou->node_count-1) * sizeof(*safe));
- safe_costs = 0;
- safe_count = 0;
- unsafe = alloca((ou->node_count-1) * sizeof(*unsafe));
- unsafe_costs = alloca((ou->node_count-1) * sizeof(*unsafe_costs));
+ safe = ALLOCAN(ir_node*, ou->node_count - 1);
+ safe_costs = 0;
+ safe_count = 0;
+ unsafe = ALLOCAN(ir_node*, ou->node_count - 1);
+ unsafe_costs = ALLOCAN(int, ou->node_count - 1);
unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) {
int is_safe = 1;
/* get the number of ous, remove them form the list and fill the array */
list_for_each_entry(unit_t, ou, &co->units, units)
count++;
- ous = alloca(count * sizeof(*ous));
+ ous = ALLOCAN(unit_t, count);
costs = co_get_max_copy_costs(co);
void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
{
- be_ifg_t *ifg = co->cenv->ifg;
- int *color_map = alloca(co->cls->n_regs * sizeof(color_map[0]));
- int *node_map = XMALLOCN(int, get_irg_last_idx(co->irg) + 1);
+ be_ifg_t *ifg = co->cenv->ifg;
+ int *color_map = ALLOCAN(int, co->cls->n_regs);
+ int *node_map = XMALLOCN(int, get_irg_last_idx(co->irg) + 1);
ir_node *irn;
void *it, *nit;
ir_graph *const irg = get_irn_irg(irn);
ir_node *const block = get_nodes_block(irn);
int const arity = get_irn_arity(irn);
- reg_pair_t *const pairs = alloca(arity * sizeof(pairs[0]));
+ reg_pair_t *const pairs = ALLOCAN(reg_pair_t, arity);
int keep_perm = 0;
int do_copy = env->do_copy;
/* Get the schedule predecessor node to the perm.
void assure_constraints(be_irg_t *birg) {
ir_graph *irg = be_get_birg_irg(birg);
constraint_env_t cenv;
- ir_node **nodes;
ir_nodemap_iterator_t map_iter;
ir_nodemap_entry_t map_entry;
/* for all */
foreach_ir_nodemap(&cenv.op_set, map_entry, map_iter) {
- op_copy_assoc_t *entry = map_entry.data;
- int n;
- ir_node *cp;
- ir_nodeset_iterator_t iter;
+ op_copy_assoc_t *entry = map_entry.data;
+ int n = ir_nodeset_size(&entry->copies);
+ ir_node **nodes = ALLOCAN(ir_node*, n);
+ ir_node *cp;
+ ir_nodeset_iterator_t iter;
be_ssa_construction_env_t senv;
- n = ir_nodeset_size(&entry->copies);
- nodes = alloca(n * sizeof(nodes[0]));
-
/* put the node in an array */
DBG((dbg_constr, LEVEL_1, "introduce copies for %+F ", map_entry.node));
return 0;
}
- map = alloca(new_size * sizeof(map[0]));
- proj_map = alloca(arity * sizeof(proj_map[0]));
+ map = ALLOCAN(int, new_size);
+ proj_map = ALLOCAN(int, arity);
memset(proj_map, -1, sizeof(proj_map[0]));
n = 0;
for (i = 0; i < arity; ++i) {
/* we might need 1 birg more for instrumentation constructor */
num_birgs = backend_irg_list ? ARR_LEN(backend_irg_list) : get_irp_n_irgs();
- birgs = alloca(sizeof(birgs[0]) * (num_birgs + 1));
+ birgs = ALLOCAN(be_irg_t, num_birgs + 1);
/* First: initialize all birgs */
for(i = 0; i < num_birgs; ++i) {
if (be_options.statev) {
const char *dot = strrchr(cup_name, '.');
const char *pos = dot ? dot : cup_name + strlen(cup_name);
- char *buf = alloca(pos - cup_name + 1);
+ char *buf = ALLOCAN(char, pos - cup_name + 1);
strncpy(buf, cup_name, pos - cup_name);
buf[pos - cup_name] = '\0';
void be_Perm_reduce(ir_node *perm, int new_size, int *map)
{
int arity = get_irn_arity(perm);
- be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0]));
+ be_reg_data_t *old_data = ALLOCAN(be_reg_data_t, arity);
be_node_attr_t *attr = get_irn_attr(perm);
ir_node **new_in;
ir_node **real_in;
int i;
- real_in = alloca((n+1) * sizeof(real_in[0]));
+ real_in = ALLOCAN(ir_node*, n + 1);
real_in[0] = frame;
memcpy(&real_in[1], in, n * sizeof(real_in[0]));
ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode)
{
- ir_node *irn;
- ir_node **in = (ir_node **) alloca((n + 1) * sizeof(in[0]));
+ ir_node *irn;
+ ir_node **in = ALLOCAN(ir_node*, n + 1);
in[0] = src;
memcpy(&in[1], in_keep, n * sizeof(in[0]));
lv = be_get_birg_liveness(birg);
n_classes = arch_env_get_n_reg_class(arch_env);
- register_values = alloca(sizeof(register_values[0]) * n_classes);
+ register_values = ALLOCAN(ir_node**, n_classes);
for(i = 0; i < n_classes; ++i) {
const arch_register_class_t *cls = arch_env_get_reg_class(arch_env, i);
unsigned n_regs = arch_register_class_n_regs(cls);
- register_values[i] = alloca(sizeof(ir_node*) * n_regs);
+ register_values[i] = ALLOCAN(ir_node*, n_regs);
}
irg_block_walk_graph(irg, process_block, NULL, NULL);
static void update_dvg(rss_t *rss, dvg_t *dvg, rss_irn_t *src, rss_irn_t *tgt) {
int i, j, idx;
rss_edge_t *edge;
- rss_edge_t **arr = alloca(pset_count(dvg->edges) * sizeof(arr[0]));
+ rss_edge_t **arr = ALLOCAN(rss_edge_t*, pset_count(dvg->edges));
/*
Add an edge from serialization target to serialization src:
*/
static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int iteration) {
int n = ir_nodeset_size(&dvg->nodes);
- int *assignment = alloca(n * sizeof(assignment[0]));
- int *assignment_rev = alloca(n * sizeof(assignment_rev[0]));
- int *idx_map = alloca(n * sizeof(idx_map[0]));
+ int *assignment = ALLOCAN(int, n);
+ int *assignment_rev = ALLOCAN(int, n);
+ int *idx_map = ALLOCAN(int, n);
hungarian_problem_t *bp;
ir_nodeset_t *values, *temp;
ir_nodeset_iterator_t iter;
int n = ir_nodeset_size(sat_vals);
int n_idx = ARR_LEN_SAFE(rss->idx_map);
int i = 0;
- ir_node **val_arr = alloca(n * sizeof(val_arr[0]));
+ ir_node **val_arr = ALLOCAN(ir_node*, n);
bitset_t *bs_sv = bitset_alloca(n_idx);
bitset_t *bs_vdesc = bitset_alloca(n_idx);
bitset_t *bs_tmp = bitset_alloca(n_idx);
/* build a new PhiM */
arity = get_irn_arity(phi);
- ins = alloca(sizeof(ir_node*) * arity);
+ ins = ALLOCAN(ir_node*, arity);
unknown = new_r_Unknown(irg, mode_M);
for(i = 0; i < arity; ++i) {
ins[i] = unknown;
bl = get_nodes_block(reloader);
}
- ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
+ ins = ALLOCAN(ir_node*, get_irn_arity(spilled));
for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
ir_node *arg = get_irn_n(spilled, i);
*/
static void displace(workset_t *new_vals, int is_usage)
{
- ir_node **to_insert = alloca(n_regs * sizeof(to_insert[0]));
- bool *spilled = alloca(n_regs * sizeof(spilled[0]));
+ ir_node **to_insert = ALLOCAN(ir_node*, n_regs);
+ bool *spilled = ALLOCAN(bool, n_regs);
ir_node *val;
int i;
int len;
/* check predecessors */
arity = get_irn_arity(block);
- pred_worksets = alloca(sizeof(pred_worksets[0]) * arity);
+ pred_worksets = ALLOCAN(workset_t*, arity);
all_preds_known = true;
for(i = 0; i < arity; ++i) {
ir_node *pred_block = get_Block_cfgpred_block(block, i);
static void displace(block_info_t *bi, workset_t *new_vals, int is_usage) {
belady_env_t *env = bi->bel;
workset_t *ws = env->ws;
- ir_node **to_insert = alloca(env->n_regs * sizeof(to_insert[0]));
+ ir_node **to_insert = ALLOCAN(ir_node*, env->n_regs);
int i, len, max_allowed, demand, iter;
ir_node *val;
return;
DBG((dbg, LEVEL_2, "\tspills needed after %+F: %d\n", node, spills_needed));
- candidates = alloca(n_live_nodes * sizeof(candidates[0]));
+ candidates = ALLOCAN(spill_candidate_t, n_live_nodes);
/* construct array with spill candidates and calculate their costs */
i = 0;
DB((dbg, DBG_COALESCING, "Coalescing %d spillslots\n", spillcount));
- interferences = alloca(spillcount * sizeof(interferences[0]));
- spillslot_unionfind = alloca(spillcount * sizeof(spillslot_unionfind[0]));
- spilllist = alloca(spillcount * sizeof(spilllist[0]));
+ interferences = ALLOCAN(bitset_t*, spillcount);
+ spillslot_unionfind = ALLOCAN(int, spillcount);
+ spilllist = ALLOCAN(spill_t*, spillcount);
uf_init(spillslot_unionfind, 0, spillcount);
*/
static void assign_spillslots(be_fec_env_t *env)
{
- int i;
- int spillcount;
- spill_t *spill;
- spill_slot_t* spillslots;
-
- spillcount = set_count(env->spills);
- spillslots = alloca(spillcount * sizeof(spillslots[0]));
-
- memset(spillslots, 0, spillcount * sizeof(spillslots[0]));
+ int spillcount = set_count(env->spills);
+ spill_slot_t *spillslots = ALLOCANZ(spill_slot_t, spillcount);
+ spill_t *spill;
+ int i;
/* construct spillslots */
for(spill = set_first(env->spills); spill != NULL;
memperm_t *memperm;
for(memperm = set_first(env->memperms); memperm != NULL; memperm = set_next(env->memperms)) {
- int i;
- memperm_entry_t *entry;
- ir_node *blockend;
- ir_node** nodes = alloca(memperm->entrycount * sizeof(nodes[0]));
- ir_node* mempermnode;
+ ir_node **nodes = ALLOCAN(ir_node*, memperm->entrycount);
+ memperm_entry_t *entry;
+ ir_node *blockend;
+ ir_node *mempermnode;
+ int i;
assert(memperm->entrycount > 0);
{
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);
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);
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);
}
}
-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;
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);
* 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) {
}
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;
/* 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;
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);
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;
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);
}
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);
}
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");
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;
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)
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);
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) {
*/
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);
* 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;
}
}
-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);
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);
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);
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);
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);
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);
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);