mirror of
https://github.com/ptitSeb/box86.git
synced 2024-11-23 06:39:55 +00:00
[DYNAREC] Fixes to Cosim and to some x87 utility functions
This commit is contained in:
parent
4abaa3d835
commit
968fc3fcfe
@ -1667,6 +1667,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
|
||||
case 0xCC:
|
||||
SETFLAGS(X_ALL, SF_SET_NODF); // Hack, set all flags (to an unknown state...)
|
||||
NOTEST(x1, x14);
|
||||
if(PK(0)=='S' && PK(1)=='C') {
|
||||
addr+=2;
|
||||
BARRIER(BARRIER_FLOAT);
|
||||
@ -1674,7 +1675,6 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
if((PK(0)==0) && (PK(1)==0) && (PK(2)==0) && (PK(3)==0))
|
||||
{
|
||||
addr+=4;
|
||||
SKIPTEST(x14);
|
||||
MESSAGE(LOG_DEBUG, "Exit x86 Emu\n");
|
||||
MOV32(x14, ip+1+2);
|
||||
SMEND();
|
||||
@ -1685,7 +1685,6 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
*need_epilog = 1;
|
||||
} else {
|
||||
MESSAGE(LOG_DUMP, "Native Call to %s\n", GetNativeName(GetNativeFnc(ip)));
|
||||
SKIPTEST(x14);
|
||||
SMEND();
|
||||
x87_forget(dyn, ninst, x3, x14, 0);
|
||||
if((box86_log<2) && !cycle_log) { // call the wrapper directly
|
||||
@ -1735,7 +1734,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
break;
|
||||
case 0xCD:
|
||||
SETFLAGS(X_ALL, SF_SET_NODF); // Hack, set all flags (to an unknown state...)
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
SMEND();
|
||||
u8 = F8;
|
||||
if(u8==0x80) {
|
||||
@ -2258,26 +2257,26 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
case 1:
|
||||
//SETFLAGS(X_ALL, SF_SET_NODF); // Hack to set flags to "dont'care" state
|
||||
MESSAGE(LOG_DUMP, "Hack for Call 0\n");
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
MOV32(xEIP, addr);
|
||||
PUSH1(xEIP);
|
||||
break;
|
||||
case 2:
|
||||
//SETFLAGS(X_ALL, SF_SET_NODF); // Hack to set flags to "dont'care" state
|
||||
MESSAGE(LOG_DUMP, "Hack for Call x86.get_pc_thunk.reg\n");
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
u8 = PK(i32+1);
|
||||
gd = xEAX+((u8&0x38)>>3);
|
||||
MOV32(gd, addr);
|
||||
break;
|
||||
case 3:
|
||||
SETFLAGS(X_ALL, SF_SET_NODF); // Hack to set flags to "dont'care" state
|
||||
SKIPTEST(x1, x14);
|
||||
BARRIER(BARRIER_FULL);
|
||||
BARRIER_NEXT(BARRIER_FULL);
|
||||
MOV32(x2, addr);
|
||||
PUSH1(x2);
|
||||
MESSAGE(LOG_DUMP, "Native Call to %s (retn=%d)\n", GetNativeName(GetNativeFnc(dyn->insts[ninst].natcall-1)), dyn->insts[ninst].retn);
|
||||
SKIPTEST(x14);
|
||||
// calling a native function
|
||||
if(isRetX87Wrapper(*(wrapper_t*)(dyn->insts[ninst].natcall+2))) {
|
||||
// return value will be on the stack, so the stack depth needs to be updated
|
||||
|
@ -95,7 +95,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
addr = fakeed(dyn, addr, ninst, nextop);
|
||||
SETFLAGS(X_ALL, SF_SET_NODF); // Hack to set flags in "don't care" state
|
||||
//CALL(arm_ud, -1, 0);
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
UDF(0);
|
||||
break;
|
||||
case 0xE0:
|
||||
@ -149,7 +149,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
INST_NAME("UD2");
|
||||
SETFLAGS(X_ALL, SF_SET_NODF); // Hack to set flags in "don't care" state
|
||||
//CALL(arm_ud, -1, 0);
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
UDF(0);
|
||||
break;
|
||||
|
||||
@ -481,7 +481,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
case 0x31:
|
||||
INST_NAME("RDTSC");
|
||||
MESSAGE(LOG_DUMP, "Need Optimization\n");
|
||||
SKIPTEST(x14);
|
||||
SKIPTEST(x1, x14);
|
||||
CALL(ReadTSC, xEAX, 0); // will return the u64 in x1:xEAX
|
||||
MOV_REG(xEDX, x1);
|
||||
break;
|
||||
@ -717,7 +717,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
break;
|
||||
case 0x51:
|
||||
INST_NAME("SQRTPS Gx, Ex");
|
||||
SKIPTEST(x1);
|
||||
SKIPTEST(x1, x14);
|
||||
nextop = F8;
|
||||
GETEX(q0, 0);
|
||||
gd = (nextop&0x38)>>3;
|
||||
@ -786,7 +786,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
break;
|
||||
case 0x52:
|
||||
INST_NAME("RSQRTPS Gx, Ex");
|
||||
SKIPTEST(x1);
|
||||
SKIPTEST(x1, x14);
|
||||
nextop = F8;
|
||||
GETEX(q0, 0);
|
||||
gd = (nextop&0x38)>>3;
|
||||
@ -809,7 +809,7 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
break;
|
||||
case 0x53:
|
||||
INST_NAME("RCPPS Gx, Ex");
|
||||
SKIPTEST(x1);
|
||||
SKIPTEST(x1, x14);
|
||||
nextop = F8;
|
||||
GETEX(q0, 0);
|
||||
gd = (nextop&0x38)>>3;
|
||||
|
@ -51,7 +51,7 @@ uintptr_t dynarecDD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
|
||||
MESSAGE(LOG_DUMP, "Hack for FFREE ST0 / FINCSTP\n");
|
||||
X87_POP_OR_FAIL(dyn, ninst, x1);
|
||||
addr+=2;
|
||||
SKIPTEST(x1);
|
||||
SKIPTEST(x1, x14);
|
||||
} else
|
||||
x87_free(dyn, ninst, x1, x2, x3, nextop&7);
|
||||
#else
|
||||
|
@ -1044,9 +1044,9 @@ static void x87_unreflectcache(dynarec_arm_t* dyn, int ninst, int s1, int s2, in
|
||||
if(a>0) {
|
||||
MOV32(s2, 0xffff);
|
||||
ORR_REG_LSL_IMM5(s1, s1, s2, 16);
|
||||
MOV_REG_LSR_IMM5(s1, s1, -a*2);
|
||||
MOV_REG_LSR_IMM5(s1, s1, a*2);
|
||||
} else {
|
||||
MOV_REG_LSL_IMM5(s1, s1, a*2);
|
||||
MOV_REG_LSL_IMM5(s1, s1, -a*2);
|
||||
}
|
||||
STRH_IMM8(s1, xEmu, offsetof(x86emu_t, fpu_tags));
|
||||
// Sub x87stack to top, with and 7
|
||||
|
@ -894,21 +894,25 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
|
||||
#define MAYUSE(A)
|
||||
#endif
|
||||
|
||||
#define NOTEST(s1) \
|
||||
#define NOTEST(s1, s2) \
|
||||
if(box86_dynarec_test) { \
|
||||
MOVW(s1, 0); \
|
||||
STR_IMM9(s1, xEmu, offsetof(x86emu_t, test.test)); \
|
||||
STR_IMM9(s1, xEmu, offsetof(x86emu_t, test.clean)); \
|
||||
MOVW(s2, offsetof(x86emu_t, test.test)); \
|
||||
STR_REG_LSL_IMM5(s1, xEmu, s2, 0); \
|
||||
ADD_IMM8(s2, s2, offsetof(x86emu_t, test.clean)-offsetof(x86emu_t, test.test));\
|
||||
STR_REG_LSL_IMM5(s1, xEmu, s2, 0); \
|
||||
}
|
||||
#define SKIPTEST(s1) \
|
||||
#define SKIPTEST(s1, s2) \
|
||||
if(box86_dynarec_test) { \
|
||||
MOVW(s1, 0); \
|
||||
STR_IMM9(s1, xEmu, offsetof(x86emu_t, test.clean)); \
|
||||
MOVW(s2, offsetof(x86emu_t, test.clean)); \
|
||||
STR_REG_LSL_IMM5(s1, xEmu, s2, 0); \
|
||||
}
|
||||
#define GOTEST(s1, s2) \
|
||||
if(box86_dynarec_test) { \
|
||||
MOVW(s2, 1); \
|
||||
STR_IMM9(s2, xEmu, offsetof(x86emu_t, test.test)); \
|
||||
MOVW(s1, offsetof(x86emu_t, test.test)); \
|
||||
STR_REG_LSL_IMM5(s2, xEmu, s1, 0); \
|
||||
}
|
||||
|
||||
#endif //__DYNAREC_ARM_HELPER_H__
|
@ -307,14 +307,14 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
|
||||
dyn->insts[ninst].x86.need_after |= X_PEND;
|
||||
#endif
|
||||
++ninst;
|
||||
NOTEST(x3);
|
||||
NOTEST(x1, x3);
|
||||
fpu_purgecache(dyn, ninst, 0, x1, x2, x3);
|
||||
jump_to_next(dyn, addr, 0, ninst);
|
||||
ok=0; need_epilog=0;
|
||||
}
|
||||
}
|
||||
if(need_epilog) {
|
||||
NOTEST(x3);
|
||||
NOTEST(x1, x3);
|
||||
fpu_purgecache(dyn, ninst, 0, x1, x2, x3);
|
||||
jump_to_epilog(dyn, ip, 0, ninst); // no linker here, it's an unknow instruction
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user