diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynarec/dynacache_reloc.c | 14 | ||||
| -rw-r--r-- | src/dynarec/dynacache_reloc.h | 13 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_00_1.c | 4 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_00_3.c | 66 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_0f.c | 36 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_66.c | 12 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_660f38.c | 18 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_consts.c | 139 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_consts.h | 114 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_d9.c | 28 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_db.c | 6 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_dd.c | 4 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_df.c | 4 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_helper.c | 8 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_helper.h | 7 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_private.h | 12 |
16 files changed, 368 insertions, 117 deletions
diff --git a/src/dynarec/dynacache_reloc.c b/src/dynarec/dynacache_reloc.c index 0ebfeb3c..d3d4fa0b 100644 --- a/src/dynarec/dynacache_reloc.c +++ b/src/dynarec/dynacache_reloc.c @@ -237,17 +237,7 @@ int RelocsHaveCancel(dynablock_t* block) return 0; } -uintptr_t RelocGetNext() { - #ifdef DUMMY_GETCONST - return 0; - #else - return getConst(const_native_next); - #endif -} - -#ifdef DUMMY_GETCONST -uintptr_t getConst(native_consts_t which) +uintptr_t RelocGetNext() { - return 0; + return getConst(const_native_next); } -#endif \ No newline at end of file diff --git a/src/dynarec/dynacache_reloc.h b/src/dynarec/dynacache_reloc.h index 40f03019..904788ea 100644 --- a/src/dynarec/dynacache_reloc.h +++ b/src/dynarec/dynacache_reloc.h @@ -3,14 +3,21 @@ #ifdef ARM64 #include "dynarec/arm64/dynarec_arm64_consts.h" -#define native_consts_t arm64_consts_t +#define native_consts_t arm64_consts_t +#elif defined(RV64) +#include "dynarec/rv64/dynarec_rv64_consts.h" +#define native_consts_t rv64_consts_t #else typedef enum native_consts_s { const_none, + const_native_next, const_last } native_consts_t; -#define DUMMY_GETCONST -uintptr_t getConst(native_consts_t which); +inline uintptr_t getConst(native_consts_t which) +{ + (void)which; + return 0; // dummy +} #endif void AddRelocTable64Const(dynarec_native_t* dyn, int ninst, native_consts_t C, int pass); diff --git a/src/dynarec/rv64/dynarec_rv64_00_1.c b/src/dynarec/rv64/dynarec_rv64_00_1.c index a56b1017..44277be8 100644 --- a/src/dynarec/rv64/dynarec_rv64_00_1.c +++ b/src/dynarec/rv64/dynarec_rv64_00_1.c @@ -293,7 +293,7 @@ uintptr_t dynarec64_00_1(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } GETIP(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_priv, -1, 0, 0); + CALL(const_native_priv, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -309,7 +309,7 @@ uintptr_t dynarec64_00_1(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } GETIP(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_priv, -1, 0, 0); + CALL(const_native_priv, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; diff --git a/src/dynarec/rv64/dynarec_rv64_00_3.c b/src/dynarec/rv64/dynarec_rv64_00_3.c index 9287f442..502f8b46 100644 --- a/src/dynarec/rv64/dynarec_rv64_00_3.c +++ b/src/dynarec/rv64/dynarec_rv64_00_3.c @@ -63,7 +63,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEB(x1, 1); u8 = F8; MOV32w(x2, u8); - CALL_(rol8, ed, x3, x1, x2); + CALL_(const_rol8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 1: @@ -73,7 +73,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEB(x1, 1); u8 = F8; MOV32w(x2, u8); - CALL_(ror8, ed, x3, x1, x2); + CALL_(const_ror8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 2: @@ -84,7 +84,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEB(x1, 1); u8 = F8; MOV32w(x2, u8); - CALL_(rcl8, ed, x3, x1, x2); + CALL_(const_rcl8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 3: @@ -95,7 +95,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEB(x1, 1); u8 = F8; MOV32w(x2, u8); - CALL_(rcr8, ed, x3, x1, x2); + CALL_(const_rcr8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 4: @@ -196,7 +196,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEDW(x4, x1, 0); u8 = (F8) & (rex.w ? 0x3f : 0x1f); MOV32w(x2, u8); - CALL_(rex.w ? ((void*)rcl64) : ((void*)rcl32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcl64) : (const_rcl32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -208,7 +208,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETEDW(x4, x1, 0); u8 = (F8) & (rex.w ? 0x3f : 0x1f); MOV32w(x2, u8); - CALL_(rex.w ? ((void*)rcr64) : ((void*)rcr32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcr64) : (const_rcr32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -467,7 +467,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int STORE_XEMU_CALL(x3); ADDI(x3, xRIP, 8 + 8 + 2); // expected return address ADDI(x1, xEmu, (uint32_t)offsetof(x64emu_t, ip)); // setup addr as &emu->ip - CALL_(EmuInt3, -1, x3, x1, 0); + CALL_(const_int3, -1, x3, x1, 0); LOAD_XEMU_CALL(); addr += 8 + 8; BNE_MARK(xRIP, x3); @@ -488,7 +488,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BEQZ_MARK(x3); GETIP(addr, x7); STORE_XEMU_CALL(x3); - CALL(native_int3, -1, 0, 0); + CALL(const_native_int3, -1, 0, 0); LOAD_XEMU_CALL(); MARK; jump_to_epilog(dyn, addr, 0, ninst); @@ -507,7 +507,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETIP(ip, x7); // priviledged instruction, IP not updated STORE_XEMU_CALL(x3); MOV32w(x1, u8); - CALL(native_int, -1, x1, 0); + CALL(const_native_int, -1, x1, 0); LOAD_XEMU_CALL(); } else if (u8 == 0x80) { INST_NAME("32bits SYSCALL"); @@ -515,7 +515,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SMEND(); GETIP(addr, x7); STORE_XEMU_CALL(x3); - CALL_S(EmuX86Syscall, -1, 0); + CALL_S(const_x86syscall, -1, 0); LOAD_XEMU_CALL(); TABLE64(x3, addr); // expected return address BNE_MARK(xRIP, x3); @@ -533,7 +533,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } GETIP(addr, x7); STORE_XEMU_CALL(x3); - CALL(native_int3, -1, 0, 0); + CALL(const_native_int3, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -547,7 +547,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } GETIP(ip, x7); // priviledged instruction, IP not updated STORE_XEMU_CALL(x3); - CALL(native_priv, -1, 0, 0); + CALL(const_native_priv, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -578,7 +578,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } MESSAGE(LOG_DUMP, "Need Optimization\n"); SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); - CALL_(rol8, ed, x3, x1, x2); + CALL_(const_rol8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 1: @@ -593,7 +593,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int } MESSAGE(LOG_DUMP, "Need Optimization\n"); SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); - CALL_(ror8, ed, x3, x1, x2); + CALL_(const_ror8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 2: @@ -609,7 +609,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int MESSAGE(LOG_DUMP, "Need Optimization\n"); READFLAGS(X_CF); SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); - CALL_(rcl8, ed, x3, x1, x2); + CALL_(const_rcl8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 3: @@ -625,7 +625,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int MESSAGE(LOG_DUMP, "Need Optimization\n"); READFLAGS(X_CF); SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); - CALL_(rcr8, ed, x3, x1, x2); + CALL_(const_rcr8, ed, x3, x1, x2); EBBACK(x5, 0); break; case 4: @@ -710,7 +710,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); MOV32w(x2, 1); GETEDW(x4, x1, 0); - CALL_(rex.w ? ((void*)rcl64) : ((void*)rcl32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcl64) : (const_rcl32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -721,7 +721,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); MOV32w(x2, 1); GETEDW(x4, x1, 0); - CALL_(rex.w ? ((void*)rcr64) : ((void*)rcr32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcr64) : (const_rcr32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -780,7 +780,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); ANDI(x2, xRCX, rex.w ? 0x3f : 0x1f); GETEDW(x4, x1, 0); - CALL_(rex.w ? ((void*)rcl64) : ((void*)rcl32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcl64) : (const_rcl32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -791,7 +791,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); ANDI(x2, xRCX, rex.w ? 0x3f : 0x1f); GETEDW(x4, x1, 0); - CALL_(rex.w ? ((void*)rcr64) : ((void*)rcr32), ed, x4, x1, x2); + CALL_(rex.w ? (const_rcr64) : (const_rcr32), ed, x4, x1, x2); WBACK; if (!wback && !rex.w) ZEROUP(ed); break; @@ -1003,7 +1003,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int GETIP_(dyn->insts[ninst].natcall, x7); // read the 0xCC already STORE_XEMU_CALL(x3); ADDI(x1, xEmu, (uint32_t)offsetof(x64emu_t, ip)); // setup addr as &emu->ip - CALL_S(EmuInt3, -1, x1); + CALL_S(const_int3, -1, x1); LOAD_XEMU_CALL(); MOV64x(x3, dyn->insts[ninst].natcall); ADDI(x3, x3, 2 + 8 + 8); @@ -1124,7 +1124,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state GETIP(ip, x7); STORE_XEMU_CALL(xRIP); - CALL(native_priv, -1, 0, 0); + CALL(const_native_priv, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -1204,7 +1204,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int MESSAGE(LOG_DUMP, "Need Optimization\n"); SETFLAGS(X_ALL, SF_SET_DF, NAT_FLAGS_NOFUSION); GETEB(x1, 0); - CALL(div8, -1, x1, 0); + CALL(const_div8, -1, x1, 0); break; case 7: INST_NAME("IDIV Eb"); @@ -1212,7 +1212,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int MESSAGE(LOG_DUMP, "Need Optimization\n"); SETFLAGS(X_ALL, SF_SET_DF, NAT_FLAGS_NOFUSION); GETEB(x1, 0); - CALL(idiv8, -1, x1, 0); + CALL(const_idiv8, -1, x1, 0); break; } break; @@ -1326,14 +1326,14 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int MESSAGE(LOG_INFO, "Divide by 0 hack\n"); GETIP(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); LOAD_XEMU_CALL(); } else { if (BOX64ENV(dynarec_div0)) { BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1361,7 +1361,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1376,14 +1376,14 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); MARK3; } BEQ_MARK(xRDX, xZR); - CALL(div64, -1, ed, 0); + CALL(const_div64, -1, ed, 0); B_NEXT_nocond; MARK; DIVU(x2, xRAX, ed); @@ -1403,7 +1403,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1426,7 +1426,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1441,7 +1441,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1456,7 +1456,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int BNE_MARK3(x2, xZR); BLT_MARK(xRAX, xZR); MARK3; - CALL((void*)idiv64, -1, ed, 0); + CALL(const_idiv64, -1, ed, 0); B_NEXT_nocond; MARK; DIV(x2, xRAX, ed); diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c index 32db4a8f..d1745b7d 100644 --- a/src/dynarec/rv64/dynarec_rv64_0f.c +++ b/src/dynarec/rv64/dynarec_rv64_0f.c @@ -89,7 +89,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni INST_NAME("RDTSCP"); NOTEST(x1); if (box64_rdtsc) { - CALL(ReadTSC, x3, 0, 0); // will return the u64 in x3 + CALL(const_readtsc, x3, 0, 0); // will return the u64 in x3 } else { CSRRS(x3, xZR, 0xC01); // RDTIME } @@ -116,7 +116,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMEND(); GETIP(addr, x7); STORE_XEMU_CALL(x3); - CALL_S(EmuX64Syscall, -1, 0); + CALL_S(const_x64syscall, -1, 0); LOAD_XEMU_CALL(); TABLE64(x3, addr); // expected return address BNE_MARK(xRIP, x3); @@ -136,7 +136,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni } GETIP(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_ud, -1, 0, 0); + CALL(const_native_ud, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -152,7 +152,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni } GETIP(ip, x7); STORE_XEMU_CALL(x3); - CALL(native_ud, -1, 0, 0); + CALL(const_native_ud, -1, 0, 0); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); *need_epilog = 0; @@ -445,7 +445,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni INST_NAME("RDTSC"); NOTEST(x1); if (box64_rdtsc) { - CALL(ReadTSC, x3, 0, 0); // will return the u64 in x3 + CALL(const_readtsc, x3, 0, 0); // will return the u64 in x3 } else { CSRRS(x3, xZR, 0xC01); // RDTIME } @@ -831,22 +831,22 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni sse_reflect_reg(dyn, ninst, x6, 0); switch (u8) { case 0xC8: - CALL(sha1nexte, -1, x1, ed); + CALL(const_sha1nexte, -1, x1, ed); break; case 0xC9: - CALL(sha1msg1, -1, x1, ed); + CALL(const_sha1msg1, -1, x1, ed); break; case 0xCA: - CALL(sha1msg2, -1, x1, ed); + CALL(const_sha1msg2, -1, x1, ed); break; case 0xCB: - CALL(sha256rnds2, -1, x1, ed); + CALL(const_sha256rnds2, -1, x1, ed); break; case 0xCC: - CALL(sha256msg1, -1, x1, ed); + CALL(const_sha256msg1, -1, x1, ed); break; case 0xCD: - CALL(sha256msg2, -1, x1, ed); + CALL(const_sha256msg2, -1, x1, ed); break; } break; @@ -920,7 +920,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni sse_forget_reg(dyn, ninst, x6, gd); ADDI(x1, xEmu, offsetof(x64emu_t, xmm[gd])); MOV32w(x3, u8); - CALL4(sha1rnds4, -1, x1, wback, x3, 0); + CALL4(const_sha1rnds4, -1, x1, wback, x3, 0); break; default: DEFAULT; @@ -1818,7 +1818,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni case 0xA2: INST_NAME("CPUID"); NOTEST(x1); - CALL_(my_cpuid, -1, 0, xRAX, 0); + CALL_(const_cpuid, -1, 0, xRAX, 0); // BX and DX are not synchronized during the call, so need to force the update LD(xRDX, xEmu, offsetof(x64emu_t, regs[_DX])); LD(xRBX, xEmu, offsetof(x64emu_t, regs[_BX])); @@ -1963,7 +1963,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SKIPTEST(x1); fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x3, &fixedaddress, rex, NULL, 0, 0); - CALL(rex.is32bits ? ((void*)fpu_fxsave32) : ((void*)fpu_fxsave64), -1, ed, 0); + CALL(rex.is32bits ? (const_fpu_fxsave32) : (const_fpu_fxsave64), -1, ed, 0); break; case 1: INST_NAME("FXRSTOR Ed"); @@ -1971,7 +1971,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SKIPTEST(x1); fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x3, &fixedaddress, rex, NULL, 0, 0); - CALL(rex.is32bits ? ((void*)fpu_fxrstor32) : ((void*)fpu_fxrstor64), -1, ed, 0); + CALL(rex.is32bits ? (const_fpu_fxrstor32) : (const_fpu_fxrstor64), -1, ed, 0); break; case 2: INST_NAME("LDMXCSR Md"); @@ -1993,7 +1993,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); MOV32w(x2, rex.w ? 0 : 1); - CALL((void*)fpu_xsave, -1, ed, x2); + CALL(const_fpu_xsave, -1, ed, x2); break; case 5: INST_NAME("XRSTOR Ed"); @@ -2001,13 +2001,13 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); MOV32w(x2, rex.w ? 0 : 1); - CALL((void*)fpu_xrstor, -1, ed, x2); + CALL(const_fpu_xrstor, -1, ed, x2); break; case 7: INST_NAME("CLFLUSH Ed"); MESSAGE(LOG_DUMP, "Need Optimization?\n"); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); - CALL_(native_clflush, -1, 0, ed, 0); + CALL_(const_native_clflush, -1, 0, ed, 0); break; default: DEFAULT; diff --git a/src/dynarec/rv64/dynarec_rv64_66.c b/src/dynarec/rv64/dynarec_rv64_66.c index ce6ff3d7..df7edff5 100644 --- a/src/dynarec/rv64/dynarec_rv64_66.c +++ b/src/dynarec/rv64/dynarec_rv64_66.c @@ -1294,7 +1294,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS(); GETEW(x1, 1); - CALL_(rol16, x1, x3, x1, x2); + CALL_(const_rol16, x1, x3, x1, x2); EWBACK; break; case 1: @@ -1304,7 +1304,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS(); GETEW(x1, 1); - CALL_(ror16, x1, x3, x1, x2); + CALL_(const_ror16, x1, x3, x1, x2); EWBACK; break; case 2: @@ -1315,7 +1315,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS(); GETEW(x1, 1); - CALL_(rcl16, x1, x3, x1, x2); + CALL_(const_rcl16, x1, x3, x1, x2); EWBACK; break; case 3: @@ -1326,7 +1326,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION); if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS(); GETEW(x1, 1); - CALL_(rcr16, x1, x3, x1, x2); + CALL_(const_rcr16, x1, x3, x1, x2); EWBACK; break; case 5: @@ -1436,7 +1436,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x6); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); @@ -1457,7 +1457,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni BNE_MARK3(ed, xZR); GETIP_(ip, x7); STORE_XEMU_CALL(x6); - CALL(native_div0, -1, 0, 0); + CALL(const_native_div0, -1, 0, 0); CLEARIP(); LOAD_XEMU_CALL(); jump_to_epilog(dyn, 0, xRIP, ninst); diff --git a/src/dynarec/rv64/dynarec_rv64_660f38.c b/src/dynarec/rv64/dynarec_rv64_660f38.c index 658a0531..f5254d6d 100644 --- a/src/dynarec/rv64/dynarec_rv64_660f38.c +++ b/src/dynarec/rv64/dynarec_rv64_660f38.c @@ -749,7 +749,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, MV(x4, xRAX); u8 = F8; MOV32w(x5, u8); - CALL6(sse42_compare_string_explicit_len, x1, ed, x2, x3, x4, x5, 0); + CALL6(const_sse42_compare_string_explicit_len, x1, ed, x2, x3, x4, x5, 0); ZEROUP(x1); BNEZ_MARK(x1); MOV32w(xRCX, (u8 & 1) ? 8 : 16); @@ -771,7 +771,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, SSE_LOOP_MV_Q(x3); sse_forget_reg(dyn, ninst, x6, gd); MOV32w(x1, gd); - CALL(native_aesimc, -1, x1, 0); + CALL(const_native_aesimc, -1, x1, 0); break; case 0xDC: INST_NAME("AESENC Gx, Ex"); // AES-NI @@ -779,7 +779,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, GETG; sse_forget_reg(dyn, ninst, x6, gd); MOV32w(x1, gd); - CALL(native_aese, -1, x1, 0); + CALL(const_native_aese, -1, x1, 0); GETGX(); GETEX(x2, 0, 8); SSE_LOOP_Q(x3, x4, XOR(x3, x3, x4)); @@ -790,7 +790,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, GETG; sse_forget_reg(dyn, ninst, x6, gd); MOV32w(x1, gd); - CALL(native_aeselast, -1, x1, 0); + CALL(const_native_aeselast, -1, x1, 0); GETGX(); GETEX(x2, 0, 8); SSE_LOOP_Q(x3, x4, XOR(x3, x3, x4)); @@ -801,7 +801,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, GETG; sse_forget_reg(dyn, ninst, x6, gd); MOV32w(x1, gd); - CALL(native_aesd, -1, x1, 0); + CALL(const_native_aesd, -1, x1, 0); GETGX(); GETEX(x2, 0, 8); SSE_LOOP_Q(x3, x4, XOR(x3, x3, x4)); @@ -813,7 +813,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, GETG; sse_forget_reg(dyn, ninst, x6, gd); MOV32w(x1, gd); - CALL(native_aesdlast, -1, x1, 0); + CALL(const_native_aesdlast, -1, x1, 0); GETGX(); GETEX(x2, 0, 8); SSE_LOOP_Q(x3, x4, XOR(x3, x3, x4)); @@ -1216,7 +1216,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, } u8 = F8; MOV32w(x4, u8); - CALL4(native_pclmul, -1, x1, x2, x3, x4); + CALL4(const_native_pclmul, -1, x1, x2, x3, x4); break; case 0x63: INST_NAME("PCMPISTRI Gx, Ex, Ib"); @@ -1235,7 +1235,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, } u8 = F8; MOV32w(x3, u8); - CALL4(sse42_compare_string_implicit_len, x1, ed, x2, x3, 0); + CALL4(const_sse42_compare_string_implicit_len, x1, ed, x2, x3, 0); ZEROUP(x1); BNEZ_MARK(x1); MOV32w(xRCX, (u8 & 1) ? 8 : 16); @@ -1269,7 +1269,7 @@ uintptr_t dynarec64_660F38(dynarec_rv64_t* dyn, uintptr_t addr, uint8_t opcode, } u8 = F8; MOV32w(x4, u8); - CALL4(native_aeskeygenassist, -1, x1, x2, x3, x4); + CALL4(const_native_aeskeygenassist, -1, x1, x2, x3, x4); break; default: DEFAULT; diff --git a/src/dynarec/rv64/dynarec_rv64_consts.c b/src/dynarec/rv64/dynarec_rv64_consts.c new file mode 100644 index 00000000..4dc44ade --- /dev/null +++ b/src/dynarec/rv64/dynarec_rv64_consts.c @@ -0,0 +1,139 @@ +#include <stdint.h> +#include <string.h> + +#include "dynarec_rv64_consts.h" +#include "debug.h" +#include "box64context.h" +#include "box64cpu.h" +#include "emu/x64emu_private.h" +#include "x64emu.h" +#include "box64stack.h" +#include "callback.h" +#include "emu/x64run_private.h" +#include "emu/x87emu_private.h" +#include "emu/x64primop.h" +#include "my_cpuid.h" +#include "freq.h" +#include "debug.h" +#include "custommem.h" +#include "dynarec_rv64_functions.h" +#include "emu/x64shaext.h" +#include "emu/x87emu_private.h" +#include "emu/x64compstrings.h" +#include "x64test.h" +#include "dynarec/dynarec_next.h" + +#ifndef HAVE_TRACE +void PrintTrace() {} +#endif + +uintptr_t getConst(rv64_consts_t which) +{ + switch(which) { + case const_none: dynarec_log(LOG_NONE, "Warning, const none used\n"); + return 0; + case const_daa8: return (uintptr_t)daa8; + case const_das8: return (uintptr_t)das8; + case const_aaa16: return (uintptr_t)aaa16; + case const_aas16: return (uintptr_t)aas16; + case const_aam16: return (uintptr_t)aam16; + case const_aad16: return (uintptr_t)aad16; + case const_native_br: return (uintptr_t)native_br; + case const_native_ud: return (uintptr_t)native_ud; + case const_native_priv: return (uintptr_t)native_priv; + case const_native_int3: return (uintptr_t)native_int3; + case const_native_int: return (uintptr_t)native_int; + case const_native_div0: return (uintptr_t)native_div0; + case const_native_clflush: return (uintptr_t)native_clflush; + case const_native_fprem: return (uintptr_t)native_fprem; + case const_native_fprem1: return (uintptr_t)native_fprem1; + case const_native_frstor16: return (uintptr_t)native_frstor16; + case const_native_fsave16: return (uintptr_t)native_fsave16; + case const_native_fsave: return (uintptr_t)native_fsave; + case const_native_aesimc: return (uintptr_t)native_aesimc; + case const_native_aesd: return (uintptr_t)native_aesd; + case const_native_aesd_y: return (uintptr_t)native_aesd_y; + case const_native_aesdlast: return (uintptr_t)native_aesdlast; + case const_native_aesdlast_y: return (uintptr_t)native_aesdlast_y; + case const_native_aese: return (uintptr_t)native_aese; + case const_native_aese_y: return (uintptr_t)native_aese_y; + case const_native_aeselast: return (uintptr_t)native_aeselast; + case const_native_aeselast_y: return (uintptr_t)native_aeselast_y; + case const_native_aeskeygenassist: return (uintptr_t)native_aeskeygenassist; + case const_native_pclmul: return (uintptr_t)native_pclmul; + case const_native_pclmul_x: return (uintptr_t)native_pclmul_x; + case const_native_pclmul_y: return (uintptr_t)native_pclmul_y; + case const_native_f2xm1: return (uintptr_t)native_f2xm1; + case const_native_fyl2x: return (uintptr_t)native_fyl2x; + case const_native_fyl2xp1: return (uintptr_t)native_fyl2xp1; + case const_native_fxtract: return (uintptr_t)native_fxtract; + case const_native_ftan: return (uintptr_t)native_ftan; + case const_native_fpatan: return (uintptr_t)native_fpatan; + case const_native_fcos: return (uintptr_t)native_fcos; + case const_native_fsin: return (uintptr_t)native_fsin; + case const_native_fsincos: return (uintptr_t)native_fsincos; + case const_native_fscale: return (uintptr_t)native_fscale; + case const_native_fld: return (uintptr_t)native_fld; + case const_native_fstp: return (uintptr_t)native_fstp; + case const_native_frstor: return (uintptr_t)native_frstor; + case const_native_next: return (uintptr_t)native_next; + case const_int3: return (uintptr_t)EmuInt3; + case const_x86syscall: return (uintptr_t)EmuX86Syscall; + case const_x64syscall: return (uintptr_t)EmuX64Syscall; + case const_rcl8: return (uintptr_t)rcl8; + case const_rcl16: return (uintptr_t)rcl16; + case const_rcl32: return (uintptr_t)rcl32; + case const_rcl64: return (uintptr_t)rcl64; + case const_rcr8: return (uintptr_t)rcr8; + case const_rcr16: return (uintptr_t)rcr16; + case const_rcr32: return (uintptr_t)rcr32; + case const_rcr64: return (uintptr_t)rcr64; + case const_rol8: return (uintptr_t)rol8; + case const_rol16: return (uintptr_t)rol16; + case const_ror8: return (uintptr_t)ror8; + case const_ror16: return (uintptr_t)ror16; + case const_div64: return (uintptr_t)div64; + case const_div8: return (uintptr_t)div8; + case const_idiv64: return (uintptr_t)idiv64; + case const_idiv8: return (uintptr_t)idiv8; + case const_random32: return (uintptr_t)get_random32; + case const_random64: return (uintptr_t)get_random64; + case const_readtsc: return (uintptr_t)ReadTSC; + case const_helper_getcpu: return (uintptr_t)helper_getcpu; + case const_cpuid: return (uintptr_t)my_cpuid; + case const_getsegmentbase: return (uintptr_t)GetSegmentBaseEmu; + case const_updateflags: return (uintptr_t)UpdateFlags; + case const_reset_fpu: return (uintptr_t)reset_fpu; + case const_sha1nexte: return (uintptr_t)sha1nexte; + case const_sha1msg1: return (uintptr_t)sha1msg1; + case const_sha1msg2: return (uintptr_t)sha1msg2; + case const_sha1rnds4: return (uintptr_t)sha1rnds4; + case const_sha256msg1: return (uintptr_t)sha256msg1; + case const_sha256msg2: return (uintptr_t)sha256msg2; + case const_sha256rnds2: return (uintptr_t)sha256rnds2; + case const_fpu_loadenv: return (uintptr_t)fpu_loadenv; + case const_fpu_savenv: return (uintptr_t)fpu_savenv; + case const_fpu_fxsave32: return (uintptr_t)fpu_fxsave32; + case const_fpu_fxsave64: return (uintptr_t)fpu_fxsave64; + case const_fpu_fxrstor32: return (uintptr_t)fpu_fxrstor32; + case const_fpu_fxrstor64: return (uintptr_t)fpu_fxrstor64; + case const_fpu_xsave: return (uintptr_t)fpu_xsave; + case const_fpu_xrstor: return (uintptr_t)fpu_xrstor; + case const_fpu_fbld: return (uintptr_t)fpu_fbld; + case const_fpu_fbst: return (uintptr_t)fpu_fbst; + case const_sse42_compare_string_explicit_len: return (uintptr_t)sse42_compare_string_explicit_len; + case const_sse42_compare_string_implicit_len: return (uintptr_t)sse42_compare_string_implicit_len; + case const_x64test_step: return (uintptr_t)x64test_step; + case const_printtrace: return (uintptr_t)PrintTrace; + case const_epilog: return (uintptr_t)native_epilog; + case const_jmptbl32: return getJumpTable32(); + case const_jmptbl48: return getJumpTable48(); + case const_jmptbl64: return getJumpTable64(); + case const_context: return (uintptr_t)my_context; + + case const_last: dynarec_log(LOG_NONE, "Warning, const last used\n"); + return 0; + } + dynarec_log(LOG_NONE, "Warning, Unknown const %d used\n", which); + return 0; +} \ No newline at end of file diff --git a/src/dynarec/rv64/dynarec_rv64_consts.h b/src/dynarec/rv64/dynarec_rv64_consts.h new file mode 100644 index 00000000..03973b3b --- /dev/null +++ b/src/dynarec/rv64/dynarec_rv64_consts.h @@ -0,0 +1,114 @@ +#ifndef __DYNAREC_RV64_CONSTS__ +#define __DYNAREC_RV64_CONSTS__ +#include <stdint.h> + +typedef enum rv64_consts_s { + const_none, + const_daa8, + const_das8, + const_aaa16, + const_aas16, + const_aam16, + const_aad16, + const_native_br, + const_native_ud, + const_native_priv, + const_native_int3, + const_native_int, + const_native_div0, + const_native_clflush, + const_native_fprem, + const_native_fprem1, + const_native_frstor16, + const_native_fsave16, + const_native_fsave, + const_native_aesimc, + const_native_aesd, + const_native_aesd_y, + const_native_aesdlast, + const_native_aesdlast_y, + const_native_aese, + const_native_aese_y, + const_native_aeselast, + const_native_aeselast_y, + const_native_aeskeygenassist, + const_native_pclmul, + const_native_pclmul_x, + const_native_pclmul_y, + const_native_f2xm1, + const_native_fyl2x, + const_native_fyl2xp1, + const_native_fxtract, + const_native_ftan, + const_native_fpatan, + const_native_fcos, + const_native_fsin, + const_native_fsincos, + const_native_fscale, + const_native_fld, + const_native_fstp, + const_native_frstor, + const_native_next, + const_int3, + const_x86syscall, + const_x64syscall, + const_rcl8, + const_rcl16, + const_rcl32, + const_rcl64, + const_rcr8, + const_rcr16, + const_rcr32, + const_rcr64, + const_rol8, + const_rol16, + const_ror8, + const_ror16, + const_div64, + const_div8, + const_idiv64, + const_idiv8, + const_random32, + const_random64, + const_readtsc, + const_helper_getcpu, + const_cpuid, + const_getsegmentbase, + const_updateflags, + const_reset_fpu, + const_sha1nexte, + const_sha1msg1, + const_sha1msg2, + const_sha1rnds4, + const_sha256msg1, + const_sha256msg2, + const_sha256rnds2, + const_fpu_loadenv, + const_fpu_savenv, + const_fpu_fxsave32, + const_fpu_fxsave64, + const_fpu_fxrstor32, + const_fpu_fxrstor64, + const_fpu_xsave, + const_fpu_xrstor, + const_fpu_fbld, + const_fpu_fbst, + const_sse42_compare_string_explicit_len, + const_sse42_compare_string_implicit_len, + const_x64test_step, + const_printtrace, + const_epilog, + const_jmptbl32, + const_jmptbl48, + const_jmptbl64, + const_context, + + const_last +} rv64_consts_t; + +uintptr_t getConst(rv64_consts_t which); + +// temporary define... +#define const_PrintTrace const_printtrace + +#endif //__DYNAREC_RV64_CONSTS__ \ No newline at end of file diff --git a/src/dynarec/rv64/dynarec_rv64_d9.c b/src/dynarec/rv64/dynarec_rv64_d9.c index 852bd0ad..16f4f84b 100644 --- a/src/dynarec/rv64/dynarec_rv64_d9.c +++ b/src/dynarec/rv64/dynarec_rv64_d9.c @@ -245,7 +245,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni MESSAGE(LOG_DUMP, "Need Optimization\n"); x87_forget(dyn, ninst, x1, x2, 0); s0 = x87_stackcount(dyn, ninst, x3); - CALL(native_f2xm1, -1, 0, 0); + CALL(const_native_f2xm1, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); break; case 0xF1: @@ -254,7 +254,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); - CALL(native_fyl2x, -1, 0, 0); + CALL(const_native_fyl2x, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); X87_POP_OR_FAIL(dyn, ninst, x3); break; @@ -264,7 +264,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_ftan, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_ftan, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); X87_PUSH_OR_FAIL(v1, dyn, ninst, x1, EXT_CACHE_ST_F); @@ -283,7 +283,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_fpatan, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_fpatan, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); X87_POP_OR_FAIL(dyn, ninst, x3); @@ -294,7 +294,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni 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); + CALL(const_native_fxtract, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); break; case 0xF5: @@ -303,7 +303,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); - CALL(native_fprem1, -1, 0, 0); + CALL(const_native_fprem1, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); break; case 0xF6: @@ -328,7 +328,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); - CALL(native_fprem, -1, 0, 0); + CALL(const_native_fprem, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); break; case 0xF9: @@ -337,7 +337,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); - CALL(native_fyl2xp1, -1, 0, 0); + CALL(const_native_fyl2xp1, -1, 0, 0); x87_unstackcount(dyn, ninst, x3, s0); X87_POP_OR_FAIL(dyn, ninst, x3); break; @@ -360,7 +360,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_fsincos, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_fsincos, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); break; @@ -411,7 +411,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 1); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_fscale, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_fscale, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); break; @@ -421,7 +421,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_fsin, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_fsin, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); break; @@ -431,7 +431,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); s0 = x87_stackcount(dyn, ninst, x3); if (!BOX64ENV(dynarec_fastround)) u8 = x87_setround(dyn, ninst, x1, x2); - CALL_(native_fcos, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); + CALL_(const_native_fcos, -1, BOX64ENV(dynarec_fastround) ? 0 : u8, 0, 0); if (!BOX64ENV(dynarec_fastround)) x87_restoreround(dyn, ninst, u8); x87_unstackcount(dyn, ninst, x3, s0); break; @@ -482,7 +482,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni fpu_purgecache(dyn, ninst, 0, x1, x2, x3); // maybe only x87, not SSE? addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); MOV32w(x2, 0); - CALL(fpu_loadenv, -1, ed, x2); + CALL(const_fpu_loadenv, -1, ed, x2); NATIVE_RESTORE_X87PC(); break; case 5: @@ -500,7 +500,7 @@ uintptr_t dynarec64_D9(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni fpu_purgecache(dyn, ninst, 0, x1, x2, x3); // maybe only x87, not SSE? addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); MOV32w(x2, 0); - CALL(fpu_savenv, -1, ed, x2); + CALL(const_fpu_savenv, -1, ed, x2); break; case 7: INST_NAME("FNSTCW Ew"); diff --git a/src/dynarec/rv64/dynarec_rv64_db.c b/src/dynarec/rv64/dynarec_rv64_db.c index 26c31b45..c07e35a5 100644 --- a/src/dynarec/rv64/dynarec_rv64_db.c +++ b/src/dynarec/rv64/dynarec_rv64_db.c @@ -111,7 +111,7 @@ uintptr_t dynarec64_DB(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni INST_NAME("FNINIT"); MESSAGE(LOG_DUMP, "Need Optimization\n"); x87_purgecache(dyn, ninst, 0, x1, x2, x3); - CALL(reset_fpu, -1, 0, 0); + CALL(const_reset_fpu, -1, 0, 0); NATIVE_RESTORE_X87PC(); break; case 0xE8 ... 0xEF: @@ -221,7 +221,7 @@ uintptr_t dynarec64_DB(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni ADDI(x1, ed, fixedaddress); X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, x3); x87_reflectcount(dyn, ninst, x3, x4); - CALL(native_fld, -1, x1, 0); + CALL(const_native_fld, -1, x1, 0); x87_unreflectcount(dyn, ninst, x3, x4); } } @@ -236,7 +236,7 @@ uintptr_t dynarec64_DB(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x3, 0); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); x87_reflectcount(dyn, ninst, x3, x4); - CALL(native_fstp, -1, ed, 0); + CALL(const_native_fstp, -1, ed, 0); x87_unreflectcount(dyn, ninst, x3, x4); } X87_POP_OR_FAIL(dyn, ninst, x3); diff --git a/src/dynarec/rv64/dynarec_rv64_dd.c b/src/dynarec/rv64/dynarec_rv64_dd.c index 4035377a..d8cadd7f 100644 --- a/src/dynarec/rv64/dynarec_rv64_dd.c +++ b/src/dynarec/rv64/dynarec_rv64_dd.c @@ -153,14 +153,14 @@ uintptr_t dynarec64_DD(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni MESSAGE(LOG_DUMP, "Need Optimization (FRSTOR)\n"); fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x4, x6, &fixedaddress, rex, NULL, 0, 0); - CALL(native_frstor, -1, ed, 0); + CALL(const_native_frstor, -1, ed, 0); break; case 6: INST_NAME("FNSAVE m108byte"); MESSAGE(LOG_DUMP, "Need Optimization\n"); fpu_purgecache(dyn, ninst, 0, x1, x2, x3); addr = geted(dyn, addr, ninst, nextop, &ed, x4, x6, &fixedaddress, rex, NULL, 0, 0); - CALL(native_fsave, -1, ed, 0); + CALL(const_native_fsave, -1, ed, 0); NATIVE_RESTORE_X87PC(); break; case 7: diff --git a/src/dynarec/rv64/dynarec_rv64_df.c b/src/dynarec/rv64/dynarec_rv64_df.c index 5831a30c..baff028f 100644 --- a/src/dynarec/rv64/dynarec_rv64_df.c +++ b/src/dynarec/rv64/dynarec_rv64_df.c @@ -214,7 +214,7 @@ uintptr_t dynarec64_DF(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni X87_PUSH_EMPTY_OR_FAIL(dyn, ninst, x1); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); s0 = x87_stackcount(dyn, ninst, x3); - CALL(fpu_fbld, -1, ed, 0); + CALL(const_fpu_fbld, -1, ed, 0); x87_unstackcount(dyn, ninst, x3, s0); break; case 5: @@ -250,7 +250,7 @@ uintptr_t dynarec64_DF(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni x87_forget(dyn, ninst, x1, x2, 0); addr = geted(dyn, addr, ninst, nextop, &ed, x1, x2, &fixedaddress, rex, NULL, 0, 0); s0 = x87_stackcount(dyn, ninst, x3); - CALL(fpu_fbst, -1, ed, 0); + CALL(const_fpu_fbst, -1, ed, 0); x87_unstackcount(dyn, ninst, x3, s0); X87_POP_OR_FAIL(dyn, ninst, x3); break; diff --git a/src/dynarec/rv64/dynarec_rv64_helper.c b/src/dynarec/rv64/dynarec_rv64_helper.c index 117045d0..f051f208 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.c +++ b/src/dynarec/rv64/dynarec_rv64_helper.c @@ -765,7 +765,7 @@ void iret_to_epilog(dynarec_rv64_t* dyn, uintptr_t ip, int ninst, int is64bits) CLEARIP(); } -void call_c(dynarec_rv64_t* dyn, int ninst, void* fnc, int reg, int ret, int saveflags, int savereg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) +void call_c(dynarec_rv64_t* dyn, int ninst, rv64_consts_t fnc, int reg, int ret, int saveflags, int savereg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { MAYUSE(fnc); if (savereg == 0) @@ -787,7 +787,7 @@ void call_c(dynarec_rv64_t* dyn, int ninst, void* fnc, int reg, int ret, int sav STORE_REG(RAX); SD(xRIP, xEmu, offsetof(x64emu_t, ip)); } - TABLE64(reg, (uintptr_t)fnc); + TABLE64(reg, getConst(fnc)); MV(A0, xEmu); if (arg1) MV(A1, arg1); if (arg2) MV(A2, arg2); @@ -884,7 +884,7 @@ void grab_segdata(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, int reg, int s CBZ_MARKSEG(t1); } MOV64x(x1, segment); - call_c(dyn, ninst, GetSegmentBaseEmu, t2, reg, 0, xFlags, x1, 0, 0, 0, 0, 0); + call_c(dyn, ninst, const_getsegmentbase, t2, reg, 0, xFlags, x1, 0, 0, 0, 0, 0); MARKSEG; MESSAGE(LOG_DUMP, "----%s Offset\n", (segment == _FS) ? "FS" : "GS"); } @@ -2784,7 +2784,7 @@ static void flagsCacheTransform(dynarec_rv64_t* dyn, int ninst, int s1) j64 = (GETMARKF2) - (dyn->native_size); BEQZ(s1, j64); } - CALL_(UpdateFlags, -1, 0, 0, 0); + CALL_(const_updateflags, -1, 0, 0, 0); MARKF2; } } diff --git a/src/dynarec/rv64/dynarec_rv64_helper.h b/src/dynarec/rv64/dynarec_rv64_helper.h index 40857156..8635d242 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.h +++ b/src/dynarec/rv64/dynarec_rv64_helper.h @@ -17,6 +17,7 @@ #include "debug.h" #include "rv64_emitter.h" #include "../emu/x64primop.h" +#include "dynarec_rv64_consts.h" #define F8 *(uint8_t*)(addr++) #define F8S *(int8_t*)(addr++) @@ -903,7 +904,7 @@ MOV_U12(S, (N)); \ SW(S, xEmu, offsetof(x64emu_t, df)); \ if (dyn->f.pending == SF_PENDING && dyn->insts[ninst].x64.need_after && !(dyn->insts[ninst].x64.need_after & X_PEND)) { \ - CALL_(UpdateFlags, -1, 0, 0, 0); \ + CALL_(const_updateflags, -1, 0, 0, 0); \ dyn->f.pending = SF_SET; \ SET_NODF(); \ } \ @@ -1047,7 +1048,7 @@ j64 = (GETMARKF) - (dyn->native_size); \ BEQ(x3, xZR, j64); \ } \ - CALL_(UpdateFlags, -1, 0, 0, 0); \ + CALL_(const_updateflags, -1, 0, 0, 0); \ MARKF; \ dyn->f.pending = SF_SET; \ SET_DFOK(); \ @@ -1445,7 +1446,7 @@ void jump_to_next(dynarec_rv64_t* dyn, uintptr_t ip, int reg, int ninst, int is3 void ret_to_epilog(dynarec_rv64_t* dyn, uintptr_t ip, int ninst, rex_t rex); void retn_to_epilog(dynarec_rv64_t* dyn, uintptr_t ip, int ninst, rex_t rex, int n); void iret_to_epilog(dynarec_rv64_t* dyn, uintptr_t ip, int ninst, int is64bits); -void call_c(dynarec_rv64_t* dyn, int ninst, void* fnc, int reg, int ret, int saveflags, int savereg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); +void call_c(dynarec_rv64_t* dyn, int ninst, rv64_consts_t fnc, int reg, int ret, int saveflags, int savereg, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); void call_n(dynarec_rv64_t* dyn, int ninst, void* fnc, int w); void grab_segdata(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, int reg, int segment, int modreg); void emit_cmp8(dynarec_rv64_t* dyn, int ninst, int s1, int s2, int s3, int s4, int s5, int s6); diff --git a/src/dynarec/rv64/dynarec_rv64_private.h b/src/dynarec/rv64/dynarec_rv64_private.h index 534227b4..dcb5b8ba 100644 --- a/src/dynarec/rv64/dynarec_rv64_private.h +++ b/src/dynarec/rv64/dynarec_rv64_private.h @@ -219,12 +219,12 @@ int Table64(dynarec_rv64_t *dyn, uint64_t val, int pass); // add a value to tab void CreateJmpNext(void* addr, void* next); -#define GO_TRACE(A, B, s0) \ - GETIP(addr, s0); \ - MV(x1, xRIP); \ - STORE_XEMU_CALL(s0); \ - MOV64x(x2, B); \ - CALL(A, -1, x1, x2); \ +#define GO_TRACE(A, B, s0) \ + GETIP(addr, s0); \ + MV(x1, xRIP); \ + STORE_XEMU_CALL(s0); \ + MOV64x(x2, B); \ + CALL(const_##A, -1, x1, x2); \ LOAD_XEMU_CALL() #endif //__DYNAREC_RV64_PRIVATE_H_ |