* @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
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
be_emit_irprintf("\",%d,0,0,0\n", N_LSYM);
be_emit_write_line();
-} /* gen_array_type */
+}
/**
* Generates a struct/union type
}
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.
finish_types(&env);
del_waitq(env.wq);
-} /* gen_types */
+}
/* -------------------------- I/F ----------------------------- */
/* 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
/* 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;
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
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 = {