Page MenuHomeFreeBSD

arm64: adjust bswap inline assembly constraints
AbandonedPublic

Authored by mhorne on Jan 12 2021, 10:34 PM.
Tags
None
Referenced Files
F102213412: D28126.diff
Sat, Nov 9, 1:20 AM
Unknown Object (File)
Thu, Nov 7, 11:30 PM
Unknown Object (File)
Oct 4 2024, 12:19 PM
Unknown Object (File)
Oct 2 2024, 4:49 AM
Unknown Object (File)
Oct 2 2024, 1:22 AM
Unknown Object (File)
Oct 1 2024, 11:00 PM
Unknown Object (File)
Sep 30 2024, 1:29 AM
Unknown Object (File)
Sep 27 2024, 1:04 PM
Subscribers

Details

Reviewers
andrew
mmel
manu
Summary

The rev instruction is a simple register/register operation. Drop the
read+write constraint on the input and the earlyclobber constraint on
the output.

While here, use a consistent the name for the input, choosing _x as is
done on x86 and riscv.

For reference:
https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers
https://developer.arm.com/docs/ddi0596/h/base-instructions-alphabetic-order/rev-reverse-bytes

PR: 236920
Submitted by: John F. Carr <jfc@mit.edu>

Test Plan

A simple Godbolt test of this pattern shows a reduction of 1 instruction.
Kernel .text decreases by 2126 bytes as a result of this patch.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36154
Build 33043: arc lint + arc unit

Event Timeline

This (like everything else) should use compiler instrinsics by default, see __builtin_bswap32 for example.

In D28126#628610, @mjg wrote:

This (like everything else) should use compiler instrinsics by default, see __builtin_bswap32 for example.

I don't disagree, but that is a larger change, since we would want it for all platforms. I can see if it is not too much effort.

Do you think we could drop the __builtin_constant_p() type optimizations if we moved to the bswap builtins? See x86/endian.h and this file below the #ifdef __OPTIMIZE__.

Well this should be made MI, but in the meantime, if you are touching any of this to begin with, you can make at least arm use the builtins.

Any checks for constant known at compilation time and whatnot should be removed -- modulo bugs in the compiler, the resulting code will be the same or better. With builtins all the way the tests for constants don't add anything the compiler does not already know.