fixed precedence constraint
[libfirm] / ir / be / beabi.c
index d515e3b..8b65cca 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+# include <config.h>
 #endif
 
 #include "obst.h"
@@ -660,19 +660,23 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp, i
 
        /* Set the register constraints of the results. */
        for (i = 0; res_projs[i]; ++i) {
-               ir_node *irn = res_projs[i];
-               int     proj = get_Proj_proj(irn);
+               int pn = get_Proj_proj(res_projs[i]);
 
                /* Correct Proj number since it has been adjusted! (see above) */
-               const be_abi_call_arg_t *arg = get_call_arg(call, 1, proj - pn_Call_max);
+               const be_abi_call_arg_t *arg = get_call_arg(call, 1, pn - pn_Call_max);
 
+               /* Matze: we need the information about the real mode for later
+                * transforms (signed/unsigend compares, stores...), so leave the fixup
+                * for the backend transform phase... */
+#if 0
                /* correct mode */
                const arch_register_class_t *cls = arch_register_get_class(arg->reg);
                ir_mode *mode = arch_register_class_mode(cls);
                set_irn_mode(irn, mode);
+#endif
 
                assert(arg->in_reg);
-               be_set_constr_single_reg(low_call, BE_OUT_POS(proj), arg->reg);
+               be_set_constr_single_reg(low_call, BE_OUT_POS(pn), arg->reg);
        }
        obstack_free(obst, in);
        exchange(irn, low_call);
@@ -871,8 +875,9 @@ static ir_node *adjust_free(be_abi_irg_t *env, ir_node *free, ir_node *curr_sp)
 {
        ir_node *block;
        ir_graph *irg;
-       ir_node *addsp, *mem, *res, *size;
+       ir_node *subsp, *mem, *res, *size, *sync;
        ir_type *type;
+       ir_node *in[2];
 
        if (get_Free_where(free) != stack_alloc) {
                assert(0);
@@ -897,12 +902,21 @@ static ir_node *adjust_free(be_abi_irg_t *env, ir_node *free, ir_node *curr_sp)
        /* The stack pointer will be modified in an unknown manner.
           We cannot omit it. */
        env->call->flags.bits.try_omit_fp = 0;
-       addsp = be_new_SubSP(env->isa->sp, irg, block, curr_sp, size);
+       subsp = be_new_SubSP(env->isa->sp, irg, block, curr_sp, size);
+
+       mem = new_r_Proj(irg, block, subsp, mode_M, pn_be_SubSP_M);
+       res = new_r_Proj(irg, block, subsp, mode_P_data, pn_be_SubSP_res);
+
+       /* we need to sync the memory */
+       in[0] = get_Free_mem(free);
+       in[1] = mem;
+       sync = new_r_Sync(irg, block, 2, in);
 
-       mem = new_r_Proj(irg, block, addsp, mode_M, pn_be_SubSP_M);
-       res = new_r_Proj(irg, block, addsp, mode_P_data, pn_be_SubSP_res);
+       /* and make the AddSP dependent on the former memory */
+       add_irn_dep(subsp, get_Free_mem(free));
 
-       exchange(free, mem);
+       /* kill the free */
+       exchange(free, sync);
        curr_sp = res;
 
        return curr_sp;