]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/bpf/bpf.opt
bpf: add -mcpu and related feature options
authorDavid Faust <david.faust@oracle.com>
Wed, 8 Sep 2021 17:26:15 +0000 (10:26 -0700)
committerDavid Faust <david.faust@oracle.com>
Fri, 10 Sep 2021 16:06:58 +0000 (09:06 -0700)
commit5b2ab1d35e41528ea844c6f5ee030f8e032f4c18
tree3db086072fed1cfcbd481e7c67fec2a661548741
parent4f0f696fea17cd91b184181abcf596df0e857304
bpf: add -mcpu and related feature options

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.

gcc/ChangeLog:
* config/bpf/bpf-opts.h (bpf_isa_version): New enum.
* config/bpf/bpf-protos.h (bpf_expand_cbranch): New.
* config/bpf/bpf.c (bpf_option_override): Handle -mcpu option.
(bpf_expand_cbranch): New function.
* config/bpf/bpf.md (AM mode iterator): Conditionalize support for SI
mode.
(zero_extendsidi2): Only use mov32 instruction if it is available.
(SIM mode iterator): Conditionalize support for SI mode.
(JM mode iterator): New.
(cbranchdi4): Update name, use new JM iterator. Use bpf_expand_cbranch.
(*branch_on_di): Update name, use new JM iterator.
* config/bpf/bpf.opt: (mjmpext): New option.
(malu32): Likewise.
(mjmp32): Likewise.
(mcpu): Likewise.
(bpf_isa): New enum.
gcc/config/bpf/bpf-opts.h
gcc/config/bpf/bpf-protos.h
gcc/config/bpf/bpf.c
gcc/config/bpf/bpf.md
gcc/config/bpf/bpf.opt