Remove the unused attribute const arch_env_t *arch_env from struct phi_handler and...
[libfirm] / ir / be / bestabs.c
index 17140be..9073c15 100644 (file)
@@ -24,9 +24,7 @@
  * @date    11.9.2006
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -41,7 +39,7 @@
 #include "pdeq.h"
 #include "irtools.h"
 #include "obst.h"
-#include "array.h"
+#include "array_t.h"
 #include "be_dbgout_t.h"
 #include "beabi.h"
 #include "bemodule.h"
@@ -188,6 +186,27 @@ typedef struct walker_env {
 #define SKIP_PTR(tp)   (is_Pointer_type(tp) ? get_pointer_points_to_type(tp) : tp)
 #endif
 
+/**
+ * mode_info for output as decimal
+ */
+static const tarval_mode_info dec_output = {
+       TVO_DECIMAL,
+       NULL,
+       NULL,
+};
+
+/**
+ * emit a tarval as decimal
+ */
+static void be_emit_tv_as_decimal(tarval *tv) {
+       ir_mode *mode = get_tarval_mode(tv);
+       const tarval_mode_info *old = get_tarval_mode_output_option(mode);
+
+       set_tarval_mode_output_option(mode, &dec_output);
+       be_emit_tarval(tv);
+       set_tarval_mode_output_option(mode, old);
+}
+
 /**
  * Generates a primitive type.
  *
@@ -215,9 +234,9 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
 
        if (mode_is_int(mode)) {
                be_emit_irprintf("\t.stabs\t\"%s:t%u=r%u;", get_type_name(tp), type_num, type_num);
-               be_emit_tarval(get_mode_min(mode));
+               be_emit_tv_as_decimal(get_mode_min(mode));
                be_emit_char(';');
-               be_emit_tarval(get_mode_max(mode));
+               be_emit_tv_as_decimal(get_mode_max(mode));
                be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM);
                be_emit_write_line();
        } else if (mode_is_float(mode)) {
@@ -448,13 +467,13 @@ static void gen_method_type(wenv_t *env, ir_type *tp) {
  * type-walker: generate declaration for simple types,
  * put all other types on a wait queue
  */
-static void walk_type(type_or_ent *tore, void *ctx)
+static void walk_type(type_or_ent tore, void *ctx)
 {
        wenv_t *env = ctx;
        ir_type  *tp;
 
-       if (get_kind(tore) == k_type) {
-               tp = (ir_type *)tore;
+       if (is_type(tore.typ)) {
+               tp = tore.typ;
 
                /* ignore the unknown type */
                if (tp == firm_unknown_type)
@@ -578,8 +597,9 @@ static void stabs_so(dbg_handle *handle, const char *filename) {
  * Main Program
  */
 static void stabs_main_program(dbg_handle *handle) {
-       (void) handle;
        ir_graph *irg = get_irp_main_irg();
+
+       (void) handle;
        if (irg) {
                be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,0\n", get_entity_name(get_irg_entity(irg)), N_MAIN);
                be_emit_write_line();
@@ -596,12 +616,6 @@ static void stabs_set_dbg_info(dbg_handle *h, dbg_info *dbgi)
                return;
 
        if (handle->curr_file != fname) {
-               /* TODO: escape filename correctly */
-               if (handle->curr_file != handle->main_file) {
-                       be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,0\n", handle->curr_file,
-                                        N_EINCL);
-                       be_emit_write_line();
-               }
                if (fname != handle->main_file) {
                        be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,0\n", fname, N_SOL);
                        be_emit_write_line();
@@ -754,7 +768,7 @@ static void stabs_types(dbg_handle *handle) {
 /**
  * dump a variable in the global type
  */
-static void stabs_variable(dbg_handle *handle, struct obstack *obst, ir_entity *ent) {
+static void stabs_variable(dbg_handle *handle, ir_entity *ent) {
        stabs_handle *h = (stabs_handle *)handle;
        unsigned tp_num = get_type_number(h, get_entity_type(ent));
        char buf[1024];
@@ -776,10 +790,7 @@ static void stabs_variable(dbg_handle *handle, struct obstack *obst, ir_entity *
        }
        buf[sizeof(buf) - 1] = '\0';
 
-       if (obst)
-               obstack_printf(obst, "%s", buf);
-       else
-               be_emit_irprintf("%s", buf);
+       be_emit_string(buf);
 }  /* stabs_variable */
 
 /**
@@ -805,7 +816,7 @@ static const debug_ops stabs_ops = {
 
 /* Opens a stabs handler */
 dbg_handle *be_stabs_open(void) {
-       stabs_handle *h = xmalloc(sizeof(*h));
+       stabs_handle *h = XMALLOC(stabs_handle);
 
        h->base.ops     = &stabs_ops;
        h->cur_ent      = NULL;