| 407 | } |
| 408 | |
| 409 | static void |
| 410 | emit_shift(struct bpf_jit_state *st, uint32_t op, uint32_t dreg) |
| 411 | { |
| 412 | uint8_t mod; |
| 413 | uint32_t bop, opx; |
| 414 | |
| 415 | static const uint8_t ops[] = {0xC1, 0xD3}; |
| 416 | static const uint8_t mods[] = { |
| 417 | [GET_BPF_OP(BPF_LSH)] = 4, |
| 418 | [GET_BPF_OP(BPF_RSH)] = 5, |
| 419 | [GET_BPF_OP(EBPF_ARSH)] = 7, |
| 420 | }; |
| 421 | |
| 422 | bop = GET_BPF_OP(op); |
| 423 | mod = mods[bop]; |
| 424 | opx = (BPF_SRC(op) == BPF_X); |
| 425 | |
| 426 | emit_rex(st, op, 0, dreg); |
| 427 | emit_bytes(st, &ops[opx], sizeof(ops[opx])); |
| 428 | emit_modregrm(st, MOD_DIRECT, mod, dreg); |
| 429 | } |
| 430 | |
| 431 | /* |
| 432 | * emit one of: |
no test coverage detected