From 3ede866c37ff52db906dc307500ca5305de0a61a Mon Sep 17 00:00:00 2001 From: Sonicadvance1 Date: Fri, 10 Jul 2009 19:25:58 +0000 Subject: [PATCH] Change the Wiimote plugin a bit since it works in both OSs the way Windows does it, fix a crash that happens in PluginManager.cpp since it was not being checked correctly. and the big one, Break out the JIT core dependency, should be able to remove easily now if added to the Scons settings. This commit WILL break Windows until someone adds the new files to the VS project files git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3734 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/PluginManager.cpp | 2 +- .../Interpreter/Interpreter_Tables.cpp | 531 +++++++++++++++- .../PowerPC/Interpreter/Interpreter_Tables.h | 28 + Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp | 3 +- Source/Core/Core/Src/PowerPC/Jit64IL/Jit.cpp | 3 +- .../Core/Src/PowerPC/JitCommon/Jit_Tables.cpp | 506 ++++++++++++++++ .../Core/Src/PowerPC/JitCommon/Jit_Tables.h | 34 ++ Source/Core/Core/Src/PowerPC/PPCTables.cpp | 568 +----------------- Source/Core/Core/Src/PowerPC/PPCTables.h | 18 +- Source/Core/Core/Src/SConscript | 3 + .../Plugin_Wiimote/Src/wiimote_real.cpp | 8 +- 11 files changed, 1121 insertions(+), 583 deletions(-) create mode 100644 Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.h create mode 100644 Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.cpp create mode 100644 Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.h diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index 81d61564ba..219e87a164 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -111,7 +111,7 @@ CPluginManager::~CPluginManager() for (int i = 0; i < MAXPADS; i++) { - if (m_pad[i] && OkayToInitPlugin(i)) + if (m_pad[i] && (OkayToInitPlugin(i) != -1)) { INFO_LOG(CONSOLE, "Delete: %i\n", i); delete m_pad[i]; diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp index fd6594493d..da2dd00b7c 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -1,16 +1,525 @@ -// __________________________________________________________________________________________________ -// F|RES and ector 2003-2005 -// -///////////////////////////////////////////////////////////////////////////////////////////////////// -// M O D U L E B E G I N /////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2003-2009 Dolphin Project. -#ifndef __APPLE__ -#include "stdafx.h" +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Interpreter_Tables.h" + +typedef void (*_Instruction) (UGeckoInstruction instCode); + +struct GekkoOPTemplate +{ + int opcode; + _Instruction Inst; + GekkoOPInfo opinfo; + int runCount; +}; + +static GekkoOPTemplate primarytable[] = +{ + {4, Interpreter::RunTable4, {"RunTable4", OPTYPE_SUBTABLE | (4<<24), 0}}, + {19, Interpreter::RunTable19, {"RunTable19", OPTYPE_SUBTABLE | (19<<24), 0}}, + {31, Interpreter::RunTable31, {"RunTable31", OPTYPE_SUBTABLE | (31<<24), 0}}, + {59, Interpreter::RunTable59, {"RunTable59", OPTYPE_SUBTABLE | (59<<24), 0}}, + {63, Interpreter::RunTable63, {"RunTable63", OPTYPE_SUBTABLE | (63<<24), 0}}, + + {16, Interpreter::bcx, {"bcx", OPTYPE_SYSTEM, FL_ENDBLOCK}}, + {18, Interpreter::bx, {"bx", OPTYPE_SYSTEM, FL_ENDBLOCK}}, + + {1, Interpreter::HLEFunction, {"HLEFunction", OPTYPE_SYSTEM, FL_ENDBLOCK}}, + {2, Interpreter::CompiledBlock, {"DynaBlock", OPTYPE_SYSTEM, 0}}, + {3, Interpreter::twi, {"twi", OPTYPE_SYSTEM, 0}}, + {17, Interpreter::sc, {"sc", OPTYPE_SYSTEM, FL_ENDBLOCK, 1}}, + + {7, Interpreter::mulli, {"mulli", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_RC_BIT, 2}}, + {8, Interpreter::subfic, {"subfic", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA}}, + {10, Interpreter::cmpli, {"cmpli", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn}}, + {11, Interpreter::cmpi, {"cmpi", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn}}, + {12, Interpreter::addic, {"addic", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA}}, + {13, Interpreter::addic_rc, {"addic_rc", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CR0}}, + {14, Interpreter::addi, {"addi", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A0}}, + {15, Interpreter::addis, {"addis", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A0}}, + + {20, Interpreter::rlwimix, {"rlwimix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_A | FL_IN_S | FL_RC_BIT}}, + {21, Interpreter::rlwinmx, {"rlwinmx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, + {23, Interpreter::rlwnmx, {"rlwnmx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_IN_B | FL_RC_BIT}}, + + {24, Interpreter::ori, {"ori", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, + {25, Interpreter::oris, {"oris", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, + {26, Interpreter::xori, {"xori", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, + {27, Interpreter::xoris, {"xoris", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, + {28, Interpreter::andi_rc, {"andi_rc", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_SET_CR0}}, + {29, Interpreter::andis_rc, {"andis_rc", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_SET_CR0}}, + +#if JITTEST + {32, Interpreter::lwz, {"lwz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {33, Interpreter::lwzu, {"lwzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, + {34, Interpreter::lbz, {"lbz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {35, Interpreter::lbzu, {"lbzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, + {40, Interpreter::lhz, {"lhz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {41, Interpreter::lhzu, {"lhzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, +#else + {32, Interpreter::lwz, {"lwz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {33, Interpreter::lwzu, {"lwzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, + {34, Interpreter::lbz, {"lbz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {35, Interpreter::lbzu, {"lbzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, + {40, Interpreter::lhz, {"lhz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {41, Interpreter::lhzu, {"lhzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, #endif + {42, Interpreter::lha, {"lha", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, + {43, Interpreter::lhau, {"lhau", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, -///////////////////////////////////////////////////////////////////////////////////////////////////// -// I M P L E M E N T A T I O N ////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// + {44, Interpreter::sth, {"sth", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, + {45, Interpreter::sthu, {"sthu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, + {36, Interpreter::stw, {"stw", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, + {37, Interpreter::stwu, {"stwu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, + {38, Interpreter::stb, {"stb", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, + {39, Interpreter::stbu, {"stbu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, + {46, Interpreter::lmw, {"lmw", OPTYPE_SYSTEM, FL_EVIL, 10}}, + {47, Interpreter::stmw, {"stmw", OPTYPE_SYSTEM, FL_EVIL, 10}}, + + {48, Interpreter::lfs, {"lfs", OPTYPE_LOADFP, FL_IN_A}}, + {49, Interpreter::lfsu, {"lfsu", OPTYPE_LOADFP, FL_OUT_A | FL_IN_A}}, + {50, Interpreter::lfd, {"lfd", OPTYPE_LOADFP, FL_IN_A}}, + {51, Interpreter::lfdu, {"lfdu", OPTYPE_LOADFP, FL_OUT_A | FL_IN_A}}, + + {52, Interpreter::stfs, {"stfs", OPTYPE_STOREFP, FL_IN_A}}, + {53, Interpreter::stfsu, {"stfsu", OPTYPE_STOREFP, FL_OUT_A | FL_IN_A}}, + {54, Interpreter::stfd, {"stfd", OPTYPE_STOREFP, FL_IN_A}}, + {55, Interpreter::stfdu, {"stfdu", OPTYPE_STOREFP, FL_OUT_A | FL_IN_A}}, + + {56, Interpreter::psq_l, {"psq_l", OPTYPE_PS, FL_IN_A}}, + {57, Interpreter::psq_lu, {"psq_lu", OPTYPE_PS, FL_OUT_A | FL_IN_A}}, + {60, Interpreter::psq_st, {"psq_st", OPTYPE_PS, FL_IN_A}}, + {61, Interpreter::psq_stu, {"psq_stu", OPTYPE_PS, FL_OUT_A | FL_IN_A}}, + + //missing: 0, 5, 6, 9, 22, 30, 62, 58 + {0, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {5, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {6, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {9, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {22, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {30, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {62, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, + {58, Interpreter::unknown_instruction, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, +}; + +static GekkoOPTemplate table4[] = +{ //SUBOP10 + {0, Interpreter::ps_cmpu0, {"ps_cmpu0", OPTYPE_PS, FL_SET_CRn}}, + {32, Interpreter::ps_cmpo0, {"ps_cmpo0", OPTYPE_PS, FL_SET_CRn}}, + {40, Interpreter::ps_neg, {"ps_neg", OPTYPE_PS, FL_RC_BIT}}, + {136, Interpreter::ps_nabs, {"ps_nabs", OPTYPE_PS, FL_RC_BIT}}, + {264, Interpreter::ps_abs, {"ps_abs", OPTYPE_PS, FL_RC_BIT}}, + {64, Interpreter::ps_cmpu1, {"ps_cmpu1", OPTYPE_PS, FL_RC_BIT}}, + {72, Interpreter::ps_mr, {"ps_mr", OPTYPE_PS, FL_RC_BIT}}, + {96, Interpreter::ps_cmpo1, {"ps_cmpo1", OPTYPE_PS, FL_RC_BIT}}, + {528, Interpreter::ps_merge00, {"ps_merge00", OPTYPE_PS, FL_RC_BIT}}, + {560, Interpreter::ps_merge01, {"ps_merge01", OPTYPE_PS, FL_RC_BIT}}, + {592, Interpreter::ps_merge10, {"ps_merge10", OPTYPE_PS, FL_RC_BIT}}, + {624, Interpreter::ps_merge11, {"ps_merge11", OPTYPE_PS, FL_RC_BIT}}, + + {1014, Interpreter::dcbz_l, {"dcbz_l", OPTYPE_SYSTEM, 0}}, +}; + +static GekkoOPTemplate table4_2[] = +{ + {10, Interpreter::ps_sum0, {"ps_sum0", OPTYPE_PS, 0}}, + {11, Interpreter::ps_sum1, {"ps_sum1", OPTYPE_PS, 0}}, + {12, Interpreter::ps_muls0, {"ps_muls0", OPTYPE_PS, 0}}, + {13, Interpreter::ps_muls1, {"ps_muls1", OPTYPE_PS, 0}}, + {14, Interpreter::ps_madds0, {"ps_madds0", OPTYPE_PS, 0}}, + {15, Interpreter::ps_madds1, {"ps_madds1", OPTYPE_PS, 0}}, + {18, Interpreter::ps_div, {"ps_div", OPTYPE_PS, 0, 16}}, + {20, Interpreter::ps_sub, {"ps_sub", OPTYPE_PS, 0}}, + {21, Interpreter::ps_add, {"ps_add", OPTYPE_PS, 0}}, + {23, Interpreter::ps_sel, {"ps_sel", OPTYPE_PS, 0}}, + {24, Interpreter::ps_res, {"ps_res", OPTYPE_PS, 0}}, + {25, Interpreter::ps_mul, {"ps_mul", OPTYPE_PS, 0}}, + {26, Interpreter::ps_rsqrte, {"ps_rsqrte", OPTYPE_PS, 0, 1}}, + {28, Interpreter::ps_msub, {"ps_msub", OPTYPE_PS, 0}}, + {29, Interpreter::ps_madd, {"ps_madd", OPTYPE_PS, 0}}, + {30, Interpreter::ps_nmsub, {"ps_nmsub", OPTYPE_PS, 0}}, + {31, Interpreter::ps_nmadd, {"ps_nmadd", OPTYPE_PS, 0}}, +}; + + +static GekkoOPTemplate table4_3[] = +{ + {6, Interpreter::psq_lx, {"psq_lx", OPTYPE_PS, 0}}, + {7, Interpreter::psq_stx, {"psq_stx", OPTYPE_PS, 0}}, + {38, Interpreter::psq_lux, {"psq_lux", OPTYPE_PS, 0}}, + {39, Interpreter::psq_stux, {"psq_stux", OPTYPE_PS, 0}}, +}; + +static GekkoOPTemplate table19[] = +{ + {528, Interpreter::bcctrx, {"bcctrx", OPTYPE_BRANCH, FL_ENDBLOCK}}, + {16, Interpreter::bclrx, {"bclrx", OPTYPE_BRANCH, FL_ENDBLOCK}}, + {257, Interpreter::crand, {"crand", OPTYPE_CR, FL_EVIL}}, + {129, Interpreter::crandc, {"crandc", OPTYPE_CR, FL_EVIL}}, + {289, Interpreter::creqv, {"creqv", OPTYPE_CR, FL_EVIL}}, + {225, Interpreter::crnand, {"crnand", OPTYPE_CR, FL_EVIL}}, + {33, Interpreter::crnor, {"crnor", OPTYPE_CR, FL_EVIL}}, + {449, Interpreter::cror, {"cror", OPTYPE_CR, FL_EVIL}}, + {417, Interpreter::crorc, {"crorc", OPTYPE_CR, FL_EVIL}}, + {193, Interpreter::crxor, {"crxor", OPTYPE_CR, FL_EVIL}}, + + {150, Interpreter::isync, {"isync", OPTYPE_ICACHE, FL_EVIL}}, + {0, Interpreter::mcrf, {"mcrf", OPTYPE_SYSTEM, FL_EVIL}}, + + {50, Interpreter::rfi, {"rfi", OPTYPE_SYSTEM, FL_ENDBLOCK | FL_CHECKEXCEPTIONS, 1}}, + {18, Interpreter::rfid, {"rfid", OPTYPE_SYSTEM, FL_ENDBLOCK | FL_CHECKEXCEPTIONS}} +}; + + +static GekkoOPTemplate table31[] = +{ + {28, Interpreter::andx, {"andx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {60, Interpreter::andcx, {"andcx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {444, Interpreter::orx, {"orx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {124, Interpreter::norx, {"norx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {316, Interpreter::xorx, {"xorx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {412, Interpreter::orcx, {"orcx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {476, Interpreter::nandx, {"nandx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {284, Interpreter::eqvx, {"eqvx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, + {0, Interpreter::cmp, {"cmp", OPTYPE_INTEGER, FL_IN_AB | FL_SET_CRn}}, + {32, Interpreter::cmpl, {"cmpl", OPTYPE_INTEGER, FL_IN_AB | FL_SET_CRn}}, + {26, Interpreter::cntlzwx, {"cntlzwx",OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, + {922, Interpreter::extshx, {"extshx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, + {954, Interpreter::extsbx, {"extsbx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, + {536, Interpreter::srwx, {"srwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, + {792, Interpreter::srawx, {"srawx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, + {824, Interpreter::srawix, {"srawix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, + {24, Interpreter::slwx, {"slwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, + + {54, Interpreter::dcbst, {"dcbst", OPTYPE_DCACHE, 0, 4}}, + {86, Interpreter::dcbf, {"dcbf", OPTYPE_DCACHE, 0, 4}}, + {246, Interpreter::dcbtst, {"dcbtst", OPTYPE_DCACHE, 0, 1}}, + {278, Interpreter::dcbt, {"dcbt", OPTYPE_DCACHE, 0, 1}}, + {470, Interpreter::dcbi, {"dcbi", OPTYPE_DCACHE, 0, 4}}, + {758, Interpreter::dcba, {"dcba", OPTYPE_DCACHE, 0, 4}}, + {1014, Interpreter::dcbz, {"dcbz", OPTYPE_DCACHE, 0, 4}}, +#if JITTEST + //load word + {23, Interpreter::lwzx, {"lwzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {55, Interpreter::lwzux, {"lwzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load halfword + {279, Interpreter::lhzx, {"lhzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {311, Interpreter::lhzux, {"lhzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load halfword signextend + {343, Interpreter::lhax, {"lhax", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {375, Interpreter::lhaux, {"lhaux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load byte + {87, Interpreter::lbzx, {"lbzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {119, Interpreter::lbzux, {"lbzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, +#else + //load word + {23, Interpreter::lwzx, {"lwzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {55, Interpreter::lwzux, {"lwzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load halfword + {279, Interpreter::lhzx, {"lhzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {311, Interpreter::lhzux, {"lhzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load halfword signextend + {343, Interpreter::lhax, {"lhax", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {375, Interpreter::lhaux, {"lhaux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //load byte + {87, Interpreter::lbzx, {"lbzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {119, Interpreter::lbzux, {"lbzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, +#endif + //load byte reverse + {534, Interpreter::lwbrx, {"lwbrx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + {790, Interpreter::lhbrx, {"lhbrx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, + + // Conditional load/store (Wii SMP) + {150, Interpreter::stwcxd, {"stwcxd", OPTYPE_STORE, FL_EVIL | FL_SET_CR0}}, + {20, Interpreter::lwarx, {"lwarx", OPTYPE_LOAD, FL_EVIL | FL_OUT_D | FL_IN_A0B | FL_SET_CR0}}, + + //load string (Inst these) + {533, Interpreter::lswx, {"lswx", OPTYPE_LOAD, FL_EVIL | FL_IN_A | FL_OUT_D}}, + {597, Interpreter::lswi, {"lswi", OPTYPE_LOAD, FL_EVIL | FL_IN_AB | FL_OUT_D}}, + + //store word + {151, Interpreter::stwx, {"stwx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, + {183, Interpreter::stwux, {"stwux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //store halfword + {407, Interpreter::sthx, {"sthx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, + {439, Interpreter::sthux, {"sthux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //store byte + {215, Interpreter::stbx, {"stbx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, + {247, Interpreter::stbux, {"stbux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, + + //store bytereverse + {662, Interpreter::stwbrx, {"stwbrx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, + {918, Interpreter::sthbrx, {"sthbrx", OPTYPE_STORE, FL_IN_A | FL_IN_B}}, + + {661, Interpreter::stswx, {"stswx", OPTYPE_STORE, FL_EVIL}}, + {725, Interpreter::stswi, {"stswi", OPTYPE_STORE, FL_EVIL}}, + + // fp load/store + {535, Interpreter::lfsx, {"lfsx", OPTYPE_LOADFP, FL_IN_A0 | FL_IN_B}}, + {567, Interpreter::lfsux, {"lfsux", OPTYPE_LOADFP, FL_IN_A | FL_IN_B}}, + {599, Interpreter::lfdx, {"lfdx", OPTYPE_LOADFP, FL_IN_A0 | FL_IN_B}}, + {631, Interpreter::lfdux, {"lfdux", OPTYPE_LOADFP, FL_IN_A | FL_IN_B}}, + + {663, Interpreter::stfsx, {"stfsx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, + {695, Interpreter::stfsux, {"stfsux", OPTYPE_STOREFP, FL_IN_A | FL_IN_B}}, + {727, Interpreter::stfdx, {"stfdx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, + {759, Interpreter::stfdux, {"stfdux", OPTYPE_STOREFP, FL_IN_A | FL_IN_B}}, + {983, Interpreter::stfiwx, {"stfiwx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, + + {19, Interpreter::mfcr, {"mfcr", OPTYPE_SYSTEM, FL_OUT_D}}, + {83, Interpreter::mfmsr, {"mfmsr", OPTYPE_SYSTEM, FL_OUT_D}}, + {144, Interpreter::mtcrf, {"mtcrf", OPTYPE_SYSTEM, 0}}, + {146, Interpreter::mtmsr, {"mtmsr", OPTYPE_SYSTEM, FL_ENDBLOCK}}, + {210, Interpreter::mtsr, {"mtsr", OPTYPE_SYSTEM, 0}}, + {242, Interpreter::mtsrin, {"mtsrin", OPTYPE_SYSTEM, 0}}, + {339, Interpreter::mfspr, {"mfspr", OPTYPE_SPR, FL_OUT_D}}, + {467, Interpreter::mtspr, {"mtspr", OPTYPE_SPR, 0, 2}}, + {371, Interpreter::mftb, {"mftb", OPTYPE_SYSTEM, FL_OUT_D | FL_TIMER}}, + {512, Interpreter::mcrxr, {"mcrxr", OPTYPE_SYSTEM, 0}}, + {595, Interpreter::mfsr, {"mfsr", OPTYPE_SYSTEM, FL_OUT_D, 2}}, + {659, Interpreter::mfsrin, {"mfsrin", OPTYPE_SYSTEM, FL_OUT_D, 2}}, + + {4, Interpreter::tw, {"tw", OPTYPE_SYSTEM, 0, 1}}, + {598, Interpreter::sync, {"sync", OPTYPE_SYSTEM, 0, 2}}, + {982, Interpreter::icbi, {"icbi", OPTYPE_SYSTEM, 0, 3}}, + + // Unused instructions on GC + {310, Interpreter::eciwx, {"eciwx", OPTYPE_INTEGER, FL_RC_BIT}}, + {438, Interpreter::ecowx, {"ecowx", OPTYPE_INTEGER, FL_RC_BIT}}, + {854, Interpreter::eieio, {"eieio", OPTYPE_INTEGER, FL_RC_BIT}}, + {306, Interpreter::tlbie, {"tlbie", OPTYPE_SYSTEM, 0}}, + {370, Interpreter::tlbia, {"tlbia", OPTYPE_SYSTEM, 0}}, + {566, Interpreter::tlbsync, {"tlbsync", OPTYPE_SYSTEM, 0}}, +}; + +static GekkoOPTemplate table31_2[] = +{ + {266, Interpreter::addx, {"addx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, + {10, Interpreter::addcx, {"addcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT}}, + {138, Interpreter::addex, {"addex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, + {234, Interpreter::addmex, {"addmex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, +#if JITTEST + {202, Interpreter::addzex, {"addzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, +#else + {202, Interpreter::addzex, {"addzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, +#endif + {491, Interpreter::divwx, {"divwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 39}}, + {459, Interpreter::divwux, {"divwux", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 39}}, + {75, Interpreter::mulhwx, {"mulhwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, + {11, Interpreter::mulhwux, {"mulhwux", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, + {235, Interpreter::mullwx, {"mullwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, + {104, Interpreter::negx, {"negx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, + {40, Interpreter::subfx, {"subfx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, + {8, Interpreter::subfcx, {"subfcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT}}, + {136, Interpreter::subfex, {"subfex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, + {232, Interpreter::subfmex, {"subfmex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, + {200, Interpreter::subfzex, {"subfzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, +}; + +static GekkoOPTemplate table59[] = +{ + {18, Interpreter::fdivsx, /*TODO*/ {"fdivsx", OPTYPE_FPU, FL_RC_BIT_F, 16}}, + {20, Interpreter::fsubsx, {"fsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {21, Interpreter::faddsx, {"faddsx", OPTYPE_FPU, FL_RC_BIT_F}}, +// {22, Interpreter::fsqrtsx, {"fsqrtsx", OPTYPE_FPU, FL_RC_BIT_F}}, // Not implemented on gekko + {24, Interpreter::fresx, {"fresx", OPTYPE_FPU, FL_RC_BIT_F}}, + {25, Interpreter::fmulsx, {"fmulsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {28, Interpreter::fmsubsx, {"fmsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {29, Interpreter::fmaddsx, {"fmaddsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {30, Interpreter::fnmsubsx, {"fnmsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {31, Interpreter::fnmaddsx, {"fnmaddsx", OPTYPE_FPU, FL_RC_BIT_F}}, +}; + +static GekkoOPTemplate table63[] = +{ + {264, Interpreter::fabsx, {"fabsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {32, Interpreter::fcmpo, {"fcmpo", OPTYPE_FPU, FL_RC_BIT_F}}, + {0, Interpreter::fcmpu, {"fcmpu", OPTYPE_FPU, FL_RC_BIT_F}}, + {14, Interpreter::fctiwx, {"fctiwx", OPTYPE_FPU, FL_RC_BIT_F}}, + {15, Interpreter::fctiwzx, {"fctiwzx", OPTYPE_FPU, FL_RC_BIT_F}}, + {72, Interpreter::fmrx, {"fmrx", OPTYPE_FPU, FL_RC_BIT_F}}, + {136, Interpreter::fnabsx, {"fnabsx", OPTYPE_FPU, FL_RC_BIT_F}}, + {40, Interpreter::fnegx, {"fnegx", OPTYPE_FPU, FL_RC_BIT_F}}, + {12, Interpreter::frspx, {"frspx", OPTYPE_FPU, FL_RC_BIT_F}}, + + {64, Interpreter::mcrfs, {"mcrfs", OPTYPE_SYSTEMFP, 0}}, + {583, Interpreter::mffsx, {"mffsx", OPTYPE_SYSTEMFP, 0}}, + {70, Interpreter::mtfsb0x, {"mtfsb0x", OPTYPE_SYSTEMFP, 0, 2}}, + {38, Interpreter::mtfsb1x, {"mtfsb1x", OPTYPE_SYSTEMFP, 0, 2}}, + {134, Interpreter::mtfsfix, {"mtfsfix", OPTYPE_SYSTEMFP, 0, 2}}, + {711, Interpreter::mtfsfx, {"mtfsfx", OPTYPE_SYSTEMFP, 0, 2}}, +}; + +static GekkoOPTemplate table63_2[] = +{ + {18, Interpreter::fdivx, {"fdivx", OPTYPE_FPU, FL_RC_BIT_F, 30}}, + {20, Interpreter::fsubx, {"fsubx", OPTYPE_FPU, FL_RC_BIT_F}}, + {21, Interpreter::faddx, {"faddx", OPTYPE_FPU, FL_RC_BIT_F}}, + {22, Interpreter::fsqrtx, {"fsqrtx", OPTYPE_FPU, FL_RC_BIT_F}}, + {23, Interpreter::fselx, {"fselx", OPTYPE_FPU, FL_RC_BIT_F}}, + {25, Interpreter::fmulx, {"fmulx", OPTYPE_FPU, FL_RC_BIT_F}}, + {26, Interpreter::frsqrtex, {"frsqrtex", OPTYPE_FPU, FL_RC_BIT_F}}, + {28, Interpreter::fmsubx, {"fmsubx", OPTYPE_FPU, FL_RC_BIT_F}}, + {29, Interpreter::fmaddx, {"fmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, + {30, Interpreter::fnmsubx, {"fnmsubx", OPTYPE_FPU, FL_RC_BIT_F}}, + {31, Interpreter::fnmaddx, {"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, +}; +namespace InterpreterTables +{ +void InitTables() +{ + //clear + for (int i = 0; i < 32; i++) + { + Interpreter::m_opTable59[i] = Interpreter::unknown_instruction; + m_infoTable59[i] = 0; + } + + for (int i = 0; i < 1024; i++) + { + Interpreter::m_opTable4 [i] = Interpreter::unknown_instruction; + Interpreter::m_opTable19[i] = Interpreter::unknown_instruction; + Interpreter::m_opTable31[i] = Interpreter::unknown_instruction; + Interpreter::m_opTable63[i] = Interpreter::unknown_instruction; + m_infoTable4[i] = 0; + m_infoTable19[i] = 0; + m_infoTable31[i] = 0; + m_infoTable63[i] = 0; + } + + for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++) + { + Interpreter::m_opTable[primarytable[i].opcode] = primarytable[i].Inst; + m_infoTable[primarytable[i].opcode] = &primarytable[i].opinfo; + } + + for (int i = 0; i < 32; i++) + { + int fill = i << 5; + for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill+table4_2[j].opcode; + Interpreter::m_opTable4[op] = table4_2[j].Inst; + m_infoTable4[op] = &table4_2[j].opinfo; + } + } + + for (int i = 0; i < 16; i++) + { + int fill = i << 6; + for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill+table4_3[j].opcode; + Interpreter::m_opTable4[op] = table4_3[j].Inst; + m_infoTable4[op] = &table4_3[j].opinfo; + } + } + + for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++) + { + int op = table4[i].opcode; + Interpreter::m_opTable4[op] = table4[i].Inst; + m_infoTable4[op] = &table4[i].opinfo; + } + + for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++) + { + int op = table31[i].opcode; + Interpreter::m_opTable31[op] = table31[i].Inst; + m_infoTable31[op] = &table31[i].opinfo; + } + + for (int i = 0; i < 1; i++) + { + int fill = i << 9; + for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill + table31_2[j].opcode; + Interpreter::m_opTable31[op] = table31_2[j].Inst; + m_infoTable31[op] = &table31_2[j].opinfo; + } + } + + for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++) + { + int op = table19[i].opcode; + Interpreter::m_opTable19[op] = table19[i].Inst; + m_infoTable19[op] = &table19[i].opinfo; + } + + for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++) + { + int op = table59[i].opcode; + Interpreter::m_opTable59[op] = table59[i].Inst; + m_infoTable59[op] = &table59[i].opinfo; + } + + for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++) + { + int op = table63[i].opcode; + Interpreter::m_opTable63[op] = table63[i].Inst; + m_infoTable63[op] = &table63[i].opinfo; + } + + for (int i = 0; i < 32; i++) + { + int fill = i << 5; + for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill + table63_2[j].opcode; + Interpreter::m_opTable63[op] = table63_2[j].Inst; + m_infoTable63[op] = &table63_2[j].opinfo; + } + } + + m_numInstructions = 0; + for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &primarytable[i].opinfo; + for (int i = 0; i < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table4_2[i].opinfo; + for (int i = 0; i < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table4_3[i].opinfo; + for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table4[i].opinfo; + for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table31[i].opinfo; + for (int i = 0; i < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table31_2[i].opinfo; + for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table19[i].opinfo; + for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table59[i].opinfo; + for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table63[i].opinfo; + for (int i = 0; i < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); i++) + m_allInstructions[m_numInstructions++] = &table63_2[i].opinfo; + if (m_numInstructions >= 512) { + PanicAlert("m_allInstructions underdimensioned"); + } +} + +} //remove diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.h b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.h new file mode 100644 index 0000000000..e651c3d95c --- /dev/null +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.h @@ -0,0 +1,28 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef INTERPRETER_TABLES_H +#define INTERPRETER_TABLES_H +#include "../Gekko.h" +#include "../PPCTables.h" +#include "Interpreter.h" + +namespace InterpreterTables +{ + void InitTables(); +} +#endif diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp index 21c455fa7b..ed243d09ec 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp @@ -35,6 +35,7 @@ #include "Jit.h" #include "JitAsm.h" #include "JitRegCache.h" +#include "Jit_Tables.h" #if defined JITTEST && JITTEST #error Jit64 cannot have JITTEST define @@ -555,7 +556,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buffer, JitB } if (!ops[i].skip) - PPCTables::CompileInstruction(ops[i].inst); + JitTables::CompileInstruction(ops[i].inst); gpr.SanityCheck(); fpr.SanityCheck(); diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/Jit.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/Jit.cpp index ffe902c81a..d751de8fca 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/Jit.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/Jit.cpp @@ -34,6 +34,7 @@ #include "Jit.h" #include "JitAsm.h" #include "../JitCommon/JitCache.h" +#include "../JitCommon/Jit_Tables.h" #if !defined JITTEST || ! JITTEST #error JitIL needs JITTEST define @@ -461,7 +462,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buffer, JitB } if (!ops[i].skip) - PPCTables::CompileInstruction(ops[i].inst); + JitTables::CompileInstruction(ops[i].inst); } // Perform actual code generation diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.cpp b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.cpp new file mode 100644 index 0000000000..78019b04d3 --- /dev/null +++ b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.cpp @@ -0,0 +1,506 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Jit_Tables.h" + +// Should be moved in to the Jit class +typedef void (Jit64::*_Instruction) (UGeckoInstruction instCode); + +_Instruction dynaOpTable[64]; +_Instruction dynaOpTable4[1024]; +_Instruction dynaOpTable19[1024]; +_Instruction dynaOpTable31[1024]; +_Instruction dynaOpTable59[32]; +_Instruction dynaOpTable63[1024]; +void Jit64::DynaRunTable4(UGeckoInstruction _inst) {(this->*dynaOpTable4 [_inst.SUBOP10])(_inst);} +void Jit64::DynaRunTable19(UGeckoInstruction _inst) {(this->*dynaOpTable19[_inst.SUBOP10])(_inst);} +void Jit64::DynaRunTable31(UGeckoInstruction _inst) {(this->*dynaOpTable31[_inst.SUBOP10])(_inst);} +void Jit64::DynaRunTable59(UGeckoInstruction _inst) {(this->*dynaOpTable59[_inst.SUBOP5 ])(_inst);} +void Jit64::DynaRunTable63(UGeckoInstruction _inst) {(this->*dynaOpTable63[_inst.SUBOP10])(_inst);} + + + +struct GekkoOPTemplate +{ + int opcode; + _Instruction Inst; + //GekkoOPInfo opinfo; // Doesn't need opinfo, Interpreter fills it out + int runCount; +}; + +static GekkoOPTemplate primarytable[] = +{ + {4, &Jit64::DynaRunTable4}, + {19, &Jit64::DynaRunTable19}, + {31, &Jit64::DynaRunTable31}, + {59, &Jit64::DynaRunTable59}, + {63, &Jit64::DynaRunTable63}, + + {16, &Jit64::bcx}, + {18, &Jit64::bx}, + + {1, &Jit64::HLEFunction}, + {2, &Jit64::Default}, + {3, &Jit64::Default}, + {17, &Jit64::sc}, + + {7, &Jit64::mulli}, + {8, &Jit64::subfic}, + {10, &Jit64::cmpXX}, + {11, &Jit64::cmpXX}, + {12, &Jit64::reg_imm}, + {13, &Jit64::reg_imm}, + {14, &Jit64::reg_imm}, + {15, &Jit64::reg_imm}, + + {20, &Jit64::rlwimix}, + {21, &Jit64::rlwinmx}, + {23, &Jit64::rlwnmx}, + + {24, &Jit64::reg_imm}, + {25, &Jit64::reg_imm}, + {26, &Jit64::reg_imm}, + {27, &Jit64::reg_imm}, + {28, &Jit64::reg_imm}, + {29, &Jit64::reg_imm}, + + {32, &Jit64::lXz}, + {33, &Jit64::Default}, + {34, &Jit64::lXz}, + {35, &Jit64::Default}, + {40, &Jit64::lXz}, + {41, &Jit64::Default}, + + {42, &Jit64::lha}, + {43, &Jit64::Default}, + + {44, &Jit64::stX}, + {45, &Jit64::stX}, + {36, &Jit64::stX}, + {37, &Jit64::stX}, + {38, &Jit64::stX}, + {39, &Jit64::stX}, + + {46, &Jit64::lmw}, + {47, &Jit64::stmw}, + + {48, &Jit64::lfs}, + {49, &Jit64::Default}, + {50, &Jit64::lfd}, + {51, &Jit64::Default}, + + {52, &Jit64::stfs}, + {53, &Jit64::stfs}, + {54, &Jit64::stfd}, + {55, &Jit64::Default}, + + {56, &Jit64::psq_l}, + {57, &Jit64::psq_l}, + {60, &Jit64::psq_st}, + {61, &Jit64::psq_st}, + + //missing: 0, 5, 6, 9, 22, 30, 62, 58 + {0, &Jit64::Default}, + {5, &Jit64::Default}, + {6, &Jit64::Default}, + {9, &Jit64::Default}, + {22, &Jit64::Default}, + {30, &Jit64::Default}, + {62, &Jit64::Default}, + {58, &Jit64::Default}, +}; + +static GekkoOPTemplate table4[] = +{ //SUBOP10 + {0, &Jit64::Default}, + {32, &Jit64::Default}, + {40, &Jit64::ps_sign}, + {136, &Jit64::ps_sign}, + {264, &Jit64::ps_sign}, + {64, &Jit64::Default}, + {72, &Jit64::ps_mr}, + {96, &Jit64::Default}, + {528, &Jit64::ps_mergeXX}, + {560, &Jit64::ps_mergeXX}, + {592, &Jit64::ps_mergeXX}, + {624, &Jit64::ps_mergeXX}, + + {1014, &Jit64::Default}, +}; + +static GekkoOPTemplate table4_2[] = +{ + {10, &Jit64::ps_sum}, + {11, &Jit64::ps_sum}, + {12, &Jit64::ps_muls}, + {13, &Jit64::ps_muls}, + {14, &Jit64::ps_maddXX}, + {15, &Jit64::ps_maddXX}, + {18, &Jit64::ps_arith}, + {20, &Jit64::ps_arith}, + {21, &Jit64::ps_arith}, + {23, &Jit64::ps_sel}, + {24, &Jit64::Default}, + {25, &Jit64::ps_arith}, + {26, &Jit64::ps_rsqrte}, + {28, &Jit64::ps_maddXX}, + {29, &Jit64::ps_maddXX}, + {30, &Jit64::ps_maddXX}, + {31, &Jit64::ps_maddXX}, +}; + + +static GekkoOPTemplate table4_3[] = +{ + {6, &Jit64::Default}, + {7, &Jit64::Default}, + {38, &Jit64::Default}, + {39, &Jit64::Default}, +}; + +static GekkoOPTemplate table19[] = +{ + {528, &Jit64::bcctrx}, + {16, &Jit64::bclrx}, + {257, &Jit64::Default}, + {129, &Jit64::Default}, + {289, &Jit64::Default}, + {225, &Jit64::Default}, + {33, &Jit64::Default}, + {449, &Jit64::Default}, + {417, &Jit64::Default}, + {193, &Jit64::Default}, + + {150, &Jit64::DoNothing}, + {0, &Jit64::Default}, + + {50, &Jit64::rfi}, + {18, &Jit64::Default} +}; + + +static GekkoOPTemplate table31[] = +{ + {28, &Jit64::andx}, + {60, &Jit64::Default}, + {444, &Jit64::orx}, + {124, &Jit64::Default}, + {316, &Jit64::xorx}, + {412, &Jit64::Default}, + {476, &Jit64::Default}, + {284, &Jit64::Default}, + {0, &Jit64::cmpXX}, + {32, &Jit64::cmpXX}, + {26, &Jit64::cntlzwx}, + {922, &Jit64::extshx}, + {954, &Jit64::extsbx}, + {536, &Jit64::srwx}, + {792, &Jit64::srawx}, + {824, &Jit64::srawix}, + {24, &Jit64::slwx}, + + {54, &Jit64::Default}, + {86, &Jit64::DoNothing}, + {246, &Jit64::Default}, + {278, &Jit64::Default}, + {470, &Jit64::Default}, + {758, &Jit64::Default}, + {1014, &Jit64::dcbz}, +#if JITTEST + //load word + {23, &Jit64::lXzx}, + {55, &Jit64::lXzx}, + + //load halfword + {279, &Jit64::lXzx}, + {311, &Jit64::lXzx}, + + //load halfword signextend + {343, &Jit64::lhax}, + {375, &Jit64::Default}, + + //load byte + {87, &Jit64::lXzx}, + {119, &Jit64::lXzx}, +#else + //load word + {23, &Jit64::lwzx}, + {55, &Jit64::lwzux}, + + //load halfword + {279, &Jit64::Default}, + {311, &Jit64::Default}, + + //load halfword signextend + {343, &Jit64::lhax}, + {375, &Jit64::Default}, + + //load byte + {87, &Jit64::lbzx}, + {119, &Jit64::Default}, +#endif + //load byte reverse + {534, &Jit64::Default}, + {790, &Jit64::Default}, + + // Conditional load/store (Wii SMP) + {150, &Jit64::Default}, + {20, &Jit64::Default}, + + //load string (interpret these) + {533, &Jit64::Default}, + {597, &Jit64::Default}, + + //store word + {151, &Jit64::stXx}, + {183, &Jit64::stXx}, + + //store halfword + {407, &Jit64::stXx}, + {439, &Jit64::stXx}, + + //store byte + {215, &Jit64::stXx}, + {247, &Jit64::stXx}, + + //store bytereverse + {662, &Jit64::Default}, + {918, &Jit64::Default}, + + {661, &Jit64::Default}, + {725, &Jit64::Default}, + + // fp load/store + {535, &Jit64::lfsx}, + {567, &Jit64::Default}, + {599, &Jit64::Default}, + {631, &Jit64::Default}, + + {663, &Jit64::stfsx}, + {695, &Jit64::Default}, + {727, &Jit64::Default}, + {759, &Jit64::Default}, + {983, &Jit64::Default}, + + {19, &Jit64::mfcr}, + {83, &Jit64::mfmsr}, + {144, &Jit64::mtcrf}, + {146, &Jit64::mtmsr}, + {210, &Jit64::Default}, + {242, &Jit64::Default}, + {339, &Jit64::mfspr}, + {467, &Jit64::mtspr}, + {371, &Jit64::mftb}, + {512, &Jit64::Default}, + {595, &Jit64::Default}, + {659, &Jit64::Default}, + + {4, &Jit64::Default}, + {598, &Jit64::DoNothing}, + {982, &Jit64::Default}, + + // Unused instructions on GC + {310, &Jit64::Default}, + {438, &Jit64::Default}, + {854, &Jit64::Default}, + {306, &Jit64::Default}, + {370, &Jit64::Default}, + {566, &Jit64::Default}, +}; + +static GekkoOPTemplate table31_2[] = +{ + {266, &Jit64::addx}, + {10, &Jit64::Default}, + {138, &Jit64::addex}, + {234, &Jit64::Default}, +#if JITTEST + {202, &Jit64::addzex}, +#else + {202, &Jit64::Default}, +#endif + {491, &Jit64::Default}, + {459, &Jit64::divwux}, + {75, &Jit64::Default}, + {11, &Jit64::mulhwux}, + {235, &Jit64::mullwx}, + {104, &Jit64::negx}, + {40, &Jit64::subfx}, + {8, &Jit64::subfcx}, + {136, &Jit64::subfex}, + {232, &Jit64::Default}, + {200, &Jit64::Default}, +}; + +static GekkoOPTemplate table59[] = +{ + {18, &Jit64::Default}, + {20, &Jit64::fp_arith_s}, + {21, &Jit64::fp_arith_s}, +// {22, &Jit64::Default}, // Not implemented on gekko + {24, &Jit64::Default}, + {25, &Jit64::fp_arith_s}, + {28, &Jit64::fmaddXX}, + {29, &Jit64::fmaddXX}, + {30, &Jit64::fmaddXX}, + {31, &Jit64::fmaddXX}, +}; + +static GekkoOPTemplate table63[] = +{ + {264, &Jit64::Default}, + {32, &Jit64::fcmpx}, + {0, &Jit64::fcmpx}, + {14, &Jit64::Default}, + {15, &Jit64::Default}, + {72, &Jit64::fmrx}, + {136, &Jit64::Default}, + {40, &Jit64::Default}, + {12, &Jit64::Default}, + + {64, &Jit64::Default}, + {583, &Jit64::Default}, + {70, &Jit64::Default}, + {38, &Jit64::Default}, + {134, &Jit64::Default}, + {711, &Jit64::Default}, +}; + +static GekkoOPTemplate table63_2[] = +{ + {18, &Jit64::Default}, + {20, &Jit64::Default}, + {21, &Jit64::Default}, + {22, &Jit64::Default}, + {23, &Jit64::Default}, + {25, &Jit64::fp_arith_s}, + {26, &Jit64::fp_arith_s}, + {28, &Jit64::fmaddXX}, + {29, &Jit64::fmaddXX}, + {30, &Jit64::fmaddXX}, + {31, &Jit64::fmaddXX}, +}; +namespace JitTables +{ +void CompileInstruction(UGeckoInstruction _inst) +{ + (jit.*dynaOpTable[_inst.OPCD])(_inst); + GekkoOPInfo *info = GetOpInfo(_inst); + if (info) { +#ifdef OPLOG + if (!strcmp(info->opname, OP_TO_LOG)){ ///"mcrfs" + rsplocations.push_back(jit.js.compilerPC); + } +#endif + info->compileCount++; + info->lastUse = jit.js.compilerPC; + } else { + PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", _inst.hex, jit.js.compilerPC); + } +} +void InitTables() +{ + //clear + for (int i = 0; i < 32; i++) + { + dynaOpTable59[i] = &Jit64::unknown_instruction; + } + + for (int i = 0; i < 1024; i++) + { + dynaOpTable4 [i] = &Jit64::unknown_instruction; + dynaOpTable19[i] = &Jit64::unknown_instruction; + dynaOpTable31[i] = &Jit64::unknown_instruction; + dynaOpTable63[i] = &Jit64::unknown_instruction; + } + + for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++) + { + dynaOpTable[primarytable[i].opcode] = primarytable[i].Inst; + } + + for (int i = 0; i < 32; i++) + { + int fill = i << 5; + for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill+table4_2[j].opcode; + dynaOpTable4[op] = table4_2[j].Inst; + } + } + + for (int i = 0; i < 16; i++) + { + int fill = i << 6; + for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill+table4_3[j].opcode; + dynaOpTable4[op] = table4_3[j].Inst; + } + } + + for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++) + { + int op = table4[i].opcode; + dynaOpTable4[op] = table4[i].Inst; + } + + for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++) + { + int op = table31[i].opcode; + dynaOpTable31[op] = table31[i].Inst; + } + + for (int i = 0; i < 1; i++) + { + int fill = i << 9; + for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill + table31_2[j].opcode; + dynaOpTable31[op] = table31_2[j].Inst; + } + } + + for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++) + { + int op = table19[i].opcode; + dynaOpTable19[op] = table19[i].Inst; + } + + for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++) + { + int op = table59[i].opcode; + dynaOpTable59[op] = table59[i].Inst; + } + + for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++) + { + int op = table63[i].opcode; + dynaOpTable63[op] = table63[i].Inst; + } + + for (int i = 0; i < 32; i++) + { + int fill = i << 5; + for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++) + { + int op = fill + table63_2[j].opcode; + dynaOpTable63[op] = table63_2[j].Inst; + } + } +} +} diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.h b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.h new file mode 100644 index 0000000000..f732196d0b --- /dev/null +++ b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Tables.h @@ -0,0 +1,34 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef JIT_TABLES_H +#define JIT_TABLES_H +#include "../Gekko.h" +#include "../PPCTables.h" +#if defined JITTEST && JITTEST +#include "../Jit64IL/Jit.h" +#else +#include "../Jit64/Jit.h" +#endif + + +namespace JitTables +{ + void CompileInstruction(UGeckoInstruction _inst); + void InitTables(); +} +#endif diff --git a/Source/Core/Core/Src/PowerPC/PPCTables.cpp b/Source/Core/Core/Src/PowerPC/PPCTables.cpp index 0eeb1b57bd..6b31bcf81d 100644 --- a/Source/Core/Core/Src/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCTables.cpp @@ -22,6 +22,8 @@ #include "PPCTables.h" #include "StringUtil.h" #include "Interpreter/Interpreter.h" +#include "Interpreter/Interpreter_Tables.h" +#include "JitCommon/Jit_Tables.h" #if defined(_M_IX86) || defined(_M_X64) #include "Jit64/Jit.h" @@ -29,16 +31,6 @@ #error Unknown architecture! #endif -struct GekkoOPTemplate -{ - int opcode; - PPCTables::_interpreterInstruction interpret; - PPCTables::_recompilerInstruction recompile; - - GekkoOPInfo opinfo; - int runCount; -}; - struct op_inf { const char *name; @@ -48,29 +40,15 @@ struct op_inf return count > o.count; } }; + GekkoOPInfo *m_infoTable[64]; + GekkoOPInfo *m_infoTable4[1024]; + GekkoOPInfo *m_infoTable19[1024]; + GekkoOPInfo *m_infoTable31[1024]; + GekkoOPInfo *m_infoTable59[32]; + GekkoOPInfo *m_infoTable63[1024]; -static GekkoOPInfo *m_infoTable[64]; -static GekkoOPInfo *m_infoTable4[1024]; -static GekkoOPInfo *m_infoTable19[1024]; -static GekkoOPInfo *m_infoTable31[1024]; -static GekkoOPInfo *m_infoTable59[32]; -static GekkoOPInfo *m_infoTable63[1024]; - -static PPCTables::_recompilerInstruction dynaOpTable[64]; -static PPCTables::_recompilerInstruction dynaOpTable4[1024]; -static PPCTables::_recompilerInstruction dynaOpTable19[1024]; -static PPCTables::_recompilerInstruction dynaOpTable31[1024]; -static PPCTables::_recompilerInstruction dynaOpTable59[32]; -static PPCTables::_recompilerInstruction dynaOpTable63[1024]; - -void Jit64::DynaRunTable4(UGeckoInstruction _inst) {(this->*dynaOpTable4 [_inst.SUBOP10])(_inst);} -void Jit64::DynaRunTable19(UGeckoInstruction _inst) {(this->*dynaOpTable19[_inst.SUBOP10])(_inst);} -void Jit64::DynaRunTable31(UGeckoInstruction _inst) {(this->*dynaOpTable31[_inst.SUBOP10])(_inst);} -void Jit64::DynaRunTable59(UGeckoInstruction _inst) {(this->*dynaOpTable59[_inst.SUBOP5 ])(_inst);} -void Jit64::DynaRunTable63(UGeckoInstruction _inst) {(this->*dynaOpTable63[_inst.SUBOP10])(_inst);} - -static GekkoOPInfo *m_allInstructions[512]; -static int m_numInstructions; + GekkoOPInfo *m_allInstructions[512]; + int m_numInstructions; GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst) { @@ -129,368 +107,6 @@ Interpreter::_interpreterInstruction GetInterpreterOp(UGeckoInstruction _inst) return Interpreter::m_opTable[_inst.OPCD]; } } - -static GekkoOPTemplate primarytable[] = -{ - {4, Interpreter::RunTable4, &Jit64::DynaRunTable4, {"RunTable4", OPTYPE_SUBTABLE | (4<<24), 0}}, - {19, Interpreter::RunTable19, &Jit64::DynaRunTable19, {"RunTable19", OPTYPE_SUBTABLE | (19<<24), 0}}, - {31, Interpreter::RunTable31, &Jit64::DynaRunTable31, {"RunTable31", OPTYPE_SUBTABLE | (31<<24), 0}}, - {59, Interpreter::RunTable59, &Jit64::DynaRunTable59, {"RunTable59", OPTYPE_SUBTABLE | (59<<24), 0}}, - {63, Interpreter::RunTable63, &Jit64::DynaRunTable63, {"RunTable63", OPTYPE_SUBTABLE | (63<<24), 0}}, - - {16, Interpreter::bcx, &Jit64::bcx, {"bcx", OPTYPE_SYSTEM, FL_ENDBLOCK}}, - {18, Interpreter::bx, &Jit64::bx, {"bx", OPTYPE_SYSTEM, FL_ENDBLOCK}}, - - {1, Interpreter::HLEFunction, &Jit64::HLEFunction, {"HLEFunction", OPTYPE_SYSTEM, FL_ENDBLOCK}}, - {2, Interpreter::CompiledBlock, &Jit64::Default, {"DynaBlock", OPTYPE_SYSTEM, 0}}, - {3, Interpreter::twi, &Jit64::Default, {"twi", OPTYPE_SYSTEM, 0}}, - {17, Interpreter::sc, &Jit64::sc, {"sc", OPTYPE_SYSTEM, FL_ENDBLOCK, 1}}, - - {7, Interpreter::mulli, &Jit64::mulli, {"mulli", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_RC_BIT, 2}}, - {8, Interpreter::subfic, &Jit64::subfic, {"subfic", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA}}, - {10, Interpreter::cmpli, &Jit64::cmpXX, {"cmpli", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn}}, - {11, Interpreter::cmpi, &Jit64::cmpXX, {"cmpi", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn}}, - {12, Interpreter::addic, &Jit64::reg_imm, {"addic", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA}}, - {13, Interpreter::addic_rc, &Jit64::reg_imm, {"addic_rc", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CR0}}, - {14, Interpreter::addi, &Jit64::reg_imm, {"addi", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A0}}, - {15, Interpreter::addis, &Jit64::reg_imm, {"addis", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A0}}, - - {20, Interpreter::rlwimix, &Jit64::rlwimix, {"rlwimix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_A | FL_IN_S | FL_RC_BIT}}, - {21, Interpreter::rlwinmx, &Jit64::rlwinmx, {"rlwinmx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, - {23, Interpreter::rlwnmx, &Jit64::rlwnmx, {"rlwnmx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_IN_B | FL_RC_BIT}}, - - {24, Interpreter::ori, &Jit64::reg_imm, {"ori", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, - {25, Interpreter::oris, &Jit64::reg_imm, {"oris", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, - {26, Interpreter::xori, &Jit64::reg_imm, {"xori", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, - {27, Interpreter::xoris, &Jit64::reg_imm, {"xoris", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S}}, - {28, Interpreter::andi_rc, &Jit64::reg_imm, {"andi_rc", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_SET_CR0}}, - {29, Interpreter::andis_rc, &Jit64::reg_imm, {"andis_rc", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_SET_CR0}}, - -#if JITTEST - {32, Interpreter::lwz, &Jit64::lXz, {"lwz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {33, Interpreter::lwzu, &Jit64::lXz, {"lwzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, - {34, Interpreter::lbz, &Jit64::lXz, {"lbz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {35, Interpreter::lbzu, &Jit64::lXz, {"lbzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, - {40, Interpreter::lhz, &Jit64::lXz, {"lhz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {41, Interpreter::lhzu, &Jit64::lXz, {"lhzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, -#else - {32, Interpreter::lwz, &Jit64::lXz, {"lwz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {33, Interpreter::lwzu, &Jit64::Default, {"lwzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, - {34, Interpreter::lbz, &Jit64::lXz, {"lbz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {35, Interpreter::lbzu, &Jit64::Default, {"lbzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, - {40, Interpreter::lhz, &Jit64::lXz, {"lhz", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {41, Interpreter::lhzu, &Jit64::Default, {"lhzu", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, -#endif - {42, Interpreter::lha, &Jit64::lha, {"lha", OPTYPE_LOAD, FL_OUT_D | FL_IN_A}}, - {43, Interpreter::lhau, &Jit64::Default, {"lhau", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A}}, - - {44, Interpreter::sth, &Jit64::stX, {"sth", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, - {45, Interpreter::sthu, &Jit64::stX, {"sthu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, - {36, Interpreter::stw, &Jit64::stX, {"stw", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, - {37, Interpreter::stwu, &Jit64::stX, {"stwu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, - {38, Interpreter::stb, &Jit64::stX, {"stb", OPTYPE_STORE, FL_IN_A | FL_IN_S}}, - {39, Interpreter::stbu, &Jit64::stX, {"stbu", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_S}}, - - {46, Interpreter::lmw, &Jit64::lmw, {"lmw", OPTYPE_SYSTEM, FL_EVIL, 10}}, - {47, Interpreter::stmw, &Jit64::stmw, {"stmw", OPTYPE_SYSTEM, FL_EVIL, 10}}, - - {48, Interpreter::lfs, &Jit64::lfs, {"lfs", OPTYPE_LOADFP, FL_IN_A}}, - {49, Interpreter::lfsu, &Jit64::Default, {"lfsu", OPTYPE_LOADFP, FL_OUT_A | FL_IN_A}}, - {50, Interpreter::lfd, &Jit64::lfd, {"lfd", OPTYPE_LOADFP, FL_IN_A}}, - {51, Interpreter::lfdu, &Jit64::Default, {"lfdu", OPTYPE_LOADFP, FL_OUT_A | FL_IN_A}}, - - {52, Interpreter::stfs, &Jit64::stfs, {"stfs", OPTYPE_STOREFP, FL_IN_A}}, - {53, Interpreter::stfsu, &Jit64::stfs, {"stfsu", OPTYPE_STOREFP, FL_OUT_A | FL_IN_A}}, - {54, Interpreter::stfd, &Jit64::stfd, {"stfd", OPTYPE_STOREFP, FL_IN_A}}, - {55, Interpreter::stfdu, &Jit64::Default, {"stfdu", OPTYPE_STOREFP, FL_OUT_A | FL_IN_A}}, - - {56, Interpreter::psq_l, &Jit64::psq_l, {"psq_l", OPTYPE_PS, FL_IN_A}}, - {57, Interpreter::psq_lu, &Jit64::psq_l, {"psq_lu", OPTYPE_PS, FL_OUT_A | FL_IN_A}}, - {60, Interpreter::psq_st, &Jit64::psq_st, {"psq_st", OPTYPE_PS, FL_IN_A}}, - {61, Interpreter::psq_stu, &Jit64::psq_st, {"psq_stu", OPTYPE_PS, FL_OUT_A | FL_IN_A}}, - - //missing: 0, 5, 6, 9, 22, 30, 62, 58 - {0, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {5, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {6, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {9, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {22, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {30, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {62, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, - {58, Interpreter::unknown_instruction, &Jit64::Default, {"unknown_instruction", OPTYPE_UNKNOWN, 0}}, -}; - -static GekkoOPTemplate table4[] = -{ //SUBOP10 - {0, Interpreter::ps_cmpu0, &Jit64::Default, {"ps_cmpu0", OPTYPE_PS, FL_SET_CRn}}, - {32, Interpreter::ps_cmpo0, &Jit64::Default, {"ps_cmpo0", OPTYPE_PS, FL_SET_CRn}}, - {40, Interpreter::ps_neg, &Jit64::ps_sign, {"ps_neg", OPTYPE_PS, FL_RC_BIT}}, - {136, Interpreter::ps_nabs, &Jit64::ps_sign, {"ps_nabs", OPTYPE_PS, FL_RC_BIT}}, - {264, Interpreter::ps_abs, &Jit64::ps_sign, {"ps_abs", OPTYPE_PS, FL_RC_BIT}}, - {64, Interpreter::ps_cmpu1, &Jit64::Default, {"ps_cmpu1", OPTYPE_PS, FL_RC_BIT}}, - {72, Interpreter::ps_mr, &Jit64::ps_mr, {"ps_mr", OPTYPE_PS, FL_RC_BIT}}, - {96, Interpreter::ps_cmpo1, &Jit64::Default, {"ps_cmpo1", OPTYPE_PS, FL_RC_BIT}}, - {528, Interpreter::ps_merge00, &Jit64::ps_mergeXX, {"ps_merge00", OPTYPE_PS, FL_RC_BIT}}, - {560, Interpreter::ps_merge01, &Jit64::ps_mergeXX, {"ps_merge01", OPTYPE_PS, FL_RC_BIT}}, - {592, Interpreter::ps_merge10, &Jit64::ps_mergeXX, {"ps_merge10", OPTYPE_PS, FL_RC_BIT}}, - {624, Interpreter::ps_merge11, &Jit64::ps_mergeXX, {"ps_merge11", OPTYPE_PS, FL_RC_BIT}}, - - {1014, Interpreter::dcbz_l, &Jit64::Default, {"dcbz_l", OPTYPE_SYSTEM, 0}}, -}; - -static GekkoOPTemplate table4_2[] = -{ - {10, Interpreter::ps_sum0, &Jit64::ps_sum, {"ps_sum0", OPTYPE_PS, 0}}, - {11, Interpreter::ps_sum1, &Jit64::ps_sum, {"ps_sum1", OPTYPE_PS, 0}}, - {12, Interpreter::ps_muls0, &Jit64::ps_muls, {"ps_muls0", OPTYPE_PS, 0}}, - {13, Interpreter::ps_muls1, &Jit64::ps_muls, {"ps_muls1", OPTYPE_PS, 0}}, - {14, Interpreter::ps_madds0, &Jit64::ps_maddXX, {"ps_madds0", OPTYPE_PS, 0}}, - {15, Interpreter::ps_madds1, &Jit64::ps_maddXX, {"ps_madds1", OPTYPE_PS, 0}}, - {18, Interpreter::ps_div, &Jit64::ps_arith, {"ps_div", OPTYPE_PS, 0, 16}}, - {20, Interpreter::ps_sub, &Jit64::ps_arith, {"ps_sub", OPTYPE_PS, 0}}, - {21, Interpreter::ps_add, &Jit64::ps_arith, {"ps_add", OPTYPE_PS, 0}}, - {23, Interpreter::ps_sel, &Jit64::ps_sel, {"ps_sel", OPTYPE_PS, 0}}, - {24, Interpreter::ps_res, &Jit64::Default, {"ps_res", OPTYPE_PS, 0}}, - {25, Interpreter::ps_mul, &Jit64::ps_arith, {"ps_mul", OPTYPE_PS, 0}}, - {26, Interpreter::ps_rsqrte, &Jit64::ps_rsqrte, {"ps_rsqrte", OPTYPE_PS, 0, 1}}, - {28, Interpreter::ps_msub, &Jit64::ps_maddXX, {"ps_msub", OPTYPE_PS, 0}}, - {29, Interpreter::ps_madd, &Jit64::ps_maddXX, {"ps_madd", OPTYPE_PS, 0}}, - {30, Interpreter::ps_nmsub, &Jit64::ps_maddXX, {"ps_nmsub", OPTYPE_PS, 0}}, - {31, Interpreter::ps_nmadd, &Jit64::ps_maddXX, {"ps_nmadd", OPTYPE_PS, 0}}, -}; - - -static GekkoOPTemplate table4_3[] = -{ - {6, Interpreter::psq_lx, &Jit64::Default, {"psq_lx", OPTYPE_PS, 0}}, - {7, Interpreter::psq_stx, &Jit64::Default, {"psq_stx", OPTYPE_PS, 0}}, - {38, Interpreter::psq_lux, &Jit64::Default, {"psq_lux", OPTYPE_PS, 0}}, - {39, Interpreter::psq_stux, &Jit64::Default, {"psq_stux", OPTYPE_PS, 0}}, -}; - -static GekkoOPTemplate table19[] = -{ - {528, Interpreter::bcctrx, &Jit64::bcctrx, {"bcctrx", OPTYPE_BRANCH, FL_ENDBLOCK}}, - {16, Interpreter::bclrx, &Jit64::bclrx, {"bclrx", OPTYPE_BRANCH, FL_ENDBLOCK}}, - {257, Interpreter::crand, &Jit64::Default, {"crand", OPTYPE_CR, FL_EVIL}}, - {129, Interpreter::crandc, &Jit64::Default, {"crandc", OPTYPE_CR, FL_EVIL}}, - {289, Interpreter::creqv, &Jit64::Default, {"creqv", OPTYPE_CR, FL_EVIL}}, - {225, Interpreter::crnand, &Jit64::Default, {"crnand", OPTYPE_CR, FL_EVIL}}, - {33, Interpreter::crnor, &Jit64::Default, {"crnor", OPTYPE_CR, FL_EVIL}}, - {449, Interpreter::cror, &Jit64::Default, {"cror", OPTYPE_CR, FL_EVIL}}, - {417, Interpreter::crorc, &Jit64::Default, {"crorc", OPTYPE_CR, FL_EVIL}}, - {193, Interpreter::crxor, &Jit64::Default, {"crxor", OPTYPE_CR, FL_EVIL}}, - - {150, Interpreter::isync, &Jit64::DoNothing, {"isync", OPTYPE_ICACHE, FL_EVIL}}, - {0, Interpreter::mcrf, &Jit64::Default, {"mcrf", OPTYPE_SYSTEM, FL_EVIL}}, - - {50, Interpreter::rfi, &Jit64::rfi, {"rfi", OPTYPE_SYSTEM, FL_ENDBLOCK | FL_CHECKEXCEPTIONS, 1}}, - {18, Interpreter::rfid, &Jit64::Default, {"rfid", OPTYPE_SYSTEM, FL_ENDBLOCK | FL_CHECKEXCEPTIONS}} -}; - - -static GekkoOPTemplate table31[] = -{ - {28, Interpreter::andx, &Jit64::andx, {"andx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {60, Interpreter::andcx, &Jit64::Default, {"andcx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {444, Interpreter::orx, &Jit64::orx, {"orx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {124, Interpreter::norx, &Jit64::Default, {"norx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {316, Interpreter::xorx, &Jit64::xorx, {"xorx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {412, Interpreter::orcx, &Jit64::Default, {"orcx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {476, Interpreter::nandx, &Jit64::Default, {"nandx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {284, Interpreter::eqvx, &Jit64::Default, {"eqvx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_SB | FL_RC_BIT}}, - {0, Interpreter::cmp, &Jit64::cmpXX, {"cmp", OPTYPE_INTEGER, FL_IN_AB | FL_SET_CRn}}, - {32, Interpreter::cmpl, &Jit64::cmpXX, {"cmpl", OPTYPE_INTEGER, FL_IN_AB | FL_SET_CRn}}, - {26, Interpreter::cntlzwx, &Jit64::cntlzwx, {"cntlzwx",OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, - {922, Interpreter::extshx, &Jit64::extshx, {"extshx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, - {954, Interpreter::extsbx, &Jit64::extsbx, {"extsbx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_S | FL_RC_BIT}}, - {536, Interpreter::srwx, &Jit64::srwx, {"srwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - {792, Interpreter::srawx, &Jit64::srawx, {"srawx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - {824, Interpreter::srawix, &Jit64::srawix, {"srawix", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - {24, Interpreter::slwx, &Jit64::slwx, {"slwx", OPTYPE_INTEGER, FL_OUT_A | FL_IN_B | FL_IN_S | FL_RC_BIT}}, - - {54, Interpreter::dcbst, &Jit64::Default, {"dcbst", OPTYPE_DCACHE, 0, 4}}, - {86, Interpreter::dcbf, &Jit64::DoNothing, {"dcbf", OPTYPE_DCACHE, 0, 4}}, - {246, Interpreter::dcbtst, &Jit64::Default, {"dcbtst", OPTYPE_DCACHE, 0, 1}}, - {278, Interpreter::dcbt, &Jit64::Default, {"dcbt", OPTYPE_DCACHE, 0, 1}}, - {470, Interpreter::dcbi, &Jit64::Default, {"dcbi", OPTYPE_DCACHE, 0, 4}}, - {758, Interpreter::dcba, &Jit64::Default, {"dcba", OPTYPE_DCACHE, 0, 4}}, - {1014, Interpreter::dcbz, &Jit64::dcbz, {"dcbz", OPTYPE_DCACHE, 0, 4}}, -#if JITTEST - //load word - {23, Interpreter::lwzx, &Jit64::lXzx, {"lwzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {55, Interpreter::lwzux, &Jit64::lXzx, {"lwzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load halfword - {279, Interpreter::lhzx, &Jit64::lXzx, {"lhzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {311, Interpreter::lhzux, &Jit64::lXzx, {"lhzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load halfword signextend - {343, Interpreter::lhax, &Jit64::lhax, {"lhax", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {375, Interpreter::lhaux, &Jit64::Default, {"lhaux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load byte - {87, Interpreter::lbzx, &Jit64::lXzx, {"lbzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {119, Interpreter::lbzux, &Jit64::lXzx, {"lbzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, -#else - //load word - {23, Interpreter::lwzx, &Jit64::lwzx, {"lwzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {55, Interpreter::lwzux, &Jit64::lwzux, {"lwzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load halfword - {279, Interpreter::lhzx, &Jit64::Default, {"lhzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {311, Interpreter::lhzux, &Jit64::Default, {"lhzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load halfword signextend - {343, Interpreter::lhax, &Jit64::lhax, {"lhax", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {375, Interpreter::lhaux, &Jit64::Default, {"lhaux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //load byte - {87, Interpreter::lbzx, &Jit64::lbzx, {"lbzx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {119, Interpreter::lbzux, &Jit64::Default, {"lbzux", OPTYPE_LOAD, FL_OUT_D | FL_OUT_A | FL_IN_A | FL_IN_B}}, -#endif - //load byte reverse - {534, Interpreter::lwbrx, &Jit64::Default, {"lwbrx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - {790, Interpreter::lhbrx, &Jit64::Default, {"lhbrx", OPTYPE_LOAD, FL_OUT_D | FL_IN_A0 | FL_IN_B}}, - - // Conditional load/store (Wii SMP) - {150, Interpreter::stwcxd, &Jit64::Default, {"stwcxd", OPTYPE_STORE, FL_EVIL | FL_SET_CR0}}, - {20, Interpreter::lwarx, &Jit64::Default, {"lwarx", OPTYPE_LOAD, FL_EVIL | FL_OUT_D | FL_IN_A0B | FL_SET_CR0}}, - - //load string (interpret these) - {533, Interpreter::lswx, &Jit64::Default, {"lswx", OPTYPE_LOAD, FL_EVIL | FL_IN_A | FL_OUT_D}}, - {597, Interpreter::lswi, &Jit64::Default, {"lswi", OPTYPE_LOAD, FL_EVIL | FL_IN_AB | FL_OUT_D}}, - - //store word - {151, Interpreter::stwx, &Jit64::stXx, {"stwx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, - {183, Interpreter::stwux, &Jit64::stXx, {"stwux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //store halfword - {407, Interpreter::sthx, &Jit64::stXx, {"sthx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, - {439, Interpreter::sthux, &Jit64::stXx, {"sthux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //store byte - {215, Interpreter::stbx, &Jit64::stXx, {"stbx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, - {247, Interpreter::stbux, &Jit64::stXx, {"stbux", OPTYPE_STORE, FL_OUT_A | FL_IN_A | FL_IN_B}}, - - //store bytereverse - {662, Interpreter::stwbrx, &Jit64::Default, {"stwbrx", OPTYPE_STORE, FL_IN_A0 | FL_IN_B}}, - {918, Interpreter::sthbrx, &Jit64::Default, {"sthbrx", OPTYPE_STORE, FL_IN_A | FL_IN_B}}, - - {661, Interpreter::stswx, &Jit64::Default, {"stswx", OPTYPE_STORE, FL_EVIL}}, - {725, Interpreter::stswi, &Jit64::Default, {"stswi", OPTYPE_STORE, FL_EVIL}}, - - // fp load/store - {535, Interpreter::lfsx, &Jit64::lfsx, {"lfsx", OPTYPE_LOADFP, FL_IN_A0 | FL_IN_B}}, - {567, Interpreter::lfsux, &Jit64::Default, {"lfsux", OPTYPE_LOADFP, FL_IN_A | FL_IN_B}}, - {599, Interpreter::lfdx, &Jit64::Default, {"lfdx", OPTYPE_LOADFP, FL_IN_A0 | FL_IN_B}}, - {631, Interpreter::lfdux, &Jit64::Default, {"lfdux", OPTYPE_LOADFP, FL_IN_A | FL_IN_B}}, - - {663, Interpreter::stfsx, &Jit64::stfsx, {"stfsx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, - {695, Interpreter::stfsux, &Jit64::Default, {"stfsux", OPTYPE_STOREFP, FL_IN_A | FL_IN_B}}, - {727, Interpreter::stfdx, &Jit64::Default, {"stfdx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, - {759, Interpreter::stfdux, &Jit64::Default, {"stfdux", OPTYPE_STOREFP, FL_IN_A | FL_IN_B}}, - {983, Interpreter::stfiwx, &Jit64::Default, {"stfiwx", OPTYPE_STOREFP, FL_IN_A0 | FL_IN_B}}, - - {19, Interpreter::mfcr, &Jit64::mfcr, {"mfcr", OPTYPE_SYSTEM, FL_OUT_D}}, - {83, Interpreter::mfmsr, &Jit64::mfmsr, {"mfmsr", OPTYPE_SYSTEM, FL_OUT_D}}, - {144, Interpreter::mtcrf, &Jit64::mtcrf, {"mtcrf", OPTYPE_SYSTEM, 0}}, - {146, Interpreter::mtmsr, &Jit64::mtmsr, {"mtmsr", OPTYPE_SYSTEM, FL_ENDBLOCK}}, - {210, Interpreter::mtsr, &Jit64::Default, {"mtsr", OPTYPE_SYSTEM, 0}}, - {242, Interpreter::mtsrin, &Jit64::Default, {"mtsrin", OPTYPE_SYSTEM, 0}}, - {339, Interpreter::mfspr, &Jit64::mfspr, {"mfspr", OPTYPE_SPR, FL_OUT_D}}, - {467, Interpreter::mtspr, &Jit64::mtspr, {"mtspr", OPTYPE_SPR, 0, 2}}, - {371, Interpreter::mftb, &Jit64::mftb, {"mftb", OPTYPE_SYSTEM, FL_OUT_D | FL_TIMER}}, - {512, Interpreter::mcrxr, &Jit64::Default, {"mcrxr", OPTYPE_SYSTEM, 0}}, - {595, Interpreter::mfsr, &Jit64::Default, {"mfsr", OPTYPE_SYSTEM, FL_OUT_D, 2}}, - {659, Interpreter::mfsrin, &Jit64::Default, {"mfsrin", OPTYPE_SYSTEM, FL_OUT_D, 2}}, - - {4, Interpreter::tw, &Jit64::Default, {"tw", OPTYPE_SYSTEM, 0, 1}}, - {598, Interpreter::sync, &Jit64::DoNothing, {"sync", OPTYPE_SYSTEM, 0, 2}}, - {982, Interpreter::icbi, &Jit64::Default, {"icbi", OPTYPE_SYSTEM, 0, 3}}, - - // Unused instructions on GC - {310, Interpreter::eciwx, &Jit64::Default, {"eciwx", OPTYPE_INTEGER, FL_RC_BIT}}, - {438, Interpreter::ecowx, &Jit64::Default, {"ecowx", OPTYPE_INTEGER, FL_RC_BIT}}, - {854, Interpreter::eieio, &Jit64::Default, {"eieio", OPTYPE_INTEGER, FL_RC_BIT}}, - {306, Interpreter::tlbie, &Jit64::Default, {"tlbie", OPTYPE_SYSTEM, 0}}, - {370, Interpreter::tlbia, &Jit64::Default, {"tlbia", OPTYPE_SYSTEM, 0}}, - {566, Interpreter::tlbsync, &Jit64::Default, {"tlbsync", OPTYPE_SYSTEM, 0}}, -}; - -static GekkoOPTemplate table31_2[] = -{ - {266, Interpreter::addx, &Jit64::addx, {"addx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, - {10, Interpreter::addcx, &Jit64::Default, {"addcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT}}, - {138, Interpreter::addex, &Jit64::addex, {"addex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, - {234, Interpreter::addmex, &Jit64::Default, {"addmex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, -#if JITTEST - {202, Interpreter::addzex, &Jit64::addzex, {"addzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, -#else - {202, Interpreter::addzex, &Jit64::Default, {"addzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, -#endif - {491, Interpreter::divwx, &Jit64::Default, {"divwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 39}}, - {459, Interpreter::divwux, &Jit64::divwux, {"divwux", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 39}}, - {75, Interpreter::mulhwx, &Jit64::Default, {"mulhwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, - {11, Interpreter::mulhwux, &Jit64::mulhwux, {"mulhwux", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, - {235, Interpreter::mullwx, &Jit64::mullwx, {"mullwx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 4}}, - {104, Interpreter::negx, &Jit64::negx, {"negx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, - {40, Interpreter::subfx, &Jit64::subfx, {"subfx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT}}, - {8, Interpreter::subfcx, &Jit64::subfcx, {"subfcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT}}, - {136, Interpreter::subfex, &Jit64::subfex, {"subfex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, - {232, Interpreter::subfmex, &Jit64::Default, {"subfmex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, - {200, Interpreter::subfzex, &Jit64::Default, {"subfzex", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_READ_CA | FL_SET_CA | FL_RC_BIT}}, -}; - -static GekkoOPTemplate table59[] = -{ - {18, Interpreter::fdivsx, &Jit64::Default, /*TODO*/ {"fdivsx", OPTYPE_FPU, FL_RC_BIT_F, 16}}, - {20, Interpreter::fsubsx, &Jit64::fp_arith_s, {"fsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {21, Interpreter::faddsx, &Jit64::fp_arith_s, {"faddsx", OPTYPE_FPU, FL_RC_BIT_F}}, -// {22, Interpreter::fsqrtsx, &Jit64::Default, {"fsqrtsx", OPTYPE_FPU, FL_RC_BIT_F}}, // Not implemented on gekko - {24, Interpreter::fresx, &Jit64::Default, {"fresx", OPTYPE_FPU, FL_RC_BIT_F}}, - {25, Interpreter::fmulsx, &Jit64::fp_arith_s, {"fmulsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {28, Interpreter::fmsubsx, &Jit64::fmaddXX, {"fmsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {29, Interpreter::fmaddsx, &Jit64::fmaddXX, {"fmaddsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {30, Interpreter::fnmsubsx, &Jit64::fmaddXX, {"fnmsubsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {31, Interpreter::fnmaddsx, &Jit64::fmaddXX, {"fnmaddsx", OPTYPE_FPU, FL_RC_BIT_F}}, -}; - -static GekkoOPTemplate table63[] = -{ - {264, Interpreter::fabsx, &Jit64::Default, {"fabsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {32, Interpreter::fcmpo, &Jit64::fcmpx, {"fcmpo", OPTYPE_FPU, FL_RC_BIT_F}}, - {0, Interpreter::fcmpu, &Jit64::fcmpx, {"fcmpu", OPTYPE_FPU, FL_RC_BIT_F}}, - {14, Interpreter::fctiwx, &Jit64::Default, {"fctiwx", OPTYPE_FPU, FL_RC_BIT_F}}, - {15, Interpreter::fctiwzx, &Jit64::Default, {"fctiwzx", OPTYPE_FPU, FL_RC_BIT_F}}, - {72, Interpreter::fmrx, &Jit64::fmrx, {"fmrx", OPTYPE_FPU, FL_RC_BIT_F}}, - {136, Interpreter::fnabsx, &Jit64::Default, {"fnabsx", OPTYPE_FPU, FL_RC_BIT_F}}, - {40, Interpreter::fnegx, &Jit64::Default, {"fnegx", OPTYPE_FPU, FL_RC_BIT_F}}, - {12, Interpreter::frspx, &Jit64::Default, {"frspx", OPTYPE_FPU, FL_RC_BIT_F}}, - - {64, Interpreter::mcrfs, &Jit64::Default, {"mcrfs", OPTYPE_SYSTEMFP, 0}}, - {583, Interpreter::mffsx, &Jit64::Default, {"mffsx", OPTYPE_SYSTEMFP, 0}}, - {70, Interpreter::mtfsb0x, &Jit64::Default, {"mtfsb0x", OPTYPE_SYSTEMFP, 0, 2}}, - {38, Interpreter::mtfsb1x, &Jit64::Default, {"mtfsb1x", OPTYPE_SYSTEMFP, 0, 2}}, - {134, Interpreter::mtfsfix, &Jit64::Default, {"mtfsfix", OPTYPE_SYSTEMFP, 0, 2}}, - {711, Interpreter::mtfsfx, &Jit64::Default, {"mtfsfx", OPTYPE_SYSTEMFP, 0, 2}}, -}; - -static GekkoOPTemplate table63_2[] = -{ - {18, Interpreter::fdivx, &Jit64::Default, {"fdivx", OPTYPE_FPU, FL_RC_BIT_F, 30}}, - {20, Interpreter::fsubx, &Jit64::Default, {"fsubx", OPTYPE_FPU, FL_RC_BIT_F}}, - {21, Interpreter::faddx, &Jit64::Default, {"faddx", OPTYPE_FPU, FL_RC_BIT_F}}, - {22, Interpreter::fsqrtx, &Jit64::Default, {"fsqrtx", OPTYPE_FPU, FL_RC_BIT_F}}, - {23, Interpreter::fselx, &Jit64::Default, {"fselx", OPTYPE_FPU, FL_RC_BIT_F}}, - {25, Interpreter::fmulx, &Jit64::fp_arith_s, {"fmulx", OPTYPE_FPU, FL_RC_BIT_F}}, - {26, Interpreter::frsqrtex,&Jit64::fp_arith_s, {"frsqrtex", OPTYPE_FPU, FL_RC_BIT_F}}, - {28, Interpreter::fmsubx, &Jit64::fmaddXX, {"fmsubx", OPTYPE_FPU, FL_RC_BIT_F}}, - {29, Interpreter::fmaddx, &Jit64::fmaddXX, {"fmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, - {30, Interpreter::fnmsubx, &Jit64::fmaddXX, {"fnmsubx", OPTYPE_FPU, FL_RC_BIT_F}}, - {31, Interpreter::fnmaddx, &Jit64::fmaddXX, {"fnmaddx", OPTYPE_FPU, FL_RC_BIT_F}}, -}; - namespace PPCTables { @@ -538,152 +154,11 @@ bool UsesFPU(UGeckoInstruction _inst) return false; } } - void InitTables() { - //clear - for (int i = 0; i < 32; i++) - { - Interpreter::m_opTable59[i] = Interpreter::unknown_instruction; - dynaOpTable59[i] = &Jit64::unknown_instruction; - m_infoTable59[i] = 0; - } - - for (int i = 0; i < 1024; i++) - { - Interpreter::m_opTable4 [i] = Interpreter::unknown_instruction; - Interpreter::m_opTable19[i] = Interpreter::unknown_instruction; - Interpreter::m_opTable31[i] = Interpreter::unknown_instruction; - Interpreter::m_opTable63[i] = Interpreter::unknown_instruction; - dynaOpTable4 [i] = &Jit64::unknown_instruction; - dynaOpTable19[i] = &Jit64::unknown_instruction; - dynaOpTable31[i] = &Jit64::unknown_instruction; - dynaOpTable63[i] = &Jit64::unknown_instruction; - m_infoTable4[i] = 0; - m_infoTable19[i] = 0; - m_infoTable31[i] = 0; - m_infoTable63[i] = 0; - } - - for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++) - { - Interpreter::m_opTable[primarytable[i].opcode] = primarytable[i].interpret; - dynaOpTable[primarytable[i].opcode] = primarytable[i].recompile; - m_infoTable[primarytable[i].opcode] = &primarytable[i].opinfo; - } - - for (int i = 0; i < 32; i++) - { - int fill = i << 5; - for (int j = 0; j < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); j++) - { - int op = fill+table4_2[j].opcode; - Interpreter::m_opTable4[op] = table4_2[j].interpret; - dynaOpTable4[op] = table4_2[j].recompile; - m_infoTable4[op] = &table4_2[j].opinfo; - } - } - - for (int i = 0; i < 16; i++) - { - int fill = i << 6; - for (int j = 0; j < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); j++) - { - int op = fill+table4_3[j].opcode; - Interpreter::m_opTable4[op] = table4_3[j].interpret; - dynaOpTable4[op] = table4_3[j].recompile; - m_infoTable4[op] = &table4_3[j].opinfo; - } - } - - for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++) - { - int op = table4[i].opcode; - Interpreter::m_opTable4[op] = table4[i].interpret; - dynaOpTable4[op] = table4[i].recompile; - m_infoTable4[op] = &table4[i].opinfo; - } - - for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++) - { - int op = table31[i].opcode; - Interpreter::m_opTable31[op] = table31[i].interpret; - dynaOpTable31[op] = table31[i].recompile; - m_infoTable31[op] = &table31[i].opinfo; - } - - for (int i = 0; i < 1; i++) - { - int fill = i << 9; - for (int j = 0; j < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); j++) - { - int op = fill + table31_2[j].opcode; - Interpreter::m_opTable31[op] = table31_2[j].interpret; - dynaOpTable31[op] = table31_2[j].recompile; - m_infoTable31[op] = &table31_2[j].opinfo; - } - } - - for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++) - { - int op = table19[i].opcode; - Interpreter::m_opTable19[op] = table19[i].interpret; - dynaOpTable19[op] = table19[i].recompile; - m_infoTable19[op] = &table19[i].opinfo; - } - - for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++) - { - int op = table59[i].opcode; - Interpreter::m_opTable59[op] = table59[i].interpret; - dynaOpTable59[op] = table59[i].recompile; - m_infoTable59[op] = &table59[i].opinfo; - } - - for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++) - { - int op = table63[i].opcode; - Interpreter::m_opTable63[op] = table63[i].interpret; - dynaOpTable63[op] = table63[i].recompile; - m_infoTable63[op] = &table63[i].opinfo; - } - - for (int i = 0; i < 32; i++) - { - int fill = i << 5; - for (int j = 0; j < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); j++) - { - int op = fill + table63_2[j].opcode; - Interpreter::m_opTable63[op] = table63_2[j].interpret; - dynaOpTable63[op] = table63_2[j].recompile; - m_infoTable63[op] = &table63_2[j].opinfo; - } - } - - m_numInstructions = 0; - for (int i = 0; i < (int)(sizeof(primarytable) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &primarytable[i].opinfo; - for (int i = 0; i < (int)(sizeof(table4_2) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table4_2[i].opinfo; - for (int i = 0; i < (int)(sizeof(table4_3) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table4_3[i].opinfo; - for (int i = 0; i < (int)(sizeof(table4) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table4[i].opinfo; - for (int i = 0; i < (int)(sizeof(table31) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table31[i].opinfo; - for (int i = 0; i < (int)(sizeof(table31_2) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table31_2[i].opinfo; - for (int i = 0; i < (int)(sizeof(table19) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table19[i].opinfo; - for (int i = 0; i < (int)(sizeof(table59) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table59[i].opinfo; - for (int i = 0; i < (int)(sizeof(table63) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table63[i].opinfo; - for (int i = 0; i < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); i++) - m_allInstructions[m_numInstructions++] = &table63_2[i].opinfo; - if (m_numInstructions >= 512) { - PanicAlert("m_allInstructions underdimensioned"); - } + // Interpreter ALWAYS needs to be initialized + InterpreterTables::InitTables(); + JitTables::InitTables(); } #define OPLOG @@ -701,23 +176,6 @@ const char *GetInstructionName(UGeckoInstruction _inst) return info ? info->opname : 0; } -void CompileInstruction(UGeckoInstruction _inst) -{ - (jit.*dynaOpTable[_inst.OPCD])(_inst); - GekkoOPInfo *info = GetOpInfo(_inst); - if (info) { -#ifdef OPLOG - if (!strcmp(info->opname, OP_TO_LOG)){ ///"mcrfs" - rsplocations.push_back(jit.js.compilerPC); - } -#endif - info->compileCount++; - info->lastUse = jit.js.compilerPC; - } else { - PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", _inst.hex, jit.js.compilerPC); - } -} - bool IsValidInstruction(UGeckoInstruction _inst) { const GekkoOPInfo *info = GetOpInfo(_inst); diff --git a/Source/Core/Core/Src/PowerPC/PPCTables.h b/Source/Core/Core/Src/PowerPC/PPCTables.h index 1c71d44575..96d2d8e327 100644 --- a/Source/Core/Core/Src/PowerPC/PPCTables.h +++ b/Source/Core/Core/Src/PowerPC/PPCTables.h @@ -82,7 +82,6 @@ enum { enum { OP_BLR = 0x4e800020, }; - struct GekkoOPInfo { const char *opname; @@ -93,18 +92,25 @@ struct GekkoOPInfo int compileCount; u32 lastUse; }; +extern GekkoOPInfo *m_infoTable[64]; +extern GekkoOPInfo *m_infoTable4[1024]; +extern GekkoOPInfo *m_infoTable19[1024]; +extern GekkoOPInfo *m_infoTable31[1024]; +extern GekkoOPInfo *m_infoTable59[32]; +extern GekkoOPInfo *m_infoTable63[1024]; + +extern GekkoOPInfo *m_allInstructions[512]; + +extern int m_numInstructions; GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst); Interpreter::_interpreterInstruction GetInterpreterOp(UGeckoInstruction _inst); -class Jit64; +class cJit64; namespace PPCTables { -typedef void (Jit64::*_recompilerInstruction) (UGeckoInstruction instCode); -typedef void (*_interpreterInstruction)(UGeckoInstruction instCode); - void InitTables(); bool IsValidInstruction(UGeckoInstruction _instCode); bool UsesFPU(UGeckoInstruction _inst); @@ -112,9 +118,7 @@ bool UsesFPU(UGeckoInstruction _inst); void CountInstruction(UGeckoInstruction _inst); void PrintInstructionRunCounts(); void LogCompiledInstructions(); -void CompileInstruction(UGeckoInstruction _inst); const char *GetInstructionName(UGeckoInstruction _inst); } // namespace - #endif diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index 5dbfb6f952..7c8e41f4da 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -82,6 +82,7 @@ files = ["ActionReplay.cpp", "PowerPC/Interpreter/Interpreter_LoadStore.cpp", "PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp", "PowerPC/Interpreter/Interpreter_SystemRegisters.cpp", + "PowerPC/Interpreter/Interpreter_Tables.cpp", "PowerPC/JitCommon/JitCache.cpp", "PowerPC/JitCommon/JitBackpatch.cpp", "PowerPC/JitCommon/Jit_Util.cpp", @@ -103,6 +104,7 @@ if env['JITTEST']: "PowerPC/Jit64IL/Jit_SystemRegisters.cpp", "PowerPC/Jit64IL/IR.cpp", "PowerPC/Jit64IL/IR_X86.cpp", + "PowerPC/JitCommon//Jit_Tables.cpp", ] else: files += ["PowerPC/Jit64/Jit.cpp", @@ -116,6 +118,7 @@ else: "PowerPC/Jit64/Jit_LoadStore.cpp", "PowerPC/Jit64/Jit_LoadStoreFloating.cpp", "PowerPC/Jit64/Jit_SystemRegisters.cpp", + "PowerPC/JitCommon/Jit_Tables.cpp", ] if sys.platform == 'win32': diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 35d07adeac..aaeeb45800 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -125,13 +125,7 @@ void ReadData() { //INFO_LOG(CONSOLE, "Writing data to the Wiimote\n"); SEvent& rEvent = m_EventWriteQueue.front(); - wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, -#ifdef _WIN32 // dunno if this is needed, sonic ran away when i found the bug :p - MAX_PAYLOAD -#else - (int)m_EventWriteQueue.size() -#endif - ); + wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, MAX_PAYLOAD); m_EventWriteQueue.pop(); #ifdef _WIN32