+void
+remove_compound_ent_value(entity *ent, entity *value_ent) {
+ int i;
+ assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
+ for (i = 1; i < (ARR_LEN (ent->val_ents)); i++) {
+ if (ent->val_ents[i] == value_ent) {
+ for(; i < (ARR_LEN (ent->val_ents))-1; i++) {
+ ent->val_ents[i] = ent->val_ents[i+1];
+ ent->values[i] = ent->values[i+1];
+ }
+ ARR_SETLEN(entity*, ent->val_ents, ARR_LEN(ent->val_ents) - 1);
+ ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1);
+ break;
+ }
+ }
+}
+
+void
+set_array_entity_values(entity *ent, tarval **values, int num_vals) {
+ int i;
+ ir_graph *rem = current_ir_graph;
+ type *arrtp = get_entity_type(ent);
+ ir_node *val;
+
+ assert(is_array_type(arrtp));
+ assert(get_array_n_dimensions(arrtp) == 1);
+ /* One bound is sufficient, the nunmber of constant fields makes the
+ size. */
+ assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
+ assert(get_entity_variability(ent) != uninitialized);
+ current_ir_graph = get_const_code_irg();
+
+ for (i = 0; i < num_vals; i++) {
+ val = new_Const(get_tarval_mode (values[i]), values[i]);
+ add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
+ }
+ current_ir_graph = rem;
+}
+
+INLINE int