This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ ping: reduce size of cp_token
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 15 Mar 2008 05:17:18 -0400
- Subject: Re: C++ ping: reduce size of cp_token
- References: <m3k5k4zy9v.fsf@fleche.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Mar 14, 2008 at 05:22:36PM -0600, Tom Tromey wrote:
> Ping. This patch is pretty simple and reduces the size of cp_token.
>
> http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00023.html
What size increase does it cause on parser.o's .text section?
There are hundreds of ->type accesses in parser.c, and that doesn't
count inlined cp_lexer_next_token_is{,_not} etc. If it is 8 bit, it
can use char access instruction, when it is 7 bit, it needs to additionally
mask it.
What about instead reusing one of the ->flags bits (from what I can see,
parser.c only cares about 3 bits from that or so):
egrep '(\.|->)flags' parser.c
= c_lex_with_flags (&token->u.value, &token->location, &token->flags,
|| (token->flags & PREV_WHITE))
&& next_token->flags & DIGRAPH
&& !(next_token_2->flags & PREV_WHITE))
if (token->type != CPP_NUMBER || !(token->flags & PURE_ZERO))
if (token->type == CPP_OPEN_SQUARE && token->flags & DIGRAPH)
if (token2->type == CPP_COLON && !(token2->flags & PREV_WHITE))
So if after c_lex_with_flags call you do token->flags &= ~AMBIGUOUS_P;
and transform ->ambiguous_p into ->flags & AMBIGUOUS_P, it might
have smaller code size impact and perhaps be even faster.
Jakub