#ifndef FIRM_DEBUG_DBGINFO_H
#define FIRM_DEBUG_DBGINFO_H
+#include <stdlib.h>
#include "firm_types.h"
#include "ident.h"
*/
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
* 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;
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;
*/
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
* 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
#define FIRM_TYPEREP_H
#include "firm_types.h"
+#include <stdlib.h>
/**
* @page entity Entity representation
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.
*
* @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.
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);
/** 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);
* 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.
*
* 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. -- */
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);
* 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.
*
* 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 --- */
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);
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);
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);
/**
* @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);
* 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);
/* --- 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.
*
* 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.
/* ------------------------------------------------------------------------ */
-/** 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.
*
* @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;
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;
}
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;
}
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);
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]);
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);
#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);
{
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);
{
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);
{
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);
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);
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.
*
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));
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 */
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();
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();
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);
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);
}
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) {
{
#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);
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));
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);
}
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;
* @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);
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);
}
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);
}
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);
}
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);
}
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);
}
*
* @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;
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));
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);
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"));
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);
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;
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);
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);
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 */
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;
}
/** 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)
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;
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 */
/**
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 */
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));
}
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));
}
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"));
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];
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;
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;
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:
}
}
+static void print_type_dbg_info(FILE *F, type_dbg_info *dbg)
+{
+ (void) F;
+ (void) dbg;
+ /* TODO */
+}
+
/**
* Dump a node
*/
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");
{
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)
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.
} 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);
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");
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");
}
} 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)) {
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));
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;
}
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");
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);
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) {
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));
}
}
}
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) {
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);
}
}
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]);
/* 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.
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) {
}
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]);
}
#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));
}
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)) {
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) {
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);
}
}
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)
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;
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 ...");
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;
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);
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)),
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;
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);
}
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) {
return;
}
- type = new_type_frame(id);
+ type = new_type_frame();
set_type_size_bytes(type, size);
kindstr = "frametype";
return;
}
- type = new_type_value(id);
+ type = new_type_value();
set_type_size_bytes(type, size);
kindstr = "valuetype";
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) {
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:
{
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);
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 */
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. */
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);
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;
/* 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));
/* 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);
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");
{
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;
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);
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++);
/* 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);
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);
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);
}
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!*/
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));
}
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));
}
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));
}
*/
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))));
}
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));
);
}
* 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;
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);
}
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;
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;
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 {
}
/* 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)
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;
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;
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;
*/
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))
} /* 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) {
/* 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);
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);
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);
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);
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);
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;
}
* @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) {
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);
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;
/* ----------------------------------------------------------------------- */
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
#include "irhooks.h"
#include "irtools.h"
#include "entity_t.h"
+#include "error.h"
+#include "dbginfo.h"
#include "array.h"
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);
_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);
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;
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)
{
#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);
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);
}
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;
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;
}
}
}
-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);
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));
}
-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);
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));
* @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);
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;
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;
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
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
}
-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);
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));
-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;
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);
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)
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;
}
-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;
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));
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);
}
-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);
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)
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;
-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;
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)
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;
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);
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;
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;
/* 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);
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);
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);
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");
+}
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;
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 */
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 ---------------*/
*
* @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);
/**
* 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 *
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);
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;
}
#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)