[PATCH] D133464: [WIP][BPF] Add sext load instructions

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 09:22:48 PDT 2022


yonghong-song added a comment.

I hacked the kernel x64 jit part, with the following jit for sext load, it seems working okay from jit perspective.

  +/* LDX: dst_reg = *(s8*)(src_reg + off) */
  +static void emit_ldx_sext(u8 **pprog, u32 size, u32 dst_reg, u32 src_reg, int off)
  +{
  +       u8 *prog = *pprog;
  +
  +       switch (size) {
  +       case BPF_B:
  +               /* Emit 'movsx rax, byte ptr [rax + off]' */
  +               EMIT3(add_2mod(0x48, src_reg, dst_reg), 0x0F, 0xBE);
  +               break;
  +       case BPF_H:
  +               /* Emit 'movsx rax, word ptr [rax + off]' */
  +               EMIT3(add_2mod(0x48, src_reg, dst_reg), 0x0F, 0xBF);
  +               break;
  +       case BPF_W:
  +               /* Emit 'movsx rax, dword ptr [rax+0x14]' */
  +               EMIT2(add_2mod(0x48, src_reg, dst_reg), 0x63);
  +               break;
  +       }
  +       emit_insn_suffix(&prog, src_reg, dst_reg, off);
  +       *pprog = prog;
  +}

My hacking is incomplete so I only showed the partial x86 jit in the above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133464/new/

https://reviews.llvm.org/D133464



More information about the llvm-commits mailing list