attribute data structure rewrite
Geoffrey Keating
geoffk@apple.com
Fri Sep 24 08:36:00 GMT 2004
On 23/09/2004, at 5:47 PM, Gabriel Dos Reis wrote:
> Geoffrey Keating <geoffk@apple.com> writes:
>
> | As a precondition for other compile speed improvements, I've been
> | rewriting the way that GCC represents attributes. The result is a
> | medium-size patch that touches every language and many targets (a
> | surprising number of targets don't define any special attributes at
> | all).
> |
> | The basic principle is that DECL_ATTRIBUTES and TREE_ATTRIBUTES now
> | point to an attribute_list:
> |
> | /* A structure representing 'attributes' on a DECL or TYPE node.
> | Each attribute has a NAME (an IDENTIFIER_NODE) and possibly a
> | VALUE. */
> | struct one_attribute GTY(())
> | {
> | tree name;
> | tree value;
> | };
> |
> | /* A counted list of attributes. */
> | struct attribute_list_s GTY(())
> | {
> | attribute_count n_attributes;
> | /* There are 16 bits free here. */
> | struct one_attribute GTY((length ("%h.n_attributes"))) attribs[1];
> | };
> |
> | This has many benefits, mostly flowing from the fact that it's not a
> | TREE_LIST any more.
> |
> | 1. Do we think this would be acceptable for stage 3, or should I make
> | a branch?
>
>
> I would argue that such a change should be accepted, at this phase of
> stage 3; now. As:
> (1) it addresses compile-time/memory regression;
> (2) it is no less interesting no less useful that the various cleanup
> we've been having, in particular in the C++ front-end.
>
>
> I would even take a further step and ask an official position about
> how we how attributes to play with language rules.
>
>
> Currently, the compiler fails on any of the following fails,
> complaining about non-"integral constant expression"-ness, which is
> pure nonense.
>
> const int N = 4;
> struct S {
> enum { M = 4 };
> float x __attibute__((__aligned__(N)));
> float x __attibute__((__aligned__(M)));
> };
>
> template<typename T, int N>
> struct buffer {
> typedef char U[sizeof(T)];
> U data __attribute__((__aligned__(N)));
> };
>
> They should be accepted.
That's a very good point. I noticed from looking at the C front-end
that an attribute can have as a 'value' any of:
1. NULL
2. an IDENTIFIER
3. an expression
From that, I suspect that what's happening here is that 'N' is an
identifier, so that rule matches in preference to treating 'N' as an
expression and evaluating it.
I would really like to avoid case (2), or at least make sure that you
can tell which of (2) or (3) any particular attribute should have.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2408 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20040924/ee7e13eb/attachment.p7s>
More information about the Gcc
mailing list