added DBG_OPT_LEA( to report Lea craetion to the firm statistic module
[libfirm] / ir / be / ia32 / ia32_optimize.c
index 1062a4c..6a88bda 100644 (file)
 #include "gen_ia32_regalloc_if.h"     /* the generated interface (register type and class defenitions) */
 #include "ia32_transform.h"
 
+/*----*/
+
+#include "irhooks.h"
+#include "dbginfo_t.h"
+#include "firmstat.h"
+
+/**
+ * Merge the debug info due to a LEA creation.
+ *
+ * @param oldn  the node
+ * @param n     the new constant holding the value
+ */
+#define DBG_OPT_LEA(oldn, n)                                \
+  do {                                                         \
+         hook_merge_nodes(&n, 1, &oldn, 1, FS_BE_IA32_LEA);      \
+    __dbg_info_merge_pair(n, oldn, dbg_backend);                 \
+  } while(0)
+
+
 #undef is_NoMem
 #define is_NoMem(irn) (get_irn_op(irn) == op_NoMem)
 
@@ -120,7 +139,7 @@ static ir_type *get_prim_type(pmap *types, ir_mode *mode)
 static entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst)
 {
        tarval *tv    = get_Const_tarval(cnst);
-       pmap_entry *e = pmap_find(cg->tv_ent, tv);
+       pmap_entry *e = pmap_find(cg->isa->tv_ent, tv);
        entity *res;
        ir_graph *rem;
 
@@ -128,7 +147,7 @@ static entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst)
                ir_mode *mode = get_irn_mode(cnst);
                ir_type *tp = get_Const_type(cnst);
                if (tp == firm_unknown_type)
-                       tp = get_prim_type(cg->types, mode);
+                       tp = get_prim_type(cg->isa->types, mode);
 
                res = new_entity(get_glob_type(), unique_id("ia32FloatCnst_%u"), tp);
 
@@ -143,6 +162,8 @@ static entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst)
                current_ir_graph = get_const_code_irg();
                set_atomic_ent_value(res, new_Const_type(tv, tp));
                current_ir_graph = rem;
+
+               pmap_insert(cg->isa->tv_ent, tv, res);
        }
        else
                res = e->value;
@@ -405,17 +426,6 @@ static void ia32_optimize_IncSP(ir_node *irn, ia32_code_gen_t *cg) {
        ir_node *prev = be_get_IncSP_pred(irn);
        int real_uses = get_irn_n_edges(prev);
 
-       if (real_uses != 1) {
-               /*
-                  This is a hack that should be removed if be_abi_fix_stack_nodes()
-                  is fixed. Currently it leaves some IncSP's outside the chain ...
-                  The previous IncSp is NOT our prev, but directly scheduled before ...
-                        Impossible in a bug-free implementation :-)
-                */
-               prev = sched_prev(irn);
-               real_uses = 1;
-       }
-
        if (be_is_IncSP(prev) && real_uses == 1) {
                /* first IncSP has only one IncSP user, kill the first one */
                unsigned       prev_offs = be_get_IncSP_offset(prev);
@@ -894,6 +904,9 @@ static ir_node *fold_addr(ia32_code_gen_t *cg, ir_node *irn, ir_node *noreg) {
 
                DBG((mod, LEVEL_1, "\tLEA [%+F + %+F * %d + %s]\n", base, index, scale, get_ia32_am_offs(res)));
 
+               /* we will exchange it, report here before the Proj is created */
+               DBG_OPT_LEA(irn, res);
+
                /* get the result Proj of the Add/Sub */
                irn = get_res_proj(irn);