X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbestabs.c;h=a385da5d4d4af51829c01c7c80253c7e0890bca5;hb=5474a1c188c9d59eea2c915515980cd9cbab58d8;hp=eca305aeb9d3600e35f1ff12cd6c2d38b0636822;hpb=85f517eca982e6a4e1d1848eb67634ae33b70de9;p=libfirm diff --git a/ir/be/bestabs.c b/ir/be/bestabs.c index eca305aeb..a385da5d4 100644 --- a/ir/be/bestabs.c +++ b/ir/be/bestabs.c @@ -22,7 +22,6 @@ * @brief Stabs support. * @author Michael Beck * @date 11.9.2006 - * @version $Id$ */ #include "config.h" @@ -37,7 +36,7 @@ #include "xmalloc.h" #include "pmap.h" #include "pdeq.h" -#include "irtools.h" +#include "util.h" #include "obst.h" #include "array_t.h" #include "be_dbgout_t.h" @@ -131,29 +130,29 @@ typedef struct stabs_handle { */ static unsigned get_type_number(stabs_handle *h, ir_type *tp) { - pmap_entry *entry; + void *entry; unsigned num; if (tp == NULL) { /* map to the void type */ return 0; } - entry = pmap_find(h->type_map, tp); - if (! entry) { + entry = pmap_get(h->type_map, tp); + if (entry == NULL) { num = h->next_type_nr++; - pmap_insert(h->type_map, tp, INT_TO_PTR(num)); + pmap_insert(h->type_map, tp, INT_TO_PTR(num+1)); } else { - num = (unsigned)PTR_TO_INT(entry->value); + num = ((unsigned)PTR_TO_INT(entry))-1; } return num; -} /* get_type_number */ +} /** * Map a given Type to void by assigned the type number 0. */ static void map_to_void(stabs_handle *h, ir_type *tp) { - pmap_insert(h->type_map, tp, INT_TO_PTR(0)); + pmap_insert(h->type_map, tp, INT_TO_PTR(1)); } /** @@ -164,7 +163,7 @@ static void gen_void_type(stabs_handle *h) (void) h; be_emit_irprintf("\t.stabs\t\"void:t%u=%u\",%d,0,0,0\n", 0, 0, N_LSYM); be_emit_write_line(); -} /* gen_void_type */ +} typedef struct walker_env { stabs_handle *h; @@ -173,10 +172,10 @@ typedef struct walker_env { /* a type is not ready: put it on the wait queue */ #define SET_TYPE_NOT_READY(wq, tp) \ - do { \ - set_type_link(tp, (void *)1); \ - waitq_put(wq, tp); \ - } while (0) + do { \ + set_type_link(tp, (void *)1); \ + waitq_put(wq, tp); \ + } while (0) /* a the is ready */ #define SET_TYPE_READY(tp) set_type_link(tp, NULL) @@ -242,13 +241,13 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) Ignore it here as it's name is remapped to "void". */ map_to_void(h, tp); return; - } /* if */ + } #if 0 if (get_mode_size_bits(mode) & 7) { /* this is a bitfield type, ignore it */ return; - } /* if */ + } #endif type_num = get_type_number(h, tp); @@ -269,7 +268,7 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) be_emit_irprintf(":t%u=r1;%d;0;\",%d,0,0,0\n", type_num, size, N_LSYM); be_emit_write_line(); } -} /* gen_primitive_type */ +} /** * Generates an enum type @@ -295,7 +294,7 @@ static void gen_enum_type(stabs_handle *h, ir_type *tp) } be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM); be_emit_write_line(); -} /* gen_enum_type */ +} /** * print a pointer type @@ -330,7 +329,7 @@ static void gen_pointer_type(wenv_t *env, ir_type *tp) print_pointer_type(h, tp, 0); be_emit_irprintf("\",%d,0,0,0\n", N_LSYM); be_emit_write_line(); -} /* gen_pointer_type */ +} /** * print an array type @@ -387,7 +386,7 @@ static void gen_array_type(wenv_t *env, ir_type *tp) be_emit_irprintf("\",%d,0,0,0\n", N_LSYM); be_emit_write_line(); -} /* gen_array_type */ +} /** * Generates a struct/union type @@ -465,7 +464,7 @@ static void gen_struct_union_type(wenv_t *env, ir_type *tp) } be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM); be_emit_write_line(); -} /* gen_struct_type */ +} /** * Generates a method type @@ -503,7 +502,7 @@ static void gen_method_type(wenv_t *env, ir_type *tp) } be_emit_irprintf("\",%d,0,0,0\n", N_LSYM); be_emit_write_line(); -} /* gen_method_type */ +} /** * type-walker: generate declaration for simple types, @@ -518,52 +517,54 @@ static void walk_type(type_or_ent tore, void *ctx) tp = tore.typ; /* ignore the unknown type */ - if (tp == firm_unknown_type) + if (is_unknown_type(tp)) return; } else { return; - } /* if */ + } switch (get_type_tpop_code(tp)) { case tpo_class: if (tp == get_glob_type()) { SET_TYPE_READY(tp); - break; + return; } /* fall through */ case tpo_struct: case tpo_union: gen_struct_union_type(env, tp); - break; + return; case tpo_enumeration: gen_enum_type(env->h, tp); - break; + return; case tpo_primitive: gen_primitive_type(env->h, tp); - break; + return; case tpo_method: gen_method_type(env, tp); - break; + return; case tpo_array: gen_array_type(env, tp); - break; + return; case tpo_pointer: gen_pointer_type(env, tp); - break; + return; + case tpo_code: + case tpo_none: case tpo_unknown: + case tpo_uninitialized: /* the unknown type: ignore */ SET_TYPE_READY(tp); - break; - default: - assert(! "Unknown tpop code"); - } /* switch */ -} /* walk_type */ + return; + } + panic("Unknown tpop code"); +} /** * generate declaration for all types @@ -604,9 +605,9 @@ static void finish_types(wenv_t *env) break; default: assert(! "Unknown tpop code"); - } /* switch */ - } /* while */ -} /* finish_types */ + } + } +} /** * generate all types. @@ -617,10 +618,15 @@ static void gen_types(stabs_handle *h) env.h = h; env.wq = new_waitq(); + + irp_reserve_resources(irp, IRP_RESOURCE_TYPE_LINK); type_walk(NULL, walk_type, &env); + irp_free_resources(irp, IRP_RESOURCE_TYPE_LINK); + finish_types(&env); del_waitq(env.wq); -} /* gen_types */ + +} /* -------------------------- I/F ----------------------------- */ @@ -702,8 +708,8 @@ static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent) /* create the method entry */ mtp = get_entity_type(ent); - if (is_lowered_type(mtp)) - mtp = get_associated_type(mtp); + while (is_lowered_type(mtp)) + mtp = get_higher_type(mtp); if (get_method_n_ress(mtp) > 0) rtp = get_method_res_type(mtp, 0); else @@ -720,18 +726,18 @@ static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent) /* create parameter entries */ between_size = get_type_size_bytes(layout->between_type); for (i = 0, n = get_method_n_params(mtp); i < n; ++i) { - ir_type *ptp = get_method_param_type(mtp, i); - const char *name = NULL; - char buf[16]; - int ofs = 0; - ir_entity *stack_ent; - - if (! name) { - snprintf(buf, sizeof(buf), "arg%d", i); - name = buf; - } + ir_type *ptp = get_method_param_type(mtp, i); + const char *name = NULL; + char buf[16]; + int ofs = 0; + ir_entity *stack_ent; + + if (! name) { + snprintf(buf, sizeof(buf), "arg%d", i); + name = buf; + } /* check if this parameter has a stack entity. If it has, it - it transmitted on the stack, else in a register */ + * it transmitted on the stack, else in a register */ stack_ent = layout->param_map[i]; if (stack_ent) { ofs = get_entity_offset(stack_ent) + between_size; @@ -753,7 +759,7 @@ static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent) be_emit_irprintf("\",%d,0,0,%d\n", N_PSYM, ofs); be_emit_write_line(); } -} /* stabs_method_begin */ +} /** * dump the stabs for a method end @@ -801,7 +807,7 @@ static void stabs_method_end(dbg_handle *handle) h->cur_ent = NULL; h->layout = NULL; -} /* stabs_method_end */ +} /** * dump types @@ -814,7 +820,7 @@ static void stabs_types(dbg_handle *handle) h->next_type_nr++; gen_void_type(h); gen_types(h); -} /* stabs_types */ +} /** * dump a variable in the global type @@ -842,7 +848,7 @@ static void stabs_variable(dbg_handle *handle, const ir_entity *ent) buf[sizeof(buf) - 1] = '\0'; be_emit_string(buf); -} /* stabs_variable */ +} /** * Close the stabs handler. @@ -852,7 +858,7 @@ static void stabs_close(dbg_handle *handle) stabs_handle *h = (stabs_handle *)handle; pmap_destroy(h->type_map); free(h); -} /* stabs_close */ +} /** The stabs operations. */ static const debug_ops stabs_ops = {