This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Getting knowledge of common declarations at the time they are declared in the source
- From: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Fri, 9 May 2003 19:29:14 +0200
- Subject: Getting knowledge of common declarations at the time they are declared in the source
Hi everybody,
My backend needs to know informations from the tree of every variable that is
declared to output them correctly. Therefore, for every variable I build an
entry in a special table that contains everything I need when the variable is
declared. For local variables and arguments this is easily done during the
function prologue callback. Unfortunately, it doesn't work that well for
common variables. Let's say I have the following program:
int randomvar;
void foo(void) {
/* foo uses randomvar somewhere */
}
The resulting assembler file will look like:
foo:
# Code for function foo
#declaration of randomvar
.common randomvar
Therefore ASM_OUTPUT_COMMON for randomvar will be called *after* the code for
foo is generated, which means after references to randomvar are outputted.
Because of this behavior, I don't have any (known) way to build my custom
informations about randomvar before it is used, since I use the
ASM_OUTPUT_COMMON hook to build them. So my backend cannot perform correctly.
After an afternoon dedicated to finding another macro/hook that would allow me
to declare randomvar at the same position as it appears in the source, I'm
still lost, and completely stuck because of this little issue. Does anybody
know of a way to workaround this with existing macros and hooks?
I know that commons are outputted at the end for good reasons (probably
because they are not definitive declarations) but if there is no other
solution, maybe an optionnal macro to let the backend know of a partial
declaration would be useful. Would a patch implementing such a macro make
sense for you and would it be accepted if I submit it?
Thanks for any comments or advice,
Alex.