updated Header
[libfirm] / ir / opt / opt_polymorphy.c
index b2e9716..9fae645 100644 (file)
@@ -1,13 +1,34 @@
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
 /*
  * Project:     libFIRM
  * File name:   ir/opt/opt_polymorphy
  * Purpose:     Optimize polymorphic Sel nodes.
- * Author:
+ * Author:      Goetz Lindenmaier, Michael Beck
  * Created:
  * CVS-ID:      $Id$
  * Copyright:   (c) 2005 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "irprog_t.h"
 #include "entity_t.h"
@@ -60,7 +81,7 @@ static ir_type *get_dynamic_type(ir_node *ptr) {
 
   /* skip Cast and Confirm nodes */
   for (;;) {
-    opcode code = get_irn_opcode(ptr);
+    ir_opcode code = get_irn_opcode(ptr);
 
     switch (code) {
     case iro_Cast:
@@ -79,10 +100,10 @@ static ir_type *get_dynamic_type(ir_node *ptr) {
 }
 
 /**
- * Check, if a entity is final, i.e. is not anymore overridden.
+ * Check, if an entity is final, i.e. is not anymore overridden.
  */
-static is_final_ent(entity *ent) {
-  if (get_entity_final(ent)) {
+static int is_final_ent(ir_entity *ent) {
+  if (is_entity_final(ent)) {
     /* not possible to override this entity. */
     return 1;
   }
@@ -99,9 +120,9 @@ static is_final_ent(entity *ent) {
  */
 ir_node *transform_node_Sel(ir_node *node)
 {
-  ir_node *new_node, *ptr;
-  ir_type *dyn_tp;
-  entity  *ent = get_Sel_entity(node);
+  ir_node   *new_node, *ptr;
+  ir_type   *dyn_tp;
+  ir_entity *ent = get_Sel_entity(node);
 
   if (get_irp_phase_state() == phase_building) return node;
 
@@ -134,7 +155,7 @@ ir_node *transform_node_Sel(ir_node *node)
   dyn_tp = get_dynamic_type(ptr);  /* The runtime type of ptr. */
 
   if (dyn_tp != firm_unknown_type) {
-    entity *called_ent;
+    ir_entity *called_ent;
     ir_node *rem_block;
 
     /* We know which method will be called, no dispatch necessary. */
@@ -165,7 +186,7 @@ ir_node *transform_node_Sel(ir_node *node)
 ir_node *transform_node_Load(ir_node *n)
 {
   ir_node *field_ptr, *new_node, *ptr;
-  entity  *ent;
+  ir_entity *ent;
   ir_type *dyn_tp;
 
   if (!(get_opt_optimize() && get_opt_dyn_meth_dispatch()))
@@ -182,7 +203,7 @@ ir_node *transform_node_Load(ir_node *n)
 
   /* If the entity is a leave in the inheritance tree,
      we can replace the Sel by a constant. */
-  if ((get_irp_phase_state() != phase_building) && (get_entity_n_overwrittenby(ent) == 0)) {
+  if ((get_irp_phase_state() != phase_building) && is_final_ent(ent)) {
     new_node = copy_const_value(get_irn_dbg_info(n), get_atomic_ent_value(ent));
     DBG_OPT_POLY(field_ptr, new_node);
 
@@ -194,7 +215,7 @@ ir_node *transform_node_Load(ir_node *n)
   dyn_tp = get_dynamic_type(ptr);  /* The runtime type of ptr. */
 
   if (dyn_tp != firm_unknown_type) {
-    entity *loaded_ent;
+    ir_entity *loaded_ent;
 
     /* We know which method will be called, no dispatch necessary. */
     loaded_ent = resolve_ent_polymorphy(dyn_tp, ent);