]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: make use of the bswap{16,32,64} V4 BPF instruction
authorJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 24 Jul 2023 08:56:27 +0000 (10:56 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 24 Jul 2023 09:01:35 +0000 (11:01 +0200)
commitf1e34551e4d6e259ab3bd0c9aba4fa1f0c448214
treef2e5953e8ea087dc908bf5d45f0b7b72f8acebd2
parent8390a2af1397ba86ea2cf80d58007b8b69a9a6eb
bpf: make use of the bswap{16,32,64} V4 BPF instruction

This patch makes the BPF backend to use the new V4 bswap{16,32,64}
instructions in order to implement the __builtin_bswap{16,32,64}
built-ins.  It also adds support for -mcpu=v4 and -m[no]bswap
command-line options.  Tests and doc updates are includes.

Tested in bpf-unknown-none.

gcc/ChangeLog

PR target/110786
* config/bpf/bpf.opt (mcpu): Add ISA_V4 and make it the default.
(mbswap): New option.
* config/bpf/bpf-opts.h (enum bpf_isa_version): New value ISA_V4.
* config/bpf/bpf.cc (bpf_option_override): Set bpf_has_bswap.
* config/bpf/bpf.md: Use bswap instructions if available for
bswap* insn, and fix constraint.
* doc/invoke.texi (eBPF Options): Document -mcpu=v4 and -mbswap.

gcc/testsuite/ChangeLog

PR target/110786
* gcc.target/bpf/bswap-1.c: Pass -mcpu=v3 to build test.
* gcc.target/bpf/bswap-2.c: New test.
gcc/config/bpf/bpf-opts.h
gcc/config/bpf/bpf.cc
gcc/config/bpf/bpf.md
gcc/config/bpf/bpf.opt
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/bpf/bswap-1.c
gcc/testsuite/gcc.target/bpf/bswap-2.c [new file with mode: 0644]