Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DYNAREC] Cleanup modreg #2209

Merged
merged 1 commit into from
Dec 25, 2024
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
6 changes: 3 additions & 3 deletions src/dynarec/arm64/dynarec_arm64_00.c
Original file line number Diff line number Diff line change
Expand Up @@ -1360,11 +1360,11 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
INST_NAME("MOV Ed, Seg");
nextop=F8;
u8 = (nextop&0x38)>>3;
if((nextop&0xC0)==0xC0) { // reg <= seg
if (MODREG) {
gd = TO_NAT((nextop & 7) + (rex.b << 3));
LDRH_U12(gd, xEmu, offsetof(x64emu_t, segs[u8]));
UXTHw(gd, gd);
} else { // mem <= seg
} else {
LDRH_U12(x3, xEmu, offsetof(x64emu_t, segs[u8]));
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, &unscaled, 0xfff<<1, 1, rex, NULL, 0, 0);
STH(x3, wback, fixedaddress);
Expand All @@ -1391,7 +1391,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
INST_NAME("MOV Seg,Ew");
nextop = F8;
u8 = (nextop&0x38)>>3;
if((nextop&0xC0)==0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/arm64/dynarec_arm64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
break;
case 0x18:
nextop = F8;
if((nextop&0xC0)==0xC0) {
if (MODREG) {
INST_NAME("NOP (multibyte)");
} else
switch((nextop>>3)&7) {
Expand Down Expand Up @@ -1548,7 +1548,7 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
INST_NAME("MOVD Ed, Gm");
nextop = F8;
GETGM(v0);
if((nextop&0xC0)==0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 0x07) + (rex.b << 3));
if(rex.w) {
FMOVxD(ed, v0);
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/arm64/dynarec_arm64_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ uintptr_t dynarec64_64(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
grab_segdata(dyn, addr, ninst, x4, seg);
nextop = F8;
u8 = (nextop&0x38)>>3;
if((nextop&0xC0)==0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
8 changes: 4 additions & 4 deletions src/dynarec/arm64/dynarec_arm64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ uintptr_t dynarec64_66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
nextop=F8;
u8 = (nextop&0x38)>>3;
LDRH_U12(x3, xEmu, offsetof(x64emu_t, segs[u8]));
if((nextop&0xC0)==0xC0) { // reg <= seg
if (MODREG) {
BFIz(TO_NAT((nextop & 7) + (rex.b << 3)), x3, 0, 16);
} else { // mem <= seg
} else {
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, &unscaled, 0xfff<<1, 1, rex, NULL, 0, 0);
STH(x3, wback, fixedaddress);
SMWRITE2();
Expand All @@ -674,7 +674,7 @@ uintptr_t dynarec64_66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
INST_NAME("MOV Seg,Ew");
nextop = F8;
u8 = (nextop&0x38)>>3;
if((nextop&0xC0)==0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand All @@ -689,7 +689,7 @@ uintptr_t dynarec64_66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
INST_NAME("POP Ew");
nextop = F8;
POP1_16(x1);
if((nextop&0xC0)==0xC0) {
if (MODREG) {
wback = TO_NAT((nextop & 7) + (rex.b << 3));
BFIz(wback, x1, 0, 16);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/arm64/dynarec_arm64_6764_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ uintptr_t dynarec64_6764_32(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, in
switch((nextop>>3)&7) {
case 6: // Push Ed
INST_NAME("PUSH FS:Ew");
if((nextop&0xC0)==0xC0) { // reg
if (MODREG) {
DEFAULT;
} else { // mem <= i32
} else {
SMREAD();
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, &unscaled, 0, 0, 0);
LDRw_REG(x3, ed, x4);
Expand Down
8 changes: 4 additions & 4 deletions src/dynarec/arm64/dynarec_arm64_f0.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
if((nextop&0xC0)==0xC0) {
if (MODREG) {
if(rex.rex) {
wback = TO_NAT((nextop & 0x07) + (rex.b << 3));
wb2 = 0;
Expand Down Expand Up @@ -147,7 +147,7 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
if((nextop&0xC0)==0xC0) {
if (MODREG) {
if(rex.rex) {
wback = TO_NAT((nextop & 0x07) + (rex.b << 3));
wb2 = 0;
Expand Down Expand Up @@ -865,7 +865,7 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
if((nextop&0xC0)==0xC0) {
if (MODREG) {
if(rex.rex) {
wback = TO_NAT((nextop & 0x07) + (rex.b << 3));
wb2 = 0;
Expand Down Expand Up @@ -1022,7 +1022,7 @@ uintptr_t dynarec64_F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
if((nextop&0xC0)==0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
emit_xor32(dyn, ninst, rex, ed, gd, x3, x4);
} else {
Expand Down
25 changes: 13 additions & 12 deletions src/dynarec/arm64/dynarec_arm64_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,18 @@
LDz(x1, wback, fixedaddress); \
ed = x1; \
}
#define GETEDw(D) if((nextop&0xC0)==0xC0) { \
ed = xEAX+(nextop&7)+(rex.b<<3); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, &unscaled, 0xfff<<2, 3, rex, NULL,0, D); \
LDW(x1, wback, fixedaddress); \
ed = x1; \
}
#define GETEDw(D) \
if (MODREG) { \
ed = xEAX + (nextop & 7) + (rex.b << 3); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, &unscaled, 0xfff << 2, 3, rex, NULL, 0, D); \
LDW(x1, wback, fixedaddress); \
ed = x1; \
}
#define GETSEDw(D) \
if ((nextop & 0xC0) == 0xC0) { \
if (MODREG) { \
ed = TO_NAT((nextop & 7) + (rex.b << 3)); \
SXTWx(x1, ed); \
wb = x1; \
Expand All @@ -106,7 +107,7 @@
ed = x1; \
}
#define GETSED32w(D) \
if ((nextop & 0xC0) == 0xC0) { \
if (MODREG) { \
ed = TO_NAT((nextop & 7) + (rex.b << 3)); \
SXTWx(x1, ed); \
wb = x1; \
Expand Down Expand Up @@ -211,7 +212,7 @@
ed = x1; \
}
#define GETSEDOw(O, D) \
if ((nextop & 0xC0) == 0xC0) { \
if (MODREG) { \
ed = TO_NAT((nextop & 7) + (rex.b << 3)); \
SXTWx(x1, ed); \
wb = x1; \
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/la64/dynarec_la64_00.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,9 +1140,9 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0x8C:
INST_NAME("MOV Ed, Seg");
nextop = F8;
if ((nextop & 0xC0) == 0xC0) { // reg <= seg
if (MODREG) {
LD_HU(TO_NAT((nextop & 7) + (rex.b << 3)), xEmu, offsetof(x64emu_t, segs[(nextop & 0x38) >> 3]));
} else { // mem <= seg
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, x1, &fixedaddress, rex, NULL, 1, 0);
LD_HU(x3, xEmu, offsetof(x64emu_t, segs[(nextop & 0x38) >> 3]));
ST_H(x3, ed, fixedaddress);
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/la64/dynarec_la64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
break;
case 0x18:
nextop = F8;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
INST_NAME("NOP (multibyte)");
} else
switch ((nextop >> 3) & 7) {
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/la64/dynarec_la64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
INST_NAME("MOV Seg, Ew");
nextop = F8;
u8 = (nextop & 0x38) >> 3;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/la64/dynarec_la64_f0.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ uintptr_t dynarec64_F0(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
nextop = F8;
GETGD;
SMDMB();
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
emit_add32(dyn, ninst, rex, ed, gd, x3, x4, x5);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/dynarec/rv64/dynarec_rv64_00_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0x8C:
INST_NAME("MOV Ed, Seg");
nextop = F8;
if ((nextop & 0xC0) == 0xC0) { // reg <= seg
if (MODREG) {
LHU(TO_NAT((nextop & 7) + (rex.b << 3)), xEmu, offsetof(x64emu_t, segs[(nextop & 0x38) >> 3]));
} else { // mem <= seg
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, x1, &fixedaddress, rex, NULL, 1, 0);
LHU(x3, xEmu, offsetof(x64emu_t, segs[(nextop & 0x38) >> 3]));
SH(x3, ed, fixedaddress);
Expand All @@ -491,7 +491,7 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0x8E:
INST_NAME("MOV Seg,Ew");
nextop = F8;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
break;
case 0x18:
nextop = F8;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
INST_NAME("NOP (multibyte)");
} else
switch ((nextop >> 3) & 7) {
Expand Down Expand Up @@ -1641,7 +1641,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
nextop = F8;
gd = ((nextop & 0x38) >> 3);
v0 = mmx_get_reg(dyn, ninst, x1, x2, x3, gd);
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
if (rex.w)
FMVXD(ed, v0);
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/rv64/dynarec_rv64_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ uintptr_t dynarec64_64(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
grab_segdata(dyn, addr, ninst, x4, seg);
nextop = F8;
u8 = (nextop & 0x38) >> 3;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
INST_NAME("MOV Ew, Seg");
nextop = F8;
LHU(x3, xEmu, offsetof(x64emu_t, segs[(nextop & 0x38) >> 3]));
if ((nextop & 0xC0) == 0xC0) { // reg <= seg
if (MODREG) {
INSHz(TO_NAT((nextop & 7) + (rex.b << 3)), x3, x1, x2, 1, 0);
} else { // mem <= seg
addr = geted(dyn, addr, ninst, nextop, &ed, x2, x1, &fixedaddress, rex, NULL, 1, 0);
Expand All @@ -722,7 +722,7 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
INST_NAME("MOV Seg, Ew");
nextop = F8;
u8 = (nextop & 0x38) >> 3;
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
} else {
SMREAD();
Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_f0.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ uintptr_t dynarec64_F0(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
nextop = F8;
GETGD;
SMDMB();
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
ed = TO_NAT((nextop & 7) + (rex.b << 3));
emit_add32(dyn, ninst, rex, ed, gd, x3, x4, x5);
} else {
Expand Down Expand Up @@ -452,7 +452,7 @@ uintptr_t dynarec64_F0(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
nextop = F8;
GETGB(x2);
SMDMB();
if ((nextop & 0xC0) == 0xC0) {
if (MODREG) {
if (rex.rex) {
wback = TO_NAT((nextop & 7) + (rex.b << 3));
wb2 = 0;
Expand Down
Loading