Skip to content
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
3 changes: 1 addition & 2 deletions src/dynarec/arm64/dynarec_arm64_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,14 +786,13 @@ void inst_name_pass3(dynarec_native_t* dyn, int ninst, const char* name, rex_t r
}

static char buf[4096];
int length = sprintf(buf, "barrier=%d state=%d/%s(%s->%s)/%d, %s=%X/%X, use=%X, need=%X/%X, sm=%d(%d/%d/%d)",
int length = sprintf(buf, "barrier=%d state=%d/%s(%s->%s)/%d, set=%X/%X, use=%X, need=%X/%X, sm=%d(%d/%d/%d)",
dyn->insts[ninst].x64.barrier,
dyn->insts[ninst].x64.state_flags,
df_status[dyn->f],
df_status[dyn->insts[ninst].f_entry],
df_status[dyn->insts[ninst].f_exit],
dyn->insts[ninst].df_notneeded,
dyn->insts[ninst].x64.may_set ? "may" : "set",
dyn->insts[ninst].x64.set_flags,
dyn->insts[ninst].x64.gen_flags,
dyn->insts[ninst].x64.use_flags,
Expand Down
12 changes: 6 additions & 6 deletions src/dynarec/arm64/dynarec_arm64_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,12 @@
#define FORCE_DFNONE() STRw_U12(wZR, xEmu, offsetof(x64emu_t, df))
#define CHECK_DFNONE(N) do {if(dyn->f==status_none_pending) {FORCE_DFNONE(); if(N) dyn->f = status_none;}} while(0)

#define SET_DFNONE() \
do { \
if(!dyn->insts[ninst].x64.may_set && (dyn->f!=status_none)) { \
dyn->f = status_none_pending; \
} \
} while(0)
#define SET_DFNONE() \
do { \
if (dyn->f != status_none) { \
dyn->f = status_none_pending; \
} \
} while (0)

#define SET_DF(S, N) \
if ((N) != d_none) { \
Expand Down
16 changes: 10 additions & 6 deletions src/dynarec/la64/dynarec_la64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,11 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0xA5:
nextop = F8;
INST_NAME("SHLD Ed, Gd, CL");
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
if (BOX64DRENV(dynarec_safeflags) > 1)
MAYSETFLAGS();
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_FUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
GETGD;
GETED(0);
if (!rex.w && !rex.is32bits && MODREG) { ZEROUP(ed); }
Expand Down Expand Up @@ -1550,9 +1552,11 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0xAD:
nextop = F8;
INST_NAME("SHRD Ed, Gd, CL");
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
if (BOX64DRENV(dynarec_safeflags) > 1)
MAYSETFLAGS();
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_FUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
GETGD;
GETED(0);
if (!rex.w && !rex.is32bits && MODREG) { ZEROUP(ed); }
Expand Down
65 changes: 45 additions & 20 deletions src/dynarec/la64/dynarec_la64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,11 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
} else {
INST_NAME("REPZ CMPSW");
}
MAYSETFLAGS();
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_NOFUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_NOFUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_NOFUSION);
CBZ_NEXT(xRCX);
ANDI(x1, xFlags, 1 << F_DF);
BNEZ_MARK2(x1);
Expand Down Expand Up @@ -972,8 +975,11 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
} else {
INST_NAME("REPZ SCASW");
}
MAYSETFLAGS();
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_NOFUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_NOFUSION);
CBZ_NEXT(xRCX);
GETDIR(x3, x1, rex.w ? 8 : 2);
if (rex.w) {
Expand Down Expand Up @@ -1214,73 +1220,92 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
switch ((nextop >> 3) & 7) {
case 0:
INST_NAME("ROL Ew, CL");
ANDI(x2, xRCX, 0x1f);
MESSAGE(LOG_DUMP, "Need Optimization\n");
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_OF | X_CF);
}
SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
ANDI(x2, xRCX, 0x1f);
GETEW(x1, 1);
CALL_(const_rol16, x1, x3, x1, x2);
EWBACK;
break;
case 1:
INST_NAME("ROR Ew, CL");
ANDI(x2, xRCX, 0x1f);
MESSAGE(LOG_DUMP, "Need Optimization\n");
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_OF | X_CF);
}
SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
ANDI(x2, xRCX, 0x1f);
GETEW(x1, 1);
CALL_(const_ror16, x1, x3, x1, x2);
EWBACK;
break;
case 2:
INST_NAME("RCL Ew, CL");
ANDI(x2, xRCX, 0x1f);
MESSAGE("LOG_DUMP", "Need optimization\n");
READFLAGS(X_CF);
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_OF | X_CF);
} else {
READFLAGS(X_CF);
}
SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
ANDI(x2, xRCX, 0x1f);
GETEW(x1, 1);
CALL_(const_rcl16, x1, x3, x1, x2);
EWBACK;
break;
case 3:
INST_NAME("RCR Ew, CL");
ANDI(x2, xRCX, 0x1f);
MESSAGE("LOG_DUMP", "Need optimization\n");
READFLAGS(X_CF);
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_OF | X_CF);
} else {
READFLAGS(X_CF);
}
SETFLAGS(X_OF | X_CF, SF_SET_DF, NAT_FLAGS_NOFUSION);
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
ANDI(x2, xRCX, 0x1f);
GETEW(x1, 1);
CALL_(const_rcr16, x1, x3, x1, x2);
EWBACK;
break;
case 5:
INST_NAME("SHR Ew, CL");
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_FUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
ANDI(x2, xRCX, 0x1f);
CBZ_NEXT(x2);
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
GETEW(x1, 0);
emit_shr16(dyn, ninst, x1, x2, x5, x4, x6);
EWBACK;
break;
case 4:
case 6:
INST_NAME("SHL Ew, CL");
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_FUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
ANDI(x2, xRCX, 0x1f);
CBZ_NEXT(x2);
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
GETEW(x1, 0);
emit_shl16(dyn, ninst, x1, x2, x5, x4, x6);
EWBACK;
break;
case 7:
INST_NAME("SAR Ew, CL");
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_ALL);
SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_FUSION);
} else
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
ANDI(x2, xRCX, 0x1f);
CBZ_NEXT(x2);
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION); // some flags are left undefined
if (BOX64DRENV(dynarec_safeflags) > 1) MAYSETFLAGS();
GETSEW(x1, 0);
emit_sar16(dyn, ninst, x1, x2, x5, x4, x6);
EWBACK;
Expand Down
3 changes: 1 addition & 2 deletions src/dynarec/la64/dynarec_la64_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,11 @@ void inst_name_pass3(dynarec_native_t* dyn, int ninst, const char* name, rex_t r
if (!dyn->need_dump && !BOX64ENV(dynarec_gdbjit) && !BOX64ENV(dynarec_perf_map)) return;

static char buf[4096];
int length = sprintf(buf, "barrier=%d state=%d/%d(%d), %s=%X/%X, use=%X, need=%X/%X, fuse=%d/%d, sm=%d(%d/%d)",
int length = sprintf(buf, "barrier=%d state=%d/%d(%d), set=%X/%X, use=%X, need=%X/%X, fuse=%d/%d, sm=%d(%d/%d)",
dyn->insts[ninst].x64.barrier,
dyn->insts[ninst].x64.state_flags,
dyn->f.pending,
dyn->f.dfnone,
dyn->insts[ninst].x64.may_set ? "may" : "set",
dyn->insts[ninst].x64.set_flags,
dyn->insts[ninst].x64.gen_flags,
dyn->insts[ninst].x64.use_flags,
Expand Down
20 changes: 6 additions & 14 deletions src/dynarec/la64/dynarec_la64_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,12 @@

#define FORCE_DFNONE() ST_W(xZR, xEmu, offsetof(x64emu_t, df))

#define SET_DFNONE() \
do { \
if (!dyn->f.dfnone) { \
FORCE_DFNONE(); \
} \
if (!dyn->insts[ninst].x64.may_set) { \
dyn->f.dfnone = 1; \
} \
#define SET_DFNONE() \
do { \
if (!dyn->f.dfnone) { \
FORCE_DFNONE(); \
} \
dyn->f.dfnone = 1; \
} while (0)

#define SET_DF(S, N) \
Expand Down Expand Up @@ -925,12 +923,6 @@
x87_do_pop(dyn, ninst, scratch);
#endif

#ifndef MAYSETFLAGS
#define MAYSETFLAGS() \
do { \
} while (0)
#endif

#ifndef READFLAGS
#define READFLAGS(A) \
if (((A) != X_PEND && dyn->f.pending != SF_SET) \
Expand Down
5 changes: 3 additions & 2 deletions src/dynarec/la64/dynarec_la64_pass0.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
dyn->insts[ninst].x64.addr = addr; \
if (ninst) dyn->insts[ninst - 1].x64.size = dyn->insts[ninst].x64.addr - dyn->insts[ninst - 1].x64.addr

#define MESSAGE(A, ...) do {} while (0)
#define MAYSETFLAGS() dyn->insts[ninst].x64.may_set = 1
#define MESSAGE(A, ...) \
do { \
} while (0)
#define READFLAGS(A) \
dyn->insts[ninst].x64.use_flags = A; \
dyn->f.dfnone = 1; \
Expand Down
Loading