X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Fcompound_path.c;h=81b41702a0919ef05d40680265309e506f995b67;hb=2158510961e84fb11e9195c200335f2314e49055;hp=50e014291a31dd0b702cb1eb9ed8f4caa5d347bf;hpb=2bc2dd4bd4f64982e9c5d2f1ea70d63d0eb10044;p=libfirm diff --git a/ir/tr/compound_path.c b/ir/tr/compound_path.c index 50e014291..81b41702a 100644 --- a/ir/tr/compound_path.c +++ b/ir/tr/compound_path.c @@ -129,16 +129,21 @@ ir_type *get_compound_graph_path_type(const compound_graph_path *gr) return gr->tp; } -void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, - compound_graph_path *path) +static void allocate_values(ir_entity *ent) { - assert(is_compound_entity(ent)); - assert(is_compound_graph_path(path)); if (ent->attr.cmpd_attr.values == NULL) { ent->attr.cmpd_attr.values = NEW_ARR_F(ir_node*, 0); assert(ent->attr.cmpd_attr.val_paths == NULL); ent->attr.cmpd_attr.val_paths = NEW_ARR_F(compound_graph_path*, 0); } +} + +void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, + compound_graph_path *path) +{ + assert(is_compound_entity(ent)); + assert(is_compound_graph_path(path)); + allocate_values(ent); ARR_APP1(ir_node *, ent->attr.cmpd_attr.values, val); ARR_APP1(compound_graph_path *, ent->attr.cmpd_attr.val_paths, path); } @@ -248,6 +253,7 @@ void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member) compound_graph_path *path; ir_type *owner_tp = get_entity_owner(member); assert(is_compound_entity(ent)); + allocate_values(ent); path = new_compound_graph_path(get_entity_type(ent), 1); path->list[0].node = member; if (is_Array_type(owner_tp)) { @@ -330,7 +336,7 @@ 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); @@ -360,7 +366,7 @@ unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, 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); @@ -370,6 +376,7 @@ int get_compound_ent_n_values(const ir_entity *ent) { assert(ent->initializer == NULL); assert(is_compound_entity(ent)); + allocate_values((ir_entity*) ent); return ARR_LEN(ent->attr.cmpd_attr.values); }