From 16101049f3511b5ccb3b24dd383f8d8e498b0270 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 16 Nov 2022 16:10:39 -0500 Subject: [PATCH] Fix EXTR (flipped rgister order) --- .../arm64/emit_arm64_data_processing.cpp | 4 ++-- tests/A64/a64.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp b/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp index 790873c2..a1e618fb 100644 --- a/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp +++ b/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp @@ -1408,7 +1408,7 @@ void EmitIR(oaknut::CodeGenerator& code, EmitCont RegAlloc::Realize(Wresult, Wop1, Wop2); const u8 lsb = args[2].GetImmediateU8(); - code.EXTR(Wresult, Wop1, Wop2, lsb); + code.EXTR(Wresult, Wop2, Wop1, lsb); // NB: flipped } template<> @@ -1422,7 +1422,7 @@ void EmitIR(oaknut::CodeGenerator& code, EmitCont RegAlloc::Realize(Xresult, Xop1, Xop2); const u8 lsb = args[2].GetImmediateU8(); - code.EXTR(Xresult, Xop1, Xop2, lsb); + code.EXTR(Xresult, Xop2, Xop1, lsb); // NB: flipped } template<> diff --git a/tests/A64/a64.cpp b/tests/A64/a64.cpp index 067da6bb..6190ae14 100644 --- a/tests/A64/a64.cpp +++ b/tests/A64/a64.cpp @@ -1024,6 +1024,23 @@ TEST_CASE("A64: This is an infinite loop if fast dispatch is enabled", "[a64]") jit.Run(); } +TEST_CASE("A64: EXTR", "[a64]") { + A64TestEnv env; + A64::Jit jit{A64::UserConfig{&env}}; + + env.code_mem.emplace_back(0x93d8fef7); // EXTR X23, X23, X24, #63 + env.code_mem.emplace_back(0x14000000); // B . + + jit.SetPC(0); + jit.SetRegister(23, 0); + jit.SetRegister(24, 1); + + env.ticks_left = 2; + jit.Run(); + + REQUIRE(jit.GetRegister(23) == 0); +} + TEST_CASE("A64: Optimization failure when folding ADD", "[a64]") { A64TestEnv env; A64::Jit jit{A64::UserConfig{&env}};