MCPcopy Create free account
hub / github.com/D7EAD/mkPIVM / enc_cmp_test

Function enc_cmp_test

src/codec.cpp:1853–1880  ·  view source on GitHub ↗

CMP / TEST: share the bin-op encoding but only write flag context.

Source from the content-addressed store, hash-verified

1851
1852 // CMP / TEST: share the bin-op encoding but only write flag context.
1853 static void enc_cmp_test(BytecodeBuilder& o, const IRInsn& i, const VMConfig& v, const Codec* self) {
1854 o.u8(v.opcode_for(self->family()));
1855 if (std::holds_alternative<VirReg>(i.ops[0])) {
1856 o.u8(0);
1857 enc_slot(o, v, get_op<VirReg>(i, 0));
1858 }
1859 else {
1860 o.u8(1);
1861 const auto& im = get_op<Imm>(i, 0);
1862 enc_imm_n(o, im.value, 8);
1863 }
1864
1865 if (std::holds_alternative<VirReg>(i.ops[1])) {
1866 o.u8(0);
1867 enc_slot(o, v, get_op<VirReg>(i, 1));
1868 }
1869 else if (std::holds_alternative<Imm>(i.ops[1])) {
1870 o.u8(1);
1871 const auto& im = get_op<Imm>(i, 1);
1872 enc_imm_n(o, im.value, 8);
1873 }
1874 else {
1875 o.u8(2);
1876 enc_mem(o, v, get_op<Mem>(i, 1));
1877 }
1878
1879 o.u8(static_cast<std::uint8_t>(width_bytes(i.width)));
1880 }
1881
1882 static void emit_cmp_test_handler(X64Emitter& e, const VMConfig& vm, bool is_test) {
1883 const auto& r = vm.dispatcher_regs();

Callers 1

encodeMethod · 0.85

Calls 7

enc_slotFunction · 0.85
enc_imm_nFunction · 0.85
enc_memFunction · 0.85
width_bytesFunction · 0.85
opcode_forMethod · 0.80
u8Method · 0.45
familyMethod · 0.45

Tested by

no test coverage detected