From 484a2c65553713acbd118fe52b855c2a55558ebf Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 6 Jun 2012 15:54:58 +0200 Subject: [PATCH] normalize block numbers in assembler output This makes the produced assembler independent from fragile node numbers. It's also a little bit easier to read. --- ir/be/begnuas.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c index 88926eb78..40bc09e38 100644 --- a/ir/be/begnuas.c +++ b/ir/be/begnuas.c @@ -51,6 +51,8 @@ bool be_gas_emit_types = true; char be_gas_elf_type_char = '@'; static be_gas_section_t current_section = (be_gas_section_t) -1; +static pmap *block_numbers; +static unsigned next_block_nr; /** * An environment containing all needed dumper data. @@ -1566,7 +1568,15 @@ void be_gas_emit_block_name(const ir_node *block) if (entity != NULL) { be_gas_emit_entity(entity); } else { - be_emit_irprintf("%s%ld", be_gas_get_private_prefix(), get_irn_node_nr(block)); + void *nr_val = pmap_get(block_numbers, block); + int nr; + if (nr_val == NULL) { + nr = next_block_nr++; + pmap_insert(block_numbers, block, INT_TO_PTR(nr+1)); + } else { + nr = PTR_TO_INT(nr_val)-1; + } + be_emit_irprintf("%s%d", be_gas_get_private_prefix(), nr); } } @@ -1875,6 +1885,9 @@ void be_gas_begin_compilation_unit(const be_main_env_t *env) be_dwarf_open(); be_dwarf_unit_begin(env->cup_name); + block_numbers = pmap_create(); + next_block_nr = 0; + emit_global_asms(); } @@ -1882,6 +1895,8 @@ void be_gas_end_compilation_unit(const be_main_env_t *env) { emit_global_decls(env); + pmap_destroy(block_numbers); + be_dwarf_unit_end(); be_dwarf_close(); } -- 2.20.1