Skip to content

Commit

Permalink
[ARM64_DYNAREC] Added an unaligned path for F0 0F C7 /1 opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Feb 6, 2024
1 parent f8fa53a commit a60d945
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/dynarec/arm64/dynarec_arm64_f0.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,16 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
case 0xC7:
switch(rep) {
case 0:
switch((nextop>>3)&7) {
case 1:
INST_NAME("LOCK CMPXCHG8B Gq, Eq");
SETFLAGS(X_ZF, SF_SUBSET);
nextop = F8;
addr = geted(dyn, addr, ninst, nextop, &wback, x1, &fixedaddress, NULL, 0, 0, rex, LOCK_LOCK, 0, 0);
if(!ALIGNED_ATOMICxw) {
TSTx_mask(wback, 1, 0, 1+rex.w); // mask=3 or 7
B_MARK(cNE); // unaligned
}
if(arm64_atomics) {
MOVx_REG(x2, xRAX);
MOVx_REG(x3, xRDX);
Expand All @@ -663,6 +669,9 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
}
MOVx_REG(xRAX, x2);
MOVx_REG(xRDX, x3);
if(!ALIGNED_ATOMICxw) {
B_NEXT_nocond;
}
} else {
MARKLOCK;
LDAXPxw(x2, x3, wback);
Expand All @@ -681,6 +690,30 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
UFLAG_IF {
MOV32w(x1, 0);
}
if(!ALIGNED_ATOMICxw) {
B_MARK3_nocond;
}
}
if(!ALIGNED_ATOMICxw) {
MARK;
LDPxw_S7_offset(x2, x3, wback, 0);
LDAXRB(x4, wback);
CMPSxw_REG(xRAX, x2);
CCMPxw(xRDX, x3, 0, cEQ);
B_MARK(cNE); // EAX!=ED[0] || EDX!=Ed[1]
STLXRB(x4, xRBX, wback);
CBNZx_MARK(x4);
STPxw_S7_offset(xRBX, xRCX, wback, 0);
UFLAG_IF {
MOV32w(x1, 1);
}
B_MARK3_nocond;
MARK;
MOVxw_REG(xRAX, x2);
MOVxw_REG(xRDX, x3);
UFLAG_IF {
MOV32w(x1, 0);
}
}
MARK3;
SMDMB();
Expand All @@ -690,6 +723,9 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
break;
default:
DEFAULT;
}
default:
DEFAULT;
}
break;

Expand Down

0 comments on commit a60d945

Please sign in to comment.