[PATCH] D144829: [WIP][BPF] Add a few new insns under cpu=v4
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 26 09:51:18 PST 2023
yonghong-song created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
In [1], a few new insns are proposed to exgend BPF ISA to
. fixing the limitation of existing insn (e.g., 16bit jmp offset)
. adding new insns which may improve code quality (sext_ld, sext_mov, st)
. feature complete (sdiv, smod)
. better user experience (bswap)
This patch implemented insn encoding for
. sign-extended load
. sign-extended mov
. sdiv/smod
. bswap insns
. unconditional jump with 32bit offset
The encoding for sign-extended load/mov, sdiv/smod are followed by
proposal in [1] except a couple of changes like sign-extended load
does not really have alu32 mode, and sign-extend mov only supports
`dst_reg<-(sign extend)src_reg` format. I will update the proposal
in bpf mailing list later.
The new bswap insns are generated under cpu=v4 for __builtin_bswap.
For cpu=v3 or earlier, for __builtin_bswap, be or le insns are generated
which is not intuitive for the user.
To support 32-bit branch offset, a 32-bit ja (JMPL) insn is implemented.
For conditional branch which is beyond 16-bit offset, llvm will do
some transformation 'cond_jmp' -> 'cond_jmp + jmpl' to simulate 32bit
conditional jmp. See BPFMIPeephole.cpp for details. The algorithm is
hueristic based. I have tested bpf selftest pyperf600 with unroll account
600 which can indeed generate 32-bit jump insn, e.g.,
14: 06 00 00 00 27 ef 00 00 gotol +0xef27 <LBB0_78200+0xffffffffffd9fd88>
In the above, need to investigate why llvm-objdump prints out
'<LBB0_78200+0xffffffffffd9fd88>', probably due to my introduction
of BPF specific fixup kinds.
Eduard is working on to add 'st' insn to cpu=v4.
This patch is in WIP stage since I need to:
(1). investigate the above '<LBB0_78200+0xffffffffffd9fd88>' print,
(2). add verifier support for the above insns.
References:
[1] https://lore.kernel.org/bpf/01515302-c37d-2ee5-c950-2f556a4caad0@meta.com/
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144829
Files:
clang/lib/Basic/Targets/BPF.cpp
clang/lib/Basic/Targets/BPF.h
llvm/lib/Target/BPF/BPF.td
llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
llvm/lib/Target/BPF/BPFISelLowering.cpp
llvm/lib/Target/BPF/BPFInstrFormats.td
llvm/lib/Target/BPF/BPFInstrInfo.td
llvm/lib/Target/BPF/BPFMIPeephole.cpp
llvm/lib/Target/BPF/BPFSubtarget.cpp
llvm/lib/Target/BPF/BPFSubtarget.h
llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h
llvm/test/CodeGen/BPF/bswap.ll
llvm/test/CodeGen/BPF/sdiv_smod.ll
llvm/test/CodeGen/BPF/sext_ld.ll
llvm/test/CodeGen/BPF/sext_mov.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144829.500597.patch
Type: text/x-patch
Size: 47721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230226/ff9bdf57/attachment-0001.bin>
More information about the llvm-commits
mailing list