Factorise creating Conv_I2Is.
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
index 4b3012a..206bf3f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <stdlib.h>
 
+#include "irargs_t.h"
 #include "irprog_t.h"
 #include "irgraph_t.h"
 #include "irnode_t.h"
@@ -49,6 +50,7 @@
 #include "../beinfo.h"
 
 #include "bearch_ia32_t.h"
+#include "ia32_common_transform.h"
 #include "ia32_nodes_attr.h"
 #include "ia32_new_nodes.h"
 #include "gen_ia32_regalloc_if.h"
@@ -863,15 +865,27 @@ void set_ia32_exc_label_id(ir_node *node, ir_label_t id) {
 /**
  * Returns the name of the original ir node.
  */
-const char *get_ia32_orig_node(const ir_node *node) {
+const char *get_ia32_orig_node(const ir_node *node)
+{
        const ia32_attr_t *attr = get_ia32_attr_const(node);
        return attr->orig_node;
 }
 
+static const char *ia32_get_old_node_name(const ir_node *irn)
+{
+       struct obstack *obst = env_cg->isa->name_obst;
+
+       lc_eoprintf(firm_get_arg_env(), obst, "%+F", irn);
+       obstack_1grow(obst, 0);
+       return obstack_finish(obst);
+}
+
 /**
  * Sets the name of the original ir node.
  */
-void set_ia32_orig_node(ir_node *node, const char *name) {
+void set_ia32_orig_node(ir_node *node, const ir_node *old)
+{
+       const char  *name = ia32_get_old_node_name(old);
        ia32_attr_t *attr = get_ia32_attr(node);
        attr->orig_node   = name;
 }
@@ -982,7 +996,7 @@ init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
        attr->offset   = offset;
 }
 
-void init_ia32_call_attributes(ir_node *const res, unsigned const pop, ir_type *const call_tp)
+void init_ia32_call_attributes(ir_node* res, unsigned pop, ir_type* call_tp)
 {
        ia32_call_attr_t *attr = get_irn_generic_attr(res);
 
@@ -1024,7 +1038,8 @@ init_ia32_condcode_attributes(ir_node *res, long pnc) {
  ***************************************************************************************/
 
 /* default compare operation to compare attributes */
-int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
+int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b)
+{
        if (a->data.tp != b->data.tp)
                return 1;
 
@@ -1046,9 +1061,6 @@ int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
            || a->frame_ent != b->frame_ent)
                return 1;
 
-       if (a->data.tp != b->data.tp)
-               return 1;
-
        if (a->data.has_except_label != b->data.has_except_label)
                return 1;