code gen for C string literals

Ian Lance Taylor iant@google.com
Mon Feb 14 05:10:00 GMT 2011


kevin diggs <diggskevin38@gmail.com> writes:

> I would like to play with the code gcc generates for string literals.
> Can someone point me to the relevant files and/or to some
> documentation that describes the inner workings?

The preprocessor turns a string literal into a CPP_STRING token.  The
parser turns that into a STRING_CST node in GENERIC.  The RTL expander
stores the string constant into the constant pool and works with a
symbol pointing to the address.

This and the various string literal optimizations are scattered across
various files.  Search for CPP_STRING and STRING_CST to see the kinds of
things that gcc does.

Ian



More information about the Gcc-help mailing list