------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-12-02 
18:14 -------
Nathan asked me to write up some details about what I intend to do.

There are some tremendous inefficiences in our representation for initializers
for an array.  In particular, we use a CONSTRUCTOR whose CONSTRUCTOR_ELTS is a
TREE_LIST.  Each node in the TREE_LIST has a TREE_PURPOSE with the equivalent of
a C99 "designator"; the TREE_VALUE is the value to be stored at that location. 
For a huge array, we waste a ton of space on the designators and the TREE_LIST
nodes.

What we should do instead is store the first designator, and then an array of
initializers.  For most arrays initializers, that will be sufficient.  For an
array that actually uses designated initializers, we'll have several such
blocks, chained together.  If we're using existing tree nodes, a TREE_VEC would
do; use the TREE_TYPE as the designator, the TREE_CHAIN to chain the initializer
blocks together, and the vector elements as the initializers themselves.

Making this change will require large, but mostly mechanical, changes to the
middle and back ends.  You could provide a converter function to go from the old
representation to the new, probably, so as to avoid having to change all of the
front ends at first.

Second, in the C++ front end, we process the huge initializer several times.  We
build up an initial representation in the parser.  Then, we run it through
reshape_array -- which creates a bunch of new nodes, rather than reusing any
existing nodes.  I'm not sure if digest_init then creates a bunch more nodes. 
Reusing the nodes from earlier phases here would be good.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at codesourcery dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16681

Reply via email to