OSDN Git Service

bpf: add variants of -mcpu=# and support for additional jmp insns
authorYonghong Song <yhs@fb.com>
Wed, 23 Aug 2017 04:25:57 +0000 (04:25 +0000)
committerYonghong Song <yhs@fb.com>
Wed, 23 Aug 2017 04:25:57 +0000 (04:25 +0000)
commitd7276a40d87b89aed89978dec6457a5b8b3a0db5
tree70518ba26891cc9670f184d1a3b8316e256bf220
parent212ebf24928280a40864fd96cc724e49b435d511
bpf: add variants of -mcpu=# and support for additional jmp insns

-mcpu=# will support:
  . generic: the default insn set
  . v1: insn set version 1, the same as generic
  . v2: insn set version 2, version 1 + additional jmp insns
  . probe: the compiler will probe the underlying kernel to
           decide proper version of insn set.

We did not not use -mcpu=native since llc/llvm will interpret -mcpu=native
as the underlying hardware architecture regardless of -march value.

Currently, only x86_64 supports -mcpu=probe. Other architecture will
silently revert to "generic".

Also added -mcpu=help to print available cpu parameters.
llvm will print out the information only if there are at least one
cpu and at least one feature. Add an unused dummy feature to
enable the printout.

Examples for usage:
$ llc -march=bpf -mcpu=v1 -filetype=asm t.ll
$ llc -march=bpf -mcpu=v2 -filetype=asm t.ll
$ llc -march=bpf -mcpu=generic -filetype=asm t.ll
$ llc -march=bpf -mcpu=probe -filetype=asm t.ll
$ llc -march=bpf -mcpu=v3 -filetype=asm t.ll
'v3' is not a recognized processor for this target (ignoring processor)
...
$ llc -march=bpf -mcpu=help -filetype=asm t.ll
Available CPUs for this target:

  generic - Select the generic processor.
  probe   - Select the probe processor.
  v1      - Select the v1 processor.
  v2      - Select the v2 processor.

Available features for this target:

  dummy - unused feature.

Use +feature to enable a feature, or -feature to disable it.
For example, llc -mcpu=mycpu -mattr=+feature1,-feature2
...

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311522 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/Host.h
lib/Support/Host.cpp
lib/Target/BPF/BPF.td
lib/Target/BPF/BPFISelLowering.cpp
lib/Target/BPF/BPFISelLowering.h
lib/Target/BPF/BPFInstrInfo.td
lib/Target/BPF/BPFSubtarget.cpp
lib/Target/BPF/BPFSubtarget.h
test/CodeGen/BPF/setcc.ll