[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPH4I2W+zvhK93U/@biznet-home.integral.gnuweeb.org>
Date: Fri, 1 Sep 2023 21:41:39 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: David Laight <David.Laight@...lab.com>
Cc: Willy Tarreau <w@....eu>,
Thomas Weißschuh <linux@...ssschuh.net>,
Nicholas Rosenberg <inori@...x.org>,
Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
Michael William Jonathan <moe@...weeb.org>,
GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH v1 0/5] nolibc x86-64 string functions
On Fri, Sep 01, 2023 at 02:23:28PM +0000, David Laight wrote:
> From: Ammar Faizi
> > Sent: 01 September 2023 14:06
...
> > __asm__ (
> > ".section .text.nolibc_memmove\n"
> > ".weak memmove\n"
> > "memmove:\n"
> > " movq %rdx, %rcx\n"
> > " movq %rdi, %rdx\n"
> > " movq %rdi, %rax\n"
>
> You seem to have confused yourself about whether you are using %eax or %edx.
What do you mean? They're all 64-bit pointers.
What I know is that the %rdx will be clobbered by "subq %rsi, %rdx"
below and the %rax should be return value. That's why I copy the %rdi
twice. memmove() returns the dst pointer. Did I miss something?
> > " subq %rsi, %rdx\n"
> > " cmpq %rcx, %rdx\n"
> > " jnb .Lforward_copy\n"
>
> I think I'd fall through to the forwards copy
> and not worry about replicating the 'reps movsb' and 'ret'.
> IIRC 'cld' can be slow as well.
Alright, I will avoid cld for the forward copy.
> > " leaq -1(%rdi, %rcx, 1), %rdi\n"
> > " leaq -1(%rsi, %rcx, 1), %rsi\n"
> > " std\n"
> > ".Lforward_copy:\n"
> > " rep movsb\n"
> > " cld\n"
> > " ret\n"
> > );
--
Ammar Faizi
Powered by blists - more mailing lists