return ent->val_paths[pos];
}
+static int equal_paths(compound_graph_path *path1, int *visited_indicees, compound_graph_path *path2) {
+ int i;
+ int len1 = get_compound_graph_path_length(path1);
+ int len2 = get_compound_graph_path_length(path2);
+
+ if (len2 > len1) return false;
+
+ for (i = 0; i < len1; i++) {
+ entity *node1 = get_compound_graph_path_node(path1, i);
+ entity *node2 = get_compound_graph_path_node(path2, i);
+ if (node1 != node2) return false;
+ type *tp = get_entity_owner(node1);
+ if (is_Array_type(tp)) {
+ /* Compute the index of this node. */
+ assert(get_array_n_dimensions(tp) == 1 && "multidim not implemented");
+ long low = get_array_lower_bound_int(tp, 0);
+ if (low+visited_indicees[i] < get_compound_graph_path_array_index(path2, i)) {
+ visited_indicees[i]++;
+ return false;
+ } else {
+ assert(low+visited_indicees[i] == get_compound_graph_path_array_index(path2, i));
+ }
+ }
+ }
+ return true;
+}
+
+/* Returns the position of a value with the given path.
+ * The path must contain array indicees for all array element entities. */
+int get_compound_ent_pos_by_path(entity *ent, compound_graph_path *path) {
+ int i, n_paths = get_compound_ent_n_values(ent);
+ int *visited_indicees = (int *)xcalloc(get_compound_graph_path_length(path), sizeof(int));
+ for (i = 0; i < n_paths; i ++) {
+ if (equal_paths(get_compound_ent_value_path(ent, i), visited_indicees, path))
+ return i;
+ }
+ assert(0 && "path not found");
+ return -1;
+}
+
+/* Returns a constant value given the access path.
+ * The path must contain array indicees for all array element entities. */
+ir_node *get_compound_ent_value_by_path(entity *ent, compound_graph_path *path) {
+ return get_compound_ent_value(ent, get_compound_ent_pos_by_path(ent, path));
+}
+
+
void
remove_compound_ent_value(entity *ent, entity *value_ent) {
int i;
* array bounds must be representable as ints.
*
* (If the bounds are not representable as ints we have to represent
- * the indices as firm nodes. But the still we must be able to
+ * the indices as firm nodes. But still we must be able to
* evaluate the index against the upper bound.)
*/
void compute_compound_ent_array_indicees(entity *ent) {
set_compound_graph_path_array_index (path, j, get_next_index(node));
}
}
-
}
/** resize: double the allocated buffer */
int get_compound_graph_path_array_index(compound_graph_path *gr, int pos);
void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
-/** Checks wether the path up to pos is correct. If the path contains a NULL,
+/** Checks whether the path up to pos is correct. If the path contains a NULL,
* assumes the path is not complete and returns 'true'. */
int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
* Asserts if the entity has variability_uninitialized.
* */
int get_compound_ent_n_values(entity *ent);
+/** Returns a constant value given the position. */
ir_node *get_compound_ent_value(entity *ent, int pos);
+/** Returns the access path for value at position pos. */
compound_graph_path *get_compound_ent_value_path(entity *ent, int pos);
+/** Returns the position of a value with the given path.
+ * The path must contain array indicees for all array element entities. */
+int get_compound_ent_pos_by_path(entity *ent, compound_graph_path *path);
+/** Returns a constant value given the access path.
+ * The path must contain array indicees for all array element entities. */
+ir_node *get_compound_ent_value_by_path(entity *ent, compound_graph_path *path);
/** Removes all constant entries where the path ends at value_ent. Does not
free the memory of the paths. (The same path might be used for several
*/
static int check_entity(entity *ent) {
int rem_vpi;
+ type *tp = get_entity_type(ent);
+ type *owner = get_entity_owner(ent);
current_ir_graph = get_const_code_irg();
if (constants_on_wrong_irg(ent)) {
}
}
+ /* Entities in global type are not dynamic or automatic allocated. */
+ if (owner == get_glob_type()) {
+ assert(get_entity_allocation(ent) != allocation_dynamic &&
+ get_entity_allocation(ent) != allocation_automatic);
+ }
+
+ if (get_entity_variability(ent) != variability_uninitialized) {
+ if (is_atomic_type(tp)) {
+ ir_node *val = get_atomic_ent_value(ent);
+ if (val)
+ assert(get_irn_mode(val) == get_type_mode(tp) &&
+ "Mode of constant in entity must match type.");
+ }
+ }
+
return no_error;
}