* @see type_t.h type tpop
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include "config.h"
+#include <string.h>
+#include <stdlib.h>
#include <stddef.h>
#include "type_t.h"
if (get_class_n_supertypes(typ1) != get_class_n_supertypes(typ2)) return 0;
if (get_class_peculiarity(typ1) != get_class_peculiarity(typ2)) return 0;
/** Compare the members **/
- m = alloca(sizeof(ir_entity *) * get_class_n_members(typ1));
- memset(m, 0, sizeof(ir_entity *) * get_class_n_members(typ1));
+ m = ALLOCANZ(ir_entity*, get_class_n_members(typ1));
/* First sort the members of typ2 */
for (i = 0; i < get_class_n_members(typ1); i++) {
ir_entity *e1 = get_class_member(typ1, i);
return 0;
}
/** Compare the supertypes **/
- t = alloca(sizeof(ir_entity *) * get_class_n_supertypes(typ1));
- memset(t, 0, sizeof(ir_entity *) * get_class_n_supertypes(typ1));
+ t = ALLOCANZ(ir_type*, get_class_n_supertypes(typ1));
/* First sort the supertypes of typ2 */
for (i = 0; i < get_class_n_supertypes(typ1); i++) {
ir_type *t1 = get_class_supertype(typ1, i);
case tpo_struct:
if (get_struct_n_members(typ1) != get_struct_n_members(typ2)) return 0;
- m = alloca(sizeof(ir_entity *) * get_struct_n_members(typ1));
- memset(m, 0, sizeof(ir_entity *) * get_struct_n_members(typ1));
+ m = ALLOCANZ(ir_entity*, get_struct_n_members(typ1));
/* First sort the members of lt */
for (i = 0; i < get_struct_n_members(typ1); i++) {
ir_entity *e1 = get_struct_member(typ1, i);
case tpo_union:
if (get_union_n_members(typ1) != get_union_n_members(typ2)) return 0;
- m = alloca(sizeof(ir_entity *) * get_union_n_members(typ1));
- memset(m, 0, sizeof(ir_entity *) * get_union_n_members(typ1));
+ m = ALLOCANZ(ir_entity*, get_union_n_members(typ1));
/* First sort the members of lt */
for (i = 0; i < get_union_n_members(typ1); i++) {
ir_entity *e1 = get_union_member(typ1, i);
if (n_st_members != get_struct_n_members(lt))
return 0;
- m = alloca(sizeof(ir_entity *) * n_st_members);
- memset(m, 0, sizeof(ir_entity *) * n_st_members);
+ 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);
case tpo_union:
n_st_members = get_union_n_members(st);
if (n_st_members != get_union_n_members(lt)) return 0;
- m = alloca(sizeof(ir_entity *) * n_st_members);
- memset(m, 0, sizeof(ir_entity *) * n_st_members);
+ 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);
/* use the parameter name if specified */
if (! id)
- id = mangle_u(name, get_type_ident(elt_type));
+ id = id_mangle_u(name, get_type_ident(elt_type));
tps[i].ent = new_entity(res, id, elt_type);
set_entity_allocation(tps[i].ent, allocation_parameter);
}
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P_code);
res->attr.ma.n_params = n_param;
- res->attr.ma.params = xcalloc(n_param, sizeof(res->attr.ma.params[0]));
+ res->attr.ma.params = XMALLOCNZ(tp_ent_pair, n_param);
res->attr.ma.value_params = NULL;
res->attr.ma.n_res = n_res;
- res->attr.ma.res_type = xcalloc(n_res, sizeof(res->attr.ma.res_type[0]));
+ res->attr.ma.res_type = XMALLOCNZ(tp_ent_pair, n_res);
res->attr.ma.value_ress = NULL;
res->attr.ma.variadicity = variadicity_non_variadic;
res->attr.ma.first_variadic_param = -1;
name = tp->name;
if (prefix != NULL)
- name = mangle(prefix, name);
+ name = id_mangle(prefix, name);
mode = tp->mode;
n_params = tp->attr.ma.n_params;
res->assoc_type = tp->assoc_type;
res->size = tp->size;
res->attr.ma.n_params = n_params;
- res->attr.ma.params = xcalloc(n_params, sizeof(res->attr.ma.params[0]));
+ res->attr.ma.params = XMALLOCN(tp_ent_pair, n_params);
memcpy(res->attr.ma.params, tp->attr.ma.params, n_params * sizeof(res->attr.ma.params[0]));
res->attr.ma.value_params = tp->attr.ma.value_params;
res->attr.ma.n_res = n_res;
- res->attr.ma.res_type = xcalloc(n_res, sizeof(res->attr.ma.res_type[0]));
+ res->attr.ma.res_type = XMALLOCN(tp_ent_pair, n_res);
memcpy(res->attr.ma.res_type, tp->attr.ma.res_type, n_res * sizeof(res->attr.ma.res_type[0]));
res->attr.ma.value_ress = tp->attr.ma.value_ress;
res->attr.ma.variadicity = tp->attr.ma.variadicity;
if (!method->attr.ma.value_params) {
/* parameter value type not created yet, build */
method->attr.ma.value_params
- = build_value_type(mangle_u(get_type_ident(method), value_params_suffix),
+ = build_value_type(id_mangle_u(get_type_ident(method), value_params_suffix),
get_method_n_params(method), method->attr.ma.params);
}
/*
if (!method->attr.ma.value_ress) {
/* result value type not created yet, build */
method->attr.ma.value_ress
- = build_value_type(mangle_u(get_type_ident(method), value_ress_suffix),
+ = build_value_type(id_mangle_u(get_type_ident(method), value_ress_suffix),
get_method_n_ress(method), method->attr.ma.res_type);
}
/*
}
/* Returns the null-terminated name of this variadicity. */
-const char *get_variadicity_name(variadicity vari) {
+const char *get_variadicity_name(ir_variadicity vari) {
#define X(a) case a: return #a
switch (vari) {
X(variadicity_non_variadic);
#undef X
}
-variadicity get_method_variadicity(const ir_type *method) {
+ir_variadicity get_method_variadicity(const ir_type *method) {
assert(method && (method->type_op == type_method));
return method->attr.ma.variadicity;
}
-void set_method_variadicity(ir_type *method, variadicity vari) {
+void set_method_variadicity(ir_type *method, ir_variadicity vari) {
assert(method && (method->type_op == type_method));
method->attr.ma.variadicity = vari;
}
res = new_type(type_array, NULL, name, db);
res->attr.aa.n_dimensions = n_dimensions;
- res->attr.aa.lower_bound = xcalloc(n_dimensions, sizeof(*res->attr.aa.lower_bound));
- res->attr.aa.upper_bound = xcalloc(n_dimensions, sizeof(*res->attr.aa.upper_bound));
- res->attr.aa.order = xcalloc(n_dimensions, sizeof(*res->attr.aa.order));
+ res->attr.aa.lower_bound = XMALLOCNZ(ir_node*, n_dimensions);
+ res->attr.aa.upper_bound = XMALLOCNZ(ir_node*, n_dimensions);
+ res->attr.aa.order = XMALLOCNZ(int, n_dimensions);
current_ir_graph = get_const_code_irg();
unk = new_Unknown(mode_Iu);
current_ir_graph = rem;
res->attr.aa.element_type = element_type;
- new_entity(res, mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
+ new_entity(res, id_mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
hook_new_type(res);
return res;
}
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_bounds(array, dimension,
- new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)),
- new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu )));
+ new_Const_long(mode_Iu, lower_bound),
+ new_Const_long(mode_Iu, upper_bound));
current_ir_graph = rem;
}
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_lower_bound(array, dimension,
- new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)));
+ new_Const_long(mode_Iu, lower_bound));
current_ir_graph = rem;
}
void
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_upper_bound(array, dimension,
- new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu)));
+ new_Const_long(mode_Iu, upper_bound));
current_ir_graph = rem;
}
int i, n;
assert(is_frame_type(type));
+ /* the entity link resource should be allocated if this function is called */
+ assert(irp_resources_reserved(irp) & IR_RESOURCE_ENTITY_LINK);
res = new_type_frame(type->name);
for (i = 0, n = get_class_n_members(type); i < n; ++i) {
frame_align = get_type_alignment_bytes(frame_type);
size = (size + frame_align - 1) & ~(frame_align - 1);
- tp = new_type_array(mangle_u(get_type_ident(frame_type), name), 1, a_byte);
+ tp = new_type_array(id_mangle_u(get_type_ident(frame_type), name), 1, a_byte);
set_array_bounds_int(tp, 0, 0, size);
set_type_alignment_bytes(tp, alignment);