Page MenuHomeFreeBSD

arm64: adjust bswap inline assembly constraints
AbandonedPublic

Authored by mhorne on Jan 12 2021, 10:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 8 2024, 12:06 AM
Unknown Object (File)
Dec 22 2023, 10:47 PM
Unknown Object (File)
Oct 19 2023, 3:20 AM
Unknown Object (File)
Oct 12 2023, 5:16 AM
Unknown Object (File)
Aug 16 2023, 7:45 AM
Unknown Object (File)
Aug 1 2023, 8:00 PM
Unknown Object (File)
Mar 30 2023, 8:48 PM
Unknown Object (File)
Nov 28 2022, 9:52 AM
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.