From 28f231110840b084e50f30b5640998233792c045 Mon Sep 17 00:00:00 2001 From: Jonathan Russell Date: Sun, 2 Sep 2018 23:44:25 +0100 Subject: [PATCH 1/3] - add vector comparison opcodes --- src/scripting/vm/jit.cpp | 86 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index a412a69192..fcca69c40d 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -304,8 +304,8 @@ private: EMIT_OP(DIVVF2_RR); EMIT_OP(DIVVF2_RK); EMIT_OP(LENV2); - // EMIT_OP(EQV2_R); - // EMIT_OP(EQV2_K); + EMIT_OP(EQV2_R); + EMIT_OP(EQV2_K); EMIT_OP(NEGV3); EMIT_OP(ADDV3_RR); EMIT_OP(SUBV3_RR); @@ -316,8 +316,8 @@ private: EMIT_OP(DIVVF3_RR); EMIT_OP(DIVVF3_RK); EMIT_OP(LENV3); - // EMIT_OP(EQV3_R); - // EMIT_OP(EQV3_K); + EMIT_OP(EQV3_R); + EMIT_OP(EQV3_K); EMIT_OP(ADDA_RR); EMIT_OP(ADDA_RK); EMIT_OP(SUBA); @@ -2266,6 +2266,8 @@ private: void EmitLTF_RR() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_RR.\n"); + cc.ucomisd(regF[C], regF[B]); cc.seta(result); cc.and_(result, 1); @@ -2275,6 +2277,8 @@ private: void EmitLTF_RK() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_RK.\n"); + auto constTmp = cc.newIntPtr(); auto xmmTmp = cc.newXmmSd(); cc.mov(constTmp, ToMemAddress(&konstf[C])); @@ -2289,6 +2293,8 @@ private: void EmitLTF_KR() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_KR.\n"); + auto tmp = cc.newIntPtr(); cc.mov(tmp, ToMemAddress(&konstf[B])); @@ -2301,6 +2307,8 @@ private: void EmitLEF_RR() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LEF_RR.\n"); + cc.ucomisd(regF[C], regF[B]); cc.setae(result); cc.and_(result, 1); @@ -2310,6 +2318,8 @@ private: void EmitLEF_RK() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LEF_RK.\n"); + auto constTmp = cc.newIntPtr(); auto xmmTmp = cc.newXmmSd(); cc.mov(constTmp, ToMemAddress(&konstf[C])); @@ -2324,6 +2334,8 @@ private: void EmitLEF_KR() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_KR.\n"); + auto tmp = cc.newIntPtr(); cc.mov(tmp, ToMemAddress(&konstf[B])); @@ -2429,8 +2441,33 @@ private: CallSqrt(regF[A], regF[A]); } - // void EmitEQV2_R() { } // if ((vB == vkC) != A) then pc++ (inexact if A & 32) - // void EmitEQV2_K() { } // this will never be used. + void EmitEQV2_R() + { + EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for EQV2_R.\n"); + + auto parityTmp = cc.newInt32(); + auto result1Tmp = cc.newInt32(); + cc.ucomisd(regF[B], regF[C]); + cc.sete(result); + cc.setnp(parityTmp); + cc.and_(result, parityTmp); + cc.and_(result, 1); + + cc.ucomisd(regF[B + 1], regF[C + 1]); + cc.sete(result1Tmp); + cc.setnp(parityTmp); + cc.and_(result1Tmp, parityTmp); + cc.and_(result1Tmp, 1); + + cc.and_(result, result1Tmp); + }); + } + + void EmitEQV2_K() + { + I_FatalError("EQV2_K is not used."); + } // Vector math. (3D) @@ -2586,8 +2623,41 @@ private: CallSqrt(regF[A], regF[A]); } - // void EmitEQV3_R() { } // if ((vB == vkC) != A) then pc++ (inexact if A & 32) - // void EmitEQV3_K() { } // this will never be used. + void EmitEQV3_R() + { + EmitComparisonOpcode([&](asmjit::X86Gp& result) { + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for EQV2_R.\n"); + + auto parityTmp = cc.newInt32(); + auto result1Tmp = cc.newInt32(); + cc.ucomisd(regF[B], regF[C]); + cc.sete(result); + cc.setnp(parityTmp); + cc.and_(result, parityTmp); + cc.and_(result, 1); + + cc.ucomisd(regF[B + 1], regF[C + 1]); + cc.sete(result1Tmp); + cc.setnp(parityTmp); + cc.and_(result1Tmp, parityTmp); + cc.and_(result1Tmp, 1); + + cc.and_(result, result1Tmp); + + cc.ucomisd(regF[B + 2], regF[C + 2]); + cc.sete(result1Tmp); + cc.setnp(parityTmp); + cc.and_(result1Tmp, parityTmp); + cc.and_(result1Tmp, 1); + + cc.and_(result, result1Tmp); + }); + } + + void EmitEQV3_K() + { + I_FatalError("EQV2_K is not used."); + } // Pointer math. From fdf17a5d8e041452bbc855bac428450a3686094d Mon Sep 17 00:00:00 2001 From: Jonathan Russell Date: Sun, 2 Sep 2018 23:45:32 +0100 Subject: [PATCH 2/3] - fix minor spelling error --- src/scripting/vm/jit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index fcca69c40d..4d74ab4187 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -2334,7 +2334,7 @@ private: void EmitLEF_KR() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { - if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LTF_KR.\n"); + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for LEF_KR.\n"); auto tmp = cc.newIntPtr(); cc.mov(tmp, ToMemAddress(&konstf[B])); From eeb4419bc489f485d0cfda69c9892da70dce4a5e Mon Sep 17 00:00:00 2001 From: Jonathan Russell Date: Sun, 2 Sep 2018 23:47:22 +0100 Subject: [PATCH 3/3] - more spelling mistakes... --- src/scripting/vm/jit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index 4d74ab4187..c8ac4ea3c9 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -2626,7 +2626,7 @@ private: void EmitEQV3_R() { EmitComparisonOpcode([&](asmjit::X86Gp& result) { - if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for EQV2_R.\n"); + if (static_cast(A & CMP_APPROX)) I_FatalError("CMP_APPROX not implemented for EQV3_R.\n"); auto parityTmp = cc.newInt32(); auto result1Tmp = cc.newInt32(); @@ -2656,7 +2656,7 @@ private: void EmitEQV3_K() { - I_FatalError("EQV2_K is not used."); + I_FatalError("EQV3_K is not used."); } // Pointer math.