[bpf] add BPF disassembler
authorAlexei Starovoitov <alexei.starovoitov@gmail.com>
Sun, 20 Nov 2016 02:25:00 +0000 (02:25 +0000)
committerAlexei Starovoitov <alexei.starovoitov@gmail.com>
Sun, 20 Nov 2016 02:25:00 +0000 (02:25 +0000)
commite6ddac0def7c2e9c1c250e2eee06cf02d0cea65d
tree2ffe1495ce3cd17be4e0c4d83e57ba70ca2da4ad
parente5669cecde86ebf2be36dc33e1dd49e0c0ae0fa2
[bpf] add BPF disassembler

add BPF disassembler, so tools like llvm-objdump can be used:
$ llvm-objdump -d -no-show-raw-insn ./sockex1_kern.o

./sockex1_kern.o: file format ELF64-BPF

Disassembly of section socket1:
bpf_prog1:
       0: r6 = r1
       8: r0 = *(u8 *)skb[23]
      10: *(u32 *)(r10 - 4) = r0
      18: r1 = *(u32 *)(r6 + 4)
      20: if r1 != 4 goto 8
      28: r2 = r10
      30: r2 += -4

ld_imm64 (the only 16-byte insn) and special ld_abs/ld_ind instructions
had to be treated in a special way. The decoders for the rest of the insns
are automatically generated.

Add tests to cover new functionality.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 287477
llvm/lib/Target/BPF/BPFInstrInfo.td
llvm/lib/Target/BPF/CMakeLists.txt
llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp [new file with mode: 0644]
llvm/lib/Target/BPF/Disassembler/CMakeLists.txt [new file with mode: 0644]
llvm/lib/Target/BPF/Disassembler/LLVMBuild.txt [new file with mode: 0644]
llvm/lib/Target/BPF/LLVMBuild.txt
llvm/test/CodeGen/BPF/atomics.ll
llvm/test/CodeGen/BPF/objdump_atomics.ll [new file with mode: 0644]
llvm/test/CodeGen/BPF/objdump_intrinsics.ll [new file with mode: 0644]
llvm/test/CodeGen/BPF/objdump_trivial.ll [new file with mode: 0644]