From: David Faust Date: Thu, 16 Apr 2020 07:52:57 +0000 (+0200) Subject: cpu,gas,opcodes: support for eBPF JMP32 instruction class X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c54a9b56696e584c2b8c7146caac337c063f5516;p=binutils-gdb.git cpu,gas,opcodes: support for eBPF JMP32 instruction class Add support for the JMP32 class of eBPF instructions. cpu/ChangeLog * bpf.cpu (define-cond-jump-insn): Renamed from djci. (dcji) New version with support for JMP32 gas/ChangeLog * testsuite/gas/bpf/bpf.exp: Run jump32 tests. * testsuite/gas/bpf/jump32.s: New file. * testsuite/gas/bpf/jump32.d: Likewise. opcodes/ChangeLog * bpf-desc.c: Regenerate. * bpf-desc.h: Likewise. * bpf-opc.c: Regenerate. * bpf-opc.h: Likewise. --- diff --git a/cpu/ChangeLog b/cpu/ChangeLog index f67c869a868..2324006fb27 100644 --- a/cpu/ChangeLog +++ b/cpu/ChangeLog @@ -1,3 +1,8 @@ +2020-02-16 David Faust + + * bpf.cpu (define-cond-jump-insn): Renamed from djci. + (dcji) New version with support for JMP32 + 2020-02-03 Alan Modra * m32c.cpu (f-dsp-64-s16): Mask before shifting signed value. diff --git a/cpu/bpf.cpu b/cpu/bpf.cpu index 1378bda94d4..89a27fe128d 100644 --- a/cpu/bpf.cpu +++ b/cpu/bpf.cpu @@ -222,7 +222,7 @@ (define-normal-insn-enum insn-op-class "eBPF instruction class" (all-isas) OP_CLASS_ f-op-class ((LD #b000) (LDX #b001) (ST #b010) (STX #b011) - (ALU #b100) (JMP #b101) (ALU64 #b111))) + (ALU #b100) (JMP #b101) (JMP32 #b110) (ALU64 #b111))) ;; For load/store instructions, the 8-bit code field is subdivided in: ;; @@ -583,25 +583,30 @@ ;; registers. Therefore, we need to define several variants in both ;; ISAs: ;; -;; J{eq,gt,ge,lt,le,set,ne,sgt,sge,slt,sle}{i,r}le for the +;; J{eq,gt,ge,lt,le,set,ne,sgt,sge,slt,sle}[32]{i,r}le for the ;; little-endian ISA. -;; J{eq,gt,ge,lt,le,set,ne.sgt,sge,slt,sle}{i,r}be for the +;; J{eq,gt,ge,lt,le,set,ne.sgt,sge,slt,sle}[32]{i,r}be for the ;; big-endian ISA. -(define-pmacro (dcji x-cond x-op-code x-endian) +(define-pmacro (define-cond-jump-insn x-cond x-suffix x-op-class x-op-code x-endian) (begin - (dni (.sym j x-cond i x-endian) - (.str j x-cond "i") + (dni (.sym j x-cond x-suffix i x-endian) + (.str j x-cond x-suffix " i") ((ISA (.sym ebpf x-endian))) - (.str "j" x-cond " $dst" x-endian ",$imm32,$disp16") + (.str "j" x-cond x-suffix " $dst" x-endian ",$imm32,$disp16") (+ imm32 disp16 ((.sym f-src x-endian) 0) (.sym dst x-endian) - OP_CLASS_JMP OP_SRC_K (.sym OP_CODE_ x-op-code)) () ()) - (dni (.sym j x-cond r x-endian) - (.str j x-cond "r") + x-op-class OP_SRC_K (.sym OP_CODE_ x-op-code)) () ()) + (dni (.sym j x-cond x-suffix r x-endian) + (.str j x-cond x-suffix " r") ((ISA (.sym ebpf x-endian))) - (.str "j" x-cond " $dst" x-endian ",$src" x-endian ",$disp16") + (.str "j" x-cond x-suffix " $dst" x-endian ",$src" x-endian ",$disp16") (+ (f-imm32 0) disp16 (.sym src x-endian) (.sym dst x-endian) - OP_CLASS_JMP OP_SRC_X (.sym OP_CODE_ x-op-code)) () ()))) + x-op-class OP_SRC_X (.sym OP_CODE_ x-op-code)) () ()))) + +(define-pmacro (dcji x-cond x-op-code x-endian) + (begin + (define-cond-jump-insn x-cond "" OP_CLASS_JMP x-op-code x-endian) + (define-cond-jump-insn x-cond "32" OP_CLASS_JMP32 x-op-code x-endian))) (define-pmacro (define-condjump-insns x-endian) (begin diff --git a/gas/ChangeLog b/gas/ChangeLog index ecc3b983bdb..09ad599c5c9 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2020-02-16 David Faust + + * testsuite/gas/bpf/bpf.exp: Run jump32 tests. + * testsuite/gas/bpf/jump32.s: New file. + * testsuite/gas/bpf/jump32.d: Likewise. + 2020-04-08 H.J. Lu * doc/c-i386.texi: Correct -mlfence-before-indirect-branch= diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp index 1c111e12923..6225d0b3589 100644 --- a/gas/testsuite/gas/bpf/bpf.exp +++ b/gas/testsuite/gas/bpf/bpf.exp @@ -23,6 +23,7 @@ if {[istarget bpf*-*-*]} { run_dump_test alu32 run_dump_test mem run_dump_test jump + run_dump_test jump32 run_dump_test call run_dump_test exit run_dump_test atomic diff --git a/gas/testsuite/gas/bpf/jump32.d b/gas/testsuite/gas/bpf/jump32.d new file mode 100644 index 00000000000..4f5ae2c5aa3 --- /dev/null +++ b/gas/testsuite/gas/bpf/jump32.d @@ -0,0 +1,31 @@ +#as: --EL +#objdump: -dr +#name: eBPF JUMP32 instructions + +.*: +file format .*bpf.* + +Disassembly of section .text: + +0+ <.text>: + 0: 05 00 03 00 00 00 00 00 ja 3 + 8: 0f 11 00 00 00 00 00 00 add %r1,%r1 + 10: 16 03 01 00 03 00 00 00 jeq32 %r3,3,1 + 18: 1e 43 00 00 00 00 00 00 jeq32 %r3,%r4,0 + 20: 36 03 fd ff 03 00 00 00 jge32 %r3,3,-3 + 28: 3e 43 fc ff 00 00 00 00 jge32 %r3,%r4,-4 + 30: a6 03 01 00 03 00 00 00 jlt32 %r3,3,1 + 38: ae 43 00 00 00 00 00 00 jlt32 %r3,%r4,0 + 40: b6 03 01 00 03 00 00 00 jle32 %r3,3,1 + 48: be 43 00 00 00 00 00 00 jle32 %r3,%r4,0 + 50: 46 03 01 00 03 00 00 00 jset32 %r3,3,1 + 58: 4e 43 00 00 00 00 00 00 jset32 %r3,%r4,0 + 60: 56 03 01 00 03 00 00 00 jne32 %r3,3,1 + 68: 5e 43 00 00 00 00 00 00 jne32 %r3,%r4,0 + 70: 66 03 01 00 03 00 00 00 jsgt32 %r3,3,1 + 78: 6e 43 00 00 00 00 00 00 jsgt32 %r3,%r4,0 + 80: 76 03 01 00 03 00 00 00 jsge32 %r3,3,1 + 88: 7e 43 00 00 00 00 00 00 jsge32 %r3,%r4,0 + 90: c6 03 01 00 03 00 00 00 jslt32 %r3,3,1 + 98: ce 43 00 00 00 00 00 00 jslt32 %r3,%r4,0 + a0: d6 03 01 00 03 00 00 00 jsle32 %r3,3,1 + a8: de 43 00 00 00 00 00 00 jsle32 %r3,%r4,0 diff --git a/gas/testsuite/gas/bpf/jump32.s b/gas/testsuite/gas/bpf/jump32.s new file mode 100644 index 00000000000..ffcf4bafcdc --- /dev/null +++ b/gas/testsuite/gas/bpf/jump32.s @@ -0,0 +1,25 @@ +# Tests for the eBPF JUMP32 instructions + .text + ja 2f + add %r1,%r1 +1: jeq32 %r3,3,2f + jeq32 %r3,%r4,2f +2: jge32 %r3,3,1b + jge32 %r3,%r4,1b +1: jlt32 %r3,3,1f + jlt32 %r3,%r4,1f +1: jle32 %r3,3,1f + jle32 %r3,%r4,1f +1: jset32 %r3,3,1f + jset32 %r3,%r4,1f +1: jne32 %r3,3,1f + jne32 %r3,%r4,1f +1: jsgt32 %r3,3,1f + jsgt32 %r3,%r4,1f +1: jsge32 %r3,3,1f + jsge32 %r3,%r4,1f +1: jslt32 %r3,3,1f + jslt32 %r3,%r4,1f +1: jsle32 %r3,3,1f + jsle32 %r3,%r4,1f +1: diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 8c121f1e6a3..1877338f550 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2020-02-16 David Faust + + * bpf-desc.c: Regenerate. + * bpf-desc.h: Likewise. + * bpf-opc.c: Regenerate. + * bpf-opc.h: Likewise. + 2020-04-07 Lili Cui * i386-dis.c (enum): Add PREFIX_0F01_REG_5_MOD_3_RM_1, diff --git a/opcodes/bpf-desc.c b/opcodes/bpf-desc.c index 953d7676f80..113f5457b5f 100644 --- a/opcodes/bpf-desc.c +++ b/opcodes/bpf-desc.c @@ -1014,6 +1014,16 @@ static const CGEN_IBASE bpf_cgen_insn_table[MAX_INSNS] = BPF_INSN_JEQRLE, "jeqrle", "jeq", 64, { 0, { { { (1<