#include "callgraph.h" /* for dumping debug output */
-/*******************************************************************/
+/**
+ * An interval initializer.
+ */
+typedef struct interval_initializer interval_initializer;
+
+/**
+ * A value initializer.
+ */
+typedef struct value_initializer value_initializer;
+
+struct interval_initializer {
+ int first_index; /**< The first index of the initialized interval. */
+ int last_index; /**< The last index of the initialized interval. */
+ interval_initializer *next; /**< Points to the next interval initializer. */
+};
+
+struct value_initializer {
+ ir_entity *ent; /**< The initialized entity. */
+ value_initializer *next; /**< Points to the next value initializer. */
+};
+
+typedef union initializer {
+ ir_node *value; /**< The value of the initializer. */
+ ir_node **values; /**< The values of an interval. */
+ value_initializer *val_init; /**< Points the the head of the next value initializers. */
+ interval_initializer *int_init; /**< Points to the head of the next value initializers. */
+} initializer;
+
+/*-----------------------------------------------------------------*/
/** general **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
ir_entity *unknown_entity = NULL;
ir_entity *get_unknown_entity(void) { return unknown_entity; }
+/** The name of the unknown entity. */
#define UNKNOWN_ENTITY_NAME "unknown_entity"
/*-----------------------------------------------------------------*/
res->allocation = allocation_automatic;
res->visibility = visibility_local;
res->volatility = volatility_non_volatile;
+ res->align = align_is_aligned;
res->stickyness = stickyness_unsticky;
res->peculiarity = peculiarity_existent;
res->address_taken = ir_address_taken_unknown;
}
if (is_compound_entity(ent)) {
if (ent->attr.cmpd_attr.val_paths) {
- for (i = 0; i < get_compound_ent_n_values(ent); i++)
+ for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i)
if (ent->attr.cmpd_attr.val_paths[i]) {
/* free_compound_graph_path(ent->attr.cmpd_attr.val_paths[i]) ; * @@@ warum nich? */
/* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
_set_entity_volatility(ent, vol);
} /* set_entity_volatility */
-/* return the name of the volatility */
+/* Return the name of the volatility. */
const char *get_volatility_name(ir_volatility var)
{
#define X(a) case a: return #a
#undef X
} /* get_volatility_name */
+ir_align
+(get_entity_align)(const ir_entity *ent) {
+ return _get_entity_align(ent);
+} /* get_entity_align */
+
+void
+(set_entity_align)(ir_entity *ent, ir_align a) {
+ _set_entity_align(ent, a);
+} /* set_entity_align */
+
+/* Return the name of the alignment. */
+const char *get_align_name(ir_align a)
+{
+#define X(a) case a: return #a
+ switch (a) {
+ X(align_non_aligned);
+ X(align_is_aligned);
+ default: return "BAD VALUE";
+ }
+#undef X
+} /* get_align_name */
+
ir_peculiarity
(get_entity_peculiarity)(const ir_entity *ent) {
return _get_entity_peculiarity(ent);
assert(is_atomic_entity(ent) && (ent->variability != variability_uninitialized));
if (is_Method_type(ent->type) && (ent->peculiarity == peculiarity_existent))
return;
+ assert(get_irn_mode(val) == get_type_mode(ent->type));
ent->value = val;
} /* set_atomic_ent_value */
* Returns the position of a value with the given path.
* The path must contain array indices for all array element entities.
*
- * @todo This implementation is very low and should be replaced when the new tree oriented
+ * @todo This implementation is very slow (O(number of initializers^2) and should
+ * be replaced when the new tree oriented
* value representation is finally implemented.
*/
static int get_compound_ent_pos_by_path(ir_entity *ent, compound_graph_path *path) {
void
remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent) {
- int i;
+ int i, n;
assert(is_compound_entity(ent) && (ent->variability != variability_uninitialized));
- for (i = 0; i < (ARR_LEN(ent->attr.cmpd_attr.val_paths)); ++i) {
+
+ n = ARR_LEN(ent->attr.cmpd_attr.val_paths);
+ for (i = 0; i < n; ++i) {
compound_graph_path *path = ent->attr.cmpd_attr.val_paths[i];
if (path->list[path->len-1].node == value_ent) {
- for (; i < (ARR_LEN(ent->attr.cmpd_attr.val_paths))-1; ++i) {
+ for (; i < n - 1; ++i) {
ent->attr.cmpd_attr.val_paths[i] = ent->attr.cmpd_attr.val_paths[i+1];
ent->attr.cmpd_attr.values[i] = ent->attr.cmpd_attr.values[i+1];
}
- ARR_SETLEN(ir_entity*, ent->attr.cmpd_attr.val_paths, ARR_LEN(ent->attr.cmpd_attr.val_paths) - 1);
- ARR_SETLEN(ir_node*, ent->attr.cmpd_attr.values, ARR_LEN(ent->attr.cmpd_attr.values) - 1);
+ ARR_SETLEN(ir_entity*, ent->attr.cmpd_attr.val_paths, n - 1);
+ ARR_SETLEN(ir_node*, ent->attr.cmpd_attr.values, n - 1);
break;
}
}
assert(get_type_state(get_entity_type(ent)) == layout_fixed);
- path = get_compound_ent_value_path(ent, pos);
+ path = get_compound_ent_value_path(ent, pos);
path_len = get_compound_graph_path_length(path);
- curr_tp = path->tp;
+ curr_tp = path->tp;
for (i = 0; i < path_len; ++i) {
- ir_entity *node = get_compound_graph_path_node(path, i);
- ir_type *node_tp = get_entity_type(node);
-
if (is_Array_type(curr_tp)) {
- int size = get_type_size_bits(node_tp);
- int align = get_type_alignment_bits(node_tp);
- int idx;
+ ir_type *elem_type = get_array_element_type(curr_tp);
+ int size = get_type_size_bits(elem_type);
+ int align = get_type_alignment_bits(elem_type);
+ int idx;
assert(size > 0);
if(size % align > 0) {
idx = get_compound_graph_path_array_index(path, i);
assert(idx >= 0);
offset += size * idx;
+ curr_tp = elem_type;
} else {
+ ir_entity *node = get_compound_graph_path_node(path, i);
offset += get_entity_offset(node);
+ curr_tp = get_entity_type(node);
}
- curr_tp = node_tp;
}
return offset;
assert(get_type_state(get_entity_type(ent)) == layout_fixed);
- path = get_compound_ent_value_path(ent, pos);
- path_len = get_compound_graph_path_length(path);
+ path = get_compound_ent_value_path(ent, pos);
+ path_len = get_compound_graph_path_length(path);
last_node = get_compound_graph_path_node(path, path_len - 1);
+ if(last_node == NULL)
+ return 0;
+
return get_entity_offset_bits_remainder(last_node);
} /* get_compound_ent_value_offset_bit_remainder */
int
get_entity_overwrites_index(ir_entity *ent, ir_entity *overwritten) {
- int i;
+ int i, n;
assert(is_Class_type(get_entity_owner(ent)));
- for (i = 0; i < get_entity_n_overwrites(ent); i++)
+ n = get_entity_n_overwrites(ent);
+ for (i = 0; i < n; ++i) {
if (get_entity_overwrites(ent, i) == overwritten)
return i;
+ }
return -1;
} /* get_entity_overwrites_index */
void
remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten) {
- int i;
+ int i, n;
assert(is_Class_type(get_entity_owner(ent)));
- for (i = 0; i < (ARR_LEN (ent->overwrites)); i++)
+ n = ARR_LEN(ent->overwrites);
+ for (i = 0; i < n; ++i) {
if (ent->overwrites[i] == overwritten) {
- for(; i < (ARR_LEN (ent->overwrites))-1; i++)
+ for (; i < n - 1; i++)
ent->overwrites[i] = ent->overwrites[i+1];
- ARR_SETLEN(ir_entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
+ ARR_SETLEN(ir_entity*, ent->overwrites, n - 1);
break;
}
+ }
} /* remove_entity_overwrites */
void
int
get_entity_n_overwrittenby(ir_entity *ent) {
assert(is_Class_type(get_entity_owner(ent)));
- return (ARR_LEN (ent->overwrittenby));
+ return ARR_LEN(ent->overwrittenby);
} /* get_entity_n_overwrittenby */
int
get_entity_overwrittenby_index(ir_entity *ent, ir_entity *overwrites) {
- int i;
+ int i, n;
assert(is_Class_type(get_entity_owner(ent)));
- for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
+ n = get_entity_n_overwrittenby(ent);
+ for (i = 0; i < n; ++i) {
if (get_entity_overwrittenby(ent, i) == overwrites)
return i;
+ }
return -1;
} /* get_entity_overwrittenby_index */
ent->overwrittenby[pos] = overwrites;
} /* set_entity_overwrittenby */
-void remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites) {
- int i;
+void remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites) {
+ int i, n;
assert(is_Class_type(get_entity_owner(ent)));
- for (i = 0; i < (ARR_LEN (ent->overwrittenby)); i++)
+
+ n = ARR_LEN(ent->overwrittenby);
+ for (i = 0; i < n; ++i) {
if (ent->overwrittenby[i] == overwrites) {
- for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
+ for(; i < n - 1; ++i)
ent->overwrittenby[i] = ent->overwrittenby[i+1];
- ARR_SETLEN(ir_entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
+ ARR_SETLEN(ir_entity*, ent->overwrittenby, n - 1);
break;
}
+ }
} /* remove_entity_overwrittenby */
/* A link to store intermediate information */
return _get_entity_repr_class(ent);
} /* get_entity_repr_class */
+dbg_info *(get_entity_dbg_info)(const ir_entity *ent) {
+ return _get_entity_dbg_info(ent);
+} /* get_entity_dbg_info */
+
+void (set_entity_dbg_info)(ir_entity *ent, dbg_info *db) {
+ _set_entity_dbg_info(ent, db);
+} /* set_entity_dbg_info */
+
/* Initialize entity module. */
void firm_init_entity(void)
{