* type_t.h type tpop
*****
*/
+
+/* $Id$ */
+
# include <stdlib.h>
# include <stddef.h>
# include "type_t.h"
# include "tpop_t.h"
# include "typegmod_t.h"
# include "array.h"
+# include "irprog.h"
+# include "mangle.h"
+# include "tv.h"
+# include "ircons.h"
/*******************************************************************/
/** TYPE **/
res->state = layout_undefined;
res->size = -1;
res->visit = 0;
+ res -> link = NULL;
return res;
}
}
}
+/* set/get the link field */
+void *get_type_link(type *tp)
+{
+ assert(tp);
+ return(tp -> link);
+}
+
+void set_type_link(type *tp, void *l)
+{
+ assert(tp);
+ tp -> link = l;
+}
+
tp_op* get_type_tpop(type *tp) {
assert(tp);
return tp->type_op;
assert(tp);
return tp->type_op->name;
}
+
const char* get_type_tpop_name(type *tp) {
assert(tp);
return id_to_str(tp->type_op->name);
}
+
tp_opcode get_type_tpop_code(type *tp) {
assert(tp);
return tp->type_op->code;
}
+
ir_mode* get_type_mode(type *tp) {
assert(tp);
return tp->mode;
}
+
void set_type_mode(type *tp, ir_mode* m) {
assert(tp);
tp->mode = m;
if ((tp->type_op == type_pointer) || (tp->type_op == type_primitive))
tp->size == get_mode_size(m);
}
-ident* get_type_nameid(type *tp) {
+
+ident* get_type_ident(type *tp) {
assert(tp);
return tp->name;
}
-void set_type_nameid(type *tp, ident* id) {
+
+void set_type_ident(type *tp, ident* id) {
assert(tp);
tp->name = id;
}
+
const char* get_type_name(type *tp) {
assert(tp);
return id_to_str(tp->name);
}
+
int get_type_size(type *tp) {
assert(tp);
return tp->size;
set_type_state(type *tp, type_state state) {
assert(tp);
/* For pointer and primitive always fixed. */
- if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive))
+ if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive)) {
+ /* @@@ assert that the layout really is fixed!!! */
tp->state = state;
+ }
}
unsigned long get_type_visited(type *tp) {
}
void add_class_subtype (type *clss, type *subtype) {
+ int i;
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
+ for (i = 0; i < get_class_n_supertype(subtype); i++)
+ if (get_class_supertype(subtype, i) == clss)
+ /* Class already registered */
+ return;
ARR_APP1 (type *, subtype->attr.ca.supertypes, clss);
}
int get_class_n_subtype (type *clss) {
}
void add_class_supertype (type *clss, type *supertype) {
+ int i;
assert(clss && (clss->type_op == type_class));
+ assert(supertype && (supertype -> type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
+ for (i = 0; i < get_class_n_subtype(supertype); i++)
+ if (get_class_subtype(supertype, i) == clss)
+ /* Class already registered */
+ return;
ARR_APP1 (type *, supertype->attr.ca.subtypes, clss);
}
int get_class_n_supertype (type *clss) {
res->attr.aa.lower_bound = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
res->attr.aa.upper_bound = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
res->attr.aa.element_type = element_type;
- new_entity(res, name, element_type);
+ new_entity(res, mangle(name, id_from_str("elem_ent", 8)), element_type);
return res;
}
inline void free_array_attrs (type *array) {
assert(array && (array->type_op == type_array));
return array->attr.aa.n_dimensions;
}
-void set_array_bounds (type *array, int dimension, ir_node * lower_bound,
- ir_node * upper_bound) {
+void set_array_bounds_int (type *array, int dimension, int lower_bound,
+ int upper_bound) {
+ ir_graph *rem;
+ assert(array && (array->type_op == type_array));
+ rem = current_ir_graph;
+ current_ir_graph = get_const_code_irg();
+ array->attr.aa.lower_bound[dimension] =
+ new_Const(mode_I, tarval_from_long (mode_I, lower_bound));
+ array->attr.aa.upper_bound[dimension] =
+ new_Const(mode_I, tarval_from_long (mode_I, upper_bound));
+ current_ir_graph = rem;
+}
+
+void set_array_bounds (type *array, int dimension, ir_node * lower_bound,
+ ir_node * upper_bound) {
assert(array && (array->type_op == type_array));
array->attr.aa.lower_bound[dimension] = lower_bound;
array->attr.aa.upper_bound[dimension] = upper_bound;
assert(primitive);
if (primitive->type_op == type_primitive) return 1; else return 0;
}
+
+int is_atomic_type(type *tp) {
+ return (is_primitive_type(tp) || is_pointer_type(tp) ||
+ is_enumeration_type(tp));
+}
+int is_compound_type(type *tp) {
+ return (is_class_type(tp) || is_struct_type(tp) ||
+ is_array_type(tp) || is_union_type(tp));
+}