Skip to content

Commit

Permalink
[DYNAREC] Force separation of x87 and mmx cache usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed May 16, 2021
1 parent 0b5a943 commit 4df9b9a
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 77 deletions.
37 changes: 18 additions & 19 deletions src/dynarec/dynarec_arm_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
}
#define GETGM(a) \
gd = (nextop&0x38)>>3; \
a = mmx_get_reg(dyn, ninst, x1, gd)
a = mmx_get_reg(dyn, ninst, x1, x2, x3, gd)
#define GETEM(a) \
if((nextop&0xC0)==0xC0) { \
a = mmx_get_reg(dyn, ninst, x1, nextop&7); \
a = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7); \
} else { \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0); \
a = fpu_get_scratch_double(dyn); \
Expand Down Expand Up @@ -284,7 +284,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
gd = (nextop&0x38)>>3;
v0 = sse_get_reg(dyn, ninst, x1, gd);
if((nextop&0xC0)==0xC0) {
v1 = mmx_get_reg(dyn, ninst, x1, nextop&7);
v1 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
v1 = fpu_get_scratch_double(dyn);
Expand All @@ -309,7 +309,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("CVTTPS2PI Gm, Ex");
nextop = F8;
gd = (nextop&0x38)>>3;
v0 = mmx_get_reg_empty(dyn, ninst, x1, gd);
v0 = mmx_get_reg_empty(dyn, ninst, x1, x2, x3, gd);
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7);
} else {
Expand All @@ -323,7 +323,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("CVTPS2PI Gm, Ex");
nextop = F8;
gd = (nextop&0x38)>>3;
v0 = mmx_get_reg_empty(dyn, ninst, x1, gd);
v0 = mmx_get_reg_empty(dyn, ninst, x1, x2, x3, gd);
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7);
} else {
Expand Down Expand Up @@ -800,7 +800,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGM(d0);
q0 = fpu_get_scratch_quad(dyn);
if((nextop&0xC0)==0xC0) {
d1 = mmx_get_reg(dyn, ninst, x1, nextop&7);
d1 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
VMOVD(q0+1, d1);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
Expand Down Expand Up @@ -861,7 +861,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
nextop = F8;
GETED;
gd = (nextop&0x38)>>3;
v0 = mmx_get_reg_empty(dyn, ninst, x3, gd);
v0 = mmx_get_reg_empty(dyn, ninst, x2, x3, x14, gd);
VEOR(v0, v0, v0);
VMOVtoDx_32(v0, 0, ed);
break;
Expand All @@ -870,11 +870,11 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
nextop = F8;
gd = (nextop&0x38)>>3;
if((nextop&0xC0)==0xC0) {
v1 = mmx_get_reg(dyn, ninst, x1, nextop&7);
v0 = mmx_get_reg_empty(dyn, ninst, x1, gd);
v1 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
v0 = mmx_get_reg_empty(dyn, ninst, x1, x2, x3, gd);
VMOVD(v0, v1);
} else {
v0 = mmx_get_reg_empty(dyn, ninst, x1, gd);
v0 = mmx_get_reg_empty(dyn, ninst, x1, x2, x3, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
VLD1_64(v0, ed);
}
Expand All @@ -884,10 +884,10 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
nextop = F8;
gd = (nextop&0x38)>>3;
i32 = -1;
v0 = mmx_get_reg(dyn, ninst, x1, gd);
v0 = mmx_get_reg(dyn, ninst, x1, x2, x3, gd);
if((nextop&0xC0)==0xC0) {
u8 = F8;
v1 = mmx_get_reg(dyn, ninst, x1, nextop&7);
v1 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
// use stack as temporary storage
SUB_IMM8(xSP, xSP, 4);
if(v1==v0) {
Expand Down Expand Up @@ -931,7 +931,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 2:
INST_NAME("PSRLW Em, Ib");
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, nextop&7);
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
d0 = fpu_get_scratch_quad(dyn);
Expand All @@ -952,7 +952,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 4:
INST_NAME("PSRAW Em, Ib");
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, nextop&7);
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
d0 = fpu_get_scratch_quad(dyn);
Expand All @@ -969,7 +969,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 6:
INST_NAME("PSLLW Em, Ib");
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, nextop&7);
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
d0 = fpu_get_scratch_quad(dyn);
Expand Down Expand Up @@ -1085,8 +1085,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0x77:
INST_NAME("EMMS");
// empty MMX, FPU now usable
/*emu->top = 0;
emu->fpu_stack = 0;*/ //TODO: Check if something is needed here?
mmx_purgecache(dyn, ninst, x1);
break;

case 0x7E:
Expand All @@ -1107,7 +1106,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
nextop = F8;
GETGM(v0);
if((nextop&0xC0)==0xC0) {
v1 = mmx_get_reg_empty(dyn, ninst, x1, nextop&7);
v1 = mmx_get_reg_empty(dyn, ninst, x1, x2, x3, nextop&7);
VMOVD(v1, v0);
} else {
parity = getedparity(dyn, ninst, addr, nextop, 3);
Expand Down Expand Up @@ -2189,7 +2188,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
DEFAULT;
} else {
v0 = mmx_get_reg(dyn, ninst, x1, gd);
v0 = mmx_get_reg(dyn, ninst, x1, x2, x3, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
VST1_64(v0, ed);
}
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/dynarec_arm_d8.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ uintptr_t dynarecD8(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7);
VCMP_F64(v1, v2);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xE0:
case 0xE1:
Expand Down Expand Up @@ -216,7 +216,7 @@ uintptr_t dynarecD8(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VCVT_F64_F32(d1, s0);
VCMP_F64(v1, d1);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FSUB ST0, float[ED]");
Expand Down
28 changes: 14 additions & 14 deletions src/dynarec/dynarec_arm_d9.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0xC7:
INST_NAME("FLD STx");
v1 = x87_get_st(dyn, ninst, x1, x2, nextop&7);
v2 = x87_do_push(dyn, ninst);
v2 = x87_do_push(dyn, ninst, x3);
VMOV_64(v2, v1);
break;

Expand Down Expand Up @@ -108,43 +108,43 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,

case 0xE8:
INST_NAME("FLD1");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_1));
VLDR_64(v1, x2, 0);
break;
case 0xE9:
INST_NAME("FLDL2T");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_l2t));
VLDR_64(v1, x2, 0);
break;
case 0xEA:
INST_NAME("FLDL2E");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_l2e));
VLDR_64(v1, x2, 0);
break;
case 0xEB:
INST_NAME("FLDPI");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_pi));
VLDR_64(v1, x2, 0);
break;
case 0xEC:
INST_NAME("FLDLG2");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_lg2));
VLDR_64(v1, x2, 0);
break;
case 0xED:
INST_NAME("FLDLN2");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_ln2));
VLDR_64(v1, x2, 0);
break;
case 0xEE:
INST_NAME("FLDZ");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
MOV32(x2, (&d_0));
VLDR_64(v1, x2, 0);
break;
Expand Down Expand Up @@ -182,13 +182,13 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
x87_forget(dyn, ninst, x1, x2, 0);
x87_forget(dyn, ninst, x1, x2, 1);
CALL(arm_fyl2x, -1, 0);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xF2:
INST_NAME("FTAN");
x87_forget(dyn, ninst, x1, x2, 0);
CALL(arm_ftan, -1, 0);
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x3);
MOV32(x2, (&d_1));
VLDR_64(v1, x2, 0);
break;
Expand All @@ -197,7 +197,7 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
x87_forget(dyn, ninst, x1, x2, 0);
x87_forget(dyn, ninst, x1, x2, 1);
CALL(arm_fpatan, -1, 0);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xF4:
INST_NAME("FXTRACT");
Expand Down Expand Up @@ -238,7 +238,7 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
x87_forget(dyn, ninst, x1, x2, 0);
x87_forget(dyn, ninst, x1, x2, 1);
CALL(arm_fyl2xp1, -1, 0);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xFB:
INST_NAME("FSINCOS");
Expand Down Expand Up @@ -289,7 +289,7 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
switch((nextop>>3)&7) {
case 0:
INST_NAME("FLD ST0, float[ED]");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
s0 = fpu_get_scratch_single(dyn);
parity = getedparity(dyn, ninst, addr, nextop, 2);
if(parity) {
Expand Down Expand Up @@ -331,7 +331,7 @@ uintptr_t dynarecD9(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VMOVfrV(x2, s0);
STR_IMM9(x2, ed, fixedaddress);
}
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FLDENV Ed");
Expand Down
6 changes: 3 additions & 3 deletions src/dynarec/dynarec_arm_da.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ uintptr_t dynarecDA(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v2 = x87_get_st(dyn, ninst, x1, x2, 1);
VCMP_F64(v1, v2);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
x87_do_pop(dyn, ninst, x3);
break;

case 0xE4:
Expand Down Expand Up @@ -168,7 +168,7 @@ uintptr_t dynarecDA(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VCVT_F64_S32(d0, s0);
VCMP_F64(v1, d0);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FISUB ST0, Ed");
Expand Down
8 changes: 4 additions & 4 deletions src/dynarec/dynarec_arm_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
switch((nextop>>3)&7) {
case 0:
INST_NAME("FILD ST0, Ed");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
s0 = fpu_get_scratch_single(dyn);
parity = getedparity(dyn, ninst, addr, nextop, 2);
if(parity) {
Expand Down Expand Up @@ -194,7 +194,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV_IMM_COND(cNE, ed, 0b10, 1); // 0x80000000
WBACK;
VMSR(x14); // put back values
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 2:
INST_NAME("FIST Ed, ST0");
Expand Down Expand Up @@ -244,7 +244,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
TSTS_IMM8_ROR(x3, 0b00000001, 0);
MOV_IMM_COND(cNE, ed, 0b10, 1); // 0x80000000
WBACK;
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
x87_restoreround(dyn, ninst, u8);
break;
case 5:
Expand Down Expand Up @@ -279,7 +279,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV_REG(x1, ed);
}
CALL(arm_fstp, -1, 0);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
default:
DEFAULT;
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/dynarec_arm_dc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ uintptr_t dynarecDC(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7);
VCMP_F64(v1, v2);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xE0:
case 0xE1:
Expand Down Expand Up @@ -211,7 +211,7 @@ uintptr_t dynarecDC(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
VCMP_F64(v1, d1);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FSUB ST0, double[ED]");
Expand Down
12 changes: 6 additions & 6 deletions src/dynarec/dynarec_arm_dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
break;
case 0xD8:
INST_NAME("FSTP ST0, ST0");
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 0xD9:
case 0xDA:
Expand All @@ -74,7 +74,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v1 = x87_get_st(dyn, ninst, x1, x2, 0);
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7);
VMOV_64(v2, v1);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;

case 0xE0:
Expand Down Expand Up @@ -104,7 +104,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7);
VCMP_F64(v1, v2);
FCOM(x1, x2);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;

case 0xC8:
Expand Down Expand Up @@ -138,7 +138,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
switch((nextop>>3)&7) {
case 0:
INST_NAME("FLD double");
v1 = x87_do_push(dyn, ninst);
v1 = x87_do_push(dyn, ninst, x1);
#if 0
// can bus error...
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3);
Expand All @@ -162,7 +162,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
if(ed!=x1) {MOV_REG(x1, ed);}
CALL(arm_fistt64, -1, 0);
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 2:
INST_NAME("FST double");
Expand Down Expand Up @@ -191,7 +191,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
}
x87_do_pop(dyn, ninst);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FRSTOR m108byte");
Expand Down
Loading

0 comments on commit 4df9b9a

Please sign in to comment.