Page MenuHomePhabricator

[libc] Add aarch64 flavors of floor, round, sqrt and trunc.
ClosedPublic

Authored by sivachandra on Feb 3 2021, 10:55 PM.

Details

Summary

Only single and double precision flavors have been added.

Diff Detail

Event Timeline

sivachandra created this revision.Feb 3 2021, 10:55 PM
sivachandra requested review of this revision.Feb 3 2021, 10:55 PM
sdesmalen added inline comments.
libc/src/math/aarch64/floor.cpp
16

Hi @sivachandra sorry for the drive-by comment on your patch, I just happened notice the use of ldr/str here. Is there a specific reason for that? I think this can simply use the register values instead, e.g:

double result;
__asm__ __volatile__("frintm %d0, %d1\n"
                     : "=w"(result) : "w"(x) : );
return result;

That way, it will just create a frintm d0, d0 instruction directly.

Use %d and %s modifiers instead of the registers directly.

sivachandra added inline comments.Feb 4 2021, 9:45 PM
libc/src/math/aarch64/floor.cpp
16

Thanks a lot for you comment. I wasn't aware that one could use %d and %s modifiers. I have applied your suggestion everywhere.

lntue accepted this revision.Feb 4 2021, 10:15 PM
This revision is now accepted and ready to land.Feb 4 2021, 10:15 PM
sdesmalen accepted this revision.Feb 5 2021, 3:56 AM

Thanks for the changes. I noticed another patch (maybe there are more?) that could probably also be updated now, e.g. ceil/ceilf from D95850.

Thanks for the changes. I noticed another patch (maybe there are more?) that could probably also be updated now, e.g. ceil/ceilf from D95850.

I have updated ceil and ceilf also in this change.