From f1e34551e4d6e259ab3bd0c9aba4fa1f0c448214 Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" Date: Mon, 24 Jul 2023 10:56:27 +0200 Subject: 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/doc/invoke.texi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/doc') diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index efd356e..a977a34 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -24707,10 +24707,14 @@ Enable 32-bit jump instructions. Enabled for CPU v3 and above. @item -malu32 Enable 32-bit ALU instructions. Enabled for CPU v3 and above. +@opindex mbswap +@item -mbswap +Enable byte swap instructions. Enabled for CPU v4 and above. + @opindex mcpu @item -mcpu=@var{version} This specifies which version of the eBPF ISA to target. Newer versions -may not be supported by all kernels. The default is @samp{v3}. +may not be supported by all kernels. The default is @samp{v4}. Supported values for @var{version} are: @@ -24728,6 +24732,11 @@ All features of v2, plus: @item 32-bit ALU operations, as in @option{-malu32} @end itemize +@item v4 +All features of v3, plus: +@itemize @minus +@item Byte swap instructions, as in @option{-mbswap} +@end itemize @end table @opindex mco-re -- cgit v1.1