diff --git a/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp b/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp index e9437380..f5a5d691 100644 --- a/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp +++ b/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp @@ -523,6 +523,29 @@ LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) } LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) +LOWFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) +{ + /* replacement using branch and mov */ + int8 *target_p = (int8 *)x86_get_target() + 1; + JCCSii(cc^1, 0); + MOVBrr(s, d); + *target_p = (uintptr)x86_get_target() - ((uintptr)target_p + 1); +} +LENDFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) + +LOWFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) +{ + if (have_cmov) + CMOVWrr(cc, s, d); + else { /* replacement using branch and mov */ + int8 *target_p = (int8 *)x86_get_target() + 1; + JCCSii(cc^1, 0); + MOVWrr(s, d); + *target_p = (uintptr)x86_get_target() - ((uintptr)target_p + 1); + } +} +LENDFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) + LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) { if (have_cmov) @@ -1739,6 +1762,36 @@ LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) } LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) +LOWFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) +{ + /* replacement using branch and mov */ + int uncc=(cc^1); + emit_byte(0x70+uncc); + emit_byte(3); /* skip next 2 bytes if not cc=true */ + emit_byte(0x88); + emit_byte(0xc0+8*s+d); +} +LENDFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) + +LOWFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) +{ + if (have_cmov) { + emit_byte(0x66); + emit_byte(0x0f); + emit_byte(0x40+cc); + emit_byte(0xc0+8*d+s); + } + else { /* replacement using branch and mov */ + int uncc=(cc^1); + emit_byte(0x70+uncc); + emit_byte(3); /* skip next 3 bytes if not cc=true */ + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0xc0+8*s+d); + } +} +LENDFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) + LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) { if (have_cmov) { diff --git a/BasiliskII/src/uae_cpu/compiler/compemu.h b/BasiliskII/src/uae_cpu/compiler/compemu.h index c6c82f91..1e161a33 100644 --- a/BasiliskII/src/uae_cpu/compiler/compemu.h +++ b/BasiliskII/src/uae_cpu/compiler/compemu.h @@ -339,6 +339,8 @@ DECLARE_MIDFUNC(shra_w_ri(RW2 r, IMM i)); DECLARE_MIDFUNC(shra_b_ri(RW1 r, IMM i)); DECLARE_MIDFUNC(setcc(W1 d, IMM cc)); DECLARE_MIDFUNC(setcc_m(IMM d, IMM cc)); +DECLARE_MIDFUNC(cmov_b_rr(RW1 d, R1 s, IMM cc)); +DECLARE_MIDFUNC(cmov_w_rr(RW2 d, R2 s, IMM cc)); DECLARE_MIDFUNC(cmov_l_rr(RW4 d, R4 s, IMM cc)); DECLARE_MIDFUNC(cmov_l_rm(RW4 d, IMM s, IMM cc)); DECLARE_MIDFUNC(bsf_l_rr(W4 d, R4 s)); diff --git a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp index 8f35a00c..2e4fcc65 100644 --- a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp +++ b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp @@ -2955,6 +2955,32 @@ MIDFUNC(2,setcc_m,(IMM d, IMM cc)) } MENDFUNC(2,setcc_m,(IMM d, IMM cc)) +MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc)) +{ + if (d==s) + return; + CLOBBER_CMOV; + s=readreg(s,1); + d=rmw(d,1,1); + raw_cmov_b_rr(d,s,cc); + unlock2(s); + unlock2(d); +} +MENDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc)) + +MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc)) +{ + if (d==s) + return; + CLOBBER_CMOV; + s=readreg(s,2); + d=rmw(d,2,2); + raw_cmov_w_rr(d,s,cc); + unlock2(s); + unlock2(d); +} +MENDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc)) + MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc)) { if (d==s)