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
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jit_shared_LIR_shared_h
#define jit_shared_LIR_shared_h
#include "mozilla/Maybe.h"
#include "jit/AtomicOp.h"
#include "jit/shared/Assembler-shared.h"
#include "util/Memory.h"
// This file declares LIR instructions that are common to every platform.
namespace js {
namespace jit {
LIR_OPCODE_CLASS_GENERATED
#ifdef FUZZING_JS_FUZZILLI
class LFuzzilliHashT : public LInstructionHelper<1, 1, 2> {
public:
LIR_HEADER(FuzzilliHashT);
LFuzzilliHashT(const LAllocation& value, const LDefinition& temp,
const LDefinition& tempFloat)
: LInstructionHelper(classOpcode) {
setOperand(0, value);
setTemp(0, temp);
setTemp(1, tempFloat);
}
const LAllocation* value() { return getOperand(0); }
MFuzzilliHash* mir() const { return mir_->toFuzzilliHash(); }
};
class LFuzzilliHashV : public LInstructionHelper<1, BOX_PIECES, 2> {
public:
LIR_HEADER(FuzzilliHashV);
LFuzzilliHashV(const LBoxAllocation& value, const LDefinition& temp,
const LDefinition& tempFloat)
: LInstructionHelper(classOpcode) {
setBoxOperand(0, value);
setTemp(0, temp);
setTemp(1, tempFloat);
}
MFuzzilliHash* mir() const { return mir_->toFuzzilliHash(); }
};
class LFuzzilliHashStore : public LInstructionHelper<0, 1, 2> {
public:
LIR_HEADER(FuzzilliHashStore);
LFuzzilliHashStore(const LAllocation& value, const LDefinition& temp1,
const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, value);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LAllocation* value() { return getOperand(0); }
MFuzzilliHashStore* mir() const { return mir_->toFuzzilliHashStore(); }
};
#endif
class LBox : public LInstructionHelper<BOX_PIECES, 1, 0> {
MIRType type_;
public:
LIR_HEADER(Box);
LBox(const LAllocation& payload, MIRType type)
: LInstructionHelper(classOpcode), type_(type) {
setOperand(0, payload);
}
MIRType type() const { return type_; }
const char* extraName() const { return StringFromMIRType(type_); }
};
template <size_t Temps, size_t ExtraUses = 0>
class LBinaryMath : public LInstructionHelper<1, 2 + ExtraUses, Temps> {
protected:
explicit LBinaryMath(LNode::Opcode opcode)
: LInstructionHelper<1, 2 + ExtraUses, Temps>(opcode) {}
public:
const LAllocation* lhs() { return this->getOperand(0); }
const LAllocation* rhs() { return this->getOperand(1); }
};
template <size_t Temps, size_t ExtraUses = 0>
class LUnaryMath : public LInstructionHelper<1, 1 + ExtraUses, Temps> {
protected:
explicit LUnaryMath(LNode::Opcode opcode)
: LInstructionHelper<1, 1 + ExtraUses, Temps>(opcode) {}
public:
const LAllocation* input() { return this->getOperand(0); }
};
// An LOsiPoint captures a snapshot after a call and ensures enough space to
// patch in a call to the invalidation mechanism.
//
// Note: LSafepoints are 1:1 with LOsiPoints, so it holds a reference to the
// corresponding LSafepoint to inform it of the LOsiPoint's masm offset when it
// gets GC'd.
class LOsiPoint : public LInstructionHelper<0, 0, 0> {
LSafepoint* safepoint_;
public:
LOsiPoint(LSafepoint* safepoint, LSnapshot* snapshot)
: LInstructionHelper(classOpcode), safepoint_(safepoint) {
MOZ_ASSERT(safepoint && snapshot);
assignSnapshot(snapshot);
}
LSafepoint* associatedSafepoint() { return safepoint_; }
LIR_HEADER(OsiPoint)
};
class LMove {
LAllocation from_;
LAllocation to_;
LDefinition::Type type_;
public:
LMove(LAllocation from, LAllocation to, LDefinition::Type type)
: from_(from), to_(to), type_(type) {}
LAllocation from() const { return from_; }
LAllocation to() const { return to_; }
LDefinition::Type type() const { return type_; }
};
class LMoveGroup : public LInstructionHelper<0, 0, 0> {
js::Vector<LMove, 2, JitAllocPolicy> moves_;
#ifdef JS_CODEGEN_X86
// Optional general register available for use when executing moves.
LAllocation scratchRegister_;
#endif
explicit LMoveGroup(TempAllocator& alloc)
: LInstructionHelper(classOpcode), moves_(alloc) {}
public:
LIR_HEADER(MoveGroup)
static LMoveGroup* New(TempAllocator& alloc) {
return new (alloc) LMoveGroup(alloc);
}
void printOperands(GenericPrinter& out);
// Add a move which takes place simultaneously with all others in the group.
bool add(LAllocation from, LAllocation to, LDefinition::Type type);
// Add a move which takes place after existing moves in the group.
bool addAfter(LAllocation from, LAllocation to, LDefinition::Type type);
size_t numMoves() const { return moves_.length(); }
const LMove& getMove(size_t i) const { return moves_[i]; }
#ifdef JS_CODEGEN_X86
void setScratchRegister(Register reg) { scratchRegister_ = LGeneralReg(reg); }
LAllocation maybeScratchRegister() { return scratchRegister_; }
#endif
bool uses(Register reg) {
for (size_t i = 0; i < numMoves(); i++) {
LMove move = getMove(i);
if (move.from() == LGeneralReg(reg) || move.to() == LGeneralReg(reg)) {
return true;
}
}
return false;
}
};
// A constant Value.
class LValue : public LInstructionHelper<BOX_PIECES, 0, 0> {
Value v_;
public:
LIR_HEADER(Value)
explicit LValue(const Value& v) : LInstructionHelper(classOpcode), v_(v) {}
Value value() const { return v_; }
};
// Base class for control instructions (goto, branch, etc.)
template <size_t Succs, size_t Operands, size_t Temps>
class LControlInstructionHelper
: public LInstructionHelper<0, Operands, Temps> {
mozilla::Array<MBasicBlock*, Succs> successors_;
protected:
explicit LControlInstructionHelper(LNode::Opcode opcode)
: LInstructionHelper<0, Operands, Temps>(opcode) {}
public:
size_t numSuccessors() const { return Succs; }
MBasicBlock* getSuccessor(size_t i) const { return successors_[i]; }
void setSuccessor(size_t i, MBasicBlock* successor) {
successors_[i] = successor;
}
};
// Jumps to the start of a basic block.
class LGoto : public LControlInstructionHelper<1, 0, 0> {
public:
LIR_HEADER(Goto)
explicit LGoto(MBasicBlock* block) : LControlInstructionHelper(classOpcode) {
setSuccessor(0, block);
}
MBasicBlock* target() const { return getSuccessor(0); }
};
class LNewArray : public LInstructionHelper<1, 0, 1> {
public:
LIR_HEADER(NewArray)
explicit LNewArray(const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setTemp(0, temp);
}
const char* extraName() const {
return mir()->isVMCall() ? "VMCall" : nullptr;
}
const LDefinition* temp() { return getTemp(0); }
MNewArray* mir() const { return mir_->toNewArray(); }
};
class LNewObject : public LInstructionHelper<1, 0, 1> {
public:
LIR_HEADER(NewObject)
explicit LNewObject(const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setTemp(0, temp);
}
const char* extraName() const {
return mir()->isVMCall() ? "VMCall" : nullptr;
}
const LDefinition* temp() { return getTemp(0); }
MNewObject* mir() const { return mir_->toNewObject(); }
};
template <size_t Defs, size_t Ops>
class LWasmReinterpretBase : public LInstructionHelper<Defs, Ops, 0> {
typedef LInstructionHelper<Defs, Ops, 0> Base;
protected:
explicit LWasmReinterpretBase(LNode::Opcode opcode) : Base(opcode) {}
public:
const LAllocation* input() { return Base::getOperand(0); }
MWasmReinterpret* mir() const { return Base::mir_->toWasmReinterpret(); }
};
class LWasmReinterpret : public LWasmReinterpretBase<1, 1> {
public:
LIR_HEADER(WasmReinterpret);
explicit LWasmReinterpret(const LAllocation& input)
: LWasmReinterpretBase(classOpcode) {
setOperand(0, input);
}
};
class LWasmReinterpretFromI64 : public LWasmReinterpretBase<1, INT64_PIECES> {
public:
static const size_t Input = 0;
LIR_HEADER(WasmReinterpretFromI64);
explicit LWasmReinterpretFromI64(const LInt64Allocation& input)
: LWasmReinterpretBase(classOpcode) {
setInt64Operand(Input, input);
}
};
class LWasmReinterpretToI64 : public LWasmReinterpretBase<INT64_PIECES, 1> {
public:
LIR_HEADER(WasmReinterpretToI64);
explicit LWasmReinterpretToI64(const LAllocation& input)
: LWasmReinterpretBase(classOpcode) {
setOperand(0, input);
}
};
namespace details {
template <size_t Defs, size_t Ops, size_t Temps>
class RotateBase : public LInstructionHelper<Defs, Ops, Temps> {
typedef LInstructionHelper<Defs, Ops, Temps> Base;
protected:
explicit RotateBase(LNode::Opcode opcode) : Base(opcode) {}
public:
MRotate* mir() { return Base::mir_->toRotate(); }
};
} // namespace details
class LRotate : public details::RotateBase<1, 2, 0> {
public:
LIR_HEADER(Rotate);
LRotate() : RotateBase(classOpcode) {}
const LAllocation* input() { return getOperand(0); }
LAllocation* count() { return getOperand(1); }
};
class LRotateI64
: public details::RotateBase<INT64_PIECES, INT64_PIECES + 1, 1> {
public:
LIR_HEADER(RotateI64);
LRotateI64() : RotateBase(classOpcode) {
setTemp(0, LDefinition::BogusTemp());
}
static const size_t Input = 0;
static const size_t Count = INT64_PIECES;
const LInt64Allocation input() { return getInt64Operand(Input); }
const LDefinition* temp() { return getTemp(0); }
LAllocation* count() { return getOperand(Count); }
};
// Allocate a new arguments object for an inlined frame.
class LCreateInlinedArgumentsObject : public LVariadicInstruction<1, 2> {
public:
LIR_HEADER(CreateInlinedArgumentsObject)
static const size_t CallObj = 0;
static const size_t Callee = 1;
static const size_t NumNonArgumentOperands = 2;
static size_t ArgIndex(size_t i) {
return NumNonArgumentOperands + BOX_PIECES * i;
}
LCreateInlinedArgumentsObject(uint32_t numOperands, const LDefinition& temp1,
const LDefinition& temp2)
: LVariadicInstruction(classOpcode, numOperands) {
setIsCall();
setTemp(0, temp1);
setTemp(1, temp2);
}
const LAllocation* getCallObject() { return getOperand(CallObj); }
const LAllocation* getCallee() { return getOperand(Callee); }
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
MCreateInlinedArgumentsObject* mir() const {
return mir_->toCreateInlinedArgumentsObject();
}
};
class LGetInlinedArgument : public LVariadicInstruction<BOX_PIECES, 0> {
public:
LIR_HEADER(GetInlinedArgument)
static const size_t Index = 0;
static const size_t NumNonArgumentOperands = 1;
static size_t ArgIndex(size_t i) {
return NumNonArgumentOperands + BOX_PIECES * i;
}
explicit LGetInlinedArgument(uint32_t numOperands)
: LVariadicInstruction(classOpcode, numOperands) {}
const LAllocation* getIndex() { return getOperand(Index); }
MGetInlinedArgument* mir() const { return mir_->toGetInlinedArgument(); }
};
class LGetInlinedArgumentHole : public LVariadicInstruction<BOX_PIECES, 0> {
public:
LIR_HEADER(GetInlinedArgumentHole)
static const size_t Index = 0;
static const size_t NumNonArgumentOperands = 1;
static size_t ArgIndex(size_t i) {
return NumNonArgumentOperands + BOX_PIECES * i;
}
explicit LGetInlinedArgumentHole(uint32_t numOperands)
: LVariadicInstruction(classOpcode, numOperands) {}
const LAllocation* getIndex() { return getOperand(Index); }
MGetInlinedArgumentHole* mir() const {
return mir_->toGetInlinedArgumentHole();
}
};
class LInlineArgumentsSlice : public LVariadicInstruction<1, 1> {
public:
LIR_HEADER(InlineArgumentsSlice)
static const size_t Begin = 0;
static const size_t Count = 1;
static const size_t NumNonArgumentOperands = 2;
static size_t ArgIndex(size_t i) {
return NumNonArgumentOperands + BOX_PIECES * i;
}
explicit LInlineArgumentsSlice(uint32_t numOperands, const LDefinition& temp)
: LVariadicInstruction(classOpcode, numOperands) {
setTemp(0, temp);
}
const LAllocation* begin() { return getOperand(Begin); }
const LAllocation* count() { return getOperand(Count); }
const LDefinition* temp() { return getTemp(0); }
MInlineArgumentsSlice* mir() const { return mir_->toInlineArgumentsSlice(); }
};
// Common code for LIR descended from MCall.
template <size_t Defs, size_t Operands, size_t Temps>
class LJSCallInstructionHelper
: public LCallInstructionHelper<Defs, Operands, Temps> {
protected:
explicit LJSCallInstructionHelper(LNode::Opcode opcode)
: LCallInstructionHelper<Defs, Operands, Temps>(opcode) {}
public:
MCall* mir() const { return this->mir_->toCall(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
// Does not include |this|.
uint32_t numActualArgs() const { return mir()->numActualArgs(); }
bool isConstructing() const { return mir()->isConstructing(); }
bool ignoresReturnValue() const { return mir()->ignoresReturnValue(); }
};
// Generates a polymorphic callsite, wherein the function being called is
// unknown and anticipated to vary.
class LCallGeneric : public LJSCallInstructionHelper<BOX_PIECES, 1, 1> {
public:
LIR_HEADER(CallGeneric)
LCallGeneric(const LAllocation& callee, const LDefinition& argc)
: LJSCallInstructionHelper(classOpcode) {
setOperand(0, callee);
setTemp(0, argc);
}
const LAllocation* getCallee() { return getOperand(0); }
const LDefinition* getArgc() { return getTemp(0); }
};
// Generates a hardcoded callsite for a known, non-native target.
class LCallKnown : public LJSCallInstructionHelper<BOX_PIECES, 1, 1> {
public:
LIR_HEADER(CallKnown)
LCallKnown(const LAllocation& func, const LDefinition& tmpobjreg)
: LJSCallInstructionHelper(classOpcode) {
setOperand(0, func);
setTemp(0, tmpobjreg);
}
const LAllocation* getFunction() { return getOperand(0); }
const LDefinition* getTempObject() { return getTemp(0); }
};
// Generates a hardcoded callsite for a known, native target.
class LCallNative : public LJSCallInstructionHelper<BOX_PIECES, 0, 4> {
public:
LIR_HEADER(CallNative)
LCallNative(const LDefinition& argContext, const LDefinition& argUintN,
const LDefinition& argVp, const LDefinition& tmpreg)
: LJSCallInstructionHelper(classOpcode) {
// Registers used for callWithABI().
setTemp(0, argContext);
setTemp(1, argUintN);
setTemp(2, argVp);
// Temporary registers.
setTemp(3, tmpreg);
}
const LDefinition* getArgContextReg() { return getTemp(0); }
const LDefinition* getArgUintNReg() { return getTemp(1); }
const LDefinition* getArgVpReg() { return getTemp(2); }
const LDefinition* getTempReg() { return getTemp(3); }
};
class LCallClassHook : public LCallInstructionHelper<BOX_PIECES, 1, 4> {
public:
LIR_HEADER(CallClassHook)
LCallClassHook(const LAllocation& callee, const LDefinition& argContext,
const LDefinition& argUintN, const LDefinition& argVp,
const LDefinition& tmpreg)
: LCallInstructionHelper(classOpcode) {
setOperand(0, callee);
// Registers used for callWithABI().
setTemp(0, argContext);
setTemp(1, argUintN);
setTemp(2, argVp);
// Temporary registers.
setTemp(3, tmpreg);
}
MCallClassHook* mir() const { return mir_->toCallClassHook(); }
const LAllocation* getCallee() { return this->getOperand(0); }
const LDefinition* getArgContextReg() { return getTemp(0); }
const LDefinition* getArgUintNReg() { return getTemp(1); }
const LDefinition* getArgVpReg() { return getTemp(2); }
const LDefinition* getTempReg() { return getTemp(3); }
};
// Generates a hardcoded callsite for a known, DOM-native target.
class LCallDOMNative : public LJSCallInstructionHelper<BOX_PIECES, 0, 4> {
public:
LIR_HEADER(CallDOMNative)
LCallDOMNative(const LDefinition& argJSContext, const LDefinition& argObj,
const LDefinition& argPrivate, const LDefinition& argArgs)
: LJSCallInstructionHelper(classOpcode) {
setTemp(0, argJSContext);
setTemp(1, argObj);
setTemp(2, argPrivate);
setTemp(3, argArgs);
}
const LDefinition* getArgJSContext() { return getTemp(0); }
const LDefinition* getArgObj() { return getTemp(1); }
const LDefinition* getArgPrivate() { return getTemp(2); }
const LDefinition* getArgArgs() { return getTemp(3); }
};
class LUnreachable : public LControlInstructionHelper<0, 0, 0> {
public:
LIR_HEADER(Unreachable)
LUnreachable() : LControlInstructionHelper(classOpcode) {}
};
class LUnreachableResultV : public LInstructionHelper<BOX_PIECES, 0, 0> {
public:
LIR_HEADER(UnreachableResultV)
LUnreachableResultV() : LInstructionHelper(classOpcode) {}
};
template <size_t defs, size_t ops>
class LDOMPropertyInstructionHelper
: public LCallInstructionHelper<defs, 1 + ops, 3> {
protected:
LDOMPropertyInstructionHelper(LNode::Opcode opcode,
const LDefinition& JSContextReg,
const LAllocation& ObjectReg,
const LDefinition& PrivReg,
const LDefinition& ValueReg)
: LCallInstructionHelper<defs, 1 + ops, 3>(opcode) {
this->setOperand(0, ObjectReg);
this->setTemp(0, JSContextReg);
this->setTemp(1, PrivReg);
this->setTemp(2, ValueReg);
}
public:
const LDefinition* getJSContextReg() { return this->getTemp(0); }
const LAllocation* getObjectReg() { return this->getOperand(0); }
const LDefinition* getPrivReg() { return this->getTemp(1); }
const LDefinition* getValueReg() { return this->getTemp(2); }
};
class LGetDOMProperty : public LDOMPropertyInstructionHelper<BOX_PIECES, 0> {
public:
LIR_HEADER(GetDOMProperty)
LGetDOMProperty(const LDefinition& JSContextReg, const LAllocation& ObjectReg,
const LDefinition& PrivReg, const LDefinition& ValueReg)
: LDOMPropertyInstructionHelper<BOX_PIECES, 0>(
classOpcode, JSContextReg, ObjectReg, PrivReg, ValueReg) {}
MGetDOMProperty* mir() const { return mir_->toGetDOMProperty(); }
};
class LGetDOMMemberV : public LInstructionHelper<BOX_PIECES, 1, 0> {
public:
LIR_HEADER(GetDOMMemberV);
explicit LGetDOMMemberV(const LAllocation& object)
: LInstructionHelper(classOpcode) {
setOperand(0, object);
}
const LAllocation* object() { return getOperand(0); }
MGetDOMMember* mir() const { return mir_->toGetDOMMember(); }
};
class LSetDOMProperty : public LDOMPropertyInstructionHelper<0, BOX_PIECES> {
public:
LIR_HEADER(SetDOMProperty)
LSetDOMProperty(const LDefinition& JSContextReg, const LAllocation& ObjectReg,
const LBoxAllocation& value, const LDefinition& PrivReg,
const LDefinition& ValueReg)
: LDOMPropertyInstructionHelper<0, BOX_PIECES>(
classOpcode, JSContextReg, ObjectReg, PrivReg, ValueReg) {
setBoxOperand(Value, value);
}
static const size_t Value = 1;
MSetDOMProperty* mir() const { return mir_->toSetDOMProperty(); }
};
// Generates a polymorphic callsite, wherein the function being called is
// unknown and anticipated to vary.
class LApplyArgsGeneric
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> {
public:
LIR_HEADER(ApplyArgsGeneric)
LApplyArgsGeneric(const LAllocation& func, const LAllocation& argc,
const LBoxAllocation& thisv, const LDefinition& tmpObjReg,
const LDefinition& tmpCopy)
: LCallInstructionHelper(classOpcode) {
setOperand(0, func);
setOperand(1, argc);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
}
MApplyArgs* mir() const { return mir_->toApplyArgs(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
uint32_t numExtraFormals() const { return mir()->numExtraFormals(); }
const LAllocation* getFunction() { return getOperand(0); }
const LAllocation* getArgc() { return getOperand(1); }
static const size_t ThisIndex = 2;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
};
class LApplyArgsObj
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> {
public:
LIR_HEADER(ApplyArgsObj)
LApplyArgsObj(const LAllocation& func, const LAllocation& argsObj,
const LBoxAllocation& thisv, const LDefinition& tmpObjReg,
const LDefinition& tmpCopy)
: LCallInstructionHelper(classOpcode) {
setOperand(0, func);
setOperand(1, argsObj);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
}
MApplyArgsObj* mir() const { return mir_->toApplyArgsObj(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
const LAllocation* getFunction() { return getOperand(0); }
const LAllocation* getArgsObj() { return getOperand(1); }
// All registers are calltemps. argc is mapped to the same register as
// ArgsObj. argc becomes live as ArgsObj is dying.
const LAllocation* getArgc() { return getOperand(1); }
static const size_t ThisIndex = 2;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
};
class LApplyArrayGeneric
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> {
public:
LIR_HEADER(ApplyArrayGeneric)
LApplyArrayGeneric(const LAllocation& func, const LAllocation& elements,
const LBoxAllocation& thisv, const LDefinition& tmpObjReg,
const LDefinition& tmpCopy)
: LCallInstructionHelper(classOpcode) {
setOperand(0, func);
setOperand(1, elements);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
}
MApplyArray* mir() const { return mir_->toApplyArray(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
const LAllocation* getFunction() { return getOperand(0); }
const LAllocation* getElements() { return getOperand(1); }
// argc is mapped to the same register as elements: argc becomes
// live as elements is dying, all registers are calltemps.
const LAllocation* getArgc() { return getOperand(1); }
static const size_t ThisIndex = 2;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
};
class LConstructArgsGeneric
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 3, 1> {
public:
LIR_HEADER(ConstructArgsGeneric)
LConstructArgsGeneric(const LAllocation& func, const LAllocation& argc,
const LAllocation& newTarget,
const LBoxAllocation& thisv,
const LDefinition& tmpObjReg)
: LCallInstructionHelper(classOpcode) {
setOperand(0, func);
setOperand(1, argc);
setOperand(2, newTarget);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
}
MConstructArgs* mir() const { return mir_->toConstructArgs(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
uint32_t numExtraFormals() const { return mir()->numExtraFormals(); }
const LAllocation* getFunction() { return getOperand(0); }
const LAllocation* getArgc() { return getOperand(1); }
const LAllocation* getNewTarget() { return getOperand(2); }
static const size_t ThisIndex = 3;
const LDefinition* getTempObject() { return getTemp(0); }
// tempForArgCopy is mapped to the same register as newTarget:
// tempForArgCopy becomes live as newTarget is dying, all registers are
// calltemps.
const LAllocation* getTempForArgCopy() { return getOperand(2); }
};
class LConstructArrayGeneric
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 3, 1> {
public:
LIR_HEADER(ConstructArrayGeneric)
LConstructArrayGeneric(const LAllocation& func, const LAllocation& elements,
const LAllocation& newTarget,
const LBoxAllocation& thisv,
const LDefinition& tmpObjReg)
: LCallInstructionHelper(classOpcode) {
setOperand(0, func);
setOperand(1, elements);
setOperand(2, newTarget);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
}
MConstructArray* mir() const { return mir_->toConstructArray(); }
bool hasSingleTarget() const { return getSingleTarget() != nullptr; }
WrappedFunction* getSingleTarget() const { return mir()->getSingleTarget(); }
const LAllocation* getFunction() { return getOperand(0); }
const LAllocation* getElements() { return getOperand(1); }
const LAllocation* getNewTarget() { return getOperand(2); }
static const size_t ThisIndex = 3;
const LDefinition* getTempObject() { return getTemp(0); }
// argc is mapped to the same register as elements: argc becomes
// live as elements is dying, all registers are calltemps.
const LAllocation* getArgc() { return getOperand(1); }
// tempForArgCopy is mapped to the same register as newTarget:
// tempForArgCopy becomes live as newTarget is dying, all registers are
// calltemps.
const LAllocation* getTempForArgCopy() { return getOperand(2); }
};
class LApplyArgsNative
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> {
public:
LIR_HEADER(ApplyArgsNative)
LApplyArgsNative(const LAllocation& argc, const LBoxAllocation& thisv,
const LDefinition& tmpObjReg, const LDefinition& tmpCopy,
const LDefinition& tmpExtra)
: LCallInstructionHelper(classOpcode) {
setOperand(0, argc);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
setTemp(2, tmpExtra);
}
static constexpr bool isConstructing() { return false; }
MApplyArgs* mir() const { return mir_->toApplyArgs(); }
uint32_t numExtraFormals() const { return mir()->numExtraFormals(); }
const LAllocation* getArgc() { return getOperand(0); }
static const size_t ThisIndex = 1;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
const LDefinition* getTempExtra() { return getTemp(2); }
};
class LApplyArgsObjNative
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> {
public:
LIR_HEADER(ApplyArgsObjNative)
LApplyArgsObjNative(const LAllocation& argsObj, const LBoxAllocation& thisv,
const LDefinition& tmpObjReg, const LDefinition& tmpCopy,
const LDefinition& tmpExtra)
: LCallInstructionHelper(classOpcode) {
setOperand(0, argsObj);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
setTemp(2, tmpExtra);
}
static constexpr bool isConstructing() { return false; }
MApplyArgsObj* mir() const { return mir_->toApplyArgsObj(); }
const LAllocation* getArgsObj() { return getOperand(0); }
static const size_t ThisIndex = 1;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
const LDefinition* getTempExtra() { return getTemp(2); }
// argc is mapped to the same register as argsObj: argc becomes live as
// argsObj is dying, all registers are calltemps.
const LAllocation* getArgc() { return getOperand(0); }
};
class LApplyArrayNative
: public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> {
public:
LIR_HEADER(ApplyArrayNative)
LApplyArrayNative(const LAllocation& elements, const LBoxAllocation& thisv,
const LDefinition& tmpObjReg, const LDefinition& tmpCopy,
const LDefinition& tmpExtra)
: LCallInstructionHelper(classOpcode) {
setOperand(0, elements);
setBoxOperand(ThisIndex, thisv);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
setTemp(2, tmpExtra);
}
static constexpr bool isConstructing() { return false; }
MApplyArray* mir() const { return mir_->toApplyArray(); }
const LAllocation* getElements() { return getOperand(0); }
static const size_t ThisIndex = 1;
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
const LDefinition* getTempExtra() { return getTemp(2); }
// argc is mapped to the same register as elements: argc becomes live as
// elements is dying, all registers are calltemps.
const LAllocation* getArgc() { return getOperand(0); }
};
class LConstructArgsNative : public LCallInstructionHelper<BOX_PIECES, 2, 3> {
public:
LIR_HEADER(ConstructArgsNative)
LConstructArgsNative(const LAllocation& argc, const LAllocation& newTarget,
const LDefinition& tmpObjReg, const LDefinition& tmpCopy,
const LDefinition& tmpExtra)
: LCallInstructionHelper(classOpcode) {
setOperand(0, argc);
setOperand(1, newTarget);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
setTemp(2, tmpExtra);
}
static constexpr bool isConstructing() { return true; }
MConstructArgs* mir() const { return mir_->toConstructArgs(); }
uint32_t numExtraFormals() const { return mir()->numExtraFormals(); }
const LAllocation* getArgc() { return getOperand(0); }
const LAllocation* getNewTarget() { return getOperand(1); }
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
const LDefinition* getTempExtra() { return getTemp(2); }
};
class LConstructArrayNative : public LCallInstructionHelper<BOX_PIECES, 2, 3> {
public:
LIR_HEADER(ConstructArrayNative)
LConstructArrayNative(const LAllocation& elements,
const LAllocation& newTarget,
const LDefinition& tmpObjReg,
const LDefinition& tmpCopy, const LDefinition& tmpExtra)
: LCallInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, newTarget);
setTemp(0, tmpObjReg);
setTemp(1, tmpCopy);
setTemp(2, tmpExtra);
}
static constexpr bool isConstructing() { return true; }
MConstructArray* mir() const { return mir_->toConstructArray(); }
const LAllocation* getElements() { return getOperand(0); }
const LAllocation* getNewTarget() { return getOperand(1); }
const LDefinition* getTempObject() { return getTemp(0); }
const LDefinition* getTempForArgCopy() { return getTemp(1); }
const LDefinition* getTempExtra() { return getTemp(2); }
// argc is mapped to the same register as elements: argc becomes live as
// elements is dying, all registers are calltemps.
const LAllocation* getArgc() { return getOperand(0); }
};
// Takes in either an integer or boolean input and tests it for truthiness.
class LTestIAndBranch : public LControlInstructionHelper<2, 1, 0> {
public:
LIR_HEADER(TestIAndBranch)
LTestIAndBranch(const LAllocation& in, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode) {
setOperand(0, in);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
// Takes in an int64 input and tests it for truthiness.
class LTestI64AndBranch : public LControlInstructionHelper<2, INT64_PIECES, 0> {
public:
LIR_HEADER(TestI64AndBranch)
LTestI64AndBranch(const LInt64Allocation& in, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode) {
setInt64Operand(0, in);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
// Takes in a double input and tests it for truthiness.
class LTestDAndBranch : public LControlInstructionHelper<2, 1, 0> {
public:
LIR_HEADER(TestDAndBranch)
LTestDAndBranch(const LAllocation& in, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode) {
setOperand(0, in);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
// Takes in a float32 input and tests it for truthiness.
class LTestFAndBranch : public LControlInstructionHelper<2, 1, 0> {
public:
LIR_HEADER(TestFAndBranch)
LTestFAndBranch(const LAllocation& in, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode) {
setOperand(0, in);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
// Takes in a bigint input and tests it for truthiness.
class LTestBIAndBranch : public LControlInstructionHelper<2, 1, 0> {
public:
LIR_HEADER(TestBIAndBranch)
LTestBIAndBranch(const LAllocation& in, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode) {
setOperand(0, in);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() { return getSuccessor(0); }
MBasicBlock* ifFalse() { return getSuccessor(1); }
};
// Takes an object and tests it for truthiness. An object is falsy iff it
// emulates |undefined|; see js::EmulatesUndefined.
class LTestOAndBranch : public LControlInstructionHelper<2, 1, 1> {
public:
LIR_HEADER(TestOAndBranch)
LTestOAndBranch(const LAllocation& input, MBasicBlock* ifTruthy,
MBasicBlock* ifFalsy, const LDefinition& temp)
: LControlInstructionHelper(classOpcode) {
setOperand(0, input);
setSuccessor(0, ifTruthy);
setSuccessor(1, ifFalsy);
setTemp(0, temp);
}
const LDefinition* temp() { return getTemp(0); }
MBasicBlock* ifTruthy() { return getSuccessor(0); }
MBasicBlock* ifFalsy() { return getSuccessor(1); }
MTest* mir() { return mir_->toTest(); }
};
// Takes in a boxed value and tests it for truthiness.
class LTestVAndBranch : public LControlInstructionHelper<2, BOX_PIECES, 3> {
public:
LIR_HEADER(TestVAndBranch)
LTestVAndBranch(MBasicBlock* ifTruthy, MBasicBlock* ifFalsy,
const LBoxAllocation& input, const LDefinition& temp0,
const LDefinition& temp1, const LDefinition& temp2)
: LControlInstructionHelper(classOpcode) {
setSuccessor(0, ifTruthy);
setSuccessor(1, ifFalsy);
setBoxOperand(Input, input);
setTemp(0, temp0);
setTemp(1, temp1);
setTemp(2, temp2);
}
static const size_t Input = 0;
const LDefinition* tempFloat() { return getTemp(0); }
const LDefinition* temp1() { return getTemp(1); }
const LDefinition* temp2() { return getTemp(2); }
MBasicBlock* ifTruthy() { return getSuccessor(0); }
MBasicBlock* ifFalsy() { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
};
// Compares two integral values of the same JS type, either integer or object.
// For objects, both operands are in registers.
class LCompare : public LInstructionHelper<1, 2, 0> {
JSOp jsop_;
public:
LIR_HEADER(Compare)
LCompare(JSOp jsop, const LAllocation& left, const LAllocation& right)
: LInstructionHelper(classOpcode), jsop_(jsop) {
setOperand(0, left);
setOperand(1, right);
}
JSOp jsop() const { return jsop_; }
const LAllocation* left() { return getOperand(0); }
const LAllocation* right() { return getOperand(1); }
MCompare* mir() { return mir_->toCompare(); }
const char* extraName() const { return CodeName(jsop_); }
};
class LCompareI64 : public LInstructionHelper<1, 2 * INT64_PIECES, 0> {
JSOp jsop_;
public:
LIR_HEADER(CompareI64)
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
LCompareI64(JSOp jsop, const LInt64Allocation& left,
const LInt64Allocation& right)
: LInstructionHelper(classOpcode), jsop_(jsop) {
setInt64Operand(Lhs, left);
setInt64Operand(Rhs, right);
}
JSOp jsop() const { return jsop_; }
MCompare* mir() { return mir_->toCompare(); }
const char* extraName() const { return CodeName(jsop_); }
};
class LCompareI64AndBranch
: public LControlInstructionHelper<2, 2 * INT64_PIECES, 0> {
MCompare* cmpMir_;
JSOp jsop_;
public:
LIR_HEADER(CompareI64AndBranch)
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
LCompareI64AndBranch(MCompare* cmpMir, JSOp jsop,
const LInt64Allocation& left,
const LInt64Allocation& right, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir), jsop_(jsop) {
setInt64Operand(Lhs, left);
setInt64Operand(Rhs, right);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
JSOp jsop() const { return jsop_; }
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
const char* extraName() const { return CodeName(jsop_); }
};
// Compares two integral values of the same JS type, either integer or object.
// For objects, both operands are in registers.
class LCompareAndBranch : public LControlInstructionHelper<2, 2, 0> {
MCompare* cmpMir_;
JSOp jsop_;
public:
LIR_HEADER(CompareAndBranch)
LCompareAndBranch(MCompare* cmpMir, JSOp jsop, const LAllocation& left,
const LAllocation& right, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir), jsop_(jsop) {
setOperand(0, left);
setOperand(1, right);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
JSOp jsop() const { return jsop_; }
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* left() { return getOperand(0); }
const LAllocation* right() { return getOperand(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
const char* extraName() const { return CodeName(jsop_); }
};
class LCompareDAndBranch : public LControlInstructionHelper<2, 2, 0> {
MCompare* cmpMir_;
public:
LIR_HEADER(CompareDAndBranch)
LCompareDAndBranch(MCompare* cmpMir, const LAllocation& left,
const LAllocation& right, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setOperand(0, left);
setOperand(1, right);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* left() { return getOperand(0); }
const LAllocation* right() { return getOperand(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
};
class LCompareFAndBranch : public LControlInstructionHelper<2, 2, 0> {
MCompare* cmpMir_;
public:
LIR_HEADER(CompareFAndBranch)
LCompareFAndBranch(MCompare* cmpMir, const LAllocation& left,
const LAllocation& right, MBasicBlock* ifTrue,
MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setOperand(0, left);
setOperand(1, right);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* left() { return getOperand(0); }
const LAllocation* right() { return getOperand(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
};
class LBitAndAndBranch : public LControlInstructionHelper<2, 2, 0> {
// This denotes only a single-word AND on the target. Hence `is64_` is
// required to be `false` on a 32-bit target.
bool is64_;
Assembler::Condition cond_;
public:
LIR_HEADER(BitAndAndBranch)
LBitAndAndBranch(MBasicBlock* ifTrue, MBasicBlock* ifFalse, bool is64,
Assembler::Condition cond = Assembler::NonZero)
: LControlInstructionHelper(classOpcode), is64_(is64), cond_(cond) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* left() { return getOperand(0); }
const LAllocation* right() { return getOperand(1); }
bool is64() const { return is64_; }
Assembler::Condition cond() const {
MOZ_ASSERT(cond_ == Assembler::Zero || cond_ == Assembler::NonZero);
return cond_;
}
};
class LIsNullOrLikeUndefinedAndBranchV
: public LControlInstructionHelper<2, BOX_PIECES, 2> {
MCompare* cmpMir_;
public:
LIR_HEADER(IsNullOrLikeUndefinedAndBranchV)
LIsNullOrLikeUndefinedAndBranchV(MCompare* cmpMir, MBasicBlock* ifTrue,
MBasicBlock* ifFalse,
const LBoxAllocation& value,
const LDefinition& temp,
const LDefinition& tempToUnbox)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Value, value);
setTemp(0, temp);
setTemp(1, tempToUnbox);
}
static const size_t Value = 0;
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
const LDefinition* temp() { return getTemp(0); }
const LDefinition* tempToUnbox() { return getTemp(1); }
};
class LIsNullOrLikeUndefinedAndBranchT
: public LControlInstructionHelper<2, 1, 1> {
MCompare* cmpMir_;
public:
LIR_HEADER(IsNullOrLikeUndefinedAndBranchT)
LIsNullOrLikeUndefinedAndBranchT(MCompare* cmpMir, const LAllocation& input,
MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LDefinition& temp)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setOperand(0, input);
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setTemp(0, temp);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
const LDefinition* temp() { return getTemp(0); }
};
class LIsNullAndBranch : public LControlInstructionHelper<2, BOX_PIECES, 0> {
MCompare* cmpMir_;
public:
LIR_HEADER(IsNullAndBranch)
LIsNullAndBranch(MCompare* cmpMir, MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LBoxAllocation& value)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Value, value);
}
static const size_t Value = 0;
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
};
class LIsUndefinedAndBranch
: public LControlInstructionHelper<2, BOX_PIECES, 0> {
MCompare* cmpMir_;
public:
LIR_HEADER(IsUndefinedAndBranch)
LIsUndefinedAndBranch(MCompare* cmpMir, MBasicBlock* ifTrue,
MBasicBlock* ifFalse, const LBoxAllocation& value)
: LControlInstructionHelper(classOpcode), cmpMir_(cmpMir) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Value, value);
}
static const size_t Value = 0;
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MTest* mir() const { return mir_->toTest(); }
MCompare* cmpMir() const { return cmpMir_; }
};
// Bitwise not operation, takes a 32-bit integer as input and returning
// a 32-bit integer result as an output.
class LBitNotI : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(BitNotI)
LBitNotI() : LInstructionHelper(classOpcode) {}
};
class LBitNotI64 : public LInstructionHelper<INT64_PIECES, INT64_PIECES, 0> {
public:
LIR_HEADER(BitNotI64)
LBitNotI64() : LInstructionHelper(classOpcode) {}
};
// Binary bitwise operation, taking two 32-bit integers as inputs and returning
// a 32-bit integer result as an output.
class LBitOpI : public LInstructionHelper<1, 2, 0> {
JSOp op_;
public:
LIR_HEADER(BitOpI)
explicit LBitOpI(JSOp op) : LInstructionHelper(classOpcode), op_(op) {}
const char* extraName() const {
if (bitop() == JSOp::Ursh && mir_->toUrsh()->bailoutsDisabled()) {
return "ursh:BailoutsDisabled";
}
return CodeName(op_);
}
JSOp bitop() const { return op_; }
};
class LBitOpI64 : public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0> {
JSOp op_;
public:
LIR_HEADER(BitOpI64)
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
explicit LBitOpI64(JSOp op) : LInstructionHelper(classOpcode), op_(op) {}
const char* extraName() const { return CodeName(op_); }
JSOp bitop() const { return op_; }
};
// Shift operation, taking two 32-bit integers as inputs and returning
// a 32-bit integer result as an output.
class LShiftI : public LBinaryMath<0> {
JSOp op_;
public:
LIR_HEADER(ShiftI)
explicit LShiftI(JSOp op) : LBinaryMath(classOpcode), op_(op) {}
JSOp bitop() { return op_; }
MInstruction* mir() { return mir_->toInstruction(); }
const char* extraName() const { return CodeName(op_); }
};
class LShiftI64 : public LInstructionHelper<INT64_PIECES, INT64_PIECES + 1, 0> {
JSOp op_;
public:
LIR_HEADER(ShiftI64)
explicit LShiftI64(JSOp op) : LInstructionHelper(classOpcode), op_(op) {}
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
JSOp bitop() { return op_; }
MInstruction* mir() { return mir_->toInstruction(); }
const char* extraName() const { return CodeName(op_); }
};
class LSignExtendInt64
: public LInstructionHelper<INT64_PIECES, INT64_PIECES, 0> {
public:
LIR_HEADER(SignExtendInt64)
explicit LSignExtendInt64(const LInt64Allocation& input)
: LInstructionHelper(classOpcode) {
setInt64Operand(0, input);
}
const MSignExtendInt64* mir() const { return mir_->toSignExtendInt64(); }
MSignExtendInt64::Mode mode() const { return mir()->mode(); }
};
class LUrshD : public LBinaryMath<1> {
public:
LIR_HEADER(UrshD)
LUrshD(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp);
}
const LDefinition* temp() { return getTemp(0); }
};
// Returns from the function being compiled (not used in inlined frames). The
// input must be a box.
class LReturn : public LInstructionHelper<0, BOX_PIECES, 0> {
bool isGenerator_;
public:
LIR_HEADER(Return)
explicit LReturn(bool isGenerator)
: LInstructionHelper(classOpcode), isGenerator_(isGenerator) {}
bool isGenerator() { return isGenerator_; }
};
class LMinMaxBase : public LInstructionHelper<1, 2, 0> {
protected:
LMinMaxBase(LNode::Opcode opcode, const LAllocation& first,
const LAllocation& second)
: LInstructionHelper(opcode) {
setOperand(0, first);
setOperand(1, second);
}
public:
const LAllocation* first() { return this->getOperand(0); }
const LAllocation* second() { return this->getOperand(1); }
const LDefinition* output() { return this->getDef(0); }
MMinMax* mir() const { return mir_->toMinMax(); }
const char* extraName() const { return mir()->isMax() ? "Max" : "Min"; }
};
class LMinMaxI : public LMinMaxBase {
public:
LIR_HEADER(MinMaxI)
LMinMaxI(const LAllocation& first, const LAllocation& second)
: LMinMaxBase(classOpcode, first, second) {}
};
class LMinMaxD : public LMinMaxBase {
public:
LIR_HEADER(MinMaxD)
LMinMaxD(const LAllocation& first, const LAllocation& second)
: LMinMaxBase(classOpcode, first, second) {}
};
class LMinMaxF : public LMinMaxBase {
public:
LIR_HEADER(MinMaxF)
LMinMaxF(const LAllocation& first, const LAllocation& second)
: LMinMaxBase(classOpcode, first, second) {}
};
class LMinMaxArrayI : public LInstructionHelper<1, 1, 3> {
public:
LIR_HEADER(MinMaxArrayI);
LMinMaxArrayI(const LAllocation& array, const LDefinition& temp0,
const LDefinition& temp1, const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, array);
setTemp(0, temp0);
setTemp(1, temp1);
setTemp(2, temp2);
}
const LAllocation* array() { return getOperand(0); }
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const LDefinition* temp3() { return getTemp(2); }
bool isMax() const { return mir_->toMinMaxArray()->isMax(); }
};
class LMinMaxArrayD : public LInstructionHelper<1, 1, 3> {
public:
LIR_HEADER(MinMaxArrayD);
LMinMaxArrayD(const LAllocation& array, const LDefinition& floatTemp,
const LDefinition& temp1, const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, array);
setTemp(0, floatTemp);
setTemp(1, temp1);
setTemp(2, temp2);
}
const LAllocation* array() { return getOperand(0); }
const LDefinition* floatTemp() { return getTemp(0); }
const LDefinition* temp1() { return getTemp(1); }
const LDefinition* temp2() { return getTemp(2); }
bool isMax() const { return mir_->toMinMaxArray()->isMax(); }
};
// Copysign for doubles.
class LCopySignD : public LInstructionHelper<1, 2, 2> {
public:
LIR_HEADER(CopySignD)
explicit LCopySignD() : LInstructionHelper(classOpcode) {}
};
// Copysign for float32.
class LCopySignF : public LInstructionHelper<1, 2, 2> {
public:
LIR_HEADER(CopySignF)
explicit LCopySignF() : LInstructionHelper(classOpcode) {}
};
class LAtan2D : public LCallInstructionHelper<1, 2, 0> {
public:
LIR_HEADER(Atan2D)
LAtan2D(const LAllocation& y, const LAllocation& x)
: LCallInstructionHelper(classOpcode) {
setOperand(0, y);
setOperand(1, x);
}
const LAllocation* y() { return getOperand(0); }
const LAllocation* x() { return getOperand(1); }
const LDefinition* output() { return getDef(0); }
};
class LHypot : public LCallInstructionHelper<1, 4, 0> {
uint32_t numOperands_;
public:
LIR_HEADER(Hypot)
LHypot(const LAllocation& x, const LAllocation& y)
: LCallInstructionHelper(classOpcode), numOperands_(2) {
setOperand(0, x);
setOperand(1, y);
}
LHypot(const LAllocation& x, const LAllocation& y, const LAllocation& z)
: LCallInstructionHelper(classOpcode), numOperands_(3) {
setOperand(0, x);
setOperand(1, y);
setOperand(2, z);
}
LHypot(const LAllocation& x, const LAllocation& y, const LAllocation& z,
const LAllocation& w)
: LCallInstructionHelper(classOpcode), numOperands_(4) {
setOperand(0, x);
setOperand(1, y);
setOperand(2, z);
setOperand(3, w);
}
uint32_t numArgs() const { return numOperands_; }
const LAllocation* x() { return getOperand(0); }
const LAllocation* y() { return getOperand(1); }
const LDefinition* output() { return getDef(0); }
};
class LMathFunctionD : public LCallInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(MathFunctionD)
explicit LMathFunctionD(const LAllocation& input)
: LCallInstructionHelper(classOpcode) {
setOperand(0, input);
}
MMathFunction* mir() const { return mir_->toMathFunction(); }
const char* extraName() const {
return MMathFunction::FunctionName(mir()->function());
}
};
class LMathFunctionF : public LCallInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(MathFunctionF)
explicit LMathFunctionF(const LAllocation& input)
: LCallInstructionHelper(classOpcode) {
setOperand(0, input);
}
MMathFunction* mir() const { return mir_->toMathFunction(); }
const char* extraName() const {
return MMathFunction::FunctionName(mir()->function());
}
};
// Adds two integers, returning an integer value.
class LAddI : public LBinaryMath<0> {
bool recoversInput_;
public:
LIR_HEADER(AddI)
LAddI() : LBinaryMath(classOpcode), recoversInput_(false) {}
const char* extraName() const {
return snapshot() ? "OverflowCheck" : nullptr;
}
bool recoversInput() const { return recoversInput_; }
void setRecoversInput() { recoversInput_ = true; }
MAdd* mir() const { return mir_->toAdd(); }
};
class LAddI64 : public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0> {
public:
LIR_HEADER(AddI64)
LAddI64() : LInstructionHelper(classOpcode) {}
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
};
// Subtracts two integers, returning an integer value.
class LSubI : public LBinaryMath<0> {
bool recoversInput_;
public:
LIR_HEADER(SubI)
LSubI() : LBinaryMath(classOpcode), recoversInput_(false) {}
const char* extraName() const {
return snapshot() ? "OverflowCheck" : nullptr;
}
bool recoversInput() const { return recoversInput_; }
void setRecoversInput() { recoversInput_ = true; }
MSub* mir() const { return mir_->toSub(); }
};
inline bool LNode::recoversInput() const {
switch (op()) {
case Opcode::AddI:
return toAddI()->recoversInput();
case Opcode::SubI:
return toSubI()->recoversInput();
default:
return false;
}
}
class LSubI64 : public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0> {
public:
LIR_HEADER(SubI64)
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
LSubI64() : LInstructionHelper(classOpcode) {}
};
class LMulI64 : public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 1> {
public:
LIR_HEADER(MulI64)
explicit LMulI64() : LInstructionHelper(classOpcode) {
setTemp(0, LDefinition());
}
const LDefinition* temp() { return getTemp(0); }
static const size_t Lhs = 0;
static const size_t Rhs = INT64_PIECES;
};
// Performs an add, sub, mul, or div on two double values.
class LMathD : public LBinaryMath<0> {
JSOp jsop_;
public:
LIR_HEADER(MathD)
explicit LMathD(JSOp jsop) : LBinaryMath(classOpcode), jsop_(jsop) {}
JSOp jsop() const { return jsop_; }
const char* extraName() const { return CodeName(jsop_); }
};
// Performs an add, sub, mul, or div on two double values.
class LMathF : public LBinaryMath<0> {
JSOp jsop_;
public:
LIR_HEADER(MathF)
explicit LMathF(JSOp jsop) : LBinaryMath(classOpcode), jsop_(jsop) {}
JSOp jsop() const { return jsop_; }
const char* extraName() const { return CodeName(jsop_); }
};
class LModD : public LBinaryMath<1> {
public:
LIR_HEADER(ModD)
LModD(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setIsCall();
}
MMod* mir() const { return mir_->toMod(); }
};
class LModPowTwoD : public LInstructionHelper<1, 1, 0> {
const uint32_t divisor_;
public:
LIR_HEADER(ModPowTwoD)
LModPowTwoD(const LAllocation& lhs, uint32_t divisor)
: LInstructionHelper(classOpcode), divisor_(divisor) {
setOperand(0, lhs);
}
uint32_t divisor() const { return divisor_; }
const LAllocation* lhs() { return getOperand(0); }
MMod* mir() const { return mir_->toMod(); }
};
class LBigIntAdd : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntAdd)
LBigIntAdd(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntSub : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntSub)
LBigIntSub(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntMul : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntMul)
LBigIntMul(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntDiv : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntDiv)
LBigIntDiv(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const MBigIntDiv* mir() const { return mirRaw()->toBigIntDiv(); }
};
class LBigIntMod : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntMod)
LBigIntMod(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const MBigIntMod* mir() const { return mirRaw()->toBigIntMod(); }
};
class LBigIntPow : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntPow)
LBigIntPow(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const MBigIntPow* mir() const { return mirRaw()->toBigIntPow(); }
};
class LBigIntBitAnd : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntBitAnd)
LBigIntBitAnd(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntBitOr : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntBitOr)
LBigIntBitOr(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntBitXor : public LBinaryMath<2> {
public:
LIR_HEADER(BigIntBitXor)
LBigIntBitXor(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntLsh : public LBinaryMath<3> {
public:
LIR_HEADER(BigIntLsh)
LBigIntLsh(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2,
const LDefinition& temp3)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
setTemp(2, temp3);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const LDefinition* temp3() { return getTemp(2); }
};
class LBigIntRsh : public LBinaryMath<3> {
public:
LIR_HEADER(BigIntRsh)
LBigIntRsh(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp1, const LDefinition& temp2,
const LDefinition& temp3)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
setTemp(0, temp1);
setTemp(1, temp2);
setTemp(2, temp3);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
const LDefinition* temp3() { return getTemp(2); }
};
class LBigIntIncrement : public LUnaryMath<2> {
public:
LIR_HEADER(BigIntIncrement)
LBigIntIncrement(const LAllocation& input, const LDefinition& temp1,
const LDefinition& temp2)
: LUnaryMath(classOpcode) {
setOperand(0, input);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntDecrement : public LUnaryMath<2> {
public:
LIR_HEADER(BigIntDecrement)
LBigIntDecrement(const LAllocation& input, const LDefinition& temp1,
const LDefinition& temp2)
: LUnaryMath(classOpcode) {
setOperand(0, input);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
class LBigIntNegate : public LUnaryMath<1> {
public:
LIR_HEADER(BigIntNegate)
LBigIntNegate(const LAllocation& input, const LDefinition& temp)
: LUnaryMath(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
}
const LDefinition* temp() { return getTemp(0); }
};
class LBigIntBitNot : public LUnaryMath<2> {
public:
LIR_HEADER(BigIntBitNot)
LBigIntBitNot(const LAllocation& input, const LDefinition& temp1,
const LDefinition& temp2)
: LUnaryMath(classOpcode) {
setOperand(0, input);
setTemp(0, temp1);
setTemp(1, temp2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
};
// Convert a value to an int32.
// Input: components of a Value
// Output: 32-bit integer
// Bailout: undefined, string, object, or non-int32 double
// Temps: one float register, one GP register
//
// This instruction requires a temporary float register.
class LValueToInt32 : public LInstructionHelper<1, BOX_PIECES, 2> {
public:
enum Mode { NORMAL, TRUNCATE };
private:
Mode mode_;
public:
LIR_HEADER(ValueToInt32)
LValueToInt32(const LBoxAllocation& input, const LDefinition& temp0,
const LDefinition& temp1, Mode mode)
: LInstructionHelper(classOpcode), mode_(mode) {
setBoxOperand(Input, input);
setTemp(0, temp0);
setTemp(1, temp1);
}
const char* extraName() const {
switch (mode()) {
case NORMAL:
return "Normal";
case TRUNCATE:
return "Truncate";
}
MOZ_CRASH("Invalid mode");
}
static const size_t Input = 0;
Mode mode() const { return mode_; }
const LDefinition* tempFloat() { return getTemp(0); }
const LDefinition* temp() { return getTemp(1); }
MToNumberInt32* mirNormal() const {
MOZ_ASSERT(mode_ == NORMAL);
return mir_->toToNumberInt32();
}
MTruncateToInt32* mirTruncate() const {
MOZ_ASSERT(mode_ == TRUNCATE);
return mir_->toTruncateToInt32();
}
MInstruction* mir() const { return mir_->toInstruction(); }
};
// Double raised to a half power.
class LPowHalfD : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(PowHalfD);
explicit LPowHalfD(const LAllocation& input)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* output() { return getDef(0); }
MPowHalf* mir() const { return mir_->toPowHalf(); }
};
// Passed the BaselineFrame address in the OsrFrameReg via the IonOsrTempData
// populated by PrepareOsrTempData.
//
// Forwards this object to the LOsrValues for Value materialization.
class LOsrEntry : public LInstructionHelper<1, 0, 1> {
protected:
Label label_;
uint32_t frameDepth_;
public:
LIR_HEADER(OsrEntry)
explicit LOsrEntry(const LDefinition& temp)
: LInstructionHelper(classOpcode), frameDepth_(0) {
setTemp(0, temp);
}
void setFrameDepth(uint32_t depth) { frameDepth_ = depth; }
uint32_t getFrameDepth() { return frameDepth_; }
Label* label() { return &label_; }
const LDefinition* temp() { return getTemp(0); }
};
// Bailout if index + minimum < 0 or index + maximum >= length.
class LBoundsCheckRange : public LInstructionHelper<0, 2, 1> {
public:
LIR_HEADER(BoundsCheckRange)
LBoundsCheckRange(const LAllocation& index, const LAllocation& length,
const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, index);
setOperand(1, length);
setTemp(0, temp);
}
const MBoundsCheck* mir() const { return mir_->toBoundsCheck(); }
const LAllocation* index() { return getOperand(0); }
const LAllocation* length() { return getOperand(1); }
};
// Load a value from a dense array's elements vector. Bail out if it's the hole
// value.
class LLoadElementV : public LInstructionHelper<BOX_PIECES, 2, 0> {
public:
LIR_HEADER(LoadElementV)
LLoadElementV(const LAllocation& elements, const LAllocation& index)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
}
const MLoadElement* mir() const { return mir_->toLoadElement(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
};
// Load a value from an array's elements vector, loading |undefined| if we hit a
// hole. Bail out if we get a negative index.
class LLoadElementHole : public LInstructionHelper<BOX_PIECES, 3, 0> {
public:
LIR_HEADER(LoadElementHole)
LLoadElementHole(const LAllocation& elements, const LAllocation& index,
const LAllocation& initLength)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, initLength);
}
const MLoadElementHole* mir() const { return mir_->toLoadElementHole(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* initLength() { return getOperand(2); }
};
// Store a boxed value to a dense array's element vector.
class LStoreElementV : public LInstructionHelper<0, 2 + BOX_PIECES, 0> {
public:
LIR_HEADER(StoreElementV)
LStoreElementV(const LAllocation& elements, const LAllocation& index,
const LBoxAllocation& value)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setBoxOperand(Value, value);
}
const char* extraName() const {
return mir()->needsHoleCheck() ? "HoleCheck" : nullptr;
}
static const size_t Value = 2;
const MStoreElement* mir() const { return mir_->toStoreElement(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
};
// Store a typed value to a dense array's elements vector. Compared to
// LStoreElementV, this instruction can store doubles and constants directly,
// and does not store the type tag if the array is monomorphic and known to
// be packed.
class LStoreElementT : public LInstructionHelper<0, 3, 0> {
public:
LIR_HEADER(StoreElementT)
LStoreElementT(const LAllocation& elements, const LAllocation& index,
const LAllocation& value)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
}
const char* extraName() const {
return mir()->needsHoleCheck() ? "HoleCheck" : nullptr;
}
const MStoreElement* mir() const { return mir_->toStoreElement(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
};
class LArrayPopShift : public LInstructionHelper<BOX_PIECES, 1, 2> {
public:
LIR_HEADER(ArrayPopShift)
LArrayPopShift(const LAllocation& object, const LDefinition& temp0,
const LDefinition& temp1)
: LInstructionHelper(classOpcode) {
setOperand(0, object);
setTemp(0, temp0);
setTemp(1, temp1);
}
const char* extraName() const {
return mir()->mode() == MArrayPopShift::Pop ? "Pop" : "Shift";
}
const MArrayPopShift* mir() const { return mir_->toArrayPopShift(); }
const LAllocation* object() { return getOperand(0); }
const LDefinition* temp0() { return getTemp(0); }
const LDefinition* temp1() { return getTemp(1); }
};
class LLoadUnboxedBigInt : public LInstructionHelper<1, 2, 1 + INT64_PIECES> {
public:
LIR_HEADER(LoadUnboxedBigInt)
LLoadUnboxedBigInt(const LAllocation& elements, const LAllocation& index,
const LDefinition& temp, const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const MLoadUnboxedScalar* mir() const { return mir_->toLoadUnboxedScalar(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LDefinition* temp() { return getTemp(0); }
const LInt64Definition temp64() { return getInt64Temp(1); }
};
class LLoadDataViewElement : public LInstructionHelper<1, 3, 1 + INT64_PIECES> {
public:
LIR_HEADER(LoadDataViewElement)
LLoadDataViewElement(const LAllocation& elements, const LAllocation& index,
const LAllocation& littleEndian, const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, littleEndian);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const MLoadDataViewElement* mir() const {
return mir_->toLoadDataViewElement();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* littleEndian() { return getOperand(2); }
const LDefinition* temp() { return getTemp(0); }
const LInt64Definition temp64() { return getInt64Temp(1); }
};
class LLoadTypedArrayElementHoleBigInt
: public LInstructionHelper<BOX_PIECES, 3, 1 + INT64_PIECES> {
public:
LIR_HEADER(LoadTypedArrayElementHoleBigInt)
LLoadTypedArrayElementHoleBigInt(const LAllocation& elements,
const LAllocation& index,
const LAllocation& length,
const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, length);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const MLoadTypedArrayElementHole* mir() const {
return mir_->toLoadTypedArrayElementHole();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* length() { return getOperand(2); }
const LDefinition* temp() { return getTemp(0); }
const LInt64Definition temp64() { return getInt64Temp(1); }
};
class LStoreUnboxedBigInt : public LInstructionHelper<0, 3, INT64_PIECES> {
public:
LIR_HEADER(StoreUnboxedBigInt)
LStoreUnboxedBigInt(const LAllocation& elements, const LAllocation& index,
const LAllocation& value, const LInt64Definition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp);
}
const MStoreUnboxedScalar* mir() const {
return mir_->toStoreUnboxedScalar();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
LInt64Definition temp() { return getInt64Temp(0); }
};
class LStoreDataViewElement
: public LInstructionHelper<0, 4, 1 + INT64_PIECES> {
public:
LIR_HEADER(StoreDataViewElement)
LStoreDataViewElement(const LAllocation& elements, const LAllocation& index,
const LAllocation& value,
const LAllocation& littleEndian,
const LDefinition& temp, const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setOperand(3, littleEndian);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const MStoreDataViewElement* mir() const {
return mir_->toStoreDataViewElement();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
const LAllocation* littleEndian() { return getOperand(3); }
const LDefinition* temp() { return getTemp(0); }
const LInt64Definition temp64() { return getInt64Temp(1); }
};
class LStoreTypedArrayElementHoleBigInt
: public LInstructionHelper<0, 4, INT64_PIECES> {
public:
LIR_HEADER(StoreTypedArrayElementHoleBigInt)
LStoreTypedArrayElementHoleBigInt(const LAllocation& elements,
const LAllocation& length,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, length);
setOperand(2, index);
setOperand(3, value);
setInt64Temp(0, temp);
}
const MStoreTypedArrayElementHole* mir() const {
return mir_->toStoreTypedArrayElementHole();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* length() { return getOperand(1); }
const LAllocation* index() { return getOperand(2); }
const LAllocation* value() { return getOperand(3); }
LInt64Definition temp() { return getInt64Temp(0); }
};
class LCompareExchangeTypedArrayElement : public LInstructionHelper<1, 4, 4> {
public:
LIR_HEADER(CompareExchangeTypedArrayElement)
// ARM, ARM64, x86, x64
LCompareExchangeTypedArrayElement(const LAllocation& elements,
const LAllocation& index,
const LAllocation& oldval,
const LAllocation& newval,
const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, oldval);
setOperand(3, newval);
setTemp(0, temp);
}
// MIPS32, MIPS64
LCompareExchangeTypedArrayElement(
const LAllocation& elements, const LAllocation& index,
const LAllocation& oldval, const LAllocation& newval,
const LDefinition& temp, const LDefinition& valueTemp,
const LDefinition& offsetTemp, const LDefinition& maskTemp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, oldval);
setOperand(3, newval);
setTemp(0, temp);
setTemp(1, valueTemp);
setTemp(2, offsetTemp);
setTemp(3, maskTemp);
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* oldval() { return getOperand(2); }
const LAllocation* newval() { return getOperand(3); }
const LDefinition* temp() { return getTemp(0); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(1); }
const LDefinition* offsetTemp() { return getTemp(2); }
const LDefinition* maskTemp() { return getTemp(3); }
const MCompareExchangeTypedArrayElement* mir() const {
return mir_->toCompareExchangeTypedArrayElement();
}
};
class LAtomicExchangeTypedArrayElement : public LInstructionHelper<1, 3, 4> {
public:
LIR_HEADER(AtomicExchangeTypedArrayElement)
// ARM, ARM64, x86, x64
LAtomicExchangeTypedArrayElement(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, temp);
}
// MIPS32, MIPS64
LAtomicExchangeTypedArrayElement(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LDefinition& temp,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, temp);
setTemp(1, valueTemp);
setTemp(2, offsetTemp);
setTemp(3, maskTemp);
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
const LDefinition* temp() { return getTemp(0); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(1); }
const LDefinition* offsetTemp() { return getTemp(2); }
const LDefinition* maskTemp() { return getTemp(3); }
const MAtomicExchangeTypedArrayElement* mir() const {
return mir_->toAtomicExchangeTypedArrayElement();
}
};
class LAtomicTypedArrayElementBinop : public LInstructionHelper<1, 3, 5> {
public:
LIR_HEADER(AtomicTypedArrayElementBinop)
static const int32_t valueOp = 2;
// ARM, ARM64, x86, x64
LAtomicTypedArrayElementBinop(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LDefinition& temp1,
const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, temp1);
setTemp(1, temp2);
}
// MIPS32, MIPS64
LAtomicTypedArrayElementBinop(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LDefinition& temp2,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, temp2);
setTemp(2, valueTemp);
setTemp(3, offsetTemp);
setTemp(4, maskTemp);
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() {
MOZ_ASSERT(valueOp == 2);
return getOperand(2);
}
const LDefinition* temp1() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(2); }
const LDefinition* offsetTemp() { return getTemp(3); }
const LDefinition* maskTemp() { return getTemp(4); }
const MAtomicTypedArrayElementBinop* mir() const {
return mir_->toAtomicTypedArrayElementBinop();
}
};
// Atomic binary operation where the result is discarded.
class LAtomicTypedArrayElementBinopForEffect
: public LInstructionHelper<0, 3, 4> {
public:
LIR_HEADER(AtomicTypedArrayElementBinopForEffect)
// ARM, ARM64, x86, x64
LAtomicTypedArrayElementBinopForEffect(
const LAllocation& elements, const LAllocation& index,
const LAllocation& value,
const LDefinition& flagTemp = LDefinition::BogusTemp())
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, flagTemp);
}
// MIPS32, MIPS64
LAtomicTypedArrayElementBinopForEffect(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, valueTemp);
setTemp(2, offsetTemp);
setTemp(3, maskTemp);
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
// Temp that may be used on LL/SC platforms for the flag result of the store.
const LDefinition* flagTemp() { return getTemp(0); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(1); }
const LDefinition* offsetTemp() { return getTemp(2); }
const LDefinition* maskTemp() { return getTemp(3); }
const MAtomicTypedArrayElementBinop* mir() const {
return mir_->toAtomicTypedArrayElementBinop();
}
};
class LAtomicLoad64 : public LInstructionHelper<1, 2, 1 + INT64_PIECES> {
public:
LIR_HEADER(AtomicLoad64)
LAtomicLoad64(const LAllocation& elements, const LAllocation& index,
const LDefinition& temp, const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const MLoadUnboxedScalar* mir() const { return mir_->toLoadUnboxedScalar(); }
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LDefinition* temp() { return getTemp(0); }
LInt64Definition temp64() { return getInt64Temp(1); }
};
class LAtomicStore64 : public LInstructionHelper<0, 3, 2 * INT64_PIECES + 1> {
public:
LIR_HEADER(AtomicStore64)
// x64, ARM64
LAtomicStore64(const LAllocation& elements, const LAllocation& index,
const LAllocation& value, const LInt64Definition& temp1)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(2 * INT64_PIECES, LDefinition::BogusTemp());
}
// ARM32
LAtomicStore64(const LAllocation& elements, const LAllocation& index,
const LAllocation& value, const LInt64Definition& temp1,
const LInt64Definition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setTemp(2 * INT64_PIECES, LDefinition::BogusTemp());
}
// x86
LAtomicStore64(const LAllocation& elements, const LAllocation& index,
const LAllocation& value, const LInt64Definition& temp1,
const LDefinition& tempLow)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(2 * INT64_PIECES, tempLow);
}
const MStoreUnboxedScalar* mir() const {
return mir_->toStoreUnboxedScalar();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
LInt64Definition temp1() { return getInt64Temp(0); }
LInt64Definition temp2() { return getInt64Temp(INT64_PIECES); }
const LDefinition* tempLow() { return getTemp(2 * INT64_PIECES); }
};
class LCompareExchangeTypedArrayElement64
: public LInstructionHelper<1, 4, 3 * INT64_PIECES + 1> {
public:
LIR_HEADER(CompareExchangeTypedArrayElement64)
// x64, ARM64
LCompareExchangeTypedArrayElement64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& oldval,
const LAllocation& newval,
const LInt64Definition& temp1,
const LInt64Definition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, oldval);
setOperand(3, newval);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setInt64Temp(2 * INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(3 * INT64_PIECES, LDefinition::BogusTemp());
}
// x86
LCompareExchangeTypedArrayElement64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& oldval,
const LAllocation& newval,
const LDefinition& tempLow)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, oldval);
setOperand(3, newval);
setInt64Temp(0, LInt64Definition::BogusTemp());
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setInt64Temp(2 * INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(3 * INT64_PIECES, tempLow);
}
// ARM
LCompareExchangeTypedArrayElement64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& oldval,
const LAllocation& newval,
const LInt64Definition& temp1,
const LInt64Definition& temp2,
const LInt64Definition& temp3)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, oldval);
setOperand(3, newval);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setInt64Temp(2 * INT64_PIECES, temp3);
setTemp(3 * INT64_PIECES, LDefinition::BogusTemp());
}
const MCompareExchangeTypedArrayElement* mir() const {
return mir_->toCompareExchangeTypedArrayElement();
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* oldval() { return getOperand(2); }
const LAllocation* newval() { return getOperand(3); }
LInt64Definition temp1() { return getInt64Temp(0); }
LInt64Definition temp2() { return getInt64Temp(INT64_PIECES); }
LInt64Definition temp3() { return getInt64Temp(2 * INT64_PIECES); }
const LDefinition* tempLow() { return getTemp(3 * INT64_PIECES); }
};
class LAtomicExchangeTypedArrayElement64
: public LInstructionHelper<1, 3, INT64_PIECES + 1> {
public:
LIR_HEADER(AtomicExchangeTypedArrayElement64)
// ARM, ARM64, x64
LAtomicExchangeTypedArrayElement64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp1,
const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setTemp(INT64_PIECES, temp2);
}
// x86
LAtomicExchangeTypedArrayElement64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp);
setTemp(INT64_PIECES, LDefinition::BogusTemp());
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
LInt64Definition temp1() { return getInt64Temp(0); }
const LDefinition* temp2() { return getTemp(INT64_PIECES); }
const MAtomicExchangeTypedArrayElement* mir() const {
return mir_->toAtomicExchangeTypedArrayElement();
}
};
class LAtomicTypedArrayElementBinop64
: public LInstructionHelper<1, 3, 3 * INT64_PIECES> {
public:
LIR_HEADER(AtomicTypedArrayElementBinop64)
// x86
LAtomicTypedArrayElementBinop64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp1)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setInt64Temp(2 * INT64_PIECES, LInt64Definition::BogusTemp());
}
// ARM64, x64
LAtomicTypedArrayElementBinop64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp1,
const LInt64Definition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setInt64Temp(2 * INT64_PIECES, LInt64Definition::BogusTemp());
}
// ARM
LAtomicTypedArrayElementBinop64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp1,
const LInt64Definition& temp2,
const LInt64Definition& temp3)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setInt64Temp(2 * INT64_PIECES, temp3);
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
LInt64Definition temp1() { return getInt64Temp(0); }
LInt64Definition temp2() { return getInt64Temp(INT64_PIECES); }
LInt64Definition temp3() { return getInt64Temp(2 * INT64_PIECES); }
const MAtomicTypedArrayElementBinop* mir() const {
return mir_->toAtomicTypedArrayElementBinop();
}
};
// Atomic binary operation where the result is discarded.
class LAtomicTypedArrayElementBinopForEffect64
: public LInstructionHelper<0, 3, 2 * INT64_PIECES + 1> {
public:
LIR_HEADER(AtomicTypedArrayElementBinopForEffect64)
// x86
LAtomicTypedArrayElementBinopForEffect64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp,
const LDefinition& tempLow)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp);
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(2 * INT64_PIECES, tempLow);
}
// x64
LAtomicTypedArrayElementBinopForEffect64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp);
setInt64Temp(INT64_PIECES, LInt64Definition::BogusTemp());
setTemp(2 * INT64_PIECES, LDefinition::BogusTemp());
}
// ARM64
LAtomicTypedArrayElementBinopForEffect64(const LAllocation& elements,
const LAllocation& index,
const LAllocation& value,
const LInt64Definition& temp1,
const LInt64Definition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
setInt64Temp(0, temp1);
setInt64Temp(INT64_PIECES, temp2);
setTemp(2 * INT64_PIECES, LDefinition::BogusTemp());
}
const LAllocation* elements() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
const LAllocation* value() { return getOperand(2); }
LInt64Definition temp1() { return getInt64Temp(0); }
LInt64Definition temp2() { return getInt64Temp(INT64_PIECES); }
const LDefinition* tempLow() { return getTemp(2 * INT64_PIECES); }
const MAtomicTypedArrayElementBinop* mir() const {
return mir_->toAtomicTypedArrayElementBinop();
}
};
class LIteratorHasIndicesAndBranch : public LControlInstructionHelper<2, 2, 2> {
public:
LIR_HEADER(IteratorHasIndicesAndBranch)
LIteratorHasIndicesAndBranch(MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LAllocation& object,
const LAllocation& iterator,
const LDefinition& temp,
const LDefinition& temp2)
: LControlInstructionHelper(classOpcode) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setOperand(0, object);
setOperand(1, iterator);
setTemp(0, temp);
setTemp(1, temp2);
}
const LAllocation* object() { return getOperand(0); }
const LAllocation* iterator() { return getOperand(1); }
const LDefinition* temp() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
class LIsNoIterAndBranch : public LControlInstructionHelper<2, BOX_PIECES, 0> {
public:
LIR_HEADER(IsNoIterAndBranch)
LIsNoIterAndBranch(MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LBoxAllocation& input)
: LControlInstructionHelper(classOpcode) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Input, input);
}
static const size_t Input = 0;
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
class LInstanceOfCache : public LInstructionHelper<1, BOX_PIECES + 1, 0> {
public:
LIR_HEADER(InstanceOfCache)
LInstanceOfCache(const LBoxAllocation& lhs, const LAllocation& rhs)
: LInstructionHelper(classOpcode) {
setBoxOperand(LHS, lhs);
setOperand(RHS, rhs);
}
const LDefinition* output() { return this->getDef(0); }
const LAllocation* rhs() { return getOperand(RHS); }
static const size_t LHS = 0;
static const size_t RHS = BOX_PIECES;
};
class LIsObjectAndBranch : public LControlInstructionHelper<2, BOX_PIECES, 0> {
public:
LIR_HEADER(IsObjectAndBranch)
LIsObjectAndBranch(MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LBoxAllocation& input)
: LControlInstructionHelper(classOpcode) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Input, input);
}
static const size_t Input = 0;
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
};
class LIsNullOrUndefinedAndBranch
: public LControlInstructionHelper<2, BOX_PIECES, 0> {
MIsNullOrUndefined* isNullOrUndefined_;
public:
LIR_HEADER(IsNullOrUndefinedAndBranch)
static const size_t Input = 0;
LIsNullOrUndefinedAndBranch(MIsNullOrUndefined* isNullOrUndefined,
MBasicBlock* ifTrue, MBasicBlock* ifFalse,
const LBoxAllocation& input)
: LControlInstructionHelper(classOpcode),
isNullOrUndefined_(isNullOrUndefined) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setBoxOperand(Input, input);
}
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
MIsNullOrUndefined* isNullOrUndefinedMir() const {
return isNullOrUndefined_;
}
};
template <size_t Defs, size_t Ops>
class LWasmSelectBase : public LInstructionHelper<Defs, Ops, 0> {
typedef LInstructionHelper<Defs, Ops, 0> Base;
protected:
explicit LWasmSelectBase(LNode::Opcode opcode) : Base(opcode) {}
public:
MWasmSelect* mir() const { return Base::mir_->toWasmSelect(); }
};
class LWasmSelect : public LWasmSelectBase<1, 3> {
public:
LIR_HEADER(WasmSelect);
static const size_t TrueExprIndex = 0;
static const size_t FalseExprIndex = 1;
static const size_t CondIndex = 2;
LWasmSelect(const LAllocation& trueExpr, const LAllocation& falseExpr,
const LAllocation& cond)
: LWasmSelectBase(classOpcode) {
setOperand(TrueExprIndex, trueExpr);
setOperand(FalseExprIndex, falseExpr);
setOperand(CondIndex, cond);
}
const LAllocation* trueExpr() { return getOperand(TrueExprIndex); }
const LAllocation* falseExpr() { return getOperand(FalseExprIndex); }
const LAllocation* condExpr() { return getOperand(CondIndex); }
};
class LWasmSelectI64
: public LWasmSelectBase<INT64_PIECES, 2 * INT64_PIECES + 1> {
public:
LIR_HEADER(WasmSelectI64);
static const size_t TrueExprIndex = 0;
static const size_t FalseExprIndex = INT64_PIECES;
static const size_t CondIndex = INT64_PIECES * 2;
LWasmSelectI64(const LInt64Allocation& trueExpr,
const LInt64Allocation& falseExpr, const LAllocation& cond)
: LWasmSelectBase(classOpcode) {
setInt64Operand(TrueExprIndex, trueExpr);
setInt64Operand(FalseExprIndex, falseExpr);
setOperand(CondIndex, cond);
}
const LInt64Allocation trueExpr() { return getInt64Operand(TrueExprIndex); }
const LInt64Allocation falseExpr() { return getInt64Operand(FalseExprIndex); }
const LAllocation* condExpr() { return getOperand(CondIndex); }
};
class LWasmCompareAndSelect : public LWasmSelectBase<1, 4> {
MCompare::CompareType compareType_;
JSOp jsop_;
public:
LIR_HEADER(WasmCompareAndSelect);
static const size_t LeftExprIndex = 0;
static const size_t RightExprIndex = 1;
static const size_t IfTrueExprIndex = 2;
static const size_t IfFalseExprIndex = 3;
LWasmCompareAndSelect(const LAllocation& leftExpr,
const LAllocation& rightExpr,
MCompare::CompareType compareType, JSOp jsop,
const LAllocation& ifTrueExpr,
const LAllocation& ifFalseExpr)
: LWasmSelectBase(classOpcode), compareType_(compareType), jsop_(jsop) {
setOperand(LeftExprIndex, leftExpr);
setOperand(RightExprIndex, rightExpr);
setOperand(IfTrueExprIndex, ifTrueExpr);
setOperand(IfFalseExprIndex, ifFalseExpr);
}
const LAllocation* leftExpr() { return getOperand(LeftExprIndex); }
const LAllocation* rightExpr() { return getOperand(RightExprIndex); }
const LAllocation* ifTrueExpr() { return getOperand(IfTrueExprIndex); }
const LAllocation* ifFalseExpr() { return getOperand(IfFalseExprIndex); }
MCompare::CompareType compareType() { return compareType_; }
JSOp jsop() { return jsop_; }
};
class LWasmBoundsCheck64
: public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0> {
public:
LIR_HEADER(WasmBoundsCheck64);
explicit LWasmBoundsCheck64(const LInt64Allocation& ptr,
const LInt64Allocation& boundsCheckLimit)
: LInstructionHelper(classOpcode) {
setInt64Operand(0, ptr);
setInt64Operand(INT64_PIECES, boundsCheckLimit);
}
MWasmBoundsCheck* mir() const { return mir_->toWasmBoundsCheck(); }
LInt64Allocation ptr() { return getInt64Operand(0); }
LInt64Allocation boundsCheckLimit() { return getInt64Operand(INT64_PIECES); }
};
namespace details {
// This is a base class for LWasmLoad/LWasmLoadI64.
template <size_t Defs, size_t Temp>
class LWasmLoadBase : public LInstructionHelper<Defs, 2, Temp> {
public:
typedef LInstructionHelper<Defs, 2, Temp> Base;
explicit LWasmLoadBase(LNode::Opcode opcode, const LAllocation& ptr,
const LAllocation& memoryBase)
: Base(opcode) {
Base::setOperand(0, ptr);
Base::setOperand(1, memoryBase);
}
MWasmLoad* mir() const { return Base::mir_->toWasmLoad(); }
const LAllocation* ptr() { return Base::getOperand(0); }
const LAllocation* memoryBase() { return Base::getOperand(1); }
};
} // namespace details
class LWasmLoad : public details::LWasmLoadBase<1, 1> {
public:
explicit LWasmLoad(const LAllocation& ptr,
const LAllocation& memoryBase = LAllocation())
: LWasmLoadBase(classOpcode, ptr, memoryBase) {
setTemp(0, LDefinition::BogusTemp());
}
const LDefinition* ptrCopy() { return Base::getTemp(0); }
LIR_HEADER(WasmLoad);
};
class LWasmLoadI64 : public details::LWasmLoadBase<INT64_PIECES, 2> {
public:
explicit LWasmLoadI64(const LAllocation& ptr,
const LAllocation& memoryBase = LAllocation())
: LWasmLoadBase(classOpcode, ptr, memoryBase) {
setTemp(0, LDefinition::BogusTemp());
setTemp(1, LDefinition::BogusTemp());
}
const LDefinition* ptrCopy() { return Base::getTemp(0); }
const LDefinition* memoryBaseCopy() { return Base::getTemp(1); }
LIR_HEADER(WasmLoadI64);
};
class LWasmStore : public LInstructionHelper<0, 3, 1> {
public:
LIR_HEADER(WasmStore);
static const size_t PtrIndex = 0;
static const size_t ValueIndex = 1;
static const size_t MemoryBaseIndex = 2;
LWasmStore(const LAllocation& ptr, const LAllocation& value,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(PtrIndex, ptr);
setOperand(ValueIndex, value);
setOperand(MemoryBaseIndex, memoryBase);
setTemp(0, LDefinition::BogusTemp());
}
MWasmStore* mir() const { return mir_->toWasmStore(); }
const LAllocation* ptr() { return getOperand(PtrIndex); }
const LDefinition* ptrCopy() { return getTemp(0); }
const LAllocation* value() { return getOperand(ValueIndex); }
const LAllocation* memoryBase() { return getOperand(MemoryBaseIndex); }
};
class LWasmStoreI64 : public LInstructionHelper<0, INT64_PIECES + 2, 1> {
public:
LIR_HEADER(WasmStoreI64);
static const size_t PtrIndex = 0;
static const size_t MemoryBaseIndex = 1;
static const size_t ValueIndex = 2;
LWasmStoreI64(const LAllocation& ptr, const LInt64Allocation& value,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(PtrIndex, ptr);
setOperand(MemoryBaseIndex, memoryBase);
setInt64Operand(ValueIndex, value);
setTemp(0, LDefinition::BogusTemp());
}
MWasmStore* mir() const { return mir_->toWasmStore(); }
const LAllocation* ptr() { return getOperand(PtrIndex); }
const LAllocation* memoryBase() { return getOperand(MemoryBaseIndex); }
const LDefinition* ptrCopy() { return getTemp(0); }
const LInt64Allocation value() { return getInt64Operand(ValueIndex); }
};
class LWasmCompareExchangeHeap : public LInstructionHelper<1, 4, 4> {
public:
LIR_HEADER(WasmCompareExchangeHeap);
// ARM, ARM64, x86, x64
LWasmCompareExchangeHeap(const LAllocation& ptr, const LAllocation& oldValue,
const LAllocation& newValue,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, oldValue);
setOperand(2, newValue);
setOperand(3, memoryBase);
setTemp(0, LDefinition::BogusTemp());
}
// MIPS32, MIPS64, LoongArch64
LWasmCompareExchangeHeap(const LAllocation& ptr, const LAllocation& oldValue,
const LAllocation& newValue,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, oldValue);
setOperand(2, newValue);
setOperand(3, memoryBase);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, valueTemp);
setTemp(2, offsetTemp);
setTemp(3, maskTemp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* oldValue() { return getOperand(1); }
const LAllocation* newValue() { return getOperand(2); }
const LAllocation* memoryBase() { return getOperand(3); }
const LDefinition* addrTemp() { return getTemp(0); }
void setAddrTemp(const LDefinition& addrTemp) { setTemp(0, addrTemp); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(1); }
const LDefinition* offsetTemp() { return getTemp(2); }
const LDefinition* maskTemp() { return getTemp(3); }
MWasmCompareExchangeHeap* mir() const {
return mir_->toWasmCompareExchangeHeap();
}
};
class LWasmAtomicExchangeHeap : public LInstructionHelper<1, 3, 4> {
public:
LIR_HEADER(WasmAtomicExchangeHeap);
// ARM, ARM64, x86, x64
LWasmAtomicExchangeHeap(const LAllocation& ptr, const LAllocation& value,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, LDefinition::BogusTemp());
}
// MIPS32, MIPS64, LoongArch64
LWasmAtomicExchangeHeap(const LAllocation& ptr, const LAllocation& value,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, valueTemp);
setTemp(2, offsetTemp);
setTemp(3, maskTemp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* value() { return getOperand(1); }
const LAllocation* memoryBase() { return getOperand(2); }
const LDefinition* addrTemp() { return getTemp(0); }
void setAddrTemp(const LDefinition& addrTemp) { setTemp(0, addrTemp); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(1); }
const LDefinition* offsetTemp() { return getTemp(2); }
const LDefinition* maskTemp() { return getTemp(3); }
MWasmAtomicExchangeHeap* mir() const {
return mir_->toWasmAtomicExchangeHeap();
}
};
class LWasmAtomicBinopHeap : public LInstructionHelper<1, 3, 6> {
public:
LIR_HEADER(WasmAtomicBinopHeap);
static const int32_t valueOp = 1;
// ARM, ARM64, x86, x64
LWasmAtomicBinopHeap(const LAllocation& ptr, const LAllocation& value,
const LDefinition& temp,
const LDefinition& flagTemp = LDefinition::BogusTemp(),
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, temp);
setTemp(1, LDefinition::BogusTemp());
setTemp(2, flagTemp);
}
// MIPS32, MIPS64, LoongArch64
LWasmAtomicBinopHeap(const LAllocation& ptr, const LAllocation& value,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, LDefinition::BogusTemp());
setTemp(2, LDefinition::BogusTemp());
setTemp(3, valueTemp);
setTemp(4, offsetTemp);
setTemp(5, maskTemp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* value() {
MOZ_ASSERT(valueOp == 1);
return getOperand(1);
}
const LAllocation* memoryBase() { return getOperand(2); }
const LDefinition* temp() { return getTemp(0); }
// Temp that may be used on some platforms to hold a computed address.
const LDefinition* addrTemp() { return getTemp(1); }
void setAddrTemp(const LDefinition& addrTemp) { setTemp(1, addrTemp); }
// Temp that may be used on LL/SC platforms for the flag result of the store.
const LDefinition* flagTemp() { return getTemp(2); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(3); }
const LDefinition* offsetTemp() { return getTemp(4); }
const LDefinition* maskTemp() { return getTemp(5); }
MWasmAtomicBinopHeap* mir() const { return mir_->toWasmAtomicBinopHeap(); }
};
// Atomic binary operation where the result is discarded.
class LWasmAtomicBinopHeapForEffect : public LInstructionHelper<0, 3, 5> {
public:
LIR_HEADER(WasmAtomicBinopHeapForEffect);
// ARM, ARM64, x86, x64
LWasmAtomicBinopHeapForEffect(
const LAllocation& ptr, const LAllocation& value,
const LDefinition& flagTemp = LDefinition::BogusTemp(),
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, flagTemp);
}
// MIPS32, MIPS64, LoongArch64
LWasmAtomicBinopHeapForEffect(const LAllocation& ptr,
const LAllocation& value,
const LDefinition& valueTemp,
const LDefinition& offsetTemp,
const LDefinition& maskTemp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, value);
setOperand(2, memoryBase);
setTemp(0, LDefinition::BogusTemp());
setTemp(1, LDefinition::BogusTemp());
setTemp(2, valueTemp);
setTemp(3, offsetTemp);
setTemp(4, maskTemp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* value() { return getOperand(1); }
const LAllocation* memoryBase() { return getOperand(2); }
// Temp that may be used on some platforms to hold a computed address.
const LDefinition* addrTemp() { return getTemp(0); }
void setAddrTemp(const LDefinition& addrTemp) { setTemp(0, addrTemp); }
// Temp that may be used on LL/SC platforms for the flag result of the store.
const LDefinition* flagTemp() { return getTemp(1); }
// Temp that may be used on LL/SC platforms for extract/insert bits of word.
const LDefinition* valueTemp() { return getTemp(2); }
const LDefinition* offsetTemp() { return getTemp(3); }
const LDefinition* maskTemp() { return getTemp(4); }
MWasmAtomicBinopHeap* mir() const { return mir_->toWasmAtomicBinopHeap(); }
};
class LWasmDerivedPointer : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(WasmDerivedPointer);
explicit LWasmDerivedPointer(const LAllocation& base)
: LInstructionHelper(classOpcode) {
setOperand(0, base);
}
const LAllocation* base() { return getOperand(0); }
uint32_t offset() { return mirRaw()->toWasmDerivedPointer()->offset(); }
};
class LWasmDerivedIndexPointer : public LInstructionHelper<1, 2, 0> {
public:
LIR_HEADER(WasmDerivedIndexPointer);
explicit LWasmDerivedIndexPointer(const LAllocation& base,
const LAllocation& index)
: LInstructionHelper(classOpcode) {
setOperand(0, base);
setOperand(1, index);
}
const LAllocation* base() { return getOperand(0); }
const LAllocation* index() { return getOperand(1); }
Scale scale() { return mirRaw()->toWasmDerivedIndexPointer()->scale(); }
};
class LWasmParameterI64 : public LInstructionHelper<INT64_PIECES, 0, 0> {
public:
LIR_HEADER(WasmParameterI64);
LWasmParameterI64() : LInstructionHelper(classOpcode) {}
};
// This is used only with LWasmCall.
class LWasmCallIndirectAdjunctSafepoint : public LInstructionHelper<0, 0, 0> {
CodeOffset offs_;
uint32_t framePushedAtStackMapBase_;
public:
LIR_HEADER(WasmCallIndirectAdjunctSafepoint);
LWasmCallIndirectAdjunctSafepoint()
: LInstructionHelper(classOpcode),
offs_(0),
framePushedAtStackMapBase_(0) {
// Ensure that the safepoint does not get live registers associated with it.
setIsCall();
}
CodeOffset safepointLocation() const {
MOZ_ASSERT(offs_.offset() != 0);
return offs_;
}
uint32_t framePushedAtStackMapBase() const {
MOZ_ASSERT(offs_.offset() != 0);
return framePushedAtStackMapBase_;
}
void recordSafepointInfo(CodeOffset offs, uint32_t framePushed) {
offs_ = offs;
framePushedAtStackMapBase_ = framePushed;
}
};
// LWasmCall may be generated into two function calls in the case of
// call_indirect, one for the fast path and one for the slow path. In that
// case, the node carries a pointer to a companion node, the "adjunct
// safepoint", representing the safepoint for the second of the two calls. The
// dual-call construction is only meaningful for wasm because wasm has no
// invalidation of code; this is not a pattern to be used generally.
class LWasmCall : public LVariadicInstruction<0, 0> {
bool needsBoundsCheck_;
mozilla::Maybe<uint32_t> tableSize_;
LWasmCallIndirectAdjunctSafepoint* adjunctSafepoint_;
public:
LIR_HEADER(WasmCall);
LWasmCall(uint32_t numOperands, bool needsBoundsCheck,
mozilla::Maybe<uint32_t> tableSize = mozilla::Nothing())
: LVariadicInstruction(classOpcode, numOperands),
needsBoundsCheck_(needsBoundsCheck),
tableSize_(tableSize),
adjunctSafepoint_(nullptr) {
this->setIsCall();
}
MWasmCallBase* callBase() const {
if (isCatchable() && !isReturnCall()) {
return static_cast<MWasmCallBase*>(mirCatchable());
}
if (isReturnCall()) {
return static_cast<MWasmReturnCall*>(mirReturnCall());
}
return static_cast<MWasmCallBase*>(mirUncatchable());
}
bool isCatchable() const { return mir_->isWasmCallCatchable(); }
bool isReturnCall() const { return mir_->isWasmReturnCall(); }
MWasmCallCatchable* mirCatchable() const {
return mir_->toWasmCallCatchable();
}
MWasmCallUncatchable* mirUncatchable() const {
return mir_->toWasmCallUncatchable();
}
MWasmReturnCall* mirReturnCall() const { return mir_->toWasmReturnCall(); }
static bool isCallPreserved(AnyRegister reg) {
// All MWasmCalls preserve the TLS register:
// - internal/indirect calls do by the internal wasm ABI
// - import calls do by explicitly saving/restoring at the callsite
// - builtin calls do because the TLS reg is non-volatile
// See also CodeGeneratorShared::emitWasmCall.
//
// All other registers are not preserved. This is is relied upon by
// MWasmCallCatchable which needs all live registers to be spilled before
// a call.
return !reg.isFloat() && reg.gpr() == InstanceReg;
}
bool needsBoundsCheck() const { return needsBoundsCheck_; }
mozilla::Maybe<uint32_t> tableSize() const { return tableSize_; }
LWasmCallIndirectAdjunctSafepoint* adjunctSafepoint() const {
MOZ_ASSERT(adjunctSafepoint_ != nullptr);
return adjunctSafepoint_;
}
void setAdjunctSafepoint(LWasmCallIndirectAdjunctSafepoint* asp) {
adjunctSafepoint_ = asp;
}
};
class LWasmRegisterResult : public LInstructionHelper<1, 0, 0> {
public:
LIR_HEADER(WasmRegisterResult);
LWasmRegisterResult() : LInstructionHelper(classOpcode) {}
MWasmRegisterResult* mir() const {
if (!mir_->isWasmRegisterResult()) {
return nullptr;
}
return mir_->toWasmRegisterResult();
}
};
class LWasmRegisterPairResult : public LInstructionHelper<2, 0, 0> {
public:
LIR_HEADER(WasmRegisterPairResult);
LWasmRegisterPairResult() : LInstructionHelper(classOpcode) {}
MDefinition* mir() const { return mirRaw(); }
};
inline uint32_t LStackArea::base() const {
return ins()->toWasmStackResultArea()->mir()->base();
}
inline void LStackArea::setBase(uint32_t base) {
ins()->toWasmStackResultArea()->mir()->setBase(base);
}
inline uint32_t LStackArea::size() const {
return ins()->toWasmStackResultArea()->mir()->byteSize();
}
inline bool LStackArea::ResultIterator::done() const {
return idx_ == alloc_.ins()->toWasmStackResultArea()->mir()->resultCount();
}
inline void LStackArea::ResultIterator::next() {
MOZ_ASSERT(!done());
idx_++;
}
inline LAllocation LStackArea::ResultIterator::alloc() const {
MOZ_ASSERT(!done());
MWasmStackResultArea* area = alloc_.ins()->toWasmStackResultArea()->mir();
return LStackSlot(area->base() - area->result(idx_).offset());
}
inline bool LStackArea::ResultIterator::isWasmAnyRef() const {
MOZ_ASSERT(!done());
MWasmStackResultArea* area = alloc_.ins()->toWasmStackResultArea()->mir();
MIRType type = area->result(idx_).type();
#ifndef JS_PUNBOX64
// LDefinition::TypeFrom isn't defined for MIRType::Int64 values on
// this platform, so here we have a special case.
if (type == MIRType::Int64) {
return false;
}
#endif
return LDefinition::TypeFrom(type) == LDefinition::WASM_ANYREF;
}
class LWasmStackResult : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(WasmStackResult);
LWasmStackResult() : LInstructionHelper(classOpcode) {}
MWasmStackResult* mir() const { return mir_->toWasmStackResult(); }
LStackSlot result(uint32_t base) const {
return LStackSlot(base - mir()->result().offset());
}
};
class LWasmStackResult64 : public LInstructionHelper<INT64_PIECES, 1, 0> {
public:
LIR_HEADER(WasmStackResult64);
LWasmStackResult64() : LInstructionHelper(classOpcode) {}
MWasmStackResult* mir() const { return mir_->toWasmStackResult(); }
LStackSlot result(uint32_t base, LDefinition* def) {
uint32_t offset = base - mir()->result().offset();
#if defined(JS_NUNBOX32)
if (def == getDef(INT64LOW_INDEX)) {
offset -= INT64LOW_OFFSET;
} else {
MOZ_ASSERT(def == getDef(INT64HIGH_INDEX));
offset -= INT64HIGH_OFFSET;
}
#else
MOZ_ASSERT(def == getDef(0));
#endif
return LStackSlot(offset);
}
};
inline LStackSlot LStackArea::resultAlloc(LInstruction* lir,
LDefinition* def) const {
if (lir->isWasmStackResult64()) {
return lir->toWasmStackResult64()->result(base(), def);
}
MOZ_ASSERT(def == lir->getDef(0));
return lir->toWasmStackResult()->result(base());
}
inline bool LNode::isCallPreserved(AnyRegister reg) const {
return isWasmCall() && LWasmCall::isCallPreserved(reg);
}
class LAssertRangeI : public LInstructionHelper<0, 1, 0> {
public:
LIR_HEADER(AssertRangeI)
explicit LAssertRangeI(const LAllocation& input)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
}
const LAllocation* input() { return getOperand(0); }
MAssertRange* mir() { return mir_->toAssertRange(); }
const Range* range() { return mir()->assertedRange(); }
};
class LAssertRangeD : public LInstructionHelper<0, 1, 1> {
public:
LIR_HEADER(AssertRangeD)
LAssertRangeD(const LAllocation& input, const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
MAssertRange* mir() { return mir_->toAssertRange(); }
const Range* range() { return mir()->assertedRange(); }
};
class LAssertRangeF : public LInstructionHelper<0, 1, 2> {
public:
LIR_HEADER(AssertRangeF)
LAssertRangeF(const LAllocation& input, const LDefinition& temp,
const LDefinition& temp2)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
setTemp(1, temp2);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
const LDefinition* temp2() { return getTemp(1); }
MAssertRange* mir() { return mir_->toAssertRange(); }
const Range* range() { return mir()->assertedRange(); }
};
class LAssertRangeV : public LInstructionHelper<0, BOX_PIECES, 3> {
public:
LIR_HEADER(AssertRangeV)
LAssertRangeV(const LBoxAllocation& input, const LDefinition& temp,
const LDefinition& floatTemp1, const LDefinition& floatTemp2)
: LInstructionHelper(classOpcode) {
setBoxOperand(Input, input);
setTemp(0, temp);
setTemp(1, floatTemp1);
setTemp(2, floatTemp2);
}
static const size_t Input = 0;
const LDefinition* temp() { return getTemp(0); }
const LDefinition* floatTemp1() { return getTemp(1); }
const LDefinition* floatTemp2() { return getTemp(2); }
MAssertRange* mir() { return mir_->toAssertRange(); }
const Range* range() { return mir()->assertedRange(); }
};
class LMemoryBarrier : public LInstructionHelper<0, 0, 0> {
private:
const MemoryBarrierBits type_;
public:
LIR_HEADER(MemoryBarrier)
// The parameter 'type' is a bitwise 'or' of the barrier types needed,
// see AtomicOp.h.
explicit LMemoryBarrier(MemoryBarrierBits type)
: LInstructionHelper(classOpcode), type_(type) {
MOZ_ASSERT((type_ & ~MembarAllbits) == MembarNobits);
}
MemoryBarrierBits type() const { return type_; }
};
// Math.random().
class LRandom : public LInstructionHelper<1, 0, 1 + 2 * INT64_PIECES> {
public:
LIR_HEADER(Random)
LRandom(const LDefinition& temp0, const LInt64Definition& temp1,
const LInt64Definition& temp2)
: LInstructionHelper(classOpcode) {
setTemp(0, temp0);
setInt64Temp(1, temp1);
setInt64Temp(1 + INT64_PIECES, temp2);
}
const LDefinition* temp0() { return getTemp(0); }
LInt64Definition temp1() { return getInt64Temp(1); }
LInt64Definition temp2() { return getInt64Temp(1 + INT64_PIECES); }
MRandom* mir() const { return mir_->toRandom(); }
};
class LBigIntAsIntN64 : public LInstructionHelper<1, 1, 1 + INT64_PIECES> {
public:
LIR_HEADER(BigIntAsIntN64)
LBigIntAsIntN64(const LAllocation& input, const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
LInt64Definition temp64() { return getInt64Temp(1); }
};
class LBigIntAsIntN32 : public LInstructionHelper<1, 1, 1 + INT64_PIECES> {
public:
LIR_HEADER(BigIntAsIntN32)
LBigIntAsIntN32(const LAllocation& input, const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
LInt64Definition temp64() { return getInt64Temp(1); }
};
class LBigIntAsUintN64 : public LInstructionHelper<1, 1, 1 + INT64_PIECES> {
public:
LIR_HEADER(BigIntAsUintN64)
LBigIntAsUintN64(const LAllocation& input, const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
LInt64Definition temp64() { return getInt64Temp(1); }
};
class LBigIntAsUintN32 : public LInstructionHelper<1, 1, 1 + INT64_PIECES> {
public:
LIR_HEADER(BigIntAsUintN32)
LBigIntAsUintN32(const LAllocation& input, const LDefinition& temp,
const LInt64Definition& temp64)
: LInstructionHelper(classOpcode) {
setOperand(0, input);
setTemp(0, temp);
setInt64Temp(1, temp64);
}
const LAllocation* input() { return getOperand(0); }
const LDefinition* temp() { return getTemp(0); }
LInt64Definition temp64() { return getInt64Temp(1); }
};
template <size_t NumDefs>
class LIonToWasmCallBase : public LVariadicInstruction<NumDefs, 1> {
using Base = LVariadicInstruction<NumDefs, 1>;
public:
explicit LIonToWasmCallBase(LNode::Opcode classOpcode, uint32_t numOperands,
const LDefinition& temp)
: Base(classOpcode, numOperands) {
this->setIsCall();
this->setTemp(0, temp);
}
MIonToWasmCall* mir() const { return this->mir_->toIonToWasmCall(); }
const LDefinition* temp() { return this->getTemp(0); }
};
class LIonToWasmCall : public LIonToWasmCallBase<1> {
public:
LIR_HEADER(IonToWasmCall);
LIonToWasmCall(uint32_t numOperands, const LDefinition& temp)
: LIonToWasmCallBase<1>(classOpcode, numOperands, temp) {}
};
class LIonToWasmCallV : public LIonToWasmCallBase<BOX_PIECES> {
public:
LIR_HEADER(IonToWasmCallV);
LIonToWasmCallV(uint32_t numOperands, const LDefinition& temp)
: LIonToWasmCallBase<BOX_PIECES>(classOpcode, numOperands, temp) {}
};
class LIonToWasmCallI64 : public LIonToWasmCallBase<INT64_PIECES> {
public:
LIR_HEADER(IonToWasmCallI64);
LIonToWasmCallI64(uint32_t numOperands, const LDefinition& temp)
: LIonToWasmCallBase<INT64_PIECES>(classOpcode, numOperands, temp) {}
};
class LWasmRefIsSubtypeOfAbstractAndBranch
: public LControlInstructionHelper<2, 2, 2> {
wasm::RefType sourceType_;
wasm::RefType destType_;
public:
LIR_HEADER(WasmRefIsSubtypeOfAbstractAndBranch)
static constexpr uint32_t Ref = 0;
LWasmRefIsSubtypeOfAbstractAndBranch(
MBasicBlock* ifTrue, MBasicBlock* ifFalse, wasm::RefType sourceType,
wasm::RefType destType, const LAllocation& ref, const LDefinition& temp0)
: LControlInstructionHelper(classOpcode),
sourceType_(sourceType),
destType_(destType) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setOperand(Ref, ref);
setTemp(0, temp0);
}
wasm::RefType sourceType() const { return sourceType_; }
wasm::RefType destType() const { return destType_; }
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* ref() { return getOperand(Ref); }
const LDefinition* temp0() { return getTemp(0); }
};
class LWasmRefIsSubtypeOfConcreteAndBranch
: public LControlInstructionHelper<2, 2, 2> {
wasm::RefType sourceType_;
wasm::RefType destType_;
public:
LIR_HEADER(WasmRefIsSubtypeOfConcreteAndBranch)
static constexpr uint32_t Ref = 0;
static constexpr uint32_t SuperSTV = 1;
LWasmRefIsSubtypeOfConcreteAndBranch(
MBasicBlock* ifTrue, MBasicBlock* ifFalse, wasm::RefType sourceType,
wasm::RefType destType, const LAllocation& ref,
const LAllocation& superSTV, const LDefinition& temp0,
const LDefinition& temp1)
: LControlInstructionHelper(classOpcode),
sourceType_(sourceType),
destType_(destType) {
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
setOperand(Ref, ref);
setOperand(SuperSTV, superSTV);
setTemp(0, temp0);
setTemp(1, temp1);
}
wasm::RefType sourceType() const { return sourceType_; }
wasm::RefType destType() const { return destType_; }
MBasicBlock* ifTrue() const { return getSuccessor(0); }
MBasicBlock* ifFalse() const { return getSuccessor(1); }
const LAllocation* ref() { return getOperand(Ref); }
const LAllocation* superSTV() { return getOperand(SuperSTV); }
const LDefinition* temp0() { return getTemp(0); }
const LDefinition* temp1() { return getTemp(1); }
};
// Wasm SIMD.
// (v128, v128, v128) -> v128 effect-free operation.
// temp is FPR.
class LWasmTernarySimd128 : public LInstructionHelper<1, 3, 1> {
wasm::SimdOp op_;
public:
LIR_HEADER(WasmTernarySimd128)
static constexpr uint32_t V0 = 0;
static constexpr uint32_t V1 = 1;
static constexpr uint32_t V2 = 2;
LWasmTernarySimd128(wasm::SimdOp op, const LAllocation& v0,
const LAllocation& v1, const LAllocation& v2)
: LInstructionHelper(classOpcode), op_(op) {
setOperand(V0, v0);
setOperand(V1, v1);
setOperand(V2, v2);
}
LWasmTernarySimd128(wasm::SimdOp op, const LAllocation& v0,
const LAllocation& v1, const LAllocation& v2,
const LDefinition& temp)
: LInstructionHelper(classOpcode), op_(op) {
setOperand(V0, v0);
setOperand(V1, v1);
setOperand(V2, v2);
setTemp(0, temp);
}
const LAllocation* v0() { return getOperand(V0); }
const LAllocation* v1() { return getOperand(V1); }
const LAllocation* v2() { return getOperand(V2); }
const LDefinition* temp() { return getTemp(0); }
wasm::SimdOp simdOp() const { return op_; }
};
// (v128, v128) -> v128 effect-free operations
// lhs and dest are the same.
// temps (if in use) are FPR.
// The op may differ from the MIR node's op.
class LWasmBinarySimd128 : public LInstructionHelper<1, 2, 2> {
wasm::SimdOp op_;
public:
LIR_HEADER(WasmBinarySimd128)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
static constexpr uint32_t Rhs = 1;
LWasmBinarySimd128(wasm::SimdOp op, const LAllocation& lhs,
const LAllocation& rhs, const LDefinition& temp0,
const LDefinition& temp1)
: LInstructionHelper(classOpcode), op_(op) {
setOperand(Lhs, lhs);
setOperand(Rhs, rhs);
setTemp(0, temp0);
setTemp(1, temp1);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const LAllocation* rhs() { return getOperand(Rhs); }
wasm::SimdOp simdOp() const { return op_; }
static bool SpecializeForConstantRhs(wasm::SimdOp op);
};
class LWasmBinarySimd128WithConstant : public LInstructionHelper<1, 1, 1> {
SimdConstant rhs_;
public:
LIR_HEADER(WasmBinarySimd128WithConstant)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
LWasmBinarySimd128WithConstant(const LAllocation& lhs,
const SimdConstant& rhs,
const LDefinition& temp)
: LInstructionHelper(classOpcode), rhs_(rhs) {
setOperand(Lhs, lhs);
setTemp(0, temp);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const SimdConstant& rhs() { return rhs_; }
wasm::SimdOp simdOp() const {
return mir_->toWasmBinarySimd128WithConstant()->simdOp();
}
};
// (v128, i32) -> v128 effect-free variable-width shift operations
// lhs and dest are the same.
// temp is an FPR (if in use).
class LWasmVariableShiftSimd128 : public LInstructionHelper<1, 2, 1> {
public:
LIR_HEADER(WasmVariableShiftSimd128)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
static constexpr uint32_t Rhs = 1;
LWasmVariableShiftSimd128(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(Lhs, lhs);
setOperand(Rhs, rhs);
setTemp(0, temp);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const LAllocation* rhs() { return getOperand(Rhs); }
wasm::SimdOp simdOp() const { return mir_->toWasmShiftSimd128()->simdOp(); }
};
// (v128, i32) -> v128 effect-free constant-width shift operations
class LWasmConstantShiftSimd128 : public LInstructionHelper<1, 1, 0> {
int32_t shift_;
public:
LIR_HEADER(WasmConstantShiftSimd128)
static constexpr uint32_t Src = 0;
LWasmConstantShiftSimd128(const LAllocation& src, int32_t shift)
: LInstructionHelper(classOpcode), shift_(shift) {
setOperand(Src, src);
}
const LAllocation* src() { return getOperand(Src); }
int32_t shift() { return shift_; }
wasm::SimdOp simdOp() const { return mir_->toWasmShiftSimd128()->simdOp(); }
};
// (v128) -> v128 sign replication operation.
class LWasmSignReplicationSimd128 : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(WasmSignReplicationSimd128)
static constexpr uint32_t Src = 0;
explicit LWasmSignReplicationSimd128(const LAllocation& src)
: LInstructionHelper(classOpcode) {
setOperand(Src, src);
}
const LAllocation* src() { return getOperand(Src); }
wasm::SimdOp simdOp() const { return mir_->toWasmShiftSimd128()->simdOp(); }
};
// (v128, v128, imm_simd) -> v128 effect-free operation.
// temp is FPR (and always in use).
class LWasmShuffleSimd128 : public LInstructionHelper<1, 2, 1> {
private:
SimdShuffleOp op_;
SimdConstant control_;
public:
LIR_HEADER(WasmShuffleSimd128)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
static constexpr uint32_t Rhs = 1;
LWasmShuffleSimd128(const LAllocation& lhs, const LAllocation& rhs,
const LDefinition& temp, SimdShuffleOp op,
SimdConstant control)
: LInstructionHelper(classOpcode), op_(op), control_(control) {
setOperand(Lhs, lhs);
setOperand(Rhs, rhs);
setTemp(0, temp);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const LAllocation* rhs() { return getOperand(Rhs); }
const LDefinition* temp() { return getTemp(0); }
SimdShuffleOp op() { return op_; }
SimdConstant control() { return control_; }
};
// (v128, imm_simd) -> v128 effect-free operation.
class LWasmPermuteSimd128 : public LInstructionHelper<1, 1, 0> {
private:
SimdPermuteOp op_;
SimdConstant control_;
public:
LIR_HEADER(WasmPermuteSimd128)
static constexpr uint32_t Src = 0;
LWasmPermuteSimd128(const LAllocation& src, SimdPermuteOp op,
SimdConstant control)
: LInstructionHelper(classOpcode), op_(op), control_(control) {
setOperand(Src, src);
}
const LAllocation* src() { return getOperand(Src); }
SimdPermuteOp op() { return op_; }
SimdConstant control() { return control_; }
};
class LWasmReplaceLaneSimd128 : public LInstructionHelper<1, 2, 0> {
public:
LIR_HEADER(WasmReplaceLaneSimd128)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
static constexpr uint32_t Rhs = 1;
LWasmReplaceLaneSimd128(const LAllocation& lhs, const LAllocation& rhs)
: LInstructionHelper(classOpcode) {
setOperand(Lhs, lhs);
setOperand(Rhs, rhs);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const LAllocation* rhs() { return getOperand(Rhs); }
uint32_t laneIndex() const {
return mir_->toWasmReplaceLaneSimd128()->laneIndex();
}
wasm::SimdOp simdOp() const {
return mir_->toWasmReplaceLaneSimd128()->simdOp();
}
};
class LWasmReplaceInt64LaneSimd128
: public LInstructionHelper<1, INT64_PIECES + 1, 0> {
public:
LIR_HEADER(WasmReplaceInt64LaneSimd128)
static constexpr uint32_t Lhs = 0;
static constexpr uint32_t LhsDest = 0;
static constexpr uint32_t Rhs = 1;
LWasmReplaceInt64LaneSimd128(const LAllocation& lhs,
const LInt64Allocation& rhs)
: LInstructionHelper(classOpcode) {
setOperand(Lhs, lhs);
setInt64Operand(Rhs, rhs);
}
const LAllocation* lhs() { return getOperand(Lhs); }
const LAllocation* lhsDest() { return getOperand(LhsDest); }
const LInt64Allocation rhs() { return getInt64Operand(Rhs); }
const LDefinition* output() { return this->getDef(0); }
uint32_t laneIndex() const {
return mir_->toWasmReplaceLaneSimd128()->laneIndex();
}
wasm::SimdOp simdOp() const {
return mir_->toWasmReplaceLaneSimd128()->simdOp();
}
};
// (scalar) -> v128 effect-free operations, scalar != int64
class LWasmScalarToSimd128 : public LInstructionHelper<1, 1, 0> {
public:
LIR_HEADER(WasmScalarToSimd128)
static constexpr uint32_t Src = 0;
explicit LWasmScalarToSimd128(const LAllocation& src)
: LInstructionHelper(classOpcode) {
setOperand(Src, src);
}
const LAllocation* src() { return getOperand(Src); }
wasm::SimdOp simdOp() const {
return mir_->toWasmScalarToSimd128()->simdOp();
}
};
// (int64) -> v128 effect-free operations
class LWasmInt64ToSimd128 : public LInstructionHelper<1, INT64_PIECES, 0> {
public:
LIR_HEADER(WasmInt64ToSimd128)
static constexpr uint32_t Src = 0;
explicit LWasmInt64ToSimd128(const LInt64Allocation& src)
: LInstructionHelper(classOpcode) {
setInt64Operand(Src, src);
}
const LInt64Allocation src() { return getInt64Operand(Src); }
wasm::SimdOp simdOp() const {
return mir_->toWasmScalarToSimd128()->simdOp();
}
};
// (v128) -> v128 effect-free operations
// temp is FPR (if in use).
class LWasmUnarySimd128 : public LInstructionHelper<1, 1, 1> {
public:
LIR_HEADER(WasmUnarySimd128)
static constexpr uint32_t Src = 0;
LWasmUnarySimd128(const LAllocation& src, const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(Src, src);
setTemp(0, temp);
}
const LAllocation* src() { return getOperand(Src); }
const LDefinition* temp() { return getTemp(0); }
wasm::SimdOp simdOp() const { return mir_->toWasmUnarySimd128()->simdOp(); }
};
// (v128, imm) -> scalar effect-free operations.
// temp is FPR (if in use).
class LWasmReduceSimd128 : public LInstructionHelper<1, 1, 1> {
public:
LIR_HEADER(WasmReduceSimd128)
static constexpr uint32_t Src = 0;
explicit LWasmReduceSimd128(const LAllocation& src, const LDefinition& temp)
: LInstructionHelper(classOpcode) {
setOperand(Src, src);
setTemp(0, temp);
}
const LAllocation* src() { return getOperand(Src); }
uint32_t imm() const { return mir_->toWasmReduceSimd128()->imm(); }
wasm::SimdOp simdOp() const { return mir_->toWasmReduceSimd128()->simdOp(); }
};
// (v128, onTrue, onFalse) test-and-branch operations.
class LWasmReduceAndBranchSimd128 : public LControlInstructionHelper<2, 1, 0> {
wasm::SimdOp op_;
public:
LIR_HEADER(WasmReduceAndBranchSimd128)
static constexpr uint32_t Src = 0;
static constexpr uint32_t IfTrue = 0;
static constexpr uint32_t IfFalse = 1;
LWasmReduceAndBranchSimd128(const LAllocation& src, wasm::SimdOp op,
MBasicBlock* ifTrue, MBasicBlock* ifFalse)
: LControlInstructionHelper(classOpcode), op_(op) {
setOperand(Src, src);
setSuccessor(IfTrue, ifTrue);
setSuccessor(IfFalse, ifFalse);
}
const LAllocation* src() { return getOperand(Src); }
wasm::SimdOp simdOp() const { return op_; }
MBasicBlock* ifTrue() const { return getSuccessor(IfTrue); }
MBasicBlock* ifFalse() const { return getSuccessor(IfFalse); }
};
// (v128, imm) -> i64 effect-free operations
class LWasmReduceSimd128ToInt64
: public LInstructionHelper<INT64_PIECES, 1, 0> {
public:
LIR_HEADER(WasmReduceSimd128ToInt64)
static constexpr uint32_t Src = 0;
explicit LWasmReduceSimd128ToInt64(const LAllocation& src)
: LInstructionHelper(classOpcode) {
setOperand(Src, src);
}
const LAllocation* src() { return getOperand(Src); }
uint32_t imm() const { return mir_->toWasmReduceSimd128()->imm(); }
wasm::SimdOp simdOp() const { return mir_->toWasmReduceSimd128()->simdOp(); }
};
class LWasmLoadLaneSimd128 : public LInstructionHelper<1, 3, 1> {
public:
LIR_HEADER(WasmLoadLaneSimd128);
static constexpr uint32_t Src = 2;
explicit LWasmLoadLaneSimd128(const LAllocation& ptr, const LAllocation& src,
const LDefinition& temp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, memoryBase);
setOperand(Src, src);
setTemp(0, temp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* memoryBase() { return getOperand(1); }
const LAllocation* src() { return getOperand(Src); }
const LDefinition* temp() { return getTemp(0); }
MWasmLoadLaneSimd128* mir() const { return mir_->toWasmLoadLaneSimd128(); }
uint32_t laneSize() const {
return mir_->toWasmLoadLaneSimd128()->laneSize();
}
uint32_t laneIndex() const {
return mir_->toWasmLoadLaneSimd128()->laneIndex();
}
};
class LWasmStoreLaneSimd128 : public LInstructionHelper<1, 3, 1> {
public:
LIR_HEADER(WasmStoreLaneSimd128);
static constexpr uint32_t Src = 2;
explicit LWasmStoreLaneSimd128(const LAllocation& ptr, const LAllocation& src,
const LDefinition& temp,
const LAllocation& memoryBase = LAllocation())
: LInstructionHelper(classOpcode) {
setOperand(0, ptr);
setOperand(1, memoryBase);
setOperand(Src, src);
setTemp(0, temp);
}
const LAllocation* ptr() { return getOperand(0); }
const LAllocation* memoryBase() { return getOperand(1); }
const LAllocation* src() { return getOperand(Src); }
const LDefinition* temp() { return getTemp(0); }
MWasmStoreLaneSimd128* mir() const { return mir_->toWasmStoreLaneSimd128(); }
uint32_t laneSize() const {
return mir_->toWasmStoreLaneSimd128()->laneSize();
}
uint32_t laneIndex() const {
return mir_->toWasmStoreLaneSimd128()->laneIndex();
}
};
// End Wasm SIMD
// End Wasm Exception Handling
} // namespace jit
} // namespace js
#endif /* jit_shared_LIR_shared_h */
|