X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Ftype.c;h=8f252f8c0165c3ac241bfd10786394a24a36a104;hb=0651be9698637d202db8d0acbda9597de4ca9a7c;hp=78e03d12586db31c39549560c1340a591f1cdad5;hpb=3ed9d6b7033abb729aa0fd500ae028782189eaa1;p=libfirm diff --git a/ir/tr/type.c b/ir/tr/type.c index 78e03d125..8f252f8c0 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -85,17 +85,8 @@ ir_type *get_unknown_type(void) static ident *value_params_suffix = NULL; static ident *value_ress_suffix = NULL; -/** The default calling convention for method types. */ -static unsigned default_cc_mask; - -unsigned get_default_cc_mask(void) -{ - return default_cc_mask; -} - -void firm_init_type(unsigned def_cc_mask) +void ir_init_type(void) { - 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); @@ -115,6 +106,24 @@ void firm_init_type(unsigned def_cc_mask) remove_irp_type(firm_unknown_type); } +void ir_finish_type(void) +{ + if (firm_none_type != NULL) { + free_type(firm_none_type); + firm_none_type = NULL; + } + if (firm_code_type != NULL) { + free_type(firm_code_type); + firm_code_type = NULL; + } + if (firm_unknown_type != NULL) { + free_type(firm_unknown_type); + firm_unknown_type = NULL; + } + value_params_suffix = NULL; + value_ress_suffix = NULL; +} + /** the global type visited flag */ ir_visited_t firm_type_visited; @@ -378,7 +387,7 @@ void set_type_state(ir_type *tp, ir_type_state state) break; case tpo_enumeration: #ifndef NDEBUG - assert(get_type_mode != NULL); + assert(get_type_mode(tp) != NULL); for (i = get_enumeration_n_enums(tp) - 1; i >= 0; --i) { ir_enum_const *ec = get_enumeration_const(tp, i); tarval *tv = get_enumeration_value(ec); @@ -776,7 +785,7 @@ 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) +static void add_class_member(ir_type *clss, ir_entity *member) { assert(clss && (clss->type_op == type_class)); assert(clss != get_entity_type(member) && "recursive type"); @@ -834,7 +843,7 @@ void set_class_members(ir_type *clss, ir_entity **members, int arity) } } -void remove_class_member(ir_type *clss, ir_entity *member) +static void remove_class_member(ir_type *clss, ir_entity *member) { int i; assert(clss && (clss->type_op == type_class)); @@ -1101,7 +1110,7 @@ int get_struct_n_members(const ir_type *strct) return ARR_LEN(strct->attr.sa.members); } -void add_struct_member(ir_type *strct, ir_entity *member) +static void add_struct_member(ir_type *strct, ir_entity *member) { assert(strct && (strct->type_op == type_struct)); assert(get_type_tpop(get_entity_type(member)) != type_method); @@ -1134,7 +1143,7 @@ void set_struct_member(ir_type *strct, int pos, ir_entity *member) strct->attr.sa.members[pos] = member; } -void remove_struct_member(ir_type *strct, ir_entity *member) +static void remove_struct_member(ir_type *strct, ir_entity *member) { int i; assert(strct && (strct->type_op == type_struct)); @@ -1215,7 +1224,6 @@ ir_type *new_d_type_method(int n_param, int n_res, type_dbg_info *db) res->attr.ma.variadicity = variadicity_non_variadic; res->attr.ma.first_variadic_param = -1; res->attr.ma.additional_properties = mtp_no_property; - res->attr.ma.irg_calling_conv = default_cc_mask; hook_new_type(res); return res; } @@ -1566,7 +1574,7 @@ int get_union_n_members(const ir_type *uni) return ARR_LEN(uni->attr.ua.members); } -void add_union_member(ir_type *uni, ir_entity *member) +static void add_union_member(ir_type *uni, ir_entity *member) { assert(uni && (uni->type_op == type_union)); assert(uni != get_entity_type(member) && "recursive type"); @@ -1598,7 +1606,7 @@ void set_union_member(ir_type *uni, int pos, ir_entity *member) uni->attr.ua.members[pos] = member; } -void remove_union_member(ir_type *uni, ir_entity *member) +static void remove_union_member(ir_type *uni, ir_entity *member) { int i; assert(uni && (uni->type_op == type_union)); @@ -1650,7 +1658,10 @@ ir_type *new_d_type_array(int n_dimensions, ir_type *element_type, current_ir_graph = rem; res->attr.aa.element_type = element_type; - new_entity(res, new_id_from_chars("elem_ent", 8), element_type); + res->attr.aa.element_ent + = new_entity(NULL, new_id_from_chars("elem_ent", 8), element_type); + res->attr.aa.element_ent->owner = res; + hook_new_type(res); return res; } @@ -2142,6 +2153,30 @@ const char *get_compound_name(const ir_type *tp) return get_id_str(get_compound_ident(tp)); } +void remove_compound_member(ir_type *compound, ir_entity *entity) +{ + switch (get_type_tpop_code(compound)) { + case tpo_class: remove_class_member(compound, entity); break; + case tpo_struct: remove_struct_member(compound, entity); break; + case tpo_union: remove_union_member(compound, entity); break; + default: + panic("argument for remove_compound_member not a compound type"); + } +} + +void add_compound_member(ir_type *compound, ir_entity *entity) +{ + switch (get_type_tpop_code(compound)) { + case tpo_class: add_class_member(compound, entity); break; + case tpo_struct: add_struct_member(compound, entity); break; + case tpo_union: add_union_member(compound, entity); break; + default: + panic("argument for add_compound_member not a compound type"); + } +} + + + int is_code_type(const ir_type *tp) { assert(tp && tp->kind == k_type);