#include "config.h"
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
+#include <string.h>
+#include <stdlib.h>
#include <stddef.h>
#include "type_t.h"
/*-----------------------------------------------------------------*/
ir_type *firm_none_type; ir_type *get_none_type(void) { return firm_none_type; }
+ir_type *firm_code_type; ir_type *get_code_type(void) { return firm_code_type; }
ir_type *firm_unknown_type; ir_type *get_unknown_type(void) { return firm_unknown_type; }
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);
+ 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);
set_type_size_bytes(firm_unknown_type, 0);
set_type_state (firm_unknown_type, layout_fixed);
* Creates a new type representation.
*/
ir_type *
-new_type(tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
+new_type(const tp_op *type_op, ir_mode *mode, ident *name, dbg_info *db) {
ir_type *res;
int node_size;
void free_type(ir_type *tp) {
const tp_op *op = get_type_tpop(tp);
- if ((get_type_tpop(tp) == tpop_none) || (get_type_tpop(tp) == tpop_unknown))
+ if ((get_type_tpop(tp) == tpop_none) || (get_type_tpop(tp) == tpop_unknown)
+ || (get_type_tpop(tp) == tpop_code))
return;
/* Remove from list of all types */
remove_irp_type(tp);
/* 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);
}
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;
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);
}
/*
return method->attr.ma.params[pos].ent;
}
+/*
+ * Sets the type that represents the copied value arguments.
+ */
+void set_method_value_param_type(ir_type *method, ir_type *tp) {
+ int i, n;
+
+ assert(method && (method->type_op == type_method));
+ assert(is_value_param_type(tp));
+ assert(get_method_n_params(method) == get_struct_n_members(tp));
+
+ method->attr.ma.value_params = tp;
+
+ n = get_struct_n_members(tp);
+ for (i = 0; i < n; i++)
+ {
+ ir_entity *ent = get_struct_member(tp, i);
+ method->attr.ma.params[i].ent = ent;
+ }
+}
+
/*
* Returns a type that represents the copied value arguments.
*/
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;
}
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;
}
return tp->type_op->flags & TP_OP_FLAG_COMPOUND;
}
+int is_code_type(const ir_type *tp) {
+ assert(tp && tp->kind == k_type);
+ return tp->type_op == tpop_code;
+}
+
/* Checks, whether a type is a frame type */
int is_frame_type(const ir_type *tp) {
return tp->flags & tf_frame_type;
return tp->flags & tf_lowered_type;
}
+/* Makes a new value type. */
+ir_type *new_type_value(ident *name) {
+ ir_type *res = new_type_struct(name);
+
+ res->flags |= tf_value_param_type;
+
+ /* Remove type from type list. Must be treated differently than other types. */
+ remove_irp_type(res);
+
+ return res;
+}
+
/* Makes a new frame type. */
ir_type *new_type_frame(ident *name) {
ir_type *res = new_type_class(name);
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);