From 1a1ce42889866b8c2a913a94d69d62be7140f1de Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jan 2017 00:43:01 -0500 Subject: [PATCH] Interpreter_Tables: Use std::array for instruction tables --- .../Interpreter/Interpreter_Tables.cpp | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp index ee10a2c8fd..798c4bcd8a 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -2,9 +2,11 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/PowerPC/Interpreter/Interpreter.h" +#include + #include "Common/MsgHandler.h" #include "Core/PowerPC/Gekko.h" +#include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_Tables.h" #include "Core/PowerPC/PPCTables.h" @@ -18,8 +20,8 @@ struct GekkoOPTemplate // clang-format off static GekkoOPInfo unknownopinfo = { "unknown_instruction", OPTYPE_UNKNOWN, FL_ENDBLOCK, 0, 0, 0, 0 }; -static GekkoOPTemplate primarytable[] = -{ +static std::array primarytable = +{{ {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}}, @@ -88,10 +90,10 @@ static GekkoOPTemplate primarytable[] = {61, Interpreter::psq_stu, {"psq_stu", OPTYPE_STOREPS, FL_IN_FLOAT_S | FL_OUT_A | FL_IN_A | FL_USE_FPU | FL_LOADSTORE, 1, 0, 0, 0}}, //missing: 0, 1, 2, 5, 6, 9, 22, 30, 62, 58 -}; +}}; -static GekkoOPTemplate table4[] = -{ //SUBOP10 +static std::array table4 = +{{ //SUBOP10 {0, Interpreter::ps_cmpu0, {"ps_cmpu0", OPTYPE_PS, FL_IN_FLOAT_AB | FL_SET_CRn | FL_USE_FPU | FL_READ_FPRF | FL_SET_FPRF, 1, 0, 0, 0}}, {32, Interpreter::ps_cmpo0, {"ps_cmpo0", OPTYPE_PS, FL_IN_FLOAT_AB | FL_SET_CRn | FL_USE_FPU | FL_READ_FPRF | FL_SET_FPRF, 1, 0, 0, 0}}, {40, Interpreter::ps_neg, {"ps_neg", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_B | FL_RC_BIT_F | FL_USE_FPU, 1, 0, 0, 0}}, @@ -106,10 +108,10 @@ static GekkoOPTemplate table4[] = {624, Interpreter::ps_merge11, {"ps_merge11", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU, 1, 0, 0, 0}}, {1014, Interpreter::dcbz_l, {"dcbz_l", OPTYPE_SYSTEM, FL_IN_A0B | FL_LOADSTORE, 1, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table4_2[] = -{ +static std::array table4_2 = +{{ {10, Interpreter::ps_sum0, {"ps_sum0", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {11, Interpreter::ps_sum1, {"ps_sum1", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {12, Interpreter::ps_muls0, {"ps_muls0", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_AC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, @@ -127,19 +129,19 @@ static GekkoOPTemplate table4_2[] = {29, Interpreter::ps_madd, {"ps_madd", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {30, Interpreter::ps_nmsub, {"ps_nmsub", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {31, Interpreter::ps_nmadd, {"ps_nmadd", OPTYPE_PS, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table4_3[] = -{ +static std::array table4_3 = +{{ {6, Interpreter::psq_lx, {"psq_lx", OPTYPE_LOADPS, FL_OUT_FLOAT_D | FL_IN_A0B | FL_USE_FPU | FL_LOADSTORE, 1, 0, 0, 0}}, {7, Interpreter::psq_stx, {"psq_stx", OPTYPE_STOREPS, FL_IN_FLOAT_S | FL_IN_A0B | FL_USE_FPU | FL_LOADSTORE, 1, 0, 0, 0}}, {38, Interpreter::psq_lux, {"psq_lux", OPTYPE_LOADPS, FL_OUT_FLOAT_D | FL_OUT_A | FL_IN_AB | FL_USE_FPU | FL_LOADSTORE, 1, 0, 0, 0}}, {39, Interpreter::psq_stux, {"psq_stux", OPTYPE_STOREPS, FL_IN_FLOAT_S | FL_OUT_A | FL_IN_AB | FL_USE_FPU | FL_LOADSTORE, 1, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table19[] = -{ +static std::array table19 = +{{ {528, Interpreter::bcctrx, {"bcctrx", OPTYPE_BRANCH, FL_ENDBLOCK, 1, 0, 0, 0}}, {16, Interpreter::bclrx, {"bclrx", OPTYPE_BRANCH, FL_ENDBLOCK, 1, 0, 0, 0}}, {257, Interpreter::crand, {"crand", OPTYPE_CR, FL_EVIL, 1, 0, 0, 0}}, @@ -155,11 +157,10 @@ static GekkoOPTemplate table19[] = {0, Interpreter::mcrf, {"mcrf", OPTYPE_SYSTEM, FL_EVIL | FL_SET_CRn, 1, 0, 0, 0}}, {50, Interpreter::rfi, {"rfi", OPTYPE_SYSTEM, FL_ENDBLOCK | FL_CHECKEXCEPTIONS, 2, 0, 0, 0}}, -}; +}}; - -static GekkoOPTemplate table31[] = -{ +static std::array table31 = +{{ {266, Interpreter::addx, {"addx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT, 1, 0, 0, 0}}, {778, Interpreter::addx, {"addox", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_RC_BIT | FL_SET_OE, 1, 0, 0, 0}}, {10, Interpreter::addcx, {"addcx", OPTYPE_INTEGER, FL_OUT_D | FL_IN_AB | FL_SET_CA | FL_RC_BIT, 1, 0, 0, 0}}, @@ -299,10 +300,10 @@ static GekkoOPTemplate table31[] = {854, Interpreter::eieio, {"eieio", OPTYPE_SYSTEM, 0, 1, 0, 0, 0}}, {306, Interpreter::tlbie, {"tlbie", OPTYPE_SYSTEM, FL_IN_B, 1, 0, 0, 0}}, {566, Interpreter::tlbsync, {"tlbsync", OPTYPE_SYSTEM, 0, 1, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table59[] = -{ +static std::array table59 = +{{ {18, Interpreter::fdivsx, {"fdivsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 17, 0, 0, 0}}, // TODO {20, Interpreter::fsubsx, {"fsubsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {21, Interpreter::faddsx, {"faddsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, @@ -312,10 +313,10 @@ static GekkoOPTemplate table59[] = {29, Interpreter::fmaddsx, {"fmaddsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {30, Interpreter::fnmsubsx, {"fnmsubsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {31, Interpreter::fnmaddsx, {"fnmaddsx", OPTYPE_SINGLEFP, FL_OUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table63[] = -{ +static std::array table63 = +{{ {264, Interpreter::fabsx, {"fabsx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_B | FL_RC_BIT_F | FL_USE_FPU, 1, 0, 0, 0}}, // FIXME: fcmp modifies the FPRF flags, but if the flags are clobbered later, @@ -338,10 +339,10 @@ static GekkoOPTemplate table63[] = {38, Interpreter::mtfsb1x, {"mtfsb1x", OPTYPE_SYSTEMFP, FL_RC_BIT_F | FL_USE_FPU | FL_READ_FPRF | FL_SET_FPRF, 3, 0, 0, 0}}, {134, Interpreter::mtfsfix, {"mtfsfix", OPTYPE_SYSTEMFP, FL_RC_BIT_F | FL_USE_FPU | FL_READ_FPRF | FL_SET_FPRF, 3, 0, 0, 0}}, {711, Interpreter::mtfsfx, {"mtfsfx", OPTYPE_SYSTEMFP, FL_RC_BIT_F | FL_IN_FLOAT_B | FL_USE_FPU | FL_READ_FPRF | FL_SET_FPRF, 3, 0, 0, 0}}, -}; +}}; -static GekkoOPTemplate table63_2[] = -{ +static std::array table63_2 = +{{ {18, Interpreter::fdivx, {"fdivx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 31, 0, 0, 0}}, {20, Interpreter::fsubx, {"fsubx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {21, Interpreter::faddx, {"faddx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_AB | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, @@ -352,7 +353,7 @@ static GekkoOPTemplate table63_2[] = {29, Interpreter::fmaddx, {"fmaddx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {30, Interpreter::fnmsubx, {"fnmsubx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, {31, Interpreter::fnmaddx, {"fnmaddx", OPTYPE_DOUBLEFP, FL_INOUT_FLOAT_D | FL_IN_FLOAT_ABC | FL_RC_BIT_F | FL_USE_FPU | FL_SET_FPRF, 1, 0, 0, 0}}, -}; +}}; // clang-format on namespace InterpreterTables