This commit is contained in:
Nekotekina 2014-04-16 15:09:06 +04:00
commit dab0751300
6 changed files with 394 additions and 281 deletions

View file

@ -59,7 +59,7 @@ public:
u8 I1 = 1 - (J1 ^ S); u8 I1 = 1 - (J1 ^ S);
u8 I2 = 1 - (J2 ^ S); u8 I2 = 1 - (J2 ^ S);
u16 imm11 = code1 & 0x7ff; u16 imm11 = code1 & 0x7ff;
u32 imm32; u32 imm32 = 0;
switch(code1 >> 14) switch(code1 >> 14)
{ {

View file

@ -95,7 +95,7 @@ public:
SRType DecodeImmShift(u8 type, u8 imm5, uint* shift_n) SRType DecodeImmShift(u8 type, u8 imm5, uint* shift_n)
{ {
SRType shift_t; SRType shift_t = SRType_None;
switch(type) switch(type)
{ {
@ -119,7 +119,7 @@ public:
SRType DecodeRegShift(u8 type) SRType DecodeRegShift(u8 type)
{ {
SRType shift_t; SRType shift_t = SRType_None;
switch(type) switch(type)
{ {
@ -235,7 +235,7 @@ public:
bool ConditionPassed(u8 cond) bool ConditionPassed(u8 cond)
{ {
bool result; bool result = false;
switch(cond >> 1) switch(cond >> 1)
{ {

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "SPUInstrTable.h" #include "SPUInstrTable.h"
#include "SPUDisAsm.h"
#include "SPUInterpreter.h" #include "SPUInterpreter.h"
#include "SPURecompiler.h" #include "SPURecompiler.h"
@ -9,7 +10,7 @@ SPURecompilerCore::SPURecompilerCore(SPUThread& cpu)
: m_enc(new SPURecompiler(cpu, *this)) : m_enc(new SPURecompiler(cpu, *this))
, inter(new SPUInterpreter(cpu)) , inter(new SPUInterpreter(cpu))
, CPU(cpu) , CPU(cpu)
//, compiler(&runtime) , first(true)
{ {
memset(entry, 0, sizeof(entry)); memset(entry, 0, sizeof(entry));
} }
@ -30,8 +31,14 @@ void SPURecompilerCore::Compile(u16 pos)
const u64 stamp0 = get_system_time(); const u64 stamp0 = get_system_time();
u64 time0 = 0; u64 time0 = 0;
SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode);
StringLogger stringLogger;
stringLogger.setOption(kLoggerOptionBinaryForm, true);
Compiler compiler(&runtime); Compiler compiler(&runtime);
m_enc->compiler = &compiler; m_enc->compiler = &compiler;
compiler.setLogger(&stringLogger);
compiler.addFunc(kFuncConvHost, FuncBuilder4<u32, void*, void*, void*, u32>()); compiler.addFunc(kFuncConvHost, FuncBuilder4<u32, void*, void*, void*, u32>());
const u16 start = pos; const u16 start = pos;
@ -55,12 +62,18 @@ void SPURecompilerCore::Compile(u16 pos)
GpVar pos_var(compiler, kVarTypeUInt32, "pos"); GpVar pos_var(compiler, kVarTypeUInt32, "pos");
compiler.setArg(3, pos_var); compiler.setArg(3, pos_var);
compiler.alloc(pos_var);
m_enc->pos_var = &pos_var; m_enc->pos_var = &pos_var;
GpVar addr_var(compiler, kVarTypeUInt32, "addr");
m_enc->addr = &addr_var;
GpVar qw0_var(compiler, kVarTypeUInt64, "qw0");
m_enc->qw0 = &qw0_var;
GpVar qw1_var(compiler, kVarTypeUInt64, "qw1");
m_enc->qw1 = &qw1_var;
for (u32 i = 0; i < 16; i++) for (u32 i = 0; i < 16; i++)
{ {
m_enc->xmm_var[i].data = new XmmVar(compiler); m_enc->xmm_var[i].data = new XmmVar(compiler, kVarTypeXmm, fmt::Format("reg_%d", i).c_str());
} }
compiler.xor_(pos_var, pos_var); compiler.xor_(pos_var, pos_var);
@ -72,10 +85,15 @@ void SPURecompilerCore::Compile(u16 pos)
if (opcode) if (opcode)
{ {
const u64 stamp1 = get_system_time(); const u64 stamp1 = get_system_time();
(*SPU_instr::rrr_list)(m_enc, opcode); // compile single opcode // disasm for logging:
dis_asm.dump_pc = CPU.dmac.ls_offset + pos * 4;
(*SPU_instr::rrr_list)(&dis_asm, opcode);
compiler.addComment(fmt::Format("SPU data: PC=0x%05x %s", pos * 4, dis_asm.last_opcode.c_str()).c_str());
// compile single opcode:
(*SPU_instr::rrr_list)(m_enc, opcode);
// force finalization between every slice using absolute alignment
/*if ((pos % 128 == 127) && !m_enc->do_finalize) /*if ((pos % 128 == 127) && !m_enc->do_finalize)
{ {
// force finalization between every slice using absolute alignment
compiler.mov(pos_var, pos + 1); compiler.mov(pos_var, pos + 1);
m_enc->do_finalize = true; m_enc->do_finalize = true;
}*/ }*/
@ -111,10 +129,17 @@ void SPURecompilerCore::Compile(u16 pos)
compiler.ret(pos_var); compiler.ret(pos_var);
compiler.endFunc(); compiler.endFunc();
entry[start].pointer = compiler.make(); entry[start].pointer = compiler.make();
compiler.setLogger(nullptr); // crashes without it
wxFile log;
log.Open(wxString::Format("SPUjit_%d.log", GetCurrentSPUThread().GetId()), first ? wxFile::write : wxFile::write_append);
log.Write(wxString::Format("========== START POSITION 0x%x ==========\n\n", start * 4));
log.Write(wxString(stringLogger.getString()));
log.Close();
//ConLog.Write("Compiled: %d (excess %d), addr=0x%x, time: [start=%d (decoding=%d), finalize=%d]", //ConLog.Write("Compiled: %d (excess %d), addr=0x%x, time: [start=%d (decoding=%d), finalize=%d]",
//entry[start].count, excess, start * 4, stamp1 - stamp0, time0, get_system_time() - stamp1); //entry[start].count, excess, start * 4, stamp1 - stamp0, time0, get_system_time() - stamp1);
m_enc->compiler = nullptr; m_enc->compiler = nullptr;
first = false;
} }
u8 SPURecompilerCore::DecodeMemory(const u64 address) u8 SPURecompilerCore::DecodeMemory(const u64 address)

View file

@ -331,7 +331,7 @@ public:
return false; return false;
} }
res = m_value[0]; res = m_value[0];
for (u32 i = 1; i < max_count; i++) // FIFO if (max_count > 1) for (u32 i = 1; i < max_count; i++) // FIFO
{ {
m_value[i-1] = m_value[i]; m_value[i-1] = m_value[i];
} }

View file

@ -468,7 +468,7 @@ int sys_spu_thread_read_ls(u32 id, u32 address, mem64_t value, u32 type)
//190 //190
int sys_spu_thread_write_spu_mb(u32 id, u32 value) int sys_spu_thread_write_spu_mb(u32 id, u32 value)
{ {
sc_spu.Warning("sys_spu_thread_write_spu_mb(id=%d, value=0x%x)", id, value); sc_spu.Log("sys_spu_thread_write_spu_mb(id=%d, value=0x%x)", id, value);
CPUThread* thr = Emu.GetCPU().GetThread(id); CPUThread* thr = Emu.GetCPU().GetThread(id);