MCPcopy Create free account
hub / github.com/F-Stack/f-stack / emit_ld_reg

Function emit_ld_reg

dpdk/lib/bpf/bpf_jit_x86.c:566–591  ·  view source on GitHub ↗

* emit mov (% ), % * note that for non 64-bit ops, higher bits have to be cleared. */

Source from the content-addressed store, hash-verified

564 * note that for non 64-bit ops, higher bits have to be cleared.
565 */
566static void
567emit_ld_reg(struct bpf_jit_state *st, uint32_t op, uint32_t sreg, uint32_t dreg,
568 int32_t ofs)
569{
570 uint32_t mods, opsz;
571 const uint8_t op32 = 0x8B;
572 const uint8_t op16[] = {0x0F, 0xB7};
573 const uint8_t op8[] = {0x0F, 0xB6};
574
575 emit_rex(st, op, dreg, sreg);
576
577 opsz = BPF_SIZE(op);
578 if (opsz == BPF_B)
579 emit_bytes(st, op8, sizeof(op8));
580 else if (opsz == BPF_H)
581 emit_bytes(st, op16, sizeof(op16));
582 else
583 emit_bytes(st, &op32, sizeof(op32));
584
585 mods = (imm_size(ofs) == 1) ? MOD_IDISP8 : MOD_IDISP32;
586
587 emit_modregrm(st, mods, dreg, sreg);
588 if (sreg == RSP || sreg == R12)
589 emit_sib(st, SIB_SCALE_1, sreg, sreg);
590 emit_imm(st, ofs, imm_size(ofs));
591}
592
593/*
594 * emit one of:

Callers 4

emit_ldmb_fast_pathFunction · 0.85
emit_ldmb_finFunction · 0.85
emit_epilogFunction · 0.85
emitFunction · 0.85

Calls 6

emit_rexFunction · 0.85
emit_bytesFunction · 0.85
imm_sizeFunction · 0.85
emit_modregrmFunction · 0.85
emit_sibFunction · 0.85
emit_immFunction · 0.85

Tested by

no test coverage detected