From af5ff9941a2e3670720dcfa0075eb98e4791580d Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Fri, 19 Feb 2016 23:57:17 +0000 Subject: [PATCH 1/3] Interpreter: deduplicate CR0 helper --- .../Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index f8e1d44520..d5e5730c4e 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -11,11 +11,7 @@ void Interpreter::Helper_UpdateCR0(u32 value) { - s64 sign_extended = (s64)(s32)value; - u64 cr_val = (u64)sign_extended; - cr_val = (cr_val & ~(1ull << 61)) | ((u64)GetXER_SO() << 61); - - PowerPC::ppcState.cr_val[0] = cr_val; + Helper_UpdateCRx(0, value); } void Interpreter::Helper_UpdateCRx(int idx, u32 value) From b291b0a7c23ce005debf02b1d6fe0e7b008f9563 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 20 Feb 2016 01:01:12 +0000 Subject: [PATCH 2/3] Interpreter: simplify mask helper --- Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index d5e5730c4e..b2c4d5406d 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -33,7 +33,7 @@ u32 Interpreter::Helper_Mask(int mb, int me) //first make 001111111111111 part u32 begin = 0xFFFFFFFF >> mb; //then make 000000000001111 part, which is used to flip the bits of the first one - u32 end = me < 31 ? (0xFFFFFFFF >> (me + 1)) : 0; + u32 end = 0x7FFFFFFF >> me; //do the bitflip u32 mask = begin ^ end; //and invert if backwards From 3b2e170f0bdfbe46a97272d0fa091301ecdfa4af Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 20 Feb 2016 02:20:41 +0000 Subject: [PATCH 3/3] Interpreter: simplify subtable handling --- .../PowerPC/Interpreter/Interpreter_Tables.cpp | 10 +++++----- Source/Core/Core/PowerPC/PPCTables.cpp | 14 ++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp index f79b47d31a..13d2852f7c 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -19,11 +19,11 @@ static GekkoOPInfo unknownopinfo = { "unknown_instruction", OPTYPE_UNKNOWN, FL_E static GekkoOPTemplate primarytable[] = { - {4, Interpreter::RunTable4, {"RunTable4", OPTYPE_SUBTABLE | (4<<24), 0, 0, 0, 0, 0}}, - {19, Interpreter::RunTable19, {"RunTable19", OPTYPE_SUBTABLE | (19<<24), 0, 0, 0, 0, 0}}, - {31, Interpreter::RunTable31, {"RunTable31", OPTYPE_SUBTABLE | (31<<24), 0, 0, 0, 0, 0}}, - {59, Interpreter::RunTable59, {"RunTable59", OPTYPE_SUBTABLE | (59<<24), 0, 0, 0, 0, 0}}, - {63, Interpreter::RunTable63, {"RunTable63", OPTYPE_SUBTABLE | (63<<24), 0, 0, 0, 0, 0}}, + {4, Interpreter::RunTable4, {"RunTable4", OPTYPE_SUBTABLE, 0, 0, 0, 0, 0}}, + {19, Interpreter::RunTable19, {"RunTable19", OPTYPE_SUBTABLE, 0, 0, 0, 0, 0}}, + {31, Interpreter::RunTable31, {"RunTable31", OPTYPE_SUBTABLE, 0, 0, 0, 0, 0}}, + {59, Interpreter::RunTable59, {"RunTable59", OPTYPE_SUBTABLE, 0, 0, 0, 0, 0}}, + {63, Interpreter::RunTable63, {"RunTable63", OPTYPE_SUBTABLE, 0, 0, 0, 0, 0}}, {16, Interpreter::bcx, {"bcx", OPTYPE_SYSTEM, FL_ENDBLOCK, 1, 0, 0, 0}}, {18, Interpreter::bx, {"bx", OPTYPE_SYSTEM, FL_ENDBLOCK, 1, 0, 0, 0}}, diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index d6d44d215f..b0d9b0d1e7 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -37,10 +37,9 @@ const u64 m_crTable[16] = GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst) { GekkoOPInfo *info = m_infoTable[_inst.OPCD]; - if ((info->type & 0xFFFFFF) == OPTYPE_SUBTABLE) + if (info->type == OPTYPE_SUBTABLE) { - int table = info->type>>24; - switch (table) + switch (_inst.OPCD) { case 4: return m_infoTable4[_inst.SUBOP10]; case 19: return m_infoTable19[_inst.SUBOP10]; @@ -54,7 +53,7 @@ GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst) } else { - if ((info->type & 0xFFFFFF) == OPTYPE_INVALID) + if (info->type == OPTYPE_INVALID) { _assert_msg_(POWERPC,0,"GetOpInfo - invalid op %08x @ %08x", _inst.hex, PC); return nullptr; @@ -66,10 +65,9 @@ GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst) Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst) { const GekkoOPInfo *info = m_infoTable[_inst.OPCD]; - if ((info->type & 0xFFFFFF) == OPTYPE_SUBTABLE) + if (info->type == OPTYPE_SUBTABLE) { - int table = info->type>>24; - switch (table) + switch (_inst.OPCD) { case 4: return Interpreter::m_opTable4[_inst.SUBOP10]; case 19: return Interpreter::m_opTable19[_inst.SUBOP10]; @@ -83,7 +81,7 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction _inst) } else { - if ((info->type & 0xFFFFFF) == OPTYPE_INVALID) + if (info->type == OPTYPE_INVALID) { _assert_msg_(POWERPC,0,"GetInterpreterOp - invalid op %08x @ %08x", _inst.hex, PC); return nullptr;