diff --git a/Core/MIPS/MIPSDisVFPU.cpp b/Core/MIPS/MIPSDisVFPU.cpp index 1c84d3b6ba..b3116a8b48 100644 --- a/Core/MIPS/MIPSDisVFPU.cpp +++ b/Core/MIPS/MIPSDisVFPU.cpp @@ -261,14 +261,14 @@ namespace MIPSDis void Dis_MatrixSet1(MIPSOpcode op, uint32_t pc, char *out, size_t outSize) { const char *name = MIPSGetName(op); int vd = _VD; - MatrixSize sz = GetMtxSizeSafe(op); + MatrixSize sz = GetMtxSize(op); snprintf(out, outSize, "%s%s\t%s", name, VSuff(op), MN(vd, sz)); } void Dis_MatrixSet2(MIPSOpcode op, uint32_t pc, char *out, size_t outSize) { const char *name = MIPSGetName(op); int vd = _VD; int vs = _VS; - MatrixSize sz = GetMtxSizeSafe(op); + MatrixSize sz = GetMtxSize(op); snprintf(out, outSize, "%s%s\t%s, %s", name, VSuff(op), MN(vd, sz), MN(vs,sz)); } void Dis_MatrixSet3(MIPSOpcode op, uint32_t pc, char *out, size_t outSize) { @@ -276,7 +276,7 @@ namespace MIPSDis int vd = _VD; int vs = _VS; int vt = _VT; - MatrixSize sz = GetMtxSizeSafe(op); + MatrixSize sz = GetMtxSize(op); snprintf(out, outSize, "%s%s\t%s, %s, %s", name, VSuff(op), MN(vd, sz), MN(vs,sz), MN(vt,sz)); } @@ -285,7 +285,7 @@ namespace MIPSDis int vd = _VD; int vs = _VS; int vt = _VT; - MatrixSize sz = GetMtxSizeSafe(op); + MatrixSize sz = GetMtxSize(op); // TODO: Xpose? snprintf(out, outSize, "%s%s\t%s, %s, %s", name, VSuff(op), MN(vd, sz), MN(Xpose(vs),sz), MN(vt,sz)); } @@ -295,7 +295,7 @@ namespace MIPSDis int vd = _VD; int vs = _VS; int vt = _VT; - MatrixSize sz = GetMtxSizeSafe(op); + MatrixSize sz = GetMtxSize(op); snprintf(out, outSize, "%s%s\t%s, %s, %s", name, VSuff(op), MN(vd, sz), MN(vs, sz), VN(vt, V_Single)); } @@ -314,7 +314,7 @@ namespace MIPSDis int vt = _VT; int ins = (op>>23) & 7; VectorSize sz = GetVecSize(op); - MatrixSize msz = GetMtxSizeSafe(op); + MatrixSize msz = GetMtxSize(op); int n = GetNumVectorElements(sz); if (n == ins) diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index d00aab26a1..1ceca72630 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -101,9 +101,8 @@ inline float nanclamp(float f, float lower, float upper) return nanmin(nanmax(f, lower), upper); } - -void ApplyPrefixST(float *r, u32 data, VectorSize size, float invalid = 0.0f) { - // Possible optimization shortcut: +static void ApplyPrefixST(float *r, u32 data, VectorSize size, float invalid = 0.0f) { + // Check for no prefix. if (data == 0xe4) return; @@ -171,6 +170,7 @@ static void RetainInvalidSwizzleST(float *d, VectorSize sz) { int tPrefix = currentMIPS->vfpuCtrl[VFPU_CTRL_TPREFIX]; int n = GetNumVectorElements(sz); + // TODO: We can probably do some faster check of sPrefix and tPrefix to skip over this loop. for (int i = 0; i < n; i++) { int swizzleS = (sPrefix >> (i + i)) & 3; int swizzleT = (tPrefix >> (i + i)) & 3; @@ -1015,9 +1015,9 @@ namespace MIPSInt void Int_Vi2x(MIPSOpcode op) { int s[4]{}; u32 d[2]{}; - int vd = _VD; - int vs = _VS; - VectorSize sz = GetVecSize(op); + const int vd = _VD; + const int vs = _VS; + const VectorSize sz = GetVecSize(op); VectorSize oz; ReadVector(reinterpret_cast(s), sz, vs); // Negate, const, etc. apply as expected. @@ -1044,7 +1044,9 @@ namespace MIPSInt break; case 2: //vi2us - for (int i = 0; i < (GetNumVectorElements(sz) + 1) / 2; i++) { + { + int elems = (GetNumVectorElements(sz) + 1) / 2; + for (int i = 0; i < elems; i++) { int low = s[i * 2]; int high = s[i * 2 + 1]; if (low < 0) low = 0; @@ -1064,8 +1066,11 @@ namespace MIPSInt break; } break; + } case 3: //vi2s - for (int i = 0; i < (GetNumVectorElements(sz) + 1) / 2; i++) { + { + int elems = (GetNumVectorElements(sz) + 1) / 2; + for (int i = 0; i < elems; i++) { u32 low = s[i * 2]; u32 high = s[i * 2 + 1]; low >>= 16; @@ -1078,11 +1083,12 @@ namespace MIPSInt case V_Pair: oz = V_Single; break; case V_Single: oz = V_Single; break; default: - _dbg_assert_msg_( 0, "Trying to interpret instruction that can't be interpreted"); + _dbg_assert_msg_(0, "Trying to interpret instruction that can't be interpreted"); oz = V_Single; break; } break; + } default: _dbg_assert_msg_( 0, "Trying to interpret instruction that can't be interpreted"); oz = V_Single; @@ -1119,7 +1125,7 @@ namespace MIPSInt int b = ((in >> 16) & 0xFF) >> 4; int g = ((in >> 8) & 0xFF) >> 4; int r = ((in) & 0xFF) >> 4; - col = (a << 12) | (b << 8) | (g << 4 ) | (r); + col = (a << 12) | (b << 8) | (g << 4) | (r); break; } case 2: // 5551 diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index e55aabc0ad..8df9da5965 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -420,25 +420,6 @@ MatrixSize GetMatrixSize(VectorSize sz) { return res; } -MatrixSize GetMtxSizeSafe(MIPSOpcode op) { - int a = (op >> 7) & 1; - int b = (op >> 15) & 1; - a += (b << 1); - switch (a) { - case 0: return M_1x1; // This happens in disassembly of junk, but has predictable behavior. - case 1: return M_2x2; - case 2: return M_3x3; - case 3: return M_4x4; - default: return M_Invalid; - } -} - -MatrixSize GetMtxSize(MIPSOpcode op) { - MatrixSize res = GetMtxSizeSafe(op); - _assert_msg_(res != M_Invalid, "%s: Bad matrix size", __FUNCTION__); - return res; -} - VectorSize MatrixVectorSizeSafe(MatrixSize sz) { switch (sz) { case M_1x1: return V_Single; diff --git a/Core/MIPS/MIPSVFPUUtils.h b/Core/MIPS/MIPSVFPUUtils.h index e7444bb316..07e620e9c0 100644 --- a/Core/MIPS/MIPSVFPUUtils.h +++ b/Core/MIPS/MIPSVFPUUtils.h @@ -213,8 +213,12 @@ inline VectorSize GetVecSize(MIPSOpcode op) { return (VectorSize)(a + b + 1); // Safe, there are no other possibilities } -MatrixSize GetMtxSizeSafe(MIPSOpcode op); -MatrixSize GetMtxSize(MIPSOpcode op); +inline MatrixSize GetMtxSize(MIPSOpcode op) { + int a = (op >> 7) & 1; + int b = (op >> 14) & 2; + return (MatrixSize)(a + b + 1); // Safe, there are no other possibilities +} + VectorSize GetHalfVectorSizeSafe(VectorSize sz); VectorSize GetHalfVectorSize(VectorSize sz); VectorSize GetDoubleVectorSizeSafe(VectorSize sz);