Page MenuHomeFreeBSD

Add fabs() to arm64 libc
ClosedPublic

Authored by emaste on May 13 2015, 1:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 24 2024, 10:08 PM
Unknown Object (File)
Feb 24 2024, 6:06 AM
Unknown Object (File)
Feb 16 2024, 5:43 PM
Unknown Object (File)
Feb 13 2024, 8:26 PM
Unknown Object (File)
Jan 26 2024, 12:02 PM
Unknown Object (File)
Jan 26 2024, 12:02 PM
Unknown Object (File)
Jan 26 2024, 11:58 AM
Unknown Object (File)
Jan 26 2024, 11:58 AM
Subscribers

Details

Summary

fabs comes from libc, not libm, for historical reasons. Add a trivial C implementation for arm64.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste retitled this revision from to Add fabs() to arm64 libc.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: andrew, imp.
andrew edited edge metadata.

We could use inline asm with the fabs instruction, but the compiler generates reasonable code:

0000000000000000 <fabs>:
   0:	1e602008 	fcmp	d0, #0.0
   4:	54000045 	b.pl	c <fabs+0xc>
   8:	1e614000 	fneg	d0, d0
   c:	d65f03c0 	ret
lib/libc/aarch64/gen/fabs.c
33 ↗(On Diff #5359)

There should be a black newline for style (but I don't agree with that part of style(9), and should x be compared with 0. (with a .) to make it a floating-point value.

This revision is now accepted and ready to land.May 13 2015, 2:06 PM

interesting, with Clang 3.7 I get:

fabs:
       0:       01 40 61 1e                                     fneg    d1, d0
       4:       08 20 60 1e                                     fcmp    d0, #0.0
       8:       20 4c 60 1e                                     fcsel   d0, d1, d0, mi
       c:       c0 03 5f d6                                     ret
emaste edited edge metadata.

Implement in assembly, as with some other archs

This revision now requires review to proceed.May 13 2015, 10:26 PM
lib/libc/aarch64/gen/fabs.S
31 ↗(On Diff #5368)

You also need a ret instruction.

emaste edited edge metadata.

Add missing ret

andrew edited edge metadata.
This revision is now accepted and ready to land.May 14 2015, 1:21 PM
This revision was automatically updated to reflect the committed changes.