--- /dev/null
+.data 8
+ok:
+.c "ok\n"
+
+#define CMOVR(N, T, OP, I0, I1, V, R0, R1, R2) \
+ movi %R1 I0 \
+ movi %R2 I1 \
+ movi %R0 V \
+ OP##r##T %R0 %R1 %R2 \
+ beqi OP##T##N##r_##R0##R1##R2 %R0 V \
+ calli @abort \
+OP##T##N##r_##R0##R1##R2:
+
+/* reg0 = reg1 op reg0 */
+#define CMOVR1(N, T, OP, I0, I1, V, R0, R1, R2) \
+ movi %R0 I1 \
+ movi %R1 I0 \
+ movi %R2 V \
+ OP##r##T %R0 %R1 %R0 \
+ beqr OP##T##N##r_1##R0##R1##R2 %R0 %R2 \
+ calli @abort \
+OP##T##N##r_1##R0##R1##R2:
+
+#define TEST_CMOV1(N, OP, I0, I1, V, R0, R1, R2) \
+ CMOVR(N, , OP, I0, I1, V, R0, R1, R2) \
+ CMOVR1(N, , OP, I0, I1, V, R0, R1, R2) \
+
+#define TEST_CMOV(N, OP, I0, I1, V) \
+ TEST_CMOV1(N, OP, I0, I1, V, v0, v1, v2) \
+ TEST_CMOV1(N, OP, I0, I1, V, v0, v1, r0) \
+ TEST_CMOV1(N, OP, I0, I1, V, v0, v1, r1) \
+ TEST_CMOV1(N, OP, I0, I1, V, v0, v1, r2) \
+ TEST_CMOV1(N, OP, I0, I1, V, v1, v2, r1) \
+ TEST_CMOV1(N, OP, I0, I1, V, v1, v2, r2) \
+ TEST_CMOV1(N, OP, I0, I1, V, v2, r0, r1) \
+ TEST_CMOV1(N, OP, I0, I1, V, v2, r0, r2) \
+ TEST_CMOV1(N, OP, I0, I1, V, r0, r1, r2)
+
+#define MOVZR(N, I0, I1, V) TEST_CMOV(N, movz, I0, I1, V)
+#define MOVNR(N, I0, I1, V) TEST_CMOV(N, movn, I0, I1, V)
+
+.code
+ prolog
+
+ MOVZR(0, 0x0, 0x0, 0x0)
+ MOVZR(1, 0xf7de, 0x0, 0xf7de)
+
+ MOVZR(2, 0x0, 0xdead, 0xdead)
+ MOVZR(3, 0xf7de, 0xdead, 0xdead)
+
+ MOVNR(0, 0x0, 0x0, 0x0)
+ MOVNR(1, 0xf7de, 0x0, 0x0)
+
+ MOVNR(2, 0x0, 0xdead, 0x0)
+ MOVNR(3, 0xf7de, 0xdead, 0xf7de)
+
+ prepare
+ pushargi ok
+ ellipsis
+ finishi @printf
+ ret
+ epilog
# define JR(r0) hrrrit(MIPS_SPECIAL,r0,0,0,0,MIPS_JR)
# endif
# define J(i0) hi(MIPS_J,i0)
+# define MOVN(rd,rs,rt) hrrrit(0,rs,rt,rd,0,MIPS_MOVN)
# define MOVZ(rd,rs,rt) hrrrit(0,rs,rt,rd,0,MIPS_MOVZ)
# define comr(r0,r1) xori(r0,r1,-1)
# define negr(r0,r1) subr(r0,_ZERO_REGNO,r1)
static void _movi(jit_state_t*,jit_int32_t,jit_word_t);
# define movi_p(r0,i0) _movi_p(_jit,r0,i0)
static jit_word_t _movi_p(jit_state_t*,jit_int32_t,jit_word_t);
+# define movnr(r0,r1,r2) MOVN(r0, r1, r2)
+# define movzr(r0,r1,r2) MOVZ(r0, r1, r2)
# define ldr_c(r0,r1) LB(r0,0,r1)
# define ldi_c(r0,i0) _ldi_c(_jit,r0,i0)
static void _ldi_c(jit_state_t*,jit_int32_t,jit_word_t);
static void _movsr(jit_state_t*,jit_int32_t,jit_int32_t);
# define movsr_u(r0, r1) _movsr_u(_jit, r0, r1)
static void _movsr_u(jit_state_t*,jit_int32_t,jit_int32_t);
+#define movnr(r0, r1, r2) _movnr(_jit, r0, r1, r2)
+static void _movnr(jit_state_t*, jit_int32_t, jit_int32_t, jit_int32_t);
+#define movzr(r0, r1, r2) _movzr(_jit, r0, r1, r2)
+static void _movzr(jit_state_t*, jit_int32_t, jit_int32_t, jit_int32_t);
# if __X64 && !__X64_32
# define movir(r0, r1) _movir(_jit, r0, r1)
static void _movir(jit_state_t*,jit_int32_t,jit_int32_t);
# define ffsl(l) __builtin_ffsl(l)
# endif
# endif
+# define jit_cmov_p() jit_cpu.cmov
#endif
#if CODE
mrm(0x03, r7(r0), r7(r1));
}
+static void
+_movnr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
+{
+ assert(jit_cmov_p());
+
+ testr(r2, r2);
+
+ rex(0, WIDE, r0, _NOREG, r1);
+ ic(0x0f);
+ ic(0x45);
+ mrm(0x03, r7(r0), r7(r1));
+}
+
+static void
+_movzr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
+{
+ assert(jit_cmov_p());
+
+ testr(r2, r2);
+
+ rex(0, WIDE, r0, _NOREG, r1);
+ ic(0x0f);
+ ic(0x44);
+ mrm(0x03, r7(r0), r7(r1));
+}
+
#if __X64
static void
_movir(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)