Primitive, Pointer, Array and Method types are anonymous now
authorMatthias Braun <matze@braunis.de>
Tue, 5 Jan 2010 15:56:54 +0000 (15:56 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 5 Jan 2010 15:56:54 +0000 (15:56 +0000)
- There's a new type_dbg_info* that allows you to attach debug names to types
- get_type_name and get_type_ident are now more. The new ir_print_type
  and the usual ir_printf("%+F", type) help in most usage cases.
  But you should be aware that names are not guaranteed to be unique anymore
  (or positively said: You don't have no trouble anymore building unique names
   in code that creates types)
- No need to specify mode for new pointer types anymore (you can still do it
  with set_type_mode)

[r26909]

45 files changed:
include/libfirm/dbginfo.h
include/libfirm/firm_common.h
include/libfirm/firm_types.h
include/libfirm/irmode.h
include/libfirm/lowering.h
include/libfirm/typerep.h
ir/ana/irmemory.c
ir/ana/irsimpletype.c
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/arm/bearch_arm.c
ir/be/beabi.c
ir/be/bestabs.c
ir/be/ia32/bearch_ia32.c
ir/be/ia32/ia32_common_transform.c
ir/be/ia32/ia32_fpu.c
ir/be/ia32/ia32_transform.c
ir/be/mips/bearch_mips.c
ir/be/ppc32/bearch_ppc32.c
ir/be/ppc32/ppc32_transform.c
ir/be/ppc32/ppc32_transform_conv.c
ir/be/sparc/bearch_sparc.c
ir/common/firm.c
ir/common/firm_common.c
ir/debug/dbginfo.c
ir/debug/debugger.c
ir/ir/irargs.c
ir/ir/irdump.c
ir/ir/irdump_t.h
ir/ir/irdumptxt.c
ir/ir/irgraph.c
ir/ir/irio.c
ir/ir/irmode.c
ir/ir/iropt.c
ir/ir/irprofile.c
ir/ir/irtypes.h
ir/ir/irvrfy.c
ir/lower/lower_calls.c
ir/lower/lower_dw.c
ir/lower/lower_mode_b.c
ir/opt/proc_cloning.c
ir/opt/tropt.c
ir/tr/tr_inheritance.c
ir/tr/type.c
ir/tr/type_finalization.c
ir/tr/type_t.h

index fde55fc..025e5eb 100644 (file)
@@ -35,6 +35,7 @@
 #ifndef FIRM_DEBUG_DBGINFO_H
 #define FIRM_DEBUG_DBGINFO_H
 
+#include <stdlib.h>
 #include "firm_types.h"
 #include "ident.h"
 
@@ -162,9 +163,28 @@ typedef const char *(*retrieve_dbg_func)(const dbg_info *dbg, unsigned *line);
  */
 void ir_set_debug_retrieve(retrieve_dbg_func func);
 
+/**
+ * The type of the type debug info retrieve function.
+ * Prints a human readable source representation of a type to an obstack.
+ *  (Used for generating debug info like stabs or dwarf)
+ */
+typedef void (*retrieve_type_dbg_func)(char *buffer, size_t buffer_size,
+                                       const type_dbg_info *tdbgi);
+
+/**
+ * Set global print_type_dbg_info function in firm
+ */
+void ir_set_type_debug_retrieve(retrieve_type_dbg_func func);
+
 /**
  * Retrieve the debug info.
  */
 const char *ir_retrieve_dbg_info(const dbg_info *dbg, unsigned *line);
 
+/**
+ * Retrieve type debug info
+ */
+void ir_retrieve_type_dbg_info(char *buffer, size_t buffer_size,
+                               const type_dbg_info *tdbgi);
+
 #endif
index db88412..4585f11 100644 (file)
  * libFirm initialization parameters.
  */
 struct _firm_parameter_t {
-  /**
-   * The size of this structure. init_firm() will only initialize
-   * this amount of data. This allows to add more fields to this structure
-   * without breaking compatibility to older source.
-   */
-  unsigned int size;
-
-  /**
-   * Statistic options. If statistic function where enabled, these
-   * flags configure it, see enum firmstat_options_t.
-   */
-  unsigned enable_statistics;
-
-  /**
-   * This function is called, whenever a local variable is
-   * used before definition. The function should insert a default value,
-   * and/or raise a compiler error/warning. Note that returning
-   * an Unknown is allowed here.
-   */
-  uninitialized_local_variable_func_t *initialize_local_func;
-
-  /**
-   * The interface functions for the type identification module.
-   * If not set, the default implementation with compare_strict() and
-   * firm_hash_name() will be used.
-   */
-  type_identify_if_t *ti_if;
-
-  /**
-   * The interface for the ident module.
-   * If not set, the default libFirm ident module (using hash sets).
-   */
-  ident_if_t *id_if;
-
-  /**
-   * The default calling convention.
-   */
-  unsigned cc_mask;
-
-  /**
-   * The debug info that should be used for "builtin" objects.
-   */
-  dbg_info *builtin_dbg;
+       /**
+        * The size of this structure. init_firm() will only initialize
+        * this amount of data. This allows to add more fields to this structure
+        * without breaking compatibility to older source.
+        */
+       unsigned int size;
+
+       /**
+        * Statistic options. If statistic function where enabled, these
+        * flags configure it, see enum firmstat_options_t.
+        */
+       unsigned enable_statistics;
+
+       /**
+        * This function is called, whenever a local variable is
+        * used before definition. The function should insert a default value,
+        * and/or raise a compiler error/warning. Note that returning
+        * an Unknown is allowed here.
+        */
+       uninitialized_local_variable_func_t *initialize_local_func;
+
+       /**
+        * The interface functions for the type identification module.
+        * If not set, the default implementation with compare_strict() and
+        * firm_hash_name() will be used.
+        */
+       type_identify_if_t *ti_if;
+
+       /**
+        * The interface for the ident module.
+        * If not set, the default libFirm ident module (using hash sets).
+        */
+       ident_if_t *id_if;
+
+       /**
+        * The default calling convention.
+        */
+       unsigned cc_mask;
+
+       /**
+        * dummy (here was dbg_info *builtin_dbg before)
+        */
+       void *dummy;
 };
 
 typedef struct _firm_parameter_t firm_parameter_t;
index 7a2f057..e792661 100644 (file)
@@ -31,6 +31,7 @@ typedef unsigned long ir_exc_region_t;
 typedef unsigned long ir_label_t;
 
 typedef struct dbg_info             dbg_info,            *dbg_info_ptr;
+typedef struct type_dbg_info        type_dbg_info;
 typedef const struct _ident         ident,               *ir_ident_ptr;
 typedef struct ir_node              ir_node,             *ir_node_ptr;
 typedef struct ir_op                ir_op,               *ir_op_ptr;
index 16d6087..a6e7b69 100644 (file)
@@ -478,4 +478,9 @@ void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode);
  */
 int is_reinterpret_cast(const ir_mode *src, const ir_mode *dst);
 
+/**
+ * Returns the primitive type matching the given mode
+ */
+ir_type *get_type_for_mode(const ir_mode *mode);
+
 #endif
index ed79523..1d04f12 100644 (file)
@@ -63,7 +63,7 @@ typedef struct {
         * A function returning a pointer type for a given type.
         * If this pointer is NULL, a new pointer type is always created.
         */
-       ir_type *(*find_pointer_type)(ir_type *e_type, ir_mode *mode, int alignment);
+       ir_type *(*find_pointer_type)(ir_type *e_type, int alignment);
 
        /**
         * If the LF_SMALL_CMP_IN_REGS flag is set, this function will be called
index 9b081f8..7f0d636 100644 (file)
@@ -25,6 +25,7 @@
 #define FIRM_TYPEREP_H
 
 #include "firm_types.h"
+#include <stdlib.h>
 
 /**
  * @page entity       Entity representation
@@ -1123,9 +1124,16 @@ ident *get_type_tpop_nameid(const ir_type *tp);
 const char *get_type_tpop_name(const ir_type *tp);
 tp_opcode get_type_tpop_code(const ir_type *tp);
 
-ident *get_type_ident(const ir_type *tp);
-void set_type_ident(ir_type *tp, ident* id);
-const char *get_type_name(const ir_type *tp);
+/**
+ * construct a string representing the type.
+ * This uses the info retrieved by the type_dbg_info if available.
+ * Otherwise it tries to create an approximate textual representation of the
+ * type.
+ * Keep in mind that this representation is not unique for each type,
+ * might abstract away some details. The main intention of this is creating
+ * human redable strings giving an idea of the type.
+ */
+void ir_print_type(char *buffer, size_t buffer_size, const ir_type *tp);
 
 /** The visibility of a type.
  *
@@ -1273,14 +1281,14 @@ void         inc_master_type_visited(void);
  * @param tp  The type.
  * @param db  The debug info.
  */
-void set_type_dbg_info(ir_type *tp, dbg_info *db);
+void set_type_dbg_info(ir_type *tp, type_dbg_info *db);
 
 /**
  * Returns the debug information of a type.
  *
  * @param tp  The type.
  */
-dbg_info *get_type_dbg_info(const ir_type *tp);
+type_dbg_info *get_type_dbg_info(const ir_type *tp);
 
 /**
  * Checks whether a pointer points to a type.
@@ -1426,10 +1434,16 @@ int smaller_type(ir_type *st, ir_type *lt);
 ir_type *new_type_class(ident *name);
 
 /** Creates a new class type with debug information. */
-ir_type *new_d_type_class(ident *name, dbg_info *db);
+ir_type *new_d_type_class(ident *name, type_dbg_info *db);
 
 /* --- manipulate private fields of class type  --- */
 
+/** return identifier of the class type */
+ident *get_class_ident(const ir_type *clss);
+
+/** return identifier of the class type */
+const char *get_class_name(const ir_type *clss);
+
 /** Adds the entity as member of the class.  */
 void add_class_member(ir_type *clss, ir_entity *member);
 
@@ -1599,10 +1613,16 @@ int is_Class_type(const ir_type *clss);
 /** Creates a new type struct */
 ir_type *new_type_struct(ident *name);
 /** Creates a new type struct with debug information. */
-ir_type *new_d_type_struct(ident *name, dbg_info* db);
+ir_type *new_d_type_struct(ident *name, type_dbg_info* db);
 
 /* --- manipulate private fields of struct --- */
 
+/** return struct identifier */
+ident *get_struct_ident(const ir_type *strct);
+
+/** return struct identifier as c-string*/
+const char *get_struct_name(const ir_type *strct);
+
 /** Adds the entity as member of the struct.  */
 void add_struct_member(ir_type *strct, ir_entity *member);
 
@@ -1673,7 +1693,7 @@ int is_Struct_type(const ir_type *strct);
  * The arrays for the parameter and result types are not initialized by
  * the constructor.
  */
-ir_type *new_type_method(ident *name, int n_param, int n_res);
+ir_type *new_type_method(int n_param, int n_res);
 
 /** Create a new method type with debug information.
  *
@@ -1685,17 +1705,7 @@ ir_type *new_type_method(ident *name, int n_param, int n_res);
  * The arrays for the parameter and result types are not initialized by
  * the constructor.
  */
-ir_type *new_d_type_method(ident *name, int n_param, int n_res, dbg_info *db);
-
-/** Clone an existing method type.
- *
- * @param tp      the method type to clone.
- * @param prefix  if non-null, will be the prefix for the name of
- *                the cloned type
- *
- * @return the cloned method type.
- */
-ir_type *clone_type_method(ir_type *tp, ident *prefix);
+ir_type *new_d_type_method(int n_param, int n_res, type_dbg_info *db);
 
 /* -- manipulate private fields of method. -- */
 
@@ -1887,10 +1897,16 @@ int is_Method_type(const ir_type *method);
 ir_type *new_type_union(ident *name);
 
 /** Creates a new type union with debug information. */
-ir_type *new_d_type_union(ident *name, dbg_info* db);
+ir_type *new_d_type_union(ident *name, type_dbg_info* db);
 
 /* --- manipulate private fields of struct --- */
 
+/** return union identifier */
+ident *get_union_ident(const ir_type *uni);
+
+/** return union identifier as c-string */
+const char *get_union_name(const ir_type *uni);
+
 /** Returns the number of unioned types of this union */
 int get_union_n_members(const ir_type *uni);
 
@@ -1938,7 +1954,7 @@ int is_Union_type(const ir_type *uni);
  * The entity for array elements is built automatically.
  * Set dimension sizes after call to constructor with set_* routines.
  */
-ir_type *new_type_array(ident *name, int n_dims, ir_type *element_type);
+ir_type *new_type_array(int n_dims, ir_type *element_type);
 
 /** Create a new type array with debug information.
  *
@@ -1948,7 +1964,7 @@ ir_type *new_type_array(ident *name, int n_dims, ir_type *element_type);
  * Set dimension sizes after call to constructor with set_* routines.
  * A legal array type must have at least one dimension set.
  */
-ir_type *new_d_type_array(ident *name, int n_dims, ir_type *element_type, dbg_info* db);
+ir_type *new_d_type_array(int n_dims, ir_type *element_type, type_dbg_info* db);
 
 /* --- manipulate private fields of array type --- */
 
@@ -2007,7 +2023,7 @@ int find_array_dimension(const ir_type *array, int order);
 void set_array_element_type(ir_type *array, ir_type* tp);
 
 /** Gets the array element type. */
-ir_type *get_array_element_type(ir_type *array);
+ir_type *get_array_element_type(const ir_type *array);
 
 /** Sets the array element entity. */
 void set_array_element_entity(ir_type *array, ir_entity *ent);
@@ -2035,10 +2051,16 @@ int is_Array_type(const ir_type *array);
 ir_type *new_type_enumeration(ident *name, int n_enums);
 
 /** Create a new type enumeration with debug information -- set the enumerators independently. */
-ir_type *new_d_type_enumeration(ident *name, int n_enums, dbg_info *db);
+ir_type *new_d_type_enumeration(ident *name, int n_enums, type_dbg_info *db);
 
 /* --- manipulate fields of enumeration type. --- */
 
+/** return enumeration identifier */
+ident *get_enumeration_ident(const ir_type *enumeration);
+
+/** return enumeration identifier as c-string */
+const char *get_enumeration_name(const ir_type *enumeration);
+
 /** Set an enumeration constant to a enumeration type at a given position. */
 void set_enumeration_const(ir_type *enumeration, int pos, ident *nameid, tarval *con);
 
@@ -2061,10 +2083,10 @@ tarval *get_enumeration_value(const ir_enum_const *enum_cnst);
 void set_enumeration_nameid(ir_enum_const *enum_cnst, ident *id);
 
 /** Returns the assigned ident of an enumeration constant. */
-ident *get_enumeration_nameid(const ir_enum_const *enum_cnst);
+ident *get_enumeration_const_nameid(const ir_enum_const *enum_cnst);
 
 /** Returns the assigned name of an enumeration constant. */
-const char *get_enumeration_name(const ir_enum_const *enum_cnst);
+const char *get_enumeration_const_name(const ir_enum_const *enum_cnst);
 
 /** Returns true if a type is a enumeration type. */
 int is_Enumeration_type(const ir_type *enumeration);
@@ -2072,25 +2094,23 @@ int is_Enumeration_type(const ir_type *enumeration);
 /**
  * @page pointer_type   Representation of a pointer type
  *
- * The mode of the pointer type must be a reference mode.
- *
  * Pointer types:
  * - points_to:      The type of the entity this pointer points to.
  */
 
 /** Creates a new type pointer. */
-ir_type *new_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode);
+ir_type *new_type_pointer(ir_type *points_to);
 
 /** Creates a new type pointer with debug information. */
-ir_type *new_d_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode, dbg_info* db);
+ir_type *new_d_type_pointer(ir_type *points_to, type_dbg_info* db);
 
 /* --- manipulate fields of type_pointer --- */
 
 /** Sets the type to which a pointer points to. */
-void  set_pointer_points_to_type(ir_type *pointer, ir_type *tp);
+void set_pointer_points_to_type(ir_type *pointer, ir_type *tp);
 
 /** Returns the type to which a pointer points to. */
-ir_type *get_pointer_points_to_type(ir_type *pointer);
+ir_type *get_pointer_points_to_type(const ir_type *pointer);
 
 /** Returns true if a type is a pointer type. */
 int is_Pointer_type(const ir_type *pointer);
@@ -2108,16 +2128,16 @@ ir_type *find_pointer_type_to_type(ir_type *tp);
  * important information they carry is held in the common mode field.
  */
 /** Creates a new primitive type. */
-ir_type *new_type_primitive(ident *name, ir_mode *mode);
+ir_type *new_type_primitive(ir_mode *mode);
 
 /** Creates a new primitive type with debug information. */
-ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info* db);
+ir_type *new_d_type_primitive(ir_mode *mode, type_dbg_info* db);
 
 /** Returns true if a type is a primitive type. */
 int is_Primitive_type(const ir_type *primitive);
 
 /** Return the base type of a primitive (bitfield) type or NULL if none. */
-ir_type *get_primitive_base_type(ir_type *tp);
+ir_type *get_primitive_base_type(const ir_type *tp);
 
 /** Sets the base type of a primitive (bitfield) type. */
 void set_primitive_base_type(ir_type *tp, ir_type *base_tp);
@@ -2183,6 +2203,14 @@ int is_atomic_type(const ir_type *tp);
 
 /* --- Support for compound types --- */
 
+/**
+ * Gets the identifier of a compound type
+ */
+ident *get_compound_ident(const ir_type *tp);
+
+/** return compound identifier as c-string */
+const char *get_compound_name(const ir_type *tp);
+
 /**
  * Gets the number of elements in a Firm compound type.
  *
@@ -2245,14 +2273,14 @@ int is_lowered_type(const ir_type *tp);
  * so all struct access functions work.
  * Value types are not in the global list of types.
  */
-ir_type *new_type_value(ident *name);
+ir_type *new_type_value(void);
 
 /**
  * Makes a new frame type. Frame types are class types,
  * so all class access functions work.
  * Frame types are not in the global list of types.
  */
-ir_type *new_type_frame(ident *name);
+ir_type *new_type_frame(void);
 
 /**
  * Makes a clone of a frame type.
@@ -2322,12 +2350,6 @@ int compare_strict(const void *tp1, const void *tp2);
 
 /* ------------------------------------------------------------------------ */
 
-/**  Type for a function that computes a hash value for a type.
- *
- *   @param tp The type to compute a hash for.
- */
-typedef int (hash_types_func_t)(ir_type *tp);
-
 /** Computes a hash value by the type name.
  *
  * Uses the name of the type and the type opcode to compute the hash.
index 42ed60c..45331c2 100644 (file)
@@ -1263,18 +1263,15 @@ static pmap *mtp_map;
  *
  * @param tp  the type to clone
  */
-static ir_type *clone_type_and_cache(ir_type *tp) {
-       static ident *prefix = NULL;
+static ir_type *clone_type_and_cache(ir_type *tp)
+{
        ir_type *res;
        pmap_entry *e = pmap_find(mtp_map, tp);
 
        if (e)
                return e->value;
 
-       if (prefix == NULL)
-               prefix = new_id_from_chars("C", 1);
-
-       res = clone_type_method(tp, prefix);
+       res = clone_type_method(tp);
        pmap_insert(mtp_map, tp, res);
 
        return res;
index 3e2b43e..08a7a99 100644 (file)
@@ -280,8 +280,7 @@ static ir_type *find_type_for_node(ir_node *n) {
 
                if (tp1 == tp2) { tp = tp1; break; }
 
-               DB((dbg, SET_LEVEL_2, "Phi %ld with two different types: %s, %s: unknown type.\n", get_irn_node_nr(n),
-                       get_type_name(tp1), get_type_name(tp2)));
+               DB((dbg, SET_LEVEL_2, "Phi %ld with two different types: %+F, %+F: unknown type.\n", get_irn_node_nr(n), tp1, tp2));
                tp = firm_unknown_type;   /* Test for supertypes? */
                break;
        }
@@ -381,8 +380,7 @@ default_code:
                                tp = phi_cycle_type;
                                break;
                        }
-                       DB((dbg, SET_LEVEL_2, "Binop %ld with two different types: %s, %s: unknown type \n", get_irn_node_nr(n),
-                               get_type_name(tp1), get_type_name(tp2)));
+                       DB((dbg, SET_LEVEL_2, "Binop %ld with two different types: %+F, %+F: unknown type\n", get_irn_node_nr(n), tp1, tp2));
                        tp = firm_unknown_type;
                        break;
                }
index 4e0a233..e14f30a 100644 (file)
@@ -307,8 +307,8 @@ static ir_type *TEMPLATE_get_between_type(void *self)
 
        if(!between_type) {
                ir_entity *ret_addr_ent;
-               ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
-               ir_type *old_bp_type   = new_type_primitive(new_id_from_str("bp"), mode_P);
+               ir_type *ret_addr_type = new_type_primitive(mode_P);
+               ir_type *old_bp_type   = new_type_primitive(mode_P);
 
                between_type           = new_type_class(new_id_from_str("TEMPLATE_between_type"));
                old_bp_ent             = new_entity(between_type, new_id_from_str("old_bp"), old_bp_type);
index fcc5104..5b5a928 100644 (file)
@@ -436,7 +436,7 @@ static void handle_calls(ir_node *call, void *env)
        n       = i;
        n_param = get_method_n_params(mtp) - n + idx;
        n_res   = get_method_n_ress(mtp);
-       new_mtd = new_d_type_method(get_type_ident(mtp), n_param, n_res, get_type_dbg_info(mtp));
+       new_mtd = new_d_type_method(n_param, n_res, get_type_dbg_info(mtp));
 
        for (i = 0; i < idx; ++i)
                set_method_param_type(new_mtd, i, new_tp[i]);
@@ -505,7 +505,7 @@ static void *arm_cg_init(be_irg_t *birg) {
 
        if (! int_tp) {
                /* create an integer type with machine size */
-               int_tp = new_type_primitive(new_id_from_chars("int", 3), mode_Is);
+               int_tp = new_type_primitive(mode_Is);
        }
 
        cg = XMALLOC(arm_code_gen_t);
@@ -543,14 +543,14 @@ static void arm_handle_intrinsics(void) {
 
 #define ID(x) new_id_from_chars(x, sizeof(x)-1)
 
-       int_tp  = new_type_primitive(ID("int"), mode_Is);
-       uint_tp = new_type_primitive(ID("uint"), mode_Iu);
+       int_tp  = new_type_primitive(mode_Is);
+       uint_tp = new_type_primitive(mode_Iu);
 
        /* ARM has neither a signed div instruction ... */
        {
                i_instr_record *map_Div = &records[n_records++].i_instr;
 
-               tp = new_type_method(ID("rt_iDiv"), 2, 1);
+               tp = new_type_method(2, 1);
                set_method_param_type(tp, 0, int_tp);
                set_method_param_type(tp, 1, int_tp);
                set_method_res_type(tp, 0, int_tp);
@@ -576,7 +576,7 @@ static void arm_handle_intrinsics(void) {
        {
                i_instr_record *map_Div = &records[n_records++].i_instr;
 
-               tp = new_type_method(ID("rt_uDiv"), 2, 1);
+               tp = new_type_method(2, 1);
                set_method_param_type(tp, 0, uint_tp);
                set_method_param_type(tp, 1, uint_tp);
                set_method_res_type(tp, 0, uint_tp);
@@ -602,7 +602,7 @@ static void arm_handle_intrinsics(void) {
        {
                i_instr_record *map_Mod = &records[n_records++].i_instr;
 
-               tp = new_type_method(ID("rt_iMod"), 2, 1);
+               tp = new_type_method(2, 1);
                set_method_param_type(tp, 0, int_tp);
                set_method_param_type(tp, 1, int_tp);
                set_method_res_type(tp, 0, int_tp);
@@ -628,7 +628,7 @@ static void arm_handle_intrinsics(void) {
        {
                i_instr_record *map_Mod = &records[n_records++].i_instr;
 
-               tp = new_type_method(ID("rt_uMod"), 2, 1);
+               tp = new_type_method(2, 1);
                set_method_param_type(tp, 0, uint_tp);
                set_method_param_type(tp, 1, uint_tp);
                set_method_res_type(tp, 0, uint_tp);
index 2324457..cdabeb8 100644 (file)
@@ -2134,7 +2134,7 @@ static ir_entity *create_pic_symbol(be_main_env_t *be, ir_entity *entity)
        ident     *old_id = get_entity_ld_ident(entity);
        ident     *id     = id_mangle3("L", old_id, "$non_lazy_ptr");
        ir_type   *e_type = get_entity_type(entity);
-       ir_type   *type   = new_type_pointer(id, e_type, mode_P_data);
+       ir_type   *type   = new_type_pointer(e_type);
        ir_type   *parent = be->pic_symbols_type;
        ir_entity *ent    = new_entity(parent, old_id, type);
        set_entity_ld_ident(ent, id);
index 6681423..6872902 100644 (file)
@@ -207,6 +207,13 @@ static void be_emit_tv_as_decimal(tarval *tv) {
        set_tarval_mode_output_option(mode, old);
 }
 
+static void emit_type_name(const ir_type *type)
+{
+       char buf[256];
+       ir_print_type(buf, sizeof(buf), type);
+       be_emit_string(buf);
+}
+
 /**
  * Generates a primitive type.
  *
@@ -233,7 +240,9 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
        type_num = get_type_number(h, tp);
 
        if (mode_is_int(mode)) {
-               be_emit_irprintf("\t.stabs\t\"%s:t%u=r%u;", get_type_name(tp), type_num, type_num);
+               be_emit_cstring("\t.stabs\t\"");
+               emit_type_name(tp);
+               be_emit_irprintf(":t%u=r%u;", type_num, type_num);
                be_emit_tv_as_decimal(get_mode_min(mode));
                be_emit_char(';');
                be_emit_tv_as_decimal(get_mode_max(mode));
@@ -241,7 +250,9 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
                be_emit_write_line();
        } else if (mode_is_float(mode)) {
                int size = get_type_size_bytes(tp);
-               be_emit_irprintf("\t.stabs\t\"%s:t%u=r1;%d;0;\",%d,0,0,0\n", get_type_name(tp), type_num, size, N_LSYM);
+               be_emit_cstring("\t.stabs\t\"");
+               emit_type_name(tp);
+               be_emit_irprintf(":t%u=r1;%d;0;\",%d,0,0,0\n", type_num, size, N_LSYM);
                be_emit_write_line();
        }
 }  /* gen_primitive_type */
@@ -257,13 +268,15 @@ static void gen_enum_type(stabs_handle *h, ir_type *tp) {
        int i, n;
 
        SET_TYPE_READY(tp);
-       be_emit_irprintf("\t.stabs\t\"%s:T%u=e", get_type_name(tp), type_num);
+       be_emit_cstring("\t.stabs\t\"");
+       emit_type_name(tp);
+       be_emit_irprintf(":T%u=e", type_num);
        for (i = 0, n = get_enumeration_n_enums(tp); i < n; ++i) {
                ir_enum_const *ec = get_enumeration_const(tp, i);
                char buf[64];
 
                tarval_snprintf(buf, sizeof(buf), get_enumeration_value(ec));
-               be_emit_irprintf("%s:%s,", get_enumeration_name(ec), buf);
+               be_emit_irprintf("%s:%s,", get_enumeration_const_name(ec), buf);
        }
        be_emit_irprintf(";\",%d,0,0,0\n", N_LSYM);
        be_emit_write_line();
@@ -294,7 +307,9 @@ static void gen_pointer_type(wenv_t *env, ir_type *tp) {
        if (! IS_TYPE_READY(el_tp))
                waitq_put(env->wq, el_tp);
 
-       be_emit_irprintf("\t.stabs\t\"%s:t", get_type_name(tp));
+       be_emit_cstring("\t.stabs\t\"");
+       emit_type_name(tp);
+       be_emit_cstring(":t");
        print_pointer_type(h, tp, 0);
        be_emit_irprintf("\",%d,0,0,0\n", N_LSYM);
        be_emit_write_line();
@@ -345,7 +360,9 @@ static void gen_array_type(wenv_t *env, ir_type *tp) {
        if (! IS_TYPE_READY(etp))
                waitq_put(env->wq, etp);
 
-       be_emit_irprintf("\t.stabs\t\"%s:t", get_type_name(tp));
+       be_emit_cstring("\t.stabs\t\"");
+       emit_type_name(tp);
+       be_emit_cstring(":t");
 
        print_array_type(h, tp, 0);
 
@@ -376,8 +393,9 @@ static void gen_struct_union_type(wenv_t *env, ir_type *tp) {
        else if (is_Union_type(tp))
                desc = 'u';
 
-       be_emit_irprintf("\t.stabs\t\"%s:Tt%u=%c%d",
-               get_type_name(tp), type_num, desc, get_type_size_bytes(tp));
+       be_emit_cstring("\t.stabs\t\"");
+       emit_type_name(tp);
+       be_emit_irprintf(":Tt%u=%c%d", type_num, desc, get_type_size_bytes(tp));
 
        for (i = 0, n = get_compound_n_members(tp); i < n; ++i) {
                ir_entity *ent = get_compound_member(tp, i);
@@ -449,7 +467,9 @@ static void gen_method_type(wenv_t *env, ir_type *tp) {
        }
        res_type_num = get_type_number(h, rtp);
 
-       be_emit_irprintf("\t.stabs\t\"%s:t%u=f%u", get_type_name(tp), type_num, res_type_num);
+       be_emit_cstring("\t.stabs\t\"");
+       emit_type_name(tp);
+       be_emit_irprintf(":t%u=f%u", type_num, res_type_num);
 
        /* handle more than one return type */
        for (i = 1; i < n; ++i) {
index 5076630..cd6469f 100644 (file)
@@ -443,8 +443,8 @@ static void ia32_build_between_type(void)
 {
 #define IDENT(s) new_id_from_chars(s, sizeof(s)-1)
        if (! between_type) {
-               ir_type *old_bp_type   = new_type_primitive(IDENT("bp"), mode_Iu);
-               ir_type *ret_addr_type = new_type_primitive(IDENT("return_addr"), mode_Iu);
+               ir_type *old_bp_type   = new_type_primitive(mode_Iu);
+               ir_type *ret_addr_type = new_type_primitive(mode_Iu);
 
                between_type           = new_type_struct(IDENT("ia32_between_type"));
                old_bp_ent             = new_entity(between_type, IDENT("old_bp"), old_bp_type);
@@ -866,7 +866,7 @@ static void ia32_before_abi(void *self)
                be_dump(cg->irg, "-lower_modeb", dump_ir_block_graph_sched);
        if (cg->gprof) {
                if (mcount == NULL) {
-                       ir_type *tp = new_type_method(ID("FKT.mcount"), 0, 0);
+                       ir_type *tp = new_type_method(0, 0);
                        mcount = new_entity(get_glob_type(), ID("mcount"), tp);
                        /* FIXME: enter the right ld_ident here */
                        set_entity_ld_ident(mcount, get_entity_ident(mcount));
index d81b1cf..fee0618 100644 (file)
@@ -93,9 +93,7 @@ static ir_type *ia32_get_prim_type(pmap *types, ir_mode *mode)
        ir_type *res;
 
        if (! e) {
-               char buf[64];
-               snprintf(buf, sizeof(buf), "prim_type_%s", get_mode_name(mode));
-               res = new_type_primitive(new_id_from_str(buf), mode);
+               res = new_type_primitive(mode);
                if (get_mode_size_bits(mode) >= 80) {
                        set_type_alignment_bytes(res, 16);
                }
index 3d69430..bb6aee7 100644 (file)
@@ -56,7 +56,7 @@ static ir_entity *fpcw_truncate = NULL;
 static ir_entity *create_ent(int value, const char *name)
 {
        ir_mode   *mode = mode_Hu;
-       ir_type   *type = new_type_primitive(new_id_from_str("_fpcw_type"), mode);
+       ir_type   *type = new_type_primitive(mode);
        ir_type   *glob = get_glob_type();
        ir_graph  *cnst_irg;
        ir_entity *ent;
index ca1cf87..2543684 100644 (file)
@@ -370,8 +370,8 @@ static ir_node *gen_SymConst(ir_node *node)
  * @param mode   the mode for the float type (might be integer mode for SSE2 types)
  * @param align  alignment
  */
-static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
-       char    buf[32];
+static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align)
+{
        ir_type *tp;
 
        assert(align <= 16);
@@ -380,8 +380,7 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
                static ir_type *int_Iu[16] = {NULL, };
 
                if (int_Iu[align] == NULL) {
-                       snprintf(buf, sizeof(buf), "int_Iu_%u", align);
-                       int_Iu[align] = tp = new_type_primitive(new_id_from_str(buf), mode);
+                       int_Iu[align] = tp = new_type_primitive(mode);
                        /* set the specified alignment */
                        set_type_alignment_bytes(tp, align);
                }
@@ -390,8 +389,7 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
                static ir_type *int_Lu[16] = {NULL, };
 
                if (int_Lu[align] == NULL) {
-                       snprintf(buf, sizeof(buf), "int_Lu_%u", align);
-                       int_Lu[align] = tp = new_type_primitive(new_id_from_str(buf), mode);
+                       int_Lu[align] = tp = new_type_primitive(mode);
                        /* set the specified alignment */
                        set_type_alignment_bytes(tp, align);
                }
@@ -400,8 +398,7 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
                static ir_type *float_F[16] = {NULL, };
 
                if (float_F[align] == NULL) {
-                       snprintf(buf, sizeof(buf), "float_F_%u", align);
-                       float_F[align] = tp = new_type_primitive(new_id_from_str(buf), mode);
+                       float_F[align] = tp = new_type_primitive(mode);
                        /* set the specified alignment */
                        set_type_alignment_bytes(tp, align);
                }
@@ -410,8 +407,7 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
                static ir_type *float_D[16] = {NULL, };
 
                if (float_D[align] == NULL) {
-                       snprintf(buf, sizeof(buf), "float_D_%u", align);
-                       float_D[align] = tp = new_type_primitive(new_id_from_str(buf), mode);
+                       float_D[align] = tp = new_type_primitive(mode);
                        /* set the specified alignment */
                        set_type_alignment_bytes(tp, align);
                }
@@ -420,8 +416,7 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
                static ir_type *float_E[16] = {NULL, };
 
                if (float_E[align] == NULL) {
-                       snprintf(buf, sizeof(buf), "float_E_%u", align);
-                       float_E[align] = tp = new_type_primitive(new_id_from_str(buf), mode);
+                       float_E[align] = tp = new_type_primitive(mode);
                        /* set the specified alignment */
                        set_type_alignment_bytes(tp, align);
                }
@@ -434,8 +429,8 @@ static ir_type *ia32_create_float_type(ir_mode *mode, unsigned align) {
  *
  * @param tp  the atomic type
  */
-static ir_type *ia32_create_float_array(ir_type *tp) {
-       char     buf[32];
+static ir_type *ia32_create_float_array(ir_type *tp)
+{
        ir_mode  *mode = get_type_mode(tp);
        unsigned align = get_type_alignment_bytes(tp);
        ir_type  *arr;
@@ -447,22 +442,19 @@ static ir_type *ia32_create_float_array(ir_type *tp) {
 
                if (float_F[align] != NULL)
                        return float_F[align];
-               snprintf(buf, sizeof(buf), "arr_float_F_%u", align);
-               arr = float_F[align] = new_type_array(new_id_from_str(buf), 1, tp);
+               arr = float_F[align] = new_type_array(1, tp);
        } else if (mode == mode_D) {
                static ir_type *float_D[16] = {NULL, };
 
                if (float_D[align] != NULL)
                        return float_D[align];
-               snprintf(buf, sizeof(buf), "arr_float_D_%u", align);
-               arr = float_D[align] = new_type_array(new_id_from_str(buf), 1, tp);
+               arr = float_D[align] = new_type_array(1, tp);
        } else {
                static ir_type *float_E[16] = {NULL, };
 
                if (float_E[align] != NULL)
                        return float_E[align];
-               snprintf(buf, sizeof(buf), "arr_float_E_%u", align);
-               arr = float_E[align] = new_type_array(new_id_from_str(buf), 1, tp);
+               arr = float_E[align] = new_type_array(1, tp);
        }
        set_type_alignment_bytes(arr, align);
        set_type_size_bytes(arr, 2 * get_type_size_bytes(tp));
index b72d88f..c49a0bd 100644 (file)
@@ -535,9 +535,9 @@ static ir_type *mips_abi_get_between_type(void *self) {
        if(env->debug && debug_between_type == NULL) {
                ir_entity *a0_ent, *a1_ent, *a2_ent, *a3_ent;
                ir_entity *ret_addr_ent;
-               ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
-               ir_type *old_fp_type   = new_type_primitive(new_id_from_str("fp"), mode_P);
-               ir_type *old_param_type = new_type_primitive(new_id_from_str("param"), mode_Iu);
+               ir_type *ret_addr_type = new_type_primitive(mode_P);
+               ir_type *old_fp_type   = new_type_primitive(mode_P);
+               ir_type *old_param_type = new_type_primitive(mode_Iu);
 
                debug_between_type     = new_type_class(new_id_from_str("mips_between_type"));
                a0_ent                             = new_entity(debug_between_type, new_id_from_str("a0_ent"), old_param_type);
@@ -556,7 +556,7 @@ static ir_type *mips_abi_get_between_type(void *self) {
 
                set_type_size_bytes(debug_between_type, 24);
        } else if(!env->debug && opt_between_type == NULL) {
-               ir_type *old_fp_type   = new_type_primitive(new_id_from_str("fp"), mode_P);
+               ir_type *old_fp_type   = new_type_primitive(mode_P);
                ir_entity *old_fp_ent;
 
                opt_between_type       = new_type_class(new_id_from_str("mips_between_type"));
index 06cced8..6268c71 100644 (file)
@@ -160,8 +160,8 @@ static ir_type *ppc32_abi_get_between_type(void *self)
 
        if(!between_type) {
                ir_entity *ret_addr_ent;
-               ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
-               ir_type *old_bp_type   = new_type_primitive(new_id_from_str("bp"), mode_P);
+               ir_type *ret_addr_type = new_type_primitive(mode_P);
+               ir_type *old_bp_type   = new_type_primitive(mode_P);
 
                between_type           = new_type_class(new_id_from_str("ppc32_between_type"));
                old_bp_ent             = new_entity(between_type, new_id_from_str("old_bp"), old_bp_type);
index 625068f..ca0d274 100644 (file)
@@ -1395,7 +1395,7 @@ static ir_node *gen_fp_known_symconst(ppc32_transform_env_t *env, tarval *known_
        if(!const_set)
                const_set = new_set(cmp_tv_ent, 10);
        if(!tp)
-               tp = new_type_primitive(new_id_from_str("const_double_t"), env->mode);
+               tp = new_type_primitive(env->mode);
 
        key.tv  = known_const;
        key.ent = NULL;
index ba10cfe..9f6f497 100644 (file)
@@ -81,9 +81,9 @@ static ir_node *own_gen_convert_call(ppc32_transform_env_t *env, ir_node *op, co
 
        in[0] = op;
 
-       method_type = new_type_method(new_id_from_str("convert_call_type"), 1, 1);
-       set_method_param_type(method_type, 0, new_type_primitive(new_id_from_str("conv_param"), from_mode));
-       set_method_res_type(method_type, 0, new_type_primitive(new_id_from_str("conv_result"), to_mode));
+       method_type = new_type_method(1, 1);
+       set_method_param_type(method_type, 0, new_type_primitive(from_mode));
+       set_method_res_type(method_type, 0, new_type_primitive(to_mode));
 
        method_ent   = new_entity(get_glob_type(), new_id_from_str(funcname), method_type);
        callee       = new_rd_SymConst_addr_ent(env->dbg, env->irg, mode_P_code, method_ent, method_type);
index 212b59a..3e4d72a 100644 (file)
@@ -222,7 +222,7 @@ static void *sparc_cg_init(be_irg_t *birg)
 
        if (! int_tp) {
                /* create an integer type with machine size */
-               int_tp = new_type_primitive(new_id_from_chars("int", 3), mode_Is);
+               int_tp = new_type_primitive(mode_Is);
        }
 
        cg                               = XMALLOC(sparc_code_gen_t);
index 3d6c417..724e6e0 100644 (file)
@@ -124,7 +124,7 @@ void ir_init(const firm_parameter_t *param)
           later. */
        init_irprog_2();
        /* Initialize the type module and construct some idents needed. */
-       firm_init_type(def_params.builtin_dbg, def_params.cc_mask);
+       firm_init_type(def_params.cc_mask);
        /* initialize the entity module */
        firm_init_entity();
        /* class cast optimization */
index 4e233ed..99c4f10 100644 (file)
@@ -77,9 +77,12 @@ void firm_identify_thing(void *X) {
        case k_entity:
                printf("entity: %s: %ld (%p)\n", get_entity_name(X), get_entity_nr(X), X);
                break;
-       case k_type:
-               printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X);
+       case k_type: {
+               char buf[256];
+               ir_print_type(buf, sizeof(buf), X);
+               printf("type: %s '%s': %ld (%p)\n", get_type_tpop_name(X), buf, get_type_nr(X), X);
                break;
+       }
        case k_ir_graph:
                printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), X);
                break;
index 9941700..d7eb835 100644 (file)
@@ -102,15 +102,14 @@ void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
 }
 
 /** The debug info retriever function. */
-static retrieve_dbg_func retrieve_dbg = NULL;
+static retrieve_dbg_func      retrieve_dbg      = NULL;
+static retrieve_type_dbg_func retrieve_type_dbg = NULL;
 
-/* Sets a debug info retriever. */
 void ir_set_debug_retrieve(retrieve_dbg_func func)
 {
        retrieve_dbg = func;
 }
 
-/* Retrieve the debug info. */
 const char *ir_retrieve_dbg_info(const dbg_info *dbg, unsigned *line)
 {
        if (retrieve_dbg)
@@ -120,6 +119,17 @@ const char *ir_retrieve_dbg_info(const dbg_info *dbg, unsigned *line)
        return NULL;
 }
 
+void ir_set_type_debug_retrieve(retrieve_type_dbg_func func)
+{
+       retrieve_type_dbg = func;
+}
+
+void ir_retrieve_type_dbg_info(char *buffer, size_t buffer_size,
+                               const type_dbg_info *tdbgi)
+{
+       retrieve_type_dbg(buffer, buffer_size, tdbgi);
+}
+
 void ir_dbg_info_snprint(char *buf, size_t bufsize, const dbg_info *dbg)
 {
        unsigned    line;
index beba7e6..4bb9d89 100644 (file)
@@ -400,18 +400,6 @@ static void dbg_new_type(void *ctx, ir_type *tp)
                        firm_debug_break();
                }
        }
-       {
-               bp_ident_t key, *elem;
-
-               key.id        = get_type_ident(tp);
-               key.bp.reason = BP_ON_NEW_TYPE;
-
-               elem = set_find(bp_idents, &key, sizeof(key), HASH_IDENT_BP(key));
-               if (elem && elem->bp.active) {
-                       dbg_printf("Firm BP %u reached, %+F was created\n", elem->bp.bpnr, tp);
-                       firm_debug_break();
-               }
-       }
 }  /* dbg_new_type */
 
 /**
@@ -734,11 +722,14 @@ static ir_type *find_type_name(const char *name) {
 
        for (i = 0; i < n; ++i) {
                tp = get_irp_type(i);
-               if (strcmp(get_type_name(tp), name) == 0)
+               if (!is_compound_type(tp))
+                       continue;
+
+               if (strcmp(get_compound_name(tp), name) == 0)
                        return tp;
        }
        tp = get_glob_type();
-       if (strcmp(get_type_name(tp), name) == 0)
+       if (strcmp(get_compound_name(tp), name) == 0)
                return tp;
        return NULL;
 }  /* find_type_name */
@@ -816,7 +807,7 @@ static void show_by_name(type_or_ent tore, void *env) {
                                ir_graph *irg = get_entity_irg(ent);
 
                                if (owner != get_glob_type()) {
-                                       printf("%s::%s", get_type_name(owner), get_id_str(id));
+                                       printf("%s::%s", get_compound_name(owner), get_id_str(id));
                                } else {
                                        printf("%s", get_id_str(id));
                                }
@@ -844,7 +835,7 @@ static void show_by_ldname(type_or_ent tore, void *env) {
                                ir_graph *irg = get_entity_irg(ent);
 
                                if (owner != get_glob_type()) {
-                                       printf("%s::%s", get_type_name(owner), get_id_str(id));
+                                       printf("%s::%s", get_compound_name(owner), get_id_str(id));
                                } else {
                                        printf("%s", get_id_str(id));
                                }
index 4713de4..77617ae 100644 (file)
@@ -136,10 +136,14 @@ static int firm_emit(lc_appendable_t *app,
                        isupper(occ->conversion) ? get_entity_ld_name_ex(X): get_entity_name(X));
                snprintf(add, sizeof(add), "[%ld]", get_entity_nr(X));
                break;
-       case k_type:
-               snprintf(buf, sizeof(buf), "%s%s:%s", A("type"), get_type_tpop_name(X), get_type_name(X));
+       case k_type: {
+               char type_name[256];
+               ir_print_type(type_name, sizeof(type_name), X);
+               snprintf(buf, sizeof(buf), "%s%s:%s", A("type"), get_type_tpop_name(X),
+                        type_name);
                snprintf(add, sizeof(add), "[%ld]", get_type_nr(X));
                break;
+       }
        case k_ir_graph:
                if (X == get_const_code_irg())
                        snprintf(buf, sizeof(buf), "%s<ConstCodeIrg>", A("irg"));
index ade9ba5..462f062 100644 (file)
@@ -259,17 +259,6 @@ const char *get_mode_name_ex(const ir_mode *mode, int *bad) {
        return ERROR_TXT;
 }
 
-/**
- * returns the name of a type or <ERROR> if mode is NOT a mode object.
- * in the later case, sets bad
- */
-const char *get_type_name_ex(const ir_type *tp, int *bad) {
-       if (is_type(tp))
-               return get_type_name(tp);
-       *bad |= 1;
-       return ERROR_TXT;
-}
-
 #define CUSTOM_COLOR_BASE    100
 static const char *color_names[ird_color_count];
 static const char *color_rgb[ird_color_count];
@@ -760,16 +749,16 @@ int dump_node_opcode(FILE *F, ir_node *n)
                        fprintf(F, "SymC %s offset", get_entity_name(get_SymConst_entity(n)));
                        break;
                case symconst_type_tag:
-                       fprintf(F, "SymC %s tag", get_type_name_ex(get_SymConst_type(n), &bad));
+                       ir_fprintf(F, "SymC %+F tag", get_SymConst_type(n));
                        break;
                case symconst_type_size:
-                       fprintf(F, "SymC %s size", get_type_name_ex(get_SymConst_type(n), &bad));
+                       ir_fprintf(F, "SymC %+F size", get_SymConst_type(n));
                        break;
                case symconst_type_align:
-                       fprintf(F, "SymC %s align", get_type_name_ex(get_SymConst_type(n), &bad));
+                       ir_fprintf(F, "SymC %+F align", get_SymConst_type(n));
                        break;
                case symconst_enum_const:
-                       fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n)));
+                       fprintf(F, "SymC %s enum", get_enumeration_const_name(get_SymConst_enum(n)));
                        break;
                }
                break;
@@ -903,10 +892,11 @@ static int dump_node_typeinfo(FILE *F, ir_node *n) {
                if (get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_consistent  ||
                        get_irg_typeinfo_state(current_ir_graph) == ir_typeinfo_inconsistent) {
                        ir_type *tp = get_irn_typeinfo_type(n);
-                       if (tp != firm_none_type)
-                               fprintf(F, "[%s] ", get_type_name_ex(tp, &bad));
-                       else
+                       if (tp != firm_none_type) {
+                               ir_fprintf(F, "[%+F]", tp);
+                       } else {
                                fprintf(F, "[] ");
+                       }
                }
        }
        return bad;
@@ -1158,13 +1148,13 @@ handle_lut:
                fprintf(F, "%s ", get_ent_dump_name(get_Sel_entity(n)));
                break;
        case iro_Cast:
-               fprintf(F, "(%s) ", get_type_name_ex(get_Cast_type(n), &bad));
+               ir_fprintf(F, "(%+F)", get_Cast_type(n));
                break;
        case iro_Confirm:
                fprintf(F, "%s ", get_pnc_string(get_Confirm_cmp(n)));
                break;
        case iro_CopyB:
-               fprintf(F, "(%s) ", get_type_name_ex(get_CopyB_type(n), &bad));
+               ir_fprintf(F, "(%+F)", get_CopyB_type(n));
                break;
 
        default:
@@ -1436,6 +1426,13 @@ static void print_dbg_info(FILE *F, dbg_info *dbg)
        }
 }
 
+static void print_type_dbg_info(FILE *F, type_dbg_info *dbg)
+{
+       (void) F;
+       (void) dbg;
+       /* TODO */
+}
+
 /**
  * Dump a node
  */
@@ -1982,16 +1979,10 @@ int dump_type_node(FILE *F, ir_type *tp)
 
        fprintf(F, "node: {title: ");
        PRINT_TYPEID(tp);
-       fprintf(F, " label: \"%s %s\"", get_type_tpop_name(tp), get_type_name_ex(tp, &bad));
-       fprintf(F, " info1: \"");
-#if 0
-       bad |= print_type_info(F, tp);
-       print_typespecific_info(F, tp);
-#else
+       ir_fprintf(F, " label: \"%s %+F\" info1: \"", get_type_tpop_name(tp), tp);
        dump_type_to_file(F, tp, dump_verbosity_max);
-#endif
        fprintf(F, "\"\n");
-       print_dbg_info(F, get_type_dbg_info(tp));
+       print_type_dbg_info(F, get_type_dbg_info(tp));
        print_typespecific_vcgattr(F, tp);
        fprintf(F, "}\n");
 
@@ -2021,7 +2012,7 @@ static void dump_enum_item(FILE *F, ir_type *tp, int pos)
 {
        char buf[1024];
        ir_enum_const *ec = get_enumeration_const(tp, pos);
-       ident         *id = get_enumeration_nameid(ec);
+       ident         *id = get_enumeration_const_nameid(ec);
        tarval        *tv = get_enumeration_value(ec);
 
        if (tv)
index baea297..69a1838 100644 (file)
@@ -99,7 +99,6 @@ const char *get_irg_dump_name(const ir_graph *irg);
 
 
 const char *get_ent_dump_name(const ir_entity *ent);
-const char *get_type_name_ex(const ir_type *tp, int *bad);
 const char *get_mode_name_ex(const ir_mode *mode, int *bad);
 /**
  * dump the name of a node n to the File F.
index 7f2267e..31aa27e 100644 (file)
@@ -224,9 +224,9 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
        }  break;
        case iro_Start: {
                ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
-               fprintf(F, "  start of method of type %s\n", get_type_name_ex(tp, &bad));
+               ir_fprintf(F, "  start of method of type %+F\n", tp);
                for (i = 0; i < get_method_n_params(tp); ++i)
-                       fprintf(F, "    param %d type: %s\n", i, get_type_name_ex(get_method_param_type(tp, i), &bad));
+                       ir_fprintf(F, "    param %d type: %+F\n", i, get_method_param_type(tp, i));
 #ifdef INTERPROCEDURAL_VIEW
                if ((get_irp_ip_view_state() == ip_view_valid) && !get_interprocedural_view()) {
                        ir_node *sbl = get_nodes_block(n);
@@ -234,32 +234,36 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                        fprintf(F, "  graph has %d interprocedural predecessors:\n", n_cfgpreds);
                        for (i = 0; i < n_cfgpreds; ++i) {
                                ir_node *cfgpred = get_Block_cg_cfgpred(sbl, i);
-                               fprintf(F, "    %d: Call %ld in graph %s\n", i, get_irn_node_nr(cfgpred),
-                                       get_irg_dump_name(get_irn_irg(cfgpred)));
+                               fprintf(F, "    %d: Call %ld in graph %s\n", i,
+                                       get_irn_node_nr(cfgpred),
+                                       get_irg_dump_name(get_irn_irg(cfgpred)));
                        }
                }
 #endif
        } break;
        case iro_Cond: {
-               fprintf(F, "  condition kind: %s\n",  get_Cond_kind(n) == dense ? "dense" : "fragmentary");
+               fprintf(F, "  condition kind: %s\n",
+                       get_Cond_kind(n) == dense ? "dense" : "fragmentary");
                fprintf(F, "  default ProjNr: %ld\n", get_Cond_default_proj(n));
-               if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE)
-                       fprintf(F, "  jump prediction: %s\n", get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
+               if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
+                       fprintf(F, "  jump prediction: %s\n",
+                               get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
+               }
        } break;
        case iro_Alloc: {
-               fprintf(F, "  allocating entity of type: %s\n", get_type_name_ex(get_Alloc_type(n), &bad));
+               ir_fprintf(F, "  allocating entity of type: %+F\n", get_Alloc_type(n));
                fprintf(F, "  allocating on: the %s\n", (get_Alloc_where(n) == stack_alloc) ? "stack" : "heap");
        } break;
        case iro_Free: {
-               fprintf(F, "  freeing entity of type %s\n", get_type_name_ex(get_Free_type(n), &bad));
+               ir_fprintf(F, "  freeing entity of type %+F\n", get_Free_type(n));
                fprintf(F, "  allocated on: the %s\n", (get_Free_where(n) == stack_alloc) ? "stack" : "heap");
        } break;
        case iro_Sel: {
                ir_entity *ent = get_Sel_entity(n);
                if (ent) {
                        fprintf(F, "  Selecting entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
-                       fprintf(F, "    of type    %s\n",  get_type_name_ex(get_entity_type(ent),  &bad));
-                       fprintf(F, "    with owner %s.\n", get_type_name_ex(get_entity_owner(ent), &bad));
+                       ir_fprintf(F, "    of type    %+F\n",  get_entity_type(ent));
+                       ir_fprintf(F, "    with owner %+F.\n", get_entity_owner(ent));
                }
                else {
                        fprintf(F, "  <NULL entity>\n");
@@ -270,12 +274,12 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                ir_type *tp = get_Call_type(n);
                if (get_Call_tail_call(n))
                        fprintf(F, "  tail call\n");
-               fprintf(F, "  calling method of type %s\n", get_type_name_ex(tp, &bad));
+               ir_fprintf(F, "  calling method of type %+F\n", tp);
                if(get_unknown_type() != tp) {
                        for (i = 0; i < get_method_n_params(tp); ++i)
-                               fprintf(F, "    param %d type: %s\n", i, get_type_name_ex(get_method_param_type(tp, i), &bad));
+                               ir_fprintf(F, "    param %d type: %+F\n", i, get_method_param_type(tp, i));
                        for (i = 0; i < get_method_n_ress(tp); ++i)
-                               fprintf(F, "    resul %d type: %s\n", i, get_type_name_ex(get_method_res_type(tp, i), &bad));
+                               ir_fprintf(F, "    result %d type: %+F\n", i, get_method_res_type(tp, i));
                }
                if (Call_has_callees(n)) {
                        fprintf(F, "  possible callees:\n");
@@ -295,19 +299,21 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                }
        } break;
        case iro_Cast: {
-               fprintf(F, "  cast to type: %s\n", get_type_name_ex(get_Cast_type(n), &bad));
+               ir_fprintf(F, "  cast to type: %+F\n", get_Cast_type(n));
        } break;
        case iro_Return: {
                if (!get_interprocedural_view()) {
                        ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
-                       fprintf(F, "  return in method of type %s\n", get_type_name_ex(tp, &bad));
-                       for (i = 0; i < get_method_n_ress(tp); ++i)
-                               fprintf(F, "    res %d type: %s\n", i, get_type_name_ex(get_method_res_type(tp, i), &bad));
+                       ir_fprintf(F, "  return in method of type %+F\n", tp);
+                       for (i = 0; i < get_method_n_ress(tp); ++i) {
+                               ir_fprintf(F, "    result %d type: %+F\n", i,
+                                          get_method_res_type(tp, i));
+                       }
                }
        } break;
        case iro_Const: {
                assert(get_Const_type(n) != firm_none_type);
-               fprintf(F, "  Const of type %s\n", get_type_name_ex(get_Const_type(n), &bad));
+               ir_fprintf(F, "  Const of type %+F\n", get_Const_type(n));
        } break;
        case iro_SymConst: {
                switch(get_SymConst_kind(n)) {
@@ -342,10 +348,10 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
                        break;
                case symconst_enum_const:
                        fprintf(F, "  kind: enumeration\n");
-                       fprintf(F, "  name: %s\n", get_enumeration_name(get_SymConst_enum(n)));
+                       fprintf(F, "  name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
                        break;
                }
-               fprintf(F, "  type of value: %s\n", get_type_name_ex(get_SymConst_value_type(n), &bad));
+               ir_fprintf(F, "  type of value: %+F\n", get_SymConst_value_type(n));
        } break;
        case iro_Load:
                fprintf(F, "  mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), &bad));
@@ -396,7 +402,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
        if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent  ||
                get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent  )
                if (get_irn_typeinfo_type(n) != firm_none_type)
-                       fprintf (F, "  Analysed type: %s\n", get_type_name_ex(get_irn_typeinfo_type(n), &bad));
+                       ir_fprintf (F, "  Analysed type: %s\n", get_irn_typeinfo_type(n));
 
        return bad;
 }
@@ -533,8 +539,7 @@ static void dump_type_list(FILE *F, ir_type *tp, char *prefix,
                        fprintf(F, ",\n%s   ", prefix);
                        comma = "";
                }
-               fprintf(F, "%s %s(%ld)", comma, get_type_name(get_type(tp, i)), get_type_nr(tp));
-               //dump_type_to_file(F, get_type(tp, i), dump_verbosity_onlynames);
+               ir_fprintf(F, "%s %+F", comma, get_type(tp, i));
                comma = ",";
        }
        fprintf(F, "\n");
@@ -619,23 +624,23 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
        owner = get_entity_owner(ent);
        type  = get_entity_type(ent);
        if (verbosity & dump_verbosity_onlynames) {
-               fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_type_name(get_entity_owner(ent)),
+               fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
                        get_entity_name(ent), get_entity_nr(ent));
                return;
        }
 
        if (verbosity & dump_verbosity_entattrs) {
                fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
-               fprintf(F, "%s  type:  %s (%ld)\n", prefix, get_type_name(type),  get_type_nr(type));
-               fprintf(F, "%s  owner: %s (%ld)\n", prefix, get_type_name(owner), get_type_nr(owner));
+               ir_fprintf(F, "%s  type:  %+F\n", prefix, type);
+               ir_fprintf(F, "%s  owner: %+F\n", prefix, owner);
 
                if (is_Class_type(get_entity_owner(ent))) {
                        if (get_entity_n_overwrites(ent) > 0) {
                                fprintf(F, "%s  overwrites:\n", prefix);
                                for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
                                        ir_entity *ov = get_entity_overwrites(ent, i);
-                                       fprintf(F, "%s    %d: %s of class %s\n", prefix, i, get_entity_name(ov),
-                                               get_type_name(get_entity_owner(ov)));
+                                       ir_fprintf(F, "%s    %d: %s of class %+F\n", prefix, i,
+                                               get_entity_name(ov), get_entity_owner(ov));
                                }
                        } else {
                                fprintf(F, "%s  Does not overwrite other entities.\n", prefix);
@@ -644,11 +649,12 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
                                fprintf(F, "%s  overwritten by:\n", prefix);
                                for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
                                        ir_entity *ov = get_entity_overwrittenby(ent, i);
-                                       fprintf(F, "%s    %d: %s of class %s\n", prefix, i, get_entity_name(ov),
-                                               get_type_name(get_entity_owner(ov)));
+                                       ir_fprintf(F, "%s    %d: %s of class %+F\n", prefix, i,
+                                                  get_entity_name(ov), get_entity_owner(ov));
                                }
                        } else {
-                               fprintf(F, "%s  Is not overwritten by other entities.\n", prefix);
+                               fprintf(F, "%s  Is not overwritten by other entities.\n",
+                                       prefix);
                        }
 
                        if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
@@ -657,15 +663,15 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
                                for (ov = get_entity_trans_overwrites_first(ent);
                                ov;
                                ov = get_entity_trans_overwrites_next(ent)) {
-                                       fprintf(F, "%s    : %s of class %s\n", prefix, get_entity_name(ov),
-                                               get_type_name(get_entity_owner(ov)));
+                                       ir_fprintf(F, "%s    : %s of class %+F\n", prefix,
+                                                  get_entity_name(ov), get_entity_owner(ov));
                                }
                                fprintf(F, "%s  transitive overwritten by:\n", prefix);
                                for (ov = get_entity_trans_overwrittenby_first(ent);
                                ov;
                                ov = get_entity_trans_overwrittenby_next(ent)) {
-                                       fprintf(F, "%s    : %s of class %s\n", prefix, get_entity_name(ov),
-                                               get_type_name(get_entity_owner(ov)));
+                                       ir_fprintf(F, "%s    : %s of class %+F\n", prefix,
+                                                  get_entity_name(ov), get_entity_owner(ov));
                                }
                        }
                }
@@ -719,9 +725,9 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
 
                fputc('\n', F);
        } else {  /* no entattrs */
-               fprintf(F, "%s(%3d:%d) %-40s: %s", prefix,
+               ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
                        get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
-                       get_type_name(get_entity_type(ent)), get_entity_name(ent));
+                       get_entity_type(ent), get_entity_name(ent));
                if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
 
                if (verbosity & dump_verbosity_accessStats) {
@@ -990,7 +996,7 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix,
 
        if (get_entity_allocation(ent) != allocation_static) {
 
-               fprintf(F, "%s_%s", get_type_name(get_entity_owner(ent)), get_entity_name(ent));
+               ir_fprintf(F, "%+F_%s", get_entity_owner(ent), get_entity_name(ent));
 
                if (max_L_freq >= 0) {
                        fprintf(F, "%s Load", comma);
@@ -999,7 +1005,10 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix,
                        }
                }
                if (max_S_freq >= 0) {
-                       if (max_L_freq >= 0)    fprintf(F, "\n%s_%s", get_type_name(get_entity_owner(ent)), get_entity_name(ent));
+                       if (max_L_freq >= 0) {
+                               ir_fprintf(F, "\n%+F_%s", get_entity_owner(ent),
+                                          get_entity_name(ent));
+                       }
                        fprintf(F, "%s Store", comma);
                        for (i = 0; i <= max_S_freq; ++i) {
                                fprintf(F, "%s %d", comma, S_freq[i]);
@@ -1036,7 +1045,7 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix,
 /* A fast hack to dump a CSV-file. */
 void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const char *comma) {
        int i;
-       char buf[1024 + 10];
+       char buf[1024];
        (void) comma;
 
        if (!is_Class_type(tp)) return;   // we also want array types. Stupid, these are classes in java.
@@ -1070,7 +1079,7 @@ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const
                        assert(is_Alloc(all));
                }
 
-               fprintf(F, "%s ", get_type_name(tp));
+               ir_fprintf(F, "%+F ", tp);
                fprintf(F, "%s Alloc ", comma);
 
                if (max_freq >= 0) {
@@ -1091,7 +1100,7 @@ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const
                }
 
                if (max_disp >= 0) {
-                       fprintf(F, "%s__disp_tab%s Load", get_type_name(tp), comma);
+                       ir_fprintf(F, "%+F__disp_tab%s Load", tp, comma);
                        for (i = 0; i <= max_disp; ++i) {
                                fprintf(F, "%s %d", comma, disp[i]);
                        }
@@ -1104,9 +1113,9 @@ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const
 
 #define DISP_TAB_SUFFIX "__disp_tab"
                if (get_trouts_state() != outs_none) {
-                       assert(strlen(get_type_name(tp)) < 1024);
-                       fprintf(F, "%-44s %6.2lf  -1.00\n", get_type_name(tp), get_type_estimated_n_instances(tp));
-                       sprintf(buf, "%s%s", get_type_name(tp), DISP_TAB_SUFFIX);
+                       ir_fprintf(F, "%+F %6.2lf  -1.00\n", tp,
+                                  get_type_estimated_n_instances(tp));
+                       ir_snprintf(buf, sizeof(buf), "%+F%s", tp, DISP_TAB_SUFFIX);
                        fprintf(F, "%-44s %6.2lf   0.00\n", buf, get_class_estimated_n_dyncalls(tp));
                }
 
@@ -1135,7 +1144,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
        if ((is_Primitive_type(tp))   && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
        if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
 
-       fprintf(F, "%s type %s (%ld)", get_tpop_name(get_type_tpop(tp)), get_type_name(tp), get_type_nr(tp));
+       ir_fprintf(F, "%+F", tp);
        if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
 
        switch (get_type_tpop_code(tp)) {
@@ -1157,12 +1166,12 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
                        fprintf(F, "  supertypes: ");
                        for (i = 0; i < get_class_n_supertypes(tp); ++i) {
                                ir_type *stp = get_class_supertype(tp, i);
-                               fprintf(F, "\n    %d %s", i, get_type_name(stp));
+                               ir_fprintf(F, "\n    %d %+F", i, stp);
                        }
                        fprintf(F, "\n  subtypes: ");
                        for (i = 0; i < get_class_n_subtypes(tp); ++i) {
                                ir_type *stp = get_class_subtype(tp, i);
-                               fprintf(F, "\n    %d %s", i, get_type_name(stp));
+                               ir_fprintf(F, "\n    %d %+F", i, stp);
                        }
 
                        if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
@@ -1171,13 +1180,13 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
                                for (stp = get_class_trans_supertype_first(tp);
                                stp;
                                stp = get_class_trans_supertype_next(tp)) {
-                                       fprintf(F, "\n    %s", get_type_name(stp));
+                                       ir_fprintf(F, "\n    %+F", stp);
                                }
                                fprintf(F, "\n  transitive subtypes: ");
                                for (stp = get_class_trans_subtype_first(tp);
                                stp;
                                stp = get_class_trans_subtype_next(tp)) {
-                                       fprintf(F, "\n    %s", get_type_name(stp));
+                                       ir_fprintf(F, "\n    %+F", stp);
                                }
                        }
 
@@ -1234,7 +1243,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
                                        fprintf(F, " %ld]", get_irn_node_nr(upper));
                                }
                        }
-                       fprintf(F, " of <%s (%ld)>", get_type_name(elem_tp), get_type_nr(elem_tp));
+                       ir_fprintf(F, " of <%+F>", elem_tp);
 
                        fprintf(F, "\n  order: ");
                        for (i = 0; i < n_dim; ++i)
@@ -1252,7 +1261,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
        case tpo_pointer:
                if (verbosity & dump_verbosity_typeattrs) {
                        ir_type *tt = get_pointer_points_to_type(tp);
-                       fprintf(F, "\n  points to %s (%ld)\n", get_type_name(tt), get_type_nr(tt));
+                       ir_fprintf(F, "\n  points to %+F\n", tt);
                }
                break;
 
@@ -1262,13 +1271,13 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
                        fprintf(F, "\n  return types: %d", get_method_n_ress(tp));
                        for (i = 0; i < get_method_n_ress(tp); ++i) {
                                ir_type *rtp = get_method_res_type(tp, i);
-                               fprintf(F, "\n    %s", get_type_name(rtp));
+                               ir_fprintf(F, "\n    %+F", rtp);
                        }
 
                        fprintf(F, "\n  parameter types: %d", get_method_n_params(tp));
                        for (i = 0; i < get_method_n_params(tp); ++i) {
                                ir_type *ptp = get_method_param_type(tp, i);
-                               fprintf(F, "\n    %s", get_type_name(ptp));
+                               ir_fprintf(F, "\n    %+F", ptp);
                        }
                        if (get_method_variadicity(tp)) {
                                fprintf(F, "\n    ...");
@@ -1281,7 +1290,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
                if (verbosity & dump_verbosity_typeattrs) {
                        ir_type *base_tp = get_primitive_base_type(tp);
                        if (base_tp != NULL)
-                               fprintf(F, "\n  base type: %s (%ld)", get_type_name(tp), get_type_nr(tp));
+                               ir_fprintf(F, "\n  base type: %+F", tp);
                        fprintf(F, "\n");
                }
                break;
index 98a95ef..58cfe05 100644 (file)
@@ -232,7 +232,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
        set_entity_irg(ent, res);
 
        /*--  a class type so that it can contain "inner" methods as in Pascal. --*/
-       res->frame_type = new_type_frame(id_mangle(get_entity_ident(ent), frame_type_suffix));
+       res->frame_type = new_type_frame();
 
        /* the Anchor node must be created first */
        res->anchor = new_Anchor(res);
index 9b4c336..c165f7c 100644 (file)
@@ -386,11 +386,10 @@ static void write_volatility(io_env_t *env, ir_node *irn)
 
 static void export_type_common(io_env_t *env, ir_type *tp)
 {
-       fprintf(env->file, "\t%s %ld %s \"%s\" %u %u %s %s ",
+       fprintf(env->file, "\t%s %ld %s %u %u %s %s ",
                        is_frame_type(tp) ? "frametype" : is_value_param_type(tp) ? "valuetype" : "type",
                        get_type_nr(tp),
                        get_type_tpop_name(tp),
-                       get_type_name(tp),
                        get_type_size_bytes(tp),
                        get_type_alignment_bytes(tp),
                        get_type_state_name(get_type_state(tp)),
@@ -416,7 +415,12 @@ static void export_type_pre(io_env_t *env, ir_type *tp)
 
        switch (get_type_tpop_code(tp))
        {
+               case tpo_uninitialized:
+                       panic("invalid type found");
+
                case tpo_class:
+                       fputs(get_class_name(tp), f);
+                       fputc(' ', f);
                        /* TODO: inheritance stuff not supported yet */
                        printf("Inheritance of classes not supported yet!\n");
                        break;
@@ -425,18 +429,20 @@ static void export_type_pre(io_env_t *env, ir_type *tp)
                        write_mode(env, get_type_mode(tp));
                        break;
 
-               case tpo_struct:
-                       break;
-
                case tpo_union:
+               case tpo_struct:
+               case tpo_enumeration:
+                       fputs(get_compound_name(tp), f);
+                       fputc(' ', f);
                        break;
 
+               case tpo_method:
+               case tpo_pointer:
+               case tpo_code:
+               case tpo_array:
+               case tpo_none:
                case tpo_unknown:
                        break;
-
-               default:
-                       printf("export_type_pre: Unknown type code \"%s\".\n", get_type_tpop_name(tp));
-                       break;
        }
        fputc('\n', f);
 }
@@ -1068,14 +1074,11 @@ static void import_type(io_env_t *env, keyword_t kwkind)
        ir_type       *type;
        long           typenr = read_long(env);
        const char    *tpop   = read_str(env);
-       const char    *name   = read_qstr(env);
        unsigned       size   = (unsigned) read_long(env);
        unsigned       align  = (unsigned) read_long(env);
        ir_type_state  state  = read_type_state(env);
        ir_visibility  vis    = read_visibility(env);
 
-       ident         *id     = new_id_from_str(name);
-
        const char    *kindstr;
 
        if (kwkind == kw_frametype) {
@@ -1085,7 +1088,7 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                        return;
                }
 
-               type = new_type_frame(id);
+               type = new_type_frame();
                set_type_size_bytes(type, size);
 
                kindstr = "frametype";
@@ -1096,7 +1099,7 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                        return;
                }
 
-               type = new_type_value(id);
+               type = new_type_value();
                set_type_size_bytes(type, size);
 
                kindstr = "valuetype";
@@ -1109,7 +1112,7 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                                long elemtypenr = read_long(env);
                                ir_type *elemtype = get_type(env, elemtypenr);
 
-                               type = new_type_array(id, ndims, elemtype);
+                               type = new_type_array(ndims, elemtype);
                                for (i = 0; i < ndims; i++) {
                                        const char *str = read_str(env);
                                        if (strcmp(str, "unknown") != 0) {
@@ -1126,13 +1129,17 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                                break;
                        }
 
-                       case tpo_class:
+                       case tpo_class: {
+                               const char *name = read_qstr(env);
+                               ident      *id   = new_id_from_str(name);
+
                                if(typenr == (long) IR_SEGMENT_GLOBAL)
                                        type = get_glob_type();
                                else
                                        type = new_type_class(id);
                                set_type_size_bytes(type, size);
                                break;
+                       }
 
                        case tpo_method:
                        {
@@ -1142,7 +1149,7 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                                int nresults         = (int)      read_long(env);
                                int variaindex;
 
-                               type = new_type_method(id, nparams, nresults);
+                               type = new_type_method(nparams, nresults);
 
                                for (i = 0; i < nparams; i++) {
                                        long     typenr = read_long(env);
@@ -1171,31 +1178,38 @@ static void import_type(io_env_t *env, keyword_t kwkind)
 
                        case tpo_pointer:
                        {
-                               ir_mode *mode = read_mode(env);
                                ir_type *pointsto = get_type(env, read_long(env));
-                               type = new_type_pointer(id, pointsto, mode);
+                               type = new_type_pointer(pointsto);
                                break;
                        }
 
                        case tpo_primitive:
                        {
                                ir_mode *mode = read_mode(env);
-                               type = new_type_primitive(id, mode);
+                               type = new_type_primitive(mode);
                                break;
                        }
 
-                       case tpo_struct:
+                       case tpo_struct: {
+                               const char *name = read_qstr(env);
+                               ident      *id   = new_id_from_str(name);
+
                                if(typenr < (long) IR_SEGMENT_COUNT)
                                        type = get_segment_type((ir_segment_t) typenr);
                                else
                                        type = new_type_struct(id);
                                set_type_size_bytes(type, size);
                                break;
+                       }
+
+                       case tpo_union: {
+                               const char *name = read_qstr(env);
+                               ident      *id   = new_id_from_str(name);
 
-                       case tpo_union:
                                type = new_type_union(id);
                                set_type_size_bytes(type, size);
                                break;
+                       }
 
                        case tpo_unknown:
                                return;   /* ignore unknown type */
@@ -1216,7 +1230,7 @@ static void import_type(io_env_t *env, keyword_t kwkind)
                ARR_APP1(ir_type *, env->fixedtypes, type);
 
        set_id(env, typenr, type);
-       printf("Insert %s %s %ld\n", kindstr, name, typenr);
+       printf("Insert %s %ld\n", kindstr, typenr);
 }
 
 /** Reads an entity description and remembers it by its id. */
index b5bb82e..88f6c6e 100644 (file)
@@ -255,6 +255,7 @@ static ir_mode *register_mode(const ir_mode *new_mode) {
        ARR_APP1(ir_mode*, mode_list, mode);
 
        mode->kind = k_ir_mode;
+       mode->type = new_type_primitive(mode);
 
        /* add the new mode to the irp list of modes */
        add_irp_mode(mode);
index eb23281..6614986 100644 (file)
@@ -5796,7 +5796,7 @@ static ir_node *transform_node_Call(ir_node *call) {
        ir_node  *callee = get_Call_ptr(call);
        ir_node  *adr, *mem, *res, *bl, **in;
        ir_type  *ctp, *mtp, *tp;
-       ident    *id;
+       type_dbg_info *tdb;
        dbg_info *db;
        int      i, n_res, n_param;
        ir_variadicity var;
@@ -5818,13 +5818,11 @@ static ir_node *transform_node_Call(ir_node *call) {
 
        /* build a new call type */
        mtp = get_Call_type(call);
-       id  = get_type_ident(mtp);
-       id  = id_mangle(new_id_from_chars("T_", 2), id);
-       db  = get_type_dbg_info(mtp);
+       tdb = get_type_dbg_info(mtp);
 
        n_res   = get_method_n_ress(mtp);
        n_param = get_method_n_params(mtp);
-       ctp     = new_d_type_method(id, n_param + 1, n_res, db);
+       ctp     = new_d_type_method(n_param + 1, n_res, tdb);
 
        for (i = 0; i < n_res; ++i)
                set_method_res_type(ctp, i, get_method_res_type(mtp, i));
@@ -5833,8 +5831,7 @@ static ir_node *transform_node_Call(ir_node *call) {
 
        /* FIXME: we don't need a new pointer type in every step */
        tp = get_irg_frame_type(current_ir_graph);
-       id = id_mangle(get_type_ident(tp), new_id_from_chars("_ptr", 4));
-       tp = new_type_pointer(id, tp, mode_P_data);
+       tp = new_type_pointer(tp);
        set_method_param_type(ctp, 0, tp);
 
        in[0] = get_Builtin_param(callee, 2);
index 7f211b2..d6a9ab6 100644 (file)
@@ -172,8 +172,7 @@ fix_ssa(ir_node * bb, void * data)
 static void add_constructor(ir_entity *method)
 {
     ir_type   *method_type  = get_entity_type(method);
-    ident     *id           = id_unique("constructor_ptrt.%u");
-    ir_type   *ptr_type     = new_type_pointer(id, method_type, mode_P_code);
+    ir_type   *ptr_type     = new_type_pointer(method_type);
 
     ir_type   *constructors = get_segment_type(IR_SEGMENT_CONSTRUCTORS);
     ident     *ide          = id_unique("constructor_ptr.%u");
@@ -198,12 +197,12 @@ gen_initializer_irg(ir_entity *ent_filename, ir_entity *bblock_id, ir_entity *bb
 {
        ir_node   *ins[4];
        ident     *name = new_id_from_str("__firmprof_initializer");
-       ir_entity *ent  = new_entity(get_glob_type(), name, new_type_method(name, 0, 0));
+       ir_entity *ent  = new_entity(get_glob_type(), name, new_type_method(0, 0));
        ir_node   *ret, *call, *symconst;
        symconst_symbol sym;
 
        ident     *init_name = new_id_from_str("__init_firmprof");
-       ir_type   *init_type = new_type_method(init_name, 4, 0);
+       ir_type   *init_type = new_type_method(4, 0);
        ir_type   *uint, *uintptr, *string;
        ir_entity *init_ent;
        ir_graph  *irg;
@@ -212,9 +211,9 @@ gen_initializer_irg(ir_entity *ent_filename, ir_entity *bblock_id, ir_entity *bb
 
        set_entity_ld_ident(ent, name);
 
-       uint    = new_type_primitive(new_id_from_str("__uint"), mode_Iu);
-       uintptr = new_type_pointer(new_id_from_str("__uintptr"), uint, get_modeP_data());
-       string  = new_type_pointer(new_id_from_str("__charptr"), new_type_primitive(new_id_from_str("__char"), mode_Bs), get_modeP_data());
+       uint    = new_type_primitive(mode_Iu);
+       uintptr = new_type_pointer(uint);
+       string  = new_type_pointer(new_type_primitive(mode_Bs));
 
        set_method_param_type(init_type, 0, string);
        set_method_param_type(init_type, 1, uintptr);
@@ -276,7 +275,7 @@ static void create_location_data(dbg_info *dbg, block_id_walker_data_t *wd)
                        tarval  **tarval_string;
 
                        snprintf(buf, sizeof(buf), "firm_name_arr.%d", nr);
-                       arr = new_type_array(new_id_from_str(buf), 1, wd->tp_char);
+                       arr = new_type_array(1, wd->tp_char);
                        set_array_bounds_int(arr, 0, 0, len);
 
                        snprintf(buf, sizeof(buf), "__firm_name.%d", nr++);
@@ -365,17 +364,17 @@ ir_profile_instrument(const char *filename, unsigned flags)
        /* create all the necessary types and entities. Note that the
           types must have a fixed layout, because we already running in the
           backend */
-       uint_type      = new_type_primitive(IDENT("__uint"), mode_Iu);
+       uint_type      = new_type_primitive(mode_Iu);
        set_type_alignment_bytes(uint_type, get_type_size_bytes(uint_type));
 
-       array_type     = new_type_array(IDENT("__block_info_array"), 1, uint_type);
+       array_type     = new_type_array(1, uint_type);
        set_array_bounds_int(array_type, 0, 0, n_blocks);
        set_type_size_bytes(array_type, n_blocks * get_mode_size_bytes(mode_Iu));
        set_type_alignment_bytes(array_type, get_mode_size_bytes(mode_Iu));
        set_type_state(array_type, layout_fixed);
 
-       character_type = new_type_primitive(IDENT("__char"), mode_Bs);
-       string_type    = new_type_array(IDENT("__filename"), 1, character_type);
+       character_type = new_type_primitive(mode_Bs);
+       string_type    = new_type_array(1, character_type);
        set_array_bounds_int(string_type, 0, 0, filename_len);
        set_type_size_bytes(string_type, filename_len);
        set_type_alignment_bytes(string_type, 1);
@@ -404,7 +403,7 @@ ir_profile_instrument(const char *filename, unsigned flags)
                size           = get_type_size_bytes(uint_type);
                set_entity_offset(loc_lineno, 0);
 
-               charptr_type   = new_type_pointer(IDENT("__charptr"), character_type, mode_P_data);
+               charptr_type   = new_type_pointer(character_type);
                align_n        = get_type_size_bytes(charptr_type);
                set_type_alignment_bytes(charptr_type, align_n);
                loc_name       = new_entity(loc_type, IDENT("name"), charptr_type);
@@ -418,11 +417,11 @@ ir_profile_instrument(const char *filename, unsigned flags)
                set_type_size_bytes(loc_type, size);
                set_type_state(loc_type, layout_fixed);
 
-               loc_type = new_type_array(IDENT("__locarray"), 1, loc_type);
+               loc_type = new_type_array(1, loc_type);
                set_array_bounds_int(string_type, 0, 0, n_blocks);
 
-               cur_ident      = IDENT("__FIRMPROF__LOCATIONS");
-               ent_locations   = new_entity(gtp, cur_ident, loc_type);
+               cur_ident     = IDENT("__FIRMPROF__LOCATIONS");
+               ent_locations = new_entity(gtp, cur_ident, loc_type);
                set_entity_ld_ident(ent_locations, cur_ident);
        }
 
index 6122c8e..c10b4e4 100644 (file)
@@ -86,6 +86,7 @@ struct ir_op {
 struct ir_mode {
        firm_kind         kind;       /**< distinguishes this node from others */
        ident             *name;      /**< Name ident of this mode */
+       ir_type           *type;      /**< corresponding primitive type */
 
        /* ----------------------------------------------------------------------- */
        /* On changing this struct you have to evaluate the mode_are_equal function!*/
index d562ddf..751a01c 100644 (file)
@@ -84,10 +84,8 @@ static void show_entity_failure(ir_node *node) {
                        ir_type *ent_type = get_entity_owner(ent);
 
                        if (ent_type) {
-                               if (ent_type == get_glob_type())
-                                       fprintf(stderr, "\nFIRM: irn_vrfy_irg() %s failed\n", get_entity_name(ent));
-                               else
-                                       fprintf(stderr, "\nFIRM: irn_vrfy_irg() %s::%s failed\n", get_type_name(ent_type), get_entity_name(ent));
+                               ir_fprintf(stderr, "\nFIRM: irn_vrfy_irg() %+F::%s failed\n",
+                                          ent_type, get_entity_name(ent));
                        } else {
                                fprintf(stderr, "\nFIRM: irn_vrfy_irg() <NULL>::%s failed\n", get_entity_name(ent));
                        }
@@ -176,13 +174,15 @@ static void show_proj_failure(ir_node *n) {
 static void show_proj_mode_failure(ir_node *n, ir_type *ty) {
        long proj  = get_Proj_proj(n);
        ir_mode *m = get_type_mode(ty);
+       char type_name[256];
+       ir_print_type(type_name, sizeof(type_name), ty);
 
        show_entity_failure(n);
        fprintf(stderr, "  Proj %ld mode %s proj %ld (type %s mode %s) failed\n" ,
                get_irn_node_nr(n),
                get_irn_modename(n),
                proj,
-               get_type_name(ty),
+               type_name,
                get_mode_name_ex(m));
 }
 
@@ -193,13 +193,15 @@ static void show_proj_failure_ent(ir_node *n, ir_entity *ent) {
        ir_node *op  = get_Proj_pred(n);
        int proj     = get_Proj_proj(n);
        ir_mode *m   = get_type_mode(get_entity_type(ent));
+       char type_name[256];
+       ir_print_type(type_name, sizeof(type_name), get_entity_type(ent));
 
        show_entity_failure(n);
        fprintf(stderr, "  node %ld %s%s %d(%s%s) entity %s(type %s mode %s)failed\n" ,
                get_irn_node_nr(n),
                get_irn_opname(n), get_irn_modename(n), proj,
                get_irn_opname(op), get_irn_modename(op),
-               get_entity_name(ent), get_type_name(get_entity_type(ent)),
+               get_entity_name(ent), type_name,
                get_mode_name_ex(m));
 }
 
@@ -215,9 +217,11 @@ static void show_node_on_graph(ir_graph *irg, ir_node *n) {
  */
 static void show_call_param(ir_node *n, ir_type *mt) {
        int i;
+       char type_name[256];
+       ir_print_type(type_name, sizeof(type_name), mt);
 
        show_entity_failure(n);
-       fprintf(stderr, "  Call type-check failed: %s(", get_type_name(mt));
+       fprintf(stderr, "  Call type-check failed: %s(", type_name);
        for (i = 0; i < get_method_n_params(mt); ++i) {
                fprintf(stderr, "%s ", get_mode_name_ex(get_type_mode(get_method_param_type(mt, i))));
        }
@@ -1181,16 +1185,16 @@ static int verify_node_Call(ir_node *n, ir_graph *irg) {
                        get_Call_n_params(n) >= get_method_n_params(mt),
                        "Number of args for Call doesn't match number of args in variadic type.",
                        0,
-                       ir_fprintf(stderr, "Call %+F has %d params, method %s type %d\n",
-                       n, get_Call_n_params(n), get_type_name(mt), get_method_n_params(mt));
+                       ir_fprintf(stderr, "Call %+F has %d params, type %d\n",
+                       n, get_Call_n_params(n), get_method_n_params(mt));
                );
        } else {
                ASSERT_AND_RET_DBG(
                        get_Call_n_params(n) == get_method_n_params(mt),
                        "Number of args for Call doesn't match number of args in non variadic type.",
                        0,
-                       ir_fprintf(stderr, "Call %+F has %d params, method %s type %d\n",
-                       n, get_Call_n_params(n), get_type_name(mt), get_method_n_params(mt));
+                       ir_fprintf(stderr, "Call %+F has %d params, type %d\n",
+                       n, get_Call_n_params(n), get_method_n_params(mt));
                );
        }
 
index f89e4f7..6f71e0f 100644 (file)
@@ -48,7 +48,7 @@ static pmap *type_map;
  * Default implementation for finding a pointer type for a given element type.
  * Simple create a new one.
  */
-static ir_type *def_find_pointer_type(ir_type *e_type, ir_mode *mode, int alignment)
+static ir_type *def_find_pointer_type(ir_type *e_type, int alignment)
 {
        ir_type *res;
        pmap_entry *e;
@@ -59,7 +59,7 @@ static ir_type *def_find_pointer_type(ir_type *e_type, ir_mode *mode, int alignm
        if (e)
                res = e->value;
        else {
-               res = new_type_pointer(id_mangle_u(get_type_ident(e_type), new_id_from_chars("Ptr", 3)), e_type, mode);
+               res = new_type_pointer(e_type);
                set_type_alignment_bytes(res, alignment);
                pmap_insert(type_map, e_type, res);
        }
@@ -83,7 +83,6 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
        int     *param_map;
        ir_mode *modes[MAX_REGISTER_RET_VAL];
        int n_ress, n_params, nn_ress, nn_params, i, first_variadic;
-       ident *id;
        add_hidden hidden_params;
        int        changed = 0;
        ir_variadicity var;
@@ -130,7 +129,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                                else {
                                        /* this compound will be allocated on callers stack and its
                                           address will be transmitted as a hidden parameter. */
-                                       ptr_tp = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
+                                       ptr_tp = lp->find_pointer_type(res_tp, lp->def_ptr_alignment);
                                        params[nn_params]    = ptr_tp;
                                        param_map[nn_params] = -1 - i;
                                        ++nn_params;
@@ -165,7 +164,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                        res_tp = get_method_res_type(mtp, i);
 
                        if (is_compound_type(res_tp)) {
-                               params[nn_params] = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
+                               params[nn_params] = lp->find_pointer_type(res_tp, lp->def_ptr_alignment);
                                param_map[nn_params] = -1 - i;
                                ++nn_params;
                        } else {
@@ -175,8 +174,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
        }
 
        /* create the new type */
-       id      = id_mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
-       lowered = new_d_type_method(id, nn_params, nn_ress, get_type_dbg_info(mtp));
+       lowered = new_d_type_method(nn_params, nn_ress, get_type_dbg_info(mtp));
 
        /* fill it */
        for (i = 0; i < nn_params; ++i)
index 483ad47..7baa7ea 100644 (file)
@@ -136,7 +136,7 @@ static ir_type *get_primitive_type(ir_mode *mode) {
                return entry->value;
 
        snprintf(buf, sizeof(buf), "_prim_%s", get_mode_name(mode));
-       tp = new_type_primitive(new_id_from_str(buf), mode);
+       tp = new_type_primitive(mode);
 
        pmap_insert(prim_types, mode, tp);
        return tp;
@@ -156,7 +156,6 @@ static ir_type *get_conv_type(ir_mode *imode, ir_mode *omode, lower_env_t *env)
        entry = set_insert(conv_types, &key, sizeof(key), HASH_PTR(imode) ^ HASH_PTR(omode));
        if (! entry->mtd) {
                int n_param = 1, n_res = 1;
-               char buf[64];
 
                if (imode == env->params->high_signed || imode == env->params->high_unsigned)
                        n_param = 2;
@@ -164,8 +163,7 @@ static ir_type *get_conv_type(ir_mode *imode, ir_mode *omode, lower_env_t *env)
                        n_res = 2;
 
                /* create a new one */
-               snprintf(buf, sizeof(buf), "LConv%s%s", get_mode_name(imode), get_mode_name(omode));
-               mtd = new_type_method(new_id_from_str(buf), n_param, n_res);
+               mtd = new_type_method(n_param, n_res);
 
                /* set param types and result types */
                n_param = 0;
@@ -1678,7 +1676,7 @@ static void lower_Conv(ir_node *node, ir_mode *mode, lower_env_t *env) {
  */
 static ir_type *lower_mtp(ir_type *mtp, lower_env_t *env) {
        pmap_entry *entry;
-       ident      *id, *lid;
+       ident      *lid;
        ir_type    *res, *value_type;
 
        if (is_lowered_type(mtp))
@@ -1716,8 +1714,7 @@ static ir_type *lower_mtp(ir_type *mtp, lower_env_t *env) {
                        }  /* if */
                }  /* for */
 
-               id  = id_mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
-               res = new_type_method(id, n_param, n_res);
+               res = new_type_method(n_param, n_res);
 
                /* set param types and result types */
                for (i = n_param = 0; i < n; ++i) {
@@ -2510,7 +2507,7 @@ void lower_dw_ops(const lwrdw_param_t *param)
 
        /* create method types for the created binop calls */
        if (! binop_tp_u) {
-               binop_tp_u = new_type_method(IDENT("binop_u_intrinsic"), 4, 2);
+               binop_tp_u = new_type_method(4, 2);
                set_method_param_type(binop_tp_u, 0, tp_u);
                set_method_param_type(binop_tp_u, 1, tp_u);
                set_method_param_type(binop_tp_u, 2, tp_u);
@@ -2519,7 +2516,7 @@ void lower_dw_ops(const lwrdw_param_t *param)
                set_method_res_type(binop_tp_u, 1, tp_u);
        }  /* if */
        if (! binop_tp_s) {
-               binop_tp_s = new_type_method(IDENT("binop_s_intrinsic"), 4, 2);
+               binop_tp_s = new_type_method(4, 2);
                set_method_param_type(binop_tp_s, 0, tp_u);
                set_method_param_type(binop_tp_s, 1, tp_s);
                set_method_param_type(binop_tp_s, 2, tp_u);
@@ -2528,7 +2525,7 @@ void lower_dw_ops(const lwrdw_param_t *param)
                set_method_res_type(binop_tp_s, 1, tp_s);
        }  /* if */
        if (! shiftop_tp_u) {
-               shiftop_tp_u = new_type_method(IDENT("shiftop_u_intrinsic"), 3, 2);
+               shiftop_tp_u = new_type_method(3, 2);
                set_method_param_type(shiftop_tp_u, 0, tp_u);
                set_method_param_type(shiftop_tp_u, 1, tp_u);
                set_method_param_type(shiftop_tp_u, 2, tp_u);
@@ -2536,7 +2533,7 @@ void lower_dw_ops(const lwrdw_param_t *param)
                set_method_res_type(shiftop_tp_u, 1, tp_u);
        }  /* if */
        if (! shiftop_tp_s) {
-               shiftop_tp_s = new_type_method(IDENT("shiftop_s_intrinsic"), 3, 2);
+               shiftop_tp_s = new_type_method(3, 2);
                set_method_param_type(shiftop_tp_s, 0, tp_u);
                set_method_param_type(shiftop_tp_s, 1, tp_s);
                set_method_param_type(shiftop_tp_s, 2, tp_u);
@@ -2544,14 +2541,14 @@ void lower_dw_ops(const lwrdw_param_t *param)
                set_method_res_type(shiftop_tp_s, 1, tp_s);
        }  /* if */
        if (! unop_tp_u) {
-               unop_tp_u = new_type_method(IDENT("unop_u_intrinsic"), 2, 2);
+               unop_tp_u = new_type_method(2, 2);
                set_method_param_type(unop_tp_u, 0, tp_u);
                set_method_param_type(unop_tp_u, 1, tp_u);
                set_method_res_type(unop_tp_u, 0, tp_u);
                set_method_res_type(unop_tp_u, 1, tp_u);
        }  /* if */
        if (! unop_tp_s) {
-               unop_tp_s = new_type_method(IDENT("unop_s_intrinsic"), 2, 2);
+               unop_tp_s = new_type_method(2, 2);
                set_method_param_type(unop_tp_s, 0, tp_u);
                set_method_param_type(unop_tp_s, 1, tp_s);
                set_method_res_type(unop_tp_s, 0, tp_u);
index 87ea563..6062702 100644 (file)
@@ -93,8 +93,7 @@ static ir_node *create_convb(ir_node *node)
 static ir_type *create_lowered_type(void)
 {
        if(lowered_type == NULL) {
-               lowered_type = new_type_primitive(new_id_from_str("__lowered_mode_b"),
-                                                 config.lowered_mode);
+               lowered_type = new_type_primitive(config.lowered_mode);
        }
        return lowered_type;
 }
index bf602a6..a86bfde 100644 (file)
@@ -368,19 +368,17 @@ static void create_clone_proc_irg(ir_entity *ent, quadruple_t *q) {
  * @param ent The entity of the clone.
  * @param nr  A pointer to the counter of clones.
  **/
-static void change_entity_type(quadruple_t *q, ir_entity *ent, unsigned *nr) {
+static void change_entity_type(quadruple_t *q, ir_entity *ent) {
        ir_type *mtp, *new_mtp, *tp;
-       ident   *tp_name;
        int     i, j, n_params, n_ress;
 
        mtp      = get_entity_type(q->ent);
-       tp_name  = get_clone_ident(get_type_ident(mtp), q->pos, (*nr)++);
        n_params = get_method_n_params(mtp);
        n_ress   = get_method_n_ress(mtp);
 
        /* Create the new type for our clone. It must have one parameter
           less then the original.*/
-       new_mtp  = new_type_method(tp_name, n_params - 1, n_ress);
+       new_mtp  = new_type_method(n_params - 1, n_ress);
 
        /* We must set the type of the methods parameters.*/
        for (i = j = 0; i < n_params; ++i) {
@@ -425,7 +423,7 @@ static ir_entity *clone_method(quadruple_t *q) {
        set_entity_ld_ident(new_entity, get_entity_ident(new_entity));
 
        /* set a new type here. */
-       change_entity_type(q, new_entity, &nr);
+       change_entity_type(q, new_entity);
 
        /* We need now a new ir_graph for our clone method. */
        create_clone_proc_irg(new_entity, q);
index 999735d..8a2190f 100644 (file)
@@ -67,17 +67,14 @@ static ir_type *default_gen_pointer_type_to(ir_type *tp) {
                if (get_type_n_pointertypes_to(tp) > 0) {
                        res = get_type_pointertype_to(tp, 0);
                } else {
-                       ir_mode *mode = is_Method_type(tp) ? mode_P_code : mode_P_data;
-
-                       res = new_type_pointer(id_mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode);
+                       res = new_type_pointer(tp);
                        /* Update trout for pointer types, so we can use it in next call. */
                        add_type_pointertype_to(tp, res);
                }
-       }
-       else {
+       } else {
                res = find_pointer_type_to_type(tp);
                if (res == firm_unknown_type)
-                       res = new_type_pointer(id_mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode_P_data);
+                       res = new_type_pointer(tp);
        }
 
        return res;
index da509d5..009d48f 100644 (file)
@@ -42,7 +42,7 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg);
 /* ----------------------------------------------------------------------- */
 
 ident *default_mangle_inherited_name(const ir_entity *super, const ir_type *clss) {
-       return id_mangle_u(new_id_from_str("inh"), id_mangle_u(get_type_ident(clss), get_entity_ident(super)));
+       return id_mangle_u(new_id_from_str("inh"), id_mangle_u(get_class_ident(clss), get_entity_ident(super)));
 }
 
 /** Replicates all entities in all super classes that are not overwritten
index 043f64b..febebf5 100644 (file)
@@ -58,6 +58,8 @@
 #include "irhooks.h"
 #include "irtools.h"
 #include "entity_t.h"
+#include "error.h"
+#include "dbginfo.h"
 
 #include "array.h"
 
@@ -90,23 +92,23 @@ unsigned get_default_cc_mask(void)
        return default_cc_mask;
 }
 
-void firm_init_type(dbg_info *builtin_db, unsigned def_cc_mask)
+void firm_init_type(unsigned def_cc_mask)
 {
        default_cc_mask     = def_cc_mask;
        value_params_suffix = new_id_from_str(VALUE_PARAMS_SUFFIX);
        value_ress_suffix   = new_id_from_str(VALUE_RESS_SUFFIX);
 
        /* construct none and unknown type. */
-       firm_none_type    = new_type(tpop_none,    mode_BAD, new_id_from_str("type_none"), builtin_db);
+       firm_none_type = new_type(tpop_none, mode_BAD, NULL);
        set_type_size_bytes(firm_none_type, 0);
        set_type_state (firm_none_type, layout_fixed);
        remove_irp_type(firm_none_type);
 
-       firm_code_type    = new_type(tpop_code, mode_ANY, new_id_from_str("type_code"), builtin_db);
+       firm_code_type = new_type(tpop_code, mode_ANY, NULL);
        set_type_state(firm_code_type, layout_fixed);
        remove_irp_type(firm_code_type);
 
-       firm_unknown_type = new_type(tpop_unknown, mode_ANY, new_id_from_str("type_unknown"), builtin_db);
+       firm_unknown_type = new_type(tpop_unknown, mode_ANY, NULL);
        set_type_size_bytes(firm_unknown_type, 0);
        set_type_state (firm_unknown_type, layout_fixed);
        remove_irp_type(firm_unknown_type);
@@ -130,14 +132,11 @@ void (inc_master_type_visited)(void)
        _inc_master_type_visited();
 }
 
-ir_type *new_type(const tp_op *type_op, ir_mode *mode, ident *name,
-                  dbg_info *db)
+ir_type *new_type(const tp_op *type_op, ir_mode *mode, type_dbg_info *db)
 {
        ir_type *res;
        int node_size;
 
-       assert(!id_contains_char(name, ' ') && "type name should not contain spaces");
-
        node_size = offsetof(ir_type, attr) +  type_op->attr_size;
        res = xmalloc(node_size);
        memset(res, 0, node_size);
@@ -145,7 +144,6 @@ ir_type *new_type(const tp_op *type_op, ir_mode *mode, ident *name,
        res->kind       = k_type;
        res->type_op    = type_op;
        res->mode       = mode;
-       res->name       = name;
        res->visibility = visibility_external_allocated;
        res->flags      = tf_none;
        res->size       = 0;
@@ -244,16 +242,6 @@ void set_type_mode(ir_type *tp, ir_mode *mode)
                assert(0 && "setting a mode is NOT allowed for this type");
 }
 
-ident *(get_type_ident)(const ir_type *tp)
-{
-       return _get_type_ident(tp);
-}
-
-void (set_type_ident)(ir_type *tp, ident* id)
-{
-       _set_type_ident(tp, id);
-}
-
 /* Outputs a unique number for this node */
 long get_type_nr(const ir_type *tp)
 {
@@ -265,12 +253,6 @@ long get_type_nr(const ir_type *tp)
 #endif
 }
 
-const char *get_type_name(const ir_type *tp)
-{
-       assert(tp && tp->kind == k_type);
-       return (get_id_str(tp->name));
-}
-
 unsigned (get_type_size_bytes)(const ir_type *tp)
 {
        return _get_type_size_bytes(tp);
@@ -438,12 +420,12 @@ int (type_not_visited)(const ir_type *tp)
        return _type_not_visited(tp);
 }
 
-dbg_info *(get_type_dbg_info)(const ir_type *tp)
+type_dbg_info *(get_type_dbg_info)(const ir_type *tp)
 {
        return _get_type_dbg_info(tp);
 }
 
-void (set_type_dbg_info)(ir_type *tp, dbg_info *db)
+void (set_type_dbg_info)(ir_type *tp, type_dbg_info *db)
 {
        _set_type_dbg_info(tp, db);
 }
@@ -463,7 +445,7 @@ int equal_type(ir_type *typ1, ir_type *typ2)
        if (typ1 == typ2) return 1;
 
        if ((get_type_tpop_code(typ1) != get_type_tpop_code(typ2)) ||
-           (get_type_ident(typ1) != get_type_ident(typ2)) ||
+           typ1->name != typ2->name ||
            (get_type_mode(typ1) != get_type_mode(typ2)) ||
            (get_type_state(typ1) != get_type_state(typ2)))
                return 0;
@@ -499,7 +481,7 @@ int equal_type(ir_type *typ1, ir_type *typ2)
                        ir_type *t1 = get_class_supertype(typ1, i);
                        for (j = 0; j < get_class_n_supertypes(typ2); j++) {
                                ir_type *t2 = get_class_supertype(typ2, j);
-                               if (get_type_ident(t2) == get_type_ident(t1))
+                               if (t2->name == t1->name)
                                        t[i] = t2;
                        }
                }
@@ -740,11 +722,12 @@ int smaller_type(ir_type *st, ir_type *lt)
 }
 
 
-ir_type *new_d_type_class(ident *name, dbg_info *db)
+ir_type *new_d_type_class(ident *name, type_dbg_info *db)
 {
        ir_type *res;
 
-       res = new_type(type_class, NULL, name, db);
+       res = new_type(type_class, NULL, db);
+       res->name = name;
 
        res->attr.ca.members     = NEW_ARR_F (ir_entity *, 0);
        res->attr.ca.subtypes    = NEW_ARR_F (ir_type *, 0);
@@ -780,6 +763,17 @@ void free_class_attrs(ir_type *clss)
        DEL_ARR_F(clss->attr.ca.supertypes);
 }
 
+ident *get_class_ident(const ir_type *clss)
+{
+       assert(clss->type_op == type_class);
+       return clss->name;
+}
+
+const char *get_class_name(const ir_type *clss)
+{
+       return get_id_str(get_class_ident(clss));
+}
+
 void add_class_member(ir_type *clss, ir_entity *member)
 {
        assert(clss && (clss->type_op == type_class));
@@ -1069,9 +1063,10 @@ void set_class_size(ir_type *tp, unsigned size) {
 }
 
 
-ir_type *new_d_type_struct(ident *name, dbg_info *db)
+ir_type *new_d_type_struct(ident *name, type_dbg_info *db)
 {
-       ir_type *res = new_type(type_struct, NULL, name, db);
+       ir_type *res = new_type(type_struct, NULL, db);
+       res->name = name;
 
        res->attr.sa.members = NEW_ARR_F(ir_entity *, 0);
        hook_new_type(res);
@@ -1097,6 +1092,17 @@ void free_struct_attrs(ir_type *strct)
        DEL_ARR_F(strct->attr.sa.members);
 }
 
+ident *get_struct_ident(const ir_type *strct)
+{
+       assert(strct->type_op == type_struct);
+       return strct->name;
+}
+
+const char *get_struct_name(const ir_type *strct)
+{
+       return get_id_str(get_struct_ident(strct));
+}
+
 int get_struct_n_members(const ir_type *strct)
 {
        assert(strct && (strct->type_op == type_struct));
@@ -1178,10 +1184,10 @@ void set_struct_size(ir_type *tp, unsigned size)
  * @param len     number of fields
  * @param tps     array of field types with length len
  */
-static ir_type *build_value_type(ident *name, int len, tp_ent_pair *tps)
+static ir_type *build_value_type(int len, tp_ent_pair *tps)
 {
        int i;
-       ir_type *res = new_type_struct(name);
+       ir_type *res = new_type_struct(NULL);
        res->flags |= tf_value_param_type;
        /* Remove type from type list.  Must be treated differently than other types. */
        remove_irp_type(res);
@@ -1192,20 +1198,21 @@ static ir_type *build_value_type(ident *name, int len, tp_ent_pair *tps)
                ir_type *elt_type = tps[i].tp ? tps[i].tp : res;
 
                /* use the parameter name if specified */
-               if (! id)
-                       id = id_mangle_u(name, get_type_ident(elt_type));
+               if (id == NULL) {
+                       id = new_id_from_str("elt");
+               }
                tps[i].ent = new_entity(res, id, elt_type);
                set_entity_allocation(tps[i].ent, allocation_parameter);
        }
        return res;
 }
 
-ir_type *new_d_type_method(ident *name, int n_param, int n_res, dbg_info *db)
+ir_type *new_d_type_method(int n_param, int n_res, type_dbg_info *db)
 {
        ir_type *res;
 
        assert((get_mode_size_bits(mode_P_code) % 8 == 0) && "unorthodox modes not implemented");
-       res = new_type(type_method, mode_P_code, name, db);
+       res = new_type(type_method, mode_P_code, db);
        res->flags                       |= tf_layout_fixed;
        res->size                         = get_mode_size_bytes(mode_P_code);
        res->attr.ma.n_params             = n_param;
@@ -1222,31 +1229,26 @@ ir_type *new_d_type_method(ident *name, int n_param, int n_res, dbg_info *db)
        return res;
 }
 
-ir_type *new_type_method(ident *name, int n_param, int n_res)
+ir_type *new_type_method(int n_param, int n_res)
 {
-       return new_d_type_method(name, n_param, n_res, NULL);
+       return new_d_type_method(n_param, n_res, NULL);
 }
 
-ir_type *clone_type_method(ir_type *tp, ident *prefix)
+ir_type *clone_type_method(ir_type *tp)
 {
        ir_type  *res;
-       ident    *name;
        ir_mode  *mode;
        int      n_params, n_res;
-       dbg_info *db;
+       type_dbg_info *db;
 
        assert(is_Method_type(tp));
 
-       name = tp->name;
-       if (prefix != NULL)
-               name = id_mangle(prefix, name);
-
        mode     = tp->mode;
        n_params = tp->attr.ma.n_params;
        n_res    = tp->attr.ma.n_res;
        db       = tp->dbi;
 
-       res = new_type(type_method, mode, name, db);
+       res = new_type(type_method, mode, db);
 
        res->flags                         = tp->flags;
        res->assoc_type                    = tp->assoc_type;
@@ -1345,8 +1347,8 @@ ir_entity *get_method_value_param_ent(ir_type *method, int pos)
        if (!method->attr.ma.value_params) {
                /* parameter value type not created yet, build */
                method->attr.ma.value_params
-                       = build_value_type(id_mangle_u(get_type_ident(method), value_params_suffix),
-                       get_method_n_params(method), method->attr.ma.params);
+                       = build_value_type(get_method_n_params(method),
+                                          method->attr.ma.params);
        }
        /*
         * build_value_type() sets the method->attr.ma.value_params type as default if
@@ -1416,8 +1418,8 @@ ir_entity *get_method_value_res_ent(ir_type *method, int pos)
        if (!method->attr.ma.value_ress) {
                /* result value type not created yet, build */
                method->attr.ma.value_ress
-                       = build_value_type(id_mangle_u(get_type_ident(method), value_ress_suffix),
-                       get_method_n_ress(method), method->attr.ma.res_type);
+                       = build_value_type(get_method_n_ress(method),
+                                          method->attr.ma.res_type);
        }
        /*
         * build_value_type() sets the method->attr.ma.value_ress type as default if
@@ -1527,9 +1529,10 @@ int (is_Method_type)(const ir_type *method)
 }
 
 
-ir_type *new_d_type_union(ident *name, dbg_info *db)
+ir_type *new_d_type_union(ident *name, type_dbg_info *db)
 {
-       ir_type *res = new_type(type_union, NULL, name, db);
+       ir_type *res = new_type(type_union, NULL, db);
+       res->name = name;
 
        res->attr.ua.members = NEW_ARR_F(ir_entity *, 0);
        hook_new_type(res);
@@ -1555,6 +1558,17 @@ void free_union_attrs (ir_type *uni)
        DEL_ARR_F(uni->attr.ua.members);
 }
 
+ident *get_union_ident(const ir_type *uni)
+{
+       assert(uni->type_op == type_union);
+       return uni->name;
+}
+
+const char *get_union_name(const ir_type *uni)
+{
+       return get_id_str(get_union_ident(uni));
+}
+
 int get_union_n_members(const ir_type *uni)
 {
        assert(uni && (uni->type_op == type_union));
@@ -1620,8 +1634,8 @@ void set_union_size(ir_type *tp, unsigned size)
 
 
 
-ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
-                          dbg_info *db)
+ir_type *new_d_type_array(int n_dimensions, ir_type *element_type,
+                          type_dbg_info *db)
 {
        ir_type *res;
        int i;
@@ -1630,7 +1644,7 @@ ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
 
        assert(!is_Method_type(element_type));
 
-       res = new_type(type_array, NULL, name, db);
+       res = new_type(type_array, NULL, db);
        res->attr.aa.n_dimensions = n_dimensions;
        res->attr.aa.lower_bound  = XMALLOCNZ(ir_node*, n_dimensions);
        res->attr.aa.upper_bound  = XMALLOCNZ(ir_node*, n_dimensions);
@@ -1646,14 +1660,14 @@ ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
        current_ir_graph = rem;
 
        res->attr.aa.element_type = element_type;
-       new_entity(res, id_mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
+       new_entity(res, new_id_from_chars("elem_ent", 8), element_type);
        hook_new_type(res);
        return res;
 }
 
-ir_type *new_type_array(ident *name, int n_dimensions, ir_type *element_type)
+ir_type *new_type_array(int n_dimensions, ir_type *element_type)
 {
-       return new_d_type_array(name, n_dimensions, element_type, NULL);
+       return new_d_type_array(n_dimensions, element_type, NULL);
 }
 
 void free_array_automatic_entities(ir_type *array)
@@ -1811,7 +1825,7 @@ void set_array_element_type(ir_type *array, ir_type *tp)
        array->attr.aa.element_type = tp;
 }
 
-ir_type *get_array_element_type(ir_type *array)
+ir_type *get_array_element_type(const ir_type *array)
 {
        assert(array && (array->type_op == type_array));
        return array->attr.aa.element_type;
@@ -1843,12 +1857,13 @@ void set_array_size(ir_type *tp, unsigned size)
 }
 
 
-ir_type *new_d_type_enumeration(ident *name, int n_enums, dbg_info *db)
+ir_type *new_d_type_enumeration(ident *name, int n_enums, type_dbg_info *db)
 {
        ir_type *res;
 
        assert(n_enums >= 0);
-       res = new_type(type_enumeration, NULL, name, db);
+       res = new_type(type_enumeration, NULL, db);
+       res->name = name;
        res->attr.ea.enumer = NEW_ARR_F(ir_enum_const, n_enums);
        hook_new_type(res);
        return res;
@@ -1871,6 +1886,17 @@ void free_enumeration_attrs(ir_type *enumeration)
        DEL_ARR_F(enumeration->attr.ea.enumer);
 }
 
+ident *get_enumeration_ident(const ir_type *enumeration)
+{
+       assert(enumeration->type_op == type_enumeration);
+       return enumeration->name;
+}
+
+const char *get_enumeration_name(const ir_type *enumeration)
+{
+       return get_id_str(get_enumeration_ident(enumeration));
+}
+
 int get_enumeration_n_enums(const ir_type *enumeration)
 {
        assert(enumeration && (enumeration->type_op == type_enumeration));
@@ -1913,12 +1939,12 @@ void set_enumeration_nameid(ir_enum_const *enum_cnst, ident *id)
        enum_cnst->nameid = id;
 }
 
-ident *get_enumeration_nameid(const ir_enum_const *enum_cnst)
+ident *get_enumeration_const_nameid(const ir_enum_const *enum_cnst)
 {
        return enum_cnst->nameid;
 }
 
-const char *get_enumeration_name(const ir_enum_const *enum_cnst)
+const char *get_enumeration_const_name(const ir_enum_const *enum_cnst)
 {
        return get_id_str(enum_cnst->nameid);
 }
@@ -1940,13 +1966,18 @@ void set_enumeration_mode(ir_type *tp, ir_mode *mode)
 
 
 
-ir_type *new_d_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode,
-                            dbg_info *db)
+ir_type *new_d_type_pointer(ir_type *points_to, type_dbg_info *db)
 {
        ir_type *res;
+       ir_mode *mode;
 
-       assert(mode_is_reference(ptr_mode));
-       res = new_type(type_pointer, ptr_mode, name, db);
+       if (is_Method_type(points_to) || is_code_type(points_to)) {
+               mode = mode_P_code;
+       } else {
+               mode = mode_P_data;
+       }
+
+       res = new_type(type_pointer, mode, db);
        res->attr.pa.points_to = points_to;
        assert((get_mode_size_bits(res->mode) % 8 == 0) && "unorthodox modes not implemented");
        res->size = get_mode_size_bytes(res->mode);
@@ -1955,9 +1986,9 @@ ir_type *new_d_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode,
        return res;
 }
 
-ir_type *new_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode)
+ir_type *new_type_pointer(ir_type *points_to)
 {
-       return new_d_type_pointer(name, points_to, ptr_mode, NULL);
+       return new_d_type_pointer(points_to, NULL);
 }
 
 void free_pointer_entities(ir_type *pointer)
@@ -1978,7 +2009,7 @@ void set_pointer_points_to_type(ir_type *pointer, ir_type *tp)
        pointer->attr.pa.points_to = tp;
 }
 
-ir_type *get_pointer_points_to_type(ir_type *pointer)
+ir_type *get_pointer_points_to_type(const ir_type *pointer)
 {
        assert(pointer && (pointer->type_op == type_pointer));
        return pointer->attr.pa.points_to;
@@ -2012,9 +2043,9 @@ ir_type *find_pointer_type_to_type(ir_type *tp)
 
 
 
-ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info *db)
+ir_type *new_d_type_primitive(ir_mode *mode, type_dbg_info *db)
 {
-       ir_type *res = new_type(type_primitive, mode, name, db);
+       ir_type *res = new_type(type_primitive, mode, db);
        res->size  = get_mode_size_bytes(mode);
        res->flags |= tf_layout_fixed;
        res->attr.ba.base_type = NULL;
@@ -2022,9 +2053,9 @@ ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info *db)
        return res;
 }
 
-ir_type *new_type_primitive(ident *name, ir_mode *mode)
+ir_type *new_type_primitive(ir_mode *mode)
 {
-       return new_d_type_primitive(name, mode, NULL);
+       return new_d_type_primitive(mode, NULL);
 }
 
 int (is_Primitive_type)(const ir_type *primitive)
@@ -2042,7 +2073,7 @@ void set_primitive_mode(ir_type *tp, ir_mode *mode)
        tp->mode = mode;
 }
 
-ir_type *get_primitive_base_type(ir_type *tp)
+ir_type *get_primitive_base_type(const ir_type *tp)
 {
        assert(is_Primitive_type(tp));
        return tp->attr.ba.base_type;
@@ -2106,6 +2137,17 @@ int is_compound_type(const ir_type *tp)
        return tp->type_op->flags & TP_OP_FLAG_COMPOUND;
 }
 
+ident *get_compound_ident(const ir_type *tp)
+{
+       assert(is_compound_type(tp));
+       return tp->name;
+}
+
+const char *get_compound_name(const ir_type *tp)
+{
+       return get_id_str(get_compound_ident(tp));
+}
+
 int is_code_type(const ir_type *tp)
 {
        assert(tp && tp->kind == k_type);
@@ -2127,9 +2169,9 @@ int is_lowered_type(const ir_type *tp)
        return tp->flags & tf_lowered_type;
 }
 
-ir_type *new_type_value(ident *name)
+ir_type *new_type_value(void)
 {
-       ir_type *res = new_type_struct(name);
+       ir_type *res = new_type_struct(new_id_from_str("<value_type>"));
 
        res->flags |= tf_value_param_type;
 
@@ -2139,9 +2181,9 @@ ir_type *new_type_value(ident *name)
        return res;
 }
 
-ir_type *new_type_frame(ident *name)
+ir_type *new_type_frame(void)
 {
-       ir_type *res = new_type_class(name);
+       ir_type *res = new_type_class(new_id_from_str("<frame_type>"));
 
        res->flags |= tf_frame_type;
 
@@ -2163,7 +2205,7 @@ ir_type *clone_frame_type(ir_type *type)
        /* the entity link resource should be allocated if this function is called */
        assert(irp_resources_reserved(irp) & IR_RESOURCE_ENTITY_LINK);
 
-       res = new_type_frame(type->name);
+       res = new_type_frame();
        for (i = 0, n = get_class_n_members(type); i < n; ++i) {
                ir_entity *ent  = get_class_member(type, i);
                ir_entity *nent = copy_entity_own(ent, res);
@@ -2209,7 +2251,7 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
        set_type_state(frame_type, layout_undefined);
 
        if (! a_byte)
-               a_byte = new_type_primitive(new_id_from_chars("byte", 4), mode_Bu);
+               a_byte = new_type_primitive(mode_Bu);
 
        snprintf(buf, sizeof(buf), "area%u", area_cnt++);
        name = new_id_from_str(buf);
@@ -2218,7 +2260,7 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
        frame_align = get_type_alignment_bytes(frame_type);
        size = (size + frame_align - 1) & ~(frame_align - 1);
 
-       tp = new_type_array(id_mangle_u(get_type_ident(frame_type), name), 1, a_byte);
+       tp = new_type_array(1, a_byte);
        set_array_bounds_int(tp, 0, 0, size);
        set_type_alignment_bytes(tp, alignment);
 
@@ -2256,3 +2298,75 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
        set_type_state(frame_type, layout_fixed);
        return area;
 }
+
+void ir_print_type(char *buffer, size_t buffer_size, const ir_type *type)
+{
+       ident *id;
+       int p;
+       type_dbg_info *tdbgi = get_type_dbg_info(type);
+       if (tdbgi != NULL) {
+               ir_retrieve_type_dbg_info(buffer, buffer_size, tdbgi);
+               return;
+       }
+
+       /* we have to construct some name... */
+       switch (get_type_tpop_code(type)) {
+       case tpo_uninitialized:
+               break;
+       case tpo_code:
+               snprintf(buffer, buffer_size, "code");
+               return;
+
+       case tpo_class:
+               id = get_class_ident(type);
+               snprintf(buffer, buffer_size, "class '%s'", get_id_str(id));
+               return;
+
+       case tpo_struct:
+               id = get_struct_ident(type);
+               snprintf(buffer, buffer_size, "struct '%s'", get_id_str(id));
+               return;
+
+       case tpo_union:
+               id = get_union_ident(type);
+               snprintf(buffer, buffer_size, "union '%s'", get_id_str(id));
+               return;
+
+       case tpo_enumeration:
+               id = get_enumeration_ident(type);
+               snprintf(buffer, buffer_size, "enumeration '%s'", get_id_str(id));
+               return;
+
+       case tpo_unknown:
+               snprintf(buffer, buffer_size, "unknown type");
+               return;
+
+       case tpo_pointer:
+               p = snprintf(buffer, buffer_size, "pointer to ");
+               buffer      += p;
+               buffer_size -= p;
+               ir_print_type(buffer, buffer_size, get_pointer_points_to_type(type));
+               return;
+
+       case tpo_array:
+               p = snprintf(buffer, buffer_size, "array of ");
+               buffer      += p;
+               buffer_size -= p;
+               ir_print_type(buffer, buffer_size, get_array_element_type(type));
+               return;
+
+       case tpo_primitive:
+               id = get_mode_ident(get_type_mode(type));
+               snprintf(buffer, buffer_size, "%s", get_id_str(id));
+               return;
+
+       case tpo_none:
+               snprintf(buffer, buffer_size, "none");
+               return;
+       case tpo_method:
+               /* TODO: we should print argument and return types here... */
+               snprintf(buffer, buffer_size, "method type");
+               return;
+       }
+       snprintf(buffer, buffer_size, "invalid type");
+}
index aac344c..64d8c56 100644 (file)
@@ -50,7 +50,7 @@ static void do_finalization(type_or_ent tore, void *env) {
                           frame/global types this way. Should not made any problems. */
                        set_class_final(cls, 1);
                        DB((dbg, LEVEL_1, " made final Class %s\n",
-                               get_type_name(cls)));
+                               get_class_name(cls)));
                }
        } else {
                ir_entity *ent = tore.ent;
@@ -68,11 +68,11 @@ static void do_finalization(type_or_ent tore, void *env) {
                        assert(get_entity_n_overwrittenby(ent) == 0);
                        set_entity_final(ent, 1);
                        DB((dbg, LEVEL_1, " made final %s::%s\n",
-                               get_type_name(owner), get_entity_name(ent)));
+                               get_compound_name(owner), get_entity_name(ent)));
                } else if (get_entity_n_overwrittenby(ent) == 0) {
                        set_entity_final(ent, 1);
                        DB((dbg, LEVEL_1, " made final %s::%s\n",
-                               get_type_name(owner), get_entity_name(ent)));
+                               get_compound_name(owner), get_entity_name(ent)));
                }
        }
 }  /* do_finalization */
index 7088a92..46c7028 100644 (file)
@@ -223,7 +223,7 @@ struct ir_type {
        ir_mode *mode;           /**< The mode for atomic types */
        ir_visited_t visit;      /**< visited counter for walks of the type information */
        void *link;              /**< holds temporary data - like in irnode_t.h */
-       struct dbg_info *dbi;    /**< A pointer to information for debug support. */
+       type_dbg_info *dbi;      /**< A pointer to information for debug support. */
        ir_type *assoc_type;     /**< The associated lowered/unlowered type */
 
        /* ------------- fields for analyses ---------------*/
@@ -241,15 +241,14 @@ struct ir_type {
  *
  *   @param type_op  the kind of this type.  May not be type_id.
  *   @param mode     the mode to be used for this type, may be NULL
- *   @param name     an ident for the name of this type.
  *   @param db       debug info
  *
  *   @return A new type of the given type.  The remaining private attributes are not
  *           initialized.  The type is in state layout_undefined.
  */
 ir_type *
-new_type(const tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db);
-void free_type_attrs       (ir_type *tp);
+new_type(const tp_op *type_op, ir_mode *mode, type_dbg_info *db);
+void free_type_attrs(ir_type *tp);
 
 void free_class_entities      (ir_type *clss);
 void free_struct_entities     (ir_type *strct);
@@ -284,11 +283,19 @@ void set_default_size(ir_type *tp, unsigned bytes);
 /**
  * Initialize the type module.
  *
- * @param builtin_db       debug info for built-in objects
  * @param default_cc_mask  default calling conventions for methods
  */
-void firm_init_type(dbg_info *builtin_db, unsigned default_cc_mask);
+void firm_init_type(unsigned default_cc_mask);
 
+/** Clone an existing method type.
+ *
+ * @param tp      the method type to clone.
+ * @param prefix  if non-null, will be the prefix for the name of
+ *                the cloned type
+ *
+ * @return the cloned method type.
+ */
+ir_type *clone_type_method(ir_type *tp);
 
 /* ------------------- *
  *  inline functions   *
@@ -336,18 +343,6 @@ _get_type_mode(const ir_type *tp) {
        return tp->mode;
 }
 
-static inline ident *
-_get_type_ident(const ir_type *tp) {
-       assert(tp && tp->kind == k_type);
-       return tp->name;
-}
-
-static inline void
-_set_type_ident(ir_type *tp, ident* id) {
-       assert(tp && tp->kind == k_type);
-       tp->name = id;
-}
-
 static inline unsigned
 _get_type_size_bytes(const ir_type *tp) {
        assert(tp && tp->kind == k_type);
@@ -391,13 +386,13 @@ _type_not_visited(const ir_type *tp) {
        return tp->visit  < firm_type_visited;
 }
 
-static inline dbg_info *
+static inline type_dbg_info *
 _get_type_dbg_info(const ir_type *tp) {
        return tp->dbi;
 }
 
 static inline void
-_set_type_dbg_info(ir_type *tp, dbg_info *db) {
+_set_type_dbg_info(ir_type *tp, type_dbg_info *db) {
        tp->dbi = db;
 }
 
@@ -590,8 +585,6 @@ _set_method_calling_convention(ir_type *method, unsigned cc_mask) {
 #define get_type_tpop_nameid(tp)          _get_type_tpop_nameid(tp)
 #define get_type_tpop_code(tp)            _get_type_tpop_code(tp)
 #define get_type_mode(tp)                 _get_type_mode(tp)
-#define get_type_ident(tp)                _get_type_ident(tp)
-#define set_type_ident(tp, id)            _set_type_ident(tp, id)
 #define get_type_size_bytes(tp)           _get_type_size_bytes(tp)
 #define get_type_state(tp)                _get_type_state(tp)
 #define get_type_visited(tp)              _get_type_visited(tp)