Commit dbd7da6a authored by Matthias Braun's avatar Matthias Braun
Browse files

rename mangling stuff to avoid name clashes

[r23665]
parent 14083b56
......@@ -184,21 +184,21 @@ void firm_init_mangle (void);
/** Computes a definite name for this entity by concatenating
the name of the owner type and the name of the entity with
a separating "_". */
ident *mangle_entity (ir_entity *ent);
ident *id_mangle_entity (ir_entity *ent);
/** mangle underscore: Returns a new ident that represents first_scnd. */
ident *mangle_u (ident *first, ident* scnd);
ident *id_mangle_u (ident *first, ident* scnd);
/** mangle dot: Returns a new ident that represents first.scnd. */
ident *mangle_dot (ident *first, ident* scnd);
ident *id_mangle_dot (ident *first, ident* scnd);
/** mangle: Returns a new ident that represents firstscnd. */
ident *mangle (ident *first, ident* scnd);
ident *id_mangle (ident *first, ident* scnd);
/** Returns a new ident that represents 'prefixscndsuffix'. */
ident *mangle3 (const char *prefix, ident *middle, const char *suffix);
ident *id_mangle3 (const char *prefix, ident *middle, const char *suffix);
/** returns a mangled name for a Win32 function using it's calling convention */
ident *decorate_win32_c_fkt(ir_entity *ent, ident *id);
ident *id_decorate_win32_c_fkt(ir_entity *ent, ident *id);
#endif
......@@ -60,38 +60,12 @@ static eset *_live_graphs = NULL;
*/
static ir_graph *get_implementing_graph (ir_entity *method)
{
#if 0
ir_graph *graph = get_entity_irg ((ir_entity*) method);
/* Search upwards in the overwrites graph. */
/* GL: this will not work for multiple inheritance */
if (NULL == graph) {
int i;
int n_over = get_entity_n_overwrites ((ir_entity*) method);
for (i = 0; (NULL == graph) && (i < n_over); i ++) {
ir_entity *over = get_entity_overwrites ((ir_entity*) method, i);
graph = get_implementing_graph (over);
}
}
/* GL this is not valid in our remove irg algorithm ... which we removed by now ... */
assert(get_entity_peculiarity(method) == peculiarity_description
|| graph == get_entity_irg(get_SymConst_entity(get_atomic_ent_value(method))));
/* we *must* always return a graph != NULL, *except* when we're used
inside remove_irg or force_description */
/* assert (graph && "no graph"); */
return (graph);
#else
ir_graph *graph = NULL;
if (get_entity_peculiarity(method) != peculiarity_description)
graph = get_entity_irg(get_SymConst_entity(get_atomic_ent_value(method)));
return graph;
#endif
}
/**
......@@ -329,36 +303,6 @@ static int stats (void)
abstract now. Pretend that it wasn't there at all, and every
entity that used to inherit this entity's graph is now abstract.
*/
/* Since we *know* that this entity will not be called, this is OK. */
static void force_description (ir_entity *ent, ir_entity *addr)
{
int i, n_over = get_entity_n_overwrittenby (ent);
set_entity_peculiarity (ent, peculiarity_description);
for (i = 0; i < n_over; i ++) {
ir_entity *over = get_entity_overwrittenby (ent, i);
if (peculiarity_inherited == get_entity_peculiarity (over)) {
/* We rely on the fact that cse is performed on the const_code_irg. */
ir_entity *my_addr = get_SymConst_entity(get_atomic_ent_value(over));
if (addr == my_addr) {
force_description (over, addr);
}
} else if (peculiarity_existent == get_entity_peculiarity (over)) {
/* check whether 'over' forces 'inheritance' of *our* graph: */
ir_node *f_addr = get_atomic_ent_value (over);
ir_entity *impl_ent = get_SymConst_entity (f_addr);
assert(is_SymConst(f_addr) && "can't do complex addrs");
if (impl_ent == addr) {
assert (0 && "gibt's denn sowas");
force_description (over, addr);
}
}
}
}
/**
Initialize the static data structures.
......
......@@ -1220,7 +1220,7 @@ static ir_type *compute_arg_type(be_abi_irg_t *env, be_abi_call_t *call, ir_type
ir_entity **map;
*param_map = map = obstack_alloc(&env->obst, n * sizeof(ir_entity *));
res = new_type_struct(mangle_u(id, new_id_from_chars("arg_type", 8)));
res = new_type_struct(id_mangle_u(id, new_id_from_chars("arg_type", 8)));
for (i = 0; i < n; ++i, curr += inc) {
ir_type *param_type = get_method_param_type(method_type, curr);
be_abi_call_arg_t *arg = get_call_arg(call, 0, curr);
......@@ -1972,7 +1972,7 @@ static ir_entity *create_trampoline(be_main_env_t *be, ir_entity *method)
{
ir_type *type = get_entity_type(method);
ident *old_id = get_entity_ld_ident(method);
ident *id = mangle3("L", old_id, "$stub");
ident *id = id_mangle3("L", old_id, "$stub");
ir_type *parent = be->pic_trampolines_type;
ir_entity *ent = new_entity(parent, old_id, type);
set_entity_ld_ident(ent, id);
......@@ -1999,7 +1999,7 @@ static ir_entity *get_trampoline(be_main_env_t *env, ir_entity *method)
static ir_entity *create_pic_symbol(be_main_env_t *be, ir_entity *entity)
{
ident *old_id = get_entity_ld_ident(entity);
ident *id = mangle3("L", old_id, "$non_lazy_ptr");
ident *id = id_mangle3("L", old_id, "$non_lazy_ptr");
ir_type *e_type = get_entity_type(entity);
ir_type *type = new_type_pointer(id, e_type, mode_P_data);
ir_type *parent = be->pic_symbols_type;
......
......@@ -781,7 +781,7 @@ ir_entity *ia32_create_intrinsic_fkt(ir_type *method, const ir_op *op,
if (ent && ! *ent) {
#define IDENT(s) new_id_from_chars(s, sizeof(s)-1)
ident *id = mangle(IDENT("L"), get_op_ident(op));
ident *id = id_mangle(IDENT("L"), get_op_ident(op));
*ent = new_entity(get_glob_type(), id, method);
}
......
......@@ -44,7 +44,7 @@ static inline ident *mangle_type(ir_type *tp) {
return tp->name;
}
ident *mangle_entity(ir_entity *ent) {
ident *id_mangle_entity(ir_entity *ent) {
ident *type_id;
char *cp;
int len;
......@@ -63,7 +63,7 @@ ident *mangle_entity(ir_entity *ent) {
/* Returns a new ident that represents 'firstscnd'. */
ident *mangle(ident *first, ident *scnd) {
ident *id_mangle(ident *first, ident *scnd) {
char *cp;
int len;
ident *res;
......@@ -78,7 +78,7 @@ ident *mangle(ident *first, ident *scnd) {
}
/** Returns a new ident that represents 'prefixscndsuffix'. */
ident *mangle3(const char *prefix, ident *scnd, const char *suffix) {
ident *id_mangle3(const char *prefix, ident *scnd, const char *suffix) {
char *cp;
int len;
ident *res;
......@@ -94,7 +94,7 @@ ident *mangle3(const char *prefix, ident *scnd, const char *suffix) {
}
/** Returns a new ident that represents first<c>scnd. */
static ident *mangle_3(ident *first, char c, ident* scnd) {
static ident *id_mangle_3(ident *first, char c, ident* scnd) {
char *cp;
int len;
ident *res;
......@@ -110,24 +110,24 @@ static ident *mangle_3(ident *first, char c, ident* scnd) {
}
/* Returns a new ident that represents first_scnd. */
ident *mangle_u(ident *first, ident* scnd) {
return mangle_3(first, '_', scnd);
ident *id_mangle_u(ident *first, ident* scnd) {
return id_mangle_3(first, '_', scnd);
}
/* Returns a new ident that represents first.scnd. */
ident *mangle_dot(ident *first, ident* scnd) {
return mangle_3(first, '.', scnd);
ident *id_mangle_dot(ident *first, ident* scnd) {
return id_mangle_3(first, '.', scnd);
}
/* returns a mangled name for a Win32 function using it's calling convention */
ident *decorate_win32_c_fkt(ir_entity *ent, ident *id) {
ident *id_decorate_win32_c_fkt(ir_entity *ent, ident *id) {
ir_type *tp = get_entity_type(ent);
unsigned cc_mask = get_method_calling_convention(tp);
char buf[16];
int size, i;
if (IS_CDECL(cc_mask))
return mangle3("_", id, "");
return id_mangle3("_", id, "");
else if (IS_STDCALL(cc_mask)) {
size = 0;
for (i = get_method_n_params(tp) - 1; i >= 0; --i) {
......@@ -137,9 +137,9 @@ ident *decorate_win32_c_fkt(ir_entity *ent, ident *id) {
snprintf(buf, sizeof(buf), "@%d", size);
if (cc_mask & cc_reg_param)
return mangle3("@", id, buf);
return id_mangle3("@", id, buf);
else
return mangle3("_", id, buf);
return id_mangle3("_", id, buf);
}
return id;
}
......
......@@ -234,7 +234,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
set_entity_irg(ent, res);
/*-- a class type so that it can contain "inner" methods as in Pascal. --*/
res->frame_type = new_type_frame(mangle(get_entity_ident(ent), frame_type_suffix));
res->frame_type = new_type_frame(id_mangle(get_entity_ident(ent), frame_type_suffix));
/* the Anchor node must be created first */
res->anchor = new_Anchor(res);
......
......@@ -59,7 +59,7 @@ static ir_type *def_find_pointer_type(ir_type *e_type, ir_mode *mode, int alignm
if (e)
res = e->value;
else {
res = new_type_pointer(mangle_u(get_type_ident(e_type), new_id_from_chars("Ptr", 3)), e_type, mode);
res = new_type_pointer(id_mangle_u(get_type_ident(e_type), new_id_from_chars("Ptr", 3)), e_type, mode);
set_type_alignment_bytes(res, alignment);
pmap_insert(type_map, e_type, res);
}
......@@ -163,7 +163,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
}
/* create the new type */
id = mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
id = id_mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
lowered = new_d_type_method(id, nn_params, nn_ress, get_type_dbg_info(mtp));
/* fill it */
......
......@@ -1744,7 +1744,7 @@ static ir_type *lower_mtp(ir_type *mtp, lower_env_t *env) {
} /* if */
} /* for */
id = mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
id = id_mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
res = new_type_method(id, n_param, n_res);
/* set param types and result types */
......
......@@ -212,7 +212,7 @@ static ident *get_clone_ident(ident *id, int pos, unsigned nr) {
snprintf(clone_postfix, sizeof(clone_postfix), "_cl_%d_%u", pos, nr);
return mangle(id, new_id_from_str(clone_postfix));
return id_mangle(id, new_id_from_str(clone_postfix));
}
/**
......
......@@ -69,7 +69,7 @@ static ir_type *default_gen_pointer_type_to(ir_type *tp) {
} else {
ir_mode *mode = is_Method_type(tp) ? mode_P_code : mode_P_data;
res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode);
res = new_type_pointer(id_mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode);
/* Update trout for pointer types, so we can use it in next call. */
add_type_pointertype_to(tp, res);
}
......@@ -77,7 +77,7 @@ static ir_type *default_gen_pointer_type_to(ir_type *tp) {
else {
res = find_pointer_type_to_type(tp);
if (res == firm_unknown_type)
res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode_P_data);
res = new_type_pointer(id_mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode_P_data);
}
return res;
......
......@@ -222,7 +222,7 @@ _get_entity_ld_ident(ir_entity *ent)
{
assert(ent && ent->kind == k_entity);
if (ent->ld_name == NULL)
ent->ld_name = mangle_entity(ent);
ent->ld_name = id_mangle_entity(ent);
return ent->ld_name;
}
......
......@@ -42,7 +42,7 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg);
/* ----------------------------------------------------------------------- */
ident *default_mangle_inherited_name(ir_entity *super, ir_type *clss) {
return mangle_u(new_id_from_str("inh"), mangle_u(get_type_ident(clss), get_entity_ident(super)));
return id_mangle_u(new_id_from_str("inh"), id_mangle_u(get_type_ident(clss), get_entity_ident(super)));
}
/** Replicates all entities in all super classes that are not overwritten
......
......@@ -1166,7 +1166,7 @@ build_value_type(ident *name, int len, tp_ent_pair *tps) {
/* use the parameter name if specified */
if (! id)
id = mangle_u(name, get_type_ident(elt_type));
id = id_mangle_u(name, get_type_ident(elt_type));
tps[i].ent = new_entity(res, id, elt_type);
set_entity_allocation(tps[i].ent, allocation_parameter);
}
......@@ -1212,7 +1212,7 @@ ir_type *clone_type_method(ir_type *tp, ident *prefix) {
name = tp->name;
if (prefix != NULL)
name = mangle(prefix, name);
name = id_mangle(prefix, name);
mode = tp->mode;
n_params = tp->attr.ma.n_params;
......@@ -1319,7 +1319,7 @@ ir_entity *get_method_value_param_ent(ir_type *method, int pos) {
if (!method->attr.ma.value_params) {
/* parameter value type not created yet, build */
method->attr.ma.value_params
= build_value_type(mangle_u(get_type_ident(method), value_params_suffix),
= build_value_type(id_mangle_u(get_type_ident(method), value_params_suffix),
get_method_n_params(method), method->attr.ma.params);
}
/*
......@@ -1373,7 +1373,7 @@ ir_entity *get_method_value_res_ent(ir_type *method, int pos) {
if (!method->attr.ma.value_ress) {
/* result value type not created yet, build */
method->attr.ma.value_ress
= build_value_type(mangle_u(get_type_ident(method), value_ress_suffix),
= build_value_type(id_mangle_u(get_type_ident(method), value_ress_suffix),
get_method_n_ress(method), method->attr.ma.res_type);
}
/*
......@@ -1603,7 +1603,7 @@ ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
current_ir_graph = rem;
res->attr.aa.element_type = element_type;
new_entity(res, mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
new_entity(res, id_mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
hook_new_type(res);
return res;
}
......@@ -2131,7 +2131,7 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment, i
frame_align = get_type_alignment_bytes(frame_type);
size = (size + frame_align - 1) & ~(frame_align - 1);
tp = new_type_array(mangle_u(get_type_ident(frame_type), name), 1, a_byte);
tp = new_type_array(id_mangle_u(get_type_ident(frame_type), name), 1, a_byte);
set_array_bounds_int(tp, 0, 0, size);
set_type_alignment_bytes(tp, alignment);
......
Supports Markdown
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