[PATCH v2 3/3] Add ffsl(), ffsll(), fls(), flsl(), flsll()
Kito Cheng
kito.cheng@gmail.com
Thu Jul 27 06:53:00 GMT 2017
Hi Sebastian:
I only hit this bug on RV64, you can try -march=rv64ima -mabi=lp64
with riscv32-elf-gcc if you don't want to rebuild.
On Thu, Jul 27, 2017 at 2:48 PM, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
> On 27/07/17 03:40, Kito Cheng wrote:
>
>> Hi
>>
>> I am testing with RISC-V with newlib/trunk and just hang on ffs,
>> after investigate, I saw gcc just generate a ffs call in ffs for riscv64
>> and I guess riscv64 is not the only target will hit this bug,
>> so maybe we can revert the part of this patch, at least for ffs.c?
>>
>> Code gen by riscv64-elf-gcc:
>> .file "ffs.c"
>> .option nopic
>> .globl ffs
>> .text
>> .align 1
>> .globl ffs
>> .type ffs, @function
>> ffs:
>> add sp,sp,-16
>> sd ra,8(sp)
>> call ffs
>> ld ra,8(sp)
>> sext.w a0,a0
>> add sp,sp,16
>> jr ra
>> .size ffs, .-ffs
>> .ident "GCC: (GNU) 8.0.0 20170509 (experimental)"
>
>
> I get:
>
> /build/git-build/b-gcc-git-riscv32-rtems4.12/./gcc/xgcc
> -B/build/git-build/b-gcc-git-riscv32-rtems4.12/./gcc/ -S -o - -O2 ffs.c
> -fno-builtin
> .file "ffs.c"
> .option nopic
> .globl __ffssi2
> .text
> .align 1
> .globl ffs
> .type ffs, @function
> ffs:
> add sp,sp,-16
> sw ra,12(sp)
> call __ffssi2
> lw ra,12(sp)
> add sp,sp,16
> jr ra
> .size ffs, .-ffs
> .ident "GCC: (GNU) 8.0.0 20170727 (experimental)
>
> Why does your GCC emit the call to ffs()?
>
>
>>
>> On Wed, Jul 5, 2017 at 7:26 PM, Corinna Vinschen <vinschen@redhat.com>
>> wrote:
>>>
>>> On Jul 5 10:54, Sebastian Huber wrote:
>>>>
>>>> Use compiler builtin for ffs(). Remove duplicate implementation from
>>>> Cygwin.
>>>>
>>>> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
>>>> ---
>>>> newlib/libc/misc/ffs.c | 14 ++-------
>>>> newlib/libc/string/Makefile.am | 5 ++++
>>>> newlib/libc/string/Makefile.in | 64
>>>> +++++++++++++++++++++++++++++++++---------
>>>> newlib/libc/string/ffsl.c | 34 ++++++++++++++++++++++
>>>> newlib/libc/string/ffsll.c | 34 ++++++++++++++++++++++
>>>> newlib/libc/string/fls.c | 38 +++++++++++++++++++++++++
>>>> newlib/libc/string/flsl.c | 38 +++++++++++++++++++++++++
>>>> newlib/libc/string/flsll.c | 38 +++++++++++++++++++++++++
>>>> winsup/cygwin/syscalls.cc | 22 ---------------
>>>> 9 files changed, 240 insertions(+), 47 deletions(-)
>>>> create mode 100644 newlib/libc/string/ffsl.c
>>>> create mode 100644 newlib/libc/string/ffsll.c
>>>> create mode 100644 newlib/libc/string/fls.c
>>>> create mode 100644 newlib/libc/string/flsl.c
>>>> create mode 100644 newlib/libc/string/flsll.c
>>>
>>> Patchset looks good, please push.
>>>
>>> For Cygwin we also need to add the new fls* entry points to
>>> common.din and to the docs. I'll do that later, when you
>>> pushed your patch.
>>>
>>>
>>> Thanks,
>>> Corinna
>>>
>>> --
>>> Corinna Vinschen
>>> Cygwin Maintainer
>>> Red Hat
>
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail : sebastian.huber@embedded-brains.de
> PGP : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
More information about the Newlib
mailing list