]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, riscv: Add encodings for compressed instructions
authorLuke Nelson <lukenels@cs.washington.edu>
Tue, 21 Jul 2020 02:52:39 +0000 (19:52 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 21 Jul 2020 20:26:25 +0000 (13:26 -0700)
commit9c1f5d940c730d0f140378ebbd6ea1e6ac32a873
tree840d9967eae77dca98a37655859a18c040d30069
parentfb7b0f5125fd287df3e55247429dc2711ef9b4b6
bpf, riscv: Add encodings for compressed instructions

This patch adds functions for encoding and emitting compressed riscv
(RVC) instructions to the BPF JIT.

Some regular riscv instructions can be compressed into an RVC instruction
if the instruction fields meet some requirements. For example, "add rd,
rs1, rs2" can be compressed into "c.add rd, rs2" when rd == rs1.

To make using RVC encodings simpler, this patch also adds helper
functions that selectively emit either a regular instruction or a
compressed instruction if possible.

For example, emit_add will produce a "c.add" if possible and regular
"add" otherwise.

Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200721025241.8077-3-luke.r.nels@gmail.com
arch/riscv/net/bpf_jit.h