-/* Compute the array indices in compound graph paths of initialized entities.
- *
- * All arrays must have fixed lower and upper bounds. One array can
- * have an open bound. If there are several open bounds, we do
- * nothing. There must be initializer elements for all array
- * elements. Uses the link field in the array element entities. The
- * 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 still we must be able to
- * evaluate the index against the upper bound.)
- */
-void compute_compound_ent_array_indicees(entity *ent) {
- type *tp = get_entity_type(ent);
- int i, n_vals;
- entity *unknown_bound_entity = NULL;
-
- if (!is_compound_type(tp) ||
- (ent->variability == variability_uninitialized)) return ;
-
- n_vals = get_compound_ent_n_values(ent);
- if (n_vals == 0) return;
-
- /* We can not compute the indexes if there is more than one array
- with an unknown bound. For this remember the first entity that
- represents such an array. It could be ent. */
- if (is_Array_type(tp)) {
- int dim = 0;
-
- assert(get_array_n_dimensions(tp) == 1 && "other not implemented");
- if (!has_array_lower_bound(tp, dim) || !has_array_upper_bound(tp, dim))
- unknown_bound_entity = ent;
- }
-
- /* Initialize the entity links to lower bound -1 and test all path elements
- for known bounds. */
- for (i = 0; i < n_vals; ++i) {
- compound_graph_path *path = get_compound_ent_value_path(ent, i);
- int j, path_len = get_compound_graph_path_length(path);
- for (j = 0; j < path_len; ++j) {
- entity *node = get_compound_graph_path_node(path, j);
- type *elem_tp = get_entity_type(node);
-
- if (is_Array_type(elem_tp)) {
- int dim = 0;
- assert(get_array_n_dimensions(elem_tp) == 1 && "other not implemented");
- if (!has_array_lower_bound(elem_tp, dim) || !has_array_upper_bound(elem_tp, dim)) {
- if (!unknown_bound_entity) unknown_bound_entity = node;
- if (node != unknown_bound_entity) return;
- }
-
- init_index(elem_tp);
- }
- }
- }
-
- /* Finally compute the indexes ... */
- for (i = 0; i < n_vals; ++i) {
- compound_graph_path *path = get_compound_ent_value_path(ent, i);
- int j, path_len = get_compound_graph_path_length(path);
- for (j = 0; j < path_len; ++j) {
- entity *node = get_compound_graph_path_node(path, j);
- type *owner_tp = get_entity_owner(node);
- if (is_Array_type(owner_tp))
- set_compound_graph_path_array_index (path, j, get_next_index(node));
- }
- }
-}
+void
+remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent) {
+ int i, n;
+ assert(is_compound_entity(ent) && (ent->variability != variability_uninitialized));
+
+ 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 < 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, n - 1);
+ ARR_SETLEN(ir_node*, ent->attr.cmpd_attr.values, n - 1);
+ break;
+ }
+ }
+} /* remove_compound_ent_value */