New instructions have been added over time to the eBPF ISA, but previously there has been no good method to select which version to target in GCC.
This patch adds the following options to the BPF backend: -mcpu={v1, v2, v3} Select which version of the eBPF ISA to target. This enables or disables generation of certain instructions. The default is v3. -mjmpext Enable extra conditional branch instructions. Enabled for CPU v2 and above. -mjmp32 Enable 32-bit jump/branch instructions. Enabled for CPU v3 and above. -malu32 Enable 32-bit ALU instructions. Enabled for CPU v3 and above. Negative versions of -mjmpext, -mjmp32, and -malu32 options are also supported. David Faust (3): bpf: add -mcpu and related feature options bpf testsuite: add tests for new feature options doc: document BPF -mcpu and related options gcc/config/bpf/bpf-opts.h | 7 ++++ gcc/config/bpf/bpf-protos.h | 1 + gcc/config/bpf/bpf.c | 41 ++++++++++++++++++++ gcc/config/bpf/bpf.md | 44 +++++++++++---------- gcc/config/bpf/bpf.opt | 29 ++++++++++++++ gcc/doc/invoke.texi | 39 ++++++++++++++++++- gcc/testsuite/gcc.target/bpf/alu-1.c | 56 +++++++++++++++++++++++++++ gcc/testsuite/gcc.target/bpf/jmp-1.c | 57 ++++++++++++++++++++++++++++ 8 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gcc.target/bpf/alu-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/jmp-1.c -- 2.33.0