This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Save memory with ppc elf shared libraries.
- To: Geoff Keating <geoffk at ozemail dot com dot au>
- Subject: Re: Save memory with ppc elf shared libraries.
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Thu, 10 Dec 1998 01:06:56 -0700
- cc: egcs-patches at cygnus dot com
- Reply-To: law at cygnus dot com
In message <199812091112.WAA25840@geoffk.wattle.id.au>you write:
> Now, in this case, most symbolic addresses are already in memory. But
> addresses of the form
>
> (const (plus (sym_ref "foo") 10))
>
> are not put in the GOT.
>
> Can reload ever try to put this in memory? Even if it can load
> (sym_ref "foo") from memory and perform the addition in the same
> register it performed the load from?
Yes. See the calls to force_const_mem in reload.c. Been there, done that.
> [Of course, reload can't ever try the same thing if the second operand
> isn't a const_int, because the linker can't handle it.]
Right.
> LEGITIMIZE_ADDRESS seems to always do such computations in registers.
But we're talking about a completely different part of the compiler.
LEGITIMIZE_ADDRESS is a totally target dependent hunk of code. The code
which forces constants into memory is generic code in reload.
> Perhaps, though, it might be best to change rs6000_select_rtx_section
> to be on the safe side. Something like:
>
> if (flag_pic == 1 &&
> (GET_CODE (x) == SYMBOL_REF
> || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
> && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF)
> || GET_CODE (x) == LABEL_REF))
> data_section ();
> else if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x))
> toc_section ();
> else
> const_section ();
>
> But I can't test this, because I have no examples of a case when it
> might ever be used...
They can be difficult to trigger since they involve reload.
> There really should be a macro to mean "includes symbol reference",
> that is the condition above.
Yes. Though it also needs to check for LABEL_REFs in precisely the same
way you check for SYMBOL_REFs. I would support putting the code into a
generic place in the compiler since more than just the ppc can use it.
My recommendation is to have a function or macro which returns nonzero if
the given rtx contains a SYMBOL_REF or LABEL_REF. Then change
SELECT_RTX_SECTION to use the data section if flag_pic is nonzero (flag_pic
can have 3 values 0, 1 and 2. 1 is used for -fpic 2 is used for -fPIC.
Combine that with your previous patch and I think we've got the right batch
of changes.
jeff