projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix wrong usage of ircons functions
[libfirm]
/
ir
/
be
/
bestabs.c
diff --git
a/ir/be/bestabs.c
b/ir/be/bestabs.c
index
a51fdfd
..
a96c8ac
100644
(file)
--- a/
ir/be/bestabs.c
+++ b/
ir/be/bestabs.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-45,6
+45,7
@@
#include "bemodule.h"
#include "beemitter.h"
#include "dbginfo.h"
#include "bemodule.h"
#include "beemitter.h"
#include "dbginfo.h"
+#include "begnuas.h"
/* Non-Stab Symbol and Stab Symbol Types */
enum stabs_types {
/* Non-Stab Symbol and Stab Symbol Types */
enum stabs_types {
@@
-115,7
+116,7
@@
enum stabs_types {
*/
typedef struct stabs_handle {
dbg_handle base; /**< the base class */
*/
typedef struct stabs_handle {
dbg_handle base; /**< the base class */
- ir_entity *cur_ent; /**< current method entity */
+
const
ir_entity *cur_ent; /**< current method entity */
const be_stack_layout_t *layout; /**< current stack layout */
unsigned next_type_nr; /**< next type number */
pmap *type_map; /**< a map from type to type number */
const be_stack_layout_t *layout; /**< current stack layout */
unsigned next_type_nr; /**< next type number */
pmap *type_map; /**< a map from type to type number */
@@
-128,7
+129,8
@@
typedef struct stabs_handle {
/**
* Returns the stabs type number of a Firm type.
*/
/**
* Returns the stabs type number of a Firm type.
*/
-static unsigned get_type_number(stabs_handle *h, ir_type *tp) {
+static unsigned get_type_number(stabs_handle *h, ir_type *tp)
+{
pmap_entry *entry;
unsigned num;
pmap_entry *entry;
unsigned num;
@@
-141,7
+143,7
@@
static unsigned get_type_number(stabs_handle *h, ir_type *tp) {
num = h->next_type_nr++;
pmap_insert(h->type_map, tp, INT_TO_PTR(num));
} else {
num = h->next_type_nr++;
pmap_insert(h->type_map, tp, INT_TO_PTR(num));
} else {
- num = PTR_TO_INT(entry->value);
+ num =
(unsigned)
PTR_TO_INT(entry->value);
}
return num;
} /* get_type_number */
}
return num;
} /* get_type_number */
@@
-149,14
+151,16
@@
static unsigned get_type_number(stabs_handle *h, ir_type *tp) {
/**
* Map a given Type to void by assigned the type number 0.
*/
/**
* Map a given Type to void by assigned the type number 0.
*/
-static void map_to_void(stabs_handle *h, ir_type *tp) {
+static void map_to_void(stabs_handle *h, ir_type *tp)
+{
pmap_insert(h->type_map, tp, INT_TO_PTR(0));
}
/**
* generate the void type.
*/
pmap_insert(h->type_map, tp, INT_TO_PTR(0));
}
/**
* generate the void type.
*/
-static void gen_void_type(stabs_handle *h) {
+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();
(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();
@@
-172,7
+176,7
@@
typedef struct walker_env {
do { \
set_type_link(tp, (void *)1); \
waitq_put(wq, tp); \
do { \
set_type_link(tp, (void *)1); \
waitq_put(wq, tp); \
- } while(0)
+ } while
(0)
/* a the is ready */
#define SET_TYPE_READY(tp) set_type_link(tp, NULL)
/* a the is ready */
#define SET_TYPE_READY(tp) set_type_link(tp, NULL)
@@
-198,7
+202,8
@@
static const tarval_mode_info dec_output = {
/**
* emit a tarval as decimal
*/
/**
* emit a tarval as decimal
*/
-static void be_emit_tv_as_decimal(tarval *tv) {
+static void be_emit_tv_as_decimal(ir_tarval *tv)
+{
ir_mode *mode = get_tarval_mode(tv);
const tarval_mode_info *old = get_tarval_mode_output_option(mode);
ir_mode *mode = get_tarval_mode(tv);
const tarval_mode_info *old = get_tarval_mode_output_option(mode);
@@
-209,8
+214,14
@@
static void be_emit_tv_as_decimal(tarval *tv) {
static void emit_type_name(const ir_type *type)
{
static void emit_type_name(const ir_type *type)
{
+ char *c;
char buf[256];
ir_print_type(buf, sizeof(buf), type);
char buf[256];
ir_print_type(buf, sizeof(buf), type);
+ /* replace special chars to be on the safe side */
+ for (c = buf; *c != '\0'; ++c) {
+ if (*c == '\n' || *c == '"' || *c == '\\')
+ *c = '?';
+ }
be_emit_string(buf);
}
be_emit_string(buf);
}
@@
-220,7
+231,8
@@
static void emit_type_name(const ir_type *type)
* @param h the stabs handle
* @param tp the type
*/
* @param h the stabs handle
* @param tp the type
*/
-static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
+static void gen_primitive_type(stabs_handle *h, ir_type *tp)
+{
ir_mode *mode = get_type_mode(tp);
unsigned type_num;
ir_mode *mode = get_type_mode(tp);
unsigned type_num;
@@
-263,7
+275,8
@@
static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
* @param h the stabs handle
* @param tp the type
*/
* @param h the stabs handle
* @param tp the type
*/
-static void gen_enum_type(stabs_handle *h, ir_type *tp) {
+static void gen_enum_type(stabs_handle *h, ir_type *tp)
+{
unsigned type_num = get_type_number(h, tp);
int i, n;
unsigned type_num = get_type_number(h, tp);
int i, n;
@@
-285,7
+298,8
@@
static void gen_enum_type(stabs_handle *h, ir_type *tp) {
/**
* print a pointer type
*/
/**
* print a pointer type
*/
-void print_pointer_type(stabs_handle *h, ir_type *tp, int local) {
+static void print_pointer_type(stabs_handle *h, ir_type *tp, int local)
+{
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
ir_type *el_tp = get_pointer_points_to_type(tp);
unsigned el_num = get_type_number(h, el_tp);
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
ir_type *el_tp = get_pointer_points_to_type(tp);
unsigned el_num = get_type_number(h, el_tp);
@@
-299,7
+313,8
@@
void print_pointer_type(stabs_handle *h, ir_type *tp, int local) {
* @param env the walker environment
* @param tp the type
*/
* @param env the walker environment
* @param tp the type
*/
-static void gen_pointer_type(wenv_t *env, ir_type *tp) {
+static void gen_pointer_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
ir_type *el_tp = get_pointer_points_to_type(tp);
stabs_handle *h = env->h;
ir_type *el_tp = get_pointer_points_to_type(tp);
@@
-318,7
+333,8
@@
static void gen_pointer_type(wenv_t *env, ir_type *tp) {
/**
* print an array type
*/
/**
* print an array type
*/
-static void print_array_type(stabs_handle *h, ir_type *tp, int local) {
+static void print_array_type(stabs_handle *h, ir_type *tp, int local)
+{
ir_type *etp = get_array_element_type(tp);
int i, n = get_array_n_dimensions(tp);
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
ir_type *etp = get_array_element_type(tp);
int i, n = get_array_n_dimensions(tp);
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
@@
-352,7
+368,8
@@
static void print_array_type(stabs_handle *h, ir_type *tp, int local) {
* @param env the walker environment
* @param tp the type
*/
* @param env the walker environment
* @param tp the type
*/
-static void gen_array_type(wenv_t *env, ir_type *tp) {
+static void gen_array_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
ir_type *etp = get_array_element_type(tp);
stabs_handle *h = env->h;
ir_type *etp = get_array_element_type(tp);
@@
-376,7
+393,8
@@
static void gen_array_type(wenv_t *env, ir_type *tp) {
* @param env the walker environment
* @param tp the type
*/
* @param env the walker environment
* @param tp the type
*/
-static void gen_struct_union_type(wenv_t *env, ir_type *tp) {
+static void gen_struct_union_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
int i, n;
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
int i, n;
@@
-452,7
+470,8
@@
static void gen_struct_union_type(wenv_t *env, ir_type *tp) {
* @param env the walker environment
* @param tp the type
*/
* @param env the walker environment
* @param tp the type
*/
-static void gen_method_type(wenv_t *env, ir_type *tp) {
+static void gen_method_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
ir_type *rtp = NULL;
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
ir_type *rtp = NULL;
@@
-489,7
+508,7
@@
static void gen_method_type(wenv_t *env, ir_type *tp) {
*/
static void walk_type(type_or_ent tore, void *ctx)
{
*/
static void walk_type(type_or_ent tore, void *ctx)
{
- wenv_t *env = ctx;
+ wenv_t *env =
(wenv_t*)
ctx;
ir_type *tp;
if (is_type(tore.typ)) {
ir_type *tp;
if (is_type(tore.typ)) {
@@
-549,10
+568,9
@@
static void walk_type(type_or_ent tore, void *ctx)
static void finish_types(wenv_t *env)
{
waitq *wq = env->wq;
static void finish_types(wenv_t *env)
{
waitq *wq = env->wq;
- ir_type *tp;
while (! waitq_empty(wq)) {
while (! waitq_empty(wq)) {
-
tp =
waitq_get(wq);
+
ir_type *tp = (ir_type*)
waitq_get(wq);
if (IS_TYPE_READY(tp))
continue;
if (IS_TYPE_READY(tp))
continue;
@@
-590,7
+608,8
@@
static void finish_types(wenv_t *env)
/**
* generate all types.
*/
/**
* generate all types.
*/
-static void gen_types(stabs_handle *h) {
+static void gen_types(stabs_handle *h)
+{
wenv_t env;
env.h = h;
wenv_t env;
env.h = h;
@@
-606,17
+625,19
@@
static void gen_types(stabs_handle *h) {
/**
* start a new source object (compilation unit)
*/
/**
* start a new source object (compilation unit)
*/
-static void stabs_so(dbg_handle *handle, const char *filename) {
+static void stabs_so(dbg_handle *handle, const char *filename)
+{
stabs_handle *h = (stabs_handle *)handle;
h->main_file = h->curr_file = filename;
stabs_handle *h = (stabs_handle *)handle;
h->main_file = h->curr_file = filename;
- be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,
.Ltext0\n", filename, N_SO
);
+ be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,
%stext0\n", filename, N_SO, be_gas_get_private_prefix()
);
be_emit_write_line();
} /* stabs_so */
/**
* Main Program
*/
be_emit_write_line();
} /* stabs_so */
/**
* Main Program
*/
-static void stabs_main_program(dbg_handle *handle) {
+static void stabs_main_program(dbg_handle *handle)
+{
ir_graph *irg = get_irp_main_irg();
(void) handle;
ir_graph *irg = get_irp_main_irg();
(void) handle;
@@
-661,12
+682,14
@@
static void stabs_set_dbg_info(dbg_handle *h, dbg_info *dbgi)
/**
* dump the stabs for a method begin
*/
/**
* dump the stabs for a method begin
*/
-static void stabs_method_begin(dbg_handle *handle,
ir_entity *ent, const be_stack_layout_t *layou
t)
+static void stabs_method_begin(dbg_handle *handle,
const ir_entity *en
t)
{
stabs_handle *h = (stabs_handle *)handle;
{
stabs_handle *h = (stabs_handle *)handle;
+ ir_graph *irg = get_entity_irg(ent);
ir_type *mtp, *rtp;
unsigned type_num;
int i, n, between_size;
ir_type *mtp, *rtp;
unsigned type_num;
int i, n, between_size;
+ be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
h->cur_ent = ent;
h->layout = layout;
h->cur_ent = ent;
h->layout = layout;
@@
-730,9
+753,10
@@
static void stabs_method_begin(dbg_handle *handle, ir_entity *ent, const be_stac
/**
* dump the stabs for a method end
*/
/**
* dump the stabs for a method end
*/
-static void stabs_method_end(dbg_handle *handle) {
+static void stabs_method_end(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
stabs_handle *h = (stabs_handle *)handle;
-
ir_entity
*ent = h->cur_ent;
+
const ir_entity
*ent = h->cur_ent;
const be_stack_layout_t *layout = h->layout;
const char *ld_name = get_entity_ld_name(ent);
int i, n, frame_size;
const be_stack_layout_t *layout = h->layout;
const char *ld_name = get_entity_ld_name(ent);
int i, n, frame_size;
@@
-777,7
+801,8
@@
static void stabs_method_end(dbg_handle *handle) {
/**
* dump types
*/
/**
* dump types
*/
-static void stabs_types(dbg_handle *handle) {
+static void stabs_types(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
/* allocate the zero for the void type */
stabs_handle *h = (stabs_handle *)handle;
/* allocate the zero for the void type */
@@
-789,7
+814,8
@@
static void stabs_types(dbg_handle *handle) {
/**
* dump a variable in the global type
*/
/**
* dump a variable in the global type
*/
-static void stabs_variable(dbg_handle *handle, ir_entity *ent) {
+static void stabs_variable(dbg_handle *handle, const ir_entity *ent)
+{
stabs_handle *h = (stabs_handle *)handle;
unsigned tp_num = get_type_number(h, get_entity_type(ent));
char buf[1024];
stabs_handle *h = (stabs_handle *)handle;
unsigned tp_num = get_type_number(h, get_entity_type(ent));
char buf[1024];
@@
-816,7
+842,8
@@
static void stabs_variable(dbg_handle *handle, ir_entity *ent) {
/**
* Close the stabs handler.
*/
/**
* Close the stabs handler.
*/
-static void stabs_close(dbg_handle *handle) {
+static void stabs_close(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
pmap_destroy(h->type_map);
free(h);
stabs_handle *h = (stabs_handle *)handle;
pmap_destroy(h->type_map);
free(h);
@@
-835,7
+862,8
@@
static const debug_ops stabs_ops = {
};
/* Opens a stabs handler */
};
/* Opens a stabs handler */
-dbg_handle *be_stabs_open(void) {
+static dbg_handle *be_stabs_open(void)
+{
stabs_handle *h = XMALLOCZ(stabs_handle);
h->base.ops = &stabs_ops;
stabs_handle *h = XMALLOCZ(stabs_handle);
h->base.ops = &stabs_ops;
@@
-844,9
+872,8
@@
dbg_handle *be_stabs_open(void) {
return &h->base;
}
return &h->base;
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_stabs);
void be_init_stabs(void)
{
be_register_dbgout_module("stabs", be_stabs_open);
}
void be_init_stabs(void)
{
be_register_dbgout_module("stabs", be_stabs_open);
}
-
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_stabs);