x86jit: Implement BSwap16.

This commit is contained in:
Unknown W. Brackets 2023-09-17 13:24:59 -07:00
parent 580c9a634b
commit 3a705d9470

View File

@ -183,7 +183,20 @@ void X64JitBackend::CompIR_Bits(IRInst inst) {
break;
case IROp::BSwap16:
CompIR_Generic(inst);
regs_.Map(inst);
if (cpu_info.bBMI2) {
// Rotate to put it into the correct register, then swap.
if (inst.dest != inst.src1)
RORX(32, regs_.RX(inst.dest), regs_.R(inst.src1), 16);
else
ROR(32, regs_.R(inst.dest), Imm8(16));
BSWAP(32, regs_.RX(inst.dest));
} else {
if (inst.dest != inst.src1)
MOV(32, regs_.R(inst.dest), regs_.R(inst.src1));
BSWAP(32, regs_.RX(inst.dest));
ROR(32, regs_.R(inst.dest), Imm8(16));
}
break;
case IROp::Clz: