This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ColdFire 26/63] Rework the call and jump handling
On Wed, 2007-01-10 at 11:28 +0000, Richard Sandiford wrote:
> This patch reworks the call and jump code. There are four main aims:
>
> - To expose the GOT load in m68k_output_pic_call. This has two benefits:
> it allows the load to be CSEd, and it removes the need for this code
> in m68k_save_reg:
>
> if (flag_pic && regno == PIC_OFFSET_TABLE_REGNUM)
> {
> ...
> if (!current_function_is_leaf && TARGET_ID_SHARED_LIBRARY)
> return true;
> }
>
> (which a later patch will remove).
>
> - To allow bra.l and bsr.l to be used for PIC calls on ISA B ColdFire
> targets.
>
> - To fix the sequences generated when long branches are not available.
> The current code reads:
>
> else if (optimize_size || TARGET_ID_SHARED_LIBRARY)
> out = "move.l %0@GOT(%%a5), %%a1\n\tjsr (%%a1)";
> else
> out = "lea %0-.-8,%%a1\n\tjsr 0(%%pc,%%a1)";
>
> but the final case isn't always safe. One of %a0 and %a1 is the
> incoming return address pointer and the other is the static chain
> register (which register is which depends on the configuration).
>
> (Actually, this isn't true for *-elf on mainline, but it ought
> to be. A later patch deals with this.)
>
> - To fix the potential problems with the SYMBOL_REF_FLAG handling.
> At the moment, the port sets SYMBOL_REF_FLAG if a symbol is used
> as a call target, and it will then be accepted as a legitimate PIC
> constant. However, the symbol could in principle be used in
> non-call situations too, and we don't want it to be accepted as
> an absolute address. This is admittedly more of a theoretical concern.
>
> The code for calls is very similar to the code for jumps -- it's
> basically just a bsr/jsr vs. bra/jmp choice -- so it would be nice to
> have only one copy of the logic. The patch therefore stores the call
> sequences for symbolic addresses in two new global strings --
> m68k_symbolic_call and m68k_symbolic_jump -- and sets them both up in
> OVERRIDE_OPTIONS. These variables are null if no symbolic calls are
> allowed; the address will then be loaded from the GOT.
>
> The patch avoids the use of SYMBOL_REF_FLAG by defining a new
> 'W' constraint for constant call addresses.
>
> The patch also removes the only use of the %o operand prefix, which
> TARGET_PCREL used to output illegitimate MEMs. It therefore removes the
> associated print_operand code too. (I don't think any user asms would
> use %o because asms will never see illegitimate MEMs.)
>
> Richard
>
>
> gcc/
> * config/m68k/m68k-protos.h (m68k_output_pic_call): Delete.
> (output_call, m68k_legitimize_call_address): Declare.
> * config/m68k/m68k.h (EXTRA_CONSTRAINT): Remove unnecessary
> parenthesees. Add support for a 'W' constraint.
> (LEGITIMATE_PIC_OPERAND_P): Remove SYMBOL_REF_FLAG handling.
> (PRINT_OPERAND_PUNCT_VALID_P): Remove comment about 'o'.
> (m68k_symbolic_call, m68k_symbolic_jump): Declare.
> * config/m68k/m68k.c (m68k_symbolic_call, m68k_symbolic_jump): New
> variables.
> (override_options): Initialize them. Do not set flag_no_function_cse
> for TARGET_ID_SHARED_LIBRARY.
> (m68k_output_pic_call): Delete.
> (m68k_legitimize_call_address): New function.
> (print_operand): Remove the %o prefix. Handle the %p prefix.
> (output_call): New function.
> (m68k_output_mi_thunk): Use m68k_symbolic_jump. Always load the
> target address from the GOT if symbolic jumps are not allowed.
> * config/m68k/m68k.md (call, general_operand): Do not set
> SYMBOL_REF_FLAG. Use m68k_legitimize_call_address instead.
> Merge separate flag_pic and !flag_pic define_insns into...
> (*call, *call_value): ...these new patterns. Match the address
> rather than the containing MEM and require it to be a call_operand.
> Use output_call to generate the asm template.
> * config/m68k/predicates.md (const_call_operand): New predicate.
> (call_operand): Likewise.
OK.
I *like* killing the SYMBOL_REF_FLAG stuff. I wasn't ever very happy
with it. The use of SYMBOL_REF_FLAG might have also played a role in
the need for special casing PIC operands in cmpsi.
Jeff