rename tarval to ir_tarval
[libfirm] / ir / opt / opt_polymorphy.c
index a0902b7..cb0b9ee 100644 (file)
@@ -27,6 +27,7 @@
  */
 #include "config.h"
 
+#include "opt_polymorphy.h"
 #include "iroptimize.h"
 #include "irprog_t.h"
 #include "entity_t.h"
@@ -45,7 +46,8 @@
  *
  * The default implementation hecks for Alloc nodes only.
  */
-ir_type *default_firm_get_Alloc(ir_node *n) {
+static ir_type *default_firm_get_Alloc(ir_node *n)
+{
        n = skip_Proj(n);
        if (is_Alloc(n)) {
                return get_Alloc_type(n);
@@ -57,7 +59,8 @@ ir_type *default_firm_get_Alloc(ir_node *n) {
 static get_Alloc_func firm_get_Alloc = default_firm_get_Alloc;
 
 /** Set a new get_Alloc_func and returns the old one. */
-get_Alloc_func firm_set_Alloc_func(get_Alloc_func newf) {
+get_Alloc_func firm_set_Alloc_func(get_Alloc_func newf)
+{
        get_Alloc_func old = firm_get_Alloc;
        firm_get_Alloc = newf;
        return old;
@@ -72,7 +75,8 @@ get_Alloc_func firm_set_Alloc_func(get_Alloc_func newf) {
  * If we find a dynamic type this means that the pointer always points
  * to an object of this type during runtime.   We resolved polymorphy.
  */
-static ir_type *get_dynamic_type(ir_node *ptr) {
+static ir_type *get_dynamic_type(ir_node *ptr)
+{
        ir_type *tp;
 
        /* skip Cast and Confirm nodes */
@@ -115,14 +119,15 @@ static int is_final_ent(ir_entity *ent)
 /*
  * Transform Sel[method] to SymC[method] if possible.
  */
-ir_node *transform_node_Sel(ir_node *node) {
+ir_node *transform_node_Sel(ir_node *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;
 
-       if (!(get_opt_optimize() && get_opt_dyn_meth_dispatch()))
+       if (!get_opt_dyn_meth_dispatch())
                return node;
 
        if (!is_Method_type(get_entity_type(ent)))
@@ -137,10 +142,7 @@ ir_node *transform_node_Sel(ir_node *node) {
                        /* We could remove the Call depending on this Sel. */
                        new_node = node;
                } else {
-                       ir_node *rem_block = get_cur_block();
-                       set_cur_block(get_nodes_block(node));
-                       new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(ent));
-                       set_cur_block(rem_block);
+                       new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(ent), get_nodes_block(node));
                        DBG_OPT_POLY(node, new_node);
                }
                return new_node;
@@ -152,15 +154,11 @@ ir_node *transform_node_Sel(ir_node *node) {
 
        if (dyn_tp != firm_unknown_type) {
                ir_entity *called_ent;
-               ir_node *rem_block;
 
                /* We know which method will be called, no dispatch necessary. */
                called_ent = resolve_ent_polymorphy(dyn_tp, ent);
 
-               rem_block = get_cur_block();
-               set_cur_block(get_nodes_block(node));
-               new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(called_ent));
-               set_cur_block(rem_block);
+               new_node = copy_const_value(get_irn_dbg_info(node), get_atomic_ent_value(called_ent), get_nodes_block(node));
                DBG_OPT_POLY(node, new_node);
 
                return new_node;
@@ -177,13 +175,14 @@ ir_node *transform_node_Sel(ir_node *node) {
  *  a tuple, or replace the Projs of the load.
  *  Therefore we call this optimization in ldstopt().
  */
-ir_node *transform_polymorph_Load(ir_node *load) {
+ir_node *transform_polymorph_Load(ir_node *load)
+{
        ir_node *new_node = NULL;
        ir_node *field_ptr, *ptr;
        ir_entity *ent;
        ir_type *dyn_tp;
 
-       if (!(get_opt_optimize() && get_opt_dyn_meth_dispatch()))
+       if (!get_opt_dyn_meth_dispatch())
                return load;
 
        field_ptr = get_Load_ptr(load);