add tw/twi to Jit64

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6869 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2011-01-17 04:29:23 +00:00
parent df3aecafef
commit d89d730778
4 changed files with 66 additions and 4 deletions

View File

@ -40,7 +40,7 @@ static GekkoOPTemplate primarytable[] =
{1, Interpreter::HLEFunction, {"HLEFunction", OPTYPE_SYSTEM, FL_ENDBLOCK}},
{2, Interpreter::CompiledBlock, {"DynaBlock", OPTYPE_SYSTEM, 0}},
{3, Interpreter::twi, {"twi", OPTYPE_SYSTEM, 0}},
{3, Interpreter::twi, {"twi", OPTYPE_SYSTEM, FL_ENDBLOCK}},
{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}},
@ -278,7 +278,7 @@ static GekkoOPTemplate table31[] =
{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}},
{4, Interpreter::tw, {"tw", OPTYPE_SYSTEM, FL_ENDBLOCK, 1}},
{598, Interpreter::sync, {"sync", OPTYPE_SYSTEM, 0, 2}},
{982, Interpreter::icbi, {"icbi", OPTYPE_SYSTEM, FL_ENDBLOCK, 3}},

View File

@ -252,6 +252,8 @@ public:
void subfmex(UGeckoInstruction inst);
void subfzex(UGeckoInstruction inst);
void twx(UGeckoInstruction inst);
void lXXx(UGeckoInstruction inst);
void stXx(UGeckoInstruction inst);

View File

@ -54,7 +54,7 @@ static GekkoOPTemplate primarytable[] =
{1, &Jit64::HLEFunction}, //"HLEFunction", OPTYPE_SYSTEM, FL_ENDBLOCK}},
{2, &Jit64::Default}, //"DynaBlock", OPTYPE_SYSTEM, 0}},
{3, &Jit64::Default}, //"twi", OPTYPE_SYSTEM, 0}},
{3, &Jit64::twx}, //"twi", OPTYPE_SYSTEM, FL_ENDBLOCK}},
{17, &Jit64::sc}, //"sc", OPTYPE_SYSTEM, FL_ENDBLOCK, 1}},
{7, &Jit64::mulli}, //"mulli", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_RC_BIT, 2}},
@ -291,7 +291,7 @@ static GekkoOPTemplate table31[] =
{595, &Jit64::Default}, //"mfsr", OPTYPE_SYSTEM, FL_OUT_D, 2}},
{659, &Jit64::Default}, //"mfsrin", OPTYPE_SYSTEM, FL_OUT_D, 2}},
{4, &Jit64::Default}, //"tw", OPTYPE_SYSTEM, 0, 1}},
{4, &Jit64::twx}, //"tw", OPTYPE_SYSTEM, FL_ENDBLOCK, 1}},
{598, &Jit64::DoNothing}, //"sync", OPTYPE_SYSTEM, 0, 2}},
{982, &Jit64::icbi}, //"icbi", OPTYPE_SYSTEM, FL_ENDBLOCK, 3}},

View File

@ -1490,3 +1490,63 @@ void Jit64::cntlzwx(UGeckoInstruction inst)
// TODO: Check PPC manual too
}
}
void Jit64::twx(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(Integer)
s32 a = inst.RA;
s32 TO = inst.TO;
gpr.Flush(FLUSH_ALL);
fpr.Flush(FLUSH_ALL);
if (inst.OPCD == 3) // twi
CMP(32, gpr.R(a), gpr.R(inst.RB));
else // tw
CMP(32, gpr.R(a), Imm32((s32)(s16)inst.SIMM_16));
FixupBranch al = J_CC(CC_L);
FixupBranch ag = J_CC(CC_G);
FixupBranch ae = J_CC(CC_Z);
// FIXME: will never be reached. But also no known code uses it...
FixupBranch ll = J_CC(CC_NO);
FixupBranch lg = J_CC(CC_O);
SetJumpTarget(al);
TEST(8, R(BL), Imm8(16));
FixupBranch exit1 = J_CC(CC_NZ);
FixupBranch take1 = J();
SetJumpTarget(ag);
TEST(8, R(BL), Imm8(8));
FixupBranch exit2 = J_CC(CC_NZ);
FixupBranch take2 = J();
SetJumpTarget(ae);
TEST(8, R(BL), Imm8(4));
FixupBranch exit3 = J_CC(CC_NZ);
FixupBranch take3 = J();
SetJumpTarget(ll);
TEST(8, R(BL), Imm8(2));
FixupBranch exit4 = J_CC(CC_NZ);
FixupBranch take4 = J();
SetJumpTarget(lg);
TEST(8, R(BL), Imm8(1));
FixupBranch exit5 = J_CC(CC_NZ);
FixupBranch take5 = J();
SetJumpTarget(take1);
SetJumpTarget(take2);
SetJumpTarget(take3);
SetJumpTarget(take4);
SetJumpTarget(take5);
LOCK();
OR(32, M((void *)&PowerPC::ppcState.Exceptions), Imm32(EXCEPTION_PROGRAM));
WriteExceptionExit();
SetJumpTarget(exit1);
SetJumpTarget(exit2);
SetJumpTarget(exit3);
SetJumpTarget(exit4);
SetJumpTarget(exit5);
}