really remove type_id
authorMatthias Braun <matze@braunis.de>
Sat, 2 Jan 2010 11:51:17 +0000 (11:51 +0000)
committerMatthias Braun <matze@braunis.de>
Sat, 2 Jan 2010 11:51:17 +0000 (11:51 +0000)
[r26874]

include/libfirm/typerep.h
ir/common/firm.c
ir/ir/irgraph_t.h
ir/ir/irnode.c
ir/ir/irprog_t.h
ir/tr/entity_t.h
ir/tr/type.c
ir/tr/type_identify.c [deleted file]
ir/tr/typegmod.c [deleted file]
ir/tr/typewalk.c

index 23d1c7d..9b081f8 100644 (file)
@@ -794,26 +794,6 @@ const tp_op *get_tpop_pointer(void);
 extern const tp_op *type_primitive;
 const tp_op *get_tpop_primitive(void);
 
-/**
- * This type opcode is an auxiliary opcode dedicated to support transformations
- * of the type structure.
- *
- * If a type is changed to another type with another
- * opcode the new type will be allocated with new memory.  All nodes refering
- * to the old type need to be changed to refer to the new one.  This is simplified
- * by turning the old type into an id type that merely forwards to the new type
- * that now replaces the old one.
- * type_ids should never be visible out of the type module.  All access routines
- * should automatically check for type_id and eventually follow the forward in
- * type_id.  Two types are exchanged by a call to exchange_types.
- * If a type_id is visible externally report this as bug.  If it is assured that
- * this never happens this extern variable can be moved to tpop_t.h.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern const tp_op *type_id;
-const tp_op *get_tpop_id(void);
-
 /**
  * The code type is used to mark pieces of code (basic blocks)
  */
@@ -1101,32 +1081,6 @@ int tr_vrfy(void);
 #define TR_VRFY()      tr_vrfy()
 #endif
 
-/** Replaces one type by the other.
- *
- *  Old type is replaced by new_type.  All references to old_type
- *  now point to new_type.  The memory for the old type is destroyed,
- *  but still used.  Therefore it is not freed.
- *  All referenced to this memory will be lost after a certain while.
- *  An exception is the list of types in irp (irprog.h).
- *  In the future there might be a routine to recover the memory, but
- *  this will be at considerable runtime cost.
- *
- *  @param old_type  - The old type that shall be replaced by the new type.
- *  @param new_type  - The new type that will replace old_type.
- *
- */
-void exchange_types(ir_type *old_type, ir_type *new_type);
-
-/** Skip id types until a useful type is reached.
- *
- *  @param tp - A type of arbitrary kind.
- *
- *  @return
- *    tp if it is not an id type.
- *    If tp is an id type returns the real type it stands for.
- */
-ir_type *skip_tid(ir_type *tp);
-
 /**
  * @page type   representation of types
  *
@@ -1148,8 +1102,6 @@ ir_type *skip_tid(ir_type *tp);
  *  the target processor.
  */
 
-#include "typerep.h"
-
 /** Frees all entities associated with a type.
  *  Does not free the array entity.
  *  Warning: ensure these entities are not referenced anywhere else.
@@ -1372,7 +1324,7 @@ int is_type(const void *thing);
  *      - the same element type
  *    - they are enumeration types and have the same enumerator names
  *    - they are pointer types and have the identical points_to type
- *      (i.e., the same C-struct to represent the type, type_id is skipped.
+ *      (i.e., the same C-struct to represent the type.
  *       This is to avoid endless recursions; with pointer types cyclic
  *       type graphs are possible.)
  */
@@ -2435,26 +2387,6 @@ ir_type *mature_type_free(ir_type *tp);
  */
 ir_type *mature_type_free_entities(ir_type *tp);
 
-/**
- * The interface type for the type identify module;
- */
-struct type_identify_if_t {
-       compare_types_func_t *cmp;    /**< The function that should be used to compare two types.
-                                          If NULL, compare_strict() will be used. */
-       hash_types_func_t *hash;      /**< The function that should be used to calculate a hash
-                                          value of a type. If NULL, hash_name() will be used. */
-};
-
-/**
- * Initialise the type identifier module.
- *
- * @param ti_if    The interface functions for this module.
- *
- * If the parameter ti_if is NULL, the default functions compare_strict() and
- * firm_hash_name() will be used.
- */
-void init_type_identify(type_identify_if_t *ti_if);
-
 /** A data type to treat types and entities as the same. */
 typedef union {
        ir_type   *typ;   /**< points to a type */
@@ -2554,13 +2486,4 @@ void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env);
  */
 void types_calc_finalization(void);
 
-/**
- * Checks if a type already exists in the program and returns the existing
- * type.
- * @param type             The type to check
- * @param free_from_obst   free type from type obst (only legal if nothing
- *                         else was allocated since the type allocation)
- */
-ir_type *identify_type(ir_type *type, int free_from_obst);
-
 #endif
index fbe300c..3d6c417 100644 (file)
@@ -127,8 +127,6 @@ void ir_init(const firm_parameter_t *param)
        firm_init_type(def_params.builtin_dbg, def_params.cc_mask);
        /* initialize the entity module */
        firm_init_entity();
-       /* allocate a hash table. */
-       init_type_identify(def_params.ti_if);
        /* class cast optimization */
        firm_init_class_casts_opt();
        /* memory disambiguation */
index d1ef682..a743ea9 100644 (file)
@@ -260,8 +260,8 @@ _set_irg_entity(ir_graph *irg, ir_entity *ent) {
 
 static inline ir_type *
 _get_irg_frame_type(ir_graph *irg) {
-       assert(irg && irg->frame_type);
-       return irg->frame_type = skip_tid(irg->frame_type);
+       assert(irg->frame_type);
+       return irg->frame_type;
 }
 
 static inline void
index b950c0c..19a36e9 100644 (file)
@@ -520,7 +520,6 @@ symconst_attr *get_irn_symconst_attr(ir_node *node) {
 
 call_attr *get_irn_call_attr(ir_node *node) {
        assert(is_Call(node));
-       node->attr.call.type = skip_tid(node->attr.call.type);
        return &node->attr.call;
 }
 
@@ -1146,7 +1145,6 @@ int (is_Const_all_one)(const ir_node *node) {
 ir_type *
 get_Const_type(ir_node *node) {
        assert(is_Const(node));
-       node->attr.con.tp = skip_tid(node->attr.con.tp);
        return node->attr.con.tp;
 }
 
@@ -1180,7 +1178,7 @@ get_SymConst_type(const ir_node *node) {
        ir_node *irn = (ir_node *)node;
        assert(is_SymConst(node) &&
               (SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
-       return irn->attr.symc.sym.type_p = skip_tid(irn->attr.symc.sym.type_p);
+       return irn->attr.symc.sym.type_p;
 }
 
 void
@@ -1239,7 +1237,6 @@ set_SymConst_symbol(ir_node *node, union symconst_symbol sym) {
 ir_type *
 get_SymConst_value_type(ir_node *node) {
        assert(is_SymConst(node));
-       if (node->attr.symc.tp) node->attr.symc.tp = skip_tid(node->attr.symc.tp);
        return node->attr.symc.tp;
 }
 
@@ -1377,7 +1374,7 @@ set_Call_param(ir_node *node, int pos, ir_node *param) {
 ir_type *
 get_Call_type(ir_node *node) {
        assert(is_Call(node));
-       return node->attr.call.type = skip_tid(node->attr.call.type);
+       return node->attr.call.type;
 }
 
 void
@@ -1450,7 +1447,7 @@ set_Builtin_param(ir_node *node, int pos, ir_node *param) {
 ir_type *
 get_Builtin_type(ir_node *node) {
        assert(is_Builtin(node));
-       return node->attr.builtin.type = skip_tid(node->attr.builtin.type);
+       return node->attr.builtin.type;
 }
 
 void
@@ -1653,7 +1650,6 @@ void set_Conv_strict(ir_node *node, int strict_flag) {
 ir_type *
 get_Cast_type(ir_node *node) {
        assert(is_Cast(node));
-       node->attr.cast.type = skip_tid(node->attr.cast.type);
        return node->attr.cast.type;
 }
 
@@ -1979,7 +1975,7 @@ set_Alloc_size(ir_node *node, ir_node *size) {
 ir_type *
 get_Alloc_type(ir_node *node) {
        assert(is_Alloc(node));
-       return node->attr.alloc.type = skip_tid(node->attr.alloc.type);
+       return node->attr.alloc.type;
 }
 
 void
@@ -2040,7 +2036,7 @@ set_Free_size(ir_node *node, ir_node *size) {
 ir_type *
 get_Free_type(ir_node *node) {
        assert(is_Free(node));
-       return node->attr.free.type = skip_tid(node->attr.free.type);
+       return node->attr.free.type;
 }
 
 void
@@ -2373,7 +2369,7 @@ void set_CopyB_src(ir_node *node, ir_node *src) {
 
 ir_type *get_CopyB_type(ir_node *node) {
        assert(is_CopyB(node));
-       return node->attr.copyb.type = skip_tid(node->attr.copyb.type);
+       return node->attr.copyb.type;
 }
 
 void set_CopyB_type(ir_node *node, ir_type *data_type) {
@@ -2385,7 +2381,7 @@ void set_CopyB_type(ir_node *node, ir_type *data_type) {
 ir_type *
 get_InstOf_type(ir_node *node) {
        assert(node->op == op_InstOf);
-       return node->attr.instof.type = skip_tid(node->attr.instof.type);
+       return node->attr.instof.type;
 }
 
 void
index bae4ed1..d2d12c7 100644 (file)
@@ -41,7 +41,7 @@
 #include "array.h"
 
 /** Adds mode to the list of modes in irp. */
-void  add_irp_mode(ir_mode *mode);
+void add_irp_mode(ir_mode *mode);
 
 /* inline functions */
 static inline ir_type *
@@ -50,7 +50,7 @@ _get_segment_type(ir_segment_t segment)
        ir_type *type;
 
        assert(segment < IR_SEGMENT_COUNT);
-       type                        = skip_tid(irp->segment_types[segment]);
+       type                        = irp->segment_types[segment];
        irp->segment_types[segment] = type;
        return type;
 }
@@ -67,7 +67,7 @@ _get_tls_type(void) {
 
 static inline int
 _get_irp_n_irgs(void) {
-       assert (irp && irp->graphs);
+       assert(irp && irp->graphs);
        if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
        return ARR_LEN(irp->graphs);
 }
@@ -82,38 +82,38 @@ _get_irp_irg(int pos){
 
 static inline int
 _get_irp_n_types(void) {
-       assert (irp && irp->types);
+       assert(irp && irp->types);
        return ARR_LEN(irp->types);
 }
 
 static inline ir_type *
 _get_irp_type(int pos) {
-       assert (irp && irp->types);
+       assert(irp->types);
        /* Don't set the skip_tid result so that no double entries are generated. */
-       return skip_tid(irp->types[pos]);
+       return irp->types[pos];
 }
 
 static inline int
 _get_irp_n_modes(void) {
-       assert (irp && irp->modes);
+       assert(irp->modes);
        return ARR_LEN(irp->modes);
 }
 
 static inline ir_mode *
 _get_irp_mode(int pos) {
-       assert (irp && irp->modes);
+       assert(irp && irp->modes);
        return irp->modes[pos];
 }
 
 static inline int
 _get_irp_n_opcodes(void) {
-       assert (irp && irp->opcodes);
+       assert(irp && irp->opcodes);
        return ARR_LEN(irp->opcodes);
 }
 
 static inline ir_op *
 _get_irp_opcode(int pos) {
-       assert (irp && irp->opcodes);
+       assert(irp && irp->opcodes);
        return irp->opcodes[pos];
 }
 
index a257220..a3f46ca 100644 (file)
@@ -209,7 +209,7 @@ _set_entity_ident(ir_entity *ent, ident *id) {
 static inline ir_type *
 _get_entity_owner(ir_entity *ent) {
        assert(ent && ent->kind == k_entity);
-       return ent->owner = skip_tid(ent->owner);
+       return ent->owner;
 }
 
 static inline ident *
@@ -236,7 +236,7 @@ _get_entity_ld_name(ir_entity *ent) {
 static inline ir_type *
 _get_entity_type(ir_entity *ent) {
        assert(ent && ent->kind == k_entity);
-       return ent->type = skip_tid(ent->type);
+       return ent->type;
 }
 
 static inline void
index 6215886..043f64b 100644 (file)
@@ -136,7 +136,6 @@ ir_type *new_type(const tp_op *type_op, ir_mode *mode, ident *name,
        ir_type *res;
        int node_size;
 
-       assert(type_op != type_id);
        assert(!id_contains_char(name, ' ') && "type name should not contain spaces");
 
        node_size = offsetof(ir_type, attr) +  type_op->attr_size;
@@ -876,7 +875,7 @@ ir_type *get_class_subtype(ir_type *clss, int pos)
 {
        assert(clss && (clss->type_op == type_class));
        assert(pos >= 0 && pos < get_class_n_subtypes(clss));
-       return clss->attr.ca.subtypes[pos] = skip_tid(clss->attr.ca.subtypes[pos]);
+       return clss->attr.ca.subtypes[pos];
 }
 
 int get_class_subtype_index(ir_type *clss, const ir_type *subclass)
@@ -942,7 +941,7 @@ ir_type *get_class_supertype(ir_type *clss, int pos)
 {
        assert(clss && (clss->type_op == type_class));
        assert(pos >= 0 && pos < get_class_n_supertypes(clss));
-       return clss->attr.ca.supertypes[pos] = skip_tid(clss->attr.ca.supertypes[pos]);
+       return clss->attr.ca.supertypes[pos];
 }
 
 void set_class_supertype(ir_type *clss, ir_type *supertype, int pos)
@@ -1303,7 +1302,7 @@ ir_type *get_method_param_type(ir_type *method, int pos)
        assert(pos >= 0 && pos < get_method_n_params(method));
        res = method->attr.ma.params[pos].tp;
        assert(res != NULL && "empty method param type");
-       return method->attr.ma.params[pos].tp = skip_tid(res);
+       return res;
 }
 
 void set_method_param_type(ir_type *method, int pos, ir_type *tp)
@@ -1393,7 +1392,7 @@ ir_type *get_method_res_type(ir_type *method, int pos)
        assert(pos >= 0 && pos < get_method_n_ress(method));
        res = method->attr.ma.res_type[pos].tp;
        assert(res != NULL && "empty method return type");
-       return method->attr.ma.res_type[pos].tp = skip_tid(res);
+       return res;
 }
 
 void  set_method_res_type(ir_type *method, int pos, ir_type *tp)
@@ -1815,7 +1814,7 @@ void set_array_element_type(ir_type *array, ir_type *tp)
 ir_type *get_array_element_type(ir_type *array)
 {
        assert(array && (array->type_op == type_array));
-       return array->attr.aa.element_type = skip_tid(array->attr.aa.element_type);
+       return array->attr.aa.element_type;
 }
 
 void set_array_element_entity(ir_type *array, ir_entity *ent)
@@ -1982,7 +1981,7 @@ void set_pointer_points_to_type(ir_type *pointer, ir_type *tp)
 ir_type *get_pointer_points_to_type(ir_type *pointer)
 {
        assert(pointer && (pointer->type_op == type_pointer));
-       return pointer->attr.pa.points_to = skip_tid(pointer->attr.pa.points_to);
+       return pointer->attr.pa.points_to;
 }
 
 int (is_Pointer_type)(const ir_type *pointer)
diff --git a/ir/tr/type_identify.c b/ir/tr/type_identify.c
deleted file mode 100644 (file)
index 31b9405..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 1995-2008 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.
- */
-
-/**
- * @file    type_identify.c
- * @brief   Representation of types.
- * @author  Goetz Lindenmaier
- * @version $Id$
- */
-#include "config.h"
-
-#include "typerep.h"
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "type_t.h"
-#include "tpop_t.h"
-#include "irprog_t.h"
-#include "array.h"
-#include "irprog_t.h"
-#include "pset.h"
-#include "irtools.h"
-
-/* The hash set for types. */
-static pset *type_table = NULL;
-
-/* hash and compare types */
-static hash_types_func_t    *hash_types_func;
-static compare_types_func_t *compare_types_func;
-
-int compare_names (const void *tp1, const void *tp2) {
-       ir_type *t1 = (ir_type *) tp1;
-       ir_type *t2 = (ir_type *) tp2;
-
-       return (t1 != t2 &&
-               (t1->type_op !=  t2->type_op ||
-                t1->name    !=  t2->name      ) );
-}
-
-/* stuff for comparing two types. */
-int compare_strict(const void *tp1, const void *tp2) {
-       const ir_type *t1 = tp1;
-       const ir_type *t2 = tp2;
-       return t1 != t2;
-}
-
-/* stuff to compute a hash value for a type. */
-int firm_hash_name(ir_type *tp) {
-       unsigned h = (unsigned)PTR_TO_INT(tp->type_op);
-       h = 9*h + (unsigned)PTR_TO_INT(tp->name);
-       return h;
-}
-
-/* The function that hashes a type. */
-ir_type *mature_type(ir_type *tp) {
-       ir_type *o;
-
-       assert(type_table);
-
-       o = pset_insert (type_table, tp, hash_types_func(tp) );
-       if (!o || o == tp) return tp;
-       exchange_types(tp, o);
-
-       return o;
-}
-
-
-/* The function that hashes a type. */
-ir_type *mature_type_free(ir_type *tp) {
-       ir_type *o;
-
-       assert(type_table);
-
-       o = pset_insert (type_table, tp, hash_types_func(tp) );
-       if (!o || o == tp) return tp;
-
-       free_type_entities(tp);
-       free_type(tp);
-
-       return o;
-}
-
-/* The function that hashes a type. */
-ir_type *mature_type_free_entities(ir_type *tp) {
-       ir_type *o;
-
-       assert(type_table);
-
-       o = pset_insert (type_table, tp, hash_types_func(tp) );
-       if (!o || o == tp) return tp;
-
-       free_type_entities(tp);
-       exchange_types(tp, o);
-
-       return o;
-}
-
-/* initialize this module */
-void init_type_identify(type_identify_if_t *ti_if) {
-       compare_types_func = ti_if && ti_if->cmp  ? ti_if->cmp  : compare_strict;
-       hash_types_func    = ti_if && ti_if->hash ? ti_if->hash : firm_hash_name;
-
-       type_table = new_pset (compare_types_func, 8);
-}
diff --git a/ir/tr/typegmod.c b/ir/tr/typegmod.c
deleted file mode 100644 (file)
index 642ef66..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 1995-2008 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.
- */
-
-/**
- * @file    typegmod.c
- * @brief   Functionality to modify the type graph.
- * @author  Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#include "config.h"
-
-#include "type_t.h"
-#include "tpop_t.h"
-#include "irmode.h"
-
-void exchange_types(ir_type *old_type, ir_type *new_type) {
-       unsigned flags = old_type->flags & ~(tf_lowered_type | tf_layout_fixed);
-       /* Deallocate datastructures not directly contained in the
-          old type.  We must do this now as it is the latest point
-          where we know the original kind of type.
-          */
-       free_type_attrs(old_type);
-
-       /* @@@@
-          Things to deal with:
-          * After exchange_types the type has two entries in the list of
-            all types in irp.  So far this is fine for the walker.
-            Maybe it's better to remove the id entry and shrink the list.
-            Does this conflict with the walker?  Might a type be left out
-            during the walk?
-          * Deallocation:  if the Id is removed from the list it will eventually
-            disappear in a memory leak.  When is impossible to determine so we
-            need to hold it in a separate list for deallocation.
-       */
-
-       /* Exchange the types */
-       old_type->type_op = type_id;
-       old_type->assoc_type = new_type;
-       /* ensure that the frame, value param, global and tls flags
-          are set right if these types are exchanged */
-       new_type->flags |= flags;
-}
-
-ir_type *skip_tid(ir_type *tp) {
-       /* @@@ implement the self cycle killing trick of skip_id(ir_node *) */
-       while (tp->type_op == type_id)
-               tp = tp->assoc_type;
-       return tp;
-}
index f20857d..4a6e094 100644 (file)
@@ -104,7 +104,6 @@ static void do_type_walk(type_or_ent tore,
                        return;
                break;
        case k_type:
-               tp = skip_tid(tore.typ);
                if (type_visited(tp))
                        return;
                break;
@@ -350,11 +349,6 @@ static void type_walk_s2s_2(type_or_ent tore,
                if (entity_visited(tore.ent)) return;
                break;
        case k_type:
-               if (type_id == get_type_tpop(tore.typ)) {
-                       cont.typ = skip_tid(tore.typ);
-                       type_walk_s2s_2(cont, pre, post, env);
-                       return;
-               }
                if (type_visited(tore.typ)) return;
                break;
        default:
@@ -378,7 +372,6 @@ static void type_walk_s2s_2(type_or_ent tore,
                                        /* execute pre method */
                                        if (pre)
                                                pre(tore, env);
-                                       tp = skip_tid(tp);
 
                                        n = get_class_n_subtypes(tp);
                                        for (i = 0; i < n; ++i) {
@@ -447,11 +440,6 @@ type_walk_super_2(type_or_ent tore,
                        return;
                break;
        case k_type:
-               if (type_id == get_type_tpop(tore.typ)) {
-                       cont.typ = skip_tid(tore.typ);
-                       type_walk_super_2(cont, pre, post, env);
-                       return;
-               }
                if (type_visited(tore.typ))
                        return;
                break;
@@ -471,7 +459,6 @@ type_walk_super_2(type_or_ent tore,
                                        /* execute pre method */
                                        if (pre)
                                                pre(tore, env);
-                                       tp = skip_tid(tp);
 
                                        n = get_class_n_supertypes(tp);
                                        for (i = 0; i < n; ++i) {
@@ -550,7 +537,6 @@ class_walk_s2s_2(ir_type *tp,
        if (pre)
                pre(tp, env);
 
-       tp = skip_tid(tp);
        n = get_class_n_subtypes(tp);
        for (i = 0; i < n; ++i) {
                class_walk_s2s_2(get_class_subtype(tp, i), pre, post, env);