From 8bd590ed994e434201ca4455a4329d5a303171c1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 3 Apr 2016 13:13:10 +0100 Subject: [PATCH] tests/JitX64: Fix thumb tests --- src/core/arm/decoder/thumb.cpp | 1 + src/core/arm/jit_x64/instructions/thumb.cpp | 6 +++--- src/tests/core/arm/jit_x64/fuzz_thumb.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/arm/decoder/thumb.cpp b/src/core/arm/decoder/thumb.cpp index 41ddd1daf..8fb960f54 100644 --- a/src/core/arm/decoder/thumb.cpp +++ b/src/core/arm/decoder/thumb.cpp @@ -412,6 +412,7 @@ static const std::array thumb_instruction_table = { { // B Cond cond = bits<8, 11>(instruction); s32 offset = bits<0, 7>(instruction); + ASSERT_MSG(cond != 0b1110, "UNDEFINED"); v->thumb_B(cond, offset); })}, { "SWI", MakeMatcher("11011111xxxxxxxx", [](Visitor* v, u32 instruction) { diff --git a/src/core/arm/jit_x64/instructions/thumb.cpp b/src/core/arm/jit_x64/instructions/thumb.cpp index 1fd18dfd8..d0a097863 100644 --- a/src/core/arm/jit_x64/instructions/thumb.cpp +++ b/src/core/arm/jit_x64/instructions/thumb.cpp @@ -56,6 +56,7 @@ void JitX64::thumb_BLX_prefix(ArmImm11 imm11) { current.arm_pc += GetInstSize(); // Compile the suffix, and make sure that it's compiled. + instructions_compiled++; // Has to be done to pass unit tests (same method of counting as interpreter). CompileSingleThumbInstruction(); ASSERT_MSG(thumb_BLX_suffix_executed, "thumb BLX suffix did not come after thumb BLX prefix, pc = %u", current.arm_pc); @@ -81,15 +82,14 @@ void JitX64::thumb_BLX_suffix(bool X, ArmImm11 imm11) { reg_alloc.UnlockArm(14); if (X) { - new_pc &= 0xFFFFFFFC; - } else { current.TFlag = false; code->MOV(32, MJitStateTFlag(), Imm32(0)); + new_pc &= 0xFFFFFFFC; } reg_alloc.FlushEverything(); current.arm_pc += GetInstSize(); - CompileUpdateCycles(false); + CompileUpdateCycles(); CompileJumpToBB(new_pc); stop_compilation = true; diff --git a/src/tests/core/arm/jit_x64/fuzz_thumb.cpp b/src/tests/core/arm/jit_x64/fuzz_thumb.cpp index ca0b45197..26bb91109 100644 --- a/src/tests/core/arm/jit_x64/fuzz_thumb.cpp +++ b/src/tests/core/arm/jit_x64/fuzz_thumb.cpp @@ -134,11 +134,11 @@ void FuzzJitThumb(const int instruction_count, const int instructions_to_execute test_mem->code_mem[2 + instruction_count] = 0xE7FE; // b +#0 // busy wait loop test_mem->recording.clear(); - interp.ExecuteInstructions(instructions_to_execute_count); + interp.ExecuteInstructions(instructions_to_execute_count + 1); auto interp_mem_recording = test_mem->recording; test_mem->recording.clear(); - jit.ExecuteInstructions(instructions_to_execute_count); + jit.ExecuteInstructions(instructions_to_execute_count + 1); auto jit_mem_recording = test_mem->recording; bool pass = true; @@ -279,6 +279,7 @@ TEST_CASE("Fuzz Thumb instructions set 2 (affects PC)", "[JitX64][Thumb]") { FromBitString16("11100xxxxxxxxxxx"), // B FromBitString16("01000100h0xxxxxx"), // ADD (high registers) FromBitString16("01000110h0xxxxxx"), // MOV (high registers) + FromBitString16("11010000xxxxxxxx"), // B FromBitString16("11010001xxxxxxxx"), // B FromBitString16("11010010xxxxxxxx"), // B FromBitString16("11010011xxxxxxxx"), // B @@ -291,7 +292,6 @@ TEST_CASE("Fuzz Thumb instructions set 2 (affects PC)", "[JitX64][Thumb]") { FromBitString16("11011010xxxxxxxx"), // B FromBitString16("11011011xxxxxxxx"), // B FromBitString16("11011100xxxxxxxx"), // B - FromBitString16("11011110xxxxxxxx"), // B }}; auto instruction_select = [&](int) -> u16 { @@ -321,5 +321,5 @@ TEST_CASE("Fuzz Thumb instructions set 3 (32-bit BL/BLX)", "[JitX64][Thumb]") { return inst_info.first | (random &~ inst_info.second); }; - FuzzJitThumb(2, 1, 1000, instruction_select); + FuzzJitThumb(2, 2, 1000, instruction_select); } \ No newline at end of file