Commit 2c5bd74e authored by Matthias Braun's avatar Matthias Braun
Browse files

entity: Don't set names for some internal entities

We can just as well make up names on the fly while printing the entities
for debugging.
parent d5019c60
......@@ -83,14 +83,22 @@ static int firm_emit_dbg(lc_appendable_t *app, const lc_arg_occ_t *occ,
return size;
}
/**
* Beware: do not set the entity ld_name
*/
static const char *get_entity_ld_name_ex(ir_entity *ent)
static void print_entity_name(char *buffer, size_t buffer_size,
char const *const add,
ir_entity const *const entity)
{
if (ent->ld_name != NULL)
return get_entity_ld_name(ent);
return get_entity_name(ent);
switch (entity->kind) {
case IR_ENTITY_PARAMETER:
snprintf(buffer, buffer_size, "%sparameter.%lu", add,
get_entity_parameter_number(entity));
return;
case IR_ENTITY_LABEL:
snprintf(buffer, buffer_size, "%slabel", add);
return;
default:
snprintf(buffer, buffer_size, "%s%s", add, get_entity_ld_name(entity));
return;
}
}
/**
......@@ -116,9 +124,8 @@ static int firm_emit(lc_appendable_t *app, const lc_arg_occ_t *occ,
snprintf(add, sizeof(add), "[%p]", X);
break;
case k_entity: {
ir_entity *entity = (ir_entity*)X;
snprintf(buf, sizeof(buf), "%s%s", A("ent"),
isupper((unsigned char)occ->conversion) ? get_entity_ld_name_ex(entity): get_entity_name(entity));
ir_entity const *const entity = (ir_entity const*)X;
print_entity_name(buf, sizeof(buf), A("ent"), entity);
snprintf(add, sizeof(add), "[%ld]", get_entity_nr(entity));
break;
}
......
......@@ -100,8 +100,7 @@ ir_entity *new_global_entity(ir_type *segment, ident *ld_name, ir_type *type,
ir_entity *new_parameter_entity(ir_type *owner, size_t pos, ir_type *type)
{
ident *name = new_id_fmt("parameter.%lu", (unsigned long)pos);
ir_entity *res = intern_new_entity(owner, IR_ENTITY_PARAMETER, name, type,
ir_entity *res = intern_new_entity(owner, IR_ENTITY_PARAMETER, NULL, type,
ir_visibility_private);
res->attr.compound_member.offset = INVALID_OFFSET;
res->attr.parameter.number = pos;
......@@ -111,9 +110,8 @@ ir_entity *new_parameter_entity(ir_type *owner, size_t pos, ir_type *type)
ir_entity *new_label_entity(ir_label_t label)
{
ident *name = id_unique("label_%u");
ir_type *global_type = get_glob_type();
ir_entity *res = intern_new_entity(global_type, IR_ENTITY_LABEL, name,
ir_entity *res = intern_new_entity(global_type, IR_ENTITY_LABEL, NULL,
get_code_type(), ir_visibility_private);
res->attr.code_attr.label = label;
hook_new_entity(res);
......
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