fix sse/x87 fixup code added at wrong places
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
index 1d5f8ab..6f31323 100644 (file)
@@ -149,7 +149,7 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                        }
                                        fputs(get_entity_name(attr->symconst), F);
                                }
-                               if(attr->offset != 0) {
+                               if(attr->offset != 0 || attr->symconst == NULL) {
                                        if(attr->offset > 0 && attr->symconst != NULL) {
                                                fputc('+', F);
                                        }
@@ -157,6 +157,28 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                }
                        }
 
+                       {
+                               const ia32_attr_t *attr = get_ia32_attr_const(n);
+
+                               if(attr->am_sc != NULL || attr->am_offs != 0)
+                                       fputs(" [", F);
+
+                               if(attr->am_sc != NULL) {
+                                       if(attr->data.am_sc_sign) {
+                                               fputc('-', F);
+                                       }
+                                       fputs(get_entity_name(attr->am_sc), F);
+                               }
+                               if(attr->am_offs != 0) {
+                                       if(attr->am_offs > 0 && attr->am_sc != NULL) {
+                                               fputc('+', F);
+                                       }
+                                       fprintf(F, "%d", attr->am_offs);
+                               }
+
+                               if(attr->am_sc != NULL || attr->am_offs != 0)
+                                       fputc(']', F);
+                       }
                        break;
 
                case dump_node_nodeattr_txt:
@@ -1174,6 +1196,16 @@ int get_ia32_out_regnr(const ir_node *node, int pos) {
        return arch_register_get_index(attr->slots[pos]);
 }
 
+void ia32_swap_left_right(ir_node *node)
+{
+       ir_node *left  = get_irn_n(node, 2);
+       ir_node *right = get_irn_n(node, 3);
+       assert(is_ia32_commutative(node));
+       set_irn_n(node, 2, right);
+       set_irn_n(node, 3, left);
+       set_ia32_pncode(node, get_inversed_pnc(get_ia32_pncode(node)));
+}
+
 /**
  * Returns the OUT register at position pos.
  */
@@ -1223,6 +1255,7 @@ init_ia32_x87_attributes(ir_node *res)
        ia32_attr_t *attr  = get_ia32_attr(res);
        attr->attr_type   |= IA32_ATTR_ia32_x87_attr_t;
 #endif
+       ia32_current_cg->do_x87_sim = 1;
 }
 
 void
@@ -1240,7 +1273,7 @@ init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
 {
        ia32_immediate_attr_t *attr = get_irn_generic_attr(res);
 
-#ifndef DEBUG
+#ifndef NDEBUG
        attr->attr.attr_type   |= IA32_ATTR_ia32_immediate_attr_t;
 #endif
        attr->symconst             = symconst;
@@ -1293,8 +1326,14 @@ int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
            || a->ls_mode != b->ls_mode)
                return 1;
 
+       /* nodes with not yet assigned entities shouldn't be CSEd (important for
+        * unsigned int -> double conversions */
+       if(a->data.use_frame && a->frame_ent == NULL)
+               return 1;
+       if(b->data.use_frame && b->frame_ent == NULL)
+               return 1;
+
        if (a->data.use_frame != b->data.use_frame
-           || a->data.use_frame != b->data.use_frame
            || a->frame_ent != b->frame_ent)
                return 1;