#include #include #include #include #include #define check_code() \ assert((char *)jit_get_label() - (char *)code < sizeof(code)) typedef struct types { long pad; /* to ensure all ldx_i/stx_i use an offset */ signed char c; unsigned char uc; signed short s; unsigned short us; signed int i; unsigned int ui; signed long l; unsigned long ul; float f; double d; void *p; } types_t; typedef void (*pvv_t)(void); pvv_t pvv; types_t t0, t1; jit_insn code[16 * 1024 * 1024]; #define warn(name, format, ...) \ fprintf(stderr, "%s:%d:%s: " format "\n", \ __FILE__, __LINE__, name ,#__VA_ARGS__) #define E(v, shift) (v >> shift) #if __WORDSIZE == 64 # define SLONG_VALUE 0x8000000000000001 # define BLONG_VALUE 0x8000000000000000 # define ULONG_VALUE 0x7fffffffffffffff # define FLONG_VALUE 0xffffffffffffffff # define C(v) E(v, 56) # define S(v) E(v, 48) # define I(v) E(v, 32) #else # define SLONG_VALUE 0x80000001 # define BLONG_VALUE 0x80000000 # define ULONG_VALUE 0x7fffffff # define FLONG_VALUE 0xffffffff # define C(v) E(v, 24) # define S(v) E(v, 16) # define I(v) E(v, 0) #endif void check(char *name, unsigned long i, double d, void *p) { if (t0.c != (signed char)C(i)) warn(name, "0x%x", t0.c); if (t0.uc != (unsigned char)C(i)) warn(name, "0x%x", t0.uc); if (t0.s != (signed short)S(i)) warn(name, "0x%x", t0.s); if (t0.us != (unsigned short)S(i)) warn(name, "0x%x", t0.us); if (t0.i != (signed int)I(i)) warn(name, "0x%x", t0.i); if (t0.ui != (unsigned int)I(i)) warn(name, "0x%x", t0.ui); if (t0.l != (signed long)i) warn(name, "0x%lx", t0.l); if (t0.ul != i) warn(name, "0x%lx", t0.ul); if (t0.f != (float)d) warn(name, "%f", t0.f); if (t0.d != d) warn(name, "%f", t0.d); if (t0.p != p) warn(name, "%p", t0.p); } void compare(char *name) { if (t0.c != t1.c) warn(name, "0x%x 0x%x", t0.c, t1.c); if (t0.uc != t1.uc) warn(name, "0x%x 0x%x", t0.uc, t1.uc); if (t0.s != t1.s) warn(name, "0x%x 0x%x", t0.s, t1.s); if (t0.us != t1.us) warn(name, "0x%x 0x%x", t0.us, t1.us); if (t0.i != t1.i) warn(name, "0x%x 0x%x", t0.i, t1.i); if (t0.ui != t1.ui) warn(name, "0x%x 0x%x", t0.ui, t1.ui); if (t0.l != t1.l) warn(name, "0x%x 0x%x", t0.l, t1.l); if (t0.ul != t1.ul) warn(name, "0x%x 0x%x", t0.ul, t1.ul); if (t0.f != t1.f) warn(name, "%f %f", t0.f, t1.f); if (t0.d != t1.d) warn(name, "%f %f", t0.d, t1.d); if (t0.p != t1.p) warn(name, "%p %p", t0.p, t1.p); } void check_c(char *name) { if (t0.c != t0.s) warn(name, "0x%x 0x%x", t0.c, t0.s); if (t0.c != t0.i) warn(name, "0x%x 0x%x", t0.c, t0.i); if (t0.c != t0.l) warn(name, "0x%x 0x%x", t0.c, t0.l); } void check_uc(char *name) { if (t0.uc != t0.us) warn(name, "0x%x 0x%x", t0.uc, t0.us); if (t0.uc != t0.ui) warn(name, "0x%x 0x%x", t0.uc, t0.ui); if (t0.uc != t0.ul) warn(name, "0x%x 0x%x", t0.uc, t0.ul); } void check_s(char *name) { if ((signed char)t0.s != t0.c) warn(name, "0x%x 0x%x", t0.s, t0.c); if (t0.s != t0.i) warn(name, "0x%x 0x%x", t0.s, t0.i); if (t0.s != t0.l) warn(name, "0x%x 0x%x", t0.s, t0.l); } void check_us(char *name) { if ((unsigned char)t0.us != t0.uc) warn(name, "0x%x 0x%x", t0.us, t0.uc); if (t0.us != t0.ui) warn(name, "0x%x 0x%x", t0.us, t0.ui); if (t0.us != t0.ul) warn(name, "0x%x 0x%x", t0.us, t0.ul); } void check_i(char *name) { if ((signed char)t0.i != t0.c) warn(name, "0x%x 0x%x", t0.i, t0.c); if ((signed short)t0.i != t0.s) warn(name, "0x%x 0x%x", t0.i, t0.s); if (t0.s != t0.l) warn(name, "0x%x 0x%x", t0.i, t0.l); } void check_ui(char *name) { if ((unsigned char)t0.ui != t0.uc) warn(name, "0x%x 0x%x", t0.ui, t0.uc); if ((unsigned short)t0.ui != t0.us) warn(name, "0x%x 0x%x", t0.ui, t0.us); if (t0.ui != t0.ul) warn(name, "0x%x 0x%x", t0.ui, t0.ul); } void stxi(types_t *t, unsigned long i, double d, void *p, int V0, int R0, int F0) { check_code (); jit_movi_p ( V0, t); jit_movi_i ( R0, C(i)); jit_stxi_c (offsetof(types_t, c), V0, R0); jit_stxi_uc (offsetof(types_t, uc), V0, R0); jit_movi_i ( R0, S(i)); jit_stxi_s (offsetof(types_t, s), V0, R0); jit_stxi_us (offsetof(types_t, us), V0, R0); jit_movi_i ( R0, I(i)); jit_stxi_i (offsetof(types_t, i), V0, R0); jit_stxi_ui (offsetof(types_t, ui), V0, R0); jit_movi_l ( R0, i); jit_stxi_l (offsetof(types_t, l), V0, R0); jit_stxi_ul (offsetof(types_t, ul), V0, R0); jit_movi_f ( F0, (float)d); jit_stxi_f (offsetof(types_t, f), V0, F0); jit_movi_d ( F0, d); jit_stxi_d (offsetof(types_t, d), V0, F0); jit_movi_p ( R0, p); jit_stxi_p (offsetof(types_t, p), V0, R0); } void movxi(types_t *ta, types_t *tb, int V0, int V1, int R0, int F0) { check_code (); jit_movi_p ( V0, ta); jit_movi_p ( V1, tb); jit_ldxi_c ( R0, V0, offsetof(types_t, c)); jit_stxi_c (offsetof(types_t, c), V1, R0); jit_ldxi_uc ( R0, V0, offsetof(types_t, uc)); jit_stxi_uc (offsetof(types_t, uc), V1, R0); jit_ldxi_s ( R0, V0, offsetof(types_t, s)); jit_stxi_s (offsetof(types_t, s), V1, R0); jit_ldxi_us ( R0, V0, offsetof(types_t, us)); jit_stxi_us (offsetof(types_t, us), V1, R0); jit_ldxi_i ( R0, V0, offsetof(types_t, i)); jit_stxi_i (offsetof(types_t, i), V1, R0); jit_ldxi_ui ( R0, V0, offsetof(types_t, ui)); jit_stxi_ui (offsetof(types_t, ui), V1, R0); jit_ldxi_l ( R0, V0, offsetof(types_t, l)); jit_stxi_l (offsetof(types_t, l), V1, R0); jit_ldxi_ul ( R0, V0, offsetof(types_t, ul)); jit_stxi_ul (offsetof(types_t, ul), V1, R0); jit_ldxi_f ( F0, V0, offsetof(types_t, f)); jit_stxi_f (offsetof(types_t, f), V1, F0); jit_ldxi_d ( F0, V0, offsetof(types_t, d)); jit_stxi_d (offsetof(types_t, d), V1, F0); jit_ldxi_p ( R0, V0, offsetof(types_t, p)); jit_stxi_p (offsetof(types_t, p), V1, R0); } void xi_c(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_c ( R0, V0, offsetof(types_t, c)); jit_stxi_s (offsetof(types_t, s), V0, R0); jit_stxi_i (offsetof(types_t, i), V0, R0); jit_stxi_l (offsetof(types_t, l), V0, R0); } void xi_uc(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_uc ( R0, V0, offsetof(types_t, uc)); jit_stxi_us (offsetof(types_t, us), V0, R0); jit_stxi_ui (offsetof(types_t, ui), V0, R0); jit_stxi_ul (offsetof(types_t, ul), V0, R0); } void xi_s(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_s ( R0, V0, offsetof(types_t, s)); jit_stxi_c (offsetof(types_t, c), V0, R0); jit_stxi_i (offsetof(types_t, i), V0, R0); jit_stxi_l (offsetof(types_t, l), V0, R0); } void xi_us(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_us ( R0, V0, offsetof(types_t, us)); jit_stxi_uc (offsetof(types_t, uc), V0, R0); jit_stxi_ui (offsetof(types_t, ui), V0, R0); jit_stxi_ul (offsetof(types_t, ul), V0, R0); } void xi_i(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_i ( R0, V0, offsetof(types_t, i)); jit_stxi_c (offsetof(types_t, c), V0, R0); jit_stxi_s (offsetof(types_t, s), V0, R0); jit_stxi_l (offsetof(types_t, l), V0, R0); } void xi_ui(types_t *t, int V0, int R0) { check_code (); jit_movi_p ( V0, t); jit_ldxi_ui ( R0, V0, offsetof(types_t, ui)); jit_stxi_uc (offsetof(types_t, uc), V0, R0); jit_stxi_us (offsetof(types_t, us), V0, R0); jit_stxi_ul (offsetof(types_t, ul), V0, R0); } void stxr(types_t *t, unsigned long i, double d, void *p, int V0, int R0, int R1, int F0) { check_code (); jit_movi_p (V0, t); jit_movi_i (R0, C(i)); jit_movi_i (R1, offsetof(types_t, c)); jit_stxr_c (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, uc)); jit_stxr_uc (R1, V0, R0); jit_movi_i (R0, S(i)); jit_movi_i (R1, offsetof(types_t, s)); jit_stxr_s (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, us)); jit_stxr_us (R1, V0, R0); jit_movi_i (R0, I(i)); jit_movi_i (R1, offsetof(types_t, i)); jit_stxr_i (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ui)); jit_stxr_ui (R1, V0, R0); jit_movi_l (R0, i); jit_movi_i (R1, offsetof(types_t, l)); jit_stxr_l (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ul)); jit_stxr_ul (R1, V0, R0); jit_movi_f (F0, (float)d); jit_movi_i (R1, offsetof(types_t, f)); jit_stxr_f (R1, V0, F0); jit_movi_d (F0, d); jit_movi_i (R1, offsetof(types_t, d)); jit_stxr_d (R1, V0, F0); jit_movi_p (R0, p); jit_movi_i (R1, offsetof(types_t, p)); jit_stxr_p (R1, V0, R0); } void movxr(types_t *ta, types_t *tb, int V0, int V1, int R0, int R1, int F0) { check_code (); jit_movi_p (V0, ta); jit_movi_p (V1, tb); jit_movi_i (R1, offsetof(types_t, c)); jit_ldxr_c (R0, V0, R1); jit_stxr_c (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, uc)); jit_ldxr_uc (R0, V0, R1); jit_stxr_uc (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, s)); jit_ldxr_s (R0, V0, R1); jit_stxr_s (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, us)); jit_ldxr_us (R0, V0, R1); jit_stxr_us (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, i)); jit_ldxr_i (R0, V0, R1); jit_stxr_i (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, ui)); jit_ldxr_ui (R0, V0, R1); jit_stxr_ui (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, l)); jit_ldxr_l (R0, V0, R1); jit_stxr_l (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, ul)); jit_ldxr_ul (R0, V0, R1); jit_stxr_ul (R1, V1, R0); jit_movi_i (R1, offsetof(types_t, f)); jit_ldxr_f (F0, V0, R1); jit_stxr_f (R1, V1, F0); jit_movi_i (R1, offsetof(types_t, d)); jit_ldxr_d (F0, V0, R1); jit_stxr_d (R1, V1, F0); jit_movi_i (R1, offsetof(types_t, p)); jit_ldxr_p (R0, V0, R1); jit_stxr_p (R1, V1, R0); } void xr_c(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, c)); jit_ldxr_c (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, s)); jit_stxr_s (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, i)); jit_stxr_i (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, l)); jit_stxr_l (R1, V0, R0); } void xr_uc(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, uc)); jit_ldxr_uc (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, us)); jit_stxr_us (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ui)); jit_stxr_ui (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ul)); jit_stxr_ul (R1, V0, R0); } void xr_s(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, s)); jit_ldxr_s (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, c)); jit_stxr_c (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, i)); jit_stxr_i (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, l)); jit_stxr_l (R1, V0, R0); } void xr_us(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, us)); jit_ldxr_us (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, uc)); jit_stxr_uc (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ui)); jit_stxr_ui (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ul)); jit_stxr_ul (R1, V0, R0); } void xr_i(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, i)); jit_ldxr_i (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, c)); jit_stxr_c (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, s)); jit_stxr_s (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, l)); jit_stxr_l (R1, V0, R0); } void xr_ui(types_t *t, int V0, int R0, int R1) { check_code (); jit_movi_p (V0, t); jit_movi_i (R1, offsetof(types_t, ui)); jit_ldxr_ui (R0, V0, R1); jit_movi_i (R1, offsetof(types_t, uc)); jit_stxr_uc (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, us)); jit_stxr_us (R1, V0, R0); jit_movi_i (R1, offsetof(types_t, ul)); jit_stxr_ul (R1, V0, R0); } void str(types_t *t, unsigned long i, double d, void *p, int V0, int R0, int F0) { check_code (); jit_movi_i (R0, C(i)); jit_movi_p (V0, (char *)t + offsetof(types_t, c)); jit_str_c (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, uc)); jit_str_uc (V0, R0); jit_movi_i (R0, S(i)); jit_movi_p (V0, (char *)t + offsetof(types_t, s)); jit_str_s (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, us)); jit_str_us (V0, R0); jit_movi_i (R0, I(i)); jit_movi_p (V0, (char *)t + offsetof(types_t, i)); jit_str_i (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ui)); jit_str_ui (V0, R0); jit_movi_l (R0, i); jit_movi_p (V0, (char *)t + offsetof(types_t, l)); jit_str_l (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ul)); jit_str_ul (V0, R0); jit_movi_f (F0, d); jit_movi_p (V0, (char *)t + offsetof(types_t, f)); jit_str_f (V0, F0); jit_movi_d (F0, d); jit_movi_p (V0, (char *)t + offsetof(types_t, d)); jit_str_d (V0, F0); jit_movi_p (R0, p); jit_movi_p (V0, (char *)t + offsetof(types_t, p)); jit_str_p (V0, R0); } void movr(types_t *ta, types_t *tb, int V0, int V1, int R0, int F0) { check_code (); jit_movi_p (V0, (char*)ta + offsetof(types_t, c)); jit_movi_p (V1, (char*)tb + offsetof(types_t, c)); jit_ldr_c (R0, V0); jit_str_c (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, uc)); jit_movi_p (V1, (char*)tb + offsetof(types_t, uc)); jit_ldr_uc (R0, V0); jit_str_uc (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, s)); jit_movi_p (V1, (char*)tb + offsetof(types_t, s)); jit_ldr_s (R0, V0); jit_str_s (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, us)); jit_movi_p (V1, (char*)tb + offsetof(types_t, us)); jit_ldr_us (R0, V0); jit_str_us (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, i)); jit_movi_p (V1, (char*)tb + offsetof(types_t, i)); jit_ldr_i (R0, V0); jit_str_i (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, ui)); jit_movi_p (V1, (char*)tb + offsetof(types_t, ui)); jit_ldr_ui (R0, V0); jit_str_ui (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, l)); jit_movi_p (V1, (char*)tb + offsetof(types_t, l)); jit_ldr_l (R0, V0); jit_str_l (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, ul)); jit_movi_p (V1, (char*)tb + offsetof(types_t, ul)); jit_ldr_ul (R0, V0); jit_str_ul (V1, R0); jit_movi_p (V0, (char*)ta + offsetof(types_t, f)); jit_movi_p (V1, (char*)tb + offsetof(types_t, f)); jit_ldr_f (F0, V0); jit_str_f (V1, F0); jit_movi_p (V0, (char*)ta + offsetof(types_t, d)); jit_movi_p (V1, (char*)tb + offsetof(types_t, d)); jit_ldr_d (F0, V0); jit_str_d (V1, F0); jit_movi_p (V0, (char*)ta + offsetof(types_t, p)); jit_movi_p (V1, (char*)tb + offsetof(types_t, p)); jit_ldr_p (R0, V0); jit_str_p (V1, R0); } void r_c(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, c)); jit_ldr_c (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, s)); jit_str_s (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, i)); jit_str_i (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, l)); jit_str_l (V0, R0); } void r_uc(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, uc)); jit_ldr_uc (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, us)); jit_str_us (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ui)); jit_str_ui (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ul)); jit_str_ul (V0, R0); } void r_s(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, s)); jit_ldr_s (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, c)); jit_str_c (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, i)); jit_str_i (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, l)); jit_str_l (V0, R0); } void r_us(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, us)); jit_ldr_us (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, uc)); jit_str_uc (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ui)); jit_str_ui (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ul)); jit_str_ul (V0, R0); } void r_i(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, i)); jit_ldr_i (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, c)); jit_str_c (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, s)); jit_str_s (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, l)); jit_str_l (V0, R0); } void r_ui(types_t *t, int V0, int R0) { check_code (); jit_movi_p (V0, (char *)t + offsetof(types_t, ui)); jit_ldr_ui (R0, V0); jit_movi_p (V0, (char *)t + offsetof(types_t, uc)); jit_str_uc (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, us)); jit_str_us (V0, R0); jit_movi_p (V0, (char *)t + offsetof(types_t, ul)); jit_str_ul (V0, R0); } void call_check(char *name, unsigned long i, double d, void *p, int R0, int F0) { check_code (); jit_prepare ((sizeof(void *) + sizeof(unsigned long) + sizeof(double) + sizeof(void *)) / sizeof(void*)); jit_movi_p (R0, p); jit_pusharg_p (R0); jit_movi_d (F0, d); jit_pusharg_d (F0); jit_movi_ul (R0, i); jit_pusharg_ul(R0); jit_movi_p (R0, name); jit_pusharg_p (R0); jit_finish (check); } void call_one(char *name, void (*function)(char*), int R0) { check_code (); jit_prepare (1); jit_movi_p (R0, name); jit_pusharg_p(R0); jit_finish (function); } void expand(types_t *ta, types_t *tb, unsigned long i, double d, void *p, int V0, int V1, int R0, int R1, int F0) { stxi (ta, i, d, p, V0, R0, F0); call_check ("stxi", i, d, p, R0, F0); movxi (ta, tb, V0, V1, R0, F0); call_one ("movxi", compare, R0); xi_c (ta, V0, R0); call_one ("xi_c", check_c, R0); xi_uc (ta, V0, R0); call_one ("xi_uc", check_uc, R0); xi_s (ta, V0, R0); call_one ("xi_s", check_s, R0); xi_us (ta, V0, R0); call_one ("xi_us", check_us, R0); xi_i (ta, V0, R0); call_one ("xi_i", check_i, R0); xi_ui (ta, V0, R0); call_one ("xi_ui", check_ui, R0); stxr (ta, i, d, p, V0, R0, R1, F0); call_check ("stxi", i, d, p, R0, F0); movxr (ta, tb, V0, V1, R0, R1, F0); call_one ("movxi", compare, R0); xr_c (ta, V0, R0, R1); call_one ("xr_c", check_c, R0); xr_uc (ta, V0, R0, R1); call_one ("xr_uc", check_uc, R0); xr_s (ta, V0, R0, R1); call_one ("xr_s", check_s, R0); xr_us (ta, V0, R0, R1); call_one ("xr_us", check_us, R0); xr_i (ta, V0, R0, R1); call_one ("xr_i", check_i, R0); xr_ui (ta, V0, R0, R1); call_one ("xr_ui", check_ui, R0); str (ta, i, d, p, V0, R0, F0); call_check ("str", i, d, p, R0, F0); movr (ta, tb, V0, V1, R0, F0); call_one ("movr", compare, R0); r_c (ta, V0, R0); call_one ("r_c", check_c, R0); r_uc (ta, V0, R0); call_one ("r_uc", check_uc, R0); r_s (ta, V0, R0); call_one ("r_s", check_s, R0); r_us (ta, V0, R0); call_one ("r_us", check_us, R0); r_i (ta, V0, R0); call_one ("r_i", check_i, R0); r_ui (ta, V0, R0); call_one ("r_ui", check_ui, R0); } void test(int V0, int V1, int R0, int R1, int F0) { expand(&t0, &t1, ULONG_VALUE, 0.5, &t0, V0, V1, R0, R1, F0); expand(&t0, &t1, SLONG_VALUE, -0.5, &t0, V0, V1, R0, R1, F0); expand(&t0, &t1, BLONG_VALUE, M_PI, &t1, V0, V1, R0, R1, F0); expand(&t0, &t1, FLONG_VALUE, 3.40282347e+38, (void *)0xdeadbeef, V0, V1, R0, R1, F0); } int main(int argc, char *argv[]) { int V[3] = { JIT_V0, JIT_V1, JIT_V2 }; int R[3] = { JIT_R0, JIT_R1, JIT_R2 }; int F[6] = { JIT_FPR0, JIT_FPR1, JIT_FPR2, JIT_FPR3, JIT_FPR4, JIT_FPR5 }; int V0, V1, R0, R1, FPR; jit_set_ip(code); jit_prolog(0); for (V0 = 0; V0 < 3; V0++) { for (V1 = 0; V1 < 3; V1++) { if (V1 == V0) continue; for (R0 = 0; R0 < 3; R0++) { for (R1 = 0; R1 < 3; R1++) { if (R1 == R0) continue; for (FPR = 0; FPR < 6; FPR++) test(V[V0], V[V1], R[R0], R[R1], F[FPR]); } } } } jit_ret(); jit_flush_code(code, jit_get_ip().ptr); pvv = (pvv_t)code; (*pvv)(); return (0); }