diff mbox

[3/4] sparc32: return destination pointer on return from memcpy

Message ID Pine.LNX.4.64.1110192258340.25694@oizys.tordivel.org
State RFC
Delegated to: David Miller
Headers show

Commit Message

Kjetil Oftedal Oct. 19, 2011, 9:11 p.m. UTC
On Wed, 19 Oct 2011, David Miller wrote:

> From: Konrad Eisele <konrad@gaisler.com>
> Date: Wed, 19 Oct 2011 10:33:25 +0200
> 
> > It seems to me that memcpy is tightly programmed. Is saving 2 lines of gdbstub.c
> > diff worth a memcpy rewrite?
> 
> You really can't find another register to save the initial %o0 value in?
> Have you even tried?

This might be considered a ugly hack. But what about using %y ? According 
to the V8 manual, %y might be destroyed across a procedure call, and none 
of the functions in memcpy.S use multiply/divide instructions. It is 
however not mentioned as a available register in the section dealing with 
leaf procedures. 

A quick test on a SS20 did not reveal any immediate side-effects, and 
the return value of memcpy is now the destination pointer.

---


--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Oct. 19, 2011, 10:12 p.m. UTC | #1
From: Kjetil Oftedal <oftedal@gmail.com>
Date: Wed, 19 Oct 2011 23:11:29 +0200 (CEST)

> On Wed, 19 Oct 2011, David Miller wrote:
> 
>> From: Konrad Eisele <konrad@gaisler.com>
>> Date: Wed, 19 Oct 2011 10:33:25 +0200
>> 
>> > It seems to me that memcpy is tightly programmed. Is saving 2 lines of gdbstub.c
>> > diff worth a memcpy rewrite?
>> 
>> You really can't find another register to save the initial %o0 value in?
>> Have you even tried?
> 
> This might be considered a ugly hack. But what about using %y ? According 
> to the V8 manual, %y might be destroyed across a procedure call, and none 
> of the functions in memcpy.S use multiply/divide instructions. It is 
> however not mentioned as a available register in the section dealing with 
> leaf procedures. 
> 
> A quick test on a SS20 did not reveal any immediate side-effects, and 
> the return value of memcpy is now the destination pointer.

Never mind, I'll work on this myself.  Trying to get you to implement
this properly is hopeless.  Writing to and reading from the %y
register is extremely expensive compared to a regular register.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Konrad Eisele Oct. 20, 2011, 6:59 a.m. UTC | #2
David Miller wrote:
> From: Kjetil Oftedal <oftedal@gmail.com>
> Date: Wed, 19 Oct 2011 23:11:29 +0200 (CEST)
> 
>> On Wed, 19 Oct 2011, David Miller wrote:
>>
>>> From: Konrad Eisele <konrad@gaisler.com>
>>> Date: Wed, 19 Oct 2011 10:33:25 +0200
>>>
>>>> It seems to me that memcpy is tightly programmed. Is saving 2 lines of gdbstub.c
>>>> diff worth a memcpy rewrite?
>>>
>>> You really can't find another register to save the initial %o0 value in?
>>> Have you even tried?
>>
>> This might be considered a ugly hack. But what about using %y ? According 
>> to the V8 manual, %y might be destroyed across a procedure call, and none 
>> of the functions in memcpy.S use multiply/divide instructions. It is 
>> however not mentioned as a available register in the section dealing with 
>> leaf procedures. 
>>
>> A quick test on a SS20 did not reveal any immediate side-effects, and 
>> the return value of memcpy is now the destination pointer.
> 
> Never mind, I'll work on this myself.  Trying to get you to implement
> this properly is hopeless.  Writing to and reading from the %y
> register is extremely expensive compared to a regular register.
> 
> 

Sorry to make you angry but, yes, I looked weather all registers are taken,
and yes, memcpy is very compact programmed. The %g6 patch was a mistake, sorry.
-- Konrad
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Oct. 20, 2011, 8:47 a.m. UTC | #3
From: Konrad Eisele <konrad@gaisler.com>
Date: Thu, 20 Oct 2011 08:59:15 +0200

> Sorry to make you angry but, yes, I looked weather all registers are taken,
> and yes, memcpy is very compact programmed.

It took me 10 minutes to code up a fix.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Konrad Eisele Oct. 20, 2011, 9:08 a.m. UTC | #4
David Miller wrote:
> From: Konrad Eisele <konrad@gaisler.com>
> Date: Thu, 20 Oct 2011 08:59:15 +0200
> 
>> Sorry to make you angry but, yes, I looked weather all registers are taken,
>> and yes, memcpy is very compact programmed.
> 
> It took me 10 minutes to code up a fix.
> 
> 

That speaks for you.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/sparc/lib/memcpy.S b/arch/sparc/lib/memcpy.S
index 34fe657..0327309 100644
--- a/arch/sparc/lib/memcpy.S
+++ b/arch/sparc/lib/memcpy.S
@@ -23,8 +23,8 @@  x:
  * One should use macros in asm/string.h for that purpose.
  * We return 0, so that bugs are more apparent.
  */
-#define SETUP_RETL
-#define RETL_INSN      clr     %o0
+#define SETUP_RETL     mov     %o0, %y
+#define RETL_INSN      mov     %y, %o0
 
 #else