This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: matching a call followed by a jump
- From: law at redhat dot com
- To: "Jan Hoogerbrugge" <hoogerbrugge at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 20 Jan 2004 08:06:57 -0700
- Subject: Re: matching a call followed by a jump
- Reply-to: law at redhat dot com
In message <BAY9-F24yWe057joKKp0005ee4d@hotmail.com>, "Jan Hoogerbrugge" writes
:
>Hi,
>
>My target architecture implements calls as follows
>
> move L123 -> ra // copy return address to return address
>register
> jump(foo)
>L123:
>
>If a call is followed by a jump, to let's say L456,
>then the following code is generated:
>
> move L123 -> ra
> jump(foo)
>L123:
> jump(L456)
>
>Obviously, one would like to generate the following
>code:
>
> move L456 -> ra
> jump(foo)
>
>How to do this? Currently I use the following code
>to match function calls to functions that do not
>return a result:
Most targets have done this by modeling it in the delay slot filling code.
Though they differ slightly from your architecture.
For those targets (Sparc, PA, maybe mips too) the call implicitly sets up
the return register and we modify the contents of the return register in
the delay slot of the call. ie
call <blah>
nop /* Delay slot */
jmp <label>
nop /* Delay slot */
[ ... other code ... ]
<label>
Would get turned into
call <blah>
add <label>-.,ra,ra /* Delay slot */
[ ... other code ... ]
<label>
You might be able to do something similar.
Alternately, you might be able to use a peephole2 to detect and
optimize this situation.
jeff