{
compound_graph_path *res;
- assert(is_compound_type(tp));
+ assert(is_compound_type(tp) || is_Array_type(tp));
assert(length > 0);
res = xmalloc(sizeof(*res) + (length-1) * sizeof(res->list[0]));
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);
+ ARR_SETLEN(compound_graph_path*, ent->attr.cmpd_attr.val_paths, n - 1);
+ ARR_SETLEN(ir_node*, ent->attr.cmpd_attr.values, n - 1);
break;
}
}
void set_array_entity_values(ir_entity *ent, tarval **values, int num_vals)
{
int i;
- ir_graph *rem = current_ir_graph;
- ir_type *arrtp = get_entity_type(ent);
- ir_node *val;
- ir_type *elttp = get_array_element_type(arrtp);
+ ir_type *arrtp = get_entity_type(ent);
+ ir_node *val;
+ ir_graph *irg = get_const_code_irg();
assert(is_Array_type(arrtp));
assert(get_array_n_dimensions(arrtp) == 1);
/* One bound is sufficient, the number of constant fields makes the
size. */
assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
- current_ir_graph = get_const_code_irg();
for (i = 0; i < num_vals; i++) {
- val = new_Const_type(values[i], elttp);
+ val = new_r_Const(irg, values[i]);
add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
set_compound_graph_path_array_index(get_compound_ent_value_path(ent, i), 0, i);
}
- current_ir_graph = rem;
}
unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos)
int idx;
assert(size > 0);
- if(size % align > 0) {
+ if (size % align > 0) {
size += align - (size % align);
}
idx = get_compound_graph_path_array_index(path, i);
path_len = get_compound_graph_path_length(path);
last_node = get_compound_graph_path_node(path, path_len - 1);
- if(last_node == NULL)
+ if (last_node == NULL)
return 0;
- return get_entity_offset_bits_remainder(last_node);
+ return get_entity_offset_bits_remainder(last_node);
}
int get_compound_ent_n_values(const ir_entity *ent)