This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ ping: reduce size of cp_token

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.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]