Fixed typo
[libfirm] / ir / ana / cgana.c
index 8feffcc..0f6528c 100644 (file)
@@ -19,8 +19,8 @@
 #include "irgwalk.h"
 #include "ircons.h"
 #include "irgmod.h"
-#include "xprintf.h"
 #include "irnode.h"
+#include "irflag.h"
 
 #include "dbginfo_t.h"
 
@@ -67,7 +67,7 @@ entity *get_inherited_methods_implementation(entity *inh_meth) {
   assert(addr && "constant entity without value");
 
   if (get_irn_op(addr) == op_Const) {
-    impl_meth = get_tv_entity(get_Const_tarval(addr));
+    impl_meth = tarval_to_entity(get_Const_tarval(addr));
   }
 
   assert(!impl_meth || get_entity_peculiarity(impl_meth) == existent);
@@ -157,16 +157,16 @@ static entity ** get_impl_methods(entity * method) {
 /* debug makros used in sel_methods_walker */
 #define SIZ(x)    sizeof(x)/sizeof((x)[0])
 
-#define DBG_OPT_NORMALIZE                                     \
+#define DBG_OPT_NORMALIZE                                                      \
          __dbg_info_merge_pair(new_node, node, dbg_const_eval)
-#define DBG_OPT_POLY_ALLOC                                               \
-  do {                                                       \
-       ir_node *ons[2];                                         \
-       ons[0] = node;                                           \
-       ons[1] = skip_Proj(get_Sel_ptr(node));                     \
+#define DBG_OPT_POLY_ALLOC                                                     \
+  do {                                                                         \
+       ir_node *ons[2];                                                       \
+       ons[0] = node;                                                         \
+       ons[1] = skip_Proj(get_Sel_ptr(node));                                 \
        __dbg_info_merge_sets(&new_node, 1, ons, SIZ(ons), dbg_rem_poly_call); \
      } while(0)
-#define DBG_OPT_POLY \
+#define DBG_OPT_POLY                                                           \
          __dbg_info_merge_pair(new_node, node, dbg_rem_poly_call)
 
 
@@ -178,12 +178,12 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
       pmap_entry * entry = pmap_find(ldname_map, (void *) get_SymConst_ptrinfo(node));
       if (entry != NULL) { /* Method is declared in the compiled code */
        entity * ent = entry->value;
-       if (get_entity_visibility(ent) != external_allocated) { /* Meth. is defined */
+       if (get_opt_normalize() && (get_entity_visibility(ent) != external_allocated)) { /* Meth. is defined */
          ir_node *new_node;
          assert(get_entity_irg(ent));
          set_irg_current_block(current_ir_graph, get_nodes_Block(node));
          new_node = new_d_Const(get_irn_dbg_info(node),
-                                mode_P, tarval_P_from_entity(ent));       DBG_OPT_NORMALIZE;
+                                mode_P, new_tarval_from_entity(ent, mode_P));       DBG_OPT_NORMALIZE;
          exchange(node, new_node);
        }
       }
@@ -191,11 +191,14 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
   } else if (get_irn_op(node) == op_Sel &&
             is_method_type(get_entity_type(get_Sel_entity(node)))) {
     entity * ent = get_Sel_entity(node);
-    if (get_irn_op(skip_Proj(get_Sel_ptr(node))) == op_Alloc) {
+    if (get_optimize() && get_opt_dyn_meth_dispatch() &&
+       (get_irn_op(skip_Proj(get_Sel_ptr(node))) == op_Alloc)) {
       ir_node *new_node;
       /* We know which method will be called, no dispatch necessary. */
       assert(get_entity_peculiarity(ent) != description);
       set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+      /* @@@ Is this correct?? Alloc could reference a subtype of the owner
+        of Sel that overwrites the method referenced in Sel. */
       new_node = copy_const_value(get_atomic_ent_value(ent));              DBG_OPT_POLY_ALLOC;
       exchange (node, new_node);
     } else {
@@ -215,9 +218,9 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
           fuer die es keine Implementierung gibt. */
        if (get_entity_peculiarity(ent) == description) {
          /* @@@ GL Methode um Fehler anzuzeigen aufrufen! */
-         xprintf("WARNING: Calling method description %I in method %I which has "
-                 "no implementation!\n", get_entity_ident(ent),
-                 get_entity_ident(get_irg_ent(current_ir_graph)));
+         printf("WARNING: Calling method description %s in method %s which has "
+                 "no implementation!\n", id_to_str(get_entity_ident(ent)),
+                 id_to_str(get_entity_ident(get_irg_ent(current_ir_graph))));
        } else {
          exchange(node, new_Bad());
        }
@@ -236,7 +239,8 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
        printf("\n");
 #endif
 
-       if (ARR_LEN(arr) == 1 && arr[0] != NULL) {
+       if (get_optimize() && get_opt_dyn_meth_dispatch() &&
+           (ARR_LEN(arr) == 1 && arr[0] != NULL)) {
          ir_node *new_node;
          /* Die Sel-Operation kann immer nur einen Wert auf eine
           * interne Methode zurückgeben. Wir können daher die
@@ -393,7 +397,7 @@ static void callee_ana_node(ir_node * node, eset * methods) {
 
   case iro_Const: {
     /* interne Methode */
-    entity * ent = get_Const_tarval(node)->u.P.ent;
+    entity * ent = tarval_to_entity(get_Const_tarval(node));
     assert(ent && is_method_type(get_entity_type(ent)));
     if (get_entity_visibility(ent) != external_allocated) {
       assert(get_entity_irg(ent));
@@ -565,9 +569,11 @@ static void free_mark(ir_node * node, eset * set) {
     break;
   case iro_Const: {
     tarval * val = get_Const_tarval(node);
-    entity * ent = val->u.P.ent;
-    if (ent != NULL && is_method_type(get_entity_type(ent))) {
-      eset_insert(set, ent);
+    if (tarval_is_entity(val)) { /* filter null pointer */
+      entity * ent = tarval_to_entity(val);
+      if (is_method_type(get_entity_type(ent))) {
+        eset_insert(set, ent);
+      }
     }
     break;
   }