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

fixed several bugs

parent 00aeb91b
......@@ -349,8 +349,10 @@ static void transform_to_Load(ia32_transform_env_t *env) {
ir_mode *mode = env->mode;
ir_node *noreg = ia32_new_NoReg_gp(env->cg);
ir_node *nomem = new_rd_NoMem(env->irg);
ir_node *new_op, *proj;
ir_node *sched_point = NULL;
ir_node *ptr = get_irn_n(irn, 0);
ir_node *mem = be_is_Reload(irn) ? get_irn_n(irn, 1) : nomem;
ir_node *new_op, *proj;
const arch_register_t *reg;
if (sched_is_scheduled(irn)) {
......@@ -358,10 +360,10 @@ static void transform_to_Load(ia32_transform_env_t *env) {
}
if (mode_is_float(mode)) {
new_op = new_rd_ia32_fLoad(env->dbg, env->irg, env->block, get_irn_n(irn, 0), noreg, nomem, mode_T);
new_op = new_rd_ia32_fLoad(env->dbg, env->irg, env->block, ptr, noreg, mem, mode_T);
}
else {
new_op = new_rd_ia32_Load(env->dbg, env->irg, env->block, get_irn_n(irn, 0), noreg, nomem, mode_T);
new_op = new_rd_ia32_Load(env->dbg, env->irg, env->block, ptr, noreg, mem, mode_T);
}
set_ia32_am_support(new_op, ia32_am_Source);
......@@ -658,7 +660,7 @@ void ia32_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t *ab
int i, ignore;
ir_mode **modes;
const arch_register_t *reg;
be_abi_call_flags_t call_flags = { 0, 0, 1, 0, 1 };
be_abi_call_flags_t call_flags = { 0, 0, 0, 0, 1 };
/* get the between type and the frame pointer save entity */
between_type = get_between_type();
......
......@@ -43,6 +43,9 @@ static const arch_env_t *arch_env = NULL;
char *ia32_emit_binop(const ir_node *n) {
static char *buf = NULL;
/* verify that this function is never called on non-AM supporting operations */
assert(get_ia32_am_support(n) != ia32_am_None && "emit binop expects addressmode support");
if (! buf) {
buf = xcalloc(1, SNPRINTF_BUF_LEN);
}
......@@ -53,27 +56,22 @@ char *ia32_emit_binop(const ir_node *n) {
switch(get_ia32_op_type(n)) {
case ia32_Normal:
if (get_ia32_cnst(n)) {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%1D, %s", n, get_ia32_cnst(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, "%1D, %4S", n, n);
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%3S, %4S", n, n);
}
break;
case ia32_AddrModeS:
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%1D, %s", n, ia32_emit_am(n));
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%4S, %s", n, ia32_emit_am(n));
break;
case ia32_AddrModeD:
if (get_ia32_cnst(n)) {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%s, %s", ia32_emit_am(n), get_ia32_cnst(n));
}
else {
if (is_ia32_St(n)) {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%s, %3S", ia32_emit_am(n), n);
}
else {
lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%s, %4S", ia32_emit_am(n), n);
}
}
break;
default:
assert(0 && "unsupported op type");
......@@ -488,8 +486,8 @@ static void finish_CondJmp(FILE *F, const ir_node *irn) {
static void emit_ia32_CondJmp(const ir_node *irn, emit_env_t *env) {
FILE *F = env->out;
lc_efprintf(ia32_get_arg_env(), F, "\tcmp %2S, %1S\t\t\t/* CondJmp(%+F, %+F) */\n", irn, irn,
get_irn_n(irn, 0), get_irn_n(irn, 1));
lc_efprintf(ia32_get_arg_env(), F, "\tcmp %s\t\t\t/* CondJmp(%+F, %+F) */\n",
ia32_emit_binop(irn), get_irn_n(irn, 0), get_irn_n(irn, 1));
finish_CondJmp(F, irn);
}
......@@ -499,7 +497,8 @@ static void emit_ia32_CondJmp(const ir_node *irn, emit_env_t *env) {
void emit_ia32_CondJmp_i(const ir_node *irn, emit_env_t *env) {
FILE *F = env->out;
lc_efprintf(ia32_get_arg_env(), F, "\tcmp %C, %1S\t\t\t/* CondJmp_i(%+F) */\n", irn, irn, get_irn_n(irn, 0));
lc_efprintf(ia32_get_arg_env(), F, "\tcmp %s\t\t\t/* CondJmp_i(%+F) */\n",
ia32_emit_binop(irn), get_irn_n(irn, 0));
finish_CondJmp(F, irn);
}
......@@ -624,7 +623,7 @@ void emit_ia32_SwitchJmp(const ir_node *irn, emit_env_t *emit_env) {
if (tbl.num_branches > 1) {
/* create table */
lc_efprintf(env, F, "\tjmp *%s(,%1S,4)\t\t/* get jump table entry as target */\n", tbl.label, irn);
lc_efprintf(env, F, "\tjmp [%1S*4+%s]\t\t/* get jump table entry as target */\n", irn, tbl.label);
fprintf(F, "\t.section\t.rodata\t\t/* start jump table */\n");
fprintf(F, "\t.align 4\n");
......
......@@ -351,7 +351,7 @@ $arch = "ia32";
"op_flags" => "L|X|Y",
"comment" => "construct switch",
"cmp_attr" => " return ia32_compare_immop_attr(attr_a, attr_b);\n",
"reg_req" => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "none" ] },
"reg_req" => { "in" => [ "gp" ], "out" => [ "none" ] },
},
"Const" => {
......
......@@ -1213,9 +1213,10 @@ static ir_node *gen_Cond(ia32_transform_env_t *env) {
}
set_ia32_pncode(res, get_Proj_proj(sel));
set_ia32_am_support(res, ia32_am_Source);
}
else {
res = new_rd_ia32_SwitchJmp(dbg, irg, block, noreg, noreg, sel, nomem, mode_T);
res = new_rd_ia32_SwitchJmp(dbg, irg, block, sel, mode_T);
set_ia32_pncode(res, get_Cond_defaultProj(node));
}
......
Supports Markdown
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