overkill: add parser, allowing ; to separate commands :-)
[libfirm] / ir / opt / funccall.c
index 57238e2..0cc1637 100644 (file)
@@ -8,6 +8,10 @@
  * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "irnode_t.h"
 #include "irgraph_t.h"
 #include "irgmod.h"
@@ -38,7 +42,7 @@ static void collect_calls(ir_node *node, void *env)
 {
   env_t *ctx = env;
   ir_node *call, *ptr;
-  entity *ent;
+  ir_entity *ent;
   unsigned mode;
 
   if (is_Call(node)) {
@@ -47,7 +51,7 @@ static void collect_calls(ir_node *node, void *env)
     /* set the link to NULL for all non-const/pure calls */
     set_irn_link(call, NULL);
     ptr = get_Call_ptr(call);
-    if (get_irn_op(ptr) == op_SymConst && get_SymConst_kind(ptr) == symconst_addr_ent) {
+    if (is_SymConst(ptr) && get_SymConst_kind(ptr) == symconst_addr_ent) {
       ent = get_SymConst_entity(ptr);
 
       mode = get_entity_additional_properties(ent);
@@ -55,14 +59,14 @@ static void collect_calls(ir_node *node, void *env)
         return;
       ++ctx->n_calls_removed_SymConst;
     } else if (get_opt_closed_world() &&
-             is_Sel(ptr) &&
-                get_irg_callee_info_state(current_ir_graph) == irg_callee_info_consistent) {
+              is_Sel(ptr) &&
+              get_irg_callee_info_state(current_ir_graph) == irg_callee_info_consistent) {
       /* If all possible callees are const functions, we can remove the memory edge. */
       int i, n_callees = get_Call_n_callees(call);
       if (n_callees == 0)
         /* This is kind of strange:  dying code or a Call that will raise an exception
-              when executed as there is no implementation to call.  So better not
-              optimize. */
+           when executed as there is no implementation to call.  So better not
+           optimize. */
         return;
 
       /* note that const function are a subset of pure ones */
@@ -122,6 +126,9 @@ static void collect_calls(ir_node *node, void *env)
 static void fix_const_call_list(ir_graph *irg, ir_node *call_list, ir_node *proj_list) {
   ir_node *call, *next, *mem, *proj;
   int exc_changed = 0;
+  ir_graph *rem = current_ir_graph;
+
+  current_ir_graph = irg;
 
   /* First step: fix all calls by removing it's memory input.
      It's original memory input is preserved in their link fields. */
@@ -181,15 +188,16 @@ static void fix_const_call_list(ir_graph *irg, ir_node *call_list, ir_node *proj
 
   /* changes were done ... */
   set_irg_outs_inconsistent(irg);
-  set_irg_loopinfo_state(current_ir_graph, loopinfo_cf_inconsistent);
+  set_irg_loopinfo_state(irg, loopinfo_cf_inconsistent);
 
   if (exc_changed) {
     /* ... including exception edges */
     set_irg_doms_inconsistent(irg);
   }
+  current_ir_graph = rem;
 }  /* fix_call_list */
 
-
+#if 0
 /**
  * Check if a graph represents a const function.
  *
@@ -258,6 +266,7 @@ static int is_const_function(ir_graph *irg)
   }
   return 0;
 }  /* is_const_function */
+#endif
 
 /* a marker */
 static char _mark;
@@ -321,8 +330,8 @@ static unsigned _follow_mem(ir_node *node) {
       ptr = get_Call_ptr(node);
       if (get_irn_op(ptr) == op_SymConst &&
           get_SymConst_kind(ptr) == symconst_addr_ent) {
-        entity   *ent = get_SymConst_entity(ptr);
-        ir_graph *irg = get_entity_irg(ent);
+        ir_entity *ent = get_SymConst_entity(ptr);
+        ir_graph  *irg = get_entity_irg(ent);
 
         if (irg == current_ir_graph) {
           /* A recursive call. The did not mode depend on this call */