Small data sections and GCC constant pool

Paul Webster pmw@uk.research.att.com
Fri Jun 16 10:04:00 GMT 2000


I'm trying to add a new feature to my GCC back-end, which is to support small
data sections. I've got it working for variables and strings, but am having a
bit of difficulty with values in the constants pool.

I've setup ENCODE_SECTION_INFO so that if VAR_DECL and any *_CST type (such as
STRING_CST) are marked using the SYMBOL_REF_FLAG when they are small enough to
be put in the small data section. I also use SELECT_SECTION to decide whether
to put data into the small sections according to their size.

For the constant pool, I use SELECT_RTX_SECTION to potentially put constants
into the small data section. However, for string constants, ENCODE_SECTION_INFO
is called, allowing me to mark references to point to the small data section.
For other values in the constant pool (larger integers, real numbers etc), GCC
does not appear to call ENCODE_SECTION_INFO, so I cannot set SYMBOL_REF_FLAG.

What is the easiest way, given a SYM_REF, to work out that it is referring to
something in the constants pool? At the moment, I am doing a string compare on
the name, as all the constant pool labels start "LC". It strikes me there must
be a better way!! The "find_pool_constant" routine looks ideal, except if it
does not find a constant for the particular SYM_REF it aborts rather than set
an error condition. I could just change "varasm.c" to add my own variation that
returns NULL when it doesn't find the SYM_REF, but I want to avoid modifying 
the main GCC tree if I can avoid it. 

Thank you in advance for any suggestions anyone can make!

   Paul Webster


==============================================================================
                          AT&T Laboratories Cambridge
------------------------------------------------------------------------------
    Dr. Paul Webster, 24a Trumpington Street, Cambridge, CB2 1QA, England.
    Tel: +44 (0)1223 343 218                       Fax: +44 (0)1223 313542
==============================================================================


More information about the Gcc-help mailing list