* @brief Stabs support.
* @author Michael Beck
* @date 11.9.2006
- * @version $Id$
*/
#include "config.h"
#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"
*/
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));
}
/**
(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;
/* 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)
Ignore it here as it's name is remapped to "void". */
map_to_void(h, tp);
return;
- } /* if */
+ }
- if (0 && get_mode_size_bits(mode) & 7) {
+#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);
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
}
be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM);
be_emit_write_line();
-} /* gen_enum_type */
+}
/**
* print a pointer type
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
ir_type *etp = get_array_element_type(tp);
size_t i, n = get_array_n_dimensions(tp);
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
- int *perm;
+ size_t *perm;
be_emit_irprintf("%u=a", type_num);
- NEW_ARR_A(size_t, perm, n);
+ perm = ALLOCAN(size_t, n);
for (i = 0; i < n; ++i) {
perm[i] = get_array_order(tp, i);
}
be_emit_irprintf("\",%d,0,0,0\n", N_LSYM);
be_emit_write_line();
-} /* gen_array_type */
+}
/**
* Generates a struct/union type
ofs = get_entity_offset(ent);
if (is_Struct_type(mtp) && get_type_mode(mtp) != NULL) {
/* this structure is a bitfield, skip */
- int i, n;
+ int m;
+ int n_members = get_struct_n_members(mtp);
- for (i = 0, n = get_struct_n_members(mtp); i < n; ++i) {
- ir_entity *ent = get_struct_member(mtp, i);
- ir_type *tp = get_entity_type(ent);
+ for (m = 0; m < n_members; ++m) {
+ ir_entity *member = get_struct_member(mtp, m);
+ ir_type *member_tp = get_entity_type(member);
int bofs;
- type_num = get_type_number(h, tp);
- size = get_type_size_bytes(tp) * 8;
- bofs = (ofs + get_entity_offset(ent)) * 8 + get_entity_offset_bits_remainder(ent);
+ type_num = get_type_number(h, member_tp);
+ size = get_type_size_bytes(member_tp) * 8;
+ bofs = (ofs + get_entity_offset(member)) * 8 + get_entity_offset_bits_remainder(member);
/* name:type, bit offset from the start of the struct', number of bits in the element. */
- be_emit_irprintf("%s:%u,%d,%u;", get_entity_name(ent), type_num, bofs, size);
+ be_emit_irprintf("%s:%u,%d,%u;", get_entity_name(member), type_num, bofs, size);
}
} else {
/* no bitfield */
}
be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM);
be_emit_write_line();
-} /* gen_struct_type */
+}
/**
* Generates a method type
}
be_emit_irprintf("\",%d,0,0,0\n", N_LSYM);
be_emit_write_line();
-} /* gen_method_type */
+}
/**
* type-walker: generate declaration for simple types,
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
break;
default:
assert(! "Unknown tpop code");
- } /* switch */
- } /* while */
-} /* finish_types */
+ }
+ }
+}
/**
* generate all types.
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 ----------------------------- */
/* create the method entry */
mtp = get_entity_type(ent);
- mtp = get_type_unlowered(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
/* 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;
- unsigned type_num = get_type_number(h, ptp);
- 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;
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
/* create entries for automatic variables on the stack */
frame_size = get_type_size_bytes(layout->frame_type);
for (i = 0, n = get_compound_n_members(layout->frame_type); i < n; ++i) {
- ir_entity *ent = get_compound_member(layout->frame_type, i);
+ ir_entity *member = get_compound_member(layout->frame_type, i);
ir_type *tp;
int ofs;
unsigned type_num;
/* ignore spill slots and other helper objects */
- if (is_entity_compiler_generated(ent))
+ if (is_entity_compiler_generated(member))
continue;
- tp = get_entity_type(ent);
+ tp = get_entity_type(member);
/* should not happen in backend but ... */
if (is_Method_type(tp))
continue;
type_num = get_type_number(h, tp);
- ofs = -frame_size + get_entity_offset(ent);
+ ofs = -frame_size + get_entity_offset(member);
be_emit_irprintf("\t.stabs\t\"%s:%u\",%d,0,0,%d\n",
- get_entity_name(ent), type_num, N_LSYM, ofs);
+ get_entity_name(member), type_num, N_LSYM, ofs);
be_emit_write_line();
}
/* we need a lexical block here */
h->cur_ent = NULL;
h->layout = NULL;
-} /* stabs_method_end */
+}
/**
* dump types
h->next_type_nr++;
gen_void_type(h);
gen_types(h);
-} /* stabs_types */
+}
/**
* dump a variable in the global type
buf[sizeof(buf) - 1] = '\0';
be_emit_string(buf);
-} /* stabs_variable */
+}
/**
* Close the stabs handler.
stabs_handle *h = (stabs_handle *)handle;
pmap_destroy(h->type_map);
free(h);
-} /* stabs_close */
+}
/** The stabs operations. */
static const debug_ops stabs_ops = {