Skip to content

Commit

Permalink
[ARM64_DYNAREC] Fixed some issue with shrd/shld opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Dec 31, 2024
1 parent 670770e commit ca8d569
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/dynarec/arm64/dynarec_arm64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,11 +1691,11 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
case 0xA4:
nextop = F8;
INST_NAME("SHLD Ed, Gd, Ib");
if(geted_ib(dyn, addr, ninst, nextop)) {
if(geted_ib(dyn, addr, ninst, nextop)&(rex.w?63:31)) {
SETFLAGS(X_ALL, SF_SET_PENDING);
GETED(1);
GETGD;
u8 = F8;
u8 = F8&(rex.w?63:31);
emit_shld32c(dyn, ninst, rex, ed, gd, u8, x3, x4);
WBACK;
} else {
Expand Down Expand Up @@ -1779,11 +1779,11 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
case 0xAC:
nextop = F8;
INST_NAME("SHRD Ed, Gd, Ib");
if(geted_ib(dyn, addr, ninst, nextop)) {
if(geted_ib(dyn, addr, ninst, nextop)&(rex.w?63:31)) {
SETFLAGS(X_ALL, SF_SET_PENDING);
GETED(1);
GETGD;
u8 = F8;
u8 = F8&(rex.w?63:31);
emit_shrd32c(dyn, ninst, rex, ed, gd, u8, x3, x4);
WBACK;
} else {
Expand Down
20 changes: 8 additions & 12 deletions src/dynarec/arm64/dynarec_arm64_emit_shift.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,9 @@ void emit_shr32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, uint32_t c, i
BFIw(xFlags, s3, 0, 1);
}
}
IFX(X_OF) {
if(c==1) {
LSRxw(s4, s1, rex.w?63:31);
BFIw(xFlags, s4, F_OF, 1);
}
IFX2(X_OF, && (c==1)) {
LSRxw(s4, s1, rex.w?63:31);
BFIw(xFlags, s4, F_OF, 1);
}
LSRxw(s1, s1, c);
IFX(X_PEND) {
Expand Down Expand Up @@ -757,7 +755,7 @@ void emit_shr16(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3, int s4)
IFX(X_OF) {
CMPSw_U12(s2, 1); // if s2==1
LSRw(s4, s1, 15);
CSELw(s4, s4, xZR, 0);
CSELw(s4, s4, xZR, cEQ);
BFIw(xFlags, s4, F_OF, 1);
}
LSRw_REG(s1, s1, s2);
Expand Down Expand Up @@ -1237,7 +1235,6 @@ void emit_rcr32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, uint32_t c, i
// emit SHRD32 instruction, from s1, fill s2 , constant c, store result in s1 using s3 and s4 as scratch
void emit_shrd32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, int s2, uint32_t c, int s3, int s4)
{
c&=(rex.w?0x3f:0x1f);
IFX(X_PEND) {
MOV32w(s3, c);
STRxw_U12(s1, xEmu, offsetof(x64emu_t, op1));
Expand Down Expand Up @@ -1288,7 +1285,7 @@ void emit_shrd32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, int s2, uint
}
if(box64_dynarec_test) {
IFX(X_AF) {BFCw(xFlags, F_AF, 1);}
IFX(X_OF) if(c>1) {BFCw(xFlags, F_OF, 1);}
IFX2(X_OF, && (c>1)) {BFCw(xFlags, F_OF, 1);}
}
IFX(X_PF) {
emit_pf(dyn, ninst, s1, s4);
Expand All @@ -1297,7 +1294,6 @@ void emit_shrd32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, int s2, uint

void emit_shld32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, int s2, uint32_t c, int s3, int s4)
{
c&=(rex.w?0x3f:0x1f);
IFX(X_PEND) {
MOV32w(s3, c);
STRxw_U12(s1, xEmu, offsetof(x64emu_t, op1));
Expand Down Expand Up @@ -1343,7 +1339,7 @@ void emit_shld32c(dynarec_arm_t* dyn, int ninst, rex_t rex, int s1, int s2, uint
}
if(box64_dynarec_test) {
IFX(X_AF) {BFCw(xFlags, F_AF, 1);}
IFX(X_OF) if(c>1) {BFCw(xFlags, F_OF, 1);}
IFX2(X_OF, && (c>1)) {BFCw(xFlags, F_OF, 1);}
}
IFX(X_PF) {
emit_pf(dyn, ninst, s1, s4);
Expand Down Expand Up @@ -1524,7 +1520,7 @@ void emit_shrd16c(dynarec_arm_t* dyn, int ninst, int s1, int s2, uint32_t c, int
}
if(box64_dynarec_test) {
IFX(X_AF) {BFCw(xFlags, F_AF, 1);}
IFX(X_OF) if(c>1) {BFCw(xFlags, F_OF, 1);}
IFX2(X_OF, && (c>1)) {BFCw(xFlags, F_OF, 1);}
}
IFX(X_PF) {
emit_pf(dyn, ninst, s1, s4);
Expand Down Expand Up @@ -1619,7 +1615,7 @@ void emit_shld16c(dynarec_arm_t* dyn, int ninst, int s1, int s2, uint32_t c, int
}
if(box64_dynarec_test) {
IFX(X_AF) {BFCw(xFlags, F_AF, 1);}
IFX(X_OF) if(c>1) {BFCw(xFlags, F_OF, 1);}
IFX2(X_OF, && (c>1)) {BFCw(xFlags, F_OF, 1);}
}
IFX(X_PF) {
emit_pf(dyn, ninst, s1, s4);
Expand Down

0 comments on commit ca8d569

Please sign in to comment.