From 3a705d9470e153f80bf93df7dfd2b478bade966b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 17 Sep 2023 13:24:59 -0700 Subject: [PATCH] x86jit: Implement BSwap16. --- Core/MIPS/x86/X64IRCompALU.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/MIPS/x86/X64IRCompALU.cpp b/Core/MIPS/x86/X64IRCompALU.cpp index 8842d02c2c..66fe205b20 100644 --- a/Core/MIPS/x86/X64IRCompALU.cpp +++ b/Core/MIPS/x86/X64IRCompALU.cpp @@ -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: