DSP Jit code cleanup

Unit Test nr/dr/ir need AR0 not ACC0


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5364 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2010-04-14 06:19:07 +00:00
parent 0dc924efef
commit 26b082d384
2 changed files with 31 additions and 53 deletions

View File

@ -31,9 +31,6 @@ using namespace Gen;
// See http://code.google.com/p/dolphin-emu/source/detail?r=3125 // See http://code.google.com/p/dolphin-emu/source/detail?r=3125
void DSPEmitter::increment_addr_reg(int reg) void DSPEmitter::increment_addr_reg(int reg)
{ {
// PUSH(EAX);
// PUSH(ECX);
// u16 tmb = g_dsp.r[DSP_REG_WR0 + reg]; // u16 tmb = g_dsp.r[DSP_REG_WR0 + reg];
MOVZX(32, 16, EAX, M(&g_dsp.r[DSP_REG_WR0 + reg])); MOVZX(32, 16, EAX, M(&g_dsp.r[DSP_REG_WR0 + reg]));
@ -80,24 +77,17 @@ void DSPEmitter::increment_addr_reg(int reg)
// g_dsp.r[reg] = tmp; // g_dsp.r[reg] = tmp;
MOV(16, M(&g_dsp.r[reg]), R(ECX)); MOV(16, M(&g_dsp.r[reg]), R(ECX));
// POP(ECX);
// POP(EAX);
} }
// See http://code.google.com/p/dolphin-emu/source/detail?r=3125 // See http://code.google.com/p/dolphin-emu/source/detail?r=3125
void DSPEmitter::decrement_addr_reg(int reg) void DSPEmitter::decrement_addr_reg(int reg)
{ {
// PUSH(EAX);
// PUSH(ECX);
// s16 tmp = g_dsp.r[reg]; // s16 tmp = g_dsp.r[reg];
MOVZX(32, 16, EAX, M(&g_dsp.r[reg])); MOV(16, R(EAX), M(&g_dsp.r[reg]));
// if ((tmp & g_dsp.r[DSP_REG_WR0 + reg]) == 0) // if ((tmp & g_dsp.r[DSP_REG_WR0 + reg]) == 0)
MOV(16, R(ECX), R(EAX)); TEST(16, R(EAX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
AND(16, R(ECX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
// CMP(16, R(ECX), Imm8(0));
FixupBranch not_equal = J_CC(CC_NZ); FixupBranch not_equal = J_CC(CC_NZ);
// tmp |= g_dsp.r[DSP_REG_WR0 + reg]; // tmp |= g_dsp.r[DSP_REG_WR0 + reg];
@ -106,15 +96,12 @@ void DSPEmitter::decrement_addr_reg(int reg)
FixupBranch end = J(); FixupBranch end = J();
SetJumpTarget(not_equal); SetJumpTarget(not_equal);
// tmp--; // tmp--;
SUB(16, R(EAX), Imm8(1)); SUB(16, R(EAX), Imm16(1));
SetJumpTarget(end); SetJumpTarget(end);
// g_dsp.r[reg] = tmp; // g_dsp.r[reg] = tmp;
MOV(16, M(&g_dsp.r[reg]), R(EAX)); MOV(16, M(&g_dsp.r[reg]), R(EAX));
// POP(ECX);
// POP(EAX);
} }
// Increase addr register according to the correspond ix register // Increase addr register according to the correspond ix register
@ -122,35 +109,30 @@ void DSPEmitter::increase_addr_reg(int reg)
{ {
// s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg]; // s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg];
MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg])); MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg]));
XOR(32, R(ESI), R(ESI)); // i = 0
// if (value > 0) // if (value > 0)
CMP(16, R(EDX), Imm16(0)); CMP(32, R(EDX), Imm32(0));
//end is further away than 0x7f, needs a 6-byte jz //end is further away than 0x7f, needs a 6-byte jz
FixupBranch end = J_CC(CC_Z, true);
FixupBranch negValue = J_CC(CC_L); FixupBranch negValue = J_CC(CC_L);
FixupBranch end = J_CC(CC_Z, true);
// for (int i = 0; i < value; i++) // for (; value == 0; value--)
JumpTarget loop_pos = GetCodePtr(); JumpTarget loop_pos = GetCodePtr();
increment_addr_reg(reg); increment_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ SUB(32, R(EDX), Imm32(1)); // value--
CMP(32, R(ESI), R(EDX)); // i < value CMP(32, R(EDX), Imm32(0)); // value == 0
J_CC(CC_NE, loop_pos); J_CC(CC_NE, loop_pos);
FixupBranch posValue = J(); FixupBranch posValue = J();
SetJumpTarget(negValue); SetJumpTarget(negValue);
//abs == cdq; xor eax, edx; sub eax, edx
//we know its negative, and in that case edx is -1
XOR(32, R(EDX), Imm32(-1));
SUB(32, R(EDX), Imm32(-1));
// for (int i = 0; i < (int)(-value); i++) // for (; value == 0; value++)
JumpTarget loop_neg = GetCodePtr(); JumpTarget loop_neg = GetCodePtr();
decrement_addr_reg(reg); decrement_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ ADD(32, R(EDX), Imm32(1)); // value++
CMP(32, R(ESI), R(EDX)); // i < -value CMP(32, R(EDX), Imm32(0)); // value == 0
J_CC(CC_NE, loop_neg); J_CC(CC_NE, loop_neg);
SetJumpTarget(posValue); SetJumpTarget(posValue);
@ -162,34 +144,30 @@ void DSPEmitter::decrease_addr_reg(int reg)
{ {
// s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg]; // s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg];
MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg])); MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg]));
XOR(32, R(ESI), R(ESI)); // i = 0
// if (value > 0) // if (value > 0)
CMP(32, R(EDX), Imm32(0)); CMP(32, R(EDX), Imm32(0));
//end is further away than 0x7f, needs a 6-byte jz
FixupBranch end = J_CC(CC_Z, true); FixupBranch end = J_CC(CC_Z, true);
FixupBranch negValue = J_CC(CC_L); FixupBranch negValue = J_CC(CC_L);
// for (int i = 0; i < value; i++) // for (; value == 0; value--)
JumpTarget loop_pos = GetCodePtr(); JumpTarget loop_pos = GetCodePtr();
decrement_addr_reg(reg); decrement_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ SUB(32, R(EDX), Imm32(1)); // value--
CMP(32, R(ESI), R(EDX)); // i < value CMP(32, R(EDX), Imm32(0)); // value == 0
J_CC(CC_NE, loop_pos); J_CC(CC_NE, loop_pos);
FixupBranch posValue = J(); FixupBranch posValue = J();
SetJumpTarget(negValue); SetJumpTarget(negValue);
//abs == cdq; xor eax, edx; sub eax, edx
//we know its negative, and in that case edx is -1
XOR(32, R(EDX), Imm32(-1));
SUB(32, R(EDX), Imm32(-1));
// for (int i = 0; i < (int)(-value); i++) // for (; value == 0; value++)
JumpTarget loop_neg = GetCodePtr(); JumpTarget loop_neg = GetCodePtr();
increment_addr_reg(reg); increment_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ ADD(32, R(EDX), Imm32(1)); // value++
CMP(32, R(ESI), R(EDX)); // i < -value CMP(32, R(EDX), Imm32(0)); // value == 0
J_CC(CC_NE, loop_neg); J_CC(CC_NE, loop_neg);
SetJumpTarget(posValue); SetJumpTarget(posValue);

View File

@ -3,7 +3,7 @@
void nx_dr() void nx_dr()
{ {
DSPJitTester tester(0x8000, 0x0004); DSPJitTester tester(0x8000, 0x0004);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.TestAll(); tester.TestAll();
tester.Report(); tester.Report();
@ -12,7 +12,7 @@ void nx_dr()
void nx_ir() void nx_ir()
{ {
DSPJitTester tester(0x8000, 0x0008); DSPJitTester tester(0x8000, 0x0008);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.TestAll(); tester.TestAll();
tester.Report(); tester.Report();
@ -21,7 +21,7 @@ void nx_ir()
void nx_nr() void nx_nr()
{ {
DSPJitTester tester(0x8000, 0x000c); DSPJitTester tester(0x8000, 0x000c);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.AddTestData(DSP_REG_IX0); tester.AddTestData(DSP_REG_IX0);
tester.TestAll(true); tester.TestAll(true);
@ -31,7 +31,7 @@ void nx_nr()
void dar() void dar()
{ {
DSPJitTester tester(0x0004); DSPJitTester tester(0x0004);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.TestAll(); tester.TestAll();
tester.Report(); tester.Report();
@ -39,7 +39,7 @@ void dar()
void iar() void iar()
{ {
DSPJitTester tester(0x0008); DSPJitTester tester(0x0008);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.TestAll(); tester.TestAll();
tester.Report(); tester.Report();
@ -47,7 +47,7 @@ void iar()
void subarn() void subarn()
{ {
DSPJitTester tester(0x000c); DSPJitTester tester(0x000c);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.AddTestData(DSP_REG_IX0); tester.AddTestData(DSP_REG_IX0);
tester.TestAll(); tester.TestAll();
@ -56,7 +56,7 @@ void subarn()
void addarn() void addarn()
{ {
DSPJitTester tester(0x0010); DSPJitTester tester(0x0010);
tester.AddTestData(DSP_REG_ACC0); tester.AddTestData(DSP_REG_AR0);
tester.AddTestData(DSP_REG_WR0); tester.AddTestData(DSP_REG_WR0);
tester.AddTestData(DSP_REG_IX0); tester.AddTestData(DSP_REG_IX0);
tester.TestAll(); tester.TestAll();