Merge pull request #3071 from lioncash/dsp

DSP Jit: Minor changes
This commit is contained in:
flacs 2015-09-21 11:35:54 +02:00
commit bbb1132d86
7 changed files with 89 additions and 157 deletions

View File

@ -169,8 +169,7 @@ void DSPEmitter::cmp(const UDSPInstruction opc)
{
if (FlagsNeeded())
{
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc0 = dsp_get_long_acc(0);
get_long_acc(0, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -198,8 +197,7 @@ void DSPEmitter::cmpar(const UDSPInstruction opc)
u8 rreg = ((opc >> 12) & 0x1);
u8 sreg = (opc >> 11) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 sr = dsp_get_long_acc(sreg);
get_long_acc(sreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -228,8 +226,7 @@ void DSPEmitter::cmpi(const UDSPInstruction opc)
if (FlagsNeeded())
{
u8 reg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 val = dsp_get_long_acc(reg);
get_long_acc(reg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -258,8 +255,7 @@ void DSPEmitter::cmpis(const UDSPInstruction opc)
{
u8 areg = (opc >> 8) & 0x1;
// s64 acc = dsp_get_long_acc(areg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_acc(areg, tmp1);
MOV(64, R(RAX), R(tmp1));
// s64 val = (s8)opc;
@ -527,8 +523,7 @@ void DSPEmitter::addr(const UDSPInstruction opc)
u8 sreg = ((opc >> 9) & 0x3) + DSP_REG_AXL0;
// s64 acc = dsp_get_long_acc(dreg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
// s64 ax = (s16)g_dsp.r[sreg];
@ -562,8 +557,7 @@ void DSPEmitter::addax(const UDSPInstruction opc)
u8 dreg = (opc >> 8) & 0x1;
u8 sreg = (opc >> 9) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -596,8 +590,7 @@ void DSPEmitter::add(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc0 = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -630,8 +623,7 @@ void DSPEmitter::addp(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -666,8 +658,7 @@ void DSPEmitter::addaxl(const UDSPInstruction opc)
u8 sreg = (opc >> 9) & 0x1;
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// u64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -701,8 +692,7 @@ void DSPEmitter::addaxl(const UDSPInstruction opc)
void DSPEmitter::addi(const UDSPInstruction opc)
{
u8 areg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(areg);
get_long_acc(areg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -739,8 +729,7 @@ void DSPEmitter::addis(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -776,8 +765,7 @@ void DSPEmitter::incm(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
s64 subtract = 0x10000;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -808,8 +796,7 @@ void DSPEmitter::incm(const UDSPInstruction opc)
void DSPEmitter::inc(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -844,8 +831,7 @@ void DSPEmitter::subr(const UDSPInstruction opc)
u8 dreg = (opc >> 8) & 0x1;
u8 sreg = ((opc >> 9) & 0x3) + DSP_REG_AXL0;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -882,8 +868,7 @@ void DSPEmitter::subax(const UDSPInstruction opc)
u8 dreg = (opc >> 8) & 0x1;
u8 sreg = (opc >> 9) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -916,8 +901,7 @@ void DSPEmitter::subax(const UDSPInstruction opc)
void DSPEmitter::sub(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc1 = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -950,8 +934,7 @@ void DSPEmitter::sub(const UDSPInstruction opc)
void DSPEmitter::subp(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -985,8 +968,7 @@ void DSPEmitter::decm(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x01;
s64 subtract = 0x10000;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));
@ -1017,8 +999,7 @@ void DSPEmitter::decm(const UDSPInstruction opc)
void DSPEmitter::dec(const UDSPInstruction opc)
{
u8 dreg = (opc >> 8) & 0x01;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// s64 acc = dsp_get_long_acc(dreg);
get_long_acc(dreg, tmp1);
MOV(64, R(RAX), R(tmp1));

View File

@ -71,8 +71,7 @@ void DSPEmitter::s(const UDSPInstruction opc)
// u16 addr = g_dsp.r[dest];
dsp_op_read_reg(dreg, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1, ZERO);
// u16 val = g_dsp.r[src];
@ -93,8 +92,7 @@ void DSPEmitter::sn(const UDSPInstruction opc)
u8 sreg = ((opc >> 3) & 0x3) + DSP_REG_ACL0;
dsp_op_read_reg(dreg, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1, ZERO);
dmem_write(tmp1);
@ -165,8 +163,7 @@ void DSPEmitter::ls(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR3, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -192,8 +189,7 @@ void DSPEmitter::lsn(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR3, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -218,8 +214,7 @@ void DSPEmitter::lsm(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR3, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -245,8 +240,7 @@ void DSPEmitter::lsnm(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR3, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -270,8 +264,7 @@ void DSPEmitter::sl(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR0, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -296,8 +289,7 @@ void DSPEmitter::sln(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR0, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -322,8 +314,7 @@ void DSPEmitter::slm(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR0, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -348,8 +339,7 @@ void DSPEmitter::slnm(const UDSPInstruction opc)
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
dsp_op_read_reg(DSP_REG_AR0, RAX, ZERO);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg + DSP_REG_ACM0, tmp1, ZERO);
dmem_write(tmp1);
@ -381,8 +371,7 @@ void DSPEmitter::ld(const UDSPInstruction opc)
pushExtValueFromMem((dreg << 1) + DSP_REG_AXL0, sreg);
// if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
XOR(16, R(ECX), R(tmp));
@ -412,8 +401,7 @@ void DSPEmitter::ldax(const UDSPInstruction opc)
pushExtValueFromMem(rreg + DSP_REG_AXH0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -445,8 +433,7 @@ void DSPEmitter::ldn(const UDSPInstruction opc)
pushExtValueFromMem((dreg << 1) + DSP_REG_AXL0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -477,8 +464,7 @@ void DSPEmitter::ldaxn(const UDSPInstruction opc)
pushExtValueFromMem(rreg + DSP_REG_AXH0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -510,8 +496,7 @@ void DSPEmitter::ldm(const UDSPInstruction opc)
pushExtValueFromMem((dreg << 1) + DSP_REG_AXL0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -542,8 +527,7 @@ void DSPEmitter::ldaxm(const UDSPInstruction opc)
pushExtValueFromMem(rreg + DSP_REG_AXH0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -575,8 +559,7 @@ void DSPEmitter::ldnm(const UDSPInstruction opc)
pushExtValueFromMem((dreg << 1) + DSP_REG_AXL0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -607,8 +590,7 @@ void DSPEmitter::ldaxnm(const UDSPInstruction opc)
pushExtValueFromMem(rreg + DSP_REG_AXH0, sreg);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3])) {
dsp_op_read_reg(sreg, RCX, NONE);
dsp_op_read_reg(DSP_REG_AR3, tmp, NONE);
@ -636,8 +618,7 @@ void DSPEmitter::pushExtValueFromMem(u16 dreg, u16 sreg)
{
// u16 addr = g_dsp.r[addr];
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1, ZERO);
dmem_read(tmp1);
@ -653,8 +634,7 @@ void DSPEmitter::pushExtValueFromMem2(u16 dreg, u16 sreg)
{
// u16 addr = g_dsp.r[addr];
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1, ZERO);
dmem_read(tmp1);

View File

@ -23,8 +23,7 @@ void DSPEmitter::srs(const UDSPInstruction opc)
u8 reg = ((opc >> 8) & 0x7) + 0x18;
//u16 addr = (g_dsp.r.cr << 8) | (opc & 0xFF);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1, ZERO);
dsp_op_read_reg(DSP_REG_CR, RAX, ZERO);
@ -44,8 +43,7 @@ void DSPEmitter::lrs(const UDSPInstruction opc)
{
u8 reg = ((opc >> 8) & 0x7) + 0x18;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
//u16 addr = (g_dsp.r[DSP_REG_CR] << 8) | (opc & 0xFF);
dsp_op_read_reg(DSP_REG_CR, tmp1, ZERO);
@ -81,8 +79,7 @@ void DSPEmitter::sr(const UDSPInstruction opc)
u8 reg = opc & DSP_REG_MASK;
u16 address = dsp_imem_read(compilePC + 1);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1);
dmem_write_imm(address, tmp1);
@ -100,8 +97,7 @@ void DSPEmitter::si(const UDSPInstruction opc)
u16 address = (s8)opc;
u16 imm = dsp_imem_read(compilePC + 1);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
MOV(32, R(tmp1), Imm32((u32)imm));
dmem_write_imm(address, tmp1);
@ -117,8 +113,7 @@ void DSPEmitter::lrr(const UDSPInstruction opc)
u8 sreg = (opc >> 5) & 0x3;
u8 dreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dmem_read(tmp1);
@ -138,8 +133,7 @@ void DSPEmitter::lrrd(const UDSPInstruction opc)
u8 sreg = (opc >> 5) & 0x3;
u8 dreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dmem_read(tmp1);
@ -160,8 +154,7 @@ void DSPEmitter::lrri(const UDSPInstruction opc)
u8 sreg = (opc >> 5) & 0x3;
u8 dreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dmem_read(tmp1);
@ -182,8 +175,7 @@ void DSPEmitter::lrrn(const UDSPInstruction opc)
u8 sreg = (opc >> 5) & 0x3;
u8 dreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dmem_read(tmp1);
@ -204,8 +196,7 @@ void DSPEmitter::srr(const UDSPInstruction opc)
u8 dreg = (opc >> 5) & 0x3;
u8 sreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dsp_op_read_reg(dreg, RAX, ZERO);
@ -223,8 +214,7 @@ void DSPEmitter::srrd(const UDSPInstruction opc)
u8 dreg = (opc >> 5) & 0x3;
u8 sreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dsp_op_read_reg(dreg, RAX, ZERO);
@ -244,8 +234,7 @@ void DSPEmitter::srri(const UDSPInstruction opc)
u8 dreg = (opc >> 5) & 0x3;
u8 sreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dsp_op_read_reg(dreg, RAX, ZERO);
@ -265,8 +254,7 @@ void DSPEmitter::srrn(const UDSPInstruction opc)
u8 dreg = (opc >> 5) & 0x3;
u8 sreg = opc & 0x1f;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(sreg, tmp1);
dsp_op_read_reg(dreg, RAX, ZERO);
@ -286,8 +274,7 @@ void DSPEmitter::ilrr(const UDSPInstruction opc)
u16 reg = opc & 0x3;
u16 dreg = (opc >> 8) & 1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1, ZERO);
imem_read(tmp1);
@ -307,8 +294,7 @@ void DSPEmitter::ilrrd(const UDSPInstruction opc)
u16 reg = opc & 0x3;
u16 dreg = (opc >> 8) & 1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1, ZERO);
imem_read(tmp1);
@ -329,8 +315,7 @@ void DSPEmitter::ilrri(const UDSPInstruction opc)
u16 reg = opc & 0x3;
u16 dreg = (opc >> 8) & 1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1, ZERO);
imem_read(tmp1);
@ -352,8 +337,7 @@ void DSPEmitter::ilrrn(const UDSPInstruction opc)
u16 reg = opc & 0x3;
u16 dreg = (opc >> 8) & 1;
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
dsp_op_read_reg(reg, tmp1, ZERO);
imem_read(tmp1);

View File

@ -100,8 +100,7 @@ void DSPEmitter::multiply_mulx(u8 axh0, u8 axh1)
{
// mixed support ON (u16)axl.0 * (s16)axh.1
// prod = a * (s16)b;
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
MOV(64, R(tmp), R(RAX));
MOVZX(64, 16, RAX, R(RCX));
IMUL(64, R(tmp));
@ -247,8 +246,7 @@ void DSPEmitter::addpaxz(const UDSPInstruction opc)
u8 sreg = (opc >> 9) & 0x1;
// s64 ax = dsp_get_long_acx(sreg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_acx(sreg, tmp1);
MOV(64, R(RDX), R(tmp1));
// s64 res = prod + (ax & ~0xffff);
@ -431,8 +429,7 @@ void DSPEmitter::mulxac(const UDSPInstruction opc)
u8 sreg = (opc >> 12) & 0x1;
// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod();
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_acc(rreg, tmp1);
get_long_prod();
ADD(64, R(tmp1), R(RAX));
@ -469,8 +466,7 @@ void DSPEmitter::mulxmv(const UDSPInstruction opc)
u8 sreg = (opc >> 12) & 0x1;
// s64 acc = dsp_get_long_prod();
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_prod(tmp1);
// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0);
dsp_op_read_reg(DSP_REG_AXL0 + sreg*2, RCX, SIGN);
@ -506,8 +502,7 @@ void DSPEmitter::mulxmvz(const UDSPInstruction opc)
u8 sreg = (opc >> 12) & 0x1;
// s64 acc = dsp_get_long_prod_round_prodl();
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
get_long_prod_round_prodl(tmp1);
// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0);
dsp_op_read_reg(DSP_REG_AXL0 + sreg*2, RCX, SIGN);

View File

@ -816,11 +816,10 @@ void DSPJitRegCache::PutReg(int reg, bool dirty)
}
else
{
// this works on the memory, so use reg instead
// This works on the memory, so use reg instead
// of real_reg, since it has the right loc
X64Reg tmp;
GetFreeXReg(tmp);
// sign extend from the bottom 8 bits.
X64Reg tmp = GetFreeXReg();
// Sign extend from the bottom 8 bits.
emitter.MOVSX(16, 8, tmp, regs[reg].loc);
emitter.MOV(16, regs[reg].loc, R(tmp));
PutXReg(tmp);
@ -1028,16 +1027,18 @@ X64Reg DSPJitRegCache::FindSpillFreeXReg()
return reg;
}
void DSPJitRegCache::GetFreeXReg(X64Reg &reg)
X64Reg DSPJitRegCache::GetFreeXReg()
{
reg = FindSpillFreeXReg();
X64Reg reg = FindSpillFreeXReg();
_assert_msg_(DSPLLE, reg != INVALID_REG, "could not find register");
if (reg == INVALID_REG)
{
emitter.INT3();
}
xregs[reg].guest_reg = DSP_REG_USED;
return reg;
}
void DSPJitRegCache::GetXReg(X64Reg reg)

View File

@ -171,7 +171,7 @@ public:
void WriteReg(int dreg, Gen::OpArg arg);
// Find a free host reg, spill if used, reserve
void GetFreeXReg(Gen::X64Reg &reg);
Gen::X64Reg GetFreeXReg();
// Spill a specific host reg if used, reserve
void GetXReg(Gen::X64Reg reg);
// Unreserve the given host reg

View File

@ -20,12 +20,11 @@ void DSPEmitter::dsp_reg_stack_push(int stack_reg)
AND(8, R(AL), Imm8(DSP_STACK_MASK));
MOV(8, M(&g_dsp.reg_stack_ptr[stack_reg]), R(AL));
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
//g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]] = g_dsp.r[DSP_REG_ST0 + stack_reg];
MOV(16, R(tmp1), M(&g_dsp.r.st[stack_reg]));
MOVZX(64, 8, RAX, R(AL));
MOV(16, MComplex(EAX, EAX, 1,
MOV(16, MComplex(EAX, EAX, SCALE_1,
PtrOffset(&g_dsp.reg_stack[stack_reg][0],nullptr)), R(tmp1));
gpr.PutXReg(tmp1);
}
@ -37,10 +36,9 @@ void DSPEmitter::dsp_reg_stack_pop(int stack_reg)
{
//g_dsp.r[DSP_REG_ST0 + stack_reg] = g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]];
MOV(8, R(AL), M(&g_dsp.reg_stack_ptr[stack_reg]));
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
MOVZX(64, 8, RAX, R(AL));
MOV(16, R(tmp1), MComplex(EAX, EAX, 1,
MOV(16, R(tmp1), MComplex(EAX, EAX, SCALE_1,
PtrOffset(&g_dsp.reg_stack[stack_reg][0],nullptr)));
MOV(16, M(&g_dsp.r.st[stack_reg]), R(tmp1));
gpr.PutXReg(tmp1);
@ -309,8 +307,7 @@ void DSPEmitter::increment_addr_reg(int reg)
gpr.PutReg(DSP_REG_WR0+reg, false);
gpr.GetReg(DSP_REG_AR0+reg,ar_reg);
MOVZX(32, 16, EAX, ar_reg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
//u32 nar = ar + 1;
MOV(32, R(tmp1), R(EAX));
ADD(32, R(EAX), Imm8(1));
@ -344,8 +341,7 @@ void DSPEmitter::decrement_addr_reg(int reg)
gpr.GetReg(DSP_REG_AR0+reg,ar_reg);
MOVZX(32, 16, EAX, ar_reg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
// u32 nar = ar + wr;
// edi = nar
LEA(32, tmp1, MRegSum(EAX, EDX));
@ -386,8 +382,7 @@ void DSPEmitter::increase_addr_reg(int reg, int _ix_reg)
gpr.GetReg(DSP_REG_AR0+reg,ar_reg);
MOVZX(32, 16, EAX, ar_reg);
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
//u32 nar = ar + ix;
//edi = nar
LEA(32, tmp1, MRegSum(EAX, ECX));
@ -419,13 +414,13 @@ void DSPEmitter::increase_addr_reg(int reg, int _ix_reg)
AND(32, R(EAX), R(ECX));
//if ((((nar + wr + 1) ^ nar) & dar) <= wr)
LEA(32, ECX, MComplex(tmp1, EDX, 1, 1));
LEA(32, ECX, MComplex(tmp1, EDX, SCALE_1, 1));
XOR(32, R(ECX), R(tmp1));
AND(32, R(ECX), R(EAX));
CMP(32, R(ECX), R(EDX));
FixupBranch done3 = J_CC(CC_A);
//nar += wr + 1;
LEA(32, tmp1, MComplex(tmp1, EDX, 1, 1));
LEA(32, tmp1, MComplex(tmp1, EDX, SCALE_1, 1));
SetJumpTarget(done);
SetJumpTarget(done2);
@ -457,10 +452,9 @@ void DSPEmitter::decrease_addr_reg(int reg)
NOT(32, R(ECX)); //esi = ~ix
X64Reg tmp1;
gpr.GetFreeXReg(tmp1);
X64Reg tmp1 = gpr.GetFreeXReg();
//u32 nar = ar - ix; (ar + ~ix + 1)
LEA(32, tmp1, MComplex(EAX, ECX, 1, 1));
LEA(32, tmp1, MComplex(EAX, ECX, SCALE_1, 1));
//u32 dar = (nar ^ ar ^ ~ix) & ((wr | 1) << 1);
//eax = dar
@ -489,13 +483,13 @@ void DSPEmitter::decrease_addr_reg(int reg)
AND(32, R(EAX), R(ECX));
//if ((((nar + wr + 1) ^ nar) & dar) <= wr)
LEA(32, ECX, MComplex(tmp1, EDX, 1, 1));
LEA(32, ECX, MComplex(tmp1, EDX, SCALE_1, 1));
XOR(32, R(ECX), R(tmp1));
AND(32, R(ECX), R(EAX));
CMP(32, R(ECX), R(EDX));
FixupBranch done3 = J_CC(CC_A);
//nar += wr + 1;
LEA(32, tmp1, MComplex(tmp1, EDX, 1, 1));
LEA(32, tmp1, MComplex(tmp1, EDX, SCALE_1, 1));
SetJumpTarget(done);
SetJumpTarget(done2);
@ -519,7 +513,7 @@ void DSPEmitter::dmem_write(X64Reg value)
// g_dsp.dram[addr & DSP_DRAM_MASK] = val;
AND(16, R(EAX), Imm16(DSP_DRAM_MASK));
MOV(64, R(ECX), ImmPtr(g_dsp.dram));
MOV(16, MComplex(ECX, EAX, 2, 0), R(value));
MOV(16, MComplex(ECX, EAX, SCALE_2, 0), R(value));
FixupBranch end = J(true);
// else if (saddr == 0xf)
@ -570,7 +564,7 @@ void DSPEmitter::imem_read(X64Reg address)
// return g_dsp.iram[addr & DSP_IRAM_MASK];
AND(16, R(address), Imm16(DSP_IRAM_MASK));
MOV(64, R(ECX), ImmPtr(g_dsp.iram));
MOV(16, R(EAX), MComplex(ECX, address, 2, 0));
MOV(16, R(EAX), MComplex(ECX, address, SCALE_2, 0));
FixupBranch end = J();
SetJumpTarget(irom);
@ -578,7 +572,7 @@ void DSPEmitter::imem_read(X64Reg address)
// return g_dsp.irom[addr & DSP_IROM_MASK];
AND(16, R(address), Imm16(DSP_IROM_MASK));
MOV(64, R(ECX), ImmPtr(g_dsp.irom));
MOV(16, R(EAX), MComplex(ECX, address, 2, 0));
MOV(16, R(EAX), MComplex(ECX, address, SCALE_2, 0));
SetJumpTarget(end);
}
@ -595,7 +589,7 @@ void DSPEmitter::dmem_read(X64Reg address)
AND(32, R(address), Imm32(DSP_DRAM_MASK));
MOVZX(64, 16, address, R(address));
MOV(64, R(ECX), ImmPtr(g_dsp.dram));
MOV(16, R(EAX), MComplex(ECX, address, 2, 0));
MOV(16, R(EAX), MComplex(ECX, address, SCALE_2, 0));
FixupBranch end = J(true);
SetJumpTarget(dram);
@ -606,7 +600,7 @@ void DSPEmitter::dmem_read(X64Reg address)
AND(32, R(address), Imm32(DSP_COEF_MASK));
MOVZX(64, 16, address, R(address));
MOV(64, R(ECX), ImmPtr(g_dsp.coef));
MOV(16, R(EAX), MComplex(ECX, address, 2, 0));
MOV(16, R(EAX), MComplex(ECX, address, SCALE_2, 0));
FixupBranch end2 = J(true);
SetJumpTarget(ifx);
@ -658,8 +652,7 @@ void DSPEmitter::get_long_prod(X64Reg long_prod)
MOV(64, R(long_prod), prod_reg);
gpr.PutReg(DSP_REG_PROD_64, false);
//no use in keeping prod_reg any longer.
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
MOV(64, R(tmp), R(long_prod));
SHL(64, R(long_prod), Imm8(64-40));//sign extend
SAR(64, R(long_prod), Imm8(64-40));
@ -676,8 +669,7 @@ void DSPEmitter::get_long_prod_round_prodl(X64Reg long_prod)
//s64 prod = dsp_get_long_prod();
get_long_prod(long_prod);
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
//if (prod & 0x10000) prod = (prod + 0x8000) & ~0xffff;
TEST(32, R(long_prod), Imm32(0x10000));
FixupBranch jump = J_CC(CC_Z);
@ -700,8 +692,7 @@ void DSPEmitter::get_long_prod_round_prodl(X64Reg long_prod)
// In: RAX = s64 val
void DSPEmitter::set_long_prod()
{
X64Reg tmp;
gpr.GetFreeXReg(tmp);
X64Reg tmp = gpr.GetFreeXReg();
MOV(64, R(tmp), Imm64(0x000000ffffffffffULL));
AND(64, R(RAX), R(tmp));