no need to set the entity for array entries in compound_graph_path
authorMatthias Braun <matze@braunis.de>
Tue, 20 Nov 2007 21:23:01 +0000 (21:23 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 20 Nov 2007 21:23:01 +0000 (21:23 +0000)
[r16815]

ir/be/begnuas.c
ir/tr/entity.c

index c2b87bf..86ac7bc 100644 (file)
@@ -528,10 +528,8 @@ static void dump_compound_init(be_gas_decl_env_t *env, obstack_t *obst,
        for (i = 0; i < n; ++i) {
                int offset = get_compound_ent_value_offset_bytes(ent, i);
                int bits_remainder = get_compound_ent_value_offset_bit_remainder(ent, i);
-               const compound_graph_path *path = get_compound_ent_value_path(ent, i);
-               int path_len = get_compound_graph_path_length(path);
-               ir_entity *last_ent = get_compound_graph_path_node(path, path_len - 1);
-               int value_len = get_type_size_bits(get_entity_type(last_ent));
+               ir_node *value = get_compound_ent_value(ent, i);
+               int      value_len = get_mode_size_bits(get_irn_mode(value));
 
                offset += (value_len + bits_remainder + 7) >> 3;
 
@@ -548,13 +546,10 @@ static void dump_compound_init(be_gas_decl_env_t *env, obstack_t *obst,
 
        /* collect the values and store them at the offsets */
        for (i = 0; i < n; ++i) {
-               const compound_graph_path *path = get_compound_ent_value_path(ent, i);
-               int path_len = get_compound_graph_path_length(path);
                int offset = get_compound_ent_value_offset_bytes(ent, i);
                int offset_bits = get_compound_ent_value_offset_bit_remainder(ent, i);
-               ir_node *value = get_compound_ent_value(ent, i);
-               ir_entity *last_ent = get_compound_graph_path_node(path, path_len - 1);
-               int value_len = get_type_size_bits(get_entity_type(last_ent));
+               ir_node   *value = get_compound_ent_value(ent, i);
+               int    value_len = get_mode_size_bits(get_irn_mode(value));
                assert(offset >= 0);
                assert(offset_bits >= 0);
 
index 13abc27..e10348a 100644 (file)
@@ -994,18 +994,16 @@ int get_compound_ent_value_offset_bytes(ir_entity *ent, int pos) {
 
        assert(get_type_state(get_entity_type(ent)) == layout_fixed);
 
-       path = get_compound_ent_value_path(ent, pos);
+       path     = get_compound_ent_value_path(ent, pos);
        path_len = get_compound_graph_path_length(path);
-       curr_tp = path->tp;
+       curr_tp  = path->tp;
 
        for (i = 0; i < path_len; ++i) {
-               ir_entity *node = get_compound_graph_path_node(path, i);
-               ir_type *node_tp = get_entity_type(node);
-
                if (is_Array_type(curr_tp)) {
-                       int size  = get_type_size_bits(node_tp);
-                       int align = get_type_alignment_bits(node_tp);
-                       int idx;
+                       ir_type *elem_type = get_array_element_type(curr_tp);
+                       int      size      = get_type_size_bits(elem_type);
+                       int      align     = get_type_alignment_bits(elem_type);
+                       int      idx;
 
                        assert(size > 0);
                        if(size % align > 0) {
@@ -1016,10 +1014,12 @@ int get_compound_ent_value_offset_bytes(ir_entity *ent, int pos) {
                        idx = get_compound_graph_path_array_index(path, i);
                        assert(idx >= 0);
                        offset += size * idx;
+                       curr_tp = elem_type;
                } else {
+                       ir_entity *node = get_compound_graph_path_node(path, i);
                        offset += get_entity_offset(node);
+                       curr_tp = get_entity_type(node);
                }
-               curr_tp = node_tp;
        }
 
        return offset;
@@ -1033,10 +1033,13 @@ int get_compound_ent_value_offset_bit_remainder(ir_entity *ent, int pos) {
 
        assert(get_type_state(get_entity_type(ent)) == layout_fixed);
 
-       path = get_compound_ent_value_path(ent, pos);
-       path_len = get_compound_graph_path_length(path);
+       path      = get_compound_ent_value_path(ent, pos);
+       path_len  = get_compound_graph_path_length(path);
        last_node = get_compound_graph_path_node(path, path_len - 1);
 
+       if(last_node == NULL)
+               return 0;
+
        return get_entity_offset_bits_remainder(last_node);
 }  /* get_compound_ent_value_offset_bit_remainder */