Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Jit64: implement ps_res
This is probably more accurate than it is allowed to be. After all, the
instructions are supposed to be "estimates".
  • Loading branch information
Tilka authored and degasus committed Nov 7, 2013
1 parent 0a2a273 commit cdc27e4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/PowerPC/Jit64/Jit.h
Expand Up @@ -178,7 +178,7 @@ class Jit64 : public Jitx86Base
void ps_arith(UGeckoInstruction inst); //aggregate
void ps_mergeXX(UGeckoInstruction inst);
void ps_maddXX(UGeckoInstruction inst);
void ps_rsqrte(UGeckoInstruction inst);
void ps_recip(UGeckoInstruction inst);
void ps_sum(UGeckoInstruction inst);
void ps_muls(UGeckoInstruction inst);

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp
Expand Up @@ -138,9 +138,9 @@ static GekkoOPTemplate table4_2[] =
{20, &Jit64::ps_arith}, //"ps_sub", OPTYPE_PS, 0}},
{21, &Jit64::ps_arith}, //"ps_add", OPTYPE_PS, 0}},
{23, &Jit64::ps_sel}, //"ps_sel", OPTYPE_PS, 0}},
{24, &Jit64::Default}, //"ps_res", OPTYPE_PS, 0}},
{24, &Jit64::ps_recip}, //"ps_res", OPTYPE_PS, 0}},
{25, &Jit64::ps_arith}, //"ps_mul", OPTYPE_PS, 0}},
{26, &Jit64::ps_rsqrte}, //"ps_rsqrte", OPTYPE_PS, 0, 1}},
{26, &Jit64::ps_recip}, //"ps_rsqrte", OPTYPE_PS, 0, 1}},
{28, &Jit64::ps_maddXX}, //"ps_msub", OPTYPE_PS, 0}},
{29, &Jit64::ps_maddXX}, //"ps_madd", OPTYPE_PS, 0}},
{30, &Jit64::ps_maddXX}, //"ps_nmsub", OPTYPE_PS, 0}},
Expand Down
10 changes: 4 additions & 6 deletions Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp
Expand Up @@ -8,9 +8,10 @@
#include "JitRegCache.h"
#include "CPUDetect.h"

const u64 GC_ALIGNED16(psSignBits2[2]) = {0x8000000000000000ULL, 0x8000000000000000ULL};
const u64 GC_ALIGNED16(psAbsMask2[2]) = {0x7FFFFFFFFFFFFFFFULL, 0x7FFFFFFFFFFFFFFFULL};
const double GC_ALIGNED16(psOneOne2[2]) = {1.0, 1.0};
static const u64 GC_ALIGNED16(psSignBits2[2]) = {0x8000000000000000ULL, 0x8000000000000000ULL};
static const u64 GC_ALIGNED16(psAbsMask2[2]) = {0x7FFFFFFFFFFFFFFFULL, 0x7FFFFFFFFFFFFFFFULL};
static const double GC_ALIGNED16(psOneOne2[2]) = {1.0, 1.0};
static const double one_const = 1.0f;

void Jit64::fp_tri_op(int d, int a, int b, bool reversible, bool dupe, void (XEmitter::*op)(Gen::X64Reg, Gen::OpArg))
{
Expand Down Expand Up @@ -59,9 +60,6 @@ void Jit64::fp_tri_op(int d, int a, int b, bool reversible, bool dupe, void (XEm
fpr.UnlockAll();
}


static const double one_const = 1.0f;

void Jit64::fp_arith_s(UGeckoInstruction inst)
{
INSTRUCTION_START
Expand Down
21 changes: 17 additions & 4 deletions Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp
Expand Up @@ -100,20 +100,33 @@ void Jit64::ps_sign(UGeckoInstruction inst)
fpr.UnlockAll();
}

void Jit64::ps_rsqrte(UGeckoInstruction inst)
// ps_res and ps_rsqrte
void Jit64::ps_recip(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITPairedOff)
if (inst.Rc) {
Default(inst); return;
}
OpArg divisor;
int d = inst.FD;
int b = inst.FB;
fpr.Lock(d, b);
fpr.BindToRegister(d, (d == b), true);
SQRTPD(XMM0, fpr.R(b));
fpr.BindToRegister(d, (d == b));
switch (inst.SUBOP5)
{
case 24:
// ps_res
divisor = fpr.R(b);
break;
case 26:
// ps_rsqrte
SQRTPD(XMM0, fpr.R(b));
divisor = R(XMM0);
break;
}
MOVAPD(XMM1, M((void*)&psOneOne));
DIVPD(XMM1, R(XMM0));
DIVPD(XMM1, divisor);
MOVAPD(fpr.R(d), XMM1);
fpr.UnlockAll();
}
Expand Down

0 comments on commit cdc27e4

Please sign in to comment.