aboutsummaryrefslogtreecommitdiff
path: root/deps/lightning/lib/jit_alpha-cpu.c
blob: 8bfef9caf9e8dd2bda2558c7c40bf1131d3deeb3 (plain)
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
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
/*
 * Copyright (C) 2014-2019  Free Software Foundation, Inc.
 *
 * This file is part of GNU lightning.
 *
 * GNU lightning is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * GNU lightning is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#if PROTO
#  define _u2(v)			((v) & 0x3)
#  define _s2_p(v)			((v) >= -0x2 && (v) <= 0x1)
#  define _u2_p(v)			((v) >= 0 && (v) <= 0x3)
#  define _u5(v)			((v) & 0x1f)
#  define _s5_p(v)			((v) >= -0x10 && (v) <= 0xf)
#  define _u5_p(v)			((v) >= 0 && (v) <= 0x1f)
#  define _u6(v)			((v) & 0x3f)
#  define _s6_p(v)			((v) >= -0x20 && (v) <= 0x1f)
#  define _u6_p(v)			((v) >= 0 && (v) <= 0x3f)
#  define _u7(v)			((v) & 0x7f)
#  define _s7_p(v)			((v) >= -0x40 && (v) <= 0x3f)
#  define _u7_p(v)			((v) >= 0 && (v) <= 0x7f)
#  define _u8(v)			((v) & 0xff)
#  define _s8_p(v)			((v) >= -0x80 && (v) <= 0x7f)
#  define _u8_p(v)			((v) >= 0 && (v) <= 0xff)
#  define _u11(v)			((v) & 0x7ff)
#  define _s11_p(v)			((v) >= -0x400 && (v) <= 0x3ff)
#  define _u11_p(v)			((v) >= 0 && (v) <= 0x7ff)
#  define _u14(v)			((v) & 0x3fff)
#  define _s14_p(v)			((v) >= -0x2000 && (v) <= 0x1fff)
#  define _u14_p(v)			((v) >= 0 && (v) <= 0x3fff)
#  define _u16(v)			((v) & 0xffff)
#  define _s16_p(v)			((v) >= -0x8000 && (v) <= 0x7fff)
#  define _u16_p(v)			((v) >= 0 && (v) <= 0xffff)
#  define _u21(v)			((v) & 0x1fffff)
#  define _s21_p(v)			((v) >= -0x100000 && (v) <= 0xfffff)
#  define _u21_p(v)			((v) >= 0 && (v) <= 0x1fffff)
#  define _u26(v)			((v) & 0x3ffffff)
#  define _s26_p(v)			((v) >= -0x2000000 && (v) <= 0x1ffffff)
#  define _u26_p(v)			((v) >= 0 && (v) <= 0x3ffffff)
#  define _u32(v)			((v) & 0xffffffff)
#  define _s32_p(v)			((v) >= -0x80000000 && (v) <= 0x7fffffff)
#  define _u32_p(v)			((v) >= 0 && (v) <= 0xffffffff)
#  define ii(i)				*_jit->pc.ui++ = i
#  define stack_framesize		224
#  define _S0_REGNO			0x09
#  define _S1_REGNO			0x0a
#  define _S2_REGNO			0x0b
#  define _S3_REGNO			0x0c
#  define _S4_REGNO			0x0d
#  define _S5_REGNO			0x0e
#  define _FP_REGNO			0x0f
#  define _A0_REGNO			0x10
#  define _A1_REGNO			0x11
#  define _A2_REGNO			0x12
#  define _V0_REGNO			0x00
#  define _T0_REGNO			0x01
#  define _T1_REGNO			0x02
#  define _RA_REGNO			0x1a
#  define _PV_REGNO			0x1b
#  define _GP_REGNO			0x1d
#  define _SP_REGNO			0x1e
#  define _R31_REGNO			0x1f
#  define Pcd(o,n)			_Pcd(_jit,o,n)
static void _Pcd(jit_state_t*,int,unsigned int) maybe_unused;
#  define Bra(o,ra,d)			_Bra(_jit,o,ra,d)
static void _Bra(jit_state_t*,int,int,int);
#  define Mem(o,ra,rb,d)			_Mem(_jit,o,ra,rb,d)
static void _Mem(jit_state_t*,int,int,int,unsigned int);
#  define Mbr(o,ra,rb,h,d)		_Mbr(_jit,o,ra,rb,h,d)
static void _Mbr(jit_state_t*,int,int,int,int,int);
#  define Opr(o,ra,rb,f,rc)		_Opr(_jit,o,ra,rb,f,rc)
static void _Opr(jit_state_t*,int,int,int,unsigned int,int);
#  define Opi(o,ra,i,f,rc)		_Opi(_jit,o,ra,i,f,rc)
static void _Opi(jit_state_t*,int,int,unsigned int,unsigned int,int);
#  define ADDL(ra,rb,rc)		Opr(0x10,ra,rb,0x00,rc)
#  define ADDLi(ra,im,rc)		Opi(0x10,ra,im,0x00,rc)
#  define ADDL_V(ra,rb,rc)		Opr(0x10,ra,rb,0x40,rc)
#  define ADDL_Vi(ra,im,rc)		Opi(0x10,ra,im,0x40,rc)
#  define ADDQ(ra,rb,rc)		Opr(0x10,ra,rb,0x20,rc)
#  define ADDQi(ra,im,rc)		Opi(0x10,ra,im,0x20,rc)
#  define ADDQ_V(ra,rb,rc)		Opr(0x10,ra,rb,0x60,rc)
#  define ADDQ_Vi(ra,im,rc)		Opi(0x10,ra,im,0x60,rc)
#  define AMASK(rb,rc)			Opr(0x11,_R31_REGNO,rb,0x61,rc)
#  define AND(ra,rb,rc)			Opr(0x11,ra,rb,0x00,rc)
#  define ANDi(ra,im,rc)		Opi(0x11,ra,im,0x00,rc)
#  define BEQ(ra,d)			Bra(0x39,ra,d)
#  define BGE(ra,d)			Bra(0x3e,ra,d)
#  define BGT(ra,d)			Bra(0x3f,ra,d)
#  define BIC(ra,rb,rc)			Opr(0x11,ra,rb,0x08,rc)
#  define ANDNOT(ra,rb,rc)		BIC(ra,rb,rc)
#  define BICi(ra,im,rc)		Opi(0x11,ra,im,0x08,rc)
#  define ANDNOTi(ra,im,rc)		BICi(ra,im,rc)
#  define BIS(ra,rb,rc)			Opr(0x11,ra,rb,0x20,rc)
#  define BISi(ra,im,rc)		Opi(0x11,ra,im,0x20,rc)
#  define OR(ra,rb,rc)			BIS(ra,rb,rc)
#  define ORi(ra,im,rc)			BISi(ra,im,rc)
#  define BLBC(ra,d)			Bra(0x38,ra,d)
#  define BLBS(ra,d)			Bra(0x3c,ra,d)
#  define BLE(ra,d)			Bra(0x3b,ra,d)
#  define BLT(ra,d)			Bra(0x3a,ra,d)
#  define BNE(ra,d)			Bra(0x3d,ra,d)
#  define BR(ra,d)			Bra(0x30,ra,d)
#  define BSR(ra,d)			Bra(0x34,ra,d)
#  define CALL_PAL(c)			Pcd(0x00,c)
#  define CMOVEQ(ra,rb,rc)		Opr(0x11,ra,rb,0x24,rc)
#  define CMOVEQi(ra,im,rc)		Opi(0x11,ra,im,0x24,rc)
#  define CMOVGE(ra,rb,rc)		Opr(0x11,ra,rb,0x46,rc)
#  define CMOVGEi(ra,im,rc)		Opi(0x11,ra,im,0x46,rc)
#  define CMOVGT(ra,rb,rc)		Opr(0x11,ra,rb,0x66,rc)
#  define CMOVGTi(ra,im,rc)		Opi(0x11,ra,im,0x66,rc)
#  define CMOVLBC(ra,rb,rc)		Opr(0x11,ra,rb,0x16,rc)
#  define CMOVLBCi(ra,im,rc)		Opi(0x11,ra,im,0x16,rc)
#  define CMOVLBS(ra,rb,rc)		Opr(0x11,ra,rb,0x14,rc)
#  define CMOVLBSi(ra,im,rc)		Opi(0x11,ra,im,0x14,rc)
#  define CMOVLE(ra,rb,rc)		Opr(0x11,ra,rb,0x64,rc)
#  define CMOVLEi(ra,im,rc)		Opi(0x11,ra,im,0x64,rc)
#  define CMOVLT(ra,rb,rc)		Opr(0x11,ra,rb,0x44,rc)
#  define CMOVLTi(ra,im,rc)		Opi(0x11,ra,im,0x44,rc)
#  define CMOVNE(ra,rb,rc)		Opr(0x11,ra,rb,0x26,rc)
#  define CMOVNEi(ra,im,rc)		Opi(0x11,ra,im,0x26,rc)
#  define CMPBGE(ra,rb,rc)		Opr(0x10,ra,rb,0x0f,rc)
#  define CMPBGEi(ra,im,rc)		Opi(0x10,ra,im,0x0f,rc)
#  define CMPEQ(ra,rb,rc)		Opr(0x10,ra,rb,0x2d,rc)
#  define CMPEQi(ra,im,rc)		Opi(0x10,ra,im,0x2d,rc)
#  define CMPLE(ra,rb,rc)		Opr(0x10,ra,rb,0x6d,rc)
#  define CMPLEi(ra,im,rc)		Opi(0x10,ra,im,0x6d,rc)
#  define CMPLT(ra,rb,rc)		Opr(0x10,ra,rb,0x4d,rc)
#  define CMPLTi(ra,im,rc)		Opi(0x10,ra,im,0x4d,rc)
#  define CMPULE(ra,rb,rc)		Opr(0x10,ra,rb,0x3d,rc)
#  define CMPULEi(ra,im,rc)		Opi(0x10,ra,im,0x3d,rc)
#  define CMPULT(ra,rb,rc)		Opr(0x10,ra,rb,0x1d,rc)
#  define CMPULTi(ra,im,rc)		Opi(0x10,ra,im,0x1d,rc)
#  define CTLZ(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x32,rc)
#  define CTPOP(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x30,rc)
#  define CTTZ(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x33,rc)
#  define ECB(rb,d)			Mem(0x18,_R31_REGNO,rb,0xe800)
#  define EQV(ra,rb,rc)			Opr(0x11,ra,rb,0x48,rc)
#  define XORNOT(ra,rb,rc)		EQV(ra,rb,rc)
#  define EQVi(ra,im,rc)		Opi(0x11,ra,im,0x48,rc)
#  define XORNOTi(ra,im,rc)		EQVi(ra,im,rc)
#  define EXCB()			Mem(0x18,0,0,0x0400)
#  define EXTBL(ra,rb,rc)		Opr(0x12,ra,rb,0x06,rc)
#  define EXTBLi(ra,im,rc)		Opi(0x12,ra,im,0x06,rc)
#  define EXTLH(ra,rb,rc)		Opr(0x12,ra,rb,0x6a,rc)
#  define EXTLHi(ra,im,rc)		Opi(0x12,ra,im,0x6a,rc)
#  define EXTLL(ra,rb,rc)		Opr(0x12,ra,rb,0x26,rc)
#  define EXTLLi(ra,im,rc)		Opi(0x12,ra,im,0x26,rc)
#  define EXTQH(ra,rb,rc)		Opr(0x12,ra,rb,0x7a,rc)
#  define EXTQHi(ra,im,rc)		Opi(0x12,ra,im,0x7a,rc)
#  define EXTQL(ra,rb,rc)		Opr(0x12,ra,rb,0x36,rc)
#  define EXTQLi(ra,im,rc)		Opi(0x12,ra,im,0x36,rc)
#  define EXTWH(ra,rb,rc)		Opr(0x12,ra,rb,0x5a,rc)
#  define EXTWHi(ra,im,rc)		Opi(0x12,ra,im,0x5a,rc)
#  define EXTWL(ra,rb,rc)		Opr(0x12,ra,rb,0x16,rc)
#  define EXTWLi(ra,im,rc)		Opi(0x12,ra,im,0x16,rc)
#  define FETCH(rb,d)			Mem(0x18,_R31_REGNO,rb,0x8000)
#  define FETCH_Mem(rb,d)		Mem(0x18,_R31_REGNO,rb,0xa000)
/* FIXME IMPLVER not disassembled */
#  define IMPLVER(rc)			Opr(0x11,_R31_REGNO,1,0x6c,rc)
#  define INSBL(ra,rb,rc)		Opr(0x12,ra,rb,0x0b,rc)
#  define INSBLi(ra,im,rc)		Opi(0x12,ra,im,0x0b,rc)
#  define INSLH(ra,rb,rc)		Opr(0x12,ra,rb,0x67,rc)
#  define INSLHi(ra,im,rc)		Opi(0x12,ra,im,0x67,rc)
#  define INSLL(ra,rb,rc)		Opr(0x12,ra,rb,0x2b,rc)
#  define INSLLi(ra,im,rc)		Opi(0x12,ra,im,0x2b,rc)
#  define INSQH(ra,rb,rc)		Opr(0x12,ra,rb,0x77,rc)
#  define INSQHi(ra,im,rc)		Opi(0x12,ra,im,0x77,rc)
#  define INSQL(ra,rb,rc)		Opr(0x12,ra,rb,0x3b,rc)
#  define INSQLi(ra,im,rc)		Opi(0x12,ra,im,0x3b,rc)
#  define INSWH(ra,rb,rc)		Opr(0x12,ra,rb,0x57,rc)
#  define INSWHi(ra,im,rc)		Opi(0x12,ra,im,0x57,rc)
#  define INSWL(ra,rb,rc)		Opr(0x12,ra,rb,0x1b,rc)
#  define INSWLi(ra,im,rc)		Opi(0x12,ra,im,0x1b,rc)
#  define JMP(ra,rb,d)			Mbr(0x1a,ra,rb,0,d)
#  define JSR(ra,rb,d)			Mbr(0x1a,ra,rb,1,d)
#  define JSR_COROUTINE(ra,rb,d)	Mbr(0x1a,ra,rb,3,d)
#  define JCR(ra,rb,rd)			JSR_COROUTINE(ra,rb,d)
#  define LDA(ra,rb,d)			Mem(0x08,ra,rb,d)
#  define LDAH(ra,rb,d)			Mem(0x09,ra,rb,d)
#  define LDBU(ra,rb,d)			Mem(0x0a,ra,rb,d)
#  define LDWU(ra,rb,d)			Mem(0x0c,ra,rb,d)
#  define LDL(ra,rb,d)			Mem(0x28,ra,rb,d)
#  define LDL_L(ra,rb,d)		Mem(0x2a,ra,rb,d)
#  define LDQ(ra,rb,d)			Mem(0x29,ra,rb,d)
#  define LDQ_L(ra,rb,d)		Mem(0x2b,ra,rb,d)
#  define LDQ_U(ra,rb,d)		Mem(0x0b,ra,rb,d)
#  define MAXSB8(ra,rb,rc)		Opr(0x1c,ra,rb,0x3e,rc)
#  define MAXSW4(ra,rb,rc)		Opr(0x1c,ra,rb,0x3f,rc)
#  define MAXSUB8(ra,rb,rc)		Opr(0x1c,ra,rb,0x3c,rc)
#  define MAXSUW4(ra,rb,rc)		Opr(0x1c,ra,rb,0x3d,rc)
#  define MB()				Mem(0x18,_R31_REGNO,_R31_REGNO,0x4000)
#  define MINSB8(ra,rb,rc)		Opr(0x1c,ra,rb,0x38,rc)
#  define MINSW4(ra,rb,rc)		Opr(0x1c,ra,rb,0x39,rc)
#  define MINSUB8(ra,rb,rc)		Opr(0x1c,ra,rb,0x3a,rc)
#  define MINSUW4(ra,rb,rc)		Opr(0x1c,ra,rb,0x3b,rc)
#  define MSKBL(ra,rb,rc)		Opr(0x12,ra,rb,0x02,rc)
#  define MSKBLi(ra,im,rc)		Opi(0x12,ra,im,0x02,rc)
#  define MSKLH(ra,rb,rc)		Opr(0x12,ra,rb,0x62,rc)
#  define MSKLHi(ra,im,rc)		Opi(0x12,ra,im,0x62,rc)
#  define MSKLL(ra,rb,rc)		Opr(0x12,ra,rb,0x22,rc)
#  define MSKLLi(ra,im,rc)		Opi(0x12,ra,im,0x22,rc)
#  define MSKQH(ra,rb,rc)		Opr(0x12,ra,rb,0x72,rc)
#  define MSKQHi(ra,im,rc)		Opi(0x12,ra,im,0x72,rc)
#  define MSKQL(ra,rb,rc)		Opr(0x12,ra,rb,0x32,rc)
#  define MSKQLi(ra,im,rc)		Opi(0x12,ra,im,0x32,rc)
#  define MSKWH(ra,rb,rc)		Opr(0x12,ra,rb,0x52,rc)
#  define MSKWHi(ra,im,rc)		Opi(0x12,ra,im,0x52,rc)
#  define MSKWL(ra,rb,rc)		Opr(0x12,ra,rb,0x12,rc)
#  define MSKWLi(ra,im,rc)		Opi(0x12,ra,im,0x12,rc)
#  define MULL(ra,rb,rc)		Opr(0x13,ra,rb,0x00,rc)
#  define MULLi(ra,im,rc)		Opi(0x13,ra,im,0x00,rc)
#  define MULL_V(ra,rb,rc)		Opr(0x13,ra,rb,0x40,rc)
#  define MULL_Vi(ra,im,rc)		Opi(0x13,ra,im,0x40,rc)
#  define MULQ(ra,rb,rc)		Opr(0x13,ra,rb,0x20,rc)
#  define MULQi(ra,im,rc)		Opi(0x13,ra,im,0x20,rc)
#  define MULQ_V(ra,rb,rc)		Opr(0x13,ra,rb,0x60,rc)
#  define MULQ_Vi(ra,im,rc)		Opi(0x13,ra,im,0x60,rc)
#  define ORNOT(ra,rb,rc)		Opr(0x11,ra,rb,0x28,rc)
#  define ORNOTi(ra,im,rc)		Opi(0x11,ra,im,0x28,rc)
#  define PERR(ra,rb,rc)		Opr(0x1c,ra,rb,0x31,rc)
#  define PKLB(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x37,rc)
#  define PKWB(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x36,rc)
/* FIXME PREFETCH* not disassembled */
#  define PREFETCH(rb,d)		Mem(0x28,_R31_REGNO,rb,d)
#  define PREFETCH_EN(rb,d)		Mem(0x29,_R31_REGNO,rb,d)
#  define PREFETCH_M(rb,d)		Mem(0x22,_R31_REGNO,rb,d)
#  define PREFETCH_MEN(rb,d)		Mem(0x23,_R31_REGNO,rb,d)
#  define RC(ra)			Mem(0x18,ra,_R31_REGNO,0xe000)
#  define RET(ra,rb,d)			Mbr(0x1a,ra,rb,2,d)
#  define RPCC(ra)			Mem(0x18,ra,_R31_REGNO,0xc000)
#  define RS(ra)			Mem(0x18,ra,_R31_REGNO,0xf000)
#  define S4ADDL(ra,rb,rc)		Opr(0x10,ra,rb,0x02,rc)
#  define S4ADDi(ra,im,rc)		Opi(0x10,ra,im,0x02,rc)
#  define S4ADDQ(ra,rb,rc)		Opr(0x10,ra,rb,0x22,rc)
#  define S4ADDQi(ra,im,rc)		Opi(0x10,ra,im,0x22,rc)
#  define S4SUBL(ra,rb,rc)		Opr(0x10,ra,rb,0x0b,rc)
#  define S4SUBLi(ra,im,rc)		Opi(0x10,ra,im,0x0b,rc)
#  define S4SUBQ(ra,rb,rc)		Opr(0x10,ra,rb,0x2b,rc)
#  define S4SUBQi(ra,im,rc)		Opi(0x10,ra,im,0x2b,rc)
#  define S8ADDL(ra,rb,rc)		Opr(0x10,ra,rb,0x12,rc)
#  define S8ADDLi(ra,im,rc)		Opi(0x10,ra,im,0x12,rc)
#  define S8ADDQ(ra,rb,rc)		Opr(0x10,ra,rb,0x32,rc)
#  define S8ADDQi(ra,im,rc)		Opi(0x10,ra,im,0x32,rc)
#  define S8SUBL(ra,rb,rc)		Opr(0x10,ra,rb,0x1b,rc)
#  define S8SUBLi(ra,im,rc)		Opi(0x10,ra,im,0x1b,rc)
#  define S8SUBQ(ra,rb,rc)		Opr(0x10,ra,rb,0x3b,rc)
#  define S8SUBQi(ra,im,rc)		Opi(0x10,ra,im,0x3b,rc)
#  define SEXTB(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x00,rc)
/* FIXME not disassembled */
#  define SEXTBi(im,rc)			Opi(0x1c,_R31_REGNO,im,0x00,rc)
#  define SEXTW(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x01,rc)
/* FIXME not disassembled */
#  define SEXTWi(im,rc)			Opi(0x1c,_R31_REGNO,im,0x01,rc)
#  define SLL(ra,rb,rc)			Opr(0x12,ra,rb,0x39,rc)
#  define SLLi(ra,im,rc)		Opi(0x12,ra,im,0x39,rc)
#  define SRA(ra,rb,rc)			Opr(0x12,ra,rb,0x3c,rc)
#  define SRAi(ra,im,rc)		Opi(0x12,ra,im,0x3c,rc)
#  define SRL(ra,rb,rc)			Opr(0x12,ra,rb,0x34,rc)
#  define SRLi(ra,im,rc)		Opi(0x12,ra,im,0x34,rc)
#  define STB(ra,rb,d)			Mem(0x0e,ra,rb,d)
#  define STL(ra,rb,d)			Mem(0x2c,ra,rb,d)
#  define STL_C(ra,rb,d)		Mem(0x2e,ra,rb,d)
#  define STQ(ra,rb,d)			Mem(0x2d,ra,rb,d)
#  define STQ_C(ra,rb,d)		Mem(0x2f,ra,rb,d)
#  define STQ_U(ra,rb,d)		Mem(0x0f,ra,rb,d)
#  define STW(ra,rb,d)			Mem(0x0d,ra,rb,d)
#  define SUBL(ra,rb,rc)		Opr(0x10,ra,rb,0x09,rc)
#  define SUBLi(ra,im,rc)		Opi(0x10,ra,im,0x09,rc)
#  define SUBL_V(ra,rb,rc)		Opr(0x10,ra,rb,0x49,rc)
#  define SUBL_Vi(ra,im,rc)		Opi(0x10,ra,im,0x49,rc)
#  define SUBQ(ra,rb,rc)		Opr(0x10,ra,rb,0x29,rc)
#  define SUBQi(ra,im,rc)		Opi(0x10,ra,im,0x29,rc)
#  define SUBQ_V(ra,rb,rc)		Opr(0x10,ra,rb,0x69,rc)
#  define SUBQ_Vi(ra,im,rc)		Opi(0x10,ra,im,0x69,rc)
#  define TRAPB()			Mem(0x18,_R31_REGNO,_R31_REGNO,0x0000)
#  define UMULH(ra,rb,rc)		Opr(0x13,ra,rb,0x30,rc)
#  define UMULHi(ra,im,rc)		Opi(0x13,ra,im,0x30,rc)
#  define UNPKBL(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x35,rc)
#  define UNPKBW(rb,rc)			Opr(0x1c,_R31_REGNO,rb,0x34,rc)
#  define WH64(ra)			Mem(0x18,ra,_R31_REGNO,0xf800)
#  define WH64EN(ra)			Mem(0x18,ra,_R31_REGNO,0xfc00)
#  define WMB()				Mem(0x18,_R31_REGNO,_R31_REGNO,0x4400)
#  define XOR(ra,rb,rc)			Opr(0x11,ra,rb,0x40,rc)
#  define XORi(ra,im,rc)		Opi(0x11,ra,im,0x40,rc)
#  define ZAP(ra,rb,rc)			Opr(0x12,ra,rb,0x30,rc)
#  define ZAPi(ra,im,rc)		Opi(0x12,ra,im,0x30,rc)
#  define ZAPNOT(ra,rb,rc)		Opr(0x12,ra,rb,0x31,rc)
#  define ZAPNOTi(ra,im,rc)		Opi(0x12,ra,im,0x31,rc)
#  define NOP()				BIS(_R31_REGNO,_R31_REGNO,_R31_REGNO)
#  define MOV(ra,rc)			BIS(ra,ra,rc)
#  define MOVi(im,rc)			BISi(_R31_REGNO,im,rc)
#  define NEGL(ra,rc)			SUBL(_R31_REGNO,ra,rc)
#  define NEGQ(ra,rc)			SUBQ(_R31_REGNO,ra,rc)
#  define NOT(ra,rc)			ORNOT(_R31_REGNO,ra,rc)
#  define nop(i0)			_nop(_jit,i0)
static void _nop(jit_state_t*,jit_int32_t);
#  define movr(r0,r1)			_movr(_jit,r0,r1)
static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
#  define movi(r0,i0)			_movi(_jit,r0,i0)
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 negr(r0,r1)			NEGQ(r1,r0)
#  define comr(r0,r1)			NOT(r1,r0)
#  define addr(r0,r1,r2)		ADDQ(r1,r2,r0)
#  define addi(r0,r1,i0)		_addi(_jit,r0,r1,i0)
static void _addi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define addcr(r0,r1,i0)		_addcr(_jit,r0,r1,i0)
static void _addcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define addci(r0,r1,i0)		_addci(_jit,r0,r1,i0)
static void _addci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define addxr(r0,r1,i0)		_addxr(_jit,r0,r1,i0)
static void _addxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define addxi(r0,r1,i0)		_addxi(_jit,r0,r1,i0)
static void _addxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define subr(r0,r1,r2)		SUBQ(r1,r2,r0)
#  define subi(r0,r1,i0)		_subi(_jit,r0,r1,i0)
static void _subi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define subcr(r0,r1,i0)		_subcr(_jit,r0,r1,i0)
static void _subcr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define subci(r0,r1,i0)		_subci(_jit,r0,r1,i0)
static void _subci(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define subxr(r0,r1,i0)		_subxr(_jit,r0,r1,i0)
static void _subxr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define subxi(r0,r1,i0)		_subxi(_jit,r0,r1,i0)
static void _subxi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define rsbi(r0, r1, i0)		_rsbi(_jit, r0, r1, i0)
static void _rsbi(jit_state_t*,jit_int32_t,jit_int32_t, jit_word_t);
#  define mulr(r0,r1,r2)		MULQ(r1,r2,r0)
#  define muli(r0,r1,i0)		_muli(_jit,r0,r1,i0)
static void _muli(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define qmulr(r0,r1,r2,r3)		_qmulr(_jit,r0,r1,r2,r3)
static void _qmulr(jit_state_t*,jit_int32_t,
		   jit_int32_t,jit_int32_t,jit_int32_t);
#  define qmuli(r0,r1,r2,i0)		_qmuli(_jit,r0,r1,r2,i0)
static void _qmuli(jit_state_t*,jit_int32_t,
		   jit_int32_t,jit_int32_t,jit_word_t);
#  define qmulr_u(r0,r1,r2,r3)		_qmulr_u(_jit,r0,r1,r2,r3)
static void _qmulr_u(jit_state_t*,jit_int32_t,
		     jit_int32_t,jit_int32_t,jit_int32_t);
#  define qmuli_u(r0,r1,r2,i0)		_qmuli_u(_jit,r0,r1,r2,i0)
static void _qmuli_u(jit_state_t*,jit_int32_t,
		     jit_int32_t,jit_int32_t,jit_word_t);
static jit_word_t __idiv(jit_word_t, jit_word_t);
#  define divr(r0,r1,r2)		_divr(_jit,r0,r1,r2)
static void _divr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define divi(r0,r1,i0)		_divi(_jit,r0,r1,i0)
static void _divi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
static jit_uword_t __udiv(jit_uword_t, jit_uword_t);
#  define divr_u(r0,r1,r2)		_divr_u(_jit,r0,r1,r2)
static void _divr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define divi_u(r0,r1,i0)		_divi_u(_jit,r0,r1,i0)
static void _divi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
static jit_word_t __irem(jit_word_t, jit_word_t);
#  define remr(r0,r1,r2)		_remr(_jit,r0,r1,r2)
static void _remr(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define remi(r0,r1,i0)		_remi(_jit,r0,r1,i0)
static void _remi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
static jit_uword_t __urem(jit_uword_t, jit_uword_t);
#  define remr_u(r0,r1,r2)		_remr_u(_jit,r0,r1,r2)
static void _remr_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define remi_u(r0,r1,i0)		_remi_u(_jit,r0,r1,i0)
static void _remi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
static jit_word_t __idivrem(jit_word_t, jit_word_t, jit_word_t*);
#  define qdivr(r0,r1,r2,r3)		_qdivr(_jit,r0,r1,r2,r3)
static void _qdivr(jit_state_t*,
		   jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
#  define qdivi(r0,r1,r2,i0)		_qdivi(_jit,r0,r1,r2,i0)
static void _qdivi(jit_state_t*,
		   jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
static jit_word_t __udivrem(jit_uword_t, jit_uword_t, jit_uword_t*);
#  define qdivr_u(r0,r1,r2,r3)		_qdivr_u(_jit,r0,r1,r2,r3)
static void _qdivr_u(jit_state_t*,
		     jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
#  define qdivi_u(r0,r1,r2,i0)		_qdivi_u(_jit,r0,r1,r2,i0)
static void _qdivi_u(jit_state_t*,
		     jit_int32_t,jit_int32_t,jit_int32_t,jit_word_t);
#  define lshr(r0,r1,r2)		SLL(r1,r2,r0)
#  define lshi(r0,r1,i0)		_lshi(_jit,r0,r1,i0)
static void _lshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define rshr(r0,r1,r2)		SRA(r1,r2,r0)
#  define rshi(r0,r1,i0)		_rshi(_jit,r0,r1,i0)
static void _rshi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define rshr_u(r0,r1,r2)		SRL(r1,r2,r0)
#  define rshi_u(r0,r1,i0)		_rshi_u(_jit,r0,r1,i0)
static void _rshi_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define andr(r0,r1,r2)		AND(r1,r2,r0)
#  define andi(r0,r1,i0)		_andi(_jit,r0,r1,i0)
static void _andi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define orr(r0,r1,r2)			OR(r1,r2,r0)
#  define ori(r0,r1,i0)			_ori(_jit,r0,r1,i0)
static void _ori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define xorr(r0,r1,r2)		XOR(r1,r2,r0)
#  define xori(r0,r1,i0)		_xori(_jit,r0,r1,i0)
static void _xori(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ltr(r0,r1,r2)			CMPLT(r1,r2,r0)
#  define lti(r0,r1,i0)			_lti(_jit,r0,r1,i0)
static void _lti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ltr_u(r0,r1,r2)		CMPULT(r1,r2,r0)
#  define lti_u(r0,r1,i0)		_lti_u(_jit,r0,r1,i0)
static void _lti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ler(r0,r1,r2)			CMPLE(r1,r2,r0)
#  define lei(r0,r1,i0)			_lei(_jit,r0,r1,i0)
static void _lei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ler_u(r0,r1,r2)		CMPULE(r1,r2,r0)
#  define lei_u(r0,r1,i0)		_lei_u(_jit,r0,r1,i0)
static void _lei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define eqr(r0,r1,r2)			CMPEQ(r1,r2,r0)
#  define eqi(r0,r1,i0)			_eqi(_jit,r0,r1,i0)
static void _eqi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ger(r0,r1,r2)			CMPLE(r2,r1,r0)
#  define gei(r0,r1,i0)			_gei(_jit,r0,r1,i0)
static void _gei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ger_u(r0,r1,r2)		CMPULE(r2,r1,r0)
#  define gei_u(r0,r1,i0)		_gei_u(_jit,r0,r1,i0)
static void _gei_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define gtr(r0,r1,r2)			CMPLT(r2,r1,r0)
#  define gti(r0,r1,i0)			_gti(_jit,r0,r1,i0)
static void _gti(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define gtr_u(r0,r1,r2)		CMPULT(r2,r1,r0)
#  define gti_u(r0,r1,i0)		_gti_u(_jit,r0,r1,i0)
static void _gti_u(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ner(r0,r1,r2)			_ner(_jit,r0,r1,r2)
static void _ner(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define nei(r0,r1,i0)			_nei(_jit,r0,r1,i0)
static void _nei(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define bltr(i0,r0,r1)		_bltr(_jit,i0,r0,r1)
static jit_word_t _bltr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define blti(i0,r0,i1)		_blti(_jit,i0,r0,i1)
static jit_word_t _blti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bltr_u(i0,r0,r1)		_bltr_u(_jit,i0,r0,r1)
static jit_word_t _bltr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define blti_u(i0,r0,i1)		_blti_u(_jit,i0,r0,i1)
static jit_word_t _blti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bler(i0,r0,r1)		_bler(_jit,i0,r0,r1)
static jit_word_t _bler(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define blei(i0,r0,i1)		_blei(_jit,i0,r0,i1)
static jit_word_t _blei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bler_u(i0,r0,r1)		_bler_u(_jit,i0,r0,r1)
static jit_word_t _bler_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define blei_u(i0,r0,i1)		_blei_u(_jit,i0,r0,i1)
static jit_word_t _blei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define beqr(i0,r0,r1)		_beqr(_jit,i0,r0,r1)
static jit_word_t _beqr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define beqi(i0,r0,i1)		_beqi(_jit,i0,r0,i1)
static jit_word_t _beqi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bger(i0,r0,r1)		_bger(_jit,i0,r0,r1)
static jit_word_t _bger(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define bgei(i0,r0,i1)			_bgei(_jit,i0,r0,i1)
static jit_word_t _bgei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bger_u(i0,r0,r1)		_bger_u(_jit,i0,r0,r1)
static jit_word_t _bger_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define bgei_u(i0,r0,i1)		_bgei_u(_jit,i0,r0,i1)
static jit_word_t _bgei_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bgtr(i0,r0,r1)		_bgtr(_jit,i0,r0,r1)
static jit_word_t _bgtr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define bgti(i0,r0,i1)		_bgti(_jit,i0,r0,i1)
static jit_word_t _bgti(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bgtr_u(i0,r0,r1)		_bgtr_u(_jit,i0,r0,r1)
static jit_word_t _bgtr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define bgti_u(i0,r0,i1)		_bgti_u(_jit,i0,r0,i1)
static jit_word_t _bgti_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define bner(i0,r0,r1)		_bner(_jit,i0,r0,r1)
static jit_word_t _bner(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define bnei(i0,r0,i1)		_bnei(_jit,i0,r0,i1)
static jit_word_t _bnei(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
#  define baddr(i0,r0,r1,cc)		_baddr(_jit,i0,r0,r1,cc)
static jit_word_t _baddr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
			 jit_bool_t);
#  define baddi(i0,r0,i1,cc)		_baddi(_jit,i0,r0,i1,cc)
static jit_word_t _baddi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
			 jit_bool_t);
#  define baddr_u(i0,r0,r1,cc)		_baddr_u(_jit,i0,r0,r1,cc)
static jit_word_t _baddr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
			   jit_bool_t);
#  define baddi_u(i0,r0,i1,cc)		_baddi_u(_jit,i0,r0,i1,cc)
static jit_word_t _baddi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
			   jit_bool_t);
#  define boaddr(i0,r0,r1)		baddr(i0,r0,r1,1)
#  define boaddi(i0,r0,i1)		baddi(i0,r0,i1,1)
#  define boaddr_u(i0,r0,r1)		baddr_u(i0,r0,r1,1)
#  define boaddi_u(i0,r0,i1)		baddi_u(i0,r0,i1,1)
#  define bxaddr(i0,r0,r1)		baddr(i0,r0,r1,0)
#  define bxaddi(i0,r0,i1)		baddi(i0,r0,i1,0)
#  define bxaddr_u(i0,r0,r1)		baddr_u(i0,r0,r1,0)
#  define bxaddi_u(i0,r0,i1)		baddi_u(i0,r0,i1,0)
#  define bsubr(i0,r0,r1,cc)		_bsubr(_jit,i0,r0,r1,cc)
static jit_word_t _bsubr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
			 jit_bool_t);
#  define bsubi(i0,r0,i1,cc)		_bsubi(_jit,i0,r0,i1,cc)
static jit_word_t _bsubi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
			 jit_bool_t);
#  define bsubr_u(i0,r0,r1,cc)		_bsubr_u(_jit,i0,r0,r1,cc)
static jit_word_t _bsubr_u(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
			   jit_bool_t);
#  define bsubi_u(i0,r0,i1,cc)		_bsubi_u(_jit,i0,r0,i1,cc)
static jit_word_t _bsubi_u(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
			   jit_bool_t);
#  define bosubr(i0,r0,r1)		bsubr(i0,r0,r1,1)
#  define bosubi(i0,r0,i1)		bsubi(i0,r0,i1,1)
#  define bosubr_u(i0,r0,r1)		bsubr_u(i0,r0,r1,1)
#  define bosubi_u(i0,r0,i1)		bsubi_u(i0,r0,i1,1)
#  define bxsubr(i0,r0,r1)		bsubr(i0,r0,r1,0)
#  define bxsubi(i0,r0,i1)		bsubi(i0,r0,i1,0)
#  define bxsubr_u(i0,r0,r1)		bsubr_u(i0,r0,r1,0)
#  define bxsubi_u(i0,r0,i1)		bsubi_u(i0,r0,i1,0)
#  define bmxr(i0,r0,r1,cc)		_bmxr(_jit,i0,r0,r1,cc)
static jit_word_t _bmxr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t,
			jit_bool_t);
#  define bmxi(i0,r0,i1,cc)		_bmxi(_jit,i0,r0,i1,cc)
static jit_word_t _bmxi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t,
			jit_bool_t);
#  define bmsr(i0,r0,r1)		bmxr(i0,r0,r1,1)
#  define bmsi(i0,r0,i1)		bmxi(i0,r0,i1,1)
#  define bmcr(i0,r0,r1)		bmxr(i0,r0,r1,0)
#  define bmci(i0,r0,i1)		bmxi(i0,r0,i1,0)
#  define ldr_c(r0,r1)			_ldr_c(_jit,r0,r1)
static void _ldr_c(jit_state_t*,jit_int32_t,jit_int32_t);
#  define ldi_c(r0,i0)			_ldi_c(_jit,r0,i0)
static void _ldi_c(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr_uc(r0,r1)			LDBU(r0,r1,0)
#  define ldi_uc(r0,i0)			_ldi_uc(_jit,r0,i0)
static void _ldi_uc(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr_s(r0,r1)			_ldr_s(_jit,r0,r1)
static void _ldr_s(jit_state_t*,jit_int32_t,jit_int32_t);
#  define ldi_s(r0,i0)			_ldi_s(_jit,r0,i0)
static void _ldi_s(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr_us(r0,r1)			LDWU(r0,r1,0)
#  define ldi_us(r0,i0)			_ldi_us(_jit,r0,i0)
static void _ldi_us(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr_i(r0,r1)			LDL(r0,r1,0)
#  define ldi_i(r0,i0)			_ldi_i(_jit,r0,i0)
static void _ldi_i(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr_ui(r0,r1)			_ldr_ui(_jit,r0,r1)
static void _ldr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
#  define ldi_ui(r0,i0)			_ldi_ui(_jit,r0,i0)
static void _ldi_ui(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldr(r0,r1)			ldr_l(r0,r1)
#  define ldr_l(r0,r1)			LDQ(r0,r1,0)
#  define ldi_l(r0,i0)			_ldi_l(_jit,r0,i0)
static void _ldi_l(jit_state_t*,jit_int32_t,jit_word_t);
#  define ldxr_c(r0,r1,r2)		_ldxr_c(_jit,r0,r1,r2)
static void _ldxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_c(r0,r1,i0)		_ldxi_c(_jit,r0,r1,i0)
static void _ldxi_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr_uc(r0,r1,r2)		_ldxr_uc(_jit,r0,r1,r2)
static void _ldxr_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_uc(r0,r1,i0)		_ldxi_uc(_jit,r0,r1,i0)
static void _ldxi_uc(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr_s(r0,r1,r2)		_ldxr_s(_jit,r0,r1,r2)
static void _ldxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_s(r0,r1,i0)		_ldxi_s(_jit,r0,r1,i0)
static void _ldxi_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr_us(r0,r1,r2)		_ldxr_us(_jit,r0,r1,r2)
static void _ldxr_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_us(r0,r1,i0)		_ldxi_us(_jit,r0,r1,i0)
static void _ldxi_us(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr_i(r0,r1,r2)		_ldxr_i(_jit,r0,r1,r2)
static void _ldxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_i(r0,r1,i0)		_ldxi_i(_jit,r0,r1,i0)
static void _ldxi_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr_ui(r0,r1,r2)		_ldxr_ui(_jit,r0,r1,r2)
static void _ldxr_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi_ui(r0,r1,i0)		_ldxi_ui(_jit,r0,r1,i0)
static void _ldxi_ui(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define ldxr(r0,r1,r2)		ldxr_l(r0,r1,r2)
#  define ldxr_l(r0,r1,r2)		_ldxr_l(_jit,r0,r1,r2)
static void _ldxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define ldxi(r0,r1,i0)		ldxi_l(r0,r1,i0)
#  define ldxi_l(r0,r1,i0)		_ldxi_l(_jit,r0,r1,i0)
static void _ldxi_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
#  define str_c(r0,r1)			STB(r1,r0,0)
#  define sti_c(i0,r0)			_sti_c(_jit,i0,r0)
static void _sti_c(jit_state_t*,jit_word_t,jit_int32_t);
#  define str_s(r0,r1)			STW(r1,r0,0)
#  define sti_s(i0,r0)			_sti_s(_jit,i0,r0)
static void _sti_s(jit_state_t*,jit_word_t,jit_int32_t);
#  define str_i(r0,r1)			STL(r1,r0,0)
#  define sti_i(i0,r0)			_sti_i(_jit,i0,r0)
static void _sti_i(jit_state_t*,jit_word_t,jit_int32_t);
#  define str(r0,r1)			str_l(r0,r1)
#  define str_l(r0,r1)			STQ(r1,r0,0)
#  define sti_l(i0,r0)			_sti_l(_jit,i0,r0)
static void _sti_l(jit_state_t*,jit_word_t,jit_int32_t);
#  define stxr_c(r0,r1,r2)		_stxr_c(_jit,r0,r1,r2)
static void _stxr_c(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define stxi_c(i0,r0,r1)		_stxi_c(_jit,i0,r0,r1)
static void _stxi_c(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define stxr_s(r0,r1,r2)		_stxr_s(_jit,r0,r1,r2)
static void _stxr_s(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define stxi_s(i0,r0,r1)		_stxi_s(_jit,i0,r0,r1)
static void _stxi_s(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define stxr_i(r0,r1,r2)		_stxr_i(_jit,r0,r1,r2)
static void _stxr_i(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define stxi_i(i0,r0,r1)		_stxi_i(_jit,i0,r0,r1)
static void _stxi_i(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define stxr_l(r0,r1,r2)		_stxr_l(_jit,r0,r1,r2)
static void _stxr_l(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t);
#  define stxi(i0,r0,r1)		stxi_l(i0,r0,r1)
#  define stxi_l(i0,r0,r1)		_stxi_l(_jit,i0,r0,r1)
static void _stxi_l(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
#  define extr_c(r0,r1)			_extr_c(_jit,r0,r1)
static void _extr_c(jit_state_t*,jit_int32_t,jit_int32_t);
#  define extr_uc(r0,r1)		_extr_uc(_jit,r0,r1)
static void _extr_uc(jit_state_t*,jit_int32_t,jit_int32_t);
#  define extr_s(r0,r1)			_extr_s(_jit,r0,r1)
static void _extr_s(jit_state_t*,jit_int32_t,jit_int32_t);
#  define extr_us(r0,r1)		_extr_us(_jit,r0,r1)
static void _extr_us(jit_state_t*,jit_int32_t,jit_int32_t);
#  define extr_i(r0,r1)			_extr_i(_jit,r0,r1)
static void _extr_i(jit_state_t*,jit_int32_t,jit_int32_t);
#  define extr_ui(r0,r1)		_extr_ui(_jit,r0,r1)
static void _extr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
#  if __BYTE_ORDER == __LITTLE_ENDIAN
#    define htonr_us(r0,r1)		_htonr_us(_jit,r0,r1)
static void _htonr_us(jit_state_t*,jit_int32_t,jit_int32_t);
#    define htonr_ui(r0,r1)		_htonr_ui(_jit,r0,r1)
static void _htonr_ui(jit_state_t*,jit_int32_t,jit_int32_t);
#    define htonr_ul(r0,r1)		_htonr_ul(_jit,r0,r1)
static void _htonr_ul(jit_state_t*,jit_int32_t,jit_int32_t);
#  else
#    define htonr_us(r0,r1)		extr_us(r0,r1)
#    define htonr_ui(r0,r1)		extr_ui(r0,r1)
#    define htonr_ul(r0,r1)		movr(r0,r1)
#  endif
#  define jmpr(r0)			JMP(_R31_REGNO,r0,0)
#  define jmpi(i0)			_jmpi(_jit,i0)
static void _jmpi(jit_state_t*, jit_word_t);
#  define jmpi_p(i0)			_jmpi_p(_jit,i0)
static jit_word_t _jmpi_p(jit_state_t*, jit_word_t);
#define callr(r0)			_callr(_jit,r0)
static void _callr(jit_state_t*, jit_int32_t);
#  define calli(i0)			_calli(_jit,i0)
static void _calli(jit_state_t*, jit_word_t);
#  define calli_p(i0)			_calli_p(_jit,i0)
static jit_word_t _calli_p(jit_state_t*, jit_word_t);
#  define prolog(node)			_prolog(_jit,node)
static void _prolog(jit_state_t*,jit_node_t*);
#  define epilog(node)			_epilog(_jit,node)
static void _epilog(jit_state_t*,jit_node_t*);
#  define vastart(r0)			_vastart(_jit, r0)
static void _vastart(jit_state_t*, jit_int32_t);
#  define vaarg(r0, r1)			_vaarg(_jit, r0, r1)
static void _vaarg(jit_state_t*, jit_int32_t, jit_int32_t);
#  define patch_at(jump,label)		_patch_at(_jit,jump,label)
static void _patch_at(jit_state_t*,jit_word_t,jit_word_t);
#endif

#if CODE
static void
_Pcd(jit_state_t *_jit, int o, unsigned int n)
{
    assert(_u6_p(o));
    assert(_u26_p(n));
    ii((o<<26)|_u26(n));
}

static void
_Bra(jit_state_t *_jit, int o, int ra, int d)
{
    assert(_u6_p(o));
    assert(_u5_p(ra));
    assert(_s21_p(d));
    ii((o<<26)|(ra<<21)|_u21(d));
}

static void
_Mem(jit_state_t *_jit, int o, int ra, int rb, unsigned int d)
{
    assert(_u6_p(o));
    assert(_u5_p(ra));
    assert(_u5_p(rb));
    assert(_u16_p(d));
    ii((o<<26)|(ra<<21)|(rb<<16)|_u16(d));
}

static void
_Mbr(jit_state_t *_jit, int o, int ra, int rb, int h, int d)
{
    assert(_u6_p(o));
    assert(_u5_p(ra));
    assert(_u5_p(rb));
    assert(_u2_p(h));
    assert(_s14_p(d));
    ii((o<<26)|(ra<<21)|(rb<<16)|(h<<14)|_u14(d));
}

static void
_Opr(jit_state_t *_jit, int o, int ra, int rb, unsigned int f, int rc)
{
    assert(_u6_p(o));
    assert(_u5_p(ra));
    assert(_u5_p(rb));
    assert(_u5_p(rc));
    assert(_u11_p(f));
    ii((o<<26)|(ra<<21)|(rb<<16)|(_u11(f)<<5)|rc);
}

static void
_Opi(jit_state_t *_jit, int o, int ra, unsigned int i, unsigned int f, int rc)
{
    assert(_u6_p(o));
    assert(_u5_p(ra));
    assert(_u8_p(i));
    assert(_u5_p(rc));
    assert(_u7_p(f));
    ii((o<<26)|(ra<<21)|(_u8(i)<<13)|(1<<12)|(_u7(f)<<5)|rc);
}

static void
_nop(jit_state_t *_jit, jit_int32_t i0)
{
    for (; i0 > 0; i0 -= 4)
	NOP();
    assert(i0 == 0);
}

static void
_movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    if (r0 != r1)
	MOV(r1, r0);
}

static void
_movi(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    jit_int16_t		s0, s1, s2, s3;
    s0 = i0;
    s1 = i0 >> 16;
    s2 = i0 >> 32;
    s3 = i0 >> 48;
    if (s0 < 0)
	++s1;
    if (s2 < 0)
	++s3;
    if (_u8_p(i0))
	MOVi(_u8(i0), r0);
    else if (_s16_p(i0))
	LDA(r0, _R31_REGNO, _u16(s0));
    else if (_s32_p(i0)) {
	LDA(r0, _R31_REGNO, _u16(s0));
	LDAH(r0, r0, _u16(s1));
    }
    else if (_u32_p(i0)) {
	LDA(r0, _R31_REGNO, _u16(s0));
	if (s1)
	    LDAH(r0, r0, _u16(s1));
	lshi(r0, r0, 32);
	rshi_u(r0, r0, 32);
    }
    else if (_u32(i0) == 0) {
	LDA(r0, _R31_REGNO, _u16(s2));
	if (s3)
	    LDAH(r0, r0, _u16(s3));
	lshi(r0, r0, 32);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	LDA(r0, _R31_REGNO, _u16(s0));
	LDA(rn(reg), _R31_REGNO, _u16(s2));
	if (s1)
	    LDAH(r0, r0, _u16(s1));
	if (s3)
	    LDAH(rn(reg), rn(reg), _u16(s3));
	lshi(r0, r0, 32);
	rshi_u(r0, r0, 32);
	lshi(rn(reg), rn(reg), 32);
	orr(r0, r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static jit_word_t
_movi_p(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_word_t		w;
    jit_int32_t		reg;
    jit_int16_t		s0, s1, s2, s3;
    w = _jit->pc.w;
    reg = jit_get_reg(jit_class_gpr);
    s0 = i0;
    s1 = i0 >> 16;
    s2 = i0 >> 32;
    s3 = i0 >> 48;
    if (s0 < 0)
	++s1;
    if (s2 < 0)
	++s3;
    LDA(r0, _R31_REGNO, _u16(s0));
    LDA(rn(reg), _R31_REGNO, _u16(s2));
    LDAH(r0, r0, _u16(s1));
    LDAH(rn(reg), rn(reg), _u16(s3));
    lshi(r0, r0, 32);
    rshi_u(r0, r0, 32);
    lshi(rn(reg), rn(reg), 32);
    orr(r0, r0, rn(reg));
    jit_unget_reg(reg);
    return (w);
}

static void
_addi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	ADDQi(r1, i0, r0);
    else if (_s16_p(i0))
	LDA(r0, r1, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	addr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_addcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    if (jit_carry == _NOREG)
	jit_carry = jit_get_reg(jit_class_gpr);
    if (r0 == r1) {
	reg = jit_get_reg(jit_class_gpr);
	addr(rn(reg), r1, r2);
	ltr_u(rn(jit_carry), rn(reg), r1);
	movr(r0, rn(reg));
	jit_unget_reg(reg);
    }
    else {
	addr(r0, r1, r2);
	ltr_u(rn(jit_carry), r0, r1);
    }
}

static void
_addci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (jit_carry == _NOREG)
	jit_carry = jit_get_reg(jit_class_gpr);
    if (r0 == r1) {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ltr_u(rn(jit_carry), rn(reg), r1);
	movr(r0, rn(reg));
	jit_unget_reg(reg);
    }
    else {
	addi(r0, r1, i0);
	ltr_u(rn(jit_carry), r0, r1);
    }
}

static void
_addxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    assert(jit_carry != _NOREG);
    reg = jit_get_reg(jit_class_gpr);
    movr(rn(reg), rn(jit_carry));
    addcr(r0, r1, r2);
    addcr(r0, r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_addxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    assert(jit_carry != _NOREG);
    reg = jit_get_reg(jit_class_gpr);
    movr(rn(reg), rn(jit_carry));
    addci(r0, r1, i0);
    addcr(r0, r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_subi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	SUBQi(r1, i0, r0);
    else if (_s16_p(-i0))
	LDA(r0, r1, _u16(-i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	subr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_subcr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    if (jit_carry == _NOREG)
	jit_carry = jit_get_reg(jit_class_gpr);
    if (r0 == r1) {
	reg = jit_get_reg(jit_class_gpr);
	subr(rn(reg), r1, r2);
	ltr_u(rn(jit_carry), r1, rn(reg));
	movr(r0, rn(reg));
	jit_unget_reg(reg);
    }
    else {
	subr(r0, r1, r2);
	ltr_u(rn(jit_carry), r1, r0);
    }
}

static void
_subci(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (jit_carry == _NOREG)
	jit_carry = jit_get_reg(jit_class_gpr);
    if (r0 == r1) {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, -i0);
	ltr_u(rn(jit_carry), r1, rn(reg));
	movr(r0, rn(reg));
	jit_unget_reg(reg);
    }
    else {
	addi(r0, r1, -i0);
	ltr_u(rn(jit_carry), r1, r0);
    }
}

static void
_subxr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    assert(jit_carry != _NOREG);
    reg = jit_get_reg(jit_class_gpr);
    movr(rn(reg), rn(jit_carry));
    subcr(r0, r1, r2);
    subcr(r0, r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_subxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    assert(jit_carry != _NOREG);
    reg = jit_get_reg(jit_class_gpr);
    movr(rn(reg), rn(jit_carry));
    subci(r0, r1, i0);
    subcr(r0, r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_rsbi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    subi(r0, r1, i0);
    negr(r0, r0);
}

static void
_muli(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	MULQi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	mulr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_qmulr(jit_state_t *_jit, jit_int32_t r0,
       jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
{
    jit_int32_t		reg;
    /* The only invalid condition is r0 == r1 */
    jit_int32_t		t2, t3, s2, s3;
    if (r2 == r0 || r2 == r1) {
	s2 = jit_get_reg(jit_class_gpr);
	t2 = rn(s2);
	movr(t2, r2);
    }
    else
	t2 = r2;
    if (r3 == r0 || r3 == r1) {
	s3 = jit_get_reg(jit_class_gpr);
	t3 = rn(s3);
	movr(t3, r3);
    }
    else
	t3 = r3;
    qmulr_u(r0, r1, r2, r3);
    reg = jit_get_reg(jit_class_gpr);
    /**/
    rshi(rn(reg), t2, 63);
    mulr(rn(reg), rn(reg), t3);
    addr(r1, r1, rn(reg));
    /**/
    rshi(rn(reg), t3, 63);
    mulr(rn(reg), rn(reg), t2);
    addr(r1, r1, rn(reg));
    jit_unget_reg(reg);
    if (t2 != r2)
	jit_unget_reg(s2);
    if (t3 != r3)
	jit_unget_reg(s3);
}

static void
_qmuli(jit_state_t *_jit, jit_int32_t r0,
       jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    movi(rn(reg), i0);
    qmulr(r0, r1, r2, rn(reg));
    jit_unget_reg(reg);
}

static void
_qmulr_u(jit_state_t *_jit, jit_int32_t r0,
	 jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
{
    jit_int32_t		reg;
    if (r0 == r2 || r0 == r3) {
	reg = jit_get_reg(jit_class_gpr);
	mulr(rn(reg), r2, r3);
    }
    else
	mulr(r0, r2, r3);
    UMULH(r2, r3, r1);
    if (r0 == r2 || r0 == r3) {
	movr(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_qmuli_u(jit_state_t *_jit, jit_int32_t r0,
	 jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0)) {
	if (r0 == r2) {
	    reg = jit_get_reg(jit_class_gpr);
	    muli(rn(reg), r2, i0);
	}
	else
	    muli(r0, r2, i0);
	UMULHi(r2, i0, r1);
	if (r0 == r2) {
	    movr(r0, rn(reg));
	    jit_unget_reg(reg);
	}
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	qmulr_u(r0, r1, r2, rn(reg));
	jit_unget_reg(reg);
    }
}

static jit_word_t
__idiv(jit_word_t u, jit_word_t v)
{
    return (u / v);
}

static void
_divr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    movr(_A0_REGNO, r1);
    movr(_A1_REGNO, r2);
    calli((jit_word_t)__idiv);
    movr(r0, _V0_REGNO);
}

static void
_divi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    movr(_A0_REGNO, r1);
    movi(_A1_REGNO, i0);
    calli((jit_word_t)__idiv);
    movr(r0, _V0_REGNO);
}

static jit_uword_t
__udiv(jit_uword_t u, jit_uword_t v)
{
    return (u / v);
}

static void
_divr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    movr(_A0_REGNO, r1);
    movr(_A1_REGNO, r2);
    calli((jit_word_t)__udiv);
    movr(r0, _V0_REGNO);
}

static void
_divi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    movr(_A0_REGNO, r1);
    movi(_A1_REGNO, i0);
    calli((jit_word_t)__udiv);
    movr(r0, _V0_REGNO);
}

static jit_word_t
__irem(jit_word_t u, jit_word_t v)
{
    return (u % v);
}

static void
_remr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    movr(_A0_REGNO, r1);
    movr(_A1_REGNO, r2);
    calli((jit_word_t)__irem);
    movr(r0, _V0_REGNO);
}

static void
_remi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    movr(_A0_REGNO, r1);
    movi(_A1_REGNO, i0);
    calli((jit_word_t)__irem);
    movr(r0, _V0_REGNO);
}

static jit_uword_t
__urem(jit_uword_t u, jit_uword_t v)
{
    return (u % v);
}

static void
_remr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    movr(_A0_REGNO, r1);
    movr(_A1_REGNO, r2);
    calli((jit_word_t)__urem);
    movr(r0, _V0_REGNO);
}

static void
_remi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    movr(_A0_REGNO, r1);
    movi(_A1_REGNO, i0);
    calli((jit_word_t)__urem);
    movr(r0, _V0_REGNO);
}

static jit_word_t
__idivrem(jit_word_t u, jit_word_t v, jit_word_t *rem)
{
    *rem = u % v;
    return (u / v);
}

static void
_qdivr(jit_state_t *_jit,
       jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
{
    movr(_A0_REGNO, r2);
    movr(_A1_REGNO, r3);
    subi(_A2_REGNO, _FP_REGNO, 8);
    calli((jit_word_t)__idivrem);
    movr(r0, _V0_REGNO);
    ldxi(r1, _FP_REGNO, -8);
}

static void
_qdivi(jit_state_t *_jit,
       jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
{
    movr(_A0_REGNO, r2);
    movi(_A1_REGNO, i0);
    subi(_A2_REGNO, _FP_REGNO, 8);
    calli((jit_word_t)__idivrem);
    movr(r0, _V0_REGNO);
    ldxi(r1, _FP_REGNO, -8);
}

static jit_word_t
__udivrem(jit_uword_t u, jit_uword_t v, jit_uword_t *rem)
{
    *rem = u % v;
    return (u / v);
}

static void
_qdivr_u(jit_state_t *_jit,
	 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_int32_t r3)
{
    movr(_A0_REGNO, r2);
    movr(_A1_REGNO, r3);
    subi(_A2_REGNO, _FP_REGNO, 8);
    calli((jit_word_t)__udivrem);
    movr(r0, _V0_REGNO);
    ldxi(r1, _FP_REGNO, -8);
}

static void
_qdivi_u(jit_state_t *_jit,
	 jit_int32_t r0, jit_int32_t r1, jit_int32_t r2, jit_word_t i0)
{
    movr(_A0_REGNO, r2);
    movi(_A1_REGNO, i0);
    subi(_A2_REGNO, _FP_REGNO, 8);
    calli((jit_word_t)__udivrem);
    movr(r0, _V0_REGNO);
    ldxi(r1, _FP_REGNO, -8);
}

static void
_lshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    assert(i0 >= 0 && i0 < 64);
    SLLi(r1, i0, r0);
}

static void
_rshi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    assert(i0 >= 0 && i0 < 64);
    SRAi(r1, i0, r0);
}

static void
_rshi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    assert(i0 >= 0 && i0 < 64);
    SRLi(r1, i0, r0);
}

static void
_andi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	ANDi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	andr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	ORi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	orr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_xori(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	XORi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	xorr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_lti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	CMPLTi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ltr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_lti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	CMPULTi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ltr_u(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	CMPLEi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ler(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    jit_word_t		ni0;
    ni0 = -i0;
    if (_u8_p(i0))
	CMPULEi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ler_u(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0))
	CMPEQi(r1, i0, r0);
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	eqr(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_gei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    movi(rn(reg), i0);
    ger(r0, r1, rn(reg));
    jit_unget_reg(reg);
}

static void
_gei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    movi(rn(reg), i0);
    ger_u(r0, r1, rn(reg));
    jit_unget_reg(reg);
}

static void
_gti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    movi(rn(reg), i0);
    gtr(r0, r1, rn(reg));
    jit_unget_reg(reg);
}

static void
_gti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    movi(rn(reg), i0);
    gtr_u(r0, r1, rn(reg));
    jit_unget_reg(reg);
}

static void
_ner(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    CMPEQ(r1, r2, r0);
    CMPEQi(r0, 0, r0);
}

static void
_nei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_u8_p(i0)) {
	CMPEQi(r1, i0, r0);
	CMPEQi(r0, 0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ner(r0, r1, rn(reg));
	jit_unget_reg(reg);
    }
}

static jit_word_t
_bltr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ltr(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_blti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BLT(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	lti(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bltr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ltr_u(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_blti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    /* FIXME cannot optimize zero because need to return a patcheable address */
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    lti_u(rn(reg), r0, i1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bler(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ler(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_blei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BLE(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	lei(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bler_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ler_u(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_blei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BEQ(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	lei_u(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
     }
    return (w);
}

static jit_word_t
_beqr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    eqr(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_beqi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BEQ(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	eqi(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bger(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ger(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bgei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BGE(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	gei(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bger_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    ger_u(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bgei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    /* always true if i1 == 0 */
    if (i0 == 0) {
	w = _jit->pc.w;
	BR(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	gei_u(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bgtr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    gtr(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bgti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BGT(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	gti(rn(reg), r0, i1);
	w = _jit->pc.w;
	BNE(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_bgtr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    gtr_u(rn(reg), r0, r1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bgti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    gti_u(rn(reg), r0, i1);
    w = _jit->pc.w;
    BNE(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bner(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    eqr(rn(reg), r0, r1);
    w = _jit->pc.w;
    BEQ(rn(reg), ((i0 - w) >> 2) - 1);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bnei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
{
    jit_word_t		w;
    jit_int32_t		reg;
    if (i1 == 0) {
	w = _jit->pc.w;
	BNE(r0, ((i0 - w) >> 2) - 1);
    }
    else {
	reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
	eqi(rn(reg), r0, i1);
	w = _jit->pc.w;
	BEQ(rn(reg), ((i0 - w) >> 2) - 1);
	jit_unget_reg(reg);
    }
    return (w);
}

static jit_word_t
_baddr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
       jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    jit_int32_t		t2;
    jit_int32_t		t3;
    /* t0 = r0 + r1;	overflow = r1 < 0 ? r0 < t0 : t0 < r0 */
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr);
    t2 = jit_get_reg(jit_class_gpr);
    t3 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    addr(rn(t0), r0, r1);		/* t0 = r0 + r1 */
    ltr(rn(t1), r1, _R31_REGNO);	/* t1 = r1 < 0 */
    ltr(rn(t2), r0, rn(t0));		/* t2 = r0 < t0 */
    ltr(rn(t3), rn(t0), r0);		/* t3 = t0 < r0 */
    movr(r0, rn(t0));			/* r0 += r1 */
    CMOVNE(rn(t1), rn(t2), rn(t3));	/* if (t1 == 0) t3 = t2; */
    jit_unget_reg(t2);
    jit_unget_reg(t1);
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t3), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t3), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t3);
    return (w);
}

static jit_word_t
_baddi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
       jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    movi(rn(reg), i1);
    w = baddr(i0, r0, rn(reg), carry);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_baddr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
	 jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    addr(rn(t0), r0, r1);
    ltr_u(rn(t1), rn(t0), r0);
    movr(r0, rn(t0));
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t1), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t1), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t1);
    return (w);
}

static jit_word_t
_baddi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
	 jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    addi(rn(t0), r0, i1);
    ltr_u(rn(t1), rn(t0), r0);
    movr(r0, rn(t0));
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t1), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t1), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t1);
    return (w);
}

static jit_word_t
_bsubr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
       jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    jit_int32_t		t2;
    jit_int32_t		t3;
    /* t0 = r0 - r1;	overflow = 0 < r1 ? r0 < t0 : t0 < r0 */
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr);
    t2 = jit_get_reg(jit_class_gpr);
    t3 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    subr(rn(t0), r0, r1);		/* r0 = r0 - r1 */
    ltr(rn(t1), _R31_REGNO, r1);	/* t1 = 0 < r1 */
    ltr(rn(t2), r0, rn(t0));		/* t2 = r0 < t0 */
    ltr(rn(t3), rn(t0), r0);		/* t3 = t0 < r0 */
    movr(r0, rn(t0));			/* r0 -= r1 */
    CMOVNE(rn(t1), rn(t2), rn(t3));	/* if (t1 == 0) t3 = t2; */
    jit_unget_reg(t2);
    jit_unget_reg(t1);
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t3), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t3), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t3);
    return (w);
}

static jit_word_t
_bsubi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
       jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    movi(rn(reg), i1);
    w = bsubr(i0, r0, rn(reg), carry);
    jit_unget_reg(reg);
    return (w);
}

static jit_word_t
_bsubr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
	 jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    subr(rn(t0), r0, r1);
    ltr_u(rn(t1), r0, rn(t0));
    movr(r0, rn(t0));
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t1), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t1), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t1);
    return (w);
}

static jit_word_t
_bsubi_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
	 jit_bool_t carry)
{
    jit_word_t		w;
    jit_int32_t		t0;
    jit_int32_t		t1;
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    subi(rn(t0), r0, i1);
    ltr_u(rn(t1), r0, rn(t0));
    movr(r0, rn(t0));
    jit_unget_reg(t0);
    w = _jit->pc.w;
    if (carry)
	BNE(rn(t1), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t1), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t1);
    return (w);
}

static jit_word_t
_bmxr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1,
      jit_bool_t set)
{
    jit_word_t		w;
    jit_int32_t		t0;
    t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    andr(rn(t0), r0, r1);
    w = _jit->pc.w;
    if (set)
	BNE(rn(t0), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t0), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t0);
    return (w);
}

static jit_word_t
_bmxi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1,
      jit_bool_t set)
{
    jit_word_t		w;
    jit_int32_t		t0;
    t0 = jit_get_reg(jit_class_gpr|jit_class_nospill);
    andi(rn(t0), r0, i1);
    w = _jit->pc.w;
    if (set)
	BNE(rn(t0), ((i0 - w) >> 2) - 1);
    else
	BEQ(rn(t0), ((i0 - w) >> 2) - 1);
    jit_unget_reg(t0);
    return (w);
}

static void
_ldr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    ldr_uc(r0, r1);
    extr_c(r0, r0);
}

static void
_ldi_c(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDBU(r0, _R31_REGNO, _u16(i0));
	extr_c(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_c(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldi_uc(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDBU(r0, _R31_REGNO, _u16(i0));
    else  {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_uc(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    ldr_us(r0, r1);
    extr_s(r0, r0);
}

static void
_ldi_s(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDWU(r0, _R31_REGNO, _u16(i0));
	extr_s(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_s(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldi_us(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDWU(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_us(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldi_i(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDL(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_i(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    ldr_i(r0, r1);
    extr_ui(r0, r0);
}

static void
_ldi_ui(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDL(r0, _R31_REGNO, _u16(i0));
	extr_ui(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_ui(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldi_l(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDQ(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	ldr_l(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_c(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDBU(r0, r1, _u16(i0));
	extr_c(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_c(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_uc(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDBU(r0, r1, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_uc(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_s(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDWU(r0, r1, _u16(i0));
	extr_s(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_s(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_us(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDWU(r0, r1, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_us(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_i(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDL(r0, r1, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_i(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_ui(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0)) {
	LDL(r0, r1, _u16(i0));
	extr_ui(r0, r0);
    }
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_ui(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_ldxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r1, r2);
    ldr_l(r0, rn(reg));
    jit_unget_reg(reg);
}

static void
_ldxi_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	LDQ(r0, r1, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r1, i0);
	ldr_l(r0, rn(reg));
	jit_unget_reg(reg);
    }
}

static void
_sti_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STB(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	str_c(rn(reg), r0);
	jit_unget_reg(reg);
    }
}

static void
_sti_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STW(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	str_s(rn(reg), r0);
	jit_unget_reg(reg);
    }
}

static void
_sti_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STL(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	str_i(rn(reg), r0);
	jit_unget_reg(reg);
    }
}

static void
_sti_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STQ(r0, _R31_REGNO, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), i0);
	str_l(rn(reg), r0);
	jit_unget_reg(reg);
    }
}

static void
_stxr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r0, r1);
    str_c(rn(reg), r2);
    jit_unget_reg(reg);
}

static void
_stxi_c(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STB(r1, r0, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r0, i0);
	str_c(rn(reg), r1);
	jit_unget_reg(reg);
    }
}

static void
_stxr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r0, r1);
    str_s(rn(reg), r2);
    jit_unget_reg(reg);
}

static void
_stxi_s(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STW(r1, r0, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r0, i0);
	str_s(rn(reg), r1);
	jit_unget_reg(reg);
    }
}

static void
_stxr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r0, r1);
    str_i(rn(reg), r2);
    jit_unget_reg(reg);
}

static void
_stxi_i(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STL(r1, r0, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r0, i0);
	str_i(rn(reg), r1);
	jit_unget_reg(reg);
    }
}

static void
_stxr_l(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr);
    addr(rn(reg), r0, r1);
    str_l(rn(reg), r2);
    jit_unget_reg(reg);
}

static void
_stxi_l(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		reg;
    if (_s16_p(i0))
	STQ(r1, r0, _u16(i0));
    else {
	reg = jit_get_reg(jit_class_gpr);
	addi(rn(reg), r0, i0);
	str_l(rn(reg), r1);
	jit_unget_reg(reg);
    }
}

static void
_extr_c(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 56);
    rshi(r0, r0, 56);
}

static void
_extr_uc(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 56);
    rshi_u(r0, r0, 56);
}

static void
_extr_s(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 48);
    rshi(r0, r0, 48);
}

static void
_extr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 48);
    rshi_u(r0, r0, 48);
}

static void
_extr_i(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 32);
    rshi(r0, r0, 32);
}

static void
_extr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    lshi(r0, r1, 32);
    rshi_u(r0, r0, 32);
}

static void
_htonr_us(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		t0;
    t0 = jit_get_reg(jit_class_gpr);
    EXTBLi(r1, 0, rn(t0));
    EXTBLi(r1, 1, r0);
    SLLi(rn(t0), 8, rn(t0));
    OR(r0, rn(t0), r0);
    jit_unget_reg(t0);
}

static void
_htonr_ui(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		t0;
    jit_int32_t		t1;
    jit_int32_t		t2;
    jit_int32_t		t3;
    t0 = jit_get_reg(jit_class_gpr);
    t1 = jit_get_reg(jit_class_gpr);
    t2 = jit_get_reg(jit_class_gpr);
    t3 = jit_get_reg(jit_class_gpr);
    EXTBLi(r1, 3, rn(t0));
    INSBLi(r1, 3, rn(t1));
    SLLi(r1, 8, rn(t2));
    ZAPNOTi(rn(t2), 4, rn(t2));
    SRLi(r1, 8, rn(t3));
    OR(rn(t0), rn(t1), r0);
    OR(rn(t2), r0, r0);
    ZAPNOTi(rn(t3), 2, rn(t3));
    OR(rn(t3), r0, r0);
    jit_unget_reg(t3);
    jit_unget_reg(t2);
    jit_unget_reg(t1);
    jit_unget_reg(t0);
}

static void
_htonr_ul(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		t0;
    jit_int32_t		t1;
    jit_int32_t		t2;
    assert(_jitc->function != NULL);
    t0 = jit_get_reg(jit_class_fpr);
    t1 = jit_get_reg(jit_class_gpr);
    t2 = jit_get_reg(jit_class_gpr);
    stxi(-8, _FP_REGNO, r1);			/* r1 = ABCD EFGH */
    LDG(rn(t0), _FP_REGNO, _u16(-8));		/* t0 = GHEF CDAB */
    STT(rn(t0), _FP_REGNO, _u16(-8));
    ldxi(rn(t1), _FP_REGNO, -8);		/* t1 = GHEF CDAB */
    lshi(rn(t2), rn(t1), 8);			/* t2 = HEFC DAB. */
    rshi_u(rn(t1), rn(t1), 8);			/* t1 = .GHE FCDA */
    ZAPi(rn(t2), 0x55, rn(t2));			/* t2 = H.F. D.B. */
    ZAPi(rn(t1), 0xaa, rn(t1));			/* t1 = .G.E .C.A */
    orr(r0, rn(t1), rn(t2));			/* r0 = HGFE DCBA */
    jit_unget_reg(t2);
    jit_unget_reg(t1);
    jit_unget_reg(t0);
}

static void
_jmpi(jit_state_t *_jit, jit_word_t i0)
{
    jit_word_t		w;
    jit_word_t		d;
    w = _jit->pc.w;
    d = ((i0 - w) >> 2) - 1;
    if (_s21_p(d))
	BR(_R31_REGNO, d);
    else
	(void)jmpi_p(i0);
}

static jit_word_t
_jmpi_p(jit_state_t *_jit, jit_word_t i0)
{
    jit_word_t		w;
    jit_int32_t		reg;
    reg = jit_get_reg(jit_class_gpr|jit_class_nospill);
    w = movi_p(rn(reg), i0);
    jmpr(rn(reg));
    jit_unget_reg(reg);
    return (w);
}

static void
_callr(jit_state_t *_jit, jit_int32_t r0)
{
    if (r0 != _PV_REGNO)
	MOV(r0, _PV_REGNO);
    JSR(_RA_REGNO, _PV_REGNO, 0);
}

static void
_calli(jit_state_t *_jit, jit_word_t i0)
{
    /* FIXME use a small buffer to load constants - using gp */
#if 0
    jit_word_t		w;
    jit_word_t		d;
    w = _jit->pc.w;
    d = ((i0 - w) >> 2) - 1;
    if (_s21_p(d))
	BSR(_RA_REGNO, d);
    else
	(void)calli_p(i0);
#else
    movi(_PV_REGNO, i0);
    callr(_PV_REGNO);
#endif
}

static jit_word_t
_calli_p(jit_state_t *_jit, jit_word_t i0)
{
    jit_word_t		w;
    w = movi_p(_PV_REGNO, i0);
    callr(_PV_REGNO);
    return (w);
}

static void
_prolog(jit_state_t *_jit, jit_node_t *node)
{
    jit_int32_t		reg;
    if (_jitc->function->define_frame || _jitc->function->assume_frame) {
	jit_int32_t	frame = -_jitc->function->frame;
	assert(_jitc->function->self.aoff >= frame);
	if (_jitc->function->assume_frame)
	    return;
	_jitc->function->self.aoff = frame;
    }
    if (_jitc->function->allocar)
	_jitc->function->self.aoff &= -8;
    _jitc->function->stack = ((_jitc->function->self.alen -
			       _jitc->function->self.aoff) + 7) & -8;
    /* ldgp gp, 0(pv) */
    LDAH(_PV_REGNO, _GP_REGNO, 0);
    LDA(_GP_REGNO, _GP_REGNO, 0);
    /* callee save registers */
    subi(_SP_REGNO, _SP_REGNO, stack_framesize);
    stxi(0, _SP_REGNO, _RA_REGNO);
    stxi(8, _SP_REGNO, _FP_REGNO);
#  define SPILL(N, O)							\
    if (jit_regset_tstbit(&_jitc->function->regset, N))			\
	stxi(O, _SP_REGNO, N##_REGNO)
#  define SPILLD(N, O)							\
    if (jit_regset_tstbit(&_jitc->function->regset, N))			\
	stxi_d(O, _SP_REGNO, N##_REGNO)
    SPILL(_S0, 16);
    SPILL(_S1, 24);
    SPILL(_S2, 32);
    SPILL(_S3, 40);
    SPILL(_S4, 48);
    SPILL(_S5, 56);
    SPILLD(_F2, 64);
    SPILLD(_F3, 72);
    SPILLD(_F4, 80);
    SPILLD(_F5, 88);
    SPILLD(_F6, 96);
    SPILLD(_F7, 104);
    SPILLD(_F8, 112);
    SPILLD(_F9, 120);
#  undef SPILLD
#  undef SPILL
    movr(_FP_REGNO, _SP_REGNO);
    /* alloca */
    if (_jitc->function->stack)
	subi(_SP_REGNO, _SP_REGNO, _jitc->function->stack);
    if (_jitc->function->allocar) {
	reg = jit_get_reg(jit_class_gpr);
	movi(rn(reg), _jitc->function->self.aoff);
	stxi_i(_jitc->function->aoffoff, _FP_REGNO, rn(reg));
	jit_unget_reg(reg);
    }

    if (_jitc->function->self.call & jit_call_varargs) {
	for (reg = _jitc->function->self.argi; jit_arg_reg_p(reg); ++reg)
	    stxi(stack_framesize - 48 + reg * 8, _FP_REGNO, rn(_A0 - reg));
	for (reg = _jitc->function->self.argi; jit_arg_reg_p(reg); ++reg)
	    stxi_d(stack_framesize - 96 + reg * 8, _FP_REGNO, rn(_F16 - reg));
    }
}

static void
_epilog(jit_state_t *_jit, jit_node_t *node)
{
    if (_jitc->function->assume_frame)
	return;
    movr(_SP_REGNO, _FP_REGNO);
    ldxi(_RA_REGNO, _SP_REGNO, 0);
    ldxi(_FP_REGNO, _SP_REGNO, 8);
#  define LOAD(N, O)							\
    if (jit_regset_tstbit(&_jitc->function->regset, N))			\
	ldxi(N##_REGNO, _SP_REGNO,  O)
#  define LOADD(N, O)							\
    if (jit_regset_tstbit(&_jitc->function->regset, N))			\
	ldxi_d(N##_REGNO, _SP_REGNO,  O)
    LOAD(_S0, 16);
    LOAD(_S1, 24);
    LOAD(_S2, 32);
    LOAD(_S3, 40);
    LOAD(_S4, 48);
    LOAD(_S5, 56);
    LOADD(_F2, 64);
    LOADD(_F3, 72);
    LOADD(_F4, 80);
    LOADD(_F5, 88);
    LOADD(_F6, 96);
    LOADD(_F7, 104);
    LOADD(_F8, 112);
    LOADD(_F9, 120);
#  undef LOADD
#  undef LOAD
    addi(_SP_REGNO, _SP_REGNO, stack_framesize);
    RET(_R31_REGNO, _RA_REGNO, 1);	/* 1 means procedure return
					 * 0 means no procedure return
					 * other values are reserved */
}

static void
_vastart(jit_state_t *_jit, jit_int32_t r0)
{
    jit_int32_t		reg;

    /* Return jit_va_list_t in the register argument */
    addi(r0, _FP_REGNO, _jitc->function->vaoff);

    reg = jit_get_reg(jit_class_gpr);

    /* The base field is constant. */
    addi(rn(reg), _FP_REGNO, stack_framesize - 48);
    stxi(offsetof(jit_va_list_t, base), r0, rn(reg));

    /* Initialize the offset field */
    if (_jitc->function->vagp < 6)
	movi(rn(reg), _jitc->function->vagp * 8);
    else
	movi(rn(reg), _jitc->function->self.size - (stack_framesize - 48));
    stxi(offsetof(jit_va_list_t, offset), r0, rn(reg));

    jit_unget_reg(reg);
}

static void
_vaarg(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
    jit_int32_t		rg0, rg1;

    assert(_jitc->function->self.call & jit_call_varargs);

    rg0 = jit_get_reg(jit_class_gpr);
    rg1 = jit_get_reg(jit_class_gpr);

    /* Load the base in first temporary. */
    ldxi(rn(rg0), r1, offsetof(jit_va_list_t, base));

    /* Load the offset in the second temporary. */
    ldxi(rn(rg1), r1, offsetof(jit_va_list_t, offset));

    /* Load the argument */
    ldxr(r0, rn(rg0), rn(rg1));

    /* No longer needed. */
    jit_unget_reg(rg0);

    /* Update offset. */
    addi(rn(rg1), rn(rg1), 8);
    stxi(offsetof(jit_va_list_t, offset), r1, rn(rg1));
    jit_unget_reg(rg1);
}

static void
_patch_at(jit_state_t *_jit, jit_word_t instr, jit_word_t label)
{
    union {
	jit_int32_t	*i;
	jit_word_t	 w;
    } u;
    jit_word_t		 d;
    jit_int16_t		s0, s1, s2, s3;
    u.w = instr;
    switch (_u6(u.i[0] >> 26)) {
	/*   BLT	     BLE	     BEQ	     BGE */
	case 0x3a:	case 0x3b:	case 0x39:	case 0x3e:
	/*   BGT	     BNE	     BLBC	     BLBS */
	case 0x3f:	case 0x3d:	case 0x38:	case 0x3c:
	/*   BR		     BSR */
	case 0x30:	case 0x34:
	/*   FBLT	     FBLE	     FBEQ	     FBGE */
	case 0x32:	case 0x33:	case 0x31:	case 0x36:
	/*   FBGT	     FBNE */
	case 0x37:	case 0x35:
	    d = ((label - instr) >> 2) - 1;
	    assert(_s21_p(d));
	    u.i[0] &= ~0x1fffff;
	    u.i[0] |= _u21(d);
	    break;
	/*   LDA */
	case 0x08:		/* movi_p */
	    s0 = label;
	    s1 = label >> 16;
	    s2 = label >> 32;
	    s3 = label >> 48;
	    if (s0 < 0)
		++s1;
	    if (s2 < 0)
		++s3;
	    u.i[0] &= ~0xffff;
	    u.i[0] |= _u16(s0);
	    /*				LDA */
	    assert(_u6(u.i[1] >> 26) == 0x08);
	    u.i[1] &= ~0xffff;
	    u.i[1] |= _u16(s2);
	    /*				LDAH */
	    assert(_u6(u.i[2] >> 26) == 0x09);
	    u.i[2] &= ~0xffff;
	    u.i[2] |= _u16(s1);
	    /*				LDAH */
	    assert(_u6(u.i[3] >> 26) == 0x09);
	    u.i[3] &= ~0xffff;
	    u.i[3] |= _u16(s3);
	    /*				SLL */
	    assert(_u6(u.i[4] >> 26) == 0x12 && _u7(u.i[4] >> 5) == 0x39);
	    /*				SRL */
	    assert(_u6(u.i[5] >> 26) == 0x12 && _u7(u.i[5] >> 5) == 0x34);
	    /*				SLL */
	    assert(_u6(u.i[6] >> 26) == 0x12 && _u7(u.i[6] >> 5) == 0x39);
	    /*				BIS */
	    assert(_u6(u.i[7] >> 26) == 0x11 && _u7(u.i[7] >> 5) == 0x20);
	    break;
	default:
	    abort();
    }
}
#endif