Commit e07b61c6 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Good day and welcome to the FIRM XMALLOC*() macros. These macros are provided...

Good day and welcome to the FIRM XMALLOC*() macros.  These macros are provided for the type safety and convenience of the IPD research facility personnel.  The time is 15:32.  Check xmalloc.h for details.

[r22494]
parent 325f4d96
......@@ -217,7 +217,7 @@ pset *get_all_phi_classes(phi_classes_t *pc) {
* @return The Phi class object for the @p irg.
*/
phi_classes_t *phi_class_new_from_irg(ir_graph *irg, int pure_phi_classes) {
phi_classes_t *res = xmalloc(sizeof(*res));
phi_classes_t *res = XMALLOC(phi_classes_t);
FIRM_DBG_REGISTER(res->dbg, "ir.ana.phiclass");
phase_init(&res->ph, "phi_classes", irg, PHASE_DEFAULT_GROWTH, irn_phi_class_init, NULL);
......@@ -236,7 +236,7 @@ phi_classes_t *phi_class_new_from_irg(ir_graph *irg, int pure_phi_classes) {
* @return The Phis class object for @p all_phis.
*/
phi_classes_t *phi_class_new_from_set(ir_graph *irg, ir_nodeset_t *all_phis, int pure_phi_classes) {
phi_classes_t *res = xmalloc(sizeof(*res));
phi_classes_t *res = XMALLOC(phi_classes_t);
FIRM_DBG_REGISTER(res->dbg, "ir.ana.phiclass");
phase_init(&res->ph, "phi_classes", irg, PHASE_DEFAULT_GROWTH, irn_phi_class_init, NULL);
......
......@@ -482,7 +482,7 @@ void rta_delete_dead_graphs (void)
int rem_vpi = get_visit_pseudo_irgs();
set_visit_pseudo_irgs(1);
dead_graphs = xmalloc(sizeof(*dead_graphs) * get_irp_n_irgs());
dead_graphs = XMALLOCN(ir_graph*, get_irp_n_irgs());
for (i = 0; i < n_graphs; i++) {
graph = get_irp_irg(i);
......
......@@ -1002,7 +1002,7 @@ static void reduce(walk_env *env, ir_region *reg) {
ir_reg_tree *construct_region_tree(ir_graph *irg) {
walk_env env;
ir_graph *rem = current_ir_graph;
ir_reg_tree *res = xmalloc(sizeof(*res));
ir_reg_tree *res = XMALLOC(ir_reg_tree);
obstack_init(&res->obst);
......
......@@ -326,7 +326,7 @@ static const arch_code_generator_if_t TEMPLATE_code_gen_if = {
static void *TEMPLATE_cg_init(be_irg_t *birg) {
const arch_env_t *arch_env = be_get_birg_arch_env(birg);
TEMPLATE_isa_t *isa = (TEMPLATE_isa_t *) arch_env;
TEMPLATE_code_gen_t *cg = xmalloc(sizeof(*cg));
TEMPLATE_code_gen_t *cg = XMALLOC(TEMPLATE_code_gen_t);
cg->impl = &TEMPLATE_code_gen_if;
cg->irg = be_get_birg_irg(birg);
......@@ -377,7 +377,7 @@ static arch_env_t *TEMPLATE_init(FILE *outfile) {
return NULL;
run_once = 1;
isa = xcalloc(1, sizeof(*isa));
isa = XMALLOC(TEMPLATE_isa_t);
memcpy(isa, &TEMPLATE_isa_template, sizeof(*isa));
be_emit_init(outfile);
......@@ -447,7 +447,7 @@ typedef struct {
static void *TEMPLATE_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
{
TEMPLATE_abi_env_t *env = xmalloc(sizeof(env[0]));
TEMPLATE_abi_env_t *env = XMALLOC(TEMPLATE_abi_env_t);
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
env->flags = fl.bits;
env->irg = irg;
......
......@@ -703,7 +703,7 @@ static void emit_arm_SwitchJmp(const ir_node *irn) {
block_nr = get_irn_node_nr(irn);
n_projs = get_arm_SwitchJmp_n_projs(irn);
projs = xcalloc(n_projs , sizeof(ir_node*));
projs = XMALLOCNZ(ir_node*, n_projs);
foreach_out_edge(irn, edge) {
proj = get_edge_src_irn(edge);
......
......@@ -581,7 +581,7 @@ static void *arm_cg_init(be_irg_t *birg) {
int_tp = new_type_primitive(new_id_from_chars("int", 3), mode_Is);
}
cg = xmalloc(sizeof(*cg));
cg = XMALLOC(arm_code_gen_t);
cg->impl = &arm_code_gen_if;
cg->irg = birg->irg;
cg->reg_set = new_set(arm_cmp_irn_reg_assoc, 1024);
......@@ -767,7 +767,7 @@ static arch_env_t *arm_init(FILE *file_handle) {
if (inited)
return NULL;
isa = xmalloc(sizeof(*isa));
isa = XMALLOC(arm_isa_t);
memcpy(isa, &arm_isa_template, sizeof(*isa));
arm_register_init();
......@@ -879,8 +879,8 @@ typedef struct {
static void *arm_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
{
arm_abi_env_t *env = xmalloc(sizeof(env[0]));
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
arm_abi_env_t *env = XMALLOC(arm_abi_env_t);
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
env->flags = fl.bits;
env->irg = irg;
env->arch_env = arch_env;
......
......@@ -235,8 +235,7 @@ be_abi_call_flags_t be_abi_call_get_flags(const be_abi_call_t *call)
*/
static be_abi_call_t *be_abi_call_new(const arch_register_class_t *cls_addr)
{
be_abi_call_t *call = xmalloc(sizeof(call[0]));
memset(call, 0, sizeof(call[0]));
be_abi_call_t *call = XMALLOCZ(be_abi_call_t);
call->flags.val = 0;
call->params = new_set(cmp_call_arg, 16);
......@@ -2163,7 +2162,7 @@ static void fix_pic_symconsts(ir_node *node, void *data)
be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
{
be_abi_irg_t *env = xmalloc(sizeof(env[0]));
be_abi_irg_t *env = XMALLOC(be_abi_irg_t);
ir_node *old_frame = get_irg_frame(birg->irg);
ir_graph *irg = birg->irg;
......
......@@ -33,7 +33,6 @@
#include "benode_t.h"
#include "ircons_t.h"
#include "irnode_t.h"
#include "xmalloc.h"
#include "bitset.h"
#include "pset.h"
......
......@@ -48,7 +48,6 @@
#include "irtools.h"
#include "irbitset.h"
#include "debug.h"
#include "xmalloc.h"
#include "iredges.h"
#include "beutil.h"
......
......@@ -163,7 +163,7 @@ const plotter_if_t ps_plotter_vtab = {
plotter_t *new_plotter_ps(const char *filename)
{
ps_plotter_t *ps_plotter = xmalloc(sizeof(*ps_plotter));
ps_plotter_t *ps_plotter = XMALLOC(ps_plotter_t);
plotter_t *p = (plotter_t *) ps_plotter;
ps_plotter->filename = filename;
......
......@@ -54,7 +54,6 @@
#include "irnode.h"
#include "ircons.h"
#include "debug.h"
#include "xmalloc.h"
#include "execfreq.h"
#include "iredges_t.h"
......
......@@ -480,11 +480,11 @@ no_stable_set:
* Creates a new qnode
*/
static INLINE qnode_t *new_qnode(const unit_t *ou, int color) {
qnode_t *qn = xmalloc(sizeof(*qn));
qn->ou = ou;
qn->color = color;
qn->mis = xmalloc(ou->node_count * sizeof(*qn->mis));
qn->conflicts = new_set(set_cmp_conflict_t, SLOTS_CONFLICTS);
qnode_t *qn = XMALLOC(qnode_t);
qn->ou = ou;
qn->color = color;
qn->mis = XMALLOCN(ir_node*, ou->node_count);
qn->conflicts = new_set(set_cmp_conflict_t, SLOTS_CONFLICTS);
qn->changed_nodes = new_set(set_cmp_node_stat_t, SLOTS_CHANGED_NODES);
return qn;
}
......
......@@ -892,15 +892,13 @@ static void process_cloud(co2_cloud_t *cloud)
co2_t *env = cloud->env;
int n_regs = env->n_regs;
int n_edges = 0;
int *mst_edges = xmalloc(cloud->n_memb * cloud->n_memb * sizeof(mst_edges[0]));
int *mst_edges = XMALLOCNZ(int, cloud->n_memb * cloud->n_memb);
pdeq *q;
edge_t *edges;
int i;
int best_col;
memset(mst_edges, 0, cloud->n_memb * cloud->n_memb * sizeof(mst_edges[0]));
/* Collect all edges in the cloud on an obstack and sort the increasingly */
obstack_init(&cloud->obst);
for(i = 0; i < cloud->n_memb; ++i) {
......@@ -1063,7 +1061,7 @@ static void process(co2_t *env)
}
i = 0;
clouds = xmalloc(n_clouds * sizeof(clouds[0]));
clouds = XMALLOCN(co2_cloud_t*, n_clouds);
list_for_each_entry(co2_cloud_t, pos, &env->cloud_head, list)
clouds[i++] = pos;
qsort(clouds, n_clouds, sizeof(clouds[0]), cmp_clouds_gt);
......
......@@ -150,8 +150,8 @@ int co_solve_heuristic_java(copy_opt_t *co)
}
}
node_map = xmalloc((get_irg_last_idx(co->irg) + 1) * sizeof(node_map[0]));
inv_node_map = xmalloc((get_irg_last_idx(co->irg) + 1) * sizeof(inv_node_map[0]));
node_map = XMALLOC(int, get_irg_last_idx(co->irg) + 1);
inv_node_map = XMALLOC(int, get_irg_last_idx(co->irg) + 1);
curr_idx = 0;
be_ifg_foreach_node(ifg, nodes_it, n) {
......
......@@ -256,7 +256,7 @@ static int cmp_col_cost_gt(const void *a, const void *b) {
* Creates a new affinity chunk
*/
static INLINE aff_chunk_t *new_aff_chunk(co_mst_env_t *env) {
aff_chunk_t *c = xmalloc(sizeof(*c) + (env->n_regs - 1) * sizeof(c->color_affinity[0]));
aff_chunk_t *c = XMALLOCF(aff_chunk_t, color_affinity, env->n_regs);
c->n = NEW_ARR_F(const ir_node *, 0);
c->interfere = NEW_ARR_F(const ir_node *, 0);
c->weight = -1;
......
......@@ -95,7 +95,7 @@ BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyilp);
size_red_t *new_size_red(copy_opt_t *co) {
size_red_t *res = xmalloc(sizeof(*res));
size_red_t *res = XMALLOC(size_red_t);
res->co = co;
res->all_removed = pset_new_ptr_default();
......@@ -208,8 +208,7 @@ void free_size_red(size_red_t *sr) {
#include <stdio.h>
ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env) {
ilp_env_t *res = xmalloc(sizeof(*res));
assert(res);
ilp_env_t *res = XMALLOC(ilp_env_t);
res->co = co;
res->build = build;
......
......@@ -500,16 +500,14 @@ static void ilp2_build(ilp_env_t *ienv) {
static void ilp2_apply(ilp_env_t *ienv) {
local_env_t *lenv = ienv->env;
double *sol;
lpp_sol_state_t state;
int i, count;
int i;
/* first check if there was sth. to optimize */
if (lenv->first_x_var >= 0) {
int count = lenv->last_x_var - lenv->first_x_var + 1;
double *sol = XMALLOCN(double, count);
lpp_sol_state_t state = lpp_get_solution(ienv->lp, sol, lenv->first_x_var, lenv->last_x_var);
count = lenv->last_x_var - lenv->first_x_var + 1;
sol = xmalloc(count * sizeof(sol[0]));
state = lpp_get_solution(ienv->lp, sol, lenv->first_x_var, lenv->last_x_var);
if (state != lpp_optimal) {
printf("WARNING %s: Solution state is not 'optimal': %d\n", ienv->co->name, state);
assert(state >= lpp_feasible && "The solution should at least be feasible!");
......
......@@ -195,7 +195,7 @@ copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs)
FIRM_DBG_REGISTER(dbg, "ir.be.copyopt");
co = xcalloc(1, sizeof(*co));
co = XMALLOCZ(copy_opt_t);
co->cenv = chordal_env;
co->aenv = chordal_env->birg->main_env->arch_env;
co->irg = chordal_env->irg;
......@@ -206,7 +206,7 @@ copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs)
s2 = get_entity_name(get_irg_entity(co->irg));
s3 = chordal_env->cls->name;
len = strlen(s1) + strlen(s2) + strlen(s3) + 5;
co->name = xmalloc(len);
co->name = XMALLOCN(char, len);
snprintf(co->name, len, "%s__%s__%s", s1, s2, s3);
return co;
......@@ -385,7 +385,7 @@ static void co_collect_units(ir_node *irn, void *env) {
return;
/* Init a new unit */
unit = xcalloc(1, sizeof(*unit));
unit = XMALLOCZ(unit_t);
unit->co = co;
unit->node_count = 1;
INIT_LIST_HEAD(&unit->queue);
......@@ -396,8 +396,8 @@ static void co_collect_units(ir_node *irn, void *env) {
/* init */
arity = get_irn_arity(irn);
unit->nodes = xmalloc((arity+1) * sizeof(*unit->nodes));
unit->costs = xmalloc((arity+1) * sizeof(*unit->costs));
unit->nodes = XMALLOCN(ir_node*, arity + 1);
unit->costs = XMALLOCN(int, arity + 1);
unit->nodes[0] = irn;
/* fill */
......@@ -437,13 +437,13 @@ static void co_collect_units(ir_node *irn, void *env) {
}
}
}
unit->nodes = xrealloc(unit->nodes, unit->node_count * sizeof(*unit->nodes));
unit->costs = xrealloc(unit->costs, unit->node_count * sizeof(*unit->costs));
unit->nodes = XREALLOC(unit->nodes, ir_node*, unit->node_count);
unit->costs = XREALLOC(unit->costs, int, unit->node_count);
} else if (is_Perm_Proj(co->aenv, irn)) {
/* Proj of a perm with corresponding arg */
assert(!nodes_interfere(co->cenv, irn, get_Perm_src(irn)));
unit->nodes = xmalloc(2 * sizeof(*unit->nodes));
unit->costs = xmalloc(2 * sizeof(*unit->costs));
unit->nodes = XMALLOCN(ir_node*, 2);
unit->costs = XMALLOCN(int, 2);
unit->node_count = 2;
unit->nodes[0] = irn;
unit->nodes[1] = get_Perm_src(irn);
......@@ -471,8 +471,8 @@ static void co_collect_units(ir_node *irn, void *env) {
if (count != 0) {
int k = 0;
++count;
unit->nodes = xmalloc(count * sizeof(*unit->nodes));
unit->costs = xmalloc(count * sizeof(*unit->costs));
unit->nodes = XMALLOCN(ir_node*, count);
unit->costs = XMALLOCN(int, count);
unit->node_count = count;
unit->nodes[k++] = irn;
......@@ -864,7 +864,7 @@ 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 = xmalloc((get_irg_last_idx(co->irg) + 1) * sizeof(node_map[0]));
int *node_map = XMALLOCN(int, get_irg_last_idx(co->irg) + 1);
ir_node *irn;
void *it, *nit;
......@@ -1141,7 +1141,7 @@ static FILE *my_open(const be_chordal_env_t *env, const char *prefix, const char
char *tu_name;
n = strlen(env->birg->main_env->cup_name);
tu_name = xmalloc((n + 1) * sizeof(*tu_name));
tu_name = XMALLOCN(char, n + 1);
strcpy(tu_name, env->birg->main_env->cup_name);
for (i = 0; i < n; ++i)
if (tu_name[i] == '.')
......
......@@ -31,7 +31,6 @@
#include <string.h>
#include "timing.h"
#include "xmalloc.h"
#include "irgraph.h"
#include "irgwalk.h"
#include "irprog.h"
......
......@@ -115,7 +115,7 @@ ir_node **compute_df(ir_node *blk, be_dom_front_info_t *info)
be_dom_front_info_t *be_compute_dominance_frontiers(ir_graph *irg)
{
be_dom_front_info_t *info = xmalloc(sizeof(*info));
be_dom_front_info_t *info = XMALLOC(be_dom_front_info_t);
edges_assure(irg);
obstack_init(&info->obst);
......
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