Commit 09f2dc24 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove unused smaller_type

parent e49d1e47
......@@ -1153,43 +1153,6 @@ FIRM_API int is_type(const void *thing);
*/
FIRM_API long get_type_nr(const ir_type *tp);
/**
* Checks whether two types are structural comparable.
*
* @param st pointer type
* @param lt pointer type
*
* @return
* true if type st is smaller than type lt, i.e. whenever
* lt is expected a st can be used.
* This is true if
* - they are the same type kind
* - mode(st) < mode (lt) (if applicable)
* - they are class types and st is (transitive) subtype of lt,
* - they are structure types and
* - the members of st have exactly one counterpart in lt with the same name,
* - the counterpart has a bigger type.
* - they are method types and have
* - the same number of parameter and result types,
* - the parameter types of st are smaller than those of lt,
* - the result types of st are smaller than those of lt
* - they are union types and have the members of st have exactly one
* @return counterpart in lt and the type is smaller
* - they are array types and have
* - the same number of dimensions
* - all bounds of lt are bound of st
* - the same dimension order
* - the same element type
* @return or
* - the element type of st is smaller than that of lt
* - the element types have the same size and fixed layout.
* - they are enumeration types and have the same enumerator names
* - they are pointer types and have the points_to type of st is
* @return smaller than the points_to type of lt.
*
*/
FIRM_API int smaller_type(ir_type *st, ir_type *lt);
/**
* @ingroup compound_type
* @defgroup class_type Class
......
......@@ -408,138 +408,6 @@ int (is_type)(const void *thing)
return _is_type(thing);
}
int smaller_type(ir_type *st, ir_type *lt)
{
ir_entity **m;
size_t i;
size_t j;
size_t n_st_members;
if (st == lt) return 1;
if (get_type_tpop_code(st) != get_type_tpop_code(lt))
return 0;
switch (get_type_tpop_code(st)) {
case tpo_class:
return is_SubClass_of(st, lt);
case tpo_struct:
n_st_members = get_struct_n_members(st);
if (n_st_members != get_struct_n_members(lt))
return 0;
m = ALLOCANZ(ir_entity*, n_st_members);
/* First sort the members of lt */
for (i = 0; i < n_st_members; ++i) {
ir_entity *se = get_struct_member(st, i);
size_t n = get_struct_n_members(lt);
for (j = 0; j < n; ++j) {
ir_entity *le = get_struct_member(lt, j);
if (get_entity_name(le) == get_entity_name(se))
m[i] = le;
}
}
for (i = 0; i < n_st_members; i++) {
if (!m[i] || /* Found no counterpart */
!smaller_type(get_entity_type(get_struct_member(st, i)), get_entity_type(m[i])))
return 0;
}
break;
case tpo_method: {
size_t n_param1, n_param2;
/** FIXME: is this still 1? */
if (get_method_variadicity(st) != get_method_variadicity(lt)) return 0;
if (get_method_n_ress(st) != get_method_n_ress(lt)) return 0;
if (get_method_calling_convention(st) !=
get_method_calling_convention(lt)) return 0;
n_param1 = get_method_n_params(st);
n_param2 = get_method_n_params(lt);
if (n_param1 != n_param2) return 0;
for (i = 0; i < get_method_n_params(st); i++) {
if (!smaller_type(get_method_param_type(st, i), get_method_param_type(lt, i)))
return 0;
}
for (i = 0; i < get_method_n_ress(st); i++) {
if (!smaller_type(get_method_res_type(st, i), get_method_res_type(lt, i)))
return 0;
}
} break;
case tpo_union:
n_st_members = get_union_n_members(st);
if (n_st_members != get_union_n_members(lt)) return 0;
m = ALLOCANZ(ir_entity*, n_st_members);
/* First sort the members of lt */
for (i = 0; i < n_st_members; ++i) {
ir_entity *se = get_union_member(st, i);
size_t n = get_union_n_members(lt);
for (j = 0; j < n; ++j) {
ir_entity *le = get_union_member(lt, j);
if (get_entity_name(le) == get_entity_name(se))
m[i] = le;
}
}
for (i = 0; i < n_st_members; ++i) {
if (!m[i] || /* Found no counterpart */
!smaller_type(get_entity_type(get_union_member(st, i)), get_entity_type(m[i])))
return 0;
}
break;
case tpo_array: {
ir_type *set, *let; /* small/large elt. ir_type */
if (get_array_n_dimensions(st) != get_array_n_dimensions(lt))
return 0;
set = get_array_element_type(st);
let = get_array_element_type(lt);
if (set != let) {
/* If the element types are different, set must be convertible
to let, and they must have the same size so that address
computations work out. To have a size the layout must
be fixed. */
if ((get_type_state(set) != layout_fixed) ||
(get_type_state(let) != layout_fixed))
return 0;
if (!smaller_type(set, let) ||
get_type_size_bytes(set) != get_type_size_bytes(let))
return 0;
}
for (i = 0; i < get_array_n_dimensions(st); i++) {
if (get_array_lower_bound(lt, i))
if (get_array_lower_bound(st, i) != get_array_lower_bound(lt, i))
return 0;
if (get_array_upper_bound(lt, i))
if (get_array_upper_bound(st, i) != get_array_upper_bound(lt, i))
return 0;
}
} break;
case tpo_enumeration:
assert(0 && "enumerations not implemented");
break;
case tpo_pointer:
if (!smaller_type(get_pointer_points_to_type(st), get_pointer_points_to_type(lt)))
return 0;
break;
case tpo_primitive:
if (!smaller_mode(get_type_mode(st), get_type_mode(lt)))
return 0;
break;
default: break;
}
return 1;
}
ir_type *new_d_type_class(ident *name, type_dbg_info *db)
{
ir_type *res;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment