Simple Load/Store optimization
[libfirm] / ir / opt / tailrec.c
index c60eb61..356ee94 100644 (file)
@@ -24,7 +24,6 @@
 #include "irgraph_t.h"
 #include "ircons.h"
 #include "irflag.h"
-#include "tv.h"
 #include "firmstat.h"
 
 /**
@@ -47,15 +46,15 @@ static void collect_data(ir_node *node, void *env)
   ir_node *pred;
   ir_op *op;
 
-  switch (intern_get_irn_opcode(node)) {
+  switch (get_irn_opcode(node)) {
   case iro_Proj:
     pred = get_Proj_pred(node);
 
-    op = intern_get_irn_op(pred);
+    op = get_irn_op(pred);
     if (op == op_Proj) {
       ir_node *start = get_Proj_pred(pred);
 
-      if (intern_get_irn_op(start) == op_Start) {
+      if (get_irn_op(start) == op_Start) {
        if (get_Proj_proj(pred) == pn_Start_T_args) {
          /* found Proj(ProjT(Start)) */
          set_irn_link(node, data->proj_data);
@@ -162,7 +161,7 @@ static void do_opt_tail_rec(ir_graph *irg, ir_node *rets, int n_tail_calls)
   for (i = 1, p = rets; p; p = get_irn_link(p)) {
     ir_node *jmp;
 
-    switch_block(get_nodes_Block(p));
+    set_cur_block(get_nodes_block(p));
     jmp = new_Jmp();
 
     exchange(p, new_Bad());
@@ -190,6 +189,8 @@ static void do_opt_tail_rec(ir_graph *irg, ir_node *rets, int n_tail_calls)
     in[i] = get_Call_mem(calls);
     ++i;
   }
+  assert(i == n_tail_calls + 1);
+
   phis[0] = new_rd_Phi(NULL, irg, block, n_tail_calls + 1, in, mode_M);
 
   /* build the data phi's */
@@ -253,36 +254,34 @@ void opt_tail_rec_irg(ir_graph *irg)
   for (i = 0; i < n_preds; ++i) {
     ir_node *ret = get_Block_cfgpred(end_block, i);
     ir_node *proj_m, *call, *call_ptr;
-    tarval *tv;
     entity *ent;
     int j, n_ress;
     ir_node **ress;
 
     /* search all returns of a block */
-    if (intern_get_irn_op(ret) != op_Return)
+    if (get_irn_op(ret) != op_Return)
       continue;
 
     /* check, if it's a Return self() */
     proj_m = get_Return_mem(ret);
 
-    if (intern_get_irn_op(proj_m) != op_Proj)
+    if (get_irn_op(proj_m) != op_Proj)
       continue;
 
     call = get_Proj_pred(proj_m);
-    if (intern_get_irn_op(call) != op_Call)
+    if (get_irn_op(call) != op_Call)
       continue;
 
     /* check if it's a recursive call */
     call_ptr = get_Call_ptr(call);
 
-    if (intern_get_irn_op(call_ptr) != op_Const)
+    if (get_irn_op(call_ptr) != op_SymConst)
       continue;
 
-    tv = get_Const_tarval(call_ptr);
-    if (! tarval_is_entity(tv))
+    if (get_SymConst_kind(call_ptr) != symconst_addr_ent)
       continue;
 
-    ent = tarval_to_entity(tv);
+    ent = get_SymConst_entity(call_ptr);
     if (!ent || get_entity_irg(ent) != irg)
       continue;
 
@@ -295,14 +294,14 @@ void opt_tail_rec_irg(ir_graph *irg)
       ir_node *proj_proj;
       ir_node *irn;
 
-      if (intern_get_irn_op(proj) != op_Proj) {
+      if (get_irn_op(proj) != op_Proj) {
        /* not routed to a call */
        break;
       }
 
       proj_proj = get_Proj_pred(proj);
 
-      if (intern_get_irn_op(proj) != op_Proj) {
+      if (get_irn_op(proj) != op_Proj) {
        /* not routed to a call */
        break;
       }