* Optimised out the R11 ImmPtr instructions
* Made the whitespacing a little more consistent
* Disabled block linking while it is being reworked

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6688 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2010-12-30 00:10:18 +00:00
parent 98752f2a1e
commit 469e81e2fd
9 changed files with 362 additions and 307 deletions

View File

@ -33,6 +33,7 @@ using namespace Gen;
const u8 *stubEntryPoint;
u16 blocksCompiled;
u16 unresolvedCalls;
u16 unresolvedCallsThisBlock;
DSPEmitter::DSPEmitter() : storeIndex(-1), storeIndex2(-1)
{
@ -127,7 +128,9 @@ void DSPEmitter::Default(UDSPInstruction inst)
}
// Fall back to interpreter
SaveDSPRegs();
ABI_CallFunctionC16((void*)opTable[inst]->intFunc, inst);
LoadDSPRegs();
}
void DSPEmitter::EmitInstruction(UDSPInstruction inst)
@ -140,7 +143,9 @@ void DSPEmitter::EmitInstruction(UDSPInstruction inst)
if ((inst >> 12) == 0x3) {
if (! extOpTable[inst & 0x7F]->jitFunc) {
// Fall back to interpreter
SaveDSPRegs();
ABI_CallFunctionC16((void*)extOpTable[inst & 0x7F]->intFunc, inst);
LoadDSPRegs();
INFO_LOG(DSPLLE, "Instruction not JITed(ext part): %04x\n", inst);
ext_is_jit = false;
} else {
@ -150,7 +155,9 @@ void DSPEmitter::EmitInstruction(UDSPInstruction inst)
} else {
if (!extOpTable[inst & 0xFF]->jitFunc) {
// Fall back to interpreter
SaveDSPRegs();
ABI_CallFunctionC16((void*)extOpTable[inst & 0xFF]->intFunc, inst);
LoadDSPRegs();
INFO_LOG(DSPLLE, "Instruction not JITed(ext part): %04x\n", inst);
ext_is_jit = false;
} else {
@ -175,7 +182,9 @@ void DSPEmitter::EmitInstruction(UDSPInstruction inst)
if (!ext_is_jit) {
//need to call the online cleanup function because
//the writeBackLog gets populated at runtime
SaveDSPRegs();
ABI_CallFunction((void*)::applyWriteBackLog);
LoadDSPRegs();
} else {
popExtValueToReg();
}
@ -189,8 +198,7 @@ void DSPEmitter::unknown_instruction(UDSPInstruction inst)
void DSPEmitter::ClearCallFlag()
{
DSPAnalyzer::code_flags[startAddr] &= ~DSPAnalyzer::CODE_CALL;
--unresolvedCalls;
--unresolvedCallsThisBlock;
}
void DSPEmitter::Compile(int start_addr)
@ -198,11 +206,12 @@ void DSPEmitter::Compile(int start_addr)
// Remember the current block address for later
startAddr = start_addr;
blocksCompiled++;
unresolvedCallsThisBlock = 0;
// If the number of unresolved calls exceeds 50, there is a critical
// If the number of unresolved calls exceeds 8, there is a critical
// block that probably cannot be resolved. If this occurs, quit linking
// blocks. Currently occurs in the zelda ucode.
if (unresolvedCalls <= 50)
if (unresolvedCalls <= 8)
{
// After every 10 blocks, clear out the blocks that have unresolved
// calls, and reattempt relinking.
@ -219,6 +228,7 @@ void DSPEmitter::Compile(int start_addr)
}
// Reset and reattempt relinking
blocksCompiled = 0;
unresolvedCalls = 0;
}
}
@ -269,6 +279,8 @@ void DSPEmitter::Compile(int start_addr)
bool fixup_pc = false;
blockSize[start_addr] = 0;
LoadDSPRegs();
while (compilePC < start_addr + MAX_BLOCK_SIZE)
{
checkExceptions(blockSize[start_addr]);
@ -277,10 +289,11 @@ void DSPEmitter::Compile(int start_addr)
const DSPOPCTemplate *opcode = GetOpTemplate(inst);
// Scan for CALL's to delay block link. TODO: Scan for J_CC after it is jitted.
if (opcode->jitFunc && (opcode->opcode >= 0x02b0 && opcode->opcode <= 0x02bf))
if (opcode->jitFunc &&
((opcode->opcode >= 0x0290 && opcode->opcode <= 0x029f) ||
(opcode->opcode >= 0x02b0 && opcode->opcode <= 0x02bf)))
{
DSPAnalyzer::code_flags[start_addr] |= DSPAnalyzer::CODE_CALL;
++unresolvedCalls;
++unresolvedCallsThisBlock;
}
EmitInstruction(inst);
@ -398,8 +411,17 @@ void DSPEmitter::Compile(int start_addr)
// Mark this block as a linkable destination if it does not contain
// any unresolved CALL's
if (!(DSPAnalyzer::code_flags[start_addr] & DSPAnalyzer::CODE_CALL))
if (unresolvedCallsThisBlock == 0)
{
DSPAnalyzer::code_flags[start_addr] &= ~DSPAnalyzer::CODE_CALL;
blockLinks[start_addr] = (CompiledCode)blockLinkEntry;
}
else
{
DSPAnalyzer::code_flags[start_addr] |= DSPAnalyzer::CODE_CALL;
blockLinks[start_addr] = 0;
++unresolvedCalls;
}
if (blockSize[start_addr] == 0)
{
@ -409,6 +431,8 @@ void DSPEmitter::Compile(int start_addr)
blockSize[start_addr] = 1;
}
SaveDSPRegs();
// ABI_RestoreStack(0);
ABI_PopAllCalleeSavedRegsAndAdjustStack();
if (DSPAnalyzer::code_flags[start_addr] & DSPAnalyzer::CODE_IDLE_SKIP)
@ -459,8 +483,8 @@ void DSPEmitter::CompileDispatcher()
#ifdef _M_IX86
TEST(8, M(&g_dsp.cr), Imm8(CR_HALT));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.cr));
TEST(8, MatR(R11), Imm8(CR_HALT));
MOV(64, R(RAX), ImmPtr(&g_dsp.cr));
TEST(8, MatR(RAX), Imm8(CR_HALT));
#endif
FixupBranch halt = J_CC(CC_NE);

View File

@ -265,6 +265,9 @@ private:
// Counts down.
// int cycles;
void LoadDSPRegs();
void SaveDSPRegs();
void Update_SR_Register(Gen::X64Reg val = Gen::EAX);
void ToMask(Gen::X64Reg value_reg = Gen::EDI);

View File

@ -98,7 +98,7 @@ void DSPEmitter::andcf(const UDSPInstruction opc)
// g_dsp.r.sr &= ~SR_LOGIC_ZERO;
AND(16, R(RAX), Imm16(imm));
CMP(16, R(RAX), Imm16(imm));
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
FixupBranch notLogicZero = J_CC(CC_NE);
OR(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)), Imm16(SR_LOGIC_ZERO));
FixupBranch exit = J();
@ -135,7 +135,7 @@ void DSPEmitter::andf(const UDSPInstruction opc)
// else
// g_dsp.r.sr &= ~SR_LOGIC_ZERO;
TEST(16, R(RAX), Imm16(imm));
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
FixupBranch notLogicZero = J_CC(CC_NE);
OR(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)), Imm16(SR_LOGIC_ZERO));
FixupBranch exit = J();
@ -606,7 +606,7 @@ void DSPEmitter::addr(const UDSPInstruction opc)
u8 sreg = ((opc >> 9) & 0x3) + DSP_REG_AXL0;
u16 *sregp = reg_ptr(sreg);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, RCX);
MOV(64, R(RAX), R(RCX));
@ -941,7 +941,7 @@ void DSPEmitter::subr(const UDSPInstruction opc)
get_long_acc(dreg, RCX);
MOV(64, R(RAX), R(RCX));
// s64 ax = (s16)g_dsp.r[sreg];
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RDX, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
// ax <<= 16;
SHL(64, R(RDX), Imm8(16));
@ -1213,7 +1213,7 @@ void DSPEmitter::movr(const UDSPInstruction opc)
u16 *sregp = reg_ptr(sreg);
// s64 acc = (s16)g_dsp.r[sreg];
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RAX, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
// acc <<= 16;
SHL(64, R(RAX), Imm8(16));

View File

@ -168,29 +168,29 @@ void r_jcc(const UDSPInstruction opc, DSPEmitter& emitter)
#ifdef _M_IX86 // All32
emitter.MOV(16, M(&(g_dsp.pc)), Imm16(dest));
// Jump directly to the called block if it has already been compiled. (Not working)
//if (emitter.blockLinks[dest])
//{
// // Check if we have enough cycles to execute the next block
// emitter.MOV(16, R(ESI), M(&cyclesLeft));
// emitter.CMP(16, R(ESI),Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
// FixupBranch notEnoughCycles = emitter.J_CC(CC_BE);
// Jump directly to the called block if it has already been compiled.
if (emitter.blockLinks[dest])
{
// Check if we have enough cycles to execute the next block
emitter.MOV(16, R(ESI), M(&cyclesLeft));
emitter.CMP(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
FixupBranch notEnoughCycles = emitter.J_CC(CC_BE);
// emitter.SUB(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr]));
// emitter.MOV(16, M(&cyclesLeft), R(ESI));
// emitter.JMPptr(M(&emitter.blockLinks[dest]));
// emitter.ClearCallFlag();
emitter.SUB(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr]));
emitter.MOV(16, M(&cyclesLeft), R(ESI));
emitter.JMPptr(M(&emitter.blockLinks[dest]));
emitter.ClearCallFlag();
// emitter.SetJumpTarget(notEnoughCycles);
//}
emitter.SetJumpTarget(notEnoughCycles);
}
#else
emitter.MOV(64, R(RAX), ImmPtr(&(g_dsp.pc)));
emitter.MOV(16, MatR(RAX), Imm16(dest));
// Jump directly to the next block if it has already been compiled. (Not working)
//if (emitter.blockLinks[dest])
//{
// // Check if we have enough cycles to execute the next block
// Jump directly to the next block if it has already been compiled.
if (emitter.blockLinks[dest])
{
// Check if we have enough cycles to execute the next block
//emitter.MOV(64, R(R12), ImmPtr(&cyclesLeft));
//emitter.MOV(16, R(RAX), MatR(R12));
//emitter.CMP(16, R(RAX), Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
@ -204,7 +204,7 @@ void r_jcc(const UDSPInstruction opc, DSPEmitter& emitter)
//emitter.ClearCallFlag();
//emitter.SetJumpTarget(notEnoughCycles);
//}
}
#endif
WriteBranchExit(emitter);
}
@ -271,16 +271,16 @@ void r_call(const UDSPInstruction opc, DSPEmitter& emitter)
if (emitter.blockLinks[dest])
{
// Check if we have enough cycles to execute the next block
emitter.MOV(16, R(ESI), M(&cyclesLeft));
emitter.CMP(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
FixupBranch notEnoughCycles = emitter.J_CC(CC_BE);
//emitter.MOV(16, R(ESI), M(&cyclesLeft));
//emitter.CMP(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
//FixupBranch notEnoughCycles = emitter.J_CC(CC_BE);
emitter.SUB(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr]));
emitter.MOV(16, M(&cyclesLeft), R(ESI));
emitter.JMPptr(M(&emitter.blockLinks[dest]));
emitter.ClearCallFlag();
//emitter.SUB(16, R(ESI), Imm16(emitter.blockSize[emitter.startAddr]));
//emitter.MOV(16, M(&cyclesLeft), R(ESI));
//emitter.JMPptr(M(&emitter.blockLinks[dest]));
//emitter.ClearCallFlag();
emitter.SetJumpTarget(notEnoughCycles);
//emitter.SetJumpTarget(notEnoughCycles);
}
#else
emitter.MOV(64, R(RAX), ImmPtr(&(g_dsp.pc)));
@ -427,7 +427,7 @@ void DSPEmitter::rti(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.sr), R(DX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)), R(DX));
#endif
// g_dsp.pc = dsp_reg_load_stack(DSP_STACK_C);
@ -473,7 +473,7 @@ void DSPEmitter::HandleLoop()
MOVZX(32, 16, EAX, M(&g_dsp.r.st[2]));
MOVZX(32, 16, ECX, M(&g_dsp.r.st[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(32, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[2])));
MOVZX(32, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[3])));
#endif
@ -529,7 +529,7 @@ void DSPEmitter::loop(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EDX, M(regp));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(32, 16, EDX, MDisp(R11, PtrOffset(regp, &g_dsp.r)));
#endif
u16 loop_pc = compilePC + 1;
@ -600,7 +600,7 @@ void DSPEmitter::bloop(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EDX, M(regp));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(32, 16, EDX, MDisp(R11, PtrOffset(regp, &g_dsp.r)));
#endif
u16 loop_pc = dsp_imem_read(compilePC + 1);

View File

@ -98,7 +98,7 @@ void DSPEmitter::s(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
MOVZX(32, 16, ECX, M(sregp));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOVZX(64, 16, ECX, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
#endif
@ -133,7 +133,7 @@ void DSPEmitter::sn(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
MOVZX(32, 16, ECX, M(sregp));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOVZX(64, 16, ECX, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
#endif
@ -160,8 +160,8 @@ void DSPEmitter::l(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOV(16, R(EAX), M(&g_dsp.r.sr));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r.sr));
MOV(16, R(EAX), MatR(R11));
MOV(64, R(RAX), ImmPtr(&g_dsp.r.sr));
MOV(16, R(RAX), MatR(RAX));
#endif
SHL(32, R(EAX), Imm8(16));
OR(32, R(EBX), R(EAX));
@ -189,8 +189,8 @@ void DSPEmitter::ln(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOV(16, R(EAX), M(&g_dsp.r.sr));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r.sr));
MOV(16, R(EAX), MatR(R11));
MOV(64, R(RAX), ImmPtr(&g_dsp.r.sr));
MOV(16, R(RAX), MatR(RAX));
#endif
SHL(32, R(EAX), Imm8(16));
OR(32, R(EBX), R(EAX));
@ -212,7 +212,7 @@ void DSPEmitter::ls(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[3]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -239,7 +239,7 @@ void DSPEmitter::lsn(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[3]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -265,7 +265,7 @@ void DSPEmitter::lsm(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[3]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -292,7 +292,7 @@ void DSPEmitter::lsnm(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[3]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -317,7 +317,7 @@ void DSPEmitter::sl(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[0]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[0])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -343,7 +343,7 @@ void DSPEmitter::sln(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[0]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[0])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -369,7 +369,7 @@ void DSPEmitter::slm(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[0]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[0])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -395,7 +395,7 @@ void DSPEmitter::slnm(const UDSPInstruction opc)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[0]));
MOVZX(32, 16, ECX, M(&g_dsp.r.ac[sreg].m));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[0])));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
#endif
@ -431,7 +431,7 @@ void DSPEmitter::ld(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[sreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -455,16 +455,16 @@ void DSPEmitter::ld(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[dreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
SHR(16, R(ESI), Imm8(10));
SHR(16, R(EDI), Imm8(10));
CMP(16, R(ESI), R(EDI));
FixupBranch not_equal = J_CC(CC_NE);
FixupBranch not_equal = J_CC(CC_NE, true);
pushExtValueFromMem2(rreg + DSP_REG_AXL0, dreg);
FixupBranch after = J(); // else
FixupBranch after = J(true); // else
SetJumpTarget(not_equal);
pushExtValueFromMem2(rreg + DSP_REG_AXL0, DSP_REG_AR3);
SetJumpTarget(after);
@ -491,7 +491,7 @@ void DSPEmitter::ldn(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[sreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -514,7 +514,7 @@ void DSPEmitter::ldn(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[dreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -550,7 +550,7 @@ void DSPEmitter::ldm(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[sreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -573,7 +573,7 @@ void DSPEmitter::ldm(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[dreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -609,7 +609,7 @@ void DSPEmitter::ldnm(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[sreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -632,7 +632,7 @@ void DSPEmitter::ldnm(const UDSPInstruction opc)
MOV(16, R(ESI), M(&g_dsp.r.ar[dreg]));
MOV(16, R(EDI), M(&g_dsp.r.ar[3]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(ESI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
MOV(16, R(EDI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[3])));
#endif
@ -671,7 +671,7 @@ void DSPEmitter::pushExtValueFromMem(u16 dreg, u16 sreg) {
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[sreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
#endif
dmem_read();
@ -685,7 +685,7 @@ void DSPEmitter::pushExtValueFromMem2(u16 dreg, u16 sreg) {
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[sreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, ECX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[sreg])));
#endif
dmem_read();
@ -708,7 +708,7 @@ void DSPEmitter::popExtValueToReg() {
#ifdef _M_IX86 // All32
MOV(16, M(dregp), R(EBX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, PtrOffset(dregp, &g_dsp.r)), R(EBX));
#endif
if (storeIndex >= DSP_REG_ACM0 && storeIndex2 == -1) {
@ -744,7 +744,7 @@ void DSPEmitter::popExtValueToReg() {
#ifdef _M_IX86 // All32
MOV(16, M(dregp), R(EBX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, PtrOffset(dregp, &g_dsp.r)), R(EBX));
#endif
}
@ -767,10 +767,18 @@ void DSPEmitter::zeroWriteBackLog(const UDSPInstruction opc)
if ((opc >> 12) == 0x3) {
if (! extOpTable[opc & 0x7F]->jitFunc)
{
SaveDSPRegs();
ABI_CallFunction((void*)::zeroWriteBackLog);
LoadDSPRegs();
}
} else {
if (! extOpTable[opc & 0xFF]->jitFunc)
{
SaveDSPRegs();
ABI_CallFunction((void*)::zeroWriteBackLog);
LoadDSPRegs();
}
}
return;
}

View File

@ -40,7 +40,7 @@ void DSPEmitter::srs(const UDSPInstruction opc)
MOVZX(32, 16, ECX, M(regp));
MOVZX(32, 8, EAX, M(&g_dsp.r.cr));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RCX, MDisp(R11, PtrOffset(regp, &g_dsp.r)));
MOVZX(64, 8, RAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, cr)));
#endif
@ -66,12 +66,12 @@ void DSPEmitter::lrs(const UDSPInstruction opc)
dmem_read();
MOV(16, M(regp), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 8, RCX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, cr)));
SHL(16, R(ECX), Imm8(8));
OR(8, R(ECX), Imm8(opc & 0xFF));
dmem_read();
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, PtrOffset(regp, &g_dsp.r)), R(RAX));
#endif
dsp_conditional_extend_accum(reg);
@ -197,7 +197,7 @@ void DSPEmitter::srr(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
#endif
dmem_write();
@ -217,7 +217,7 @@ void DSPEmitter::srrd(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
#endif
dmem_write();
@ -238,7 +238,7 @@ void DSPEmitter::srri(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
#endif
dmem_write();
@ -259,7 +259,7 @@ void DSPEmitter::srrn(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[dreg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[dreg])));
#endif
dmem_write();
@ -278,14 +278,14 @@ void DSPEmitter::ilrr(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RCX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
#endif
imem_read();
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[dreg].m), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[dreg].m)), R(RAX));
#endif
dsp_conditional_extend_accum(dreg);
@ -303,14 +303,14 @@ void DSPEmitter::ilrrd(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RCX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
#endif
imem_read();
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[dreg].m), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[dreg].m)), R(RAX));
#endif
dsp_conditional_extend_accum(dreg);
@ -329,14 +329,14 @@ void DSPEmitter::ilrri(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RCX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
#endif
imem_read();
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[dreg].m), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[dreg].m)), R(RAX));
#endif
dsp_conditional_extend_accum(dreg);
@ -356,14 +356,14 @@ void DSPEmitter::ilrrn(const UDSPInstruction opc)
#ifdef _M_IX86 // All32
MOVZX(32, 16, ECX, M(&g_dsp.r.ar[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(64, 16, RCX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
#endif
imem_read();
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[dreg].m), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[dreg].m)), R(RAX));
#endif
dsp_conditional_extend_accum(dreg);

View File

@ -52,7 +52,7 @@ void DSPEmitter::dsp_reg_stack_push(int stack_reg)
MOVZX(32, 8, EAX, R(AL));
MOV(16, MComplex(EAX, EAX, 1, (u32)&g_dsp.reg_stack[stack_reg][0]), R(CX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(CX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[stack_reg])));
MOVZX(64, 8, RAX, R(AL));
MOV(64, R(R10), ImmPtr(&g_dsp.reg_stack[stack_reg][0]));
@ -82,7 +82,7 @@ void DSPEmitter::dsp_reg_stack_pop(int stack_reg)
MOVZX(64, 8, RAX, R(AL));
MOV(64, R(R10), ImmPtr(&g_dsp.reg_stack[stack_reg][0]));
MOV(16, R(CX), MComplex(R10, RAX, 2, 0));
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[stack_reg])), R(CX));
#endif
@ -109,7 +109,7 @@ void DSPEmitter::dsp_reg_store_stack(int stack_reg, Gen::X64Reg host_sreg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.st[stack_reg]), R(EDX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[stack_reg])), R(EDX));
#endif
}
@ -120,7 +120,7 @@ void DSPEmitter::dsp_reg_load_stack(int stack_reg, Gen::X64Reg host_dreg)
#ifdef _M_IX86 // All32
MOV(16, R(EDX), M(&g_dsp.r.st[stack_reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(EDX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[stack_reg])));
#endif
dsp_reg_stack_pop(stack_reg);
@ -136,7 +136,7 @@ void DSPEmitter::dsp_reg_store_stack_imm(int stack_reg, u16 val)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.st[stack_reg]), Imm16(val));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, st[stack_reg])), Imm16(val));
#endif
}
@ -152,7 +152,7 @@ void DSPEmitter::dsp_op_write_reg(int reg, Gen::X64Reg host_sreg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[reg-DSP_REG_ACH0].h), R(host_sreg));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[reg-DSP_REG_ACH0].h)), R(host_sreg));
#endif
break;
@ -171,7 +171,7 @@ void DSPEmitter::dsp_op_write_reg(int reg, Gen::X64Reg host_sreg)
#ifdef _M_IX86 // All32
MOV(16, M(regp), R(host_sreg));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, PtrOffset(regp, &g_dsp.r)), R(host_sreg));
#endif
break;
@ -189,7 +189,7 @@ void DSPEmitter::dsp_op_write_reg_imm(int reg, u16 val)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ac[reg-DSP_REG_ACH0].h), Imm16((u16)(s16)(s8)(u8)val));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[reg-DSP_REG_ACH0].h)), Imm16((u16)(s16)(s8)(u8)val));
#endif
break;
@ -208,7 +208,7 @@ void DSPEmitter::dsp_op_write_reg_imm(int reg, u16 val)
#ifdef _M_IX86 // All32
MOV(16, M(regp), Imm16(val));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, PtrOffset(regp, &g_dsp.r)), Imm16(val));
#endif
break;
@ -226,7 +226,7 @@ void DSPEmitter::dsp_conditional_extend_accum(int reg)
#ifdef _M_IX86 // All32
MOV(16, R(EAX), M(&g_dsp.r.sr));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(EAX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)));
#endif
TEST(16, R(EAX), Imm16(SR_40_MODE_BIT));
@ -268,7 +268,7 @@ void DSPEmitter::dsp_conditional_extend_accum_imm(int reg, u16 val)
#ifdef _M_IX86 // All32
MOV(16, R(EAX), M(&g_dsp.r.sr));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(EAX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)));
#endif
TEST(16, R(EAX), Imm16(SR_40_MODE_BIT));
@ -310,7 +310,7 @@ void DSPEmitter::dsp_op_read_reg(int reg, Gen::X64Reg host_dreg)
#ifdef _M_IX86 // All32
MOV(16, R(host_dreg), M(regp));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(host_dreg), MDisp(R11, PtrOffset(regp, &g_dsp.r)));
#endif
}
@ -427,7 +427,7 @@ void DSPEmitter::setCompileSR(u16 bit) {
#ifdef _M_IX86 // All32
OR(16, M(&g_dsp.r.sr), Imm16(bit));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
OR(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)), Imm16(bit));
#endif
@ -440,7 +440,7 @@ void DSPEmitter::clrCompileSR(u16 bit) {
#ifdef _M_IX86 // All32
AND(16, M(&g_dsp.r.sr), Imm16(~bit));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
AND(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, sr)), Imm16(~bit));
#endif

View File

@ -156,7 +156,7 @@ void DSPEmitter::clrp(const UDSPInstruction opc)
{
#ifdef _M_X64
// g_dsp.r[DSP_REG_PRODL] = 0x0000;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.l)), Imm16(0x0000));
// g_dsp.r[DSP_REG_PRODM] = 0xfff0;
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.m)), Imm16(0xfff0));
@ -317,7 +317,7 @@ void DSPEmitter::mulaxh(const UDSPInstruction opc)
{
#ifdef _M_X64
// s64 prod = dsp_multiply(dsp_get_ax_h(0), dsp_get_ax_h(0));
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[0].h)));
MOV(64, R(RDI), R(RSI));
multiply();
@ -340,7 +340,7 @@ void DSPEmitter::mul(const UDSPInstruction opc)
u8 sreg = (opc >> 11) & 0x1;
// u16 axl = dsp_get_ax_l(sreg);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[sreg].l)));
// u16 axh = dsp_get_ax_h(sreg);
MOVSX(64, 16, RDI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[sreg].h)));
@ -464,7 +464,7 @@ void DSPEmitter::mulx(const UDSPInstruction opc)
u16 *sregp = reg_ptr(DSP_REG_AXL0 + sreg*2);
u16 *tregp = reg_ptr(DSP_REG_AXL1 + treg*2);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0);
MOVSX(64, 16, RSI, MDisp(R11, PtrOffset(sregp,&g_dsp.r)));
// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1);
@ -611,7 +611,7 @@ void DSPEmitter::mulc(const UDSPInstruction opc)
u8 sreg = (opc >> 12) & 0x1;
// u16 accm = dsp_get_acc_m(sreg);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, ESI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
// u16 axh = dsp_get_ax_h(treg);
MOVSX(64, 16, EDI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[treg].h)));
@ -720,7 +720,7 @@ void DSPEmitter::mulcmvz(const UDSPInstruction opc)
u8 treg = (opc >> 11) & 0x1;
u8 sreg = (opc >> 12) & 0x1;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// s64 acc = dsp_get_long_prod_round_prodl();
get_long_prod_round_prodl();
PUSH(64, R(RAX));
@ -760,7 +760,7 @@ void DSPEmitter::maddx(const UDSPInstruction opc)
u16 *sregp = reg_ptr(DSP_REG_AXL0 + sreg*2);
u16 *tregp = reg_ptr(DSP_REG_AXL1 + treg*2);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0);
MOVSX(64, 16, RSI, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1);
@ -787,7 +787,7 @@ void DSPEmitter::msubx(const UDSPInstruction opc)
u16 *sregp = reg_ptr(DSP_REG_AXL0 + sreg*2);
u16 *tregp = reg_ptr(DSP_REG_AXL1 + treg*2);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0);
MOVSX(64, 16, RSI, MDisp(R11, PtrOffset(sregp, &g_dsp.r)));
// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1);
@ -812,7 +812,7 @@ void DSPEmitter::maddc(const UDSPInstruction opc)
u8 treg = (opc >> 8) & 0x1;
u8 sreg = (opc >> 9) & 0x1;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// u16 accm = dsp_get_acc_m(sreg);
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
// u16 axh = dsp_get_ax_h(treg);
@ -838,7 +838,7 @@ void DSPEmitter::msubc(const UDSPInstruction opc)
u8 sreg = (opc >> 9) & 0x1;
// u16 accm = dsp_get_acc_m(sreg);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[sreg].m)));
// u16 axh = dsp_get_ax_h(treg);
MOVSX(64, 16, RDI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[treg].h)));
@ -861,7 +861,7 @@ void DSPEmitter::madd(const UDSPInstruction opc)
#ifdef _M_X64
u8 sreg = (opc >> 8) & 0x1;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
// u16 axl = dsp_get_ax_l(sreg);
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[sreg].l)));
// u16 axh = dsp_get_ax_h(sreg);
@ -886,7 +886,7 @@ void DSPEmitter::msub(const UDSPInstruction opc)
u8 sreg = (opc >> 8) & 0x1;
//
// u16 axl = dsp_get_ax_l(sreg);
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, RSI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[sreg].l)));
// u16 axh = dsp_get_ax_h(sreg);
MOVSX(64, 16, RDI, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[sreg].h)));

View File

@ -80,7 +80,7 @@ void DSPEmitter::increment_addr_reg(int reg)
MOVZX(32, 16, EAX, M(&g_dsp.r.ar[reg]));
MOV(16, R(DX), M(&g_dsp.r.wr[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVZX(32, 16, EAX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
MOV(16, R(DX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, wr[reg])));
#endif
@ -104,7 +104,7 @@ void DSPEmitter::increment_addr_reg(int reg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ar[reg]), R(AX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])), R(AX));
#endif
}
@ -129,7 +129,7 @@ void DSPEmitter::decrement_addr_reg(int reg)
MOV(16, R(AX), M(&g_dsp.r.ar[reg]));
MOVZX(32, 16, EDX, M(&g_dsp.r.wr[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(AX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
MOVZX(32, 16, EDX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, wr[reg])));
#endif
@ -160,7 +160,7 @@ void DSPEmitter::decrement_addr_reg(int reg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ar[reg]), R(AX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])), R(AX));
#endif
}
@ -193,7 +193,7 @@ void DSPEmitter::increase_addr_reg(int reg)
MOV(16, R(AX), M(&g_dsp.r.ar[reg]));
MOVZX(32, 16, EDX, M(&g_dsp.r.wr[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(SI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ix[reg])));
MOV(16, R(AX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
MOVZX(32, 16, EDX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, wr[reg])));
@ -247,7 +247,7 @@ void DSPEmitter::increase_addr_reg(int reg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ar[reg]), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])), R(EAX));
#endif
}
@ -280,7 +280,7 @@ void DSPEmitter::decrease_addr_reg(int reg)
MOV(16, R(AX), M(&g_dsp.r.ar[reg]));
MOVZX(32, 16, EDX, M(&g_dsp.r.wr[reg]));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, R(SI), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ix[reg])));
MOV(16, R(AX), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])));
MOVZX(32, 16, EDX, MDisp(R11, STRUCT_OFFSET(g_dsp.r, wr[reg])));
@ -331,7 +331,7 @@ void DSPEmitter::decrease_addr_reg(int reg)
#ifdef _M_IX86 // All32
MOV(16, M(&g_dsp.r.ar[reg]), R(EAX));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ar[reg])), R(EAX));
#endif
}
@ -359,7 +359,9 @@ void DSPEmitter::dmem_write()
// else if (saddr == 0xf)
SetJumpTarget(ifx);
// Does it mean gdsp_ifx_write needs u32 rather than u16?
SaveDSPRegs();
ABI_CallFunctionRR((void *)gdsp_ifx_write, EAX, ECX);
LoadDSPRegs();
SetJumpTarget(end);
}
@ -379,7 +381,9 @@ void DSPEmitter::dmem_write_imm(u16 address)
case 0xf: // Fxxx HW regs
MOV(16, R(EAX), Imm16(address));
SaveDSPRegs();
ABI_CallFunctionRR((void *)gdsp_ifx_write, EAX, ECX);
LoadDSPRegs();
break;
default: // Unmapped/non-existing memory
@ -461,8 +465,9 @@ void DSPEmitter::dmem_read()
SetJumpTarget(ifx);
// else if (saddr == 0xf)
// return gdsp_ifx_read(addr);
SaveDSPRegs();
ABI_CallFunctionR((void *)gdsp_ifx_read, ECX);
LoadDSPRegs();
SetJumpTarget(end);
SetJumpTarget(end2);
}
@ -490,7 +495,9 @@ void DSPEmitter::dmem_read_imm(u16 address)
break;
case 0xf: // Fxxx HW regs
SaveDSPRegs();
ABI_CallFunctionC16((void *)gdsp_ifx_read, address);
LoadDSPRegs();
break;
default: // Unmapped/non-existing memory
@ -504,7 +511,7 @@ void DSPEmitter::get_long_prod(X64Reg long_prod)
{
#ifdef _M_X64
#if 0
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
//s64 val = (s8)(u8)g_dsp.r[DSP_REG_PRODH];
MOVSX(64, 8, long_prod, MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.h)));
//val <<= 32;
@ -519,7 +526,7 @@ void DSPEmitter::get_long_prod(X64Reg long_prod)
OR(16, R(long_prod), MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.l)));
//return val;
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
//s64 val = (s8)(u8)g_dsp.r[DSP_REG_PRODH];
MOV(64, R(long_prod), MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.val)));
MOV(64, R(R11), R(long_prod));
@ -567,7 +574,7 @@ void DSPEmitter::set_long_prod()
#ifdef _M_X64
#if 0
// g_dsp.r[DSP_REG_PRODL] = (u16)val;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, prod.l)), R(AX));
// val >>= 16;
SAR(64, R(RAX), Imm8(16));
@ -618,7 +625,7 @@ void DSPEmitter::get_long_acc(int _reg, X64Reg acc)
#ifdef _M_X64
#if 0
// s64 high = (s64)(s8)g_dsp.r[DSP_REG_ACH0 + reg] << 32;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 8, acc, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].h)));
SHL(64, R(acc), Imm8(16));
// u32 mid_low = ((u32)g_dsp.r[DSP_REG_ACM0 + reg] << 16) | g_dsp.r[DSP_REG_ACL0 + reg];
@ -628,7 +635,7 @@ void DSPEmitter::get_long_acc(int _reg, X64Reg acc)
// return high | mid_low;
#else
// s64 high = (s64)(s8)g_dsp.r[DSP_REG_ACH0 + reg] << 32;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(64, R(acc), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].val)));
SHL(64, R(acc), Imm8(64-40));//sign extend
SAR(64, R(acc), Imm8(64-40));
@ -643,7 +650,7 @@ void DSPEmitter::set_long_acc(int _reg, X64Reg acc)
#ifdef _M_X64
#if 0
// g_dsp.r[DSP_REG_ACL0 + _reg] = (u16)val;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].l)), R(acc));
// val >>= 16;
SHR(64, R(acc), Imm8(16));
@ -658,7 +665,7 @@ void DSPEmitter::set_long_acc(int _reg, X64Reg acc)
SHL(64, R(acc), Imm8(64-40));//sign extend
SAR(64, R(acc), Imm8(64-40));
// g_dsp.r[DSP_REG_ACL0 + _reg] = (u16)val;
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(64, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].val)), R(acc));
#endif
#endif
@ -669,7 +676,7 @@ void DSPEmitter::get_acc_m(int _reg, X64Reg acm)
{
// return g_dsp.r[DSP_REG_ACM0 + _reg];
#ifdef _M_X64
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, acm, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].m)));
#endif
}
@ -679,7 +686,7 @@ void DSPEmitter::set_acc_m(int _reg)
{
// return g_dsp.r[DSP_REG_ACM0 + _reg];
#ifdef _M_X64
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOV(16, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ac[_reg].m)), R(RAX));
#endif
}
@ -690,12 +697,12 @@ void DSPEmitter::get_long_acx(int _reg, X64Reg acx)
// return ((u32)g_dsp.r[DSP_REG_AXH0 + _reg] << 16) | g_dsp.r[DSP_REG_AXL0 + _reg];
#ifdef _M_X64
#if 0
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, acx, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[_reg].h)));
SHL(64, R(acx), Imm8(16));
OR(16, R(acx), MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[_reg].l)));
#else
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 32, acx, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[_reg].val)));
#endif
#endif
@ -706,7 +713,7 @@ void DSPEmitter::get_ax_l(int _reg, X64Reg axl)
{
// return (s16)g_dsp.r[DSP_REG_AXL0 + _reg];
#ifdef _M_X64
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, axl, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[_reg].l)));
#endif
}
@ -716,7 +723,20 @@ void DSPEmitter::get_ax_h(int _reg, X64Reg axh)
{
// return (s16)g_dsp.r[DSP_REG_AXH0 + _reg];
#ifdef _M_X64
MOV(64, R(R11), ImmPtr(&g_dsp.r));
// MOV(64, R(R11), ImmPtr(&g_dsp.r));
MOVSX(64, 16, axh, MDisp(R11, STRUCT_OFFSET(g_dsp.r, ax[_reg].h)));
#endif
}
void DSPEmitter::LoadDSPRegs()
{
#ifdef _M_X64
MOV(64, R(R11), ImmPtr(&g_dsp.r));
#endif
// Load DSP register state here...
}
void DSPEmitter::SaveDSPRegs()
{
// Save DSP register state here...
}