bugfixes for am_offs changes
authorMatthias Braun <matze@braunis.de>
Fri, 8 Sep 2006 12:14:00 +0000 (12:14 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 8 Sep 2006 12:14:00 +0000 (12:14 +0000)
ir/be/ia32/bearch_ia32.c
ir/be/ia32/ia32_new_nodes.c
ir/be/ia32/ia32_transform.c

index 077c866..1c948ea 100644 (file)
@@ -298,7 +298,7 @@ static void ia32_set_frame_offset(const void *self, ir_node *irn, int bias) {
        if (get_ia32_frame_ent(irn)) {
                ia32_am_flavour_t am_flav = get_ia32_am_flavour(irn);
 
-               /* Pop nodes modify the stack pointer before reading the destination
+               /* Pop nodes modify the stack pointer before calculating the destination
                 * address, so fix this here
                 */
                if(is_ia32_Pop(irn)) {
@@ -311,8 +311,7 @@ static void ia32_set_frame_offset(const void *self, ir_node *irn, int bias) {
 
                if (get_ia32_op_type(irn) == ia32_Normal) {
                        set_ia32_cnst(irn, buf);
-               }
-               else {
+               } else {
                        add_ia32_am_offs(irn, buf);
                        am_flav |= ia32_O;
                        set_ia32_am_flavour(irn, am_flav);
@@ -327,7 +326,7 @@ static int ia32_get_sp_bias(const void *self, const ir_node *irn) {
 
                if(is_ia32_Push(pred) && proj == 0)
                        return 4;
-               else if(is_ia32_Pop(pred) && proj == 1)
+               if(is_ia32_Pop(pred) && proj == 1)
                        return -4;
        }
 
index ba1e3a6..1c1aaea 100644 (file)
@@ -542,14 +542,13 @@ void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour) {
  */
 char *get_ia32_am_offs(const ir_node *node) {
        ia32_attr_t *attr = get_ia32_attr(node);
-       char        *res  = NULL;
+       static char res[64];
 
        if (! attr->am_offs) {
                return NULL;
        }
 
-       res = obstack_alloc(get_irg_obstack(get_irn_irg(node)), 64);
-       snprintf(res, 64, "%+ld", attr->am_offs);
+       snprintf(res, sizeof(res), "%+ld", attr->am_offs);
 
        return res;
 }
@@ -572,12 +571,12 @@ static void extend_ia32_am_offs(ir_node *node, char *offset, char op) {
        if (! offset || strlen(offset) < 1)
                return;
 
-       sscanf(offset, "%d", &o);
+       assert(sscanf(offset, "%d", &o) == 1);
 
        if (op == '-')
                attr->am_offs -= o;
        else if (op == '+')
-               attr->am_offs -= o;
+               attr->am_offs += o;
        else
                assert(0);
 }
index e35e71c..4540b6f 100644 (file)
@@ -1472,7 +1472,7 @@ static ir_node *gen_Store(ia32_transform_env_t *env) {
 
        /* base is an constant address */
        if (is_imm) {
-               if (get_ia32_immop_type(ptr) == ia32_ImmSymConst) {
+               if (get_ia32_op_type(ptr) == ia32_SymConst) {
                        set_ia32_am_sc(new_op, get_ia32_id_cnst(ptr));
                        am_flav = ia32_am_N;
                }