9 main(int argc, char *argv[])
13 jit_node_t *jmp, *inner, *fail;
16 _jit = jit_new_state();
20 /* Create a simple function that changes all available JIT_Vx */
23 for (off = JIT_R_NUM - 1; off >= 0; --off) {
24 if (jit_callee_save_p(JIT_R(off)))
25 jit_movi(JIT_R(off), (off + 1) * 2);
27 for (off = JIT_V_NUM - 1; off >= 0; --off)
28 jit_movi(JIT_V(off), -(off + 1));
29 /* If fprs are callee save, also test them */
30 for (off = JIT_F_NUM - 1; off >= 0; --off) {
31 if (jit_callee_save_p(JIT_F(off)))
32 jit_movi_d(JIT_F(off), -(off + 1));
34 /* Add some noise as there might be some error in the stack frame and
35 * a standard C function might clobber registers saved in the stack */
37 jit_pushargi((jit_word_t)stderr);
38 jit_pushargi((jit_word_t)
39 "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d "
40 "%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n");
89 for (off = JIT_R_NUM - 1; off >= 0; --off) {
90 if (jit_callee_save_p(JIT_R(off)))
91 jit_movi(JIT_R(off), -(off + 1) * 2);
93 for (off = JIT_V_NUM - 1; off >= 0; --off)
94 jit_movi(JIT_V(off), 0x7fffffff - (off + 1));
95 /* If fprs are callee save, also test them */
96 for (off = JIT_F_NUM - 1; off >= 0; --off) {
97 if (jit_callee_save_p(JIT_F(off)))
98 jit_movi_d(JIT_F(off), 0x7fffffff - (off + 1));
100 jit_patch_at(jit_calli(NULL), inner);
102 /* Now validate no register has been clobbered */
103 fail = jit_forward();
105 for (off = JIT_R_NUM - 1; off >= 0; --off) {
106 if (jit_callee_save_p(JIT_R(off))) {
108 jmp = jit_beqi(JIT_R(off), -(off + 1) * 2);
112 jit_patch_at(jit_bnei(JIT_R(off), -(off + 1) * 2), fail);
116 for (off = JIT_V_NUM - 1; off >= 0; --off) {
118 jmp = jit_beqi(JIT_V(off), 0x7fffffff - (off + 1));
122 jit_patch_at(jit_bnei(JIT_V(off), 0x7fffffff - (off + 1)), fail);
125 for (off = JIT_F_NUM - 1; off >= 0; --off) {
126 if (jit_callee_save_p(JIT_F(off))) {
128 jmp = jit_beqi_d(JIT_F(off), 0x7fffffff - (off + 1));
132 jit_patch_at(jit_bnei_d(JIT_F(off), 0x7fffffff - (off + 1)), fail);
137 /* Done if passed all tests */
139 /* Where to land if there was any register clobber */