try a new github issue template
[pcsx_rearmed.git] / deps / lightning / doc / incr.c
1 #include <stdio.h>
2 #include <lightning.h>
3
4 static jit_state_t *_jit;
5
6 typedef int (*pifi)(int);    /* Pointer to Int Function of Int */
7
8 int main(int argc, char *argv[])
9 {
10   jit_node_t  *in;
11   pifi         incr;
12
13   init_jit(argv[0]);
14   _jit = jit_new_state();
15
16   jit_prolog();                    /* @t{     prolog             } */
17   in = jit_arg();                  /* @t{     in = arg           } */
18   jit_getarg(JIT_R0, in);          /* @t{     getarg R0          } */
19   jit_addi(JIT_R0, JIT_R0, 1);     /* @t{     addi   R0\, R0\, 1 } */
20   jit_retr(JIT_R0);                /* @t{     retr   R0          } */
21
22   incr = jit_emit();
23   jit_clear_state();
24
25   /* call the generated code\, passing 5 as an argument */
26   printf("%d + 1 = %d\n", 5, incr(5));
27
28   jit_destroy_state();
29   finish_jit();
30   return 0;
31 }