[ARM64_DYNAREC] More work on UD flags for (66) F3 0F BC/BD opcodes

This commit is contained in:
ptitSeb 2025-04-27 16:18:57 +02:00
parent e1fd56123c
commit 35c8beb15f
2 changed files with 60 additions and 4 deletions

View File

@ -85,7 +85,15 @@ uintptr_t dynarec64_66F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0xBC:
INST_NAME("TZCNT Gw, Ew");
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
if(!BOX64ENV(dynarec_safeflags)) {
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
} else {
if(BOX64ENV(cputype)) {
SETFLAGS(X_ALL&~X_OF, SF_SUBSET);
} else {
SETFLAGS(X_ALL, SF_SET);
}
}
SET_DFNONE();
nextop = F8;
GETEW(x1, 0);
@ -104,12 +112,26 @@ uintptr_t dynarec64_66F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int
CSETw(x3, cEQ);
BFIw(xFlags, x3, F_ZF, 1); // ZF = is dest 0?
}
if(BOX64ENV(dynarec_safeflags)) {
IFX(X_AF) BFCw(xFlags, F_AF, 1);
IFX(X_PF) BFCw(xFlags, F_PF, 1);
IFX(X_SF) BFCw(xFlags, F_SF, 1);
IFX2(X_OF, && !BOX64ENV(cputype)) BFCw(xFlags, F_OF, 1);
}
GWBACK;
break;
case 0xBD:
INST_NAME("LZCNT Gw, Ew");
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
if(!BOX64ENV(dynarec_safeflags)) {
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
} else {
if(BOX64ENV(cputype)) {
SETFLAGS(X_ALL&~X_OF, SF_SUBSET);
} else {
SETFLAGS(X_ALL, SF_SET);
}
}
SET_DFNONE();
nextop = F8;
GETEW(x1, 0);
@ -126,6 +148,12 @@ uintptr_t dynarec64_66F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int
CSETw(x3, cEQ);
BFIw(xFlags, x3, F_ZF, 1); // ZF = is dest 0?
}
if(BOX64ENV(dynarec_safeflags)) {
IFX(X_AF) BFCw(xFlags, F_AF, 1);
IFX(X_PF) BFCw(xFlags, F_PF, 1);
IFX(X_SF) BFCw(xFlags, F_SF, 1);
IFX2(X_OF, && !BOX64ENV(cputype)) BFCw(xFlags, F_OF, 1);
}
GWBACK;
break;

View File

@ -545,7 +545,15 @@ uintptr_t dynarec64_F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int n
case 0xBC:
INST_NAME("TZCNT Gd, Ed");
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
if(!BOX64ENV(dynarec_safeflags)) {
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
} else {
if(BOX64ENV(cputype)) {
SETFLAGS(X_ALL&~X_OF, SF_SUBSET);
} else {
SETFLAGS(X_ALL, SF_SET);
}
}
SET_DFNONE();
nextop = F8;
GETED(0);
@ -562,10 +570,24 @@ uintptr_t dynarec64_F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int n
CSETw(x3, cEQ);
BFIw(xFlags, x3, F_ZF, 1); // ZF = is dest 0?
}
if(BOX64ENV(dynarec_safeflags)) {
IFX(X_AF) BFCw(xFlags, F_AF, 1);
IFX(X_PF) BFCw(xFlags, F_PF, 1);
IFX(X_SF) BFCw(xFlags, F_SF, 1);
IFX2(X_OF, && !BOX64ENV(cputype)) BFCw(xFlags, F_OF, 1);
}
break;
case 0xBD:
INST_NAME("LZCNT Gd, Ed");
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
if(!BOX64ENV(dynarec_safeflags)) {
SETFLAGS(X_CF|X_ZF, SF_SUBSET);
} else {
if(BOX64ENV(cputype)) {
SETFLAGS(X_ALL&~X_OF, SF_SUBSET);
} else {
SETFLAGS(X_ALL, SF_SET);
}
}
SET_DFNONE();
nextop = F8;
GETED(0);
@ -581,6 +603,12 @@ uintptr_t dynarec64_F30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int n
CSETw(x3, cEQ);
BFIw(xFlags, x3, F_ZF, 1); // ZF = is dest 0?
}
if(BOX64ENV(dynarec_safeflags)) {
IFX(X_AF) BFCw(xFlags, F_AF, 1);
IFX(X_PF) BFCw(xFlags, F_PF, 1);
IFX(X_SF) BFCw(xFlags, F_SF, 1);
IFX2(X_OF, && !BOX64ENV(cputype)) BFCw(xFlags, F_OF, 1);
}
break;
case 0xC2: