1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
|
#include <lightning.h>
#include <stdio.h>
#define _w0 0
#define _w1 1
#define _w2 (_w1-2)
#define _w3 (_w2-3)
#define _w4 (_w3-4)
#define _w5 (_w4-5)
#define _w6 (_w5-6)
#define _w7 (_w6-7)
#define _w8 (_w7-8)
#define _w9 (_w8-9)
#define _w10 (_w9-10)
#define _w11 (_w10-11)
#define _w12 (_w11-12)
#define _w13 (_w12-13)
#define _w14 (_w13-14)
#define _w15 (_w14-15)
#define _c0 _w0
#define _c1 _w1
#define _c2 _w2
#define _c3 _w3
#define _c4 _w4
#define _c5 _w5
#define _c6 _w6
#define _c7 _w7
#define _c8 _w8
#define _c9 _w9
#define _c10 _w10
#define _c11 _w11
#define _c12 _w12
#define _c13 _w13
#define _c14 _w14
#define _c15 _w15
#define _uc0 (_w0&0xff)
#define _uc1 (_w1&0xff)
#define _uc2 (_w2&0xff)
#define _uc3 (_w3&0xff)
#define _uc4 (_w4&0xff)
#define _uc5 (_w5&0xff)
#define _uc6 (_w6&0xff)
#define _uc7 (_w7&0xff)
#define _uc8 (_w8&0xff)
#define _uc9 (_w9&0xff)
#define _uc10 (_w10&0xff)
#define _uc11 (_w11&0xff)
#define _uc12 (_w12&0xff)
#define _uc13 (_w13&0xff)
#define _uc14 (_w14&0xff)
#define _uc15 (_w15&0xff)
#define _s0 _w0
#define _s1 _w1
#define _s2 _w2
#define _s3 _w3
#define _s4 _w4
#define _s5 _w5
#define _s6 _w6
#define _s7 _w7
#define _s8 _w8
#define _s9 _w9
#define _s10 _w10
#define _s11 _w11
#define _s12 _w12
#define _s13 _w13
#define _s14 _w14
#define _s15 _w15
#define _us0 (_w0&0xffff)
#define _us1 (_w1&0xffff)
#define _us2 (_w2&0xffff)
#define _us3 (_w3&0xffff)
#define _us4 (_w4&0xffff)
#define _us5 (_w5&0xffff)
#define _us6 (_w6&0xffff)
#define _us7 (_w7&0xffff)
#define _us8 (_w8&0xffff)
#define _us9 (_w9&0xffff)
#define _us10 (_w10&0xffff)
#define _us11 (_w11&0xffff)
#define _us12 (_w12&0xffff)
#define _us13 (_w13&0xffff)
#define _us14 (_w14&0xffff)
#define _us15 (_w15&0xffff)
#define _i0 _w0
#define _i1 _w1
#define _i2 _w2
#define _i3 _w3
#define _i4 _w4
#define _i5 _w5
#define _i6 _w6
#define _i7 _w7
#define _i8 _w8
#define _i9 _w9
#define _i10 _w10
#define _i11 _w11
#define _i12 _w12
#define _i13 _w13
#define _i14 _w14
#define _i15 _w15
#if __WORDSIZE == 64
# define _ui0 (_w0&0xffffffff)
# define _ui1 (_w1&0xffffffff)
# define _ui2 (_w2&0xffffffff)
# define _ui3 (_w3&0xffffffff)
# define _ui4 (_w4&0xffffffff)
# define _ui5 (_w5&0xffffffff)
# define _ui6 (_w6&0xffffffff)
# define _ui7 (_w7&0xffffffff)
# define _ui8 (_w8&0xffffffff)
# define _ui9 (_w9&0xffffffff)
# define _ui10 (_w10&0xffffffff)
# define _ui11 (_w11&0xffffffff)
# define _ui12 (_w12&0xffffffff)
# define _ui13 (_w13&0xffffffff)
# define _ui14 (_w14&0xffffffff)
# define _ui15 (_w15&0xffffffff)
# define _l0 _w0
# define _l1 _w1
# define _l2 _w2
# define _l3 _w3
# define _l4 _w4
# define _l5 _w5
# define _l6 _w6
# define _l7 _w7
# define _l8 _w8
# define _l9 _w9
# define _l10 _w10
# define _l11 _w11
# define _l12 _w12
# define _l13 _w13
# define _l14 _w14
# define _l15 _w15
#endif
/*
* Types
*/
typedef signed char _c;
typedef unsigned char _uc;
typedef signed short _s;
typedef unsigned short _us;
typedef signed int _i;
#if __WORDSIZE == 64
typedef unsigned int _ui;
typedef jit_word_t _l;
#endif
typedef float _f;
typedef double _d;
#define prt0(T) T C##T##0(void);
#define prt1(T) prt0(T) \
T C##T##1(T);
#define prt2(T) prt1(T) \
T C##T##2(T,T);
#define prt3(T) prt2(T) \
T C##T##3(T,T,T);
#define prt4(T) prt3(T) \
T C##T##4(T,T,T,T);
#define prt5(T) prt4(T) \
T C##T##5(T,T,T,T,T);
#define prt6(T) prt5(T) \
T C##T##6(T,T,T,T,T,T);
#define prt7(T) prt6(T) \
T C##T##7(T,T,T,T,T,T,T);
#define prt8(T) prt7(T) \
T C##T##8(T,T,T,T,T,T,T,T);
#define prt9(T) prt8(T) \
T C##T##9(T,T,T,T,T,T,T,T,T);
#define prt10(T) prt9(T) \
T C##T##10(T,T,T,T,T,T,T,T,T,T);
#define prt11(T) prt10(T) \
T C##T##11(T,T,T,T,T,T,T,T,T,T,T);
#define prt12(T) prt11(T) \
T C##T##12(T,T,T,T,T,T,T,T,T,T,T,T);
#define prt13(T) prt12(T) \
T C##T##13(T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt14(T) prt13(T) \
T C##T##14(T,T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt15(T) prt14(T) \
T C##T##15(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt(T) prt15(T)
prt(_c)
prt(_uc)
prt(_s)
prt(_us)
prt(_i)
#if __WORDSIZE == 64
prt(_ui)
prt(_l)
#endif
prt(_f)
prt(_d)
#undef prt
#undef prt15
#undef prt14
#undef prt13
#undef prt12
#undef prt11
#undef prt10
#undef prt9
#undef prt8
#undef prt7
#undef prt6
#undef prt5
#undef prt4
#undef prt3
#undef prt2
#undef prt1
#undef prt0
#define prtn(N,T) T J##T##n(void);
#define prt0(T) prtn(0,T)
#define prt1(T) prt0(T) prtn(1,T)
#define prt2(T) prt1(T) prtn(2,T)
#define prt3(T) prt2(T) prtn(3,T)
#define prt4(T) prt3(T) prtn(4,T)
#define prt5(T) prt4(T) prtn(5,T)
#define prt6(T) prt5(T) prtn(6,T)
#define prt7(T) prt6(T) prtn(7,T)
#define prt8(T) prt7(T) prtn(8,T)
#define prt9(T) prt8(T) prtn(9,T)
#define prt10(T) prt9(T) prtn(10,T)
#define prt11(T) prt10(T) prtn(11,T)
#define prt12(T) prt11(T) prtn(12,T)
#define prt13(T) prt12(T) prtn(13,T)
#define prt14(T) prt13(T) prtn(14,T)
#define prt15(T) prt14(T) prtn(15,T)
#define prt(T) prt15(T)
prt(_c)
prt(_uc)
prt(_s)
prt(_us)
prt(_i)
#if __WORDSIZE == 64
prt(_ui)
prt(_l)
#endif
prt(_f)
prt(_d)
#undef prt
#undef prt15
#undef prt14
#undef prt13
#undef prt12
#undef prt11
#undef prt10
#undef prt9
#undef prt8
#undef prt7
#undef prt6
#undef prt5
#undef prt4
#undef prt3
#undef prt2
#undef prt1
#undef prt0
#undef prtn
/*
* Initialization
*/
#define dat0(T) T (*j##T##0)(void); \
jit_node_t *n##T##0;
#define dat1(T) dat0(T) \
T (*j##T##1)(T); \
jit_node_t *n##T##1;
#define dat2(T) dat1(T) \
T (*j##T##2)(T,T); \
jit_node_t *n##T##2;
#define dat3(T) dat2(T) \
T (*j##T##3)(T,T,T); \
jit_node_t *n##T##3;
#define dat4(T) dat3(T) \
T (*j##T##4)(T,T,T,T); \
jit_node_t *n##T##4;
#define dat5(T) dat4(T) \
T (*j##T##5)(T,T,T,T,T); \
jit_node_t *n##T##5;
#define dat6(T) dat5(T) \
T (*j##T##6)(T,T,T,T,T,T); \
jit_node_t *n##T##6;
#define dat7(T) dat6(T) \
T (*j##T##7)(T,T,T,T,T,T,T); \
jit_node_t *n##T##7;
#define dat8(T) dat7(T) \
T (*j##T##8)(T,T,T,T,T,T,T,T); \
jit_node_t *n##T##8;
#define dat9(T) dat8(T) \
T (*j##T##9)(T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##9;
#define dat10(T) dat9(T) \
T (*j##T##10)(T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##10;
#define dat11(T) dat10(T) \
T (*j##T##11)(T,T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##11;
#define dat12(T) dat11(T) \
T (*j##T##12)(T,T,T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##12;
#define dat13(T) dat12(T) \
T (*j##T##13)(T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##13;
#define dat14(T) dat13(T) \
T (*j##T##14)(T,T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##14;
#define dat15(T) dat14(T) \
T (*j##T##15)(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##15;
#define dat(T) dat15(T)
dat(_c)
dat(_uc)
dat(_s)
dat(_us)
dat(_i)
#if __WORDSIZE == 64
dat(_ui)
dat(_l)
#endif
dat(_f)
dat(_d)
#undef dat
#undef dat15
#undef dat14
#undef dat13
#undef dat12
#undef dat11
#undef dat10
#undef dat9
#undef dat8
#undef dat7
#undef dat6
#undef dat5
#undef dat4
#undef dat3
#undef dat2
#undef dat1
#undef dat0
/*
* Implementation
*/
#define dcl0(T) \
T C##T##0(void) \
{ \
return (0); \
}
#define dcl1(T) \
dcl0(T) \
T C##T##1(T A) \
{ \
return (A); \
}
#define dcl2(T) \
dcl1(T) \
T C##T##2(T A,T B) \
{ \
return (A-B); \
}
#define dcl3(T) \
dcl2(T) \
T C##T##3(T A,T B,T C) \
{ \
return (A-B-C); \
}
#define dcl4(T) \
dcl3(T) \
T C##T##4(T A,T B,T C,T D) \
{ \
return (A-B-C-D); \
}
#define dcl5(T) \
dcl4(T) \
T C##T##5(T A,T B,T C,T D,T E) \
{ \
return (A-B-C-D-E); \
}
#define dcl6(T) \
dcl5(T) \
T C##T##6(T A,T B,T C,T D,T E,T F) \
{ \
return (A-B-C-D-E-F); \
}
#define dcl7(T) \
dcl6(T) \
T C##T##7(T A,T B,T C,T D,T E,T F,T G) \
{ \
return (A-B-C-D-E-F-G); \
}
#define dcl8(T) \
dcl7(T) \
T C##T##8(T A,T B,T C,T D,T E,T F,T G,T H) \
{ \
return (A-B-C-D-E-F-G-H); \
}
#define dcl9(T) \
dcl8(T) \
T C##T##9(T A,T B,T C,T D,T E,T F,T G,T H,T I) \
{ \
return (A-B-C-D-E-F-G-H-I); \
}
#define dcl10(T) \
dcl9(T) \
T C##T##10(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J) \
{ \
return (A-B-C-D-E-F-G-H-I-J); \
}
#define dcl11(T) \
dcl10(T) \
T C##T##11(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K); \
}
#define dcl12(T) \
dcl11(T) \
T C##T##12(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L); \
}
#define dcl13(T) \
dcl12(T) \
T C##T##13(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M); \
}
#define dcl14(T) \
dcl13(T) \
T C##T##14(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M,T N) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M-N); \
}
#define dcl15(T) \
dcl14(T) \
T C##T##15(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M,T N,T O) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M-N-O); \
}
#define dcl(T) dcl15(T)
dcl(_c)
dcl(_uc)
dcl(_s)
dcl(_us)
dcl(_i)
#if __WORDSIZE == 64
dcl(_ui)
dcl(_l)
#endif
dcl(_f)
dcl(_d)
#undef dcl
#undef dcl15
#undef dcl14
#undef dcl13
#undef dcl12
#undef dcl11
#undef dcl10
#undef dcl9
#undef dcl8
#undef dcl7
#undef dcl6
#undef dcl5
#undef dcl4
#undef dcl3
#undef dcl2
#undef dcl1
#undef dcl0
#define dcl0(T) \
T CJ##T##0(void) \
{ \
return ((*j##T##0)()); \
}
#define dcl1(T) \
dcl0(T) \
T CJ##T##1(void) \
{ \
return ((*j##T##1)(1)); \
}
#define dcl2(T) \
dcl1(T) \
T CJ##T##2(void) \
{ \
return ((*j##T##2)(1,2)); \
}
#define dcl3(T) \
dcl2(T) \
T CJ##T##3(void) \
{ \
return ((*j##T##3)(1,2,3)); \
}
#define dcl4(T) \
dcl3(T) \
T CJ##T##4(void) \
{ \
return ((*j##T##4)(1,2,3,4)); \
}
#define dcl5(T) \
dcl4(T) \
T CJ##T##5(void) \
{ \
return ((*j##T##5)(1,2,3,4,5)); \
}
#define dcl6(T) \
dcl5(T) \
T CJ##T##6(void) \
{ \
return ((*j##T##6)(1,2,3,4,5,6)); \
}
#define dcl7(T) \
dcl6(T) \
T CJ##T##7(void) \
{ \
return ((*j##T##7)(1,2,3,4,5,6,7)); \
}
#define dcl8(T) \
dcl7(T) \
T CJ##T##8(void) \
{ \
return ((*j##T##8)(1,2,3,4,5,6,7,8)); \
}
#define dcl9(T) \
dcl8(T) \
T CJ##T##9(void) \
{ \
return ((*j##T##9)(1,2,3,4,5,6,7,8,9)); \
}
#define dcl10(T) \
dcl9(T) \
T CJ##T##10(void) \
{ \
return ((*j##T##10)(1,2,3,4,5,6,7,8,9,10)); \
}
#define dcl11(T) \
dcl10(T) \
T CJ##T##11(void) \
{ \
return ((*j##T##11)(1,2,3,4,5,6,7,8,9,10,11)); \
}
#define dcl12(T) \
dcl11(T) \
T CJ##T##12(void) \
{ \
return ((*j##T##12)(1,2,3,4,5,6,7,8,9,10,11,12)); \
}
#define dcl13(T) \
dcl12(T) \
T CJ##T##13(void) \
{ \
return ((*j##T##13)(1,2,3,4,5,6,7,8,9,10,11,12,13)); \
}
#define dcl14(T) \
dcl13(T) \
T CJ##T##14(void) \
{ \
return ((*j##T##14)(1,2,3,4,5,6,7,8,9,10,11,12,13,14)); \
}
#define dcl15(T) \
dcl14(T) \
T CJ##T##15(void) \
{ \
return ((*j##T##15)(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)); \
}
#define dcl(t) dcl15(t)
dcl(_c)
dcl(_uc)
dcl(_s)
dcl(_us)
dcl(_i)
#if __WORDSIZE == 64
dcl(_ui)
dcl(_l)
#endif
dcl(_f)
dcl(_d)
#undef dcl
#undef dcl15
#undef dcl14
#undef dcl13
#undef dcl12
#undef dcl11
#undef dcl10
#undef dcl9
#undef dcl8
#undef dcl7
#undef dcl6
#undef dcl5
#undef dcl4
#undef dcl3
#undef dcl2
#undef dcl1
#undef dcl0
int
main(int argc, char *argv[])
{
jit_state_t *_jit;
jit_node_t *jmpi_main;
void (*function)(void);
jit_node_t *a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9;
jit_node_t *a10,*a11,*a12,*a13,*a14,*a15;
jit_node_t *jmp;
init_jit(argv[0]);
_jit = jit_new_state();
jmpi_main = jit_jmpi();
#define arg0(T) /**/
#define arg1(T) a1 = jit_arg##T();
#define arg2(T) arg1(T) a2 = jit_arg##T();
#define arg3(T) arg2(T) a3 = jit_arg##T();
#define arg4(T) arg3(T) a4 = jit_arg##T();
#define arg5(T) arg4(T) a5 = jit_arg##T();
#define arg6(T) arg5(T) a6 = jit_arg##T();
#define arg7(T) arg6(T) a7 = jit_arg##T();
#define arg8(T) arg7(T) a8 = jit_arg##T();
#define arg9(T) arg8(T) a9 = jit_arg##T();
#define arg10(T) arg9(T) a10 = jit_arg##T();
#define arg11(T) arg10(T) a11 = jit_arg##T();
#define arg12(T) arg11(T) a12 = jit_arg##T();
#define arg13(T) arg12(T) a13 = jit_arg##T();
#define arg14(T) arg13(T) a14 = jit_arg##T();
#define arg15(T) arg14(T) a15 = jit_arg##T();
#define get0(B,T,R) jit_movi##B(R##0,0);
#define get1(B,T,R) jit_getarg##B(R##0,a##1);
#define get2(B,T,R) \
get1(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##2); \
jit_subr##B(R##0, R##1, R##0);
#define get3(B,T,R) \
get2(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##3); \
jit_subr##B(R##0, R##1, R##0);
#define get4(B,T,R) \
get3(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##4); \
jit_subr##B(R##0, R##1, R##0);
#define get5(B,T,R) \
get4(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##5); \
jit_subr##B(R##0, R##1, R##0);
#define get6(B,T,R) \
get5(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##6); \
jit_subr##B(R##0, R##1, R##0);
#define get7(B,T,R) \
get6(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##7); \
jit_subr##B(R##0, R##1, R##0);
#define get8(B,T,R) \
get7(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##8); \
jit_subr##B(R##0, R##1, R##0);
#define get9(B,T,R) \
get8(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##9); \
jit_subr##B(R##0, R##1, R##0);
#define get10(B,T,R) \
get9(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##10); \
jit_subr##B(R##0, R##1, R##0);
#define get11(B,T,R) \
get10(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##11); \
jit_subr##B(R##0, R##1, R##0);
#define get12(B,T,R) \
get11(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##12); \
jit_subr##B(R##0, R##1, R##0);
#define get13(B,T,R) \
get12(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##13); \
jit_subr##B(R##0, R##1, R##0);
#define get14(B,T,R) \
get13(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##14); \
jit_subr##B(R##0, R##1, R##0);
#define get15(B,T,R) \
get14(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##15); \
jit_subr##B(R##0, R##1, R##0);
#if __WORDSIZE == 32
# define jit_extr_i(u, v) /**/
#else
# define jit_extr_l(u, v) /**/
#endif
#define strfy(n) #n
#define defi(T, N) \
n##T##N = jit_name(strfy(n##T##N)); \
jit_note("ccall.c", __LINE__); \
jit_prolog(); \
arg##N(); \
get##N(,T,JIT_R) \
jit_extr##T(JIT_R0, JIT_R0); \
jit_retr(JIT_R0); \
jit_epilog();
#define deff(T, N) \
n##T##N = jit_name(strfy(n##T##N)); \
jit_note("ccall.c", __LINE__); \
jit_prolog(); \
arg##N(T); \
get##N(T,T,JIT_F); \
jit_retr##T(JIT_F0); \
jit_epilog();
#define def0(X, T) def##X(T, 0)
#define def1(X, T) def0(X, T) def##X(T, 1)
#define def2(X, T) def1(X, T) def##X(T, 2)
#define def3(X, T) def2(X, T) def##X(T, 3)
#define def4(X, T) def3(X, T) def##X(T, 4)
#define def5(X, T) def4(X, T) def##X(T, 5)
#define def6(X, T) def5(X, T) def##X(T, 6)
#define def7(X, T) def6(X, T) def##X(T, 7)
#define def8(X, T) def7(X, T) def##X(T, 8)
#define def9(X, T) def8(X, T) def##X(T, 9)
#define def10(X, T) def9(X, T) def##X(T, 10)
#define def11(X, T) def10(X, T) def##X(T, 11)
#define def12(X, T) def11(X, T) def##X(T, 12)
#define def13(X, T) def12(X, T) def##X(T, 13)
#define def14(X, T) def13(X, T) def##X(T, 14)
#define def15(X, T) def14(X, T) def##X(T, 15)
#define def(T) def15(i, T)
def(_c)
def(_uc)
def(_s)
def(_us)
def(_i)
#if __WORDSIZE == 64
def(_ui)
def(_l)
#endif
#undef def
#define def(T) def15(f, T)
def(_f)
def(_d)
#undef def
jit_patch(jmpi_main);
jit_name("main");
jit_note("ccall.c", __LINE__);
jit_prolog();
#define push0(T) /**/
#define push1(T) jit_pushargi##T(1);
#define push2(T) push1(T) jit_pushargi##T(2);
#define push3(T) push2(T) jit_pushargi##T(3);
#define push4(T) push3(T) jit_pushargi##T(4);
#define push5(T) push4(T) jit_pushargi##T(5);
#define push6(T) push5(T) jit_pushargi##T(6);
#define push7(T) push6(T) jit_pushargi##T(7);
#define push8(T) push7(T) jit_pushargi##T(8);
#define push9(T) push8(T) jit_pushargi##T(9);
#define push10(T) push9(T) jit_pushargi##T(10);
#define push11(T) push10(T) jit_pushargi##T(11);
#define push12(T) push11(T) jit_pushargi##T(12);
#define push13(T) push12(T) jit_pushargi##T(13);
#define push14(T) push13(T) jit_pushargi##T(14);
#define push15(T) push14(T) jit_pushargi##T(15);
#define calin(T,N) \
jit_prepare(); \
push##N() \
jit_finishi(C##T##N); \
jit_retval##T(JIT_R0); \
jmp = jit_beqi(JIT_R0, T##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calfn(T,N) \
jit_prepare(); \
push##N(T) \
jit_finishi(C##T##N); \
jit_retval##T(JIT_F0); \
jmp = jit_beqi##T(JIT_F0, _w##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calx0(X,T) cal##X##n(T,0)
#define calx1(X,T) calx0(X,T) cal##X##n(T,1)
#define calx2(X,T) calx1(X,T) cal##X##n(T,2)
#define calx3(X,T) calx2(X,T) cal##X##n(T,3)
#define calx4(X,T) calx3(X,T) cal##X##n(T,4)
#define calx5(X,T) calx4(X,T) cal##X##n(T,5)
#define calx6(X,T) calx5(X,T) cal##X##n(T,6)
#define calx7(X,T) calx6(X,T) cal##X##n(T,7)
#define calx8(X,T) calx7(X,T) cal##X##n(T,8)
#define calx9(X,T) calx8(X,T) cal##X##n(T,9)
#define calx10(X,T) calx9(X,T) cal##X##n(T,10)
#define calx11(X,T) calx10(X,T) cal##X##n(T,11)
#define calx12(X,T) calx11(X,T) cal##X##n(T,12)
#define calx13(X,T) calx12(X,T) cal##X##n(T,13)
#define calx14(X,T) calx13(X,T) cal##X##n(T,14)
#define calx15(X,T) calx14(X,T) cal##X##n(T,15)
#define cali(T) calx15(i,T)
#define calf(T) calx15(f,T)
cali(_c)
cali(_uc)
cali(_s)
cali(_us)
cali(_i)
#if __WORDSIZE == 64
cali(_ui)
cali(_l)
#endif
calf(_f)
calf(_d)
#undef calin
#undef calfn
#define calin(T,N) \
jit_prepare(); \
push##N() \
jit_finishi(CJ##T##N); \
jit_retval##T(JIT_R0); \
jmp = jit_beqi(JIT_R0, T##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calfn(T,N) \
jit_prepare(); \
push##N(T) \
jit_finishi(CJ##T##N); \
jit_retval##T(JIT_F0); \
jmp = jit_beqi##T(JIT_F0, _w##N); \
jit_calli(abort); \
jit_patch(jmp);
cali(_c)
cali(_uc)
cali(_s)
cali(_us)
cali(_i)
#if __WORDSIZE == 64
cali(_ui)
cali(_l)
#endif
calf(_f)
calf(_d)
jit_ret();
function = jit_emit();
#define initn(T,N) j##T##N = jit_address(n##T##N);
#define init0(T) initn(T,0)
#define init1(T) init0(T) initn(T,1)
#define init2(T) init1(T) initn(T,2)
#define init3(T) init2(T) initn(T,3)
#define init4(T) init3(T) initn(T,4)
#define init5(T) init4(T) initn(T,5)
#define init6(T) init5(T) initn(T,6)
#define init7(T) init6(T) initn(T,7)
#define init8(T) init7(T) initn(T,8)
#define init9(T) init8(T) initn(T,9)
#define init10(T) init9(T) initn(T,10)
#define init11(T) init10(T) initn(T,11)
#define init12(T) init11(T) initn(T,12)
#define init13(T) init12(T) initn(T,13)
#define init14(T) init13(T) initn(T,14)
#define init15(T) init14(T) initn(T,15)
#define init(T) init15(T)
init(_c)
init(_uc)
init(_s)
init(_us)
init(_i)
#if __WORDSIZE == 64
init(_ui)
init(_l)
#endif
init(_f)
init(_d)
#if 0
jit_print();
jit_disassemble();
#endif
jit_clear_state();
(*function)();
jit_destroy_state();
finish_jit();
printf("ok\n");
return (0);
}
|