Commit 6f0d594f authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ident: Simplify the interface of id_unique().

Now you only pass a name prefix and it automatically adds a ".%u".
parent 9d78d6c9
......@@ -64,7 +64,7 @@ FIRM_API const char *get_id_str(ident *id);
/**
* helper function for creating unique idents. It contains an internal counter
* and replaces a "%u" inside the tag with the counter.
* and appends it separated by a dot to the given tag.
*/
FIRM_API ident *id_unique(const char *tag);
......
......@@ -332,7 +332,7 @@ ir_entity *create_float_const_entity(ir_tarval *const tv)
ir_type *type = mode == x86_mode_E ? x86_type_E : get_type_for_mode(mode);
ir_type *glob = get_glob_type();
entity = new_global_entity(glob, id_unique("C%u"), type,
entity = new_global_entity(glob, id_unique("C"), type,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......@@ -1552,7 +1552,7 @@ static ir_node *gen_Switch(ir_node *const node)
ir_type *const utype = get_unknown_type();
ir_entity *const entity
= new_global_entity(irp->dummy_owner, id_unique("TBL%u"), utype,
= new_global_entity(irp->dummy_owner, id_unique("TBL"), utype,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......
......@@ -318,7 +318,7 @@ static ir_entity *create_float_const_entity(ir_tarval *tv, ident *name)
ir_entity *res = pmap_get(ir_entity, ia32_tv_ent, tv);
if (!res) {
if (!name)
name = id_unique("C%u");
name = id_unique("C");
ir_type *const tp = get_prim_type(mode);
res = new_global_entity(get_glob_type(), name, tp,
......@@ -2867,7 +2867,7 @@ static ir_node *gen_Switch(ir_node *node)
ir_type *const utype = get_unknown_type();
ir_entity *const entity
= new_global_entity(irp->dummy_owner, id_unique("TBL%u"), utype,
= new_global_entity(irp->dummy_owner, id_unique("TBL"), utype,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......@@ -3259,7 +3259,7 @@ static ir_entity *ia32_create_const_array(ir_node *c0, ir_node *c1,
tp = ia32_create_float_array(tp);
ir_entity *ent
= new_global_entity(get_glob_type(), id_unique("C%u"), tp,
= new_global_entity(get_glob_type(), id_unique("C"), tp,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......
......@@ -1159,7 +1159,7 @@ static ir_entity *create_float_const_entity(ir_tarval *const tv)
ir_mode *mode = get_tarval_mode(tv);
ir_type *type = get_type_for_mode(mode);
ir_type *glob = get_glob_type();
entity = new_global_entity(glob, id_unique("C%u"), type,
entity = new_global_entity(glob, id_unique("C"), type,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......@@ -1235,7 +1235,7 @@ static ir_node *gen_Switch(ir_node *node)
ir_type *const utype = get_unknown_type();
ir_entity *const entity
= new_global_entity(irp->dummy_owner, id_unique("TBL%u"), utype,
= new_global_entity(irp->dummy_owner, id_unique("TBL"), utype,
ir_visibility_private,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
......
......@@ -73,5 +73,5 @@ void finish_ident(void)
ident *id_unique(const char *tag)
{
static unsigned unique_id = 0;
return new_id_fmt(tag, unique_id++);
return new_id_fmt("%s.%u", tag, unique_id++);
}
......@@ -134,7 +134,7 @@ static void add_constructor(ir_entity *method)
ir_type *const method_type = get_entity_type(method);
ir_type *const ptr_type = new_type_pointer(method_type);
ir_type *const constructors = get_segment_type(IR_SEGMENT_CONSTRUCTORS);
ident *const ide = id_unique("constructor_ptr.%u");
ident *const ide = id_unique("constructor_ptr");
ir_entity *const ptr = new_global_entity(constructors, ide, ptr_type, ir_visibility_private, IR_LINKAGE_CONSTANT | IR_LINKAGE_HIDDEN_USER);
ir_graph *const irg = get_const_code_irg();
ir_node *const val = new_r_Address(irg, method);
......
......@@ -506,7 +506,7 @@ static ir_node *get_dummy_member(ir_node *block, ir_type *tp)
panic("fixed layout not implemented");
}
ident *dummy_id = id_unique("call_result.%u");
ident *dummy_id = id_unique("call_result");
ir_entity *ent = new_entity(ft, dummy_id, tp);
return new_r_Member(block, get_irg_frame(irg), ent);
}
......@@ -712,7 +712,7 @@ static void fix_call_compound_ret(const cl_entry *entry,
static ir_entity *create_compound_arg_entity(ir_graph *irg, ir_type *type)
{
ir_type *frame = get_irg_frame_type(irg);
ident *id = id_unique("$compound_param.%u");
ident *id = id_unique("$compound_param");
ir_entity *entity = new_entity(frame, id, type);
/* TODO: we could do some optimizations here and create a big union type
* for all different call types in a function */
......
......@@ -1428,7 +1428,7 @@ transform:
* 1 double store+2 integer loads */
ir_graph *irg = get_irn_irg(node);
ir_type *frame_type = get_irg_frame_type(irg);
ident *id = id_unique("bitcast_%u");
ident *id = id_unique("bitcast");
ir_entity *entity = new_entity(frame_type, id,
get_type_for_mode(other_mode));
ir_node *block = get_nodes_block(node);
......
......@@ -2193,11 +2193,11 @@ again:;
/* Construct an anonymous struct type
* for the combined Store.
*/
ident *struct_id = id_unique("__combined_Store_%u");
ident *struct_id = id_unique("__combined_Store");
type = new_type_struct(struct_id);
ident *member0_id = id_unique("__Store_part_%u");
ident *member0_id = id_unique("__Store_part");
new_entity(type, member0_id, type0);
ident *member1_id = id_unique("__Store_part_%u");
ident *member1_id = id_unique("__Store_part");
new_entity(type, member1_id, type1);
} else {
type = type0;
......
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