This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SH2A: "RTV/N Rn" implementation


On Tue, Jul 17, 2007 at 01:12:19PM +0530, Naveen H.S. wrote:
> Hi,
> 
> RTV/N instruction is one of the new instructions added in the SH2A
> target.
> 
> Description : RTV/N instruction performs a return from a subroutine 
> procedure after a transfer from specified general register Rn to R0.
> That is, after the Rn value is stored in R0, the PC is restored from 
> PR, and processing is resumed from the address indicated by the PC.
> 
> RTV/N		Rn = Rn--->R0 + RTS/N
> So RTV/N instruction can be used as an optimized return instruction 
> in case of the functions having the return type as INTEGER_TYPE. This
> instruction moves the return argument of the function from register 
> Rn--->R0 along with RETURN. So there is no need to exclusively 
> transfer the RETURN value of the function to RETURN_REG (R0) before
> RETURN.
[snip]
> Any help in implementing this instruction would be highly appreciated.

   Presumably the main problem here is that combine runs before the epilogue
is emitted, leaving no chance for combine to generate RTV/N?

   My first shot at this would be to emit RTV/N in a dummy form as part of
the epilogue and leave the usual Rn--->R0 setup as it is, producing

(set (reg R0) (reg Rn))
...
(parallel [
	(set (reg R0) (reg R0))
	(return)
])

and hope that the rnreg pass changes this to

(set (reg R0) (reg Rn))
...
(parallel [
	(set (reg R0) (reg Rn))
	(return)
])

at which point the first instruction becomes dead and we should get just

(parallel [
	(set (reg R0) (reg Rn))
	(return)
])

which is the RTV/N instruction.

   Actually, this is something the register allocator should get right, but
that doesn't seem to happen any time soon.

-- 
Rask Ingemann Lambertsen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]