From 2d04cbe97c8dca2805cf7e2c204dcbf2010450dd Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Mon, 25 Nov 2024 03:04:01 +0800 Subject: [PATCH] [ARM64_DYNAREC] Use YIELD instead of WFE (#2066) --- src/dynarec/arm64/arm64_emitter.h | 2 ++ src/dynarec/arm64/arm64_printer.c | 12 ++++++++++++ src/dynarec/arm64/dynarec_arm64_00.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dynarec/arm64/arm64_emitter.h b/src/dynarec/arm64/arm64_emitter.h index 562f3f0bd..168f26e0d 100644 --- a/src/dynarec/arm64/arm64_emitter.h +++ b/src/dynarec/arm64/arm64_emitter.h @@ -541,6 +541,8 @@ int convert_bitmask(uint64_t bitmask); #define NOP EMIT(0b11010101000000110010000000011111) #define WFE EMIT(0b11010101000000110010000001011111) +#define WFI EMIT(0b11010101000000110010000001111111) +#define YIELD EMIT(0b11010101000000110010000000111111) #define CSINC_gen(sf, Rm, cond, Rn, Rd) ((sf)<<31 | 0b11010100<<21 | (Rm)<<16 | (cond)<<12 | 1<<10 | (Rn)<<5 | (Rd)) #define CSINCx(Rd, Rn, Rm, cond) EMIT(CSINC_gen(1, Rm, cond, Rn, Rd)) diff --git a/src/dynarec/arm64/arm64_printer.c b/src/dynarec/arm64/arm64_printer.c index 48b67e0c4..4b797a3c8 100644 --- a/src/dynarec/arm64/arm64_printer.c +++ b/src/dynarec/arm64/arm64_printer.c @@ -124,6 +124,18 @@ const char* arm64_print(uint32_t opcode, uintptr_t addr) snprintf(buff, sizeof(buff), "NOP"); return buff; } + if(isMask(opcode, "11010101000000110010000001011111", &a)) { + snprintf(buff, sizeof(buff), "WFE"); + return buff; + } + if(isMask(opcode, "11010101000000110010000001111111", &a)) { + snprintf(buff, sizeof(buff), "WFI"); + return buff; + } + if(isMask(opcode, "11010101000000110010000000111111", &a)) { + snprintf(buff, sizeof(buff), "YIELD"); + return buff; + } // --- LDR / STR if(isMask(opcode, "f010100011iiiiiii22222nnnnnttttt", &a)) { int offset = signExtend(imm, 7)<<(2+sf); diff --git a/src/dynarec/arm64/dynarec_arm64_00.c b/src/dynarec/arm64/dynarec_arm64_00.c index 3380911c1..5141a598f 100644 --- a/src/dynarec/arm64/dynarec_arm64_00.c +++ b/src/dynarec/arm64/dynarec_arm64_00.c @@ -1427,7 +1427,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin if(gd==xRAX) { if (rep == 2) { INST_NAME("PAUSE"); - WFE; + YIELD; } else { INST_NAME("NOP"); }