Commit 13291cce authored by Christian Würdig's avatar Christian Würdig
Browse files

fixed several bugs

changed name obstack handling
parent efb7a3f9
......@@ -544,6 +544,15 @@ static void *ia32_cg_init(FILE *F, const be_irg_t *birg) {
cg->opt.placecnst = 1;
cg->opt.immops = 1;
#ifndef NDEBUG
if (isa->name_obst_size) {
//printf("freed %d bytes from name obst\n", isa->name_obst_size);
isa->name_obst_size = 0;
obstack_free(isa->name_obst, NULL);
obstack_init(isa->name_obst);
}
#endif /* NDEBUG */
isa->num_codegens++;
if (isa->num_codegens > 1)
......@@ -598,6 +607,7 @@ static void *ia32_init(void) {
#ifndef NDEBUG
isa->name_obst = xcalloc(1, sizeof(*(isa->name_obst)));
obstack_init(isa->name_obst);
isa->name_obst_size = 0;
#endif /* NDEBUG */
inited = 1;
......@@ -614,6 +624,7 @@ static void ia32_done(void *self) {
ia32_isa_t *isa = self;
#ifndef NDEBUG
//printf("name obst size = %d bytes\n", isa->name_obst_size);
obstack_free(isa->name_obst, NULL);
#endif /* NDEBUG */
......@@ -647,7 +658,7 @@ const arch_register_class_t *ia32_get_reg_class_for_mode(const void *self, const
/**
* Produces the type which sits between the stack args and the locals on the stack.
* it will contain the return address and space to store the old base pointer.
* @return The Firm type modelling the ABI between type.
* @return The Firm type modeling the ABI between type.
*/
static ir_type *get_between_type(void)
{
......
......@@ -39,6 +39,7 @@ typedef struct _ia32_isa_t {
int num_codegens;
#ifndef NDEBUG
struct obstack *name_obst; /**< holds the original node names (for debugging) */
unsigned long name_obst_size;
#endif /* NDEBUG */
} ia32_isa_t;
......
......@@ -59,7 +59,7 @@ char *ia32_emit_binop(const ir_node *n) {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%3S, %s", n, get_ia32_cnst(n));
}
else {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%3S, %4S", n, n);
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%3S,%4S", n, n);
}
break;
case ia32_AddrModeS:
......@@ -139,11 +139,8 @@ char *ia32_emit_am(const ir_node *n) {
case 16:
obstack_printf(obst, "WORD PTR ");
break;
case 32:
obstack_printf(obst, "DWORD PTR ");
break;
default:
assert(0 && "unsupported mode size");
break;
}
}
......@@ -324,12 +321,19 @@ static int ia32_const_to_str(lc_appendable_t *app,
static int ia32_get_mode_suffix(lc_appendable_t *app,
const lc_arg_occ_t *occ, const lc_arg_value_t *arg)
{
ir_node *X = arg->v_ptr;
ir_node *X = arg->v_ptr;
ir_mode *mode = is_ia32_Lea(X) ? get_irn_mode(X) : get_ia32_ls_mode(X);
if (!X)
return lc_arg_append(app, occ, "(null)", 6);
return lc_appendable_chadd(app, get_mode_size_bits(get_irn_mode(X)) == 32 ? 's' : 'd');
if (mode_is_float(mode)) {
return lc_appendable_chadd(app, get_mode_size_bits(mode) == 32 ? 's' : 'd');
}
else {
return lc_appendable_chadd(app, mode_is_signed(mode) ? 's' : 'z');
}
}
/**
......@@ -801,13 +805,13 @@ void emit_be_IncSP(const ir_node *irn, emit_env_t *emit_env) {
void emit_be_SetSP(const ir_node *irn, emit_env_t *emit_env) {
FILE *F = emit_env->out;
lc_efprintf(ia32_get_arg_env(), F, "\tmov %1D,%3S\t\t\t/* restore SP */\n", irn, irn);
lc_efprintf(ia32_get_arg_env(), F, "\tmov %1D, %3S\t\t\t/* restore SP */\n", irn, irn);
}
void emit_be_Copy(const ir_node *irn, emit_env_t *emit_env) {
FILE *F = emit_env->out;
lc_efprintf(ia32_get_arg_env(), F, "\tmov %1D,%1S\t\t\t/* %+F */\n", irn, irn, irn);
lc_efprintf(ia32_get_arg_env(), F, "\tmov %1D, %1S\t\t\t/* %+F */\n", irn, irn, irn);
}
void emit_be_Perm(const ir_node *irn, emit_env_t *emit_env) {
......
......@@ -381,7 +381,14 @@ $arch = "ia32";
"comment" => "construct Load: Load(ptr, mem) = LD ptr -> reg",
"cmp_attr" => " return ia32_compare_immop_attr(attr_a, attr_b);\n",
"reg_req" => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
"emit" => '. mov %D1, %ia32_emit_am\t\t\t/* Load((%A1)) -> %D1 */'
"emit" =>
' if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
4. mov%Mx %D1, %ia32_emit_am\t\t\t/* Load((%A1)) -> %D1 */
}
else {
4. mov %D1, %ia32_emit_am\t\t\t/* Load((%A1)) -> %D1 */
}
'
},
"Store" => {
......
......@@ -159,10 +159,16 @@ static char *gen_fp_known_const(ir_mode *mode, ia32_known_const_t kct) {
* Prints the old node name on cg obst and returns a pointer to it.
*/
const char *get_old_node_name(ia32_transform_env_t *env) {
static int name_cnt = 0;
ia32_isa_t *isa = (ia32_isa_t *)env->cg->arch_env->isa;
lc_eoprintf(firm_get_arg_env(), isa->name_obst, "%+F", env->irn);
obstack_1grow(isa->name_obst, 0);
isa->name_obst_size += obstack_object_size(isa->name_obst);
name_cnt++;
if (name_cnt % 1024 == 0) {
printf("name obst size reached %d bytes after %d nodes\n", isa->name_obst_size, name_cnt);
}
return obstack_finish(isa->name_obst);
}
#endif /* NDEBUG */
......@@ -1368,6 +1374,7 @@ static ir_node *gen_Mux(ia32_transform_env_t *env) {
}
#if 0
/**
* Checks of we can omit the Int -> Int Conv
*/
......@@ -1378,15 +1385,6 @@ static int ignore_int_conv(ir_mode *src_mode, ir_mode *tgt_mode) {
int src_bits = get_mode_size_bits(src_mode);
int tgt_bits = get_mode_size_bits(tgt_mode);
/* mode_P is already converted in mode_Is */
#if 0
/* ignore mode_P -> mode_Is Convs */
ignore = ((src_mode == mode_P) && (tgt_mode == mode_Is)) ? 1 : 0;
/* ignore mode_Is -> mode_P Convs */
ignore = ((src_mode == mode_Is) && (tgt_mode == mode_P)) ? 1 : 0;
#endif
/* ignore Convs small -> big if same signedness */
ignore = (src_sign == tgt_sign) && (src_bits < tgt_bits) ? 1 : ignore;
......@@ -1398,6 +1396,7 @@ static int ignore_int_conv(ir_mode *src_mode, ir_mode *tgt_mode) {
return ignore;
}
#endif /* if 0 */
/**
* Transforms a Conv node.
......@@ -1444,16 +1443,8 @@ static ir_node *gen_Conv(ia32_transform_env_t *env, ir_node *op) {
}
else {
/* ... to int */
DB((mod, LEVEL_1, "create Conv(int, int) ..."));
/* check if we can omit the Conv */
if (ignore_int_conv(src_mode, tgt_mode)) {
DB((mod, LEVEL_1, "omitted Conv ..."));
edges_reroute(env->irn, op, irg);
}
else {
new_op = new_rd_ia32_Conv_I2I(dbg, irg, block, noreg, noreg, op, nomem, mode_T);
}
DB((mod, LEVEL_1, "omitting Conv(Int, Int) ..."));
edges_reroute(env->irn, op, irg);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment