Page MenuHomeFreeBSD

arm64: adjust bswap inline assembly constraints
Needs ReviewPublic

Authored by mhorne on Tue, Jan 12, 10:34 PM.

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 OK
Unit
No Unit 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.