CMP / TEST: share the bin-op encoding but only write flag context.
| 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(); |
no test coverage detected