8000 [RV64_DYNAREC] Minor x87 changes to enable test31 by ksco · Pull Request #2441 · ptitSeb/box64 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[RV64_DYNAREC] Minor x87 changes to enable test31 #2441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1513,11 +1513,7 @@ add_test(fpu_rounding ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref31.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )

if(ARM_DYNAREC)
set_tests_properties(fpu_rounding PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTROUND=0;BOX64_DYNAREC_TEST=1")
else()
set_tests_properties(fpu_rounding PROPERTIES ENVIRONMENT "BOX64_DYNAREC=0")
endif()
set_tests_properties(fpu_rounding PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTROUND=0")

else()

Expand Down
26 changes: 13 additions & 13 deletions src/dynarec/rv64/dynarec_rv64_d9.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,6 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
ADDI(x5, x5, i2);
ANDI(x5, x5, 7); // (emu->top + i)&7
}
// load tag
LHU(x3, xEmu, offsetof(x64emu_t, fpu_tags));
if (i2 < 0) {
SLLI(x3, x3, -i2 * 2);
} else if (i2 > 0) {
LUI(x2, 0xffff0);
OR(x3, x3, x2);
SRLI(x3, x3, i2 * 2);
}
ANDI(x2, x3, 0b11);
BNEZ_MARK3(x2); // empty: C3,C2,C0 = 101
// load x2 with ST0 anyway, for sign extraction
if (rv64_zba)
SH3ADD(x1, x5, xEmu);
Expand All @@ -171,6 +160,17 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
ADD(x1, xEmu, x5);
}
LD(x2, x1, offsetof(x64emu_t, x87));
// load tag
if (i2 >= 0) {
LHU(x3, xEmu, offsetof(x64emu_t, fpu_tags));
if (i2 > 0) {
LUI(x5, 0xffff0);
OR(x3, x3, x5);
SRLI(x3, x3, i2 * 2);
}
ANDI(x3, x3, 0b11);
BNEZ_MARK3(x3); // empty: C3,C2,C0 = 101
}
}
} else {
// simply move from cache reg to x2
Expand Down Expand Up @@ -312,7 +312,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0xF4:
INST_NAME("FXTRACT");
MESSAGE(LOG_DUMP, "Need Optimization\n");
X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, 0);
X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, x3);
x87_forget(dyn, ninst, x1, x2, 1);
s0 = x87_stackcount(dyn, ninst, x3);
CALL(native_fxtract, -1, 0, 0);
Expand Down Expand Up @@ -376,7 +376,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0xFB:
INST_NAME("FSINCOS");
MESSAGE(LOG_DUMP, "Need Optimization\n");
X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, 0);
X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, x3);
x87_forget(dyn, ninst, x1, x2, 1);
s0 = x87_stackcount(dyn, ninst, x3);
if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2);
Expand Down
8 changes: 6 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_db.c
Original file line number Diff line number Diff line change
Expand Up @ 8000 @ -243,14 +243,14 @@ uintptr_t dynarec64_DB(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 5:
INST_NAME("FLD tbyte");
addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 8, 0);
if ((PK(0) == 0xDB && ((PK(1) >> 3) & 7) == 7) || (PK(0) >= 0x40 && PK(0) <= 0x4f && PK(1) == 0xDB && ((PK(2) >> 3) & 7) == 7)) {
if ((PK(0) == 0xDB && ((PK(1) >> 3) & 7) == 7) || (!rex.is32bits && PK(0) >= 0x40 && PK(0) <= 0x4f && PK(1) == 0xDB && ((PK(2) >> 3) & 7) == 7)) {
// the FLD is immediatly followed by an FSTP
LD(x5, ed, fixedaddress + 0);
LH(x6, ed, fixedaddress + 8);
// no persistant scratch register, so unrool both instruction here...
MESSAGE(LOG_DUMP, "\tHack: FSTP tbyte\n");
nextop = F8; // 0xDB or rex
if (nextop >= 0x40 && nextop <= 0x4f) {
if (!rex.is32bits && nextop >= 0x40 && nextop <= 0x4f) {
rex.rex = nextop;
nextop = F8; // 0xDB
} else
Expand All @@ -266,7 +266,11 @@ uintptr_t dynarec64_DB(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
} else {
ADDI(x1, ed, fixedaddress);
X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, x3);
// sync top
s0 = x87_stackcount(dyn, ninst, x3);
CALL(native_fld, -1, x1, 0);
// go back with the top & stack counter
x87_unstackcount(dyn, ninst, x3, s0);
}
}
break;
Expand Down
10 changes: 2 additions & 8 deletions src/dynarec/rv64/dynarec_rv64_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,6 @@ void x87_do_push_empty(dynarec_rv64_t* dyn, int ninst, int s1)
MESSAGE(LOG_DUMP, "Incoherent x87 stack cache, aborting\n");
dyn->abort = 1;
}
if (s1)
x87_stackcount(dyn, ninst, s1);
}
static void internal_x87_dopop(dynarec_rv64_t* dyn)
{
Expand Down Expand Up @@ -1083,19 +1081,15 @@ void x87_purgecache(dynarec_rv64_t* dyn, int ninst, int next, int s1, int s2, in
// Sub x87stack to top, with and 7
LW(s2, xEmu, offsetof(x64emu_t, top));
// update tags (and top at the same time)
if (a > 0) {
SUBI(s2, s2, a);
} else {
ADDI(s2, s2, -a);
}
SUBI(s2, s2, a);
ANDI(s2, s2, 7);
SW(s2, xEmu, offsetof(x64emu_t, top));
// update tags (and top at the same time)
LHU(s1, xEmu, offsetof(x64emu_t, fpu_tags));
if (a > 0) {
SLLI(s1, s1, a * 2);
} else {
MOV32w(s3, 0xffff0000);
LUI(s3, 0xffff0);
OR(s1, s1, s3);
SRLI(s1, s1, -a * 2);
}
Expand Down
0