SH2A: "RTV/N Rn" implementation

Naveen H.S. naveen.hs@kpitcummins.com
Tue Jul 17 07:45:00 GMT 2007


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.

We implemented the direct RTL for RTV/N instruction and found that 
the RTL is not recognized by the GNUSH compiler. It was because the
return value is moved from the register Rn--->R0 before the epilogue
sequence and RETURN is performed after the epilogue sequence.

As the observation goes, all the architectures as incorporated in GCC
transfers the RETURN value of a function to RETURN_REG (Rn--->R0) 
before the epilogue sequence followed by RETURN. We investigated and 
found that the register transfer Rn--->R0 is done in the top level 
file "gcc/stmt.c". The function where this transfer is done is
expand_value_return (rtx val). RTV/N instruction requires this 
transfer to be suppressed and using the register Rn in RETURN pattern
as "RTV/N	Rn".

Implementation : 

We tried to get the register (Rn) transferred to RETURN_REG(R0) from 
the function expand_value_return (rtx val). This register Rn needs to
be used as the operand in "RTV/N  Rn" instruction.
However register (Rn) in the function expand_value_return (rtx val) 
is a PSEUDO REGISTER instead of a HARD REGISTER. "RTV/N 	Rn" 
expects the register Rn to be a hard register.

Any help in implementing this instruction would be highly appreciated.

Regards,
Naveen.H.S.
KPIT Cummins Infosystems Ltd,
Pune (INDIA) 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	
Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C	
and M32C Series. The following site also offers free technical support	
to its users. Visit http://www.kpitgnutools.com for details. 	
Latest versions of KPIT GNU tools were released on June 1, 2007.	
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	



More information about the Gcc mailing list