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
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
|
/* Subroutines used for code generation on the DEC Alpha.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "insn-config.h"
#include "conditions.h"
#include "output.h"
#include "insn-attr.h"
#include "flags.h"
#include "recog.h"
#include "expr.h"
#include "optabs.h"
#include "reload.h"
#include "obstack.h"
#include "except.h"
#include "function.h"
#include "diagnostic-core.h"
#include "ggc.h"
#include "integrate.h"
#include "tm_p.h"
#include "target.h"
#include "target-def.h"
#include "debug.h"
#include "langhooks.h"
#include "splay-tree.h"
#include "cfglayout.h"
#include "gimple.h"
#include "tree-flow.h"
#include "tree-stdarg.h"
#include "tm-constrs.h"
#include "df.h"
#include "libfuncs.h"
/* Specify which cpu to schedule for. */
enum processor_type alpha_tune;
/* Which cpu we're generating code for. */
enum processor_type alpha_cpu;
static const char * const alpha_cpu_name[] =
{
"ev4", "ev5", "ev6"
};
/* Specify how accurate floating-point traps need to be. */
enum alpha_trap_precision alpha_tp;
/* Specify the floating-point rounding mode. */
enum alpha_fp_rounding_mode alpha_fprm;
/* Specify which things cause traps. */
enum alpha_fp_trap_mode alpha_fptm;
/* Nonzero if inside of a function, because the Alpha asm can't
handle .files inside of functions. */
static int inside_function = FALSE;
/* The number of cycles of latency we should assume on memory reads. */
int alpha_memory_latency = 3;
/* Whether the function needs the GP. */
static int alpha_function_needs_gp;
/* The assembler name of the current function. */
static const char *alpha_fnname;
/* The next explicit relocation sequence number. */
extern GTY(()) int alpha_next_sequence_number;
int alpha_next_sequence_number = 1;
/* The literal and gpdisp sequence numbers for this insn, as printed
by %# and %* respectively. */
extern GTY(()) int alpha_this_literal_sequence_number;
extern GTY(()) int alpha_this_gpdisp_sequence_number;
int alpha_this_literal_sequence_number;
int alpha_this_gpdisp_sequence_number;
/* Costs of various operations on the different architectures. */
struct alpha_rtx_cost_data
{
unsigned char fp_add;
unsigned char fp_mult;
unsigned char fp_div_sf;
unsigned char fp_div_df;
unsigned char int_mult_si;
unsigned char int_mult_di;
unsigned char int_shift;
unsigned char int_cmov;
unsigned short int_div;
};
static struct alpha_rtx_cost_data const alpha_rtx_cost_data[PROCESSOR_MAX] =
{
{ /* EV4 */
COSTS_N_INSNS (6), /* fp_add */
COSTS_N_INSNS (6), /* fp_mult */
COSTS_N_INSNS (34), /* fp_div_sf */
COSTS_N_INSNS (63), /* fp_div_df */
COSTS_N_INSNS (23), /* int_mult_si */
COSTS_N_INSNS (23), /* int_mult_di */
COSTS_N_INSNS (2), /* int_shift */
COSTS_N_INSNS (2), /* int_cmov */
COSTS_N_INSNS (97), /* int_div */
},
{ /* EV5 */
COSTS_N_INSNS (4), /* fp_add */
COSTS_N_INSNS (4), /* fp_mult */
COSTS_N_INSNS (15), /* fp_div_sf */
COSTS_N_INSNS (22), /* fp_div_df */
COSTS_N_INSNS (8), /* int_mult_si */
COSTS_N_INSNS (12), /* int_mult_di */
COSTS_N_INSNS (1) + 1, /* int_shift */
COSTS_N_INSNS (1), /* int_cmov */
COSTS_N_INSNS (83), /* int_div */
},
{ /* EV6 */
COSTS_N_INSNS (4), /* fp_add */
COSTS_N_INSNS (4), /* fp_mult */
COSTS_N_INSNS (12), /* fp_div_sf */
COSTS_N_INSNS (15), /* fp_div_df */
COSTS_N_INSNS (7), /* int_mult_si */
COSTS_N_INSNS (7), /* int_mult_di */
COSTS_N_INSNS (1), /* int_shift */
COSTS_N_INSNS (2), /* int_cmov */
COSTS_N_INSNS (86), /* int_div */
},
};
/* Similar but tuned for code size instead of execution latency. The
extra +N is fractional cost tuning based on latency. It's used to
encourage use of cheaper insns like shift, but only if there's just
one of them. */
static struct alpha_rtx_cost_data const alpha_rtx_cost_size =
{
COSTS_N_INSNS (1), /* fp_add */
COSTS_N_INSNS (1), /* fp_mult */
COSTS_N_INSNS (1), /* fp_div_sf */
COSTS_N_INSNS (1) + 1, /* fp_div_df */
COSTS_N_INSNS (1) + 1, /* int_mult_si */
COSTS_N_INSNS (1) + 2, /* int_mult_di */
COSTS_N_INSNS (1), /* int_shift */
COSTS_N_INSNS (1), /* int_cmov */
COSTS_N_INSNS (6), /* int_div */
};
/* Get the number of args of a function in one of two ways. */
#if TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK
#define NUM_ARGS crtl->args.info.num_args
#else
#define NUM_ARGS crtl->args.info
#endif
#define REG_PV 27
#define REG_RA 26
/* Declarations of static functions. */
static struct machine_function *alpha_init_machine_status (void);
static rtx alpha_emit_xfloating_compare (enum rtx_code *, rtx, rtx);
#if TARGET_ABI_OPEN_VMS
static void alpha_write_linkage (FILE *, const char *, tree);
static bool vms_valid_pointer_mode (enum machine_mode);
#endif
static void unicosmk_output_deferred_case_vectors (FILE *);
static void unicosmk_gen_dsib (unsigned long *);
static void unicosmk_output_ssib (FILE *, const char *);
static int unicosmk_need_dex (rtx);
/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
static const struct default_options alpha_option_optimization_table[] =
{
{ OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
{ OPT_LEVELS_NONE, 0, NULL, 0 }
};
/* Implement TARGET_HANDLE_OPTION. */
static bool
alpha_handle_option (size_t code, const char *arg, int value)
{
switch (code)
{
case OPT_mfp_regs:
if (value == 0)
target_flags |= MASK_SOFT_FP;
break;
case OPT_mieee:
case OPT_mieee_with_inexact:
target_flags |= MASK_IEEE_CONFORMANT;
break;
case OPT_mtls_size_:
if (value != 16 && value != 32 && value != 64)
error ("bad value %qs for -mtls-size switch", arg);
break;
}
return true;
}
#ifdef TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
/* Implement TARGET_MANGLE_TYPE. */
static const char *
alpha_mangle_type (const_tree type)
{
if (TYPE_MAIN_VARIANT (type) == long_double_type_node
&& TARGET_LONG_DOUBLE_128)
return "g";
/* For all other types, use normal C++ mangling. */
return NULL;
}
#endif
/* Parse target option strings. */
static void
alpha_option_override (void)
{
static const struct cpu_table {
const char *const name;
const enum processor_type processor;
const int flags;
} cpu_table[] = {
{ "ev4", PROCESSOR_EV4, 0 },
{ "ev45", PROCESSOR_EV4, 0 },
{ "21064", PROCESSOR_EV4, 0 },
{ "ev5", PROCESSOR_EV5, 0 },
{ "21164", PROCESSOR_EV5, 0 },
{ "ev56", PROCESSOR_EV5, MASK_BWX },
{ "21164a", PROCESSOR_EV5, MASK_BWX },
{ "pca56", PROCESSOR_EV5, MASK_BWX|MASK_MAX },
{ "21164PC",PROCESSOR_EV5, MASK_BWX|MASK_MAX },
{ "21164pc",PROCESSOR_EV5, MASK_BWX|MASK_MAX },
{ "ev6", PROCESSOR_EV6, MASK_BWX|MASK_MAX|MASK_FIX },
{ "21264", PROCESSOR_EV6, MASK_BWX|MASK_MAX|MASK_FIX },
{ "ev67", PROCESSOR_EV6, MASK_BWX|MASK_MAX|MASK_FIX|MASK_CIX },
{ "21264a", PROCESSOR_EV6, MASK_BWX|MASK_MAX|MASK_FIX|MASK_CIX }
};
int const ct_size = ARRAY_SIZE (cpu_table);
int i;
#ifdef SUBTARGET_OVERRIDE_OPTIONS
SUBTARGET_OVERRIDE_OPTIONS;
#endif
/* Unicos/Mk doesn't have shared libraries. */
if (TARGET_ABI_UNICOSMK && flag_pic)
{
warning (0, "-f%s ignored for Unicos/Mk (not supported)",
(flag_pic > 1) ? "PIC" : "pic");
flag_pic = 0;
}
/* On Unicos/Mk, the native compiler consistently generates /d suffices for
floating-point instructions. Make that the default for this target. */
if (TARGET_ABI_UNICOSMK)
alpha_fprm = ALPHA_FPRM_DYN;
else
alpha_fprm = ALPHA_FPRM_NORM;
alpha_tp = ALPHA_TP_PROG;
alpha_fptm = ALPHA_FPTM_N;
/* We cannot use su and sui qualifiers for conversion instructions on
Unicos/Mk. I'm not sure if this is due to assembler or hardware
limitations. Right now, we issue a warning if -mieee is specified
and then ignore it; eventually, we should either get it right or
disable the option altogether. */
if (TARGET_IEEE)
{
if (TARGET_ABI_UNICOSMK)
warning (0, "-mieee not supported on Unicos/Mk");
else
{
alpha_tp = ALPHA_TP_INSN;
alpha_fptm = ALPHA_FPTM_SU;
}
}
if (TARGET_IEEE_WITH_INEXACT)
{
if (TARGET_ABI_UNICOSMK)
warning (0, "-mieee-with-inexact not supported on Unicos/Mk");
else
{
alpha_tp = ALPHA_TP_INSN;
alpha_fptm = ALPHA_FPTM_SUI;
}
}
if (alpha_tp_string)
{
if (! strcmp (alpha_tp_string, "p"))
alpha_tp = ALPHA_TP_PROG;
else if (! strcmp (alpha_tp_string, "f"))
alpha_tp = ALPHA_TP_FUNC;
else if (! strcmp (alpha_tp_string, "i"))
alpha_tp = ALPHA_TP_INSN;
else
error ("bad value %qs for -mtrap-precision switch", alpha_tp_string);
}
if (alpha_fprm_string)
{
if (! strcmp (alpha_fprm_string, "n"))
alpha_fprm = ALPHA_FPRM_NORM;
else if (! strcmp (alpha_fprm_string, "m"))
alpha_fprm = ALPHA_FPRM_MINF;
else if (! strcmp (alpha_fprm_string, "c"))
alpha_fprm = ALPHA_FPRM_CHOP;
else if (! strcmp (alpha_fprm_string,"d"))
alpha_fprm = ALPHA_FPRM_DYN;
else
error ("bad value %qs for -mfp-rounding-mode switch",
alpha_fprm_string);
}
if (alpha_fptm_string)
{
if (strcmp (alpha_fptm_string, "n") == 0)
alpha_fptm = ALPHA_FPTM_N;
else if (strcmp (alpha_fptm_string, "u") == 0)
alpha_fptm = ALPHA_FPTM_U;
else if (strcmp (alpha_fptm_string, "su") == 0)
alpha_fptm = ALPHA_FPTM_SU;
else if (strcmp (alpha_fptm_string, "sui") == 0)
alpha_fptm = ALPHA_FPTM_SUI;
else
error ("bad value %qs for -mfp-trap-mode switch", alpha_fptm_string);
}
if (alpha_cpu_string)
{
for (i = 0; i < ct_size; i++)
if (! strcmp (alpha_cpu_string, cpu_table [i].name))
{
alpha_tune = alpha_cpu = cpu_table [i].processor;
target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX);
target_flags |= cpu_table [i].flags;
break;
}
if (i == ct_size)
error ("bad value %qs for -mcpu switch", alpha_cpu_string);
}
if (alpha_tune_string)
{
for (i = 0; i < ct_size; i++)
if (! strcmp (alpha_tune_string, cpu_table [i].name))
{
alpha_tune = cpu_table [i].processor;
break;
}
if (i == ct_size)
error ("bad value %qs for -mtune switch", alpha_tune_string);
}
/* Do some sanity checks on the above options. */
if (TARGET_ABI_UNICOSMK && alpha_fptm != ALPHA_FPTM_N)
{
warning (0, "trap mode not supported on Unicos/Mk");
alpha_fptm = ALPHA_FPTM_N;
}
if ((alpha_fptm == ALPHA_FPTM_SU || alpha_fptm == ALPHA_FPTM_SUI)
&& alpha_tp != ALPHA_TP_INSN && alpha_cpu != PROCESSOR_EV6)
{
warning (0, "fp software completion requires -mtrap-precision=i");
alpha_tp = ALPHA_TP_INSN;
}
if (alpha_cpu == PROCESSOR_EV6)
{
/* Except for EV6 pass 1 (not released), we always have precise
arithmetic traps. Which means we can do software completion
without minding trap shadows. */
alpha_tp = ALPHA_TP_PROG;
}
if (TARGET_FLOAT_VAX)
{
if (alpha_fprm == ALPHA_FPRM_MINF || alpha_fprm == ALPHA_FPRM_DYN)
{
warning (0, "rounding mode not supported for VAX floats");
alpha_fprm = ALPHA_FPRM_NORM;
}
if (alpha_fptm == ALPHA_FPTM_SUI)
{
warning (0, "trap mode not supported for VAX floats");
alpha_fptm = ALPHA_FPTM_SU;
}
if (target_flags_explicit & MASK_LONG_DOUBLE_128)
warning (0, "128-bit long double not supported for VAX floats");
target_flags &= ~MASK_LONG_DOUBLE_128;
}
{
char *end;
int lat;
if (!alpha_mlat_string)
alpha_mlat_string = "L1";
if (ISDIGIT ((unsigned char)alpha_mlat_string[0])
&& (lat = strtol (alpha_mlat_string, &end, 10), *end == '\0'))
;
else if ((alpha_mlat_string[0] == 'L' || alpha_mlat_string[0] == 'l')
&& ISDIGIT ((unsigned char)alpha_mlat_string[1])
&& alpha_mlat_string[2] == '\0')
{
static int const cache_latency[][4] =
{
{ 3, 30, -1 }, /* ev4 -- Bcache is a guess */
{ 2, 12, 38 }, /* ev5 -- Bcache from PC164 LMbench numbers */
{ 3, 12, 30 }, /* ev6 -- Bcache from DS20 LMbench. */
};
lat = alpha_mlat_string[1] - '0';
if (lat <= 0 || lat > 3 || cache_latency[alpha_tune][lat-1] == -1)
{
warning (0, "L%d cache latency unknown for %s",
lat, alpha_cpu_name[alpha_tune]);
lat = 3;
}
else
lat = cache_latency[alpha_tune][lat-1];
}
else if (! strcmp (alpha_mlat_string, "main"))
{
/* Most current memories have about 370ns latency. This is
a reasonable guess for a fast cpu. */
lat = 150;
}
else
{
warning (0, "bad value %qs for -mmemory-latency", alpha_mlat_string);
lat = 3;
}
alpha_memory_latency = lat;
}
/* Default the definition of "small data" to 8 bytes. */
if (!global_options_set.x_g_switch_value)
g_switch_value = 8;
/* Infer TARGET_SMALL_DATA from -fpic/-fPIC. */
if (flag_pic == 1)
target_flags |= MASK_SMALL_DATA;
else if (flag_pic == 2)
target_flags &= ~MASK_SMALL_DATA;
/* Align labels and loops for optimal branching. */
/* ??? Kludge these by not doing anything if we don't optimize and also if
we are writing ECOFF symbols to work around a bug in DEC's assembler. */
if (optimize > 0 && write_symbols != SDB_DEBUG)
{
if (align_loops <= 0)
align_loops = 16;
if (align_jumps <= 0)
align_jumps = 16;
}
if (align_functions <= 0)
align_functions = 16;
/* Register variables and functions with the garbage collector. */
/* Set up function hooks. */
init_machine_status = alpha_init_machine_status;
/* Tell the compiler when we're using VAX floating point. */
if (TARGET_FLOAT_VAX)
{
REAL_MODE_FORMAT (SFmode) = &vax_f_format;
REAL_MODE_FORMAT (DFmode) = &vax_g_format;
REAL_MODE_FORMAT (TFmode) = NULL;
}
#ifdef TARGET_DEFAULT_LONG_DOUBLE_128
if (!(target_flags_explicit & MASK_LONG_DOUBLE_128))
target_flags |= MASK_LONG_DOUBLE_128;
#endif
/* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
can be optimized to ap = __builtin_next_arg (0). */
if (TARGET_ABI_UNICOSMK)
targetm.expand_builtin_va_start = NULL;
}
/* Returns 1 if VALUE is a mask that contains full bytes of zero or ones. */
int
zap_mask (HOST_WIDE_INT value)
{
int i;
for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
i++, value >>= 8)
if ((value & 0xff) != 0 && (value & 0xff) != 0xff)
return 0;
return 1;
}
/* Return true if OP is valid for a particular TLS relocation.
We are already guaranteed that OP is a CONST. */
int
tls_symbolic_operand_1 (rtx op, int size, int unspec)
{
op = XEXP (op, 0);
if (GET_CODE (op) != UNSPEC || XINT (op, 1) != unspec)
return 0;
op = XVECEXP (op, 0, 0);
if (GET_CODE (op) != SYMBOL_REF)
return 0;
switch (SYMBOL_REF_TLS_MODEL (op))
{
case TLS_MODEL_LOCAL_DYNAMIC:
return unspec == UNSPEC_DTPREL && size == alpha_tls_size;
case TLS_MODEL_INITIAL_EXEC:
return unspec == UNSPEC_TPREL && size == 64;
case TLS_MODEL_LOCAL_EXEC:
return unspec == UNSPEC_TPREL && size == alpha_tls_size;
default:
gcc_unreachable ();
}
}
/* Used by aligned_memory_operand and unaligned_memory_operand to
resolve what reload is going to do with OP if it's a register. */
rtx
resolve_reload_operand (rtx op)
{
if (reload_in_progress)
{
rtx tmp = op;
if (GET_CODE (tmp) == SUBREG)
tmp = SUBREG_REG (tmp);
if (REG_P (tmp)
&& REGNO (tmp) >= FIRST_PSEUDO_REGISTER)
{
op = reg_equiv_memory_loc[REGNO (tmp)];
if (op == 0)
return 0;
}
}
return op;
}
/* The scalar modes supported differs from the default check-what-c-supports
version in that sometimes TFmode is available even when long double
indicates only DFmode. On unicosmk, we have the situation that HImode
doesn't map to any C type, but of course we still support that. */
static bool
alpha_scalar_mode_supported_p (enum machine_mode mode)
{
switch (mode)
{
case QImode:
case HImode:
case SImode:
case DImode:
case TImode: /* via optabs.c */
return true;
case SFmode:
case DFmode:
return true;
case TFmode:
return TARGET_HAS_XFLOATING_LIBS;
default:
return false;
}
}
/* Alpha implements a couple of integer vector mode operations when
TARGET_MAX is enabled. We do not check TARGET_MAX here, however,
which allows the vectorizer to operate on e.g. move instructions,
or when expand_vector_operations can do something useful. */
static bool
alpha_vector_mode_supported_p (enum machine_mode mode)
{
return mode == V8QImode || mode == V4HImode || mode == V2SImode;
}
/* Return 1 if this function can directly return via $26. */
int
direct_return (void)
{
return (! TARGET_ABI_OPEN_VMS && ! TARGET_ABI_UNICOSMK
&& reload_completed
&& alpha_sa_size () == 0
&& get_frame_size () == 0
&& crtl->outgoing_args_size == 0
&& crtl->args.pretend_args_size == 0);
}
/* Return the ADDR_VEC associated with a tablejump insn. */
rtx
alpha_tablejump_addr_vec (rtx insn)
{
rtx tmp;
tmp = JUMP_LABEL (insn);
if (!tmp)
return NULL_RTX;
tmp = NEXT_INSN (tmp);
if (!tmp)
return NULL_RTX;
if (JUMP_P (tmp)
&& GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC)
return PATTERN (tmp);
return NULL_RTX;
}
/* Return the label of the predicted edge, or CONST0_RTX if we don't know. */
rtx
alpha_tablejump_best_label (rtx insn)
{
rtx jump_table = alpha_tablejump_addr_vec (insn);
rtx best_label = NULL_RTX;
/* ??? Once the CFG doesn't keep getting completely rebuilt, look
there for edge frequency counts from profile data. */
if (jump_table)
{
int n_labels = XVECLEN (jump_table, 1);
int best_count = -1;
int i, j;
for (i = 0; i < n_labels; i++)
{
int count = 1;
for (j = i + 1; j < n_labels; j++)
if (XEXP (XVECEXP (jump_table, 1, i), 0)
== XEXP (XVECEXP (jump_table, 1, j), 0))
count++;
if (count > best_count)
best_count = count, best_label = XVECEXP (jump_table, 1, i);
}
}
return best_label ? best_label : const0_rtx;
}
/* Return the TLS model to use for SYMBOL. */
static enum tls_model
tls_symbolic_operand_type (rtx symbol)
{
enum tls_model model;
if (GET_CODE (symbol) != SYMBOL_REF)
return TLS_MODEL_NONE;
model = SYMBOL_REF_TLS_MODEL (symbol);
/* Local-exec with a 64-bit size is the same code as initial-exec. */
if (model == TLS_MODEL_LOCAL_EXEC && alpha_tls_size == 64)
model = TLS_MODEL_INITIAL_EXEC;
return model;
}
/* Return true if the function DECL will share the same GP as any
function in the current unit of translation. */
static bool
decl_has_samegp (const_tree decl)
{
/* Functions that are not local can be overridden, and thus may
not share the same gp. */
if (!(*targetm.binds_local_p) (decl))
return false;
/* If -msmall-data is in effect, assume that there is only one GP
for the module, and so any local symbol has this property. We
need explicit relocations to be able to enforce this for symbols
not defined in this unit of translation, however. */
if (TARGET_EXPLICIT_RELOCS && TARGET_SMALL_DATA)
return true;
/* Functions that are not external are defined in this UoT. */
/* ??? Irritatingly, static functions not yet emitted are still
marked "external". Apply this to non-static functions only. */
return !TREE_PUBLIC (decl) || !DECL_EXTERNAL (decl);
}
/* Return true if EXP should be placed in the small data section. */
static bool
alpha_in_small_data_p (const_tree exp)
{
/* We want to merge strings, so we never consider them small data. */
if (TREE_CODE (exp) == STRING_CST)
return false;
/* Functions are never in the small data area. Duh. */
if (TREE_CODE (exp) == FUNCTION_DECL)
return false;
if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
{
const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
if (strcmp (section, ".sdata") == 0
|| strcmp (section, ".sbss") == 0)
return true;
}
else
{
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
/* If this is an incomplete type with size 0, then we can't put it
in sdata because it might be too big when completed. */
if (size > 0 && size <= g_switch_value)
return true;
}
return false;
}
#if TARGET_ABI_OPEN_VMS
static bool
vms_valid_pointer_mode (enum machine_mode mode)
{
return (mode == SImode || mode == DImode);
}
static bool
alpha_linkage_symbol_p (const char *symname)
{
int symlen = strlen (symname);
if (symlen > 4)
return strcmp (&symname [symlen - 4], "..lk") == 0;
return false;
}
#define LINKAGE_SYMBOL_REF_P(X) \
((GET_CODE (X) == SYMBOL_REF \
&& alpha_linkage_symbol_p (XSTR (X, 0))) \
|| (GET_CODE (X) == CONST \
&& GET_CODE (XEXP (X, 0)) == PLUS \
&& GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF \
&& alpha_linkage_symbol_p (XSTR (XEXP (XEXP (X, 0), 0), 0))))
#endif
/* legitimate_address_p recognizes an RTL expression that is a valid
memory address for an instruction. The MODE argument is the
machine mode for the MEM expression that wants to use this address.
For Alpha, we have either a constant address or the sum of a
register and a constant address, or just a register. For DImode,
any of those forms can be surrounded with an AND that clear the
low-order three bits; this is an "unaligned" access. */
static bool
alpha_legitimate_address_p (enum machine_mode mode, rtx x, bool strict)
{
/* If this is an ldq_u type address, discard the outer AND. */
if (mode == DImode
&& GET_CODE (x) == AND
&& CONST_INT_P (XEXP (x, 1))
&& INTVAL (XEXP (x, 1)) == -8)
x = XEXP (x, 0);
/* Discard non-paradoxical subregs. */
if (GET_CODE (x) == SUBREG
&& (GET_MODE_SIZE (GET_MODE (x))
< GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))))
x = SUBREG_REG (x);
/* Unadorned general registers are valid. */
if (REG_P (x)
&& (strict
? STRICT_REG_OK_FOR_BASE_P (x)
: NONSTRICT_REG_OK_FOR_BASE_P (x)))
return true;
/* Constant addresses (i.e. +/- 32k) are valid. */
if (CONSTANT_ADDRESS_P (x))
return true;
#if TARGET_ABI_OPEN_VMS
if (LINKAGE_SYMBOL_REF_P (x))
return true;
#endif
/* Register plus a small constant offset is valid. */
if (GET_CODE (x) == PLUS)
{
rtx ofs = XEXP (x, 1);
x = XEXP (x, 0);
/* Discard non-paradoxical subregs. */
if (GET_CODE (x) == SUBREG
&& (GET_MODE_SIZE (GET_MODE (x))
< GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))))
x = SUBREG_REG (x);
if (REG_P (x))
{
if (! strict
&& NONSTRICT_REG_OK_FP_BASE_P (x)
&& CONST_INT_P (ofs))
return true;
if ((strict
? STRICT_REG_OK_FOR_BASE_P (x)
: NONSTRICT_REG_OK_FOR_BASE_P (x))
&& CONSTANT_ADDRESS_P (ofs))
return true;
}
}
/* If we're managing explicit relocations, LO_SUM is valid, as are small
data symbols. Avoid explicit relocations of modes larger than word
mode since i.e. $LC0+8($1) can fold around +/- 32k offset. */
else if (TARGET_EXPLICIT_RELOCS
&& GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
{
if (small_symbolic_operand (x, Pmode))
return true;
if (GET_CODE (x) == LO_SUM)
{
rtx ofs = XEXP (x, 1);
x = XEXP (x, 0);
/* Discard non-paradoxical subregs. */
if (GET_CODE (x) == SUBREG
&& (GET_MODE_SIZE (GET_MODE (x))
< GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))))
x = SUBREG_REG (x);
/* Must have a valid base register. */
if (! (REG_P (x)
&& (strict
? STRICT_REG_OK_FOR_BASE_P (x)
: NONSTRICT_REG_OK_FOR_BASE_P (x))))
return false;
/* The symbol must be local. */
if (local_symbolic_operand (ofs, Pmode)
|| dtp32_symbolic_operand (ofs, Pmode)
|| tp32_symbolic_operand (ofs, Pmode))
return true;
}
}
return false;
}
/* Build the SYMBOL_REF for __tls_get_addr. */
static GTY(()) rtx tls_get_addr_libfunc;
static rtx
get_tls_get_addr (void)
{
if (!tls_get_addr_libfunc)
tls_get_addr_libfunc = init_one_libfunc ("__tls_get_addr");
return tls_get_addr_libfunc;
}
/* Try machine-dependent ways of modifying an illegitimate address
to be legitimate. If we find one, return the new, valid address. */
static rtx
alpha_legitimize_address_1 (rtx x, rtx scratch, enum machine_mode mode)
{
HOST_WIDE_INT addend;
/* If the address is (plus reg const_int) and the CONST_INT is not a
valid offset, compute the high part of the constant and add it to
the register. Then our address is (plus temp low-part-const). */
if (GET_CODE (x) == PLUS
&& REG_P (XEXP (x, 0))
&& CONST_INT_P (XEXP (x, 1))
&& ! CONSTANT_ADDRESS_P (XEXP (x, 1)))
{
addend = INTVAL (XEXP (x, 1));
x = XEXP (x, 0);
goto split_addend;
}
/* If the address is (const (plus FOO const_int)), find the low-order
part of the CONST_INT. Then load FOO plus any high-order part of the
CONST_INT into a register. Our address is (plus reg low-part-const).
This is done to reduce the number of GOT entries. */
if (can_create_pseudo_p ()
&& GET_CODE (x) == CONST
&& GET_CODE (XEXP (x, 0)) == PLUS
&& CONST_INT_P (XEXP (XEXP (x, 0), 1)))
{
addend = INTVAL (XEXP (XEXP (x, 0), 1));
x = force_reg (Pmode, XEXP (XEXP (x, 0), 0));
goto split_addend;
}
/* If we have a (plus reg const), emit the load as in (2), then add
the two registers, and finally generate (plus reg low-part-const) as
our address. */
if (can_create_pseudo_p ()
&& GET_CODE (x) == PLUS
&& REG_P (XEXP (x, 0))
&& GET_CODE (XEXP (x, 1)) == CONST
&& GET_CODE (XEXP (XEXP (x, 1), 0)) == PLUS
&& CONST_INT_P (XEXP (XEXP (XEXP (x, 1), 0), 1)))
{
addend = INTVAL (XEXP (XEXP (XEXP (x, 1), 0), 1));
x = expand_simple_binop (Pmode, PLUS, XEXP (x, 0),
XEXP (XEXP (XEXP (x, 1), 0), 0),
NULL_RTX, 1, OPTAB_LIB_WIDEN);
goto split_addend;
}
/* If this is a local symbol, split the address into HIGH/LO_SUM parts.
Avoid modes larger than word mode since i.e. $LC0+8($1) can fold
around +/- 32k offset. */
if (TARGET_EXPLICIT_RELOCS
&& GET_MODE_SIZE (mode) <= UNITS_PER_WORD
&& symbolic_operand (x, Pmode))
{
rtx r0, r16, eqv, tga, tp, insn, dest, seq;
switch (tls_symbolic_operand_type (x))
{
case TLS_MODEL_NONE:
break;
case TLS_MODEL_GLOBAL_DYNAMIC:
start_sequence ();
r0 = gen_rtx_REG (Pmode, 0);
r16 = gen_rtx_REG (Pmode, 16);
tga = get_tls_get_addr ();
dest = gen_reg_rtx (Pmode);
seq = GEN_INT (alpha_next_sequence_number++);
emit_insn (gen_movdi_er_tlsgd (r16, pic_offset_table_rtx, x, seq));
insn = gen_call_value_osf_tlsgd (r0, tga, seq);
insn = emit_call_insn (insn);
RTL_CONST_CALL_P (insn) = 1;
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r16);
insn = get_insns ();
end_sequence ();
emit_libcall_block (insn, dest, r0, x);
return dest;
case TLS_MODEL_LOCAL_DYNAMIC:
start_sequence ();
r0 = gen_rtx_REG (Pmode, 0);
r16 = gen_rtx_REG (Pmode, 16);
tga = get_tls_get_addr ();
scratch = gen_reg_rtx (Pmode);
seq = GEN_INT (alpha_next_sequence_number++);
emit_insn (gen_movdi_er_tlsldm (r16, pic_offset_table_rtx, seq));
insn = gen_call_value_osf_tlsldm (r0, tga, seq);
insn = emit_call_insn (insn);
RTL_CONST_CALL_P (insn) = 1;
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r16);
insn = get_insns ();
end_sequence ();
eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
UNSPEC_TLSLDM_CALL);
emit_libcall_block (insn, scratch, r0, eqv);
eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, x), UNSPEC_DTPREL);
eqv = gen_rtx_CONST (Pmode, eqv);
if (alpha_tls_size == 64)
{
dest = gen_reg_rtx (Pmode);
emit_insn (gen_rtx_SET (VOIDmode, dest, eqv));
emit_insn (gen_adddi3 (dest, dest, scratch));
return dest;
}
if (alpha_tls_size == 32)
{
insn = gen_rtx_HIGH (Pmode, eqv);
insn = gen_rtx_PLUS (Pmode, scratch, insn);
scratch = gen_reg_rtx (Pmode);
emit_insn (gen_rtx_SET (VOIDmode, scratch, insn));
}
return gen_rtx_LO_SUM (Pmode, scratch, eqv);
case TLS_MODEL_INITIAL_EXEC:
eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, x), UNSPEC_TPREL);
eqv = gen_rtx_CONST (Pmode, eqv);
tp = gen_reg_rtx (Pmode);
scratch = gen_reg_rtx (Pmode);
dest = gen_reg_rtx (Pmode);
emit_insn (gen_load_tp (tp));
emit_insn (gen_rtx_SET (VOIDmode, scratch, eqv));
emit_insn (gen_adddi3 (dest, tp, scratch));
return dest;
case TLS_MODEL_LOCAL_EXEC:
eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, x), UNSPEC_TPREL);
eqv = gen_rtx_CONST (Pmode, eqv);
tp = gen_reg_rtx (Pmode);
emit_insn (gen_load_tp (tp));
if (alpha_tls_size == 32)
{
insn = gen_rtx_HIGH (Pmode, eqv);
insn = gen_rtx_PLUS (Pmode, tp, insn);
tp = gen_reg_rtx (Pmode);
emit_insn (gen_rtx_SET (VOIDmode, tp, insn));
}
return gen_rtx_LO_SUM (Pmode, tp, eqv);
default:
gcc_unreachable ();
}
if (local_symbolic_operand (x, Pmode))
{
if (small_symbolic_operand (x, Pmode))
return x;
else
{
if (can_create_pseudo_p ())
scratch = gen_reg_rtx (Pmode);
emit_insn (gen_rtx_SET (VOIDmode, scratch,
gen_rtx_HIGH (Pmode, x)));
return gen_rtx_LO_SUM (Pmode, scratch, x);
}
}
}
return NULL;
split_addend:
{
HOST_WIDE_INT low, high;
low = ((addend & 0xffff) ^ 0x8000) - 0x8000;
addend -= low;
high = ((addend & 0xffffffff) ^ 0x80000000) - 0x80000000;
addend -= high;
if (addend)
x = expand_simple_binop (Pmode, PLUS, x, GEN_INT (addend),
(!can_create_pseudo_p () ? scratch : NULL_RTX),
1, OPTAB_LIB_WIDEN);
if (high)
x = expand_simple_binop (Pmode, PLUS, x, GEN_INT (high),
(!can_create_pseudo_p () ? scratch : NULL_RTX),
1, OPTAB_LIB_WIDEN);
return plus_constant (x, low);
}
}
/* Try machine-dependent ways of modifying an illegitimate address
to be legitimate. Return X or the new, valid address. */
static rtx
alpha_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
enum machine_mode mode)
{
rtx new_x = alpha_legitimize_address_1 (x, NULL_RTX, mode);
return new_x ? new_x : x;
}
/* Primarily this is required for TLS symbols, but given that our move
patterns *ought* to be able to handle any symbol at any time, we
should never be spilling symbolic operands to the constant pool, ever. */
static bool
alpha_cannot_force_const_mem (rtx x)
{
enum rtx_code code = GET_CODE (x);
return code == SYMBOL_REF || code == LABEL_REF || code == CONST;
}
/* We do not allow indirect calls to be optimized into sibling calls, nor
can we allow a call to a function with a different GP to be optimized
into a sibcall. */
static bool
alpha_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
{
/* Can't do indirect tail calls, since we don't know if the target
uses the same GP. */
if (!decl)
return false;
/* Otherwise, we can make a tail call if the target function shares
the same GP. */
return decl_has_samegp (decl);
}
int
some_small_symbolic_operand_int (rtx *px, void *data ATTRIBUTE_UNUSED)
{
rtx x = *px;
/* Don't re-split. */
if (GET_CODE (x) == LO_SUM)
return -1;
return small_symbolic_operand (x, Pmode) != 0;
}
static int
split_small_symbolic_operand_1 (rtx *px, void *data ATTRIBUTE_UNUSED)
{
rtx x = *px;
/* Don't re-split. */
if (GET_CODE (x) == LO_SUM)
return -1;
if (small_symbolic_operand (x, Pmode))
{
x = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, x);
*px = x;
return -1;
}
return 0;
}
rtx
split_small_symbolic_operand (rtx x)
{
x = copy_insn (x);
for_each_rtx (&x, split_small_symbolic_operand_1, NULL);
return x;
}
/* Indicate that INSN cannot be duplicated. This is true for any insn
that we've marked with gpdisp relocs, since those have to stay in
1-1 correspondence with one another.
Technically we could copy them if we could set up a mapping from one
sequence number to another, across the set of insns to be duplicated.
This seems overly complicated and error-prone since interblock motion
from sched-ebb could move one of the pair of insns to a different block.
Also cannot allow jsr insns to be duplicated. If they throw exceptions,
then they'll be in a different block from their ldgp. Which could lead
the bb reorder code to think that it would be ok to copy just the block
containing the call and branch to the block containing the ldgp. */
static bool
alpha_cannot_copy_insn_p (rtx insn)
{
if (!reload_completed || !TARGET_EXPLICIT_RELOCS)
return false;
if (recog_memoized (insn) >= 0)
return get_attr_cannot_copy (insn);
else
return false;
}
/* Try a machine-dependent way of reloading an illegitimate address
operand. If we find one, push the reload and return the new rtx. */
rtx
alpha_legitimize_reload_address (rtx x,
enum machine_mode mode ATTRIBUTE_UNUSED,
int opnum, int type,
int ind_levels ATTRIBUTE_UNUSED)
{
/* We must recognize output that we have already generated ourselves. */
if (GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 0)) == PLUS
&& REG_P (XEXP (XEXP (x, 0), 0))
&& CONST_INT_P (XEXP (XEXP (x, 0), 1))
&& CONST_INT_P (XEXP (x, 1)))
{
push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
opnum, (enum reload_type) type);
return x;
}
/* We wish to handle large displacements off a base register by
splitting the addend across an ldah and the mem insn. This
cuts number of extra insns needed from 3 to 1. */
if (GET_CODE (x) == PLUS
&& REG_P (XEXP (x, 0))
&& REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
&& REGNO_OK_FOR_BASE_P (REGNO (XEXP (x, 0)))
&& GET_CODE (XEXP (x, 1)) == CONST_INT)
{
HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
HOST_WIDE_INT high
= (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;
/* Check for 32-bit overflow. */
if (high + low != val)
return NULL_RTX;
/* Reload the high part into a base reg; leave the low part
in the mem directly. */
x = gen_rtx_PLUS (GET_MODE (x),
gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
GEN_INT (high)),
GEN_INT (low));
push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
opnum, (enum reload_type) type);
return x;
}
return NULL_RTX;
}
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */
static bool
alpha_rtx_costs (rtx x, int code, int outer_code, int *total,
bool speed)
{
enum machine_mode mode = GET_MODE (x);
bool float_mode_p = FLOAT_MODE_P (mode);
const struct alpha_rtx_cost_data *cost_data;
if (!speed)
cost_data = &alpha_rtx_cost_size;
else
cost_data = &alpha_rtx_cost_data[alpha_tune];
switch (code)
{
case CONST_INT:
/* If this is an 8-bit constant, return zero since it can be used
nearly anywhere with no cost. If it is a valid operand for an
ADD or AND, likewise return 0 if we know it will be used in that
context. Otherwise, return 2 since it might be used there later.
All other constants take at least two insns. */
if (INTVAL (x) >= 0 && INTVAL (x) < 256)
{
*total = 0;
return true;
}
/* FALLTHRU */
case CONST_DOUBLE:
if (x == CONST0_RTX (mode))
*total = 0;
else if ((outer_code == PLUS && add_operand (x, VOIDmode))
|| (outer_code == AND && and_operand (x, VOIDmode)))
*total = 0;
else if (add_operand (x, VOIDmode) || and_operand (x, VOIDmode))
*total = 2;
else
*total = COSTS_N_INSNS (2);
return true;
case CONST:
case SYMBOL_REF:
case LABEL_REF:
if (TARGET_EXPLICIT_RELOCS && small_symbolic_operand (x, VOIDmode))
*total = COSTS_N_INSNS (outer_code != MEM);
else if (TARGET_EXPLICIT_RELOCS && local_symbolic_operand (x, VOIDmode))
*total = COSTS_N_INSNS (1 + (outer_code != MEM));
else if (tls_symbolic_operand_type (x))
/* Estimate of cost for call_pal rduniq. */
/* ??? How many insns do we emit here? More than one... */
*total = COSTS_N_INSNS (15);
else
/* Otherwise we do a load from the GOT. */
*total = COSTS_N_INSNS (!speed ? 1 : alpha_memory_latency);
return true;
case HIGH:
/* This is effectively an add_operand. */
*total = 2;
return true;
case PLUS:
case MINUS:
if (float_mode_p)
*total = cost_data->fp_add;
else if (GET_CODE (XEXP (x, 0)) == MULT
&& const48_operand (XEXP (XEXP (x, 0), 1), VOIDmode))
{
*total = (rtx_cost (XEXP (XEXP (x, 0), 0),
(enum rtx_code) outer_code, speed)
+ rtx_cost (XEXP (x, 1),
(enum rtx_code) outer_code, speed)
+ COSTS_N_INSNS (1));
return true;
}
return false;
case MULT:
if (float_mode_p)
*total = cost_data->fp_mult;
else if (mode == DImode)
*total = cost_data->int_mult_di;
else
*total = cost_data->int_mult_si;
return false;
case ASHIFT:
if (CONST_INT_P (XEXP (x, 1))
&& INTVAL (XEXP (x, 1)) <= 3)
{
*total = COSTS_N_INSNS (1);
return false;
}
/* FALLTHRU */
case ASHIFTRT:
case LSHIFTRT:
*total = cost_data->int_shift;
return false;
case IF_THEN_ELSE:
if (float_mode_p)
*total = cost_data->fp_add;
else
*total = cost_data->int_cmov;
return false;
case DIV:
case UDIV:
case MOD:
case UMOD:
if (!float_mode_p)
*total = cost_data->int_div;
else if (mode == SFmode)
*total = cost_data->fp_div_sf;
else
*total = cost_data->fp_div_df;
return false;
case MEM:
*total = COSTS_N_INSNS (!speed ? 1 : alpha_memory_latency);
return true;
case NEG:
if (! float_mode_p)
{
*total = COSTS_N_INSNS (1);
return false;
}
/* FALLTHRU */
case ABS:
if (! float_mode_p)
{
*total = COSTS_N_INSNS (1) + cost_data->int_cmov;
return false;
}
/* FALLTHRU */
case FLOAT:
case UNSIGNED_FLOAT:
case FIX:
case UNSIGNED_FIX:
case FLOAT_TRUNCATE:
*total = cost_data->fp_add;
return false;
case FLOAT_EXTEND:
if (MEM_P (XEXP (x, 0)))
*total = 0;
else
*total = cost_data->fp_add;
return false;
default:
return false;
}
}
/* REF is an alignable memory location. Place an aligned SImode
reference into *PALIGNED_MEM and the number of bits to shift into
*PBITNUM. SCRATCH is a free register for use in reloading out
of range stack slots. */
void
get_aligned_mem (rtx ref, rtx *paligned_mem, rtx *pbitnum)
{
rtx base;
HOST_WIDE_INT disp, offset;
gcc_assert (MEM_P (ref));
if (reload_in_progress
&& ! memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
{
base = find_replacement (&XEXP (ref, 0));
gcc_assert (memory_address_p (GET_MODE (ref), base));
}
else
base = XEXP (ref, 0);
if (GET_CODE (base) == PLUS)
disp = INTVAL (XEXP (base, 1)), base = XEXP (base, 0);
else
disp = 0;
/* Find the byte offset within an aligned word. If the memory itself is
claimed to be aligned, believe it. Otherwise, aligned_memory_operand
will have examined the base register and determined it is aligned, and
thus displacements from it are naturally alignable. */
if (MEM_ALIGN (ref) >= 32)
offset = 0;
else
offset = disp & 3;
/* The location should not cross aligned word boundary. */
gcc_assert (offset + GET_MODE_SIZE (GET_MODE (ref))
<= GET_MODE_SIZE (SImode));
/* Access the entire aligned word. */
*paligned_mem = widen_memory_access (ref, SImode, -offset);
/* Convert the byte offset within the word to a bit offset. */
if (WORDS_BIG_ENDIAN)
offset = 32 - (GET_MODE_BITSIZE (GET_MODE (ref)) + offset * 8);
else
offset *= 8;
*pbitnum = GEN_INT (offset);
}
/* Similar, but just get the address. Handle the two reload cases.
Add EXTRA_OFFSET to the address we return. */
rtx
get_unaligned_address (rtx ref)
{
rtx base;
HOST_WIDE_INT offset = 0;
gcc_assert (MEM_P (ref));
if (reload_in_progress
&& ! memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
{
base = find_replacement (&XEXP (ref, 0));
gcc_assert (memory_address_p (GET_MODE (ref), base));
}
else
base = XEXP (ref, 0);
if (GET_CODE (base) == PLUS)
offset += INTVAL (XEXP (base, 1)), base = XEXP (base, 0);
return plus_constant (base, offset);
}
/* Compute a value X, such that X & 7 == (ADDR + OFS) & 7.
X is always returned in a register. */
rtx
get_unaligned_offset (rtx addr, HOST_WIDE_INT ofs)
{
if (GET_CODE (addr) == PLUS)
{
ofs += INTVAL (XEXP (addr, 1));
addr = XEXP (addr, 0);
}
return expand_simple_binop (Pmode, PLUS, addr, GEN_INT (ofs & 7),
NULL_RTX, 1, OPTAB_LIB_WIDEN);
}
/* On the Alpha, all (non-symbolic) constants except zero go into
a floating-point register via memory. Note that we cannot
return anything that is not a subset of RCLASS, and that some
symbolic constants cannot be dropped to memory. */
enum reg_class
alpha_preferred_reload_class(rtx x, enum reg_class rclass)
{
/* Zero is present in any register class. */
if (x == CONST0_RTX (GET_MODE (x)))
return rclass;
/* These sorts of constants we can easily drop to memory. */
if (CONST_INT_P (x)
|| GET_CODE (x) == CONST_DOUBLE
|| GET_CODE (x) == CONST_VECTOR)
{
if (rclass == FLOAT_REGS)
return NO_REGS;
if (rclass == ALL_REGS)
return GENERAL_REGS;
return rclass;
}
/* All other kinds of constants should not (and in the case of HIGH
cannot) be dropped to memory -- instead we use a GENERAL_REGS
secondary reload. */
if (CONSTANT_P (x))
return (rclass == ALL_REGS ? GENERAL_REGS : rclass);
return rclass;
}
/* Inform reload about cases where moving X with a mode MODE to a register in
RCLASS requires an extra scratch or immediate register. Return the class
needed for the immediate register. */
static reg_class_t
alpha_secondary_reload (bool in_p, rtx x, reg_class_t rclass_i,
enum machine_mode mode, secondary_reload_info *sri)
{
enum reg_class rclass = (enum reg_class) rclass_i;
/* Loading and storing HImode or QImode values to and from memory
usually requires a scratch register. */
if (!TARGET_BWX && (mode == QImode || mode == HImode || mode == CQImode))
{
if (any_memory_operand (x, mode))
{
if (in_p)
{
if (!aligned_memory_operand (x, mode))
sri->icode = direct_optab_handler (reload_in_optab, mode);
}
else
sri->icode = direct_optab_handler (reload_out_optab, mode);
return NO_REGS;
}
}
/* We also cannot do integral arithmetic into FP regs, as might result
from register elimination into a DImode fp register. */
if (rclass == FLOAT_REGS)
{
if (MEM_P (x) && GET_CODE (XEXP (x, 0)) == AND)
return GENERAL_REGS;
if (in_p && INTEGRAL_MODE_P (mode)
&& !MEM_P (x) && !REG_P (x) && !CONST_INT_P (x))
return GENERAL_REGS;
}
return NO_REGS;
}
/* Subfunction of the following function. Update the flags of any MEM
found in part of X. */
static int
alpha_set_memflags_1 (rtx *xp, void *data)
{
rtx x = *xp, orig = (rtx) data;
if (!MEM_P (x))
return 0;
MEM_VOLATILE_P (x) = MEM_VOLATILE_P (orig);
MEM_IN_STRUCT_P (x) = MEM_IN_STRUCT_P (orig);
MEM_SCALAR_P (x) = MEM_SCALAR_P (orig);
MEM_NOTRAP_P (x) = MEM_NOTRAP_P (orig);
MEM_READONLY_P (x) = MEM_READONLY_P (orig);
/* Sadly, we cannot use alias sets because the extra aliasing
produced by the AND interferes. Given that two-byte quantities
are the only thing we would be able to differentiate anyway,
there does not seem to be any point in convoluting the early
out of the alias check. */
return -1;
}
/* Given SEQ, which is an INSN list, look for any MEMs in either
a SET_DEST or a SET_SRC and copy the in-struct, unchanging, and
volatile flags from REF into each of the MEMs found. If REF is not
a MEM, don't do anything. */
void
alpha_set_memflags (rtx seq, rtx ref)
{
rtx insn;
if (!MEM_P (ref))
return;
/* This is only called from alpha.md, after having had something
generated from one of the insn patterns. So if everything is
zero, the pattern is already up-to-date. */
if (!MEM_VOLATILE_P (ref)
&& !MEM_IN_STRUCT_P (ref)
&& !MEM_SCALAR_P (ref)
&& !MEM_NOTRAP_P (ref)
&& !MEM_READONLY_P (ref))
return;
for (insn = seq; insn; insn = NEXT_INSN (insn))
if (INSN_P (insn))
for_each_rtx (&PATTERN (insn), alpha_set_memflags_1, (void *) ref);
else
gcc_unreachable ();
}
static rtx alpha_emit_set_const (rtx, enum machine_mode, HOST_WIDE_INT,
int, bool);
/* Internal routine for alpha_emit_set_const to check for N or below insns.
If NO_OUTPUT is true, then we only check to see if N insns are possible,
and return pc_rtx if successful. */
static rtx
alpha_emit_set_const_1 (rtx target, enum machine_mode mode,
HOST_WIDE_INT c, int n, bool no_output)
{
HOST_WIDE_INT new_const;
int i, bits;
/* Use a pseudo if highly optimizing and still generating RTL. */
rtx subtarget
= (flag_expensive_optimizations && can_create_pseudo_p () ? 0 : target);
rtx temp, insn;
/* If this is a sign-extended 32-bit constant, we can do this in at most
three insns, so do it if we have enough insns left. We always have
a sign-extended 32-bit constant when compiling on a narrow machine. */
if (HOST_BITS_PER_WIDE_INT != 64
|| c >> 31 == -1 || c >> 31 == 0)
{
HOST_WIDE_INT low = ((c & 0xffff) ^ 0x8000) - 0x8000;
HOST_WIDE_INT tmp1 = c - low;
HOST_WIDE_INT high = (((tmp1 >> 16) & 0xffff) ^ 0x8000) - 0x8000;
HOST_WIDE_INT extra = 0;
/* If HIGH will be interpreted as negative but the constant is
positive, we must adjust it to do two ldha insns. */
if ((high & 0x8000) != 0 && c >= 0)
{
extra = 0x4000;
tmp1 -= 0x40000000;
high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000);
}
if (c == low || (low == 0 && extra == 0))
{
/* We used to use copy_to_suggested_reg (GEN_INT (c), target, mode)
but that meant that we can't handle INT_MIN on 32-bit machines
(like NT/Alpha), because we recurse indefinitely through
emit_move_insn to gen_movdi. So instead, since we know exactly
what we want, create it explicitly. */
if (no_output)
return pc_rtx;
if (target == NULL)
target = gen_reg_rtx (mode);
emit_insn (gen_rtx_SET (VOIDmode, target, GEN_INT (c)));
return target;
}
else if (n >= 2 + (extra != 0))
{
if (no_output)
return pc_rtx;
if (!can_create_pseudo_p ())
{
emit_insn (gen_rtx_SET (VOIDmode, target, GEN_INT (high << 16)));
temp = target;
}
else
temp = copy_to_suggested_reg (GEN_INT (high << 16),
subtarget, mode);
/* As of 2002-02-23, addsi3 is only available when not optimizing.
This means that if we go through expand_binop, we'll try to
generate extensions, etc, which will require new pseudos, which
will fail during some split phases. The SImode add patterns
still exist, but are not named. So build the insns by hand. */
if (extra != 0)
{
if (! subtarget)
subtarget = gen_reg_rtx (mode);
insn = gen_rtx_PLUS (mode, temp, GEN_INT (extra << 16));
insn = gen_rtx_SET (VOIDmode, subtarget, insn);
emit_insn (insn);
temp = subtarget;
}
if (target == NULL)
target = gen_reg_rtx (mode);
insn = gen_rtx_PLUS (mode, temp, GEN_INT (low));
insn = gen_rtx_SET (VOIDmode, target, insn);
emit_insn (insn);
return target;
}
}
/* If we couldn't do it that way, try some other methods. But if we have
no instructions left, don't bother. Likewise, if this is SImode and
we can't make pseudos, we can't do anything since the expand_binop
and expand_unop calls will widen and try to make pseudos. */
if (n == 1 || (mode == SImode && !can_create_pseudo_p ()))
return 0;
/* Next, see if we can load a related constant and then shift and possibly
negate it to get the constant we want. Try this once each increasing
numbers of insns. */
for (i = 1; i < n; i++)
{
/* First, see if minus some low bits, we've an easy load of
high bits. */
new_const = ((c & 0xffff) ^ 0x8000) - 0x8000;
if (new_const != 0)
{
temp = alpha_emit_set_const (subtarget, mode, c - new_const, i, no_output);
if (temp)
{
if (no_output)
return temp;
return expand_binop (mode, add_optab, temp, GEN_INT (new_const),
target, 0, OPTAB_WIDEN);
}
}
/* Next try complementing. */
temp = alpha_emit_set_const (subtarget, mode, ~c, i, no_output);
if (temp)
{
if (no_output)
return temp;
return expand_unop (mode, one_cmpl_optab, temp, target, 0);
}
/* Next try to form a constant and do a left shift. We can do this
if some low-order bits are zero; the exact_log2 call below tells
us that information. The bits we are shifting out could be any
value, but here we'll just try the 0- and sign-extended forms of
the constant. To try to increase the chance of having the same
constant in more than one insn, start at the highest number of
bits to shift, but try all possibilities in case a ZAPNOT will
be useful. */
bits = exact_log2 (c & -c);
if (bits > 0)
for (; bits > 0; bits--)
{
new_const = c >> bits;
temp = alpha_emit_set_const (subtarget, mode, new_const, i, no_output);
if (!temp && c < 0)
{
new_const = (unsigned HOST_WIDE_INT)c >> bits;
temp = alpha_emit_set_const (subtarget, mode, new_const,
i, no_output);
}
if (temp)
{
if (no_output)
return temp;
return expand_binop (mode, ashl_optab, temp, GEN_INT (bits),
target, 0, OPTAB_WIDEN);
}
}
/* Now try high-order zero bits. Here we try the shifted-in bits as
all zero and all ones. Be careful to avoid shifting outside the
mode and to avoid shifting outside the host wide int size. */
/* On narrow hosts, don't shift a 1 into the high bit, since we'll
confuse the recursive call and set all of the high 32 bits. */
bits = (MIN (HOST_BITS_PER_WIDE_INT, GET_MODE_SIZE (mode) * 8)
- floor_log2 (c) - 1 - (HOST_BITS_PER_WIDE_INT < 64));
if (bits > 0)
for (; bits > 0; bits--)
{
new_const = c << bits;
temp = alpha_emit_set_const (subtarget, mode, new_const, i, no_output);
if (!temp)
{
new_const = (c << bits) | (((HOST_WIDE_INT) 1 << bits) - 1);
temp = alpha_emit_set_const (subtarget, mode, new_const,
i, no_output);
}
if (temp)
{
if (no_output)
return temp;
return expand_binop (mode, lshr_optab, temp, GEN_INT (bits),
target, 1, OPTAB_WIDEN);
}
}
/* Now try high-order 1 bits. We get that with a sign-extension.
But one bit isn't enough here. Be careful to avoid shifting outside
the mode and to avoid shifting outside the host wide int size. */
bits = (MIN (HOST_BITS_PER_WIDE_INT, GET_MODE_SIZE (mode) * 8)
- floor_log2 (~ c) - 2);
if (bits > 0)
for (; bits > 0; bits--)
{
new_const = c << bits;
temp = alpha_emit_set_const (subtarget, mode, new_const, i, no_output);
if (!temp)
{
new_const = (c << bits) | (((HOST_WIDE_INT) 1 << bits) - 1);
temp = alpha_emit_set_const (subtarget, mode, new_const,
i, no_output);
}
if (temp)
{
if (no_output)
return temp;
return expand_binop (mode, ashr_optab, temp, GEN_INT (bits),
target, 0, OPTAB_WIDEN);
}
}
}
#if HOST_BITS_PER_WIDE_INT == 64
/* Finally, see if can load a value into the target that is the same as the
constant except that all bytes that are 0 are changed to be 0xff. If we
can, then we can do a ZAPNOT to obtain the desired constant. */
new_const = c;
for (i = 0; i < 64; i += 8)
if ((new_const & ((HOST_WIDE_INT) 0xff << i)) == 0)
new_const |= (HOST_WIDE_INT) 0xff << i;
/* We are only called for SImode and DImode. If this is SImode, ensure that
we are sign extended to a full word. */
if (mode == SImode)
new_const = ((new_const & 0xffffffff) ^ 0x80000000) - 0x80000000;
if (new_const != c)
{
temp = alpha_emit_set_const (subtarget, mode, new_const, n - 1, no_output);
if (temp)
{
if (no_output)
return temp;
return expand_binop (mode, and_optab, temp, GEN_INT (c | ~ new_const),
target, 0, OPTAB_WIDEN);
}
}
#endif
return 0;
}
/* Try to output insns to set TARGET equal to the constant C if it can be
done in less than N insns. Do all computations in MODE. Returns the place
where the output has been placed if it can be done and the insns have been
emitted. If it would take more than N insns, zero is returned and no
insns and emitted. */
static rtx
alpha_emit_set_const (rtx target, enum machine_mode mode,
HOST_WIDE_INT c, int n, bool no_output)
{
enum machine_mode orig_mode = mode;
rtx orig_target = target;
rtx result = 0;
int i;
/* If we can't make any pseudos, TARGET is an SImode hard register, we
can't load this constant in one insn, do this in DImode. */
if (!can_create_pseudo_p () && mode == SImode
&& REG_P (target) && REGNO (target) < FIRST_PSEUDO_REGISTER)
{
result = alpha_emit_set_const_1 (target, mode, c, 1, no_output);
if (result)
return result;
target = no_output ? NULL : gen_lowpart (DImode, target);
mode = DImode;
}
else if (mode == V8QImode || mode == V4HImode || mode == V2SImode)
{
target = no_output ? NULL : gen_lowpart (DImode, target);
mode = DImode;
}
/* Try 1 insn, then 2, then up to N. */
for (i = 1; i <= n; i++)
{
result = alpha_emit_set_const_1 (target, mode, c, i, no_output);
if (result)
{
rtx insn, set;
if (no_output)
return result;
insn = get_last_insn ();
set = single_set (insn);
if (! CONSTANT_P (SET_SRC (set)))
set_unique_reg_note (get_last_insn (), REG_EQUAL, GEN_INT (c));
break;
}
}
/* Allow for the case where we changed the mode of TARGET. */
if (result)
{
if (result == target)
result = orig_target;
else if (mode != orig_mode)
result = gen_lowpart (orig_mode, result);
}
return result;
}
/* Having failed to find a 3 insn sequence in alpha_emit_set_const,
fall back to a straight forward decomposition. We do this to avoid
exponential run times encountered when looking for longer sequences
with alpha_emit_set_const. */
static rtx
alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1, HOST_WIDE_INT c2)
{
HOST_WIDE_INT d1, d2, d3, d4;
/* Decompose the entire word */
#if HOST_BITS_PER_WIDE_INT >= 64
gcc_assert (c2 == -(c1 < 0));
d1 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
c1 -= d1;
d2 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
c1 = (c1 - d2) >> 32;
d3 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
c1 -= d3;
d4 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
gcc_assert (c1 == d4);
#else
d1 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
c1 -= d1;
d2 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
gcc_assert (c1 == d2);
c2 += (d2 < 0);
d3 = ((c2 & 0xffff) ^ 0x8000) - 0x8000;
c2 -= d3;
d4 = ((c2 & 0xffffffff) ^ 0x80000000) - 0x80000000;
gcc_assert (c2 == d4);
#endif
/* Construct the high word */
if (d4)
{
emit_move_insn (target, GEN_INT (d4));
if (d3)
emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d3)));
}
else
emit_move_insn (target, GEN_INT (d3));
/* Shift it into place */
emit_move_insn (target, gen_rtx_ASHIFT (DImode, target, GEN_INT (32)));
/* Add in the low bits. */
if (d2)
emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d2)));
if (d1)
emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d1)));
return target;
}
/* Given an integral CONST_INT, CONST_DOUBLE, or CONST_VECTOR, return
the low 64 bits. */
static void
alpha_extract_integer (rtx x, HOST_WIDE_INT *p0, HOST_WIDE_INT *p1)
{
HOST_WIDE_INT i0, i1;
if (GET_CODE (x) == CONST_VECTOR)
x = simplify_subreg (DImode, x, GET_MODE (x), 0);
if (CONST_INT_P (x))
{
i0 = INTVAL (x);
i1 = -(i0 < 0);
}
else if (HOST_BITS_PER_WIDE_INT >= 64)
{
i0 = CONST_DOUBLE_LOW (x);
i1 = -(i0 < 0);
}
else
{
i0 = CONST_DOUBLE_LOW (x);
i1 = CONST_DOUBLE_HIGH (x);
}
*p0 = i0;
*p1 = i1;
}
/* Implement LEGITIMATE_CONSTANT_P. This is all constants for which we
are willing to load the value into a register via a move pattern.
Normally this is all symbolic constants, integral constants that
take three or fewer instructions, and floating-point zero. */
bool
alpha_legitimate_constant_p (rtx x)
{
enum machine_mode mode = GET_MODE (x);
HOST_WIDE_INT i0, i1;
switch (GET_CODE (x))
{
case LABEL_REF:
case HIGH:
return true;
case CONST:
if (GET_CODE (XEXP (x, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
x = XEXP (XEXP (x, 0), 0);
else
return true;
if (GET_CODE (x) != SYMBOL_REF)
return true;
/* FALLTHRU */
case SYMBOL_REF:
/* TLS symbols are never valid. */
return SYMBOL_REF_TLS_MODEL (x) == 0;
case CONST_DOUBLE:
if (x == CONST0_RTX (mode))
return true;
if (FLOAT_MODE_P (mode))
return false;
goto do_integer;
case CONST_VECTOR:
if (x == CONST0_RTX (mode))
return true;
if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
return false;
if (GET_MODE_SIZE (mode) != 8)
return false;
goto do_integer;
case CONST_INT:
do_integer:
if (TARGET_BUILD_CONSTANTS)
return true;
alpha_extract_integer (x, &i0, &i1);
if (HOST_BITS_PER_WIDE_INT >= 64 || i1 == (-i0 < 0))
return alpha_emit_set_const_1 (x, mode, i0, 3, true) != NULL;
return false;
default:
return false;
}
}
/* Operand 1 is known to be a constant, and should require more than one
instruction to load. Emit that multi-part load. */
bool
alpha_split_const_mov (enum machine_mode mode, rtx *operands)
{
HOST_WIDE_INT i0, i1;
rtx temp = NULL_RTX;
alpha_extract_integer (operands[1], &i0, &i1);
if (HOST_BITS_PER_WIDE_INT >= 64 || i1 == -(i0 < 0))
temp = alpha_emit_set_const (operands[0], mode, i0, 3, false);
if (!temp && TARGET_BUILD_CONSTANTS)
temp = alpha_emit_set_long_const (operands[0], i0, i1);
if (temp)
{
if (!rtx_equal_p (operands[0], temp))
emit_move_insn (operands[0], temp);
return true;
}
return false;
}
/* Expand a move instruction; return true if all work is done.
We don't handle non-bwx subword loads here. */
bool
alpha_expand_mov (enum machine_mode mode, rtx *operands)
{
rtx tmp;
/* If the output is not a register, the input must be. */
if (MEM_P (operands[0])
&& ! reg_or_0_operand (operands[1], mode))
operands[1] = force_reg (mode, operands[1]);
/* Allow legitimize_address to perform some simplifications. */
if (mode == Pmode && symbolic_operand (operands[1], mode))
{
tmp = alpha_legitimize_address_1 (operands[1], operands[0], mode);
if (tmp)
{
if (tmp == operands[0])
return true;
operands[1] = tmp;
return false;
}
}
/* Early out for non-constants and valid constants. */
if (! CONSTANT_P (operands[1]) || input_operand (operands[1], mode))
return false;
/* Split large integers. */
if (CONST_INT_P (operands[1])
|| GET_CODE (operands[1]) == CONST_DOUBLE
|| GET_CODE (operands[1]) == CONST_VECTOR)
{
if (alpha_split_const_mov (mode, operands))
return true;
}
/* Otherwise we've nothing left but to drop the thing to memory. */
tmp = force_const_mem (mode, operands[1]);
if (tmp == NULL_RTX)
return false;
if (reload_in_progress)
{
emit_move_insn (operands[0], XEXP (tmp, 0));
operands[1] = replace_equiv_address (tmp, operands[0]);
}
else
operands[1] = validize_mem (tmp);
return false;
}
/* Expand a non-bwx QImode or HImode move instruction;
return true if all work is done. */
bool
alpha_expand_mov_nobwx (enum machine_mode mode, rtx *operands)
{
rtx seq;
/* If the output is not a register, the input must be. */
if (MEM_P (operands[0]))
operands[1] = force_reg (mode, operands[1]);
/* Handle four memory cases, unaligned and aligned for either the input
or the output. The only case where we can be called during reload is
for aligned loads; all other cases require temporaries. */
if (any_memory_operand (operands[1], mode))
{
if (aligned_memory_operand (operands[1], mode))
{
if (reload_in_progress)
{
if (mode == QImode)
seq = gen_reload_inqi_aligned (operands[0], operands[1]);
else
seq = gen_reload_inhi_aligned (operands[0], operands[1]);
emit_insn (seq);
}
else
{
rtx aligned_mem, bitnum;
rtx scratch = gen_reg_rtx (SImode);
rtx subtarget;
bool copyout;
get_aligned_mem (operands[1], &aligned_mem, &bitnum);
subtarget = operands[0];
if (REG_P (subtarget))
subtarget = gen_lowpart (DImode, subtarget), copyout = false;
else
subtarget = gen_reg_rtx (DImode), copyout = true;
if (mode == QImode)
seq = gen_aligned_loadqi (subtarget, aligned_mem,
bitnum, scratch);
else
seq = gen_aligned_loadhi (subtarget, aligned_mem,
bitnum, scratch);
emit_insn (seq);
if (copyout)
emit_move_insn (operands[0], gen_lowpart (mode, subtarget));
}
}
else
{
/* Don't pass these as parameters since that makes the generated
code depend on parameter evaluation order which will cause
bootstrap failures. */
rtx temp1, temp2, subtarget, ua;
bool copyout;
temp1 = gen_reg_rtx (DImode);
temp2 = gen_reg_rtx (DImode);
subtarget = operands[0];
if (REG_P (subtarget))
subtarget = gen_lowpart (DImode, subtarget), copyout = false;
else
subtarget = gen_reg_rtx (DImode), copyout = true;
ua = get_unaligned_address (operands[1]);
if (mode == QImode)
seq = gen_unaligned_loadqi (subtarget, ua, temp1, temp2);
else
seq = gen_unaligned_loadhi (subtarget, ua, temp1, temp2);
alpha_set_memflags (seq, operands[1]);
emit_insn (seq);
if (copyout)
emit_move_insn (operands[0], gen_lowpart (mode, subtarget));
}
return true;
}
if (any_memory_operand (operands[0], mode))
{
if (aligned_memory_operand (operands[0], mode))
{
rtx aligned_mem, bitnum;
rtx temp1 = gen_reg_rtx (SImode);
rtx temp2 = gen_reg_rtx (SImode);
get_aligned_mem (operands[0], &aligned_mem, &bitnum);
emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
temp1, temp2));
}
else
{
rtx temp1 = gen_reg_rtx (DImode);
rtx temp2 = gen_reg_rtx (DImode);
rtx temp3 = gen_reg_rtx (DImode);
rtx ua = get_unaligned_address (operands[0]);
if (mode == QImode)
seq = gen_unaligned_storeqi (ua, operands[1], temp1, temp2, temp3);
else
seq = gen_unaligned_storehi (ua, operands[1], temp1, temp2, temp3);
alpha_set_memflags (seq, operands[0]);
emit_insn (seq);
}
return true;
}
return false;
}
/* Implement the movmisalign patterns. One of the operands is a memory
that is not naturally aligned. Emit instructions to load it. */
void
alpha_expand_movmisalign (enum machine_mode mode, rtx *operands)
{
/* Honor misaligned loads, for those we promised to do so. */
if (MEM_P (operands[1]))
{
rtx tmp;
if (register_operand (operands[0], mode))
tmp = operands[0];
else
tmp = gen_reg_rtx (mode);
alpha_expand_unaligned_load (tmp, operands[1], 8, 0, 0);
if (tmp != operands[0])
emit_move_insn (operands[0], tmp);
}
else if (MEM_P (operands[0]))
{
if (!reg_or_0_operand (operands[1], mode))
operands[1] = force_reg (mode, operands[1]);
alpha_expand_unaligned_store (operands[0], operands[1], 8, 0);
}
else
gcc_unreachable ();
}
/* Generate an unsigned DImode to FP conversion. This is the same code
optabs would emit if we didn't have TFmode patterns.
For SFmode, this is the only construction I've found that can pass
gcc.c-torture/execute/ieee/rbug.c. No scenario that uses DFmode
intermediates will work, because you'll get intermediate rounding
that ruins the end result. Some of this could be fixed by turning
on round-to-positive-infinity, but that requires diddling the fpsr,
which kills performance. I tried turning this around and converting
to a negative number, so that I could turn on /m, but either I did
it wrong or there's something else cause I wound up with the exact
same single-bit error. There is a branch-less form of this same code:
srl $16,1,$1
and $16,1,$2
cmplt $16,0,$3
or $1,$2,$2
cmovge $16,$16,$2
itoft $3,$f10
itoft $2,$f11
cvtqs $f11,$f11
adds $f11,$f11,$f0
fcmoveq $f10,$f11,$f0
I'm not using it because it's the same number of instructions as
this branch-full form, and it has more serialized long latency
instructions on the critical path.
For DFmode, we can avoid rounding errors by breaking up the word
into two pieces, converting them separately, and adding them back:
LC0: .long 0,0x5f800000
itoft $16,$f11
lda $2,LC0
cmplt $16,0,$1
cpyse $f11,$f31,$f10
cpyse $f31,$f11,$f11
s4addq $1,$2,$1
lds $f12,0($1)
cvtqt $f10,$f10
cvtqt $f11,$f11
addt $f12,$f10,$f0
addt $f0,$f11,$f0
This doesn't seem to be a clear-cut win over the optabs form.
It probably all depends on the distribution of numbers being
converted -- in the optabs form, all but high-bit-set has a
much lower minimum execution time. */
void
alpha_emit_floatuns (rtx operands[2])
{
rtx neglab, donelab, i0, i1, f0, in, out;
enum machine_mode mode;
out = operands[0];
in = force_reg (DImode, operands[1]);
mode = GET_MODE (out);
neglab = gen_label_rtx ();
donelab = gen_label_rtx ();
i0 = gen_reg_rtx (DImode);
i1 = gen_reg_rtx (DImode);
f0 = gen_reg_rtx (mode);
emit_cmp_and_jump_insns (in, const0_rtx, LT, const0_rtx, DImode, 0, neglab);
emit_insn (gen_rtx_SET (VOIDmode, out, gen_rtx_FLOAT (mode, in)));
emit_jump_insn (gen_jump (donelab));
emit_barrier ();
emit_label (neglab);
emit_insn (gen_lshrdi3 (i0, in, const1_rtx));
emit_insn (gen_anddi3 (i1, in, const1_rtx));
emit_insn (gen_iordi3 (i0, i0, i1));
emit_insn (gen_rtx_SET (VOIDmode, f0, gen_rtx_FLOAT (mode, i0)));
emit_insn (gen_rtx_SET (VOIDmode, out, gen_rtx_PLUS (mode, f0, f0)));
emit_label (donelab);
}
/* Generate the comparison for a conditional branch. */
void
alpha_emit_conditional_branch (rtx operands[], enum machine_mode cmp_mode)
{
enum rtx_code cmp_code, branch_code;
enum machine_mode branch_mode = VOIDmode;
enum rtx_code code = GET_CODE (operands[0]);
rtx op0 = operands[1], op1 = operands[2];
rtx tem;
if (cmp_mode == TFmode)
{
op0 = alpha_emit_xfloating_compare (&code, op0, op1);
op1 = const0_rtx;
cmp_mode = DImode;
}
/* The general case: fold the comparison code to the types of compares
that we have, choosing the branch as necessary. */
switch (code)
{
case EQ: case LE: case LT: case LEU: case LTU:
case UNORDERED:
/* We have these compares. */
cmp_code = code, branch_code = NE;
break;
case NE:
case ORDERED:
/* These must be reversed. */
cmp_code = reverse_condition (code), branch_code = EQ;
break;
case GE: case GT: case GEU: case GTU:
/* For FP, we swap them, for INT, we reverse them. */
if (cmp_mode == DFmode)
{
cmp_code = swap_condition (code);
branch_code = NE;
tem = op0, op0 = op1, op1 = tem;
}
else
{
cmp_code = reverse_condition (code);
branch_code = EQ;
}
break;
default:
gcc_unreachable ();
}
if (cmp_mode == DFmode)
{
if (flag_unsafe_math_optimizations && cmp_code != UNORDERED)
{
/* When we are not as concerned about non-finite values, and we
are comparing against zero, we can branch directly. */
if (op1 == CONST0_RTX (DFmode))
cmp_code = UNKNOWN, branch_code = code;
else if (op0 == CONST0_RTX (DFmode))
{
/* Undo the swap we probably did just above. */
tem = op0, op0 = op1, op1 = tem;
branch_code = swap_condition (cmp_code);
cmp_code = UNKNOWN;
}
}
else
{
/* ??? We mark the branch mode to be CCmode to prevent the
compare and branch from being combined, since the compare
insn follows IEEE rules that the branch does not. */
branch_mode = CCmode;
}
}
else
{
/* The following optimizations are only for signed compares. */
if (code != LEU && code != LTU && code != GEU && code != GTU)
{
/* Whee. Compare and branch against 0 directly. */
if (op1 == const0_rtx)
cmp_code = UNKNOWN, branch_code = code;
/* If the constants doesn't fit into an immediate, but can
be generated by lda/ldah, we adjust the argument and
compare against zero, so we can use beq/bne directly. */
/* ??? Don't do this when comparing against symbols, otherwise
we'll reduce (&x == 0x1234) to (&x-0x1234 == 0), which will
be declared false out of hand (at least for non-weak). */
else if (CONST_INT_P (op1)
&& (code == EQ || code == NE)
&& !(symbolic_operand (op0, VOIDmode)
|| (REG_P (op0) && REG_POINTER (op0))))
{
rtx n_op1 = GEN_INT (-INTVAL (op1));
if (! satisfies_constraint_I (op1)
&& (satisfies_constraint_K (n_op1)
|| satisfies_constraint_L (n_op1)))
cmp_code = PLUS, branch_code = code, op1 = n_op1;
}
}
if (!reg_or_0_operand (op0, DImode))
op0 = force_reg (DImode, op0);
if (cmp_code != PLUS && !reg_or_8bit_operand (op1, DImode))
op1 = force_reg (DImode, op1);
}
/* Emit an initial compare instruction, if necessary. */
tem = op0;
if (cmp_code != UNKNOWN)
{
tem = gen_reg_rtx (cmp_mode);
emit_move_insn (tem, gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1));
}
/* Emit the branch instruction. */
tem = gen_rtx_SET (VOIDmode, pc_rtx,
gen_rtx_IF_THEN_ELSE (VOIDmode,
gen_rtx_fmt_ee (branch_code,
branch_mode, tem,
CONST0_RTX (cmp_mode)),
gen_rtx_LABEL_REF (VOIDmode,
operands[3]),
pc_rtx));
emit_jump_insn (tem);
}
/* Certain simplifications can be done to make invalid setcc operations
valid. Return the final comparison, or NULL if we can't work. */
bool
alpha_emit_setcc (rtx operands[], enum machine_mode cmp_mode)
{
enum rtx_code cmp_code;
enum rtx_code code = GET_CODE (operands[1]);
rtx op0 = operands[2], op1 = operands[3];
rtx tmp;
if (cmp_mode == TFmode)
{
op0 = alpha_emit_xfloating_compare (&code, op0, op1);
op1 = const0_rtx;
cmp_mode = DImode;
}
if (cmp_mode == DFmode && !TARGET_FIX)
return 0;
/* The general case: fold the comparison code to the types of compares
that we have, choosing the branch as necessary. */
cmp_code = UNKNOWN;
switch (code)
{
case EQ: case LE: case LT: case LEU: case LTU:
case UNORDERED:
/* We have these compares. */
if (cmp_mode == DFmode)
cmp_code = code, code = NE;
break;
case NE:
if (cmp_mode == DImode && op1 == const0_rtx)
break;
/* FALLTHRU */
case ORDERED:
cmp_code = reverse_condition (code);
code = EQ;
break;
case GE: case GT: case GEU: case GTU:
/* These normally need swapping, but for integer zero we have
special patterns that recognize swapped operands. */
if (cmp_mode == DImode && op1 == const0_rtx)
break;
code = swap_condition (code);
if (cmp_mode == DFmode)
cmp_code = code, code = NE;
tmp = op0, op0 = op1, op1 = tmp;
break;
default:
gcc_unreachable ();
}
if (cmp_mode == DImode)
{
if (!register_operand (op0, DImode))
op0 = force_reg (DImode, op0);
if (!reg_or_8bit_operand (op1, DImode))
op1 = force_reg (DImode, op1);
}
/* Emit an initial compare instruction, if necessary. */
if (cmp_code != UNKNOWN)
{
tmp = gen_reg_rtx (cmp_mode);
emit_insn (gen_rtx_SET (VOIDmode, tmp,
gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1)));
op0 = cmp_mode != DImode ? gen_lowpart (DImode, tmp) : tmp;
op1 = const0_rtx;
}
/* Emit the setcc instruction. */
emit_insn (gen_rtx_SET (VOIDmode, operands[0],
gen_rtx_fmt_ee (code, DImode, op0, op1)));
return true;
}
/* Rewrite a comparison against zero CMP of the form
(CODE (cc0) (const_int 0)) so it can be written validly in
a conditional move (if_then_else CMP ...).
If both of the operands that set cc0 are nonzero we must emit
an insn to perform the compare (it can't be done within
the conditional move). */
rtx
alpha_emit_conditional_move (rtx cmp, enum machine_mode mode)
{
enum rtx_code code = GET_CODE (cmp);
enum rtx_code cmov_code = NE;
rtx op0 = XEXP (cmp, 0);
rtx op1 = XEXP (cmp, 1);
enum machine_mode cmp_mode
= (GET_MODE (op0) == VOIDmode ? DImode : GET_MODE (op0));
enum machine_mode cmov_mode = VOIDmode;
int local_fast_math = flag_unsafe_math_optimizations;
rtx tem;
if (cmp_mode == TFmode)
{
op0 = alpha_emit_xfloating_compare (&code, op0, op1);
op1 = const0_rtx;
cmp_mode = DImode;
}
gcc_assert (cmp_mode == DFmode || cmp_mode == DImode);
if (FLOAT_MODE_P (cmp_mode) != FLOAT_MODE_P (mode))
{
enum rtx_code cmp_code;
if (! TARGET_FIX)
return 0;
/* If we have fp<->int register move instructions, do a cmov by
performing the comparison in fp registers, and move the
zero/nonzero value to integer registers, where we can then
use a normal cmov, or vice-versa. */
switch (code)
{
case EQ: case LE: case LT: case LEU: case LTU:
case UNORDERED:
/* We have these compares. */
cmp_code = code, code = NE;
break;
case NE:
case ORDERED:
/* These must be reversed. */
cmp_code = reverse_condition (code), code = EQ;
break;
case GE: case GT: case GEU: case GTU:
/* These normally need swapping, but for integer zero we have
special patterns that recognize swapped operands. */
if (cmp_mode == DImode && op1 == const0_rtx)
cmp_code = code, code = NE;
else
{
cmp_code = swap_condition (code);
code = NE;
tem = op0, op0 = op1, op1 = tem;
}
break;
default:
gcc_unreachable ();
}
if (cmp_mode == DImode)
{
if (!reg_or_0_operand (op0, DImode))
op0 = force_reg (DImode, op0);
if (!reg_or_8bit_operand (op1, DImode))
op1 = force_reg (DImode, op1);
}
tem = gen_reg_rtx (cmp_mode);
emit_insn (gen_rtx_SET (VOIDmode, tem,
gen_rtx_fmt_ee (cmp_code, cmp_mode,
op0, op1)));
cmp_mode = cmp_mode == DImode ? DFmode : DImode;
op0 = gen_lowpart (cmp_mode, tem);
op1 = CONST0_RTX (cmp_mode);
local_fast_math = 1;
}
if (cmp_mode == DImode)
{
if (!reg_or_0_operand (op0, DImode))
op0 = force_reg (DImode, op0);
if (!reg_or_8bit_operand (op1, DImode))
op1 = force_reg (DImode, op1);
}
/* We may be able to use a conditional move directly.
This avoids emitting spurious compares. */
if (signed_comparison_operator (cmp, VOIDmode)
&& (cmp_mode == DImode || local_fast_math)
&& (op0 == CONST0_RTX (cmp_mode) || op1 == CONST0_RTX (cmp_mode)))
return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
/* We can't put the comparison inside the conditional move;
emit a compare instruction and put that inside the
conditional move. Make sure we emit only comparisons we have;
swap or reverse as necessary. */
if (!can_create_pseudo_p ())
return NULL_RTX;
switch (code)
{
case EQ: case LE: case LT: case LEU: case LTU:
case UNORDERED:
/* We have these compares: */
break;
case NE:
case ORDERED:
/* These must be reversed. */
code = reverse_condition (code);
cmov_code = EQ;
break;
case GE: case GT: case GEU: case GTU:
/* These must be swapped. */
if (op1 != CONST0_RTX (cmp_mode))
{
code = swap_condition (code);
tem = op0, op0 = op1, op1 = tem;
}
break;
default:
gcc_unreachable ();
}
if (cmp_mode == DImode)
{
if (!reg_or_0_operand (op0, DImode))
op0 = force_reg (DImode, op0);
if (!reg_or_8bit_operand (op1, DImode))
op1 = force_reg (DImode, op1);
}
/* ??? We mark the branch mode to be CCmode to prevent the compare
and cmov from being combined, since the compare insn follows IEEE
rules that the cmov does not. */
if (cmp_mode == DFmode && !local_fast_math)
cmov_mode = CCmode;
tem = gen_reg_rtx (cmp_mode);
emit_move_insn (tem, gen_rtx_fmt_ee (code, cmp_mode, op0, op1));
return gen_rtx_fmt_ee (cmov_code, cmov_mode, tem, CONST0_RTX (cmp_mode));
}
/* Simplify a conditional move of two constants into a setcc with
arithmetic. This is done with a splitter since combine would
just undo the work if done during code generation. It also catches
cases we wouldn't have before cse. */
int
alpha_split_conditional_move (enum rtx_code code, rtx dest, rtx cond,
rtx t_rtx, rtx f_rtx)
{
HOST_WIDE_INT t, f, diff;
enum machine_mode mode;
rtx target, subtarget, tmp;
mode = GET_MODE (dest);
t = INTVAL (t_rtx);
f = INTVAL (f_rtx);
diff = t - f;
if (((code == NE || code == EQ) && diff < 0)
|| (code == GE || code == GT))
{
code = reverse_condition (code);
diff = t, t = f, f = diff;
diff = t - f;
}
subtarget = target = dest;
if (mode != DImode)
{
target = gen_lowpart (DImode, dest);
if (can_create_pseudo_p ())
subtarget = gen_reg_rtx (DImode);
else
subtarget = target;
}
/* Below, we must be careful to use copy_rtx on target and subtarget
in intermediate insns, as they may be a subreg rtx, which may not
be shared. */
if (f == 0 && exact_log2 (diff) > 0
/* On EV6, we've got enough shifters to make non-arithmetic shifts
viable over a longer latency cmove. On EV5, the E0 slot is a
scarce resource, and on EV4 shift has the same latency as a cmove. */
&& (diff <= 8 || alpha_tune == PROCESSOR_EV6))
{
tmp = gen_rtx_fmt_ee (code, DImode, cond, const0_rtx);
emit_insn (gen_rtx_SET (VOIDmode, copy_rtx (subtarget), tmp));
tmp = gen_rtx_ASHIFT (DImode, copy_rtx (subtarget),
GEN_INT (exact_log2 (t)));
emit_insn (gen_rtx_SET (VOIDmode, target, tmp));
}
else if (f == 0 && t == -1)
{
tmp = gen_rtx_fmt_ee (code, DImode, cond, const0_rtx);
emit_insn (gen_rtx_SET (VOIDmode, copy_rtx (subtarget), tmp));
emit_insn (gen_negdi2 (target, copy_rtx (subtarget)));
}
else if (diff == 1 || diff == 4 || diff == 8)
{
rtx add_op;
tmp = gen_rtx_fmt_ee (code, DImode, cond, const0_rtx);
emit_insn (gen_rtx_SET (VOIDmode, copy_rtx (subtarget), tmp));
if (diff == 1)
emit_insn (gen_adddi3 (target, copy_rtx (subtarget), GEN_INT (f)));
else
{
add_op = GEN_INT (f);
if (sext_add_operand (add_op, mode))
{
tmp = gen_rtx_MULT (DImode, copy_rtx (subtarget),
GEN_INT (diff));
tmp = gen_rtx_PLUS (DImode, tmp, add_op);
emit_insn (gen_rtx_SET (VOIDmode, target, tmp));
}
else
return 0;
}
}
else
return 0;
return 1;
}
/* Look up the function X_floating library function name for the
given operation. */
struct GTY(()) xfloating_op
{
const enum rtx_code code;
const char *const GTY((skip)) osf_func;
const char *const GTY((skip)) vms_func;
rtx libcall;
};
static GTY(()) struct xfloating_op xfloating_ops[] =
{
{ PLUS, "_OtsAddX", "OTS$ADD_X", 0 },
{ MINUS, "_OtsSubX", "OTS$SUB_X", 0 },
{ MULT, "_OtsMulX", "OTS$MUL_X", 0 },
{ DIV, "_OtsDivX", "OTS$DIV_X", 0 },
{ EQ, "_OtsEqlX", "OTS$EQL_X", 0 },
{ NE, "_OtsNeqX", "OTS$NEQ_X", 0 },
{ LT, "_OtsLssX", "OTS$LSS_X", 0 },
{ LE, "_OtsLeqX", "OTS$LEQ_X", 0 },
{ GT, "_OtsGtrX", "OTS$GTR_X", 0 },
{ GE, "_OtsGeqX", "OTS$GEQ_X", 0 },
{ FIX, "_OtsCvtXQ", "OTS$CVTXQ", 0 },
{ FLOAT, "_OtsCvtQX", "OTS$CVTQX", 0 },
{ UNSIGNED_FLOAT, "_OtsCvtQUX", "OTS$CVTQUX", 0 },
{ FLOAT_EXTEND, "_OtsConvertFloatTX", "OTS$CVT_FLOAT_T_X", 0 },
{ FLOAT_TRUNCATE, "_OtsConvertFloatXT", "OTS$CVT_FLOAT_X_T", 0 }
};
static GTY(()) struct xfloating_op vax_cvt_ops[] =
{
{ FLOAT_EXTEND, "_OtsConvertFloatGX", "OTS$CVT_FLOAT_G_X", 0 },
{ FLOAT_TRUNCATE, "_OtsConvertFloatXG", "OTS$CVT_FLOAT_X_G", 0 }
};
static rtx
alpha_lookup_xfloating_lib_func (enum rtx_code code)
{
struct xfloating_op *ops = xfloating_ops;
long n = ARRAY_SIZE (xfloating_ops);
long i;
gcc_assert (TARGET_HAS_XFLOATING_LIBS);
/* How irritating. Nothing to key off for the main table. */
if (TARGET_FLOAT_VAX && (code == FLOAT_EXTEND || code == FLOAT_TRUNCATE))
{
ops = vax_cvt_ops;
n = ARRAY_SIZE (vax_cvt_ops);
}
for (i = 0; i < n; ++i, ++ops)
if (ops->code == code)
{
rtx func = ops->libcall;
if (!func)
{
func = init_one_libfunc (TARGET_ABI_OPEN_VMS
? ops->vms_func : ops->osf_func);
ops->libcall = func;
}
return func;
}
gcc_unreachable ();
}
/* Most X_floating operations take the rounding mode as an argument.
Compute that here. */
static int
alpha_compute_xfloating_mode_arg (enum rtx_code code,
enum alpha_fp_rounding_mode round)
{
int mode;
switch (round)
{
case ALPHA_FPRM_NORM:
mode = 2;
break;
case ALPHA_FPRM_MINF:
mode = 1;
break;
case ALPHA_FPRM_CHOP:
mode = 0;
break;
case ALPHA_FPRM_DYN:
mode = 4;
break;
default:
gcc_unreachable ();
/* XXX For reference, round to +inf is mode = 3. */
}
if (code == FLOAT_TRUNCATE && alpha_fptm == ALPHA_FPTM_N)
mode |= 0x10000;
return mode;
}
/* Emit an X_floating library function call.
Note that these functions do not follow normal calling conventions:
TFmode arguments are passed in two integer registers (as opposed to
indirect); TFmode return values appear in R16+R17.
FUNC is the function to call.
TARGET is where the output belongs.
OPERANDS are the inputs.
NOPERANDS is the count of inputs.
EQUIV is the expression equivalent for the function.
*/
static void
alpha_emit_xfloating_libcall (rtx func, rtx target, rtx operands[],
int noperands, rtx equiv)
{
rtx usage = NULL_RTX, tmp, reg;
int regno = 16, i;
start_sequence ();
for (i = 0; i < noperands; ++i)
{
switch (GET_MODE (operands[i]))
{
case TFmode:
reg = gen_rtx_REG (TFmode, regno);
regno += 2;
break;
case DFmode:
reg = gen_rtx_REG (DFmode, regno + 32);
regno += 1;
break;
case VOIDmode:
gcc_assert (CONST_INT_P (operands[i]));
/* FALLTHRU */
case DImode:
reg = gen_rtx_REG (DImode, regno);
regno += 1;
break;
default:
gcc_unreachable ();
}
emit_move_insn (reg, operands[i]);
usage = alloc_EXPR_LIST (0, gen_rtx_USE (VOIDmode, reg), usage);
}
switch (GET_MODE (target))
{
case TFmode:
reg = gen_rtx_REG (TFmode, 16);
break;
case DFmode:
reg = gen_rtx_REG (DFmode, 32);
break;
case DImode:
reg = gen_rtx_REG (DImode, 0);
break;
default:
gcc_unreachable ();
}
tmp = gen_rtx_MEM (QImode, func);
tmp = emit_call_insn (GEN_CALL_VALUE (reg, tmp, const0_rtx,
const0_rtx, const0_rtx));
CALL_INSN_FUNCTION_USAGE (tmp) = usage;
RTL_CONST_CALL_P (tmp) = 1;
tmp = get_insns ();
end_sequence ();
emit_libcall_block (tmp, target, reg, equiv);
}
/* Emit an X_floating library function call for arithmetic (+,-,*,/). */
void
alpha_emit_xfloating_arith (enum rtx_code code, rtx operands[])
{
rtx func;
int mode;
rtx out_operands[3];
func = alpha_lookup_xfloating_lib_func (code);
mode = alpha_compute_xfloating_mode_arg (code, alpha_fprm);
out_operands[0] = operands[1];
out_operands[1] = operands[2];
out_operands[2] = GEN_INT (mode);
alpha_emit_xfloating_libcall (func, operands[0], out_operands, 3,
gen_rtx_fmt_ee (code, TFmode, operands[1],
operands[2]));
}
/* Emit an X_floating library function call for a comparison. */
static rtx
alpha_emit_xfloating_compare (enum rtx_code *pcode, rtx op0, rtx op1)
{
enum rtx_code cmp_code, res_code;
rtx func, out, operands[2], note;
/* X_floating library comparison functions return
-1 unordered
0 false
1 true
Convert the compare against the raw return value. */
cmp_code = *pcode;
switch (cmp_code)
{
case UNORDERED:
cmp_code = EQ;
res_code = LT;
break;
case ORDERED:
cmp_code = EQ;
res_code = GE;
break;
case NE:
res_code = NE;
break;
case EQ:
case LT:
case GT:
case LE:
case GE:
res_code = GT;
break;
default:
gcc_unreachable ();
}
*pcode = res_code;
func = alpha_lookup_xfloating_lib_func (cmp_code);
operands[0] = op0;
operands[1] = op1;
out = gen_reg_rtx (DImode);
/* What's actually returned is -1,0,1, not a proper boolean value,
so use an EXPR_LIST as with a generic libcall instead of a
comparison type expression. */
note = gen_rtx_EXPR_LIST (VOIDmode, op1, NULL_RTX);
note = gen_rtx_EXPR_LIST (VOIDmode, op0, note);
note = gen_rtx_EXPR_LIST (VOIDmode, func, note);
alpha_emit_xfloating_libcall (func, out, operands, 2, note);
return out;
}
/* Emit an X_floating library function call for a conversion. */
void
alpha_emit_xfloating_cvt (enum rtx_code orig_code, rtx operands[])
{
int noperands = 1, mode;
rtx out_operands[2];
rtx func;
enum rtx_code code = orig_code;
if (code == UNSIGNED_FIX)
code = FIX;
func = alpha_lookup_xfloating_lib_func (code);
out_operands[0] = operands[1];
switch (code)
{
case FIX:
mode = alpha_compute_xfloating_mode_arg (code, ALPHA_FPRM_CHOP);
out_operands[1] = GEN_INT (mode);
noperands = 2;
break;
case FLOAT_TRUNCATE:
mode = alpha_compute_xfloating_mode_arg (code, alpha_fprm);
out_operands[1] = GEN_INT (mode);
noperands = 2;
break;
default:
break;
}
alpha_emit_xfloating_libcall (func, operands[0], out_operands, noperands,
gen_rtx_fmt_e (orig_code,
GET_MODE (operands[0]),
operands[1]));
}
/* Split a TImode or TFmode move from OP[1] to OP[0] into a pair of
DImode moves from OP[2,3] to OP[0,1]. If FIXUP_OVERLAP is true,
guarantee that the sequence
set (OP[0] OP[2])
set (OP[1] OP[3])
is valid. Naturally, output operand ordering is little-endian.
This is used by *movtf_internal and *movti_internal. */
void
alpha_split_tmode_pair (rtx operands[4], enum machine_mode mode,
bool fixup_overlap)
{
switch (GET_CODE (operands[1]))
{
case REG:
operands[3] = gen_rtx_REG (DImode, REGNO (operands[1]) + 1);
operands[2] = gen_rtx_REG (DImode, REGNO (operands[1]));
break;
case MEM:
operands[3] = adjust_address (operands[1], DImode, 8);
operands[2] = adjust_address (operands[1], DImode, 0);
break;
case CONST_INT:
case CONST_DOUBLE:
gcc_assert (operands[1] == CONST0_RTX (mode));
operands[2] = operands[3] = const0_rtx;
break;
default:
gcc_unreachable ();
}
switch (GET_CODE (operands[0]))
{
case REG:
operands[1] = gen_rtx_REG (DImode, REGNO (operands[0]) + 1);
operands[0] = gen_rtx_REG (DImode, REGNO (operands[0]));
break;
case MEM:
operands[1] = adjust_address (operands[0], DImode, 8);
operands[0] = adjust_address (operands[0], DImode, 0);
break;
default:
gcc_unreachable ();
}
if (fixup_overlap && reg_overlap_mentioned_p (operands[0], operands[3]))
{
rtx tmp;
tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
}
}
/* Implement negtf2 or abstf2. Op0 is destination, op1 is source,
op2 is a register containing the sign bit, operation is the
logical operation to be performed. */
void
alpha_split_tfmode_frobsign (rtx operands[3], rtx (*operation) (rtx, rtx, rtx))
{
rtx high_bit = operands[2];
rtx scratch;
int move;
alpha_split_tmode_pair (operands, TFmode, false);
/* Detect three flavors of operand overlap. */
move = 1;
if (rtx_equal_p (operands[0], operands[2]))
move = 0;
else if (rtx_equal_p (operands[1], operands[2]))
{
if (rtx_equal_p (operands[0], high_bit))
move = 2;
else
move = -1;
}
if (move < 0)
emit_move_insn (operands[0], operands[2]);
/* ??? If the destination overlaps both source tf and high_bit, then
assume source tf is dead in its entirety and use the other half
for a scratch register. Otherwise "scratch" is just the proper
destination register. */
scratch = operands[move < 2 ? 1 : 3];
emit_insn ((*operation) (scratch, high_bit, operands[3]));
if (move > 0)
{
emit_move_insn (operands[0], operands[2]);
if (move > 1)
emit_move_insn (operands[1], scratch);
}
}
/* Use ext[wlq][lh] as the Architecture Handbook describes for extracting
unaligned data:
unsigned: signed:
word: ldq_u r1,X(r11) ldq_u r1,X(r11)
ldq_u r2,X+1(r11) ldq_u r2,X+1(r11)
lda r3,X(r11) lda r3,X+2(r11)
extwl r1,r3,r1 extql r1,r3,r1
extwh r2,r3,r2 extqh r2,r3,r2
or r1.r2.r1 or r1,r2,r1
sra r1,48,r1
long: ldq_u r1,X(r11) ldq_u r1,X(r11)
ldq_u r2,X+3(r11) ldq_u r2,X+3(r11)
lda r3,X(r11) lda r3,X(r11)
extll r1,r3,r1 extll r1,r3,r1
extlh r2,r3,r2 extlh r2,r3,r2
or r1.r2.r1 addl r1,r2,r1
quad: ldq_u r1,X(r11)
ldq_u r2,X+7(r11)
lda r3,X(r11)
extql r1,r3,r1
extqh r2,r3,r2
or r1.r2.r1
*/
void
alpha_expand_unaligned_load (rtx tgt, rtx mem, HOST_WIDE_INT size,
HOST_WIDE_INT ofs, int sign)
{
rtx meml, memh, addr, extl, exth, tmp, mema;
enum machine_mode mode;
if (TARGET_BWX && size == 2)
{
meml = adjust_address (mem, QImode, ofs);
memh = adjust_address (mem, QImode, ofs+1);
if (BYTES_BIG_ENDIAN)
tmp = meml, meml = memh, memh = tmp;
extl = gen_reg_rtx (DImode);
exth = gen_reg_rtx (DImode);
emit_insn (gen_zero_extendqidi2 (extl, meml));
emit_insn (gen_zero_extendqidi2 (exth, memh));
exth = expand_simple_binop (DImode, ASHIFT, exth, GEN_INT (8),
NULL, 1, OPTAB_LIB_WIDEN);
addr = expand_simple_binop (DImode, IOR, extl, exth,
NULL, 1, OPTAB_LIB_WIDEN);
if (sign && GET_MODE (tgt) != HImode)
{
addr = gen_lowpart (HImode, addr);
emit_insn (gen_extend_insn (tgt, addr, GET_MODE (tgt), HImode, 0));
}
else
{
if (GET_MODE (tgt) != DImode)
addr = gen_lowpart (GET_MODE (tgt), addr);
emit_move_insn (tgt, addr);
}
return;
}
meml = gen_reg_rtx (DImode);
memh = gen_reg_rtx (DImode);
addr = gen_reg_rtx (DImode);
extl = gen_reg_rtx (DImode);
exth = gen_reg_rtx (DImode);
mema = XEXP (mem, 0);
if (GET_CODE (mema) == LO_SUM)
mema = force_reg (Pmode, mema);
/* AND addresses cannot be in any alias set, since they may implicitly
alias surrounding code. Ideally we'd have some alias set that
covered all types except those with alignment 8 or higher. */
tmp = change_address (mem, DImode,
gen_rtx_AND (DImode,
plus_constant (mema, ofs),
GEN_INT (-8)));
set_mem_alias_set (tmp, 0);
emit_move_insn (meml, tmp);
tmp = change_address (mem, DImode,
gen_rtx_AND (DImode,
plus_constant (mema, ofs + size - 1),
GEN_INT (-8)));
set_mem_alias_set (tmp, 0);
emit_move_insn (memh, tmp);
if (WORDS_BIG_ENDIAN && sign && (size == 2 || size == 4))
{
emit_move_insn (addr, plus_constant (mema, -1));
emit_insn (gen_extqh_be (extl, meml, addr));
emit_insn (gen_extxl_be (exth, memh, GEN_INT (64), addr));
addr = expand_binop (DImode, ior_optab, extl, exth, tgt, 1, OPTAB_WIDEN);
addr = expand_binop (DImode, ashr_optab, addr, GEN_INT (64 - size*8),
addr, 1, OPTAB_WIDEN);
}
else if (sign && size == 2)
{
emit_move_insn (addr, plus_constant (mema, ofs+2));
emit_insn (gen_extxl_le (extl, meml, GEN_INT (64), addr));
emit_insn (gen_extqh_le (exth, memh, addr));
/* We must use tgt here for the target. Alpha-vms port fails if we use
addr for the target, because addr is marked as a pointer and combine
knows that pointers are always sign-extended 32-bit values. */
addr = expand_binop (DImode, ior_optab, extl, exth, tgt, 1, OPTAB_WIDEN);
addr = expand_binop (DImode, ashr_optab, addr, GEN_INT (48),
addr, 1, OPTAB_WIDEN);
}
else
{
if (WORDS_BIG_ENDIAN)
{
emit_move_insn (addr, plus_constant (mema, ofs+size-1));
switch ((int) size)
{
case 2:
emit_insn (gen_extwh_be (extl, meml, addr));
mode = HImode;
break;
case 4:
emit_insn (gen_extlh_be (extl, meml, addr));
mode = SImode;
break;
case 8:
emit_insn (gen_extqh_be (extl, meml, addr));
mode = DImode;
break;
default:
gcc_unreachable ();
}
emit_insn (gen_extxl_be (exth, memh, GEN_INT (size*8), addr));
}
else
{
emit_move_insn (addr, plus_constant (mema, ofs));
emit_insn (gen_extxl_le (extl, meml, GEN_INT (size*8), addr));
switch ((int) size)
{
case 2:
emit_insn (gen_extwh_le (exth, memh, addr));
mode = HImode;
break;
case 4:
emit_insn (gen_extlh_le (exth, memh, addr));
mode = SImode;
break;
case 8:
emit_insn (gen_extqh_le (exth, memh, addr));
mode = DImode;
break;
default:
gcc_unreachable ();
}
}
addr = expand_binop (mode, ior_optab, gen_lowpart (mode, extl),
gen_lowpart (mode, exth), gen_lowpart (mode, tgt),
sign, OPTAB_WIDEN);
}
if (addr != tgt)
emit_move_insn (tgt, gen_lowpart (GET_MODE (tgt), addr));
}
/* Similarly, use ins and msk instructions to perform unaligned stores. */
void
alpha_expand_unaligned_store (rtx dst, rtx src,
HOST_WIDE_INT size, HOST_WIDE_INT ofs)
{
rtx dstl, dsth, addr, insl, insh, meml, memh, dsta;
if (TARGET_BWX && size == 2)
{
if (src != const0_rtx)
{
dstl = gen_lowpart (QImode, src);
dsth = expand_simple_binop (DImode, LSHIFTRT, src, GEN_INT (8),
NULL, 1, OPTAB_LIB_WIDEN);
dsth = gen_lowpart (QImode, dsth);
}
else
dstl = dsth = const0_rtx;
meml = adjust_address (dst, QImode, ofs);
memh = adjust_address (dst, QImode, ofs+1);
if (BYTES_BIG_ENDIAN)
addr = meml, meml = memh, memh = addr;
emit_move_insn (meml, dstl);
emit_move_insn (memh, dsth);
return;
}
dstl = gen_reg_rtx (DImode);
dsth = gen_reg_rtx (DImode);
insl = gen_reg_rtx (DImode);
insh = gen_reg_rtx (DImode);
dsta = XEXP (dst, 0);
if (GET_CODE (dsta) == LO_SUM)
dsta = force_reg (Pmode, dsta);
/* AND addresses cannot be in any alias set, since they may implicitly
alias surrounding code. Ideally we'd have some alias set that
covered all types except those with alignment 8 or higher. */
meml = change_address (dst, DImode,
gen_rtx_AND (DImode,
plus_constant (dsta, ofs),
GEN_INT (-8)));
set_mem_alias_set (meml, 0);
memh = change_address (dst, DImode,
gen_rtx_AND (DImode,
plus_constant (dsta, ofs + size - 1),
GEN_INT (-8)));
set_mem_alias_set (memh, 0);
emit_move_insn (dsth, memh);
emit_move_insn (dstl, meml);
if (WORDS_BIG_ENDIAN)
{
addr = copy_addr_to_reg (plus_constant (dsta, ofs+size-1));
if (src != const0_rtx)
{
switch ((int) size)
{
case 2:
emit_insn (gen_inswl_be (insh, gen_lowpart (HImode,src), addr));
break;
case 4:
emit_insn (gen_insll_be (insh, gen_lowpart (SImode,src), addr));
break;
case 8:
emit_insn (gen_insql_be (insh, gen_lowpart (DImode,src), addr));
break;
}
emit_insn (gen_insxh (insl, gen_lowpart (DImode, src),
GEN_INT (size*8), addr));
}
switch ((int) size)
{
case 2:
emit_insn (gen_mskxl_be (dsth, dsth, GEN_INT (0xffff), addr));
break;
case 4:
{
rtx msk = immed_double_const (0xffffffff, 0, DImode);
emit_insn (gen_mskxl_be (dsth, dsth, msk, addr));
break;
}
case 8:
emit_insn (gen_mskxl_be (dsth, dsth, constm1_rtx, addr));
break;
}
emit_insn (gen_mskxh (dstl, dstl, GEN_INT (size*8), addr));
}
else
{
addr = copy_addr_to_reg (plus_constant (dsta, ofs));
if (src != CONST0_RTX (GET_MODE (src)))
{
emit_insn (gen_insxh (insh, gen_lowpart (DImode, src),
GEN_INT (size*8), addr));
switch ((int) size)
{
case 2:
emit_insn (gen_inswl_le (insl, gen_lowpart (HImode, src), addr));
break;
case 4:
emit_insn (gen_insll_le (insl, gen_lowpart (SImode, src), addr));
break;
case 8:
emit_insn (gen_insql_le (insl, gen_lowpart (DImode, src), addr));
break;
}
}
emit_insn (gen_mskxh (dsth, dsth, GEN_INT (size*8), addr));
switch ((int) size)
{
case 2:
emit_insn (gen_mskxl_le (dstl, dstl, GEN_INT (0xffff), addr));
break;
case 4:
{
rtx msk = immed_double_const (0xffffffff, 0, DImode);
emit_insn (gen_mskxl_le (dstl, dstl, msk, addr));
break;
}
case 8:
emit_insn (gen_mskxl_le (dstl, dstl, constm1_rtx, addr));
break;
}
}
if (src != CONST0_RTX (GET_MODE (src)))
{
dsth = expand_binop (DImode, ior_optab, insh, dsth, dsth, 0, OPTAB_WIDEN);
dstl = expand_binop (DImode, ior_optab, insl, dstl, dstl, 0, OPTAB_WIDEN);
}
if (WORDS_BIG_ENDIAN)
{
emit_move_insn (meml, dstl);
emit_move_insn (memh, dsth);
}
else
{
/* Must store high before low for degenerate case of aligned. */
emit_move_insn (memh, dsth);
emit_move_insn (meml, dstl);
}
}
/* The block move code tries to maximize speed by separating loads and
stores at the expense of register pressure: we load all of the data
before we store it back out. There are two secondary effects worth
mentioning, that this speeds copying to/from aligned and unaligned
buffers, and that it makes the code significantly easier to write. */
#define MAX_MOVE_WORDS 8
/* Load an integral number of consecutive unaligned quadwords. */
static void
alpha_expand_unaligned_load_words (rtx *out_regs, rtx smem,
HOST_WIDE_INT words, HOST_WIDE_INT ofs)
{
rtx const im8 = GEN_INT (-8);
rtx const i64 = GEN_INT (64);
rtx ext_tmps[MAX_MOVE_WORDS], data_regs[MAX_MOVE_WORDS+1];
rtx sreg, areg, tmp, smema;
HOST_WIDE_INT i;
smema = XEXP (smem, 0);
if (GET_CODE (smema) == LO_SUM)
smema = force_reg (Pmode, smema);
/* Generate all the tmp registers we need. */
for (i = 0; i < words; ++i)
{
data_regs[i] = out_regs[i];
ext_tmps[i] = gen_reg_rtx (DImode);
}
data_regs[words] = gen_reg_rtx (DImode);
if (ofs != 0)
smem = adjust_address (smem, GET_MODE (smem), ofs);
/* Load up all of the source data. */
for (i = 0; i < words; ++i)
{
tmp = change_address (smem, DImode,
gen_rtx_AND (DImode,
plus_constant (smema, 8*i),
im8));
set_mem_alias_set (tmp, 0);
emit_move_insn (data_regs[i], tmp);
}
tmp = change_address (smem, DImode,
gen_rtx_AND (DImode,
plus_constant (smema, 8*words - 1),
im8));
set_mem_alias_set (tmp, 0);
emit_move_insn (data_regs[words], tmp);
/* Extract the half-word fragments. Unfortunately DEC decided to make
extxh with offset zero a noop instead of zeroing the register, so
we must take care of that edge condition ourselves with cmov. */
sreg = copy_addr_to_reg (smema);
areg = expand_binop (DImode, and_optab, sreg, GEN_INT (7), NULL,
1, OPTAB_WIDEN);
if (WORDS_BIG_ENDIAN)
emit_move_insn (sreg, plus_constant (sreg, 7));
for (i = 0; i < words; ++i)
{
if (WORDS_BIG_ENDIAN)
{
emit_insn (gen_extqh_be (data_regs[i], data_regs[i], sreg));
emit_insn (gen_extxl_be (ext_tmps[i], data_regs[i+1], i64, sreg));
}
else
{
emit_insn (gen_extxl_le (data_regs[i], data_regs[i], i64, sreg));
emit_insn (gen_extqh_le (ext_tmps[i], data_regs[i+1], sreg));
}
emit_insn (gen_rtx_SET (VOIDmode, ext_tmps[i],
gen_rtx_IF_THEN_ELSE (DImode,
gen_rtx_EQ (DImode, areg,
const0_rtx),
const0_rtx, ext_tmps[i])));
}
/* Merge the half-words into whole words. */
for (i = 0; i < words; ++i)
{
out_regs[i] = expand_binop (DImode, ior_optab, data_regs[i],
ext_tmps[i], data_regs[i], 1, OPTAB_WIDEN);
}
}
/* Store an integral number of consecutive unaligned quadwords. DATA_REGS
may be NULL to store zeros. */
static void
alpha_expand_unaligned_store_words (rtx *data_regs, rtx dmem,
HOST_WIDE_INT words, HOST_WIDE_INT ofs)
{
rtx const im8 = GEN_INT (-8);
rtx const i64 = GEN_INT (64);
rtx ins_tmps[MAX_MOVE_WORDS];
rtx st_tmp_1, st_tmp_2, dreg;
rtx st_addr_1, st_addr_2, dmema;
HOST_WIDE_INT i;
dmema = XEXP (dmem, 0);
if (GET_CODE (dmema) == LO_SUM)
dmema = force_reg (Pmode, dmema);
/* Generate all the tmp registers we need. */
if (data_regs != NULL)
for (i = 0; i < words; ++i)
ins_tmps[i] = gen_reg_rtx(DImode);
st_tmp_1 = gen_reg_rtx(DImode);
st_tmp_2 = gen_reg_rtx(DImode);
if (ofs != 0)
dmem = adjust_address (dmem, GET_MODE (dmem), ofs);
st_addr_2 = change_address (dmem, DImode,
gen_rtx_AND (DImode,
plus_constant (dmema, words*8 - 1),
im8));
set_mem_alias_set (st_addr_2, 0);
st_addr_1 = change_address (dmem, DImode,
gen_rtx_AND (DImode, dmema, im8));
set_mem_alias_set (st_addr_1, 0);
/* Load up the destination end bits. */
emit_move_insn (st_tmp_2, st_addr_2);
emit_move_insn (st_tmp_1, st_addr_1);
/* Shift the input data into place. */
dreg = copy_addr_to_reg (dmema);
if (WORDS_BIG_ENDIAN)
emit_move_insn (dreg, plus_constant (dreg, 7));
if (data_regs != NULL)
{
for (i = words-1; i >= 0; --i)
{
if (WORDS_BIG_ENDIAN)
{
emit_insn (gen_insql_be (ins_tmps[i], data_regs[i], dreg));
emit_insn (gen_insxh (data_regs[i], data_regs[i], i64, dreg));
}
else
{
emit_insn (gen_insxh (ins_tmps[i], data_regs[i], i64, dreg));
emit_insn (gen_insql_le (data_regs[i], data_regs[i], dreg));
}
}
for (i = words-1; i > 0; --i)
{
ins_tmps[i-1] = expand_binop (DImode, ior_optab, data_regs[i],
ins_tmps[i-1], ins_tmps[i-1], 1,
OPTAB_WIDEN);
}
}
/* Split and merge the ends with the destination data. */
if (WORDS_BIG_ENDIAN)
{
emit_insn (gen_mskxl_be (st_tmp_2, st_tmp_2, constm1_rtx, dreg));
emit_insn (gen_mskxh (st_tmp_1, st_tmp_1, i64, dreg));
}
else
{
emit_insn (gen_mskxh (st_tmp_2, st_tmp_2, i64, dreg));
emit_insn (gen_mskxl_le (st_tmp_1, st_tmp_1, constm1_rtx, dreg));
}
if (data_regs != NULL)
{
st_tmp_2 = expand_binop (DImode, ior_optab, st_tmp_2, ins_tmps[words-1],
st_tmp_2, 1, OPTAB_WIDEN);
st_tmp_1 = expand_binop (DImode, ior_optab, st_tmp_1, data_regs[0],
st_tmp_1, 1, OPTAB_WIDEN);
}
/* Store it all. */
if (WORDS_BIG_ENDIAN)
emit_move_insn (st_addr_1, st_tmp_1);
else
emit_move_insn (st_addr_2, st_tmp_2);
for (i = words-1; i > 0; --i)
{
rtx tmp = change_address (dmem, DImode,
gen_rtx_AND (DImode,
plus_constant(dmema,
WORDS_BIG_ENDIAN ? i*8-1 : i*8),
im8));
set_mem_alias_set (tmp, 0);
emit_move_insn (tmp, data_regs ? ins_tmps[i-1] : const0_rtx);
}
if (WORDS_BIG_ENDIAN)
emit_move_insn (st_addr_2, st_tmp_2);
else
emit_move_insn (st_addr_1, st_tmp_1);
}
/* Expand string/block move operations.
operands[0] is the pointer to the destination.
operands[1] is the pointer to the source.
operands[2] is the number of bytes to move.
operands[3] is the alignment. */
int
alpha_expand_block_move (rtx operands[])
{
rtx bytes_rtx = operands[2];
rtx align_rtx = operands[3];
HOST_WIDE_INT orig_bytes = INTVAL (bytes_rtx);
HOST_WIDE_INT bytes = orig_bytes;
HOST_WIDE_INT src_align = INTVAL (align_rtx) * BITS_PER_UNIT;
HOST_WIDE_INT dst_align = src_align;
rtx orig_src = operands[1];
rtx orig_dst = operands[0];
rtx data_regs[2 * MAX_MOVE_WORDS + 16];
rtx tmp;
unsigned int i, words, ofs, nregs = 0;
if (orig_bytes <= 0)
return 1;
else if (orig_bytes > MAX_MOVE_WORDS * UNITS_PER_WORD)
return 0;
/* Look for additional alignment information from recorded register info. */
tmp = XEXP (orig_src, 0);
if (REG_P (tmp))
src_align = MAX (src_align, REGNO_POINTER_ALIGN (REGNO (tmp)));
else if (GET_CODE (tmp) == PLUS
&& REG_P (XEXP (tmp, 0))
&& CONST_INT_P (XEXP (tmp, 1)))
{
unsigned HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
unsigned int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
if (a > src_align)
{
if (a >= 64 && c % 8 == 0)
src_align = 64;
else if (a >= 32 && c % 4 == 0)
src_align = 32;
else if (a >= 16 && c % 2 == 0)
src_align = 16;
}
}
tmp = XEXP (orig_dst, 0);
if (REG_P (tmp))
dst_align = MAX (dst_align, REGNO_POINTER_ALIGN (REGNO (tmp)));
else if (GET_CODE (tmp) == PLUS
&& REG_P (XEXP (tmp, 0))
&& CONST_INT_P (XEXP (tmp, 1)))
{
unsigned HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
unsigned int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
if (a > dst_align)
{
if (a >= 64 && c % 8 == 0)
dst_align = 64;
else if (a >= 32 && c % 4 == 0)
dst_align = 32;
else if (a >= 16 && c % 2 == 0)
dst_align = 16;
}
}
ofs = 0;
if (src_align >= 64 && bytes >= 8)
{
words = bytes / 8;
for (i = 0; i < words; ++i)
data_regs[nregs + i] = gen_reg_rtx (DImode);
for (i = 0; i < words; ++i)
emit_move_insn (data_regs[nregs + i],
adjust_address (orig_src, DImode, ofs + i * 8));
nregs += words;
bytes -= words * 8;
ofs += words * 8;
}
if (src_align >= 32 && bytes >= 4)
{
words = bytes / 4;
for (i = 0; i < words; ++i)
data_regs[nregs + i] = gen_reg_rtx (SImode);
for (i = 0; i < words; ++i)
emit_move_insn (data_regs[nregs + i],
adjust_address (orig_src, SImode, ofs + i * 4));
nregs += words;
bytes -= words * 4;
ofs += words * 4;
}
if (bytes >= 8)
{
words = bytes / 8;
for (i = 0; i < words+1; ++i)
data_regs[nregs + i] = gen_reg_rtx (DImode);
alpha_expand_unaligned_load_words (data_regs + nregs, orig_src,
words, ofs);
nregs += words;
bytes -= words * 8;
ofs += words * 8;
}
if (! TARGET_BWX && bytes >= 4)
{
data_regs[nregs++] = tmp = gen_reg_rtx (SImode);
alpha_expand_unaligned_load (tmp, orig_src, 4, ofs, 0);
bytes -= 4;
ofs += 4;
}
if (bytes >= 2)
{
if (src_align >= 16)
{
do {
data_regs[nregs++] = tmp = gen_reg_rtx (HImode);
emit_move_insn (tmp, adjust_address (orig_src, HImode, ofs));
bytes -= 2;
ofs += 2;
} while (bytes >= 2);
}
else if (! TARGET_BWX)
{
data_regs[nregs++] = tmp = gen_reg_rtx (HImode);
alpha_expand_unaligned_load (tmp, orig_src, 2, ofs, 0);
bytes -= 2;
ofs += 2;
}
}
while (bytes > 0)
{
data_regs[nregs++] = tmp = gen_reg_rtx (QImode);
emit_move_insn (tmp, adjust_address (orig_src, QImode, ofs));
bytes -= 1;
ofs += 1;
}
gcc_assert (nregs <= ARRAY_SIZE (data_regs));
/* Now save it back out again. */
i = 0, ofs = 0;
/* Write out the data in whatever chunks reading the source allowed. */
if (dst_align >= 64)
{
while (i < nregs && GET_MODE (data_regs[i]) == DImode)
{
emit_move_insn (adjust_address (orig_dst, DImode, ofs),
data_regs[i]);
ofs += 8;
i++;
}
}
if (dst_align >= 32)
{
/* If the source has remaining DImode regs, write them out in
two pieces. */
while (i < nregs && GET_MODE (data_regs[i]) == DImode)
{
tmp = expand_binop (DImode, lshr_optab, data_regs[i], GEN_INT (32),
NULL_RTX, 1, OPTAB_WIDEN);
emit_move_insn (adjust_address (orig_dst, SImode, ofs),
gen_lowpart (SImode, data_regs[i]));
emit_move_insn (adjust_address (orig_dst, SImode, ofs + 4),
gen_lowpart (SImode, tmp));
ofs += 8;
i++;
}
while (i < nregs && GET_MODE (data_regs[i]) == SImode)
{
emit_move_insn (adjust_address (orig_dst, SImode, ofs),
data_regs[i]);
ofs += 4;
i++;
}
}
if (i < nregs && GET_MODE (data_regs[i]) == DImode)
{
/* Write out a remaining block of words using unaligned methods. */
for (words = 1; i + words < nregs; words++)
if (GET_MODE (data_regs[i + words]) != DImode)
break;
if (words == 1)
alpha_expand_unaligned_store (orig_dst, data_regs[i], 8, ofs);
else
alpha_expand_unaligned_store_words (data_regs + i, orig_dst,
words, ofs);
i += words;
ofs += words * 8;
}
/* Due to the above, this won't be aligned. */
/* ??? If we have more than one of these, consider constructing full
words in registers and using alpha_expand_unaligned_store_words. */
while (i < nregs && GET_MODE (data_regs[i]) == SImode)
{
alpha_expand_unaligned_store (orig_dst, data_regs[i], 4, ofs);
ofs += 4;
i++;
}
if (dst_align >= 16)
while (i < nregs && GET_MODE (data_regs[i]) == HImode)
{
emit_move_insn (adjust_address (orig_dst, HImode, ofs), data_regs[i]);
i++;
ofs += 2;
}
else
while (i < nregs && GET_MODE (data_regs[i]) == HImode)
{
alpha_expand_unaligned_store (orig_dst, data_regs[i], 2, ofs);
i++;
ofs += 2;
}
/* The remainder must be byte copies. */
while (i < nregs)
{
gcc_assert (GET_MODE (data_regs[i]) == QImode);
emit_move_insn (adjust_address (orig_dst, QImode, ofs), data_regs[i]);
i++;
ofs += 1;
}
return 1;
}
int
alpha_expand_block_clear (rtx operands[])
{
rtx bytes_rtx = operands[1];
rtx align_rtx = operands[3];
HOST_WIDE_INT orig_bytes = INTVAL (bytes_rtx);
HOST_WIDE_INT bytes = orig_bytes;
HOST_WIDE_INT align = INTVAL (align_rtx) * BITS_PER_UNIT;
HOST_WIDE_INT alignofs = 0;
rtx orig_dst = operands[0];
rtx tmp;
int i, words, ofs = 0;
if (orig_bytes <= 0)
return 1;
if (orig_bytes > MAX_MOVE_WORDS * UNITS_PER_WORD)
return 0;
/* Look for stricter alignment. */
tmp = XEXP (orig_dst, 0);
if (REG_P (tmp))
align = MAX (align, REGNO_POINTER_ALIGN (REGNO (tmp)));
else if (GET_CODE (tmp) == PLUS
&& REG_P (XEXP (tmp, 0))
&& CONST_INT_P (XEXP (tmp, 1)))
{
HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
if (a > align)
{
if (a >= 64)
align = a, alignofs = 8 - c % 8;
else if (a >= 32)
align = a, alignofs = 4 - c % 4;
else if (a >= 16)
align = a, alignofs = 2 - c % 2;
}
}
/* Handle an unaligned prefix first. */
if (alignofs > 0)
{
#if HOST_BITS_PER_WIDE_INT >= 64
/* Given that alignofs is bounded by align, the only time BWX could
generate three stores is for a 7 byte fill. Prefer two individual
stores over a load/mask/store sequence. */
if ((!TARGET_BWX || alignofs == 7)
&& align >= 32
&& !(alignofs == 4 && bytes >= 4))
{
enum machine_mode mode = (align >= 64 ? DImode : SImode);
int inv_alignofs = (align >= 64 ? 8 : 4) - alignofs;
rtx mem, tmp;
HOST_WIDE_INT mask;
mem = adjust_address (orig_dst, mode, ofs - inv_alignofs);
set_mem_alias_set (mem, 0);
mask = ~(~(HOST_WIDE_INT)0 << (inv_alignofs * 8));
if (bytes < alignofs)
{
mask |= ~(HOST_WIDE_INT)0 << ((inv_alignofs + bytes) * 8);
ofs += bytes;
bytes = 0;
}
else
{
bytes -= alignofs;
ofs += alignofs;
}
alignofs = 0;
tmp = expand_binop (mode, and_optab, mem, GEN_INT (mask),
NULL_RTX, 1, OPTAB_WIDEN);
emit_move_insn (mem, tmp);
}
#endif
if (TARGET_BWX && (alignofs & 1) && bytes >= 1)
{
emit_move_insn (adjust_address (orig_dst, QImode, ofs), const0_rtx);
bytes -= 1;
ofs += 1;
alignofs -= 1;
}
if (TARGET_BWX && align >= 16 && (alignofs & 3) == 2 && bytes >= 2)
{
emit_move_insn (adjust_address (orig_dst, HImode, ofs), const0_rtx);
bytes -= 2;
ofs += 2;
alignofs -= 2;
}
if (alignofs == 4 && bytes >= 4)
{
emit_move_insn (adjust_address (orig_dst, SImode, ofs), const0_rtx);
bytes -= 4;
ofs += 4;
alignofs = 0;
}
/* If we've not used the extra lead alignment information by now,
we won't be able to. Downgrade align to match what's left over. */
if (alignofs > 0)
{
alignofs = alignofs & -alignofs;
align = MIN (align, alignofs * BITS_PER_UNIT);
}
}
/* Handle a block of contiguous long-words. */
if (align >= 64 && bytes >= 8)
{
words = bytes / 8;
for (i = 0; i < words; ++i)
emit_move_insn (adjust_address (orig_dst, DImode, ofs + i * 8),
const0_rtx);
bytes -= words * 8;
ofs += words * 8;
}
/* If the block is large and appropriately aligned, emit a single
store followed by a sequence of stq_u insns. */
if (align >= 32 && bytes > 16)
{
rtx orig_dsta;
emit_move_insn (adjust_address (orig_dst, SImode, ofs), const0_rtx);
bytes -= 4;
ofs += 4;
orig_dsta = XEXP (orig_dst, 0);
if (GET_CODE (orig_dsta) == LO_SUM)
orig_dsta = force_reg (Pmode, orig_dsta);
words = bytes / 8;
for (i = 0; i < words; ++i)
{
rtx mem
= change_address (orig_dst, DImode,
gen_rtx_AND (DImode,
plus_constant (orig_dsta, ofs + i*8),
GEN_INT (-8)));
set_mem_alias_set (mem, 0);
emit_move_insn (mem, const0_rtx);
}
/* Depending on the alignment, the first stq_u may have overlapped
with the initial stl, which means that the last stq_u didn't
write as much as it would appear. Leave those questionable bytes
unaccounted for. */
bytes -= words * 8 - 4;
ofs += words * 8 - 4;
}
/* Handle a smaller block of aligned words. */
if ((align >= 64 && bytes == 4)
|| (align == 32 && bytes >= 4))
{
words = bytes / 4;
for (i = 0; i < words; ++i)
emit_move_insn (adjust_address (orig_dst, SImode, ofs + i * 4),
const0_rtx);
bytes -= words * 4;
ofs += words * 4;
}
/* An unaligned block uses stq_u stores for as many as possible. */
if (bytes >= 8)
{
words = bytes / 8;
alpha_expand_unaligned_store_words (NULL, orig_dst, words, ofs);
bytes -= words * 8;
ofs += words * 8;
}
/* Next clean up any trailing pieces. */
#if HOST_BITS_PER_WIDE_INT >= 64
/* Count the number of bits in BYTES for which aligned stores could
be emitted. */
words = 0;
for (i = (TARGET_BWX ? 1 : 4); i * BITS_PER_UNIT <= align ; i <<= 1)
if (bytes & i)
words += 1;
/* If we have appropriate alignment (and it wouldn't take too many
instructions otherwise), mask out the bytes we need. */
if (TARGET_BWX ? words > 2 : bytes > 0)
{
if (align >= 64)
{
rtx mem, tmp;
HOST_WIDE_INT mask;
mem = adjust_address (orig_dst, DImode, ofs);
set_mem_alias_set (mem, 0);
mask = ~(HOST_WIDE_INT)0 << (bytes * 8);
tmp = expand_binop (DImode, and_optab, mem, GEN_INT (mask),
NULL_RTX, 1, OPTAB_WIDEN);
emit_move_insn (mem, tmp);
return 1;
}
else if (align >= 32 && bytes < 4)
{
rtx mem, tmp;
HOST_WIDE_INT mask;
mem = adjust_address (orig_dst, SImode, ofs);
set_mem_alias_set (mem, 0);
mask = ~(HOST_WIDE_INT)0 << (bytes * 8);
tmp = expand_binop (SImode, and_optab, mem, GEN_INT (mask),
NULL_RTX, 1, OPTAB_WIDEN);
emit_move_insn (mem, tmp);
return 1;
}
}
#endif
if (!TARGET_BWX && bytes >= 4)
{
alpha_expand_unaligned_store (orig_dst, const0_rtx, 4, ofs);
bytes -= 4;
ofs += 4;
}
if (bytes >= 2)
{
if (align >= 16)
{
do {
emit_move_insn (adjust_address (orig_dst, HImode, ofs),
const0_rtx);
bytes -= 2;
ofs += 2;
} while (bytes >= 2);
}
else if (! TARGET_BWX)
{
alpha_expand_unaligned_store (orig_dst, const0_rtx, 2, ofs);
bytes -= 2;
ofs += 2;
}
}
while (bytes > 0)
{
emit_move_insn (adjust_address (orig_dst, QImode, ofs), const0_rtx);
bytes -= 1;
ofs += 1;
}
return 1;
}
/* Returns a mask so that zap(x, value) == x & mask. */
rtx
alpha_expand_zap_mask (HOST_WIDE_INT value)
{
rtx result;
int i;
if (HOST_BITS_PER_WIDE_INT >= 64)
{
HOST_WIDE_INT mask = 0;
for (i = 7; i >= 0; --i)
{
mask <<= 8;
if (!((value >> i) & 1))
mask |= 0xff;
}
result = gen_int_mode (mask, DImode);
}
else
{
HOST_WIDE_INT mask_lo = 0, mask_hi = 0;
gcc_assert (HOST_BITS_PER_WIDE_INT == 32);
for (i = 7; i >= 4; --i)
{
mask_hi <<= 8;
if (!((value >> i) & 1))
mask_hi |= 0xff;
}
for (i = 3; i >= 0; --i)
{
mask_lo <<= 8;
if (!((value >> i) & 1))
mask_lo |= 0xff;
}
result = immed_double_const (mask_lo, mask_hi, DImode);
}
return result;
}
void
alpha_expand_builtin_vector_binop (rtx (*gen) (rtx, rtx, rtx),
enum machine_mode mode,
rtx op0, rtx op1, rtx op2)
{
op0 = gen_lowpart (mode, op0);
if (op1 == const0_rtx)
op1 = CONST0_RTX (mode);
else
op1 = gen_lowpart (mode, op1);
if (op2 == const0_rtx)
op2 = CONST0_RTX (mode);
else
op2 = gen_lowpart (mode, op2);
emit_insn ((*gen) (op0, op1, op2));
}
/* A subroutine of the atomic operation splitters. Jump to LABEL if
COND is true. Mark the jump as unlikely to be taken. */
static void
emit_unlikely_jump (rtx cond, rtx label)
{
rtx very_unlikely = GEN_INT (REG_BR_PROB_BASE / 100 - 1);
rtx x;
x = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label, pc_rtx);
x = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, x));
add_reg_note (x, REG_BR_PROB, very_unlikely);
}
/* A subroutine of the atomic operation splitters. Emit a load-locked
instruction in MODE. */
static void
emit_load_locked (enum machine_mode mode, rtx reg, rtx mem)
{
rtx (*fn) (rtx, rtx) = NULL;
if (mode == SImode)
fn = gen_load_locked_si;
else if (mode == DImode)
fn = gen_load_locked_di;
emit_insn (fn (reg, mem));
}
/* A subroutine of the atomic operation splitters. Emit a store-conditional
instruction in MODE. */
static void
emit_store_conditional (enum machine_mode mode, rtx res, rtx mem, rtx val)
{
rtx (*fn) (rtx, rtx, rtx) = NULL;
if (mode == SImode)
fn = gen_store_conditional_si;
else if (mode == DImode)
fn = gen_store_conditional_di;
emit_insn (fn (res, mem, val));
}
/* A subroutine of the atomic operation splitters. Emit an insxl
instruction in MODE. */
static rtx
emit_insxl (enum machine_mode mode, rtx op1, rtx op2)
{
rtx ret = gen_reg_rtx (DImode);
rtx (*fn) (rtx, rtx, rtx);
if (WORDS_BIG_ENDIAN)
{
if (mode == QImode)
fn = gen_insbl_be;
else
fn = gen_inswl_be;
}
else
{
if (mode == QImode)
fn = gen_insbl_le;
else
fn = gen_inswl_le;
}
/* The insbl and inswl patterns require a register operand. */
op1 = force_reg (mode, op1);
emit_insn (fn (ret, op1, op2));
return ret;
}
/* Expand an atomic fetch-and-operate pattern. CODE is the binary operation
to perform. MEM is the memory on which to operate. VAL is the second
operand of the binary operator. BEFORE and AFTER are optional locations to
return the value of MEM either before of after the operation. SCRATCH is
a scratch register. */
void
alpha_split_atomic_op (enum rtx_code code, rtx mem, rtx val,
rtx before, rtx after, rtx scratch)
{
enum machine_mode mode = GET_MODE (mem);
rtx label, x, cond = gen_rtx_REG (DImode, REGNO (scratch));
emit_insn (gen_memory_barrier ());
label = gen_label_rtx ();
emit_label (label);
label = gen_rtx_LABEL_REF (DImode, label);
if (before == NULL)
before = scratch;
emit_load_locked (mode, before, mem);
if (code == NOT)
{
x = gen_rtx_AND (mode, before, val);
emit_insn (gen_rtx_SET (VOIDmode, val, x));
x = gen_rtx_NOT (mode, val);
}
else
x = gen_rtx_fmt_ee (code, mode, before, val);
if (after)
emit_insn (gen_rtx_SET (VOIDmode, after, copy_rtx (x)));
emit_insn (gen_rtx_SET (VOIDmode, scratch, x));
emit_store_conditional (mode, cond, mem, scratch);
x = gen_rtx_EQ (DImode, cond, const0_rtx);
emit_unlikely_jump (x, label);
emit_insn (gen_memory_barrier ());
}
/* Expand a compare and swap operation. */
void
alpha_split_compare_and_swap (rtx retval, rtx mem, rtx oldval, rtx newval,
rtx scratch)
{
enum machine_mode mode = GET_MODE (mem);
rtx label1, label2, x, cond = gen_lowpart (DImode, scratch);
emit_insn (gen_memory_barrier ());
label1 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
label2 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
emit_label (XEXP (label1, 0));
emit_load_locked (mode, retval, mem);
x = gen_lowpart (DImode, retval);
if (oldval == const0_rtx)
x = gen_rtx_NE (DImode, x, const0_rtx);
else
{
x = gen_rtx_EQ (DImode, x, oldval);
emit_insn (gen_rtx_SET (VOIDmode, cond, x));
x = gen_rtx_EQ (DImode, cond, const0_rtx);
}
emit_unlikely_jump (x, label2);
emit_move_insn (scratch, newval);
emit_store_conditional (mode, cond, mem, scratch);
x = gen_rtx_EQ (DImode, cond, const0_rtx);
emit_unlikely_jump (x, label1);
emit_insn (gen_memory_barrier ());
emit_label (XEXP (label2, 0));
}
void
alpha_expand_compare_and_swap_12 (rtx dst, rtx mem, rtx oldval, rtx newval)
{
enum machine_mode mode = GET_MODE (mem);
rtx addr, align, wdst;
rtx (*fn5) (rtx, rtx, rtx, rtx, rtx);
addr = force_reg (DImode, XEXP (mem, 0));
align = expand_simple_binop (Pmode, AND, addr, GEN_INT (-8),
NULL_RTX, 1, OPTAB_DIRECT);
oldval = convert_modes (DImode, mode, oldval, 1);
newval = emit_insxl (mode, newval, addr);
wdst = gen_reg_rtx (DImode);
if (mode == QImode)
fn5 = gen_sync_compare_and_swapqi_1;
else
fn5 = gen_sync_compare_and_swaphi_1;
emit_insn (fn5 (wdst, addr, oldval, newval, align));
emit_move_insn (dst, gen_lowpart (mode, wdst));
}
void
alpha_split_compare_and_swap_12 (enum machine_mode mode, rtx dest, rtx addr,
rtx oldval, rtx newval, rtx align,
rtx scratch, rtx cond)
{
rtx label1, label2, mem, width, mask, x;
mem = gen_rtx_MEM (DImode, align);
MEM_VOLATILE_P (mem) = 1;
emit_insn (gen_memory_barrier ());
label1 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
label2 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
emit_label (XEXP (label1, 0));
emit_load_locked (DImode, scratch, mem);
width = GEN_INT (GET_MODE_BITSIZE (mode));
mask = GEN_INT (mode == QImode ? 0xff : 0xffff);
if (WORDS_BIG_ENDIAN)
emit_insn (gen_extxl_be (dest, scratch, width, addr));
else
emit_insn (gen_extxl_le (dest, scratch, width, addr));
if (oldval == const0_rtx)
x = gen_rtx_NE (DImode, dest, const0_rtx);
else
{
x = gen_rtx_EQ (DImode, dest, oldval);
emit_insn (gen_rtx_SET (VOIDmode, cond, x));
x = gen_rtx_EQ (DImode, cond, const0_rtx);
}
emit_unlikely_jump (x, label2);
if (WORDS_BIG_ENDIAN)
emit_insn (gen_mskxl_be (scratch, scratch, mask, addr));
else
emit_insn (gen_mskxl_le (scratch, scratch, mask, addr));
emit_insn (gen_iordi3 (scratch, scratch, newval));
emit_store_conditional (DImode, scratch, mem, scratch);
x = gen_rtx_EQ (DImode, scratch, const0_rtx);
emit_unlikely_jump (x, label1);
emit_insn (gen_memory_barrier ());
emit_label (XEXP (label2, 0));
}
/* Expand an atomic exchange operation. */
void
alpha_split_lock_test_and_set (rtx retval, rtx mem, rtx val, rtx scratch)
{
enum machine_mode mode = GET_MODE (mem);
rtx label, x, cond = gen_lowpart (DImode, scratch);
label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
emit_label (XEXP (label, 0));
emit_load_locked (mode, retval, mem);
emit_move_insn (scratch, val);
emit_store_conditional (mode, cond, mem, scratch);
x = gen_rtx_EQ (DImode, cond, const0_rtx);
emit_unlikely_jump (x, label);
emit_insn (gen_memory_barrier ());
}
void
alpha_expand_lock_test_and_set_12 (rtx dst, rtx mem, rtx val)
{
enum machine_mode mode = GET_MODE (mem);
rtx addr, align, wdst;
rtx (*fn4) (rtx, rtx, rtx, rtx);
/* Force the address into a register. */
addr = force_reg (DImode, XEXP (mem, 0));
/* Align it to a multiple of 8. */
align = expand_simple_binop (Pmode, AND, addr, GEN_INT (-8),
NULL_RTX, 1, OPTAB_DIRECT);
/* Insert val into the correct byte location within the word. */
val = emit_insxl (mode, val, addr);
wdst = gen_reg_rtx (DImode);
if (mode == QImode)
fn4 = gen_sync_lock_test_and_setqi_1;
else
fn4 = gen_sync_lock_test_and_sethi_1;
emit_insn (fn4 (wdst, addr, val, align));
emit_move_insn (dst, gen_lowpart (mode, wdst));
}
void
alpha_split_lock_test_and_set_12 (enum machine_mode mode, rtx dest, rtx addr,
rtx val, rtx align, rtx scratch)
{
rtx label, mem, width, mask, x;
mem = gen_rtx_MEM (DImode, align);
MEM_VOLATILE_P (mem) = 1;
label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ());
emit_label (XEXP (label, 0));
emit_load_locked (DImode, scratch, mem);
width = GEN_INT (GET_MODE_BITSIZE (mode));
mask = GEN_INT (mode == QImode ? 0xff : 0xffff);
if (WORDS_BIG_ENDIAN)
{
emit_insn (gen_extxl_be (dest, scratch, width, addr));
emit_insn (gen_mskxl_be (scratch, scratch, mask, addr));
}
else
{
emit_insn (gen_extxl_le (dest, scratch, width, addr));
emit_insn (gen_mskxl_le (scratch, scratch, mask, addr));
}
emit_insn (gen_iordi3 (scratch, scratch, val));
emit_store_conditional (DImode, scratch, mem, scratch);
x = gen_rtx_EQ (DImode, scratch, const0_rtx);
emit_unlikely_jump (x, label);
emit_insn (gen_memory_barrier ());
}
/* Adjust the cost of a scheduling dependency. Return the new cost of
a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
static int
alpha_adjust_cost (rtx insn, rtx link, rtx dep_insn, int cost)
{
enum attr_type dep_insn_type;
/* If the dependence is an anti-dependence, there is no cost. For an
output dependence, there is sometimes a cost, but it doesn't seem
worth handling those few cases. */
if (REG_NOTE_KIND (link) != 0)
return cost;
/* If we can't recognize the insns, we can't really do anything. */
if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0)
return cost;
dep_insn_type = get_attr_type (dep_insn);
/* Bring in the user-defined memory latency. */
if (dep_insn_type == TYPE_ILD
|| dep_insn_type == TYPE_FLD
|| dep_insn_type == TYPE_LDSYM)
cost += alpha_memory_latency-1;
/* Everything else handled in DFA bypasses now. */
return cost;
}
/* The number of instructions that can be issued per cycle. */
static int
alpha_issue_rate (void)
{
return (alpha_tune == PROCESSOR_EV4 ? 2 : 4);
}
/* How many alternative schedules to try. This should be as wide as the
scheduling freedom in the DFA, but no wider. Making this value too
large results extra work for the scheduler.
For EV4, loads can be issued to either IB0 or IB1, thus we have 2
alternative schedules. For EV5, we can choose between E0/E1 and
FA/FM. For EV6, an arithmetic insn can be issued to U0/U1/L0/L1. */
static int
alpha_multipass_dfa_lookahead (void)
{
return (alpha_tune == PROCESSOR_EV6 ? 4 : 2);
}
/* Machine-specific function data. */
struct GTY(()) machine_function
{
/* For unicosmk. */
/* List of call information words for calls from this function. */
struct rtx_def *first_ciw;
struct rtx_def *last_ciw;
int ciw_count;
/* List of deferred case vectors. */
struct rtx_def *addr_list;
/* For OSF. */
const char *some_ld_name;
/* For TARGET_LD_BUGGY_LDGP. */
struct rtx_def *gp_save_rtx;
/* For VMS condition handlers. */
bool uses_condition_handler;
};
/* How to allocate a 'struct machine_function'. */
static struct machine_function *
alpha_init_machine_status (void)
{
return ggc_alloc_cleared_machine_function ();
}
/* Support for frame based VMS condition handlers. */
/* A VMS condition handler may be established for a function with a call to
__builtin_establish_vms_condition_handler, and cancelled with a call to
__builtin_revert_vms_condition_handler.
The VMS Condition Handling Facility knows about the existence of a handler
from the procedure descriptor .handler field. As the VMS native compilers,
we store the user specified handler's address at a fixed location in the
stack frame and point the procedure descriptor at a common wrapper which
fetches the real handler's address and issues an indirect call.
The indirection wrapper is "__gcc_shell_handler", provided by libgcc.
We force the procedure kind to PT_STACK, and the fixed frame location is
fp+8, just before the register save area. We use the handler_data field in
the procedure descriptor to state the fp offset at which the installed
handler address can be found. */
#define VMS_COND_HANDLER_FP_OFFSET 8
/* Expand code to store the currently installed user VMS condition handler
into TARGET and install HANDLER as the new condition handler. */
void
alpha_expand_builtin_establish_vms_condition_handler (rtx target, rtx handler)
{
rtx handler_slot_address
= plus_constant (hard_frame_pointer_rtx, VMS_COND_HANDLER_FP_OFFSET);
rtx handler_slot
= gen_rtx_MEM (DImode, handler_slot_address);
emit_move_insn (target, handler_slot);
emit_move_insn (handler_slot, handler);
/* Notify the start/prologue/epilogue emitters that the condition handler
slot is needed. In addition to reserving the slot space, this will force
the procedure kind to PT_STACK so ensure that the hard_frame_pointer_rtx
use above is correct. */
cfun->machine->uses_condition_handler = true;
}
/* Expand code to store the current VMS condition handler into TARGET and
nullify it. */
void
alpha_expand_builtin_revert_vms_condition_handler (rtx target)
{
/* We implement this by establishing a null condition handler, with the tiny
side effect of setting uses_condition_handler. This is a little bit
pessimistic if no actual builtin_establish call is ever issued, which is
not a real problem and expected never to happen anyway. */
alpha_expand_builtin_establish_vms_condition_handler (target, const0_rtx);
}
/* Functions to save and restore alpha_return_addr_rtx. */
/* Start the ball rolling with RETURN_ADDR_RTX. */
rtx
alpha_return_addr (int count, rtx frame ATTRIBUTE_UNUSED)
{
if (count != 0)
return const0_rtx;
return get_hard_reg_initial_val (Pmode, REG_RA);
}
/* Return or create a memory slot containing the gp value for the current
function. Needed only if TARGET_LD_BUGGY_LDGP. */
rtx
alpha_gp_save_rtx (void)
{
rtx seq, m = cfun->machine->gp_save_rtx;
if (m == NULL)
{
start_sequence ();
m = assign_stack_local (DImode, UNITS_PER_WORD, BITS_PER_WORD);
m = validize_mem (m);
emit_move_insn (m, pic_offset_table_rtx);
seq = get_insns ();
end_sequence ();
/* We used to simply emit the sequence after entry_of_function.
However this breaks the CFG if the first instruction in the
first block is not the NOTE_INSN_BASIC_BLOCK, for example a
label. Emit the sequence properly on the edge. We are only
invoked from dw2_build_landing_pads and finish_eh_generation
will call commit_edge_insertions thanks to a kludge. */
insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
cfun->machine->gp_save_rtx = m;
}
return m;
}
static void
alpha_instantiate_decls (void)
{
if (cfun->machine->gp_save_rtx != NULL_RTX)
instantiate_decl_rtl (cfun->machine->gp_save_rtx);
}
static int
alpha_ra_ever_killed (void)
{
rtx top;
if (!has_hard_reg_initial_val (Pmode, REG_RA))
return (int)df_regs_ever_live_p (REG_RA);
push_topmost_sequence ();
top = get_insns ();
pop_topmost_sequence ();
return reg_set_between_p (gen_rtx_REG (Pmode, REG_RA), top, NULL_RTX);
}
/* Return the trap mode suffix applicable to the current
instruction, or NULL. */
static const char *
get_trap_mode_suffix (void)
{
enum attr_trap_suffix s = get_attr_trap_suffix (current_output_insn);
switch (s)
{
case TRAP_SUFFIX_NONE:
return NULL;
case TRAP_SUFFIX_SU:
if (alpha_fptm >= ALPHA_FPTM_SU)
return "su";
return NULL;
case TRAP_SUFFIX_SUI:
if (alpha_fptm >= ALPHA_FPTM_SUI)
return "sui";
return NULL;
case TRAP_SUFFIX_V_SV:
switch (alpha_fptm)
{
case ALPHA_FPTM_N:
return NULL;
case ALPHA_FPTM_U:
return "v";
case ALPHA_FPTM_SU:
case ALPHA_FPTM_SUI:
return "sv";
default:
gcc_unreachable ();
}
case TRAP_SUFFIX_V_SV_SVI:
switch (alpha_fptm)
{
case ALPHA_FPTM_N:
return NULL;
case ALPHA_FPTM_U:
return "v";
case ALPHA_FPTM_SU:
return "sv";
case ALPHA_FPTM_SUI:
return "svi";
default:
gcc_unreachable ();
}
break;
case TRAP_SUFFIX_U_SU_SUI:
switch (alpha_fptm)
{
case ALPHA_FPTM_N:
return NULL;
case ALPHA_FPTM_U:
return "u";
case ALPHA_FPTM_SU:
return "su";
case ALPHA_FPTM_SUI:
return "sui";
default:
gcc_unreachable ();
}
break;
default:
gcc_unreachable ();
}
gcc_unreachable ();
}
/* Return the rounding mode suffix applicable to the current
instruction, or NULL. */
static const char *
get_round_mode_suffix (void)
{
enum attr_round_suffix s = get_attr_round_suffix (current_output_insn);
switch (s)
{
case ROUND_SUFFIX_NONE:
return NULL;
case ROUND_SUFFIX_NORMAL:
switch (alpha_fprm)
{
case ALPHA_FPRM_NORM:
return NULL;
case ALPHA_FPRM_MINF:
return "m";
case ALPHA_FPRM_CHOP:
return "c";
case ALPHA_FPRM_DYN:
return "d";
default:
gcc_unreachable ();
}
break;
case ROUND_SUFFIX_C:
return "c";
default:
gcc_unreachable ();
}
gcc_unreachable ();
}
/* Locate some local-dynamic symbol still in use by this function
so that we can print its name in some movdi_er_tlsldm pattern. */
static int
get_some_local_dynamic_name_1 (rtx *px, void *data ATTRIBUTE_UNUSED)
{
rtx x = *px;
if (GET_CODE (x) == SYMBOL_REF
&& SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)
{
cfun->machine->some_ld_name = XSTR (x, 0);
return 1;
}
return 0;
}
static const char *
get_some_local_dynamic_name (void)
{
rtx insn;
if (cfun->machine->some_ld_name)
return cfun->machine->some_ld_name;
for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
if (INSN_P (insn)
&& for_each_rtx (&PATTERN (insn), get_some_local_dynamic_name_1, 0))
return cfun->machine->some_ld_name;
gcc_unreachable ();
}
/* Print an operand. Recognize special options, documented below. */
void
print_operand (FILE *file, rtx x, int code)
{
int i;
switch (code)
{
case '~':
/* Print the assembler name of the current function. */
assemble_name (file, alpha_fnname);
break;
case '&':
assemble_name (file, get_some_local_dynamic_name ());
break;
case '/':
{
const char *trap = get_trap_mode_suffix ();
const char *round = get_round_mode_suffix ();
if (trap || round)
fprintf (file, (TARGET_AS_SLASH_BEFORE_SUFFIX ? "/%s%s" : "%s%s"),
(trap ? trap : ""), (round ? round : ""));
break;
}
case ',':
/* Generates single precision instruction suffix. */
fputc ((TARGET_FLOAT_VAX ? 'f' : 's'), file);
break;
case '-':
/* Generates double precision instruction suffix. */
fputc ((TARGET_FLOAT_VAX ? 'g' : 't'), file);
break;
case '#':
if (alpha_this_literal_sequence_number == 0)
alpha_this_literal_sequence_number = alpha_next_sequence_number++;
fprintf (file, "%d", alpha_this_literal_sequence_number);
break;
case '*':
if (alpha_this_gpdisp_sequence_number == 0)
alpha_this_gpdisp_sequence_number = alpha_next_sequence_number++;
fprintf (file, "%d", alpha_this_gpdisp_sequence_number);
break;
case 'H':
if (GET_CODE (x) == HIGH)
output_addr_const (file, XEXP (x, 0));
else
output_operand_lossage ("invalid %%H value");
break;
case 'J':
{
const char *lituse;
if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLSGD_CALL)
{
x = XVECEXP (x, 0, 0);
lituse = "lituse_tlsgd";
}
else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLSLDM_CALL)
{
x = XVECEXP (x, 0, 0);
lituse = "lituse_tlsldm";
}
else if (CONST_INT_P (x))
lituse = "lituse_jsr";
else
{
output_operand_lossage ("invalid %%J value");
break;
}
if (x != const0_rtx)
fprintf (file, "\t\t!%s!%d", lituse, (int) INTVAL (x));
}
break;
case 'j':
{
const char *lituse;
#ifdef HAVE_AS_JSRDIRECT_RELOCS
lituse = "lituse_jsrdirect";
#else
lituse = "lituse_jsr";
#endif
gcc_assert (INTVAL (x) != 0);
fprintf (file, "\t\t!%s!%d", lituse, (int) INTVAL (x));
}
break;
case 'r':
/* If this operand is the constant zero, write it as "$31". */
if (REG_P (x))
fprintf (file, "%s", reg_names[REGNO (x)]);
else if (x == CONST0_RTX (GET_MODE (x)))
fprintf (file, "$31");
else
output_operand_lossage ("invalid %%r value");
break;
case 'R':
/* Similar, but for floating-point. */
if (REG_P (x))
fprintf (file, "%s", reg_names[REGNO (x)]);
else if (x == CONST0_RTX (GET_MODE (x)))
fprintf (file, "$f31");
else
output_operand_lossage ("invalid %%R value");
break;
case 'N':
/* Write the 1's complement of a constant. */
if (!CONST_INT_P (x))
output_operand_lossage ("invalid %%N value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ~ INTVAL (x));
break;
case 'P':
/* Write 1 << C, for a constant C. */
if (!CONST_INT_P (x))
output_operand_lossage ("invalid %%P value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) 1 << INTVAL (x));
break;
case 'h':
/* Write the high-order 16 bits of a constant, sign-extended. */
if (!CONST_INT_P (x))
output_operand_lossage ("invalid %%h value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) >> 16);
break;
case 'L':
/* Write the low-order 16 bits of a constant, sign-extended. */
if (!CONST_INT_P (x))
output_operand_lossage ("invalid %%L value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC,
(INTVAL (x) & 0xffff) - 2 * (INTVAL (x) & 0x8000));
break;
case 'm':
/* Write mask for ZAP insn. */
if (GET_CODE (x) == CONST_DOUBLE)
{
HOST_WIDE_INT mask = 0;
HOST_WIDE_INT value;
value = CONST_DOUBLE_LOW (x);
for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
i++, value >>= 8)
if (value & 0xff)
mask |= (1 << i);
value = CONST_DOUBLE_HIGH (x);
for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
i++, value >>= 8)
if (value & 0xff)
mask |= (1 << (i + sizeof (int)));
fprintf (file, HOST_WIDE_INT_PRINT_DEC, mask & 0xff);
}
else if (CONST_INT_P (x))
{
HOST_WIDE_INT mask = 0, value = INTVAL (x);
for (i = 0; i < 8; i++, value >>= 8)
if (value & 0xff)
mask |= (1 << i);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, mask);
}
else
output_operand_lossage ("invalid %%m value");
break;
case 'M':
/* 'b', 'w', 'l', or 'q' as the value of the constant. */
if (!CONST_INT_P (x)
|| (INTVAL (x) != 8 && INTVAL (x) != 16
&& INTVAL (x) != 32 && INTVAL (x) != 64))
output_operand_lossage ("invalid %%M value");
fprintf (file, "%s",
(INTVAL (x) == 8 ? "b"
: INTVAL (x) == 16 ? "w"
: INTVAL (x) == 32 ? "l"
: "q"));
break;
case 'U':
/* Similar, except do it from the mask. */
if (CONST_INT_P (x))
{
HOST_WIDE_INT value = INTVAL (x);
if (value == 0xff)
{
fputc ('b', file);
break;
}
if (value == 0xffff)
{
fputc ('w', file);
break;
}
if (value == 0xffffffff)
{
fputc ('l', file);
break;
}
if (value == -1)
{
fputc ('q', file);
break;
}
}
else if (HOST_BITS_PER_WIDE_INT == 32
&& GET_CODE (x) == CONST_DOUBLE
&& CONST_DOUBLE_LOW (x) == 0xffffffff
&& CONST_DOUBLE_HIGH (x) == 0)
{
fputc ('l', file);
break;
}
output_operand_lossage ("invalid %%U value");
break;
case 's':
/* Write the constant value divided by 8 for little-endian mode or
(56 - value) / 8 for big-endian mode. */
if (!CONST_INT_P (x)
|| (unsigned HOST_WIDE_INT) INTVAL (x) >= (WORDS_BIG_ENDIAN
? 56
: 64)
|| (INTVAL (x) & 7) != 0)
output_operand_lossage ("invalid %%s value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC,
WORDS_BIG_ENDIAN
? (56 - INTVAL (x)) / 8
: INTVAL (x) / 8);
break;
case 'S':
/* Same, except compute (64 - c) / 8 */
if (!CONST_INT_P (x)
&& (unsigned HOST_WIDE_INT) INTVAL (x) >= 64
&& (INTVAL (x) & 7) != 8)
output_operand_lossage ("invalid %%s value");
fprintf (file, HOST_WIDE_INT_PRINT_DEC, (64 - INTVAL (x)) / 8);
break;
case 't':
{
/* On Unicos/Mk systems: use a DEX expression if the symbol
clashes with a register name. */
int dex = unicosmk_need_dex (x);
if (dex)
fprintf (file, "DEX(%d)", dex);
else
output_addr_const (file, x);
}
break;
case 'C': case 'D': case 'c': case 'd':
/* Write out comparison name. */
{
enum rtx_code c = GET_CODE (x);
if (!COMPARISON_P (x))
output_operand_lossage ("invalid %%C value");
else if (code == 'D')
c = reverse_condition (c);
else if (code == 'c')
c = swap_condition (c);
else if (code == 'd')
c = swap_condition (reverse_condition (c));
if (c == LEU)
fprintf (file, "ule");
else if (c == LTU)
fprintf (file, "ult");
else if (c == UNORDERED)
fprintf (file, "un");
else
fprintf (file, "%s", GET_RTX_NAME (c));
}
break;
case 'E':
/* Write the divide or modulus operator. */
switch (GET_CODE (x))
{
case DIV:
fprintf (file, "div%s", GET_MODE (x) == SImode ? "l" : "q");
break;
case UDIV:
fprintf (file, "div%su", GET_MODE (x) == SImode ? "l" : "q");
break;
case MOD:
fprintf (file, "rem%s", GET_MODE (x) == SImode ? "l" : "q");
break;
case UMOD:
fprintf (file, "rem%su", GET_MODE (x) == SImode ? "l" : "q");
break;
default:
output_operand_lossage ("invalid %%E value");
break;
}
break;
case 'A':
/* Write "_u" for unaligned access. */
if (MEM_P (x) && GET_CODE (XEXP (x, 0)) == AND)
fprintf (file, "_u");
break;
case 0:
if (REG_P (x))
fprintf (file, "%s", reg_names[REGNO (x)]);
else if (MEM_P (x))
output_address (XEXP (x, 0));
else if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == UNSPEC)
{
switch (XINT (XEXP (x, 0), 1))
{
case UNSPEC_DTPREL:
case UNSPEC_TPREL:
output_addr_const (file, XVECEXP (XEXP (x, 0), 0, 0));
break;
default:
output_operand_lossage ("unknown relocation unspec");
break;
}
}
else
output_addr_const (file, x);
break;
default:
output_operand_lossage ("invalid %%xn code");
}
}
void
print_operand_address (FILE *file, rtx addr)
{
int basereg = 31;
HOST_WIDE_INT offset = 0;
if (GET_CODE (addr) == AND)
addr = XEXP (addr, 0);
if (GET_CODE (addr) == PLUS
&& CONST_INT_P (XEXP (addr, 1)))
{
offset = INTVAL (XEXP (addr, 1));
addr = XEXP (addr, 0);
}
if (GET_CODE (addr) == LO_SUM)
{
const char *reloc16, *reloclo;
rtx op1 = XEXP (addr, 1);
if (GET_CODE (op1) == CONST && GET_CODE (XEXP (op1, 0)) == UNSPEC)
{
op1 = XEXP (op1, 0);
switch (XINT (op1, 1))
{
case UNSPEC_DTPREL:
reloc16 = NULL;
reloclo = (alpha_tls_size == 16 ? "dtprel" : "dtprello");
break;
case UNSPEC_TPREL:
reloc16 = NULL;
reloclo = (alpha_tls_size == 16 ? "tprel" : "tprello");
break;
default:
output_operand_lossage ("unknown relocation unspec");
return;
}
output_addr_const (file, XVECEXP (op1, 0, 0));
}
else
{
reloc16 = "gprel";
reloclo = "gprellow";
output_addr_const (file, op1);
}
if (offset)
fprintf (file, "+" HOST_WIDE_INT_PRINT_DEC, offset);
addr = XEXP (addr, 0);
switch (GET_CODE (addr))
{
case REG:
basereg = REGNO (addr);
break;
case SUBREG:
basereg = subreg_regno (addr);
break;
default:
gcc_unreachable ();
}
fprintf (file, "($%d)\t\t!%s", basereg,
(basereg == 29 ? reloc16 : reloclo));
return;
}
switch (GET_CODE (addr))
{
case REG:
basereg = REGNO (addr);
break;
case SUBREG:
basereg = subreg_regno (addr);
break;
case CONST_INT:
offset = INTVAL (addr);
break;
#if TARGET_ABI_OPEN_VMS
case SYMBOL_REF:
fprintf (file, "%s", XSTR (addr, 0));
return;
case CONST:
gcc_assert (GET_CODE (XEXP (addr, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (addr, 0), 0)) == SYMBOL_REF);
fprintf (file, "%s+" HOST_WIDE_INT_PRINT_DEC,
XSTR (XEXP (XEXP (addr, 0), 0), 0),
INTVAL (XEXP (XEXP (addr, 0), 1)));
return;
#endif
default:
gcc_unreachable ();
}
fprintf (file, HOST_WIDE_INT_PRINT_DEC "($%d)", offset, basereg);
}
/* Emit RTL insns to initialize the variable parts of a trampoline at
M_TRAMP. FNDECL is target function's decl. CHAIN_VALUE is an rtx
for the static chain value for the function. */
static void
alpha_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
{
rtx fnaddr, mem, word1, word2;
fnaddr = XEXP (DECL_RTL (fndecl), 0);
#ifdef POINTERS_EXTEND_UNSIGNED
fnaddr = convert_memory_address (Pmode, fnaddr);
chain_value = convert_memory_address (Pmode, chain_value);
#endif
if (TARGET_ABI_OPEN_VMS)
{
const char *fnname;
char *trname;
/* Construct the name of the trampoline entry point. */
fnname = XSTR (fnaddr, 0);
trname = (char *) alloca (strlen (fnname) + 5);
strcpy (trname, fnname);
strcat (trname, "..tr");
fnname = ggc_alloc_string (trname, strlen (trname) + 1);
word2 = gen_rtx_SYMBOL_REF (Pmode, fnname);
/* Trampoline (or "bounded") procedure descriptor is constructed from
the function's procedure descriptor with certain fields zeroed IAW
the VMS calling standard. This is stored in the first quadword. */
word1 = force_reg (DImode, gen_const_mem (DImode, fnaddr));
word1 = expand_and (DImode, word1, GEN_INT (0xffff0fff0000fff0), NULL);
}
else
{
/* These 4 instructions are:
ldq $1,24($27)
ldq $27,16($27)
jmp $31,($27),0
nop
We don't bother setting the HINT field of the jump; the nop
is merely there for padding. */
word1 = GEN_INT (0xa77b0010a43b0018);
word2 = GEN_INT (0x47ff041f6bfb0000);
}
/* Store the first two words, as computed above. */
mem = adjust_address (m_tramp, DImode, 0);
emit_move_insn (mem, word1);
mem = adjust_address (m_tramp, DImode, 8);
emit_move_insn (mem, word2);
/* Store function address and static chain value. */
mem = adjust_address (m_tramp, Pmode, 16);
emit_move_insn (mem, fnaddr);
mem = adjust_address (m_tramp, Pmode, 24);
emit_move_insn (mem, chain_value);
if (!TARGET_ABI_OPEN_VMS)
{
emit_insn (gen_imb ());
#ifdef ENABLE_EXECUTE_STACK
emit_library_call (init_one_libfunc ("__enable_execute_stack"),
LCT_NORMAL, VOIDmode, 1, XEXP (m_tramp, 0), Pmode);
#endif
}
}
/* Determine where to put an argument to a function.
Value is zero to push the argument on the stack,
or a hard register in which to store the argument.
MODE is the argument's machine mode.
TYPE is the data type of the argument (as a tree).
This is null for libcalls where that information may
not be available.
CUM is a variable of type CUMULATIVE_ARGS which gives info about
the preceding args and about the function being called.
NAMED is nonzero if this argument is a named parameter
(otherwise it is an extra parameter matching an ellipsis).
On Alpha the first 6 words of args are normally in registers
and the rest are pushed. */
static rtx
alpha_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
const_tree type, bool named ATTRIBUTE_UNUSED)
{
int basereg;
int num_args;
/* Don't get confused and pass small structures in FP registers. */
if (type && AGGREGATE_TYPE_P (type))
basereg = 16;
else
{
#ifdef ENABLE_CHECKING
/* With alpha_split_complex_arg, we shouldn't see any raw complex
values here. */
gcc_assert (!COMPLEX_MODE_P (mode));
#endif
/* Set up defaults for FP operands passed in FP registers, and
integral operands passed in integer registers. */
if (TARGET_FPREGS && GET_MODE_CLASS (mode) == MODE_FLOAT)
basereg = 32 + 16;
else
basereg = 16;
}
/* ??? Irritatingly, the definition of CUMULATIVE_ARGS is different for
the two platforms, so we can't avoid conditional compilation. */
#if TARGET_ABI_OPEN_VMS
{
if (mode == VOIDmode)
return alpha_arg_info_reg_val (*cum);
num_args = cum->num_args;
if (num_args >= 6
|| targetm.calls.must_pass_in_stack (mode, type))
return NULL_RTX;
}
#elif TARGET_ABI_OSF
{
if (*cum >= 6)
return NULL_RTX;
num_args = *cum;
/* VOID is passed as a special flag for "last argument". */
if (type == void_type_node)
basereg = 16;
else if (targetm.calls.must_pass_in_stack (mode, type))
return NULL_RTX;
}
#else
#error Unhandled ABI
#endif
return gen_rtx_REG (mode, num_args + basereg);
}
/* Update the data in CUM to advance over an argument
of mode MODE and data type TYPE.
(TYPE is null for libcalls where that information may not be available.) */
static void
alpha_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
const_tree type, bool named ATTRIBUTE_UNUSED)
{
bool onstack = targetm.calls.must_pass_in_stack (mode, type);
int increment = onstack ? 6 : ALPHA_ARG_SIZE (mode, type, named);
#if TARGET_ABI_OSF
*cum += increment;
#else
if (!onstack && cum->num_args < 6)
cum->atypes[cum->num_args] = alpha_arg_type (mode);
cum->num_args += increment;
#endif
}
static int
alpha_arg_partial_bytes (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
enum machine_mode mode ATTRIBUTE_UNUSED,
tree type ATTRIBUTE_UNUSED,
bool named ATTRIBUTE_UNUSED)
{
int words = 0;
#if TARGET_ABI_OPEN_VMS
if (cum->num_args < 6
&& 6 < cum->num_args + ALPHA_ARG_SIZE (mode, type, named))
words = 6 - cum->num_args;
#elif TARGET_ABI_UNICOSMK
/* Never any split arguments. */
#elif TARGET_ABI_OSF
if (*cum < 6 && 6 < *cum + ALPHA_ARG_SIZE (mode, type, named))
words = 6 - *cum;
#else
#error Unhandled ABI
#endif
return words * UNITS_PER_WORD;
}
/* Return true if TYPE must be returned in memory, instead of in registers. */
static bool
alpha_return_in_memory (const_tree type, const_tree fndecl ATTRIBUTE_UNUSED)
{
enum machine_mode mode = VOIDmode;
int size;
if (type)
{
mode = TYPE_MODE (type);
/* All aggregates are returned in memory, except on OpenVMS where
records that fit 64 bits should be returned by immediate value
as required by section 3.8.7.1 of the OpenVMS Calling Standard. */
if (TARGET_ABI_OPEN_VMS
&& TREE_CODE (type) != ARRAY_TYPE
&& (unsigned HOST_WIDE_INT) int_size_in_bytes(type) <= 8)
return false;
if (AGGREGATE_TYPE_P (type))
return true;
}
size = GET_MODE_SIZE (mode);
switch (GET_MODE_CLASS (mode))
{
case MODE_VECTOR_FLOAT:
/* Pass all float vectors in memory, like an aggregate. */
return true;
case MODE_COMPLEX_FLOAT:
/* We judge complex floats on the size of their element,
not the size of the whole type. */
size = GET_MODE_UNIT_SIZE (mode);
break;
case MODE_INT:
case MODE_FLOAT:
case MODE_COMPLEX_INT:
case MODE_VECTOR_INT:
break;
default:
/* ??? We get called on all sorts of random stuff from
aggregate_value_p. We must return something, but it's not
clear what's safe to return. Pretend it's a struct I
guess. */
return true;
}
/* Otherwise types must fit in one register. */
return size > UNITS_PER_WORD;
}
/* Return true if TYPE should be passed by invisible reference. */
static bool
alpha_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
enum machine_mode mode,
const_tree type ATTRIBUTE_UNUSED,
bool named ATTRIBUTE_UNUSED)
{
return mode == TFmode || mode == TCmode;
}
/* Define how to find the value returned by a function. VALTYPE is the
data type of the value (as a tree). If the precise function being
called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0.
MODE is set instead of VALTYPE for libcalls.
On Alpha the value is found in $0 for integer functions and
$f0 for floating-point functions. */
rtx
function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED,
enum machine_mode mode)
{
unsigned int regnum, dummy ATTRIBUTE_UNUSED;
enum mode_class mclass;
gcc_assert (!valtype || !alpha_return_in_memory (valtype, func));
if (valtype)
mode = TYPE_MODE (valtype);
mclass = GET_MODE_CLASS (mode);
switch (mclass)
{
case MODE_INT:
/* Do the same thing as PROMOTE_MODE except for libcalls on VMS,
where we have them returning both SImode and DImode. */
if (!(TARGET_ABI_OPEN_VMS && valtype && AGGREGATE_TYPE_P (valtype)))
PROMOTE_MODE (mode, dummy, valtype);
/* FALLTHRU */
case MODE_COMPLEX_INT:
case MODE_VECTOR_INT:
regnum = 0;
break;
case MODE_FLOAT:
regnum = 32;
break;
case MODE_COMPLEX_FLOAT:
{
enum machine_mode cmode = GET_MODE_INNER (mode);
return gen_rtx_PARALLEL
(VOIDmode,
gen_rtvec (2,
gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (cmode, 32),
const0_rtx),
gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (cmode, 33),
GEN_INT (GET_MODE_SIZE (cmode)))));
}
case MODE_RANDOM:
/* We should only reach here for BLKmode on VMS. */
gcc_assert (TARGET_ABI_OPEN_VMS && mode == BLKmode);
regnum = 0;
break;
default:
gcc_unreachable ();
}
return gen_rtx_REG (mode, regnum);
}
/* TCmode complex values are passed by invisible reference. We
should not split these values. */
static bool
alpha_split_complex_arg (const_tree type)
{
return TYPE_MODE (type) != TCmode;
}
static tree
alpha_build_builtin_va_list (void)
{
tree base, ofs, space, record, type_decl;
if (TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK)
return ptr_type_node;
record = (*lang_hooks.types.make_type) (RECORD_TYPE);
type_decl = build_decl (BUILTINS_LOCATION,
TYPE_DECL, get_identifier ("__va_list_tag"), record);
TYPE_STUB_DECL (record) = type_decl;
TYPE_NAME (record) = type_decl;
/* C++? SET_IS_AGGR_TYPE (record, 1); */
/* Dummy field to prevent alignment warnings. */
space = build_decl (BUILTINS_LOCATION,
FIELD_DECL, NULL_TREE, integer_type_node);
DECL_FIELD_CONTEXT (space) = record;
DECL_ARTIFICIAL (space) = 1;
DECL_IGNORED_P (space) = 1;
ofs = build_decl (BUILTINS_LOCATION,
FIELD_DECL, get_identifier ("__offset"),
integer_type_node);
DECL_FIELD_CONTEXT (ofs) = record;
DECL_CHAIN (ofs) = space;
/* ??? This is a hack, __offset is marked volatile to prevent
DCE that confuses stdarg optimization and results in
gcc.c-torture/execute/stdarg-1.c failure. See PR 41089. */
TREE_THIS_VOLATILE (ofs) = 1;
base = build_decl (BUILTINS_LOCATION,
FIELD_DECL, get_identifier ("__base"),
ptr_type_node);
DECL_FIELD_CONTEXT (base) = record;
DECL_CHAIN (base) = ofs;
TYPE_FIELDS (record) = base;
layout_type (record);
va_list_gpr_counter_field = ofs;
return record;
}
#if TARGET_ABI_OSF
/* Helper function for alpha_stdarg_optimize_hook. Skip over casts
and constant additions. */
static gimple
va_list_skip_additions (tree lhs)
{
gimple stmt;
for (;;)
{
enum tree_code code;
stmt = SSA_NAME_DEF_STMT (lhs);
if (gimple_code (stmt) == GIMPLE_PHI)
return stmt;
if (!is_gimple_assign (stmt)
|| gimple_assign_lhs (stmt) != lhs)
return NULL;
if (TREE_CODE (gimple_assign_rhs1 (stmt)) != SSA_NAME)
return stmt;
code = gimple_assign_rhs_code (stmt);
if (!CONVERT_EXPR_CODE_P (code)
&& ((code != PLUS_EXPR && code != POINTER_PLUS_EXPR)
|| TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST
|| !host_integerp (gimple_assign_rhs2 (stmt), 1)))
return stmt;
lhs = gimple_assign_rhs1 (stmt);
}
}
/* Check if LHS = RHS statement is
LHS = *(ap.__base + ap.__offset + cst)
or
LHS = *(ap.__base
+ ((ap.__offset + cst <= 47)
? ap.__offset + cst - 48 : ap.__offset + cst) + cst2).
If the former, indicate that GPR registers are needed,
if the latter, indicate that FPR registers are needed.
Also look for LHS = (*ptr).field, where ptr is one of the forms
listed above.
On alpha, cfun->va_list_gpr_size is used as size of the needed
regs and cfun->va_list_fpr_size is a bitmask, bit 0 set if GPR
registers are needed and bit 1 set if FPR registers are needed.
Return true if va_list references should not be scanned for the
current statement. */
static bool
alpha_stdarg_optimize_hook (struct stdarg_info *si, const_gimple stmt)
{
tree base, offset, rhs;
int offset_arg = 1;
gimple base_stmt;
if (get_gimple_rhs_class (gimple_assign_rhs_code (stmt))
!= GIMPLE_SINGLE_RHS)
return false;
rhs = gimple_assign_rhs1 (stmt);
while (handled_component_p (rhs))
rhs = TREE_OPERAND (rhs, 0);
if (TREE_CODE (rhs) != MEM_REF
|| TREE_CODE (TREE_OPERAND (rhs, 0)) != SSA_NAME)
return false;
stmt = va_list_skip_additions (TREE_OPERAND (rhs, 0));
if (stmt == NULL
|| !is_gimple_assign (stmt)
|| gimple_assign_rhs_code (stmt) != POINTER_PLUS_EXPR)
return false;
base = gimple_assign_rhs1 (stmt);
if (TREE_CODE (base) == SSA_NAME)
{
base_stmt = va_list_skip_additions (base);
if (base_stmt
&& is_gimple_assign (base_stmt)
&& gimple_assign_rhs_code (base_stmt) == COMPONENT_REF)
base = gimple_assign_rhs1 (base_stmt);
}
if (TREE_CODE (base) != COMPONENT_REF
|| TREE_OPERAND (base, 1) != TYPE_FIELDS (va_list_type_node))
{
base = gimple_assign_rhs2 (stmt);
if (TREE_CODE (base) == SSA_NAME)
{
base_stmt = va_list_skip_additions (base);
if (base_stmt
&& is_gimple_assign (base_stmt)
&& gimple_assign_rhs_code (base_stmt) == COMPONENT_REF)
base = gimple_assign_rhs1 (base_stmt);
}
if (TREE_CODE (base) != COMPONENT_REF
|| TREE_OPERAND (base, 1) != TYPE_FIELDS (va_list_type_node))
return false;
offset_arg = 0;
}
base = get_base_address (base);
if (TREE_CODE (base) != VAR_DECL
|| !bitmap_bit_p (si->va_list_vars, DECL_UID (base)))
return false;
offset = gimple_op (stmt, 1 + offset_arg);
if (TREE_CODE (offset) == SSA_NAME)
{
gimple offset_stmt = va_list_skip_additions (offset);
if (offset_stmt
&& gimple_code (offset_stmt) == GIMPLE_PHI)
{
HOST_WIDE_INT sub;
gimple arg1_stmt, arg2_stmt;
tree arg1, arg2;
enum tree_code code1, code2;
if (gimple_phi_num_args (offset_stmt) != 2)
goto escapes;
arg1_stmt
= va_list_skip_additions (gimple_phi_arg_def (offset_stmt, 0));
arg2_stmt
= va_list_skip_additions (gimple_phi_arg_def (offset_stmt, 1));
if (arg1_stmt == NULL
|| !is_gimple_assign (arg1_stmt)
|| arg2_stmt == NULL
|| !is_gimple_assign (arg2_stmt))
goto escapes;
code1 = gimple_assign_rhs_code (arg1_stmt);
code2 = gimple_assign_rhs_code (arg2_stmt);
if (code1 == COMPONENT_REF
&& (code2 == MINUS_EXPR || code2 == PLUS_EXPR))
/* Do nothing. */;
else if (code2 == COMPONENT_REF
&& (code1 == MINUS_EXPR || code1 == PLUS_EXPR))
{
gimple tem = arg1_stmt;
code2 = code1;
arg1_stmt = arg2_stmt;
arg2_stmt = tem;
}
else
goto escapes;
if (!host_integerp (gimple_assign_rhs2 (arg2_stmt), 0))
goto escapes;
sub = tree_low_cst (gimple_assign_rhs2 (arg2_stmt), 0);
if (code2 == MINUS_EXPR)
sub = -sub;
if (sub < -48 || sub > -32)
goto escapes;
arg1 = gimple_assign_rhs1 (arg1_stmt);
arg2 = gimple_assign_rhs1 (arg2_stmt);
if (TREE_CODE (arg2) == SSA_NAME)
{
arg2_stmt = va_list_skip_additions (arg2);
if (arg2_stmt == NULL
|| !is_gimple_assign (arg2_stmt)
|| gimple_assign_rhs_code (arg2_stmt) != COMPONENT_REF)
goto escapes;
arg2 = gimple_assign_rhs1 (arg2_stmt);
}
if (arg1 != arg2)
goto escapes;
if (TREE_CODE (arg1) != COMPONENT_REF
|| TREE_OPERAND (arg1, 1) != va_list_gpr_counter_field
|| get_base_address (arg1) != base)
goto escapes;
/* Need floating point regs. */
cfun->va_list_fpr_size |= 2;
return false;
}
if (offset_stmt
&& is_gimple_assign (offset_stmt)
&& gimple_assign_rhs_code (offset_stmt) == COMPONENT_REF)
offset = gimple_assign_rhs1 (offset_stmt);
}
if (TREE_CODE (offset) != COMPONENT_REF
|| TREE_OPERAND (offset, 1) != va_list_gpr_counter_field
|| get_base_address (offset) != base)
goto escapes;
else
/* Need general regs. */
cfun->va_list_fpr_size |= 1;
return false;
escapes:
si->va_list_escapes = true;
return false;
}
#endif
/* Perform any needed actions needed for a function that is receiving a
variable number of arguments. */
static void
alpha_setup_incoming_varargs (CUMULATIVE_ARGS *pcum, enum machine_mode mode,
tree type, int *pretend_size, int no_rtl)
{
CUMULATIVE_ARGS cum = *pcum;
/* Skip the current argument. */
targetm.calls.function_arg_advance (&cum, mode, type, true);
#if TARGET_ABI_UNICOSMK
/* On Unicos/Mk, the standard subroutine __T3E_MISMATCH stores all register
arguments on the stack. Unfortunately, it doesn't always store the first
one (i.e. the one that arrives in $16 or $f16). This is not a problem
with stdargs as we always have at least one named argument there. */
if (cum.num_reg_words < 6)
{
if (!no_rtl)
{
emit_insn (gen_umk_mismatch_args (GEN_INT (cum.num_reg_words)));
emit_insn (gen_arg_home_umk ());
}
*pretend_size = 0;
}
#elif TARGET_ABI_OPEN_VMS
/* For VMS, we allocate space for all 6 arg registers plus a count.
However, if NO registers need to be saved, don't allocate any space.
This is not only because we won't need the space, but because AP
includes the current_pretend_args_size and we don't want to mess up
any ap-relative addresses already made. */
if (cum.num_args < 6)
{
if (!no_rtl)
{
emit_move_insn (gen_rtx_REG (DImode, 1), virtual_incoming_args_rtx);
emit_insn (gen_arg_home ());
}
*pretend_size = 7 * UNITS_PER_WORD;
}
#else
/* On OSF/1 and friends, we allocate space for all 12 arg registers, but
only push those that are remaining. However, if NO registers need to
be saved, don't allocate any space. This is not only because we won't
need the space, but because AP includes the current_pretend_args_size
and we don't want to mess up any ap-relative addresses already made.
If we are not to use the floating-point registers, save the integer
registers where we would put the floating-point registers. This is
not the most efficient way to implement varargs with just one register
class, but it isn't worth doing anything more efficient in this rare
case. */
if (cum >= 6)
return;
if (!no_rtl)
{
int count;
alias_set_type set = get_varargs_alias_set ();
rtx tmp;
count = cfun->va_list_gpr_size / UNITS_PER_WORD;
if (count > 6 - cum)
count = 6 - cum;
/* Detect whether integer registers or floating-point registers
are needed by the detected va_arg statements. See above for
how these values are computed. Note that the "escape" value
is VA_LIST_MAX_FPR_SIZE, which is 255, which has both of
these bits set. */
gcc_assert ((VA_LIST_MAX_FPR_SIZE & 3) == 3);
if (cfun->va_list_fpr_size & 1)
{
tmp = gen_rtx_MEM (BLKmode,
plus_constant (virtual_incoming_args_rtx,
(cum + 6) * UNITS_PER_WORD));
MEM_NOTRAP_P (tmp) = 1;
set_mem_alias_set (tmp, set);
move_block_from_reg (16 + cum, tmp, count);
}
if (cfun->va_list_fpr_size & 2)
{
tmp = gen_rtx_MEM (BLKmode,
plus_constant (virtual_incoming_args_rtx,
cum * UNITS_PER_WORD));
MEM_NOTRAP_P (tmp) = 1;
set_mem_alias_set (tmp, set);
move_block_from_reg (16 + cum + TARGET_FPREGS*32, tmp, count);
}
}
*pretend_size = 12 * UNITS_PER_WORD;
#endif
}
static void
alpha_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
{
HOST_WIDE_INT offset;
tree t, offset_field, base_field;
if (TREE_CODE (TREE_TYPE (valist)) == ERROR_MARK)
return;
if (TARGET_ABI_UNICOSMK)
std_expand_builtin_va_start (valist, nextarg);
/* For Unix, TARGET_SETUP_INCOMING_VARARGS moves the starting address base
up by 48, storing fp arg registers in the first 48 bytes, and the
integer arg registers in the next 48 bytes. This is only done,
however, if any integer registers need to be stored.
If no integer registers need be stored, then we must subtract 48
in order to account for the integer arg registers which are counted
in argsize above, but which are not actually stored on the stack.
Must further be careful here about structures straddling the last
integer argument register; that futzes with pretend_args_size,
which changes the meaning of AP. */
if (NUM_ARGS < 6)
offset = TARGET_ABI_OPEN_VMS ? UNITS_PER_WORD : 6 * UNITS_PER_WORD;
else
offset = -6 * UNITS_PER_WORD + crtl->args.pretend_args_size;
if (TARGET_ABI_OPEN_VMS)
{
t = make_tree (ptr_type_node, virtual_incoming_args_rtx);
t = build2 (POINTER_PLUS_EXPR, ptr_type_node, t,
size_int (offset + NUM_ARGS * UNITS_PER_WORD));
t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
else
{
base_field = TYPE_FIELDS (TREE_TYPE (valist));
offset_field = DECL_CHAIN (base_field);
base_field = build3 (COMPONENT_REF, TREE_TYPE (base_field),
valist, base_field, NULL_TREE);
offset_field = build3 (COMPONENT_REF, TREE_TYPE (offset_field),
valist, offset_field, NULL_TREE);
t = make_tree (ptr_type_node, virtual_incoming_args_rtx);
t = build2 (POINTER_PLUS_EXPR, ptr_type_node, t,
size_int (offset));
t = build2 (MODIFY_EXPR, TREE_TYPE (base_field), base_field, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
t = build_int_cst (NULL_TREE, NUM_ARGS * UNITS_PER_WORD);
t = build2 (MODIFY_EXPR, TREE_TYPE (offset_field), offset_field, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
}
static tree
alpha_gimplify_va_arg_1 (tree type, tree base, tree offset,
gimple_seq *pre_p)
{
tree type_size, ptr_type, addend, t, addr;
gimple_seq internal_post;
/* If the type could not be passed in registers, skip the block
reserved for the registers. */
if (targetm.calls.must_pass_in_stack (TYPE_MODE (type), type))
{
t = build_int_cst (TREE_TYPE (offset), 6*8);
gimplify_assign (offset,
build2 (MAX_EXPR, TREE_TYPE (offset), offset, t),
pre_p);
}
addend = offset;
ptr_type = build_pointer_type_for_mode (type, ptr_mode, true);
if (TREE_CODE (type) == COMPLEX_TYPE)
{
tree real_part, imag_part, real_temp;
real_part = alpha_gimplify_va_arg_1 (TREE_TYPE (type), base,
offset, pre_p);
/* Copy the value into a new temporary, lest the formal temporary
be reused out from under us. */
real_temp = get_initialized_tmp_var (real_part, pre_p, NULL);
imag_part = alpha_gimplify_va_arg_1 (TREE_TYPE (type), base,
offset, pre_p);
return build2 (COMPLEX_EXPR, type, real_temp, imag_part);
}
else if (TREE_CODE (type) == REAL_TYPE)
{
tree fpaddend, cond, fourtyeight;
fourtyeight = build_int_cst (TREE_TYPE (addend), 6*8);
fpaddend = fold_build2 (MINUS_EXPR, TREE_TYPE (addend),
addend, fourtyeight);
cond = fold_build2 (LT_EXPR, boolean_type_node, addend, fourtyeight);
addend = fold_build3 (COND_EXPR, TREE_TYPE (addend), cond,
fpaddend, addend);
}
/* Build the final address and force that value into a temporary. */
addr = build2 (POINTER_PLUS_EXPR, ptr_type, fold_convert (ptr_type, base),
fold_convert (sizetype, addend));
internal_post = NULL;
gimplify_expr (&addr, pre_p, &internal_post, is_gimple_val, fb_rvalue);
gimple_seq_add_seq (pre_p, internal_post);
/* Update the offset field. */
type_size = TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (type));
if (type_size == NULL || TREE_OVERFLOW (type_size))
t = size_zero_node;
else
{
t = size_binop (PLUS_EXPR, type_size, size_int (7));
t = size_binop (TRUNC_DIV_EXPR, t, size_int (8));
t = size_binop (MULT_EXPR, t, size_int (8));
}
t = fold_convert (TREE_TYPE (offset), t);
gimplify_assign (offset, build2 (PLUS_EXPR, TREE_TYPE (offset), offset, t),
pre_p);
return build_va_arg_indirect_ref (addr);
}
static tree
alpha_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
gimple_seq *post_p)
{
tree offset_field, base_field, offset, base, t, r;
bool indirect;
if (TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK)
return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);
base_field = TYPE_FIELDS (va_list_type_node);
offset_field = DECL_CHAIN (base_field);
base_field = build3 (COMPONENT_REF, TREE_TYPE (base_field),
valist, base_field, NULL_TREE);
offset_field = build3 (COMPONENT_REF, TREE_TYPE (offset_field),
valist, offset_field, NULL_TREE);
/* Pull the fields of the structure out into temporaries. Since we never
modify the base field, we can use a formal temporary. Sign-extend the
offset field so that it's the proper width for pointer arithmetic. */
base = get_formal_tmp_var (base_field, pre_p);
t = fold_convert (lang_hooks.types.type_for_size (64, 0), offset_field);
offset = get_initialized_tmp_var (t, pre_p, NULL);
indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
if (indirect)
type = build_pointer_type_for_mode (type, ptr_mode, true);
/* Find the value. Note that this will be a stable indirection, or
a composite of stable indirections in the case of complex. */
r = alpha_gimplify_va_arg_1 (type, base, offset, pre_p);
/* Stuff the offset temporary back into its field. */
gimplify_assign (unshare_expr (offset_field),
fold_convert (TREE_TYPE (offset_field), offset), pre_p);
if (indirect)
r = build_va_arg_indirect_ref (r);
return r;
}
/* Builtins. */
enum alpha_builtin
{
ALPHA_BUILTIN_CMPBGE,
ALPHA_BUILTIN_EXTBL,
ALPHA_BUILTIN_EXTWL,
ALPHA_BUILTIN_EXTLL,
ALPHA_BUILTIN_EXTQL,
ALPHA_BUILTIN_EXTWH,
ALPHA_BUILTIN_EXTLH,
ALPHA_BUILTIN_EXTQH,
ALPHA_BUILTIN_INSBL,
ALPHA_BUILTIN_INSWL,
ALPHA_BUILTIN_INSLL,
ALPHA_BUILTIN_INSQL,
ALPHA_BUILTIN_INSWH,
ALPHA_BUILTIN_INSLH,
ALPHA_BUILTIN_INSQH,
ALPHA_BUILTIN_MSKBL,
ALPHA_BUILTIN_MSKWL,
ALPHA_BUILTIN_MSKLL,
ALPHA_BUILTIN_MSKQL,
ALPHA_BUILTIN_MSKWH,
ALPHA_BUILTIN_MSKLH,
ALPHA_BUILTIN_MSKQH,
ALPHA_BUILTIN_UMULH,
ALPHA_BUILTIN_ZAP,
ALPHA_BUILTIN_ZAPNOT,
ALPHA_BUILTIN_AMASK,
ALPHA_BUILTIN_IMPLVER,
ALPHA_BUILTIN_RPCC,
ALPHA_BUILTIN_THREAD_POINTER,
ALPHA_BUILTIN_SET_THREAD_POINTER,
ALPHA_BUILTIN_ESTABLISH_VMS_CONDITION_HANDLER,
ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER,
/* TARGET_MAX */
ALPHA_BUILTIN_MINUB8,
ALPHA_BUILTIN_MINSB8,
ALPHA_BUILTIN_MINUW4,
ALPHA_BUILTIN_MINSW4,
ALPHA_BUILTIN_MAXUB8,
ALPHA_BUILTIN_MAXSB8,
ALPHA_BUILTIN_MAXUW4,
ALPHA_BUILTIN_MAXSW4,
ALPHA_BUILTIN_PERR,
ALPHA_BUILTIN_PKLB,
ALPHA_BUILTIN_PKWB,
ALPHA_BUILTIN_UNPKBL,
ALPHA_BUILTIN_UNPKBW,
/* TARGET_CIX */
ALPHA_BUILTIN_CTTZ,
ALPHA_BUILTIN_CTLZ,
ALPHA_BUILTIN_CTPOP,
ALPHA_BUILTIN_max
};
static enum insn_code const code_for_builtin[ALPHA_BUILTIN_max] = {
CODE_FOR_builtin_cmpbge,
CODE_FOR_builtin_extbl,
CODE_FOR_builtin_extwl,
CODE_FOR_builtin_extll,
CODE_FOR_builtin_extql,
CODE_FOR_builtin_extwh,
CODE_FOR_builtin_extlh,
CODE_FOR_builtin_extqh,
CODE_FOR_builtin_insbl,
CODE_FOR_builtin_inswl,
CODE_FOR_builtin_insll,
CODE_FOR_builtin_insql,
CODE_FOR_builtin_inswh,
CODE_FOR_builtin_inslh,
CODE_FOR_builtin_insqh,
CODE_FOR_builtin_mskbl,
CODE_FOR_builtin_mskwl,
CODE_FOR_builtin_mskll,
CODE_FOR_builtin_mskql,
CODE_FOR_builtin_mskwh,
CODE_FOR_builtin_msklh,
CODE_FOR_builtin_mskqh,
CODE_FOR_umuldi3_highpart,
CODE_FOR_builtin_zap,
CODE_FOR_builtin_zapnot,
CODE_FOR_builtin_amask,
CODE_FOR_builtin_implver,
CODE_FOR_builtin_rpcc,
CODE_FOR_load_tp,
CODE_FOR_set_tp,
CODE_FOR_builtin_establish_vms_condition_handler,
CODE_FOR_builtin_revert_vms_condition_handler,
/* TARGET_MAX */
CODE_FOR_builtin_minub8,
CODE_FOR_builtin_minsb8,
CODE_FOR_builtin_minuw4,
CODE_FOR_builtin_minsw4,
CODE_FOR_builtin_maxub8,
CODE_FOR_builtin_maxsb8,
CODE_FOR_builtin_maxuw4,
CODE_FOR_builtin_maxsw4,
CODE_FOR_builtin_perr,
CODE_FOR_builtin_pklb,
CODE_FOR_builtin_pkwb,
CODE_FOR_builtin_unpkbl,
CODE_FOR_builtin_unpkbw,
/* TARGET_CIX */
CODE_FOR_ctzdi2,
CODE_FOR_clzdi2,
CODE_FOR_popcountdi2
};
struct alpha_builtin_def
{
const char *name;
enum alpha_builtin code;
unsigned int target_mask;
bool is_const;
};
static struct alpha_builtin_def const zero_arg_builtins[] = {
{ "__builtin_alpha_implver", ALPHA_BUILTIN_IMPLVER, 0, true },
{ "__builtin_alpha_rpcc", ALPHA_BUILTIN_RPCC, 0, false }
};
static struct alpha_builtin_def const one_arg_builtins[] = {
{ "__builtin_alpha_amask", ALPHA_BUILTIN_AMASK, 0, true },
{ "__builtin_alpha_pklb", ALPHA_BUILTIN_PKLB, MASK_MAX, true },
{ "__builtin_alpha_pkwb", ALPHA_BUILTIN_PKWB, MASK_MAX, true },
{ "__builtin_alpha_unpkbl", ALPHA_BUILTIN_UNPKBL, MASK_MAX, true },
{ "__builtin_alpha_unpkbw", ALPHA_BUILTIN_UNPKBW, MASK_MAX, true },
{ "__builtin_alpha_cttz", ALPHA_BUILTIN_CTTZ, MASK_CIX, true },
{ "__builtin_alpha_ctlz", ALPHA_BUILTIN_CTLZ, MASK_CIX, true },
{ "__builtin_alpha_ctpop", ALPHA_BUILTIN_CTPOP, MASK_CIX, true }
};
static struct alpha_builtin_def const two_arg_builtins[] = {
{ "__builtin_alpha_cmpbge", ALPHA_BUILTIN_CMPBGE, 0, true },
{ "__builtin_alpha_extbl", ALPHA_BUILTIN_EXTBL, 0, true },
{ "__builtin_alpha_extwl", ALPHA_BUILTIN_EXTWL, 0, true },
{ "__builtin_alpha_extll", ALPHA_BUILTIN_EXTLL, 0, true },
{ "__builtin_alpha_extql", ALPHA_BUILTIN_EXTQL, 0, true },
{ "__builtin_alpha_extwh", ALPHA_BUILTIN_EXTWH, 0, true },
{ "__builtin_alpha_extlh", ALPHA_BUILTIN_EXTLH, 0, true },
{ "__builtin_alpha_extqh", ALPHA_BUILTIN_EXTQH, 0, true },
{ "__builtin_alpha_insbl", ALPHA_BUILTIN_INSBL, 0, true },
{ "__builtin_alpha_inswl", ALPHA_BUILTIN_INSWL, 0, true },
{ "__builtin_alpha_insll", ALPHA_BUILTIN_INSLL, 0, true },
{ "__builtin_alpha_insql", ALPHA_BUILTIN_INSQL, 0, true },
{ "__builtin_alpha_inswh", ALPHA_BUILTIN_INSWH, 0, true },
{ "__builtin_alpha_inslh", ALPHA_BUILTIN_INSLH, 0, true },
{ "__builtin_alpha_insqh", ALPHA_BUILTIN_INSQH, 0, true },
{ "__builtin_alpha_mskbl", ALPHA_BUILTIN_MSKBL, 0, true },
{ "__builtin_alpha_mskwl", ALPHA_BUILTIN_MSKWL, 0, true },
{ "__builtin_alpha_mskll", ALPHA_BUILTIN_MSKLL, 0, true },
{ "__builtin_alpha_mskql", ALPHA_BUILTIN_MSKQL, 0, true },
{ "__builtin_alpha_mskwh", ALPHA_BUILTIN_MSKWH, 0, true },
{ "__builtin_alpha_msklh", ALPHA_BUILTIN_MSKLH, 0, true },
{ "__builtin_alpha_mskqh", ALPHA_BUILTIN_MSKQH, 0, true },
{ "__builtin_alpha_umulh", ALPHA_BUILTIN_UMULH, 0, true },
{ "__builtin_alpha_zap", ALPHA_BUILTIN_ZAP, 0, true },
{ "__builtin_alpha_zapnot", ALPHA_BUILTIN_ZAPNOT, 0, true },
{ "__builtin_alpha_minub8", ALPHA_BUILTIN_MINUB8, MASK_MAX, true },
{ "__builtin_alpha_minsb8", ALPHA_BUILTIN_MINSB8, MASK_MAX, true },
{ "__builtin_alpha_minuw4", ALPHA_BUILTIN_MINUW4, MASK_MAX, true },
{ "__builtin_alpha_minsw4", ALPHA_BUILTIN_MINSW4, MASK_MAX, true },
{ "__builtin_alpha_maxub8", ALPHA_BUILTIN_MAXUB8, MASK_MAX, true },
{ "__builtin_alpha_maxsb8", ALPHA_BUILTIN_MAXSB8, MASK_MAX, true },
{ "__builtin_alpha_maxuw4", ALPHA_BUILTIN_MAXUW4, MASK_MAX, true },
{ "__builtin_alpha_maxsw4", ALPHA_BUILTIN_MAXSW4, MASK_MAX, true },
{ "__builtin_alpha_perr", ALPHA_BUILTIN_PERR, MASK_MAX, true }
};
static GTY(()) tree alpha_v8qi_u;
static GTY(()) tree alpha_v8qi_s;
static GTY(()) tree alpha_v4hi_u;
static GTY(()) tree alpha_v4hi_s;
static GTY(()) tree alpha_builtins[(int) ALPHA_BUILTIN_max];
/* Return the alpha builtin for CODE. */
static tree
alpha_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
{
if (code >= ALPHA_BUILTIN_max)
return error_mark_node;
return alpha_builtins[code];
}
/* Helper function of alpha_init_builtins. Add the built-in specified
by NAME, TYPE, CODE, and ECF. */
static void
alpha_builtin_function (const char *name, tree ftype,
enum alpha_builtin code, unsigned ecf)
{
tree decl = add_builtin_function (name, ftype, (int) code,
BUILT_IN_MD, NULL, NULL_TREE);
if (ecf & ECF_CONST)
TREE_READONLY (decl) = 1;
if (ecf & ECF_NOTHROW)
TREE_NOTHROW (decl) = 1;
alpha_builtins [(int) code] = decl;
}
/* Helper function of alpha_init_builtins. Add the COUNT built-in
functions pointed to by P, with function type FTYPE. */
static void
alpha_add_builtins (const struct alpha_builtin_def *p, size_t count,
tree ftype)
{
size_t i;
for (i = 0; i < count; ++i, ++p)
if ((target_flags & p->target_mask) == p->target_mask)
alpha_builtin_function (p->name, ftype, p->code,
(p->is_const ? ECF_CONST : 0) | ECF_NOTHROW);
}
static void
alpha_init_builtins (void)
{
tree dimode_integer_type_node;
tree ftype;
dimode_integer_type_node = lang_hooks.types.type_for_mode (DImode, 0);
/* Fwrite on VMS is non-standard. */
#if TARGET_ABI_OPEN_VMS
implicit_built_in_decls[(int) BUILT_IN_FWRITE] = NULL_TREE;
implicit_built_in_decls[(int) BUILT_IN_FWRITE_UNLOCKED] = NULL_TREE;
#endif
ftype = build_function_type (dimode_integer_type_node, void_list_node);
alpha_add_builtins (zero_arg_builtins, ARRAY_SIZE (zero_arg_builtins),
ftype);
ftype = build_function_type_list (dimode_integer_type_node,
dimode_integer_type_node, NULL_TREE);
alpha_add_builtins (one_arg_builtins, ARRAY_SIZE (one_arg_builtins),
ftype);
ftype = build_function_type_list (dimode_integer_type_node,
dimode_integer_type_node,
dimode_integer_type_node, NULL_TREE);
alpha_add_builtins (two_arg_builtins, ARRAY_SIZE (two_arg_builtins),
ftype);
ftype = build_function_type (ptr_type_node, void_list_node);
alpha_builtin_function ("__builtin_thread_pointer", ftype,
ALPHA_BUILTIN_THREAD_POINTER, ECF_NOTHROW);
ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
alpha_builtin_function ("__builtin_set_thread_pointer", ftype,
ALPHA_BUILTIN_SET_THREAD_POINTER, ECF_NOTHROW);
if (TARGET_ABI_OPEN_VMS)
{
ftype = build_function_type_list (ptr_type_node, ptr_type_node,
NULL_TREE);
alpha_builtin_function ("__builtin_establish_vms_condition_handler",
ftype,
ALPHA_BUILTIN_ESTABLISH_VMS_CONDITION_HANDLER,
0);
ftype = build_function_type_list (ptr_type_node, void_type_node,
NULL_TREE);
alpha_builtin_function ("__builtin_revert_vms_condition_handler", ftype,
ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER, 0);
}
alpha_v8qi_u = build_vector_type (unsigned_intQI_type_node, 8);
alpha_v8qi_s = build_vector_type (intQI_type_node, 8);
alpha_v4hi_u = build_vector_type (unsigned_intHI_type_node, 4);
alpha_v4hi_s = build_vector_type (intHI_type_node, 4);
}
/* Expand an expression EXP that calls a built-in function,
with result going to TARGET if that's convenient
(and in mode MODE if that's convenient).
SUBTARGET may be used as the target for computing one of EXP's operands.
IGNORE is nonzero if the value is to be ignored. */
static rtx
alpha_expand_builtin (tree exp, rtx target,
rtx subtarget ATTRIBUTE_UNUSED,
enum machine_mode mode ATTRIBUTE_UNUSED,
int ignore ATTRIBUTE_UNUSED)
{
#define MAX_ARGS 2
tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
tree arg;
call_expr_arg_iterator iter;
enum insn_code icode;
rtx op[MAX_ARGS], pat;
int arity;
bool nonvoid;
if (fcode >= ALPHA_BUILTIN_max)
internal_error ("bad builtin fcode");
icode = code_for_builtin[fcode];
if (icode == 0)
internal_error ("bad builtin fcode");
nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
arity = 0;
FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
{
const struct insn_operand_data *insn_op;
if (arg == error_mark_node)
return NULL_RTX;
if (arity > MAX_ARGS)
return NULL_RTX;
insn_op = &insn_data[icode].operand[arity + nonvoid];
op[arity] = expand_expr (arg, NULL_RTX, insn_op->mode, EXPAND_NORMAL);
if (!(*insn_op->predicate) (op[arity], insn_op->mode))
op[arity] = copy_to_mode_reg (insn_op->mode, op[arity]);
arity++;
}
if (nonvoid)
{
enum machine_mode tmode = insn_data[icode].operand[0].mode;
if (!target
|| GET_MODE (target) != tmode
|| !(*insn_data[icode].operand[0].predicate) (target, tmode))
target = gen_reg_rtx (tmode);
}
switch (arity)
{
case 0:
pat = GEN_FCN (icode) (target);
break;
case 1:
if (nonvoid)
pat = GEN_FCN (icode) (target, op[0]);
else
pat = GEN_FCN (icode) (op[0]);
break;
case 2:
pat = GEN_FCN (icode) (target, op[0], op[1]);
break;
default:
gcc_unreachable ();
}
if (!pat)
return NULL_RTX;
emit_insn (pat);
if (nonvoid)
return target;
else
return const0_rtx;
}
/* Several bits below assume HWI >= 64 bits. This should be enforced
by config.gcc. */
#if HOST_BITS_PER_WIDE_INT < 64
# error "HOST_WIDE_INT too small"
#endif
/* Fold the builtin for the CMPBGE instruction. This is a vector comparison
with an 8-bit output vector. OPINT contains the integer operands; bit N
of OP_CONST is set if OPINT[N] is valid. */
static tree
alpha_fold_builtin_cmpbge (unsigned HOST_WIDE_INT opint[], long op_const)
{
if (op_const == 3)
{
int i, val;
for (i = 0, val = 0; i < 8; ++i)
{
unsigned HOST_WIDE_INT c0 = (opint[0] >> (i * 8)) & 0xff;
unsigned HOST_WIDE_INT c1 = (opint[1] >> (i * 8)) & 0xff;
if (c0 >= c1)
val |= 1 << i;
}
return build_int_cst (long_integer_type_node, val);
}
else if (op_const == 2 && opint[1] == 0)
return build_int_cst (long_integer_type_node, 0xff);
return NULL;
}
/* Fold the builtin for the ZAPNOT instruction. This is essentially a
specialized form of an AND operation. Other byte manipulation instructions
are defined in terms of this instruction, so this is also used as a
subroutine for other builtins.
OP contains the tree operands; OPINT contains the extracted integer values.
Bit N of OP_CONST it set if OPINT[N] is valid. OP may be null if only
OPINT may be considered. */
static tree
alpha_fold_builtin_zapnot (tree *op, unsigned HOST_WIDE_INT opint[],
long op_const)
{
if (op_const & 2)
{
unsigned HOST_WIDE_INT mask = 0;
int i;
for (i = 0; i < 8; ++i)
if ((opint[1] >> i) & 1)
mask |= (unsigned HOST_WIDE_INT)0xff << (i * 8);
if (op_const & 1)
return build_int_cst (long_integer_type_node, opint[0] & mask);
if (op)
return fold_build2 (BIT_AND_EXPR, long_integer_type_node, op[0],
build_int_cst (long_integer_type_node, mask));
}
else if ((op_const & 1) && opint[0] == 0)
return build_int_cst (long_integer_type_node, 0);
return NULL;
}
/* Fold the builtins for the EXT family of instructions. */
static tree
alpha_fold_builtin_extxx (tree op[], unsigned HOST_WIDE_INT opint[],
long op_const, unsigned HOST_WIDE_INT bytemask,
bool is_high)
{
long zap_const = 2;
tree *zap_op = NULL;
if (op_const & 2)
{
unsigned HOST_WIDE_INT loc;
loc = opint[1] & 7;
if (BYTES_BIG_ENDIAN)
loc ^= 7;
loc *= 8;
if (loc != 0)
{
if (op_const & 1)
{
unsigned HOST_WIDE_INT temp = opint[0];
if (is_high)
temp <<= loc;
else
temp >>= loc;
opint[0] = temp;
zap_const = 3;
}
}
else
zap_op = op;
}
opint[1] = bytemask;
return alpha_fold_builtin_zapnot (zap_op, opint, zap_const);
}
/* Fold the builtins for the INS family of instructions. */
static tree
alpha_fold_builtin_insxx (tree op[], unsigned HOST_WIDE_INT opint[],
long op_const, unsigned HOST_WIDE_INT bytemask,
bool is_high)
{
if ((op_const & 1) && opint[0] == 0)
return build_int_cst (long_integer_type_node, 0);
if (op_const & 2)
{
unsigned HOST_WIDE_INT temp, loc, byteloc;
tree *zap_op = NULL;
loc = opint[1] & 7;
if (BYTES_BIG_ENDIAN)
loc ^= 7;
bytemask <<= loc;
temp = opint[0];
if (is_high)
{
byteloc = (64 - (loc * 8)) & 0x3f;
if (byteloc == 0)
zap_op = op;
else
temp >>= byteloc;
bytemask >>= 8;
}
else
{
byteloc = loc * 8;
if (byteloc == 0)
zap_op = op;
else
temp <<= byteloc;
}
opint[0] = temp;
opint[1] = bytemask;
return alpha_fold_builtin_zapnot (zap_op, opint, op_const);
}
return NULL;
}
static tree
alpha_fold_builtin_mskxx (tree op[], unsigned HOST_WIDE_INT opint[],
long op_const, unsigned HOST_WIDE_INT bytemask,
bool is_high)
{
if (op_const & 2)
{
unsigned HOST_WIDE_INT loc;
loc = opint[1] & 7;
if (BYTES_BIG_ENDIAN)
loc ^= 7;
bytemask <<= loc;
if (is_high)
bytemask >>= 8;
opint[1] = bytemask ^ 0xff;
}
return alpha_fold_builtin_zapnot (op, opint, op_const);
}
static tree
alpha_fold_builtin_umulh (unsigned HOST_WIDE_INT opint[], long op_const)
{
switch (op_const)
{
case 3:
{
unsigned HOST_WIDE_INT l;
HOST_WIDE_INT h;
mul_double (opint[0], 0, opint[1], 0, &l, &h);
#if HOST_BITS_PER_WIDE_INT > 64
# error fixme
#endif
return build_int_cst (long_integer_type_node, h);
}
case 1:
opint[1] = opint[0];
/* FALLTHRU */
case 2:
/* Note that (X*1) >> 64 == 0. */
if (opint[1] == 0 || opint[1] == 1)
return build_int_cst (long_integer_type_node, 0);
break;
}
return NULL;
}
static tree
alpha_fold_vector_minmax (enum tree_code code, tree op[], tree vtype)
{
tree op0 = fold_convert (vtype, op[0]);
tree op1 = fold_convert (vtype, op[1]);
tree val = fold_build2 (code, vtype, op0, op1);
return fold_build1 (VIEW_CONVERT_EXPR, long_integer_type_node, val);
}
static tree
alpha_fold_builtin_perr (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp = 0;
int i;
if (op_const != 3)
return NULL;
for (i = 0; i < 8; ++i)
{
unsigned HOST_WIDE_INT a = (opint[0] >> (i * 8)) & 0xff;
unsigned HOST_WIDE_INT b = (opint[1] >> (i * 8)) & 0xff;
if (a >= b)
temp += a - b;
else
temp += b - a;
}
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_pklb (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
temp = opint[0] & 0xff;
temp |= (opint[0] >> 24) & 0xff00;
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_pkwb (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
temp = opint[0] & 0xff;
temp |= (opint[0] >> 8) & 0xff00;
temp |= (opint[0] >> 16) & 0xff0000;
temp |= (opint[0] >> 24) & 0xff000000;
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_unpkbl (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
temp = opint[0] & 0xff;
temp |= (opint[0] & 0xff00) << 24;
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_unpkbw (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
temp = opint[0] & 0xff;
temp |= (opint[0] & 0x0000ff00) << 8;
temp |= (opint[0] & 0x00ff0000) << 16;
temp |= (opint[0] & 0xff000000) << 24;
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_cttz (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
if (opint[0] == 0)
temp = 64;
else
temp = exact_log2 (opint[0] & -opint[0]);
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_ctlz (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp;
if (op_const == 0)
return NULL;
if (opint[0] == 0)
temp = 64;
else
temp = 64 - floor_log2 (opint[0]) - 1;
return build_int_cst (long_integer_type_node, temp);
}
static tree
alpha_fold_builtin_ctpop (unsigned HOST_WIDE_INT opint[], long op_const)
{
unsigned HOST_WIDE_INT temp, op;
if (op_const == 0)
return NULL;
op = opint[0];
temp = 0;
while (op)
temp++, op &= op - 1;
return build_int_cst (long_integer_type_node, temp);
}
/* Fold one of our builtin functions. */
static tree
alpha_fold_builtin (tree fndecl, int n_args, tree *op,
bool ignore ATTRIBUTE_UNUSED)
{
unsigned HOST_WIDE_INT opint[MAX_ARGS];
long op_const = 0;
int i;
if (n_args >= MAX_ARGS)
return NULL;
for (i = 0; i < n_args; i++)
{
tree arg = op[i];
if (arg == error_mark_node)
return NULL;
opint[i] = 0;
if (TREE_CODE (arg) == INTEGER_CST)
{
op_const |= 1L << i;
opint[i] = int_cst_value (arg);
}
}
switch (DECL_FUNCTION_CODE (fndecl))
{
case ALPHA_BUILTIN_CMPBGE:
return alpha_fold_builtin_cmpbge (opint, op_const);
case ALPHA_BUILTIN_EXTBL:
return alpha_fold_builtin_extxx (op, opint, op_const, 0x01, false);
case ALPHA_BUILTIN_EXTWL:
return alpha_fold_builtin_extxx (op, opint, op_const, 0x03, false);
case ALPHA_BUILTIN_EXTLL:
return alpha_fold_builtin_extxx (op, opint, op_const, 0x0f, false);
case ALPHA_BUILTIN_EXTQL:
return alpha_fold_builtin_extxx (op, opint, op_const, 0xff, false);
case ALPHA_BUILTIN_EXTWH:
return alpha_fold_builtin_extxx (op, opint, op_const, 0x03, true);
case ALPHA_BUILTIN_EXTLH:
return alpha_fold_builtin_extxx (op, opint, op_const, 0x0f, true);
case ALPHA_BUILTIN_EXTQH:
return alpha_fold_builtin_extxx (op, opint, op_const, 0xff, true);
case ALPHA_BUILTIN_INSBL:
return alpha_fold_builtin_insxx (op, opint, op_const, 0x01, false);
case ALPHA_BUILTIN_INSWL:
return alpha_fold_builtin_insxx (op, opint, op_const, 0x03, false);
case ALPHA_BUILTIN_INSLL:
return alpha_fold_builtin_insxx (op, opint, op_const, 0x0f, false);
case ALPHA_BUILTIN_INSQL:
return alpha_fold_builtin_insxx (op, opint, op_const, 0xff, false);
case ALPHA_BUILTIN_INSWH:
return alpha_fold_builtin_insxx (op, opint, op_const, 0x03, true);
case ALPHA_BUILTIN_INSLH:
return alpha_fold_builtin_insxx (op, opint, op_const, 0x0f, true);
case ALPHA_BUILTIN_INSQH:
return alpha_fold_builtin_insxx (op, opint, op_const, 0xff, true);
case ALPHA_BUILTIN_MSKBL:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0x01, false);
case ALPHA_BUILTIN_MSKWL:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0x03, false);
case ALPHA_BUILTIN_MSKLL:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0x0f, false);
case ALPHA_BUILTIN_MSKQL:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0xff, false);
case ALPHA_BUILTIN_MSKWH:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0x03, true);
case ALPHA_BUILTIN_MSKLH:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0x0f, true);
case ALPHA_BUILTIN_MSKQH:
return alpha_fold_builtin_mskxx (op, opint, op_const, 0xff, true);
case ALPHA_BUILTIN_UMULH:
return alpha_fold_builtin_umulh (opint, op_const);
case ALPHA_BUILTIN_ZAP:
opint[1] ^= 0xff;
/* FALLTHRU */
case ALPHA_BUILTIN_ZAPNOT:
return alpha_fold_builtin_zapnot (op, opint, op_const);
case ALPHA_BUILTIN_MINUB8:
return alpha_fold_vector_minmax (MIN_EXPR, op, alpha_v8qi_u);
case ALPHA_BUILTIN_MINSB8:
return alpha_fold_vector_minmax (MIN_EXPR, op, alpha_v8qi_s);
case ALPHA_BUILTIN_MINUW4:
return alpha_fold_vector_minmax (MIN_EXPR, op, alpha_v4hi_u);
case ALPHA_BUILTIN_MINSW4:
return alpha_fold_vector_minmax (MIN_EXPR, op, alpha_v4hi_s);
case ALPHA_BUILTIN_MAXUB8:
return alpha_fold_vector_minmax (MAX_EXPR, op, alpha_v8qi_u);
case ALPHA_BUILTIN_MAXSB8:
return alpha_fold_vector_minmax (MAX_EXPR, op, alpha_v8qi_s);
case ALPHA_BUILTIN_MAXUW4:
return alpha_fold_vector_minmax (MAX_EXPR, op, alpha_v4hi_u);
case ALPHA_BUILTIN_MAXSW4:
return alpha_fold_vector_minmax (MAX_EXPR, op, alpha_v4hi_s);
case ALPHA_BUILTIN_PERR:
return alpha_fold_builtin_perr (opint, op_const);
case ALPHA_BUILTIN_PKLB:
return alpha_fold_builtin_pklb (opint, op_const);
case ALPHA_BUILTIN_PKWB:
return alpha_fold_builtin_pkwb (opint, op_const);
case ALPHA_BUILTIN_UNPKBL:
return alpha_fold_builtin_unpkbl (opint, op_const);
case ALPHA_BUILTIN_UNPKBW:
return alpha_fold_builtin_unpkbw (opint, op_const);
case ALPHA_BUILTIN_CTTZ:
return alpha_fold_builtin_cttz (opint, op_const);
case ALPHA_BUILTIN_CTLZ:
return alpha_fold_builtin_ctlz (opint, op_const);
case ALPHA_BUILTIN_CTPOP:
return alpha_fold_builtin_ctpop (opint, op_const);
case ALPHA_BUILTIN_AMASK:
case ALPHA_BUILTIN_IMPLVER:
case ALPHA_BUILTIN_RPCC:
case ALPHA_BUILTIN_THREAD_POINTER:
case ALPHA_BUILTIN_SET_THREAD_POINTER:
/* None of these are foldable at compile-time. */
default:
return NULL;
}
}
/* This page contains routines that are used to determine what the function
prologue and epilogue code will do and write them out. */
/* Compute the size of the save area in the stack. */
/* These variables are used for communication between the following functions.
They indicate various things about the current function being compiled
that are used to tell what kind of prologue, epilogue and procedure
descriptor to generate. */
/* Nonzero if we need a stack procedure. */
enum alpha_procedure_types {PT_NULL = 0, PT_REGISTER = 1, PT_STACK = 2};
static enum alpha_procedure_types alpha_procedure_type;
/* Register number (either FP or SP) that is used to unwind the frame. */
static int vms_unwind_regno;
/* Register number used to save FP. We need not have one for RA since
we don't modify it for register procedures. This is only defined
for register frame procedures. */
static int vms_save_fp_regno;
/* Register number used to reference objects off our PV. */
static int vms_base_regno;
/* Compute register masks for saved registers. */
static void
alpha_sa_mask (unsigned long *imaskP, unsigned long *fmaskP)
{
unsigned long imask = 0;
unsigned long fmask = 0;
unsigned int i;
/* When outputting a thunk, we don't have valid register life info,
but assemble_start_function wants to output .frame and .mask
directives. */
if (cfun->is_thunk)
{
*imaskP = 0;
*fmaskP = 0;
return;
}
if (TARGET_ABI_OPEN_VMS && alpha_procedure_type == PT_STACK)
imask |= (1UL << HARD_FRAME_POINTER_REGNUM);
/* One for every register we have to save. */
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (! fixed_regs[i] && ! call_used_regs[i]
&& df_regs_ever_live_p (i) && i != REG_RA
&& (!TARGET_ABI_UNICOSMK || i != HARD_FRAME_POINTER_REGNUM))
{
if (i < 32)
imask |= (1UL << i);
else
fmask |= (1UL << (i - 32));
}
/* We need to restore these for the handler. */
if (crtl->calls_eh_return)
{
for (i = 0; ; ++i)
{
unsigned regno = EH_RETURN_DATA_REGNO (i);
if (regno == INVALID_REGNUM)
break;
imask |= 1UL << regno;
}
}
/* If any register spilled, then spill the return address also. */
/* ??? This is required by the Digital stack unwind specification
and isn't needed if we're doing Dwarf2 unwinding. */
if (imask || fmask || alpha_ra_ever_killed ())
imask |= (1UL << REG_RA);
*imaskP = imask;
*fmaskP = fmask;
}
int
alpha_sa_size (void)
{
unsigned long mask[2];
int sa_size = 0;
int i, j;
alpha_sa_mask (&mask[0], &mask[1]);
if (TARGET_ABI_UNICOSMK)
{
if (mask[0] || mask[1])
sa_size = 14;
}
else
{
for (j = 0; j < 2; ++j)
for (i = 0; i < 32; ++i)
if ((mask[j] >> i) & 1)
sa_size++;
}
if (TARGET_ABI_UNICOSMK)
{
/* We might not need to generate a frame if we don't make any calls
(including calls to __T3E_MISMATCH if this is a vararg function),
don't have any local variables which require stack slots, don't
use alloca and have not determined that we need a frame for other
reasons. */
alpha_procedure_type
= (sa_size || get_frame_size() != 0
|| crtl->outgoing_args_size
|| cfun->stdarg || cfun->calls_alloca
|| frame_pointer_needed)
? PT_STACK : PT_REGISTER;
/* Always reserve space for saving callee-saved registers if we
need a frame as required by the calling convention. */
if (alpha_procedure_type == PT_STACK)
sa_size = 14;
}
else if (TARGET_ABI_OPEN_VMS)
{
/* Start with a stack procedure if we make any calls (REG_RA used), or
need a frame pointer, with a register procedure if we otherwise need
at least a slot, and with a null procedure in other cases. */
if ((mask[0] >> REG_RA) & 1 || frame_pointer_needed)
alpha_procedure_type = PT_STACK;
else if (get_frame_size() != 0)
alpha_procedure_type = PT_REGISTER;
else
alpha_procedure_type = PT_NULL;
/* Don't reserve space for saving FP & RA yet. Do that later after we've
made the final decision on stack procedure vs register procedure. */
if (alpha_procedure_type == PT_STACK)
sa_size -= 2;
/* Decide whether to refer to objects off our PV via FP or PV.
If we need FP for something else or if we receive a nonlocal
goto (which expects PV to contain the value), we must use PV.
Otherwise, start by assuming we can use FP. */
vms_base_regno
= (frame_pointer_needed
|| cfun->has_nonlocal_label
|| alpha_procedure_type == PT_STACK
|| crtl->outgoing_args_size)
? REG_PV : HARD_FRAME_POINTER_REGNUM;
/* If we want to copy PV into FP, we need to find some register
in which to save FP. */
vms_save_fp_regno = -1;
if (vms_base_regno == HARD_FRAME_POINTER_REGNUM)
for (i = 0; i < 32; i++)
if (! fixed_regs[i] && call_used_regs[i] && ! df_regs_ever_live_p (i))
vms_save_fp_regno = i;
/* A VMS condition handler requires a stack procedure in our
implementation. (not required by the calling standard). */
if ((vms_save_fp_regno == -1 && alpha_procedure_type == PT_REGISTER)
|| cfun->machine->uses_condition_handler)
vms_base_regno = REG_PV, alpha_procedure_type = PT_STACK;
else if (alpha_procedure_type == PT_NULL)
vms_base_regno = REG_PV;
/* Stack unwinding should be done via FP unless we use it for PV. */
vms_unwind_regno = (vms_base_regno == REG_PV
? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
/* If this is a stack procedure, allow space for saving FP, RA and
a condition handler slot if needed. */
if (alpha_procedure_type == PT_STACK)
sa_size += 2 + cfun->machine->uses_condition_handler;
}
else
{
/* Our size must be even (multiple of 16 bytes). */
if (sa_size & 1)
sa_size++;
}
return sa_size * 8;
}
/* Define the offset between two registers, one to be eliminated,
and the other its replacement, at the start of a routine. */
HOST_WIDE_INT
alpha_initial_elimination_offset (unsigned int from,
unsigned int to ATTRIBUTE_UNUSED)
{
HOST_WIDE_INT ret;
ret = alpha_sa_size ();
ret += ALPHA_ROUND (crtl->outgoing_args_size);
switch (from)
{
case FRAME_POINTER_REGNUM:
break;
case ARG_POINTER_REGNUM:
ret += (ALPHA_ROUND (get_frame_size ()
+ crtl->args.pretend_args_size)
- crtl->args.pretend_args_size);
break;
default:
gcc_unreachable ();
}
return ret;
}
#if TARGET_ABI_OPEN_VMS
/* Worker function for TARGET_CAN_ELIMINATE. */
static bool
alpha_vms_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to)
{
/* We need the alpha_procedure_type to decide. Evaluate it now. */
alpha_sa_size ();
switch (alpha_procedure_type)
{
case PT_NULL:
/* NULL procedures have no frame of their own and we only
know how to resolve from the current stack pointer. */
return to == STACK_POINTER_REGNUM;
case PT_REGISTER:
case PT_STACK:
/* We always eliminate except to the stack pointer if there is no
usable frame pointer at hand. */
return (to != STACK_POINTER_REGNUM
|| vms_unwind_regno != HARD_FRAME_POINTER_REGNUM);
}
gcc_unreachable ();
}
/* FROM is to be eliminated for TO. Return the offset so that TO+offset
designates the same location as FROM. */
HOST_WIDE_INT
alpha_vms_initial_elimination_offset (unsigned int from, unsigned int to)
{
/* The only possible attempts we ever expect are ARG or FRAME_PTR to
HARD_FRAME or STACK_PTR. We need the alpha_procedure_type to decide
on the proper computations and will need the register save area size
in most cases. */
HOST_WIDE_INT sa_size = alpha_sa_size ();
/* PT_NULL procedures have no frame of their own and we only allow
elimination to the stack pointer. This is the argument pointer and we
resolve the soft frame pointer to that as well. */
if (alpha_procedure_type == PT_NULL)
return 0;
/* For a PT_STACK procedure the frame layout looks as follows
-----> decreasing addresses
< size rounded up to 16 | likewise >
--------------#------------------------------+++--------------+++-------#
incoming args # pretended args | "frame" | regs sa | PV | outgoing args #
--------------#---------------------------------------------------------#
^ ^ ^ ^
ARG_PTR FRAME_PTR HARD_FRAME_PTR STACK_PTR
PT_REGISTER procedures are similar in that they may have a frame of their
own. They have no regs-sa/pv/outgoing-args area.
We first compute offset to HARD_FRAME_PTR, then add what we need to get
to STACK_PTR if need be. */
{
HOST_WIDE_INT offset;
HOST_WIDE_INT pv_save_size = alpha_procedure_type == PT_STACK ? 8 : 0;
switch (from)
{
case FRAME_POINTER_REGNUM:
offset = ALPHA_ROUND (sa_size + pv_save_size);
break;
case ARG_POINTER_REGNUM:
offset = (ALPHA_ROUND (sa_size + pv_save_size
+ get_frame_size ()
+ crtl->args.pretend_args_size)
- crtl->args.pretend_args_size);
break;
default:
gcc_unreachable ();
}
if (to == STACK_POINTER_REGNUM)
offset += ALPHA_ROUND (crtl->outgoing_args_size);
return offset;
}
}
#define COMMON_OBJECT "common_object"
static tree
common_object_handler (tree *node, tree name ATTRIBUTE_UNUSED,
tree args ATTRIBUTE_UNUSED, int flags ATTRIBUTE_UNUSED,
bool *no_add_attrs ATTRIBUTE_UNUSED)
{
tree decl = *node;
gcc_assert (DECL_P (decl));
DECL_COMMON (decl) = 1;
return NULL_TREE;
}
static const struct attribute_spec vms_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
{ COMMON_OBJECT, 0, 1, true, false, false, common_object_handler },
{ NULL, 0, 0, false, false, false, NULL }
};
void
vms_output_aligned_decl_common(FILE *file, tree decl, const char *name,
unsigned HOST_WIDE_INT size,
unsigned int align)
{
tree attr = DECL_ATTRIBUTES (decl);
fprintf (file, "%s", COMMON_ASM_OP);
assemble_name (file, name);
fprintf (file, "," HOST_WIDE_INT_PRINT_UNSIGNED, size);
/* ??? Unlike on OSF/1, the alignment factor is not in log units. */
fprintf (file, ",%u", align / BITS_PER_UNIT);
if (attr)
{
attr = lookup_attribute (COMMON_OBJECT, attr);
if (attr)
fprintf (file, ",%s",
IDENTIFIER_POINTER (TREE_VALUE (TREE_VALUE (attr))));
}
fputc ('\n', file);
}
#undef COMMON_OBJECT
#endif
static int
find_lo_sum_using_gp (rtx *px, void *data ATTRIBUTE_UNUSED)
{
return GET_CODE (*px) == LO_SUM && XEXP (*px, 0) == pic_offset_table_rtx;
}
int
alpha_find_lo_sum_using_gp (rtx insn)
{
return for_each_rtx (&PATTERN (insn), find_lo_sum_using_gp, NULL) > 0;
}
static int
alpha_does_function_need_gp (void)
{
rtx insn;
/* The GP being variable is an OSF abi thing. */
if (! TARGET_ABI_OSF)
return 0;
/* We need the gp to load the address of __mcount. */
if (TARGET_PROFILING_NEEDS_GP && crtl->profile)
return 1;
/* The code emitted by alpha_output_mi_thunk_osf uses the gp. */
if (cfun->is_thunk)
return 1;
/* The nonlocal receiver pattern assumes that the gp is valid for
the nested function. Reasonable because it's almost always set
correctly already. For the cases where that's wrong, make sure
the nested function loads its gp on entry. */
if (crtl->has_nonlocal_goto)
return 1;
/* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.
Even if we are a static function, we still need to do this in case
our address is taken and passed to something like qsort. */
push_topmost_sequence ();
insn = get_insns ();
pop_topmost_sequence ();
for (; insn; insn = NEXT_INSN (insn))
if (NONDEBUG_INSN_P (insn)
&& ! JUMP_TABLE_DATA_P (insn)
&& GET_CODE (PATTERN (insn)) != USE
&& GET_CODE (PATTERN (insn)) != CLOBBER
&& get_attr_usegp (insn))
return 1;
return 0;
}
/* Helper function to set RTX_FRAME_RELATED_P on instructions, including
sequences. */
static rtx
set_frame_related_p (void)
{
rtx seq = get_insns ();
rtx insn;
end_sequence ();
if (!seq)
return NULL_RTX;
if (INSN_P (seq))
{
insn = seq;
while (insn != NULL_RTX)
{
RTX_FRAME_RELATED_P (insn) = 1;
insn = NEXT_INSN (insn);
}
seq = emit_insn (seq);
}
else
{
seq = emit_insn (seq);
RTX_FRAME_RELATED_P (seq) = 1;
}
return seq;
}
#define FRP(exp) (start_sequence (), exp, set_frame_related_p ())
/* Generates a store with the proper unwind info attached. VALUE is
stored at BASE_REG+BASE_OFS. If FRAME_BIAS is nonzero, then BASE_REG
contains SP+FRAME_BIAS, and that is the unwind info that should be
generated. If FRAME_REG != VALUE, then VALUE is being stored on
behalf of FRAME_REG, and FRAME_REG should be present in the unwind. */
static void
emit_frame_store_1 (rtx value, rtx base_reg, HOST_WIDE_INT frame_bias,
HOST_WIDE_INT base_ofs, rtx frame_reg)
{
rtx addr, mem, insn;
addr = plus_constant (base_reg, base_ofs);
mem = gen_frame_mem (DImode, addr);
insn = emit_move_insn (mem, value);
RTX_FRAME_RELATED_P (insn) = 1;
if (frame_bias || value != frame_reg)
{
if (frame_bias)
{
addr = plus_constant (stack_pointer_rtx, frame_bias + base_ofs);
mem = gen_rtx_MEM (DImode, addr);
}
add_reg_note (insn, REG_FRAME_RELATED_EXPR,
gen_rtx_SET (VOIDmode, mem, frame_reg));
}
}
static void
emit_frame_store (unsigned int regno, rtx base_reg,
HOST_WIDE_INT frame_bias, HOST_WIDE_INT base_ofs)
{
rtx reg = gen_rtx_REG (DImode, regno);
emit_frame_store_1 (reg, base_reg, frame_bias, base_ofs, reg);
}
/* Compute the frame size. SIZE is the size of the "naked" frame
and SA_SIZE is the size of the register save area. */
static HOST_WIDE_INT
compute_frame_size (HOST_WIDE_INT size, HOST_WIDE_INT sa_size)
{
if (TARGET_ABI_OPEN_VMS)
return ALPHA_ROUND (sa_size
+ (alpha_procedure_type == PT_STACK ? 8 : 0)
+ size
+ crtl->args.pretend_args_size);
else if (TARGET_ABI_UNICOSMK)
/* We have to allocate space for the DSIB if we generate a frame. */
return ALPHA_ROUND (sa_size
+ (alpha_procedure_type == PT_STACK ? 48 : 0))
+ ALPHA_ROUND (size
+ crtl->outgoing_args_size);
else
return ALPHA_ROUND (crtl->outgoing_args_size)
+ sa_size
+ ALPHA_ROUND (size
+ crtl->args.pretend_args_size);
}
/* Write function prologue. */
/* On vms we have two kinds of functions:
- stack frame (PROC_STACK)
these are 'normal' functions with local vars and which are
calling other functions
- register frame (PROC_REGISTER)
keeps all data in registers, needs no stack
We must pass this to the assembler so it can generate the
proper pdsc (procedure descriptor)
This is done with the '.pdesc' command.
On not-vms, we don't really differentiate between the two, as we can
simply allocate stack without saving registers. */
void
alpha_expand_prologue (void)
{
/* Registers to save. */
unsigned long imask = 0;
unsigned long fmask = 0;
/* Stack space needed for pushing registers clobbered by us. */
HOST_WIDE_INT sa_size;
/* Complete stack size needed. */
HOST_WIDE_INT frame_size;
/* Probed stack size; it additionally includes the size of
the "reserve region" if any. */
HOST_WIDE_INT probed_size;
/* Offset from base reg to register save area. */
HOST_WIDE_INT reg_offset;
rtx sa_reg;
int i;
sa_size = alpha_sa_size ();
frame_size = compute_frame_size (get_frame_size (), sa_size);
if (flag_stack_usage)
current_function_static_stack_size = frame_size;
if (TARGET_ABI_OPEN_VMS)
reg_offset = 8 + 8 * cfun->machine->uses_condition_handler;
else
reg_offset = ALPHA_ROUND (crtl->outgoing_args_size);
alpha_sa_mask (&imask, &fmask);
/* Emit an insn to reload GP, if needed. */
if (TARGET_ABI_OSF)
{
alpha_function_needs_gp = alpha_does_function_need_gp ();
if (alpha_function_needs_gp)
emit_insn (gen_prologue_ldgp ());
}
/* TARGET_PROFILING_NEEDS_GP actually implies that we need to insert
the call to mcount ourselves, rather than having the linker do it
magically in response to -pg. Since _mcount has special linkage,
don't represent the call as a call. */
if (TARGET_PROFILING_NEEDS_GP && crtl->profile)
emit_insn (gen_prologue_mcount ());
if (TARGET_ABI_UNICOSMK)
unicosmk_gen_dsib (&imask);
/* Adjust the stack by the frame size. If the frame size is > 4096
bytes, we need to be sure we probe somewhere in the first and last
4096 bytes (we can probably get away without the latter test) and
every 8192 bytes in between. If the frame size is > 32768, we
do this in a loop. Otherwise, we generate the explicit probe
instructions.
Note that we are only allowed to adjust sp once in the prologue. */
probed_size = frame_size;
if (flag_stack_check)
probed_size += STACK_CHECK_PROTECT;
if (probed_size <= 32768)
{
if (probed_size > 4096)
{
int probed;
for (probed = 4096; probed < probed_size; probed += 8192)
emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
? -probed + 64
: -probed)));
/* We only have to do this probe if we aren't saving registers or
if we are probing beyond the frame because of -fstack-check. */
if ((sa_size == 0 && probed_size > probed - 4096)
|| flag_stack_check)
emit_insn (gen_probe_stack (GEN_INT (-probed_size)));
}
if (frame_size != 0)
FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
GEN_INT (TARGET_ABI_UNICOSMK
? -frame_size + 64
: -frame_size))));
}
else
{
/* Here we generate code to set R22 to SP + 4096 and set R23 to the
number of 8192 byte blocks to probe. We then probe each block
in the loop and then set SP to the proper location. If the
amount remaining is > 4096, we have to do one more probe if we
are not saving any registers or if we are probing beyond the
frame because of -fstack-check. */
HOST_WIDE_INT blocks = (probed_size + 4096) / 8192;
HOST_WIDE_INT leftover = probed_size + 4096 - blocks * 8192;
rtx ptr = gen_rtx_REG (DImode, 22);
rtx count = gen_rtx_REG (DImode, 23);
rtx seq;
emit_move_insn (count, GEN_INT (blocks));
emit_insn (gen_adddi3 (ptr, stack_pointer_rtx,
GEN_INT (TARGET_ABI_UNICOSMK ? 4096 - 64 : 4096)));
/* Because of the difficulty in emitting a new basic block this
late in the compilation, generate the loop as a single insn. */
emit_insn (gen_prologue_stack_probe_loop (count, ptr));
if ((leftover > 4096 && sa_size == 0) || flag_stack_check)
{
rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
MEM_VOLATILE_P (last) = 1;
emit_move_insn (last, const0_rtx);
}
if (TARGET_ABI_WINDOWS_NT || flag_stack_check)
{
/* For NT stack unwind (done by 'reverse execution'), it's
not OK to take the result of a loop, even though the value
is already in ptr, so we reload it via a single operation
and subtract it to sp.
Same if -fstack-check is specified, because the probed stack
size is not equal to the frame size.
Yes, that's correct -- we have to reload the whole constant
into a temporary via ldah+lda then subtract from sp. */
HOST_WIDE_INT lo, hi;
lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
hi = frame_size - lo;
emit_move_insn (ptr, GEN_INT (hi));
emit_insn (gen_adddi3 (ptr, ptr, GEN_INT (lo)));
seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
ptr));
}
else
{
seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
GEN_INT (-leftover)));
}
/* This alternative is special, because the DWARF code cannot
possibly intuit through the loop above. So we invent this
note it looks at instead. */
RTX_FRAME_RELATED_P (seq) = 1;
add_reg_note (seq, REG_FRAME_RELATED_EXPR,
gen_rtx_SET (VOIDmode, stack_pointer_rtx,
gen_rtx_PLUS (Pmode, stack_pointer_rtx,
GEN_INT (TARGET_ABI_UNICOSMK
? -frame_size + 64
: -frame_size))));
}
if (!TARGET_ABI_UNICOSMK)
{
HOST_WIDE_INT sa_bias = 0;
/* Cope with very large offsets to the register save area. */
sa_reg = stack_pointer_rtx;
if (reg_offset + sa_size > 0x8000)
{
int low = ((reg_offset & 0xffff) ^ 0x8000) - 0x8000;
rtx sa_bias_rtx;
if (low + sa_size <= 0x8000)
sa_bias = reg_offset - low, reg_offset = low;
else
sa_bias = reg_offset, reg_offset = 0;
sa_reg = gen_rtx_REG (DImode, 24);
sa_bias_rtx = GEN_INT (sa_bias);
if (add_operand (sa_bias_rtx, DImode))
emit_insn (gen_adddi3 (sa_reg, stack_pointer_rtx, sa_bias_rtx));
else
{
emit_move_insn (sa_reg, sa_bias_rtx);
emit_insn (gen_adddi3 (sa_reg, stack_pointer_rtx, sa_reg));
}
}
/* Save regs in stack order. Beginning with VMS PV. */
if (TARGET_ABI_OPEN_VMS && alpha_procedure_type == PT_STACK)
emit_frame_store (REG_PV, stack_pointer_rtx, 0, 0);
/* Save register RA next. */
if (imask & (1UL << REG_RA))
{
emit_frame_store (REG_RA, sa_reg, sa_bias, reg_offset);
imask &= ~(1UL << REG_RA);
reg_offset += 8;
}
/* Now save any other registers required to be saved. */
for (i = 0; i < 31; i++)
if (imask & (1UL << i))
{
emit_frame_store (i, sa_reg, sa_bias, reg_offset);
reg_offset += 8;
}
for (i = 0; i < 31; i++)
if (fmask & (1UL << i))
{
emit_frame_store (i+32, sa_reg, sa_bias, reg_offset);
reg_offset += 8;
}
}
else if (TARGET_ABI_UNICOSMK && alpha_procedure_type == PT_STACK)
{
/* The standard frame on the T3E includes space for saving registers.
We just have to use it. We don't have to save the return address and
the old frame pointer here - they are saved in the DSIB. */
reg_offset = -56;
for (i = 9; i < 15; i++)
if (imask & (1UL << i))
{
emit_frame_store (i, hard_frame_pointer_rtx, 0, reg_offset);
reg_offset -= 8;
}
for (i = 2; i < 10; i++)
if (fmask & (1UL << i))
{
emit_frame_store (i+32, hard_frame_pointer_rtx, 0, reg_offset);
reg_offset -= 8;
}
}
if (TARGET_ABI_OPEN_VMS)
{
/* Register frame procedures save the fp. */
if (alpha_procedure_type == PT_REGISTER)
{
rtx insn = emit_move_insn (gen_rtx_REG (DImode, vms_save_fp_regno),
hard_frame_pointer_rtx);
add_reg_note (insn, REG_CFA_REGISTER, NULL);
RTX_FRAME_RELATED_P (insn) = 1;
}
if (alpha_procedure_type != PT_NULL && vms_base_regno != REG_PV)
emit_insn (gen_force_movdi (gen_rtx_REG (DImode, vms_base_regno),
gen_rtx_REG (DImode, REG_PV)));
if (alpha_procedure_type != PT_NULL
&& vms_unwind_regno == HARD_FRAME_POINTER_REGNUM)
FRP (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
/* If we have to allocate space for outgoing args, do it now. */
if (crtl->outgoing_args_size != 0)
{
rtx seq
= emit_move_insn (stack_pointer_rtx,
plus_constant
(hard_frame_pointer_rtx,
- (ALPHA_ROUND
(crtl->outgoing_args_size))));
/* Only set FRAME_RELATED_P on the stack adjustment we just emitted
if ! frame_pointer_needed. Setting the bit will change the CFA
computation rule to use sp again, which would be wrong if we had
frame_pointer_needed, as this means sp might move unpredictably
later on.
Also, note that
frame_pointer_needed
=> vms_unwind_regno == HARD_FRAME_POINTER_REGNUM
and
crtl->outgoing_args_size != 0
=> alpha_procedure_type != PT_NULL,
so when we are not setting the bit here, we are guaranteed to
have emitted an FRP frame pointer update just before. */
RTX_FRAME_RELATED_P (seq) = ! frame_pointer_needed;
}
}
else if (!TARGET_ABI_UNICOSMK)
{
/* If we need a frame pointer, set it from the stack pointer. */
if (frame_pointer_needed)
{
if (TARGET_CAN_FAULT_IN_PROLOGUE)
FRP (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
else
/* This must always be the last instruction in the
prologue, thus we emit a special move + clobber. */
FRP (emit_insn (gen_init_fp (hard_frame_pointer_rtx,
stack_pointer_rtx, sa_reg)));
}
}
/* The ABIs for VMS and OSF/1 say that while we can schedule insns into
the prologue, for exception handling reasons, we cannot do this for
any insn that might fault. We could prevent this for mems with a
(clobber:BLK (scratch)), but this doesn't work for fp insns. So we
have to prevent all such scheduling with a blockage.
Linux, on the other hand, never bothered to implement OSF/1's
exception handling, and so doesn't care about such things. Anyone
planning to use dwarf2 frame-unwind info can also omit the blockage. */
if (! TARGET_CAN_FAULT_IN_PROLOGUE)
emit_insn (gen_blockage ());
}
/* Count the number of .file directives, so that .loc is up to date. */
int num_source_filenames = 0;
/* Output the textual info surrounding the prologue. */
void
alpha_start_function (FILE *file, const char *fnname,
tree decl ATTRIBUTE_UNUSED)
{
unsigned long imask = 0;
unsigned long fmask = 0;
/* Stack space needed for pushing registers clobbered by us. */
HOST_WIDE_INT sa_size;
/* Complete stack size needed. */
unsigned HOST_WIDE_INT frame_size;
/* The maximum debuggable frame size (512 Kbytes using Tru64 as). */
unsigned HOST_WIDE_INT max_frame_size = TARGET_ABI_OSF && !TARGET_GAS
? 524288
: 1UL << 31;
/* Offset from base reg to register save area. */
HOST_WIDE_INT reg_offset;
char *entry_label = (char *) alloca (strlen (fnname) + 6);
char *tramp_label = (char *) alloca (strlen (fnname) + 6);
int i;
/* Don't emit an extern directive for functions defined in the same file. */
if (TARGET_ABI_UNICOSMK)
{
tree name_tree;
name_tree = get_identifier (fnname);
TREE_ASM_WRITTEN (name_tree) = 1;
}
#if TARGET_ABI_OPEN_VMS
if (vms_debug_main
&& strncmp (vms_debug_main, fnname, strlen (vms_debug_main)) == 0)
{
targetm.asm_out.globalize_label (asm_out_file, VMS_DEBUG_MAIN_POINTER);
ASM_OUTPUT_DEF (asm_out_file, VMS_DEBUG_MAIN_POINTER, fnname);
switch_to_section (text_section);
vms_debug_main = NULL;
}
#endif
alpha_fnname = fnname;
sa_size = alpha_sa_size ();
frame_size = compute_frame_size (get_frame_size (), sa_size);
if (TARGET_ABI_OPEN_VMS)
reg_offset = 8 + 8 * cfun->machine->uses_condition_handler;
else
reg_offset = ALPHA_ROUND (crtl->outgoing_args_size);
alpha_sa_mask (&imask, &fmask);
/* Ecoff can handle multiple .file directives, so put out file and lineno.
We have to do that before the .ent directive as we cannot switch
files within procedures with native ecoff because line numbers are
linked to procedure descriptors.
Outputting the lineno helps debugging of one line functions as they
would otherwise get no line number at all. Please note that we would
like to put out last_linenum from final.c, but it is not accessible. */
if (write_symbols == SDB_DEBUG)
{
#ifdef ASM_OUTPUT_SOURCE_FILENAME
ASM_OUTPUT_SOURCE_FILENAME (file,
DECL_SOURCE_FILE (current_function_decl));
#endif
#ifdef SDB_OUTPUT_SOURCE_LINE
if (debug_info_level != DINFO_LEVEL_TERSE)
SDB_OUTPUT_SOURCE_LINE (file,
DECL_SOURCE_LINE (current_function_decl));
#endif
}
/* Issue function start and label. */
if (TARGET_ABI_OPEN_VMS
|| (!TARGET_ABI_UNICOSMK && !flag_inhibit_size_directive))
{
fputs ("\t.ent ", file);
assemble_name (file, fnname);
putc ('\n', file);
/* If the function needs GP, we'll write the "..ng" label there.
Otherwise, do it here. */
if (TARGET_ABI_OSF
&& ! alpha_function_needs_gp
&& ! cfun->is_thunk)
{
putc ('$', file);
assemble_name (file, fnname);
fputs ("..ng:\n", file);
}
}
/* Nested functions on VMS that are potentially called via trampoline
get a special transfer entry point that loads the called functions
procedure descriptor and static chain. */
if (TARGET_ABI_OPEN_VMS
&& !TREE_PUBLIC (decl)
&& DECL_CONTEXT (decl)
&& !TYPE_P (DECL_CONTEXT (decl)))
{
strcpy (tramp_label, fnname);
strcat (tramp_label, "..tr");
ASM_OUTPUT_LABEL (file, tramp_label);
fprintf (file, "\tldq $1,24($27)\n");
fprintf (file, "\tldq $27,16($27)\n");
}
strcpy (entry_label, fnname);
if (TARGET_ABI_OPEN_VMS)
strcat (entry_label, "..en");
/* For public functions, the label must be globalized by appending an
additional colon. */
if (TARGET_ABI_UNICOSMK && TREE_PUBLIC (decl))
strcat (entry_label, ":");
ASM_OUTPUT_LABEL (file, entry_label);
inside_function = TRUE;
if (TARGET_ABI_OPEN_VMS)
fprintf (file, "\t.base $%d\n", vms_base_regno);
if (!TARGET_ABI_OPEN_VMS && !TARGET_ABI_UNICOSMK && TARGET_IEEE_CONFORMANT
&& !flag_inhibit_size_directive)
{
/* Set flags in procedure descriptor to request IEEE-conformant
math-library routines. The value we set it to is PDSC_EXC_IEEE
(/usr/include/pdsc.h). */
fputs ("\t.eflag 48\n", file);
}
/* Set up offsets to alpha virtual arg/local debugging pointer. */
alpha_auto_offset = -frame_size + crtl->args.pretend_args_size;
alpha_arg_offset = -frame_size + 48;
/* Describe our frame. If the frame size is larger than an integer,
print it as zero to avoid an assembler error. We won't be
properly describing such a frame, but that's the best we can do. */
if (TARGET_ABI_UNICOSMK)
;
else if (TARGET_ABI_OPEN_VMS)
fprintf (file, "\t.frame $%d," HOST_WIDE_INT_PRINT_DEC ",$26,"
HOST_WIDE_INT_PRINT_DEC "\n",
vms_unwind_regno,
frame_size >= (1UL << 31) ? 0 : frame_size,
reg_offset);
else if (!flag_inhibit_size_directive)
fprintf (file, "\t.frame $%d," HOST_WIDE_INT_PRINT_DEC ",$26,%d\n",
(frame_pointer_needed
? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM),
frame_size >= max_frame_size ? 0 : frame_size,
crtl->args.pretend_args_size);
/* Describe which registers were spilled. */
if (TARGET_ABI_UNICOSMK)
;
else if (TARGET_ABI_OPEN_VMS)
{
if (imask)
/* ??? Does VMS care if mask contains ra? The old code didn't
set it, so I don't here. */
fprintf (file, "\t.mask 0x%lx,0\n", imask & ~(1UL << REG_RA));
if (fmask)
fprintf (file, "\t.fmask 0x%lx,0\n", fmask);
if (alpha_procedure_type == PT_REGISTER)
fprintf (file, "\t.fp_save $%d\n", vms_save_fp_regno);
}
else if (!flag_inhibit_size_directive)
{
if (imask)
{
fprintf (file, "\t.mask 0x%lx," HOST_WIDE_INT_PRINT_DEC "\n", imask,
frame_size >= max_frame_size ? 0 : reg_offset - frame_size);
for (i = 0; i < 32; ++i)
if (imask & (1UL << i))
reg_offset += 8;
}
if (fmask)
fprintf (file, "\t.fmask 0x%lx," HOST_WIDE_INT_PRINT_DEC "\n", fmask,
frame_size >= max_frame_size ? 0 : reg_offset - frame_size);
}
#if TARGET_ABI_OPEN_VMS
/* If a user condition handler has been installed at some point, emit
the procedure descriptor bits to point the Condition Handling Facility
at the indirection wrapper, and state the fp offset at which the user
handler may be found. */
if (cfun->machine->uses_condition_handler)
{
fprintf (file, "\t.handler __gcc_shell_handler\n");
fprintf (file, "\t.handler_data %d\n", VMS_COND_HANDLER_FP_OFFSET);
}
/* Ifdef'ed cause link_section are only available then. */
switch_to_section (readonly_data_section);
fprintf (file, "\t.align 3\n");
assemble_name (file, fnname); fputs ("..na:\n", file);
fputs ("\t.ascii \"", file);
assemble_name (file, fnname);
fputs ("\\0\"\n", file);
alpha_need_linkage (fnname, 1);
switch_to_section (text_section);
#endif
}
/* Emit the .prologue note at the scheduled end of the prologue. */
static void
alpha_output_function_end_prologue (FILE *file)
{
if (TARGET_ABI_UNICOSMK)
;
else if (TARGET_ABI_OPEN_VMS)
fputs ("\t.prologue\n", file);
else if (TARGET_ABI_WINDOWS_NT)
fputs ("\t.prologue 0\n", file);
else if (!flag_inhibit_size_directive)
fprintf (file, "\t.prologue %d\n",
alpha_function_needs_gp || cfun->is_thunk);
}
/* Write function epilogue. */
void
alpha_expand_epilogue (void)
{
/* Registers to save. */
unsigned long imask = 0;
unsigned long fmask = 0;
/* Stack space needed for pushing registers clobbered by us. */
HOST_WIDE_INT sa_size;
/* Complete stack size needed. */
HOST_WIDE_INT frame_size;
/* Offset from base reg to register save area. */
HOST_WIDE_INT reg_offset;
int fp_is_frame_pointer, fp_offset;
rtx sa_reg, sa_reg_exp = NULL;
rtx sp_adj1, sp_adj2, mem, reg, insn;
rtx eh_ofs;
rtx cfa_restores = NULL_RTX;
int i;
sa_size = alpha_sa_size ();
frame_size = compute_frame_size (get_frame_size (), sa_size);
if (TARGET_ABI_OPEN_VMS)
{
if (alpha_procedure_type == PT_STACK)
reg_offset = 8 + 8 * cfun->machine->uses_condition_handler;
else
reg_offset = 0;
}
else
reg_offset = ALPHA_ROUND (crtl->outgoing_args_size);
alpha_sa_mask (&imask, &fmask);
fp_is_frame_pointer
= ((TARGET_ABI_OPEN_VMS && alpha_procedure_type == PT_STACK)
|| (!TARGET_ABI_OPEN_VMS && frame_pointer_needed));
fp_offset = 0;
sa_reg = stack_pointer_rtx;
if (crtl->calls_eh_return)
eh_ofs = EH_RETURN_STACKADJ_RTX;
else
eh_ofs = NULL_RTX;
if (!TARGET_ABI_UNICOSMK && sa_size)
{
/* If we have a frame pointer, restore SP from it. */
if ((TARGET_ABI_OPEN_VMS
&& vms_unwind_regno == HARD_FRAME_POINTER_REGNUM)
|| (!TARGET_ABI_OPEN_VMS && frame_pointer_needed))
emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx);
/* Cope with very large offsets to the register save area. */
if (reg_offset + sa_size > 0x8000)
{
int low = ((reg_offset & 0xffff) ^ 0x8000) - 0x8000;
HOST_WIDE_INT bias;
if (low + sa_size <= 0x8000)
bias = reg_offset - low, reg_offset = low;
else
bias = reg_offset, reg_offset = 0;
sa_reg = gen_rtx_REG (DImode, 22);
sa_reg_exp = plus_constant (stack_pointer_rtx, bias);
emit_move_insn (sa_reg, sa_reg_exp);
}
/* Restore registers in order, excepting a true frame pointer. */
mem = gen_frame_mem (DImode, plus_constant (sa_reg, reg_offset));
reg = gen_rtx_REG (DImode, REG_RA);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
reg_offset += 8;
imask &= ~(1UL << REG_RA);
for (i = 0; i < 31; ++i)
if (imask & (1UL << i))
{
if (i == HARD_FRAME_POINTER_REGNUM && fp_is_frame_pointer)
fp_offset = reg_offset;
else
{
mem = gen_frame_mem (DImode,
plus_constant (sa_reg, reg_offset));
reg = gen_rtx_REG (DImode, i);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg,
cfa_restores);
}
reg_offset += 8;
}
for (i = 0; i < 31; ++i)
if (fmask & (1UL << i))
{
mem = gen_frame_mem (DFmode, plus_constant (sa_reg, reg_offset));
reg = gen_rtx_REG (DFmode, i+32);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
reg_offset += 8;
}
}
else if (TARGET_ABI_UNICOSMK && alpha_procedure_type == PT_STACK)
{
/* Restore callee-saved general-purpose registers. */
reg_offset = -56;
for (i = 9; i < 15; i++)
if (imask & (1UL << i))
{
mem = gen_frame_mem (DImode,
plus_constant (hard_frame_pointer_rtx,
reg_offset));
reg = gen_rtx_REG (DImode, i);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
reg_offset -= 8;
}
for (i = 2; i < 10; i++)
if (fmask & (1UL << i))
{
mem = gen_frame_mem (DFmode,
plus_constant (hard_frame_pointer_rtx,
reg_offset));
reg = gen_rtx_REG (DFmode, i+32);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
reg_offset -= 8;
}
/* Restore the return address from the DSIB. */
mem = gen_frame_mem (DImode, plus_constant (hard_frame_pointer_rtx, -8));
reg = gen_rtx_REG (DImode, REG_RA);
emit_move_insn (reg, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
}
if (frame_size || eh_ofs)
{
sp_adj1 = stack_pointer_rtx;
if (eh_ofs)
{
sp_adj1 = gen_rtx_REG (DImode, 23);
emit_move_insn (sp_adj1,
gen_rtx_PLUS (Pmode, stack_pointer_rtx, eh_ofs));
}
/* If the stack size is large, begin computation into a temporary
register so as not to interfere with a potential fp restore,
which must be consecutive with an SP restore. */
if (frame_size < 32768
&& ! (TARGET_ABI_UNICOSMK && cfun->calls_alloca))
sp_adj2 = GEN_INT (frame_size);
else if (TARGET_ABI_UNICOSMK)
{
sp_adj1 = gen_rtx_REG (DImode, 23);
emit_move_insn (sp_adj1, hard_frame_pointer_rtx);
sp_adj2 = const0_rtx;
}
else if (frame_size < 0x40007fffL)
{
int low = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
sp_adj2 = plus_constant (sp_adj1, frame_size - low);
if (sa_reg_exp && rtx_equal_p (sa_reg_exp, sp_adj2))
sp_adj1 = sa_reg;
else
{
sp_adj1 = gen_rtx_REG (DImode, 23);
emit_move_insn (sp_adj1, sp_adj2);
}
sp_adj2 = GEN_INT (low);
}
else
{
rtx tmp = gen_rtx_REG (DImode, 23);
sp_adj2 = alpha_emit_set_const (tmp, DImode, frame_size, 3, false);
if (!sp_adj2)
{
/* We can't drop new things to memory this late, afaik,
so build it up by pieces. */
sp_adj2 = alpha_emit_set_long_const (tmp, frame_size,
-(frame_size < 0));
gcc_assert (sp_adj2);
}
}
/* From now on, things must be in order. So emit blockages. */
/* Restore the frame pointer. */
if (TARGET_ABI_UNICOSMK)
{
emit_insn (gen_blockage ());
mem = gen_frame_mem (DImode,
plus_constant (hard_frame_pointer_rtx, -16));
emit_move_insn (hard_frame_pointer_rtx, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE,
hard_frame_pointer_rtx, cfa_restores);
}
else if (fp_is_frame_pointer)
{
emit_insn (gen_blockage ());
mem = gen_frame_mem (DImode, plus_constant (sa_reg, fp_offset));
emit_move_insn (hard_frame_pointer_rtx, mem);
cfa_restores = alloc_reg_note (REG_CFA_RESTORE,
hard_frame_pointer_rtx, cfa_restores);
}
else if (TARGET_ABI_OPEN_VMS)
{
emit_insn (gen_blockage ());
emit_move_insn (hard_frame_pointer_rtx,
gen_rtx_REG (DImode, vms_save_fp_regno));
cfa_restores = alloc_reg_note (REG_CFA_RESTORE,
hard_frame_pointer_rtx, cfa_restores);
}
/* Restore the stack pointer. */
emit_insn (gen_blockage ());
if (sp_adj2 == const0_rtx)
insn = emit_move_insn (stack_pointer_rtx, sp_adj1);
else
insn = emit_move_insn (stack_pointer_rtx,
gen_rtx_PLUS (DImode, sp_adj1, sp_adj2));
REG_NOTES (insn) = cfa_restores;
add_reg_note (insn, REG_CFA_DEF_CFA, stack_pointer_rtx);
RTX_FRAME_RELATED_P (insn) = 1;
}
else
{
gcc_assert (cfa_restores == NULL);
if (TARGET_ABI_OPEN_VMS && alpha_procedure_type == PT_REGISTER)
{
emit_insn (gen_blockage ());
insn = emit_move_insn (hard_frame_pointer_rtx,
gen_rtx_REG (DImode, vms_save_fp_regno));
add_reg_note (insn, REG_CFA_RESTORE, hard_frame_pointer_rtx);
RTX_FRAME_RELATED_P (insn) = 1;
}
else if (TARGET_ABI_UNICOSMK && alpha_procedure_type != PT_STACK)
{
/* Decrement the frame pointer if the function does not have a
frame. */
emit_insn (gen_blockage ());
emit_insn (gen_adddi3 (hard_frame_pointer_rtx,
hard_frame_pointer_rtx, constm1_rtx));
}
}
}
/* Output the rest of the textual info surrounding the epilogue. */
void
alpha_end_function (FILE *file, const char *fnname, tree decl ATTRIBUTE_UNUSED)
{
rtx insn;
/* We output a nop after noreturn calls at the very end of the function to
ensure that the return address always remains in the caller's code range,
as not doing so might confuse unwinding engines. */
insn = get_last_insn ();
if (!INSN_P (insn))
insn = prev_active_insn (insn);
if (insn && CALL_P (insn))
output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL);
#if TARGET_ABI_OPEN_VMS
alpha_write_linkage (file, fnname, decl);
#endif
/* End the function. */
if (!TARGET_ABI_UNICOSMK && !flag_inhibit_size_directive)
{
fputs ("\t.end ", file);
assemble_name (file, fnname);
putc ('\n', file);
}
inside_function = FALSE;
/* Output jump tables and the static subroutine information block. */
if (TARGET_ABI_UNICOSMK)
{
unicosmk_output_ssib (file, fnname);
unicosmk_output_deferred_case_vectors (file);
}
}
#if TARGET_ABI_OPEN_VMS
void avms_asm_output_external (FILE *file, tree decl ATTRIBUTE_UNUSED, const char *name)
{
#ifdef DO_CRTL_NAMES
DO_CRTL_NAMES;
#endif
}
#endif
#if TARGET_ABI_OSF
/* Emit a tail call to FUNCTION after adjusting THIS by DELTA.
In order to avoid the hordes of differences between generated code
with and without TARGET_EXPLICIT_RELOCS, and to avoid duplicating
lots of code loading up large constants, generate rtl and emit it
instead of going straight to text.
Not sure why this idea hasn't been explored before... */
static void
alpha_output_mi_thunk_osf (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset,
tree function)
{
HOST_WIDE_INT hi, lo;
rtx this_rtx, insn, funexp;
/* We always require a valid GP. */
emit_insn (gen_prologue_ldgp ());
emit_note (NOTE_INSN_PROLOGUE_END);
/* Find the "this" pointer. If the function returns a structure,
the structure return pointer is in $16. */
if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function))
this_rtx = gen_rtx_REG (Pmode, 17);
else
this_rtx = gen_rtx_REG (Pmode, 16);
/* Add DELTA. When possible we use ldah+lda. Otherwise load the
entire constant for the add. */
lo = ((delta & 0xffff) ^ 0x8000) - 0x8000;
hi = (((delta - lo) & 0xffffffff) ^ 0x80000000) - 0x80000000;
if (hi + lo == delta)
{
if (hi)
emit_insn (gen_adddi3 (this_rtx, this_rtx, GEN_INT (hi)));
if (lo)
emit_insn (gen_adddi3 (this_rtx, this_rtx, GEN_INT (lo)));
}
else
{
rtx tmp = alpha_emit_set_long_const (gen_rtx_REG (Pmode, 0),
delta, -(delta < 0));
emit_insn (gen_adddi3 (this_rtx, this_rtx, tmp));
}
/* Add a delta stored in the vtable at VCALL_OFFSET. */
if (vcall_offset)
{
rtx tmp, tmp2;
tmp = gen_rtx_REG (Pmode, 0);
emit_move_insn (tmp, gen_rtx_MEM (Pmode, this_rtx));
lo = ((vcall_offset & 0xffff) ^ 0x8000) - 0x8000;
hi = (((vcall_offset - lo) & 0xffffffff) ^ 0x80000000) - 0x80000000;
if (hi + lo == vcall_offset)
{
if (hi)
emit_insn (gen_adddi3 (tmp, tmp, GEN_INT (hi)));
}
else
{
tmp2 = alpha_emit_set_long_const (gen_rtx_REG (Pmode, 1),
vcall_offset, -(vcall_offset < 0));
emit_insn (gen_adddi3 (tmp, tmp, tmp2));
lo = 0;
}
if (lo)
tmp2 = gen_rtx_PLUS (Pmode, tmp, GEN_INT (lo));
else
tmp2 = tmp;
emit_move_insn (tmp, gen_rtx_MEM (Pmode, tmp2));
emit_insn (gen_adddi3 (this_rtx, this_rtx, tmp));
}
/* Generate a tail call to the target function. */
if (! TREE_USED (function))
{
assemble_external (function);
TREE_USED (function) = 1;
}
funexp = XEXP (DECL_RTL (function), 0);
funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
insn = emit_call_insn (gen_sibcall (funexp, const0_rtx));
SIBLING_CALL_P (insn) = 1;
/* Run just enough of rest_of_compilation to get the insns emitted.
There's not really enough bulk here to make other passes such as
instruction scheduling worth while. Note that use_thunk calls
assemble_start_function and assemble_end_function. */
insn = get_insns ();
insn_locators_alloc ();
shorten_branches (insn);
final_start_function (insn, file, 1);
final (insn, file, 1);
final_end_function ();
}
#endif /* TARGET_ABI_OSF */
/* Debugging support. */
#include "gstab.h"
/* Count the number of sdb related labels are generated (to find block
start and end boundaries). */
int sdb_label_count = 0;
/* Name of the file containing the current function. */
static const char *current_function_file = "";
/* Offsets to alpha virtual arg/local debugging pointers. */
long alpha_arg_offset;
long alpha_auto_offset;
/* Emit a new filename to a stream. */
void
alpha_output_filename (FILE *stream, const char *name)
{
static int first_time = TRUE;
if (first_time)
{
first_time = FALSE;
++num_source_filenames;
current_function_file = name;
fprintf (stream, "\t.file\t%d ", num_source_filenames);
output_quoted_string (stream, name);
fprintf (stream, "\n");
if (!TARGET_GAS && write_symbols == DBX_DEBUG)
fprintf (stream, "\t#@stabs\n");
}
else if (write_symbols == DBX_DEBUG)
/* dbxout.c will emit an appropriate .stabs directive. */
return;
else if (name != current_function_file
&& strcmp (name, current_function_file) != 0)
{
if (inside_function && ! TARGET_GAS)
fprintf (stream, "\t#.file\t%d ", num_source_filenames);
else
{
++num_source_filenames;
current_function_file = name;
fprintf (stream, "\t.file\t%d ", num_source_filenames);
}
output_quoted_string (stream, name);
fprintf (stream, "\n");
}
}
/* Structure to show the current status of registers and memory. */
struct shadow_summary
{
struct {
unsigned int i : 31; /* Mask of int regs */
unsigned int fp : 31; /* Mask of fp regs */
unsigned int mem : 1; /* mem == imem | fpmem */
} used, defd;
};
/* Summary the effects of expression X on the machine. Update SUM, a pointer
to the summary structure. SET is nonzero if the insn is setting the
object, otherwise zero. */
static void
summarize_insn (rtx x, struct shadow_summary *sum, int set)
{
const char *format_ptr;
int i, j;
if (x == 0)
return;
switch (GET_CODE (x))
{
/* ??? Note that this case would be incorrect if the Alpha had a
ZERO_EXTRACT in SET_DEST. */
case SET:
summarize_insn (SET_SRC (x), sum, 0);
summarize_insn (SET_DEST (x), sum, 1);
break;
case CLOBBER:
summarize_insn (XEXP (x, 0), sum, 1);
break;
case USE:
summarize_insn (XEXP (x, 0), sum, 0);
break;
case ASM_OPERANDS:
for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--)
summarize_insn (ASM_OPERANDS_INPUT (x, i), sum, 0);
break;
case PARALLEL:
for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
summarize_insn (XVECEXP (x, 0, i), sum, 0);
break;
case SUBREG:
summarize_insn (SUBREG_REG (x), sum, 0);
break;
case REG:
{
int regno = REGNO (x);
unsigned long mask = ((unsigned long) 1) << (regno % 32);
if (regno == 31 || regno == 63)
break;
if (set)
{
if (regno < 32)
sum->defd.i |= mask;
else
sum->defd.fp |= mask;
}
else
{
if (regno < 32)
sum->used.i |= mask;
else
sum->used.fp |= mask;
}
}
break;
case MEM:
if (set)
sum->defd.mem = 1;
else
sum->used.mem = 1;
/* Find the regs used in memory address computation: */
summarize_insn (XEXP (x, 0), sum, 0);
break;
case CONST_INT: case CONST_DOUBLE:
case SYMBOL_REF: case LABEL_REF: case CONST:
case SCRATCH: case ASM_INPUT:
break;
/* Handle common unary and binary ops for efficiency. */
case COMPARE: case PLUS: case MINUS: case MULT: case DIV:
case MOD: case UDIV: case UMOD: case AND: case IOR:
case XOR: case ASHIFT: case ROTATE: case ASHIFTRT: case LSHIFTRT:
case ROTATERT: case SMIN: case SMAX: case UMIN: case UMAX:
case NE: case EQ: case GE: case GT: case LE:
case LT: case GEU: case GTU: case LEU: case LTU:
summarize_insn (XEXP (x, 0), sum, 0);
summarize_insn (XEXP (x, 1), sum, 0);
break;
case NEG: case NOT: case SIGN_EXTEND: case ZERO_EXTEND:
case TRUNCATE: case FLOAT_EXTEND: case FLOAT_TRUNCATE: case FLOAT:
case FIX: case UNSIGNED_FLOAT: case UNSIGNED_FIX: case ABS:
case SQRT: case FFS:
summarize_insn (XEXP (x, 0), sum, 0);
break;
default:
format_ptr = GET_RTX_FORMAT (GET_CODE (x));
for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
switch (format_ptr[i])
{
case 'e':
summarize_insn (XEXP (x, i), sum, 0);
break;
case 'E':
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
summarize_insn (XVECEXP (x, i, j), sum, 0);
break;
case 'i':
break;
default:
gcc_unreachable ();
}
}
}
/* Ensure a sufficient number of `trapb' insns are in the code when
the user requests code with a trap precision of functions or
instructions.
In naive mode, when the user requests a trap-precision of
"instruction", a trapb is needed after every instruction that may
generate a trap. This ensures that the code is resumption safe but
it is also slow.
When optimizations are turned on, we delay issuing a trapb as long
as possible. In this context, a trap shadow is the sequence of
instructions that starts with a (potentially) trap generating
instruction and extends to the next trapb or call_pal instruction
(but GCC never generates call_pal by itself). We can delay (and
therefore sometimes omit) a trapb subject to the following
conditions:
(a) On entry to the trap shadow, if any Alpha register or memory
location contains a value that is used as an operand value by some
instruction in the trap shadow (live on entry), then no instruction
in the trap shadow may modify the register or memory location.
(b) Within the trap shadow, the computation of the base register
for a memory load or store instruction may not involve using the
result of an instruction that might generate an UNPREDICTABLE
result.
(c) Within the trap shadow, no register may be used more than once
as a destination register. (This is to make life easier for the
trap-handler.)
(d) The trap shadow may not include any branch instructions. */
static void
alpha_handle_trap_shadows (void)
{
struct shadow_summary shadow;
int trap_pending, exception_nesting;
rtx i, n;
trap_pending = 0;
exception_nesting = 0;
shadow.used.i = 0;
shadow.used.fp = 0;
shadow.used.mem = 0;
shadow.defd = shadow.used;
for (i = get_insns (); i ; i = NEXT_INSN (i))
{
if (NOTE_P (i))
{
switch (NOTE_KIND (i))
{
case NOTE_INSN_EH_REGION_BEG:
exception_nesting++;
if (trap_pending)
goto close_shadow;
break;
case NOTE_INSN_EH_REGION_END:
exception_nesting--;
if (trap_pending)
goto close_shadow;
break;
case NOTE_INSN_EPILOGUE_BEG:
if (trap_pending && alpha_tp >= ALPHA_TP_FUNC)
goto close_shadow;
break;
}
}
else if (trap_pending)
{
if (alpha_tp == ALPHA_TP_FUNC)
{
if (JUMP_P (i)
&& GET_CODE (PATTERN (i)) == RETURN)
goto close_shadow;
}
else if (alpha_tp == ALPHA_TP_INSN)
{
if (optimize > 0)
{
struct shadow_summary sum;
sum.used.i = 0;
sum.used.fp = 0;
sum.used.mem = 0;
sum.defd = sum.used;
switch (GET_CODE (i))
{
case INSN:
/* Annoyingly, get_attr_trap will die on these. */
if (GET_CODE (PATTERN (i)) == USE
|| GET_CODE (PATTERN (i)) == CLOBBER)
break;
summarize_insn (PATTERN (i), &sum, 0);
if ((sum.defd.i & shadow.defd.i)
|| (sum.defd.fp & shadow.defd.fp))
{
/* (c) would be violated */
goto close_shadow;
}
/* Combine shadow with summary of current insn: */
shadow.used.i |= sum.used.i;
shadow.used.fp |= sum.used.fp;
shadow.used.mem |= sum.used.mem;
shadow.defd.i |= sum.defd.i;
shadow.defd.fp |= sum.defd.fp;
shadow.defd.mem |= sum.defd.mem;
if ((sum.defd.i & shadow.used.i)
|| (sum.defd.fp & shadow.used.fp)
|| (sum.defd.mem & shadow.used.mem))
{
/* (a) would be violated (also takes care of (b)) */
gcc_assert (get_attr_trap (i) != TRAP_YES
|| (!(sum.defd.i & sum.used.i)
&& !(sum.defd.fp & sum.used.fp)));
goto close_shadow;
}
break;
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
goto close_shadow;
default:
gcc_unreachable ();
}
}
else
{
close_shadow:
n = emit_insn_before (gen_trapb (), i);
PUT_MODE (n, TImode);
PUT_MODE (i, TImode);
trap_pending = 0;
shadow.used.i = 0;
shadow.used.fp = 0;
shadow.used.mem = 0;
shadow.defd = shadow.used;
}
}
}
if ((exception_nesting > 0 || alpha_tp >= ALPHA_TP_FUNC)
&& NONJUMP_INSN_P (i)
&& GET_CODE (PATTERN (i)) != USE
&& GET_CODE (PATTERN (i)) != CLOBBER
&& get_attr_trap (i) == TRAP_YES)
{
if (optimize && !trap_pending)
summarize_insn (PATTERN (i), &shadow, 0);
trap_pending = 1;
}
}
}
/* Alpha can only issue instruction groups simultaneously if they are
suitably aligned. This is very processor-specific. */
/* There are a number of entries in alphaev4_insn_pipe and alphaev5_insn_pipe
that are marked "fake". These instructions do not exist on that target,
but it is possible to see these insns with deranged combinations of
command-line options, such as "-mtune=ev4 -mmax". Instead of aborting,
choose a result at random. */
enum alphaev4_pipe {
EV4_STOP = 0,
EV4_IB0 = 1,
EV4_IB1 = 2,
EV4_IBX = 4
};
enum alphaev5_pipe {
EV5_STOP = 0,
EV5_NONE = 1,
EV5_E01 = 2,
EV5_E0 = 4,
EV5_E1 = 8,
EV5_FAM = 16,
EV5_FA = 32,
EV5_FM = 64
};
static enum alphaev4_pipe
alphaev4_insn_pipe (rtx insn)
{
if (recog_memoized (insn) < 0)
return EV4_STOP;
if (get_attr_length (insn) != 4)
return EV4_STOP;
switch (get_attr_type (insn))
{
case TYPE_ILD:
case TYPE_LDSYM:
case TYPE_FLD:
case TYPE_LD_L:
return EV4_IBX;
case TYPE_IADD:
case TYPE_ILOG:
case TYPE_ICMOV:
case TYPE_ICMP:
case TYPE_FST:
case TYPE_SHIFT:
case TYPE_IMUL:
case TYPE_FBR:
case TYPE_MVI: /* fake */
return EV4_IB0;
case TYPE_IST:
case TYPE_MISC:
case TYPE_IBR:
case TYPE_JSR:
case TYPE_CALLPAL:
case TYPE_FCPYS:
case TYPE_FCMOV:
case TYPE_FADD:
case TYPE_FDIV:
case TYPE_FMUL:
case TYPE_ST_C:
case TYPE_MB:
case TYPE_FSQRT: /* fake */
case TYPE_FTOI: /* fake */
case TYPE_ITOF: /* fake */
return EV4_IB1;
default:
gcc_unreachable ();
}
}
static enum alphaev5_pipe
alphaev5_insn_pipe (rtx insn)
{
if (recog_memoized (insn) < 0)
return EV5_STOP;
if (get_attr_length (insn) != 4)
return EV5_STOP;
switch (get_attr_type (insn))
{
case TYPE_ILD:
case TYPE_FLD:
case TYPE_LDSYM:
case TYPE_IADD:
case TYPE_ILOG:
case TYPE_ICMOV:
case TYPE_ICMP:
return EV5_E01;
case TYPE_IST:
case TYPE_FST:
case TYPE_SHIFT:
case TYPE_IMUL:
case TYPE_MISC:
case TYPE_MVI:
case TYPE_LD_L:
case TYPE_ST_C:
case TYPE_MB:
case TYPE_FTOI: /* fake */
case TYPE_ITOF: /* fake */
return EV5_E0;
case TYPE_IBR:
case TYPE_JSR:
case TYPE_CALLPAL:
return EV5_E1;
case TYPE_FCPYS:
return EV5_FAM;
case TYPE_FBR:
case TYPE_FCMOV:
case TYPE_FADD:
case TYPE_FDIV:
case TYPE_FSQRT: /* fake */
return EV5_FA;
case TYPE_FMUL:
return EV5_FM;
default:
gcc_unreachable ();
}
}
/* IN_USE is a mask of the slots currently filled within the insn group.
The mask bits come from alphaev4_pipe above. If EV4_IBX is set, then
the insn in EV4_IB0 can be swapped by the hardware into EV4_IB1.
LEN is, of course, the length of the group in bytes. */
static rtx
alphaev4_next_group (rtx insn, int *pin_use, int *plen)
{
int len, in_use;
len = in_use = 0;
if (! INSN_P (insn)
|| GET_CODE (PATTERN (insn)) == CLOBBER
|| GET_CODE (PATTERN (insn)) == USE)
goto next_and_done;
while (1)
{
enum alphaev4_pipe pipe;
pipe = alphaev4_insn_pipe (insn);
switch (pipe)
{
case EV4_STOP:
/* Force complex instructions to start new groups. */
if (in_use)
goto done;
/* If this is a completely unrecognized insn, it's an asm.
We don't know how long it is, so record length as -1 to
signal a needed realignment. */
if (recog_memoized (insn) < 0)
len = -1;
else
len = get_attr_length (insn);
goto next_and_done;
case EV4_IBX:
if (in_use & EV4_IB0)
{
if (in_use & EV4_IB1)
goto done;
in_use |= EV4_IB1;
}
else
in_use |= EV4_IB0 | EV4_IBX;
break;
case EV4_IB0:
if (in_use & EV4_IB0)
{
if (!(in_use & EV4_IBX) || (in_use & EV4_IB1))
goto done;
in_use |= EV4_IB1;
}
in_use |= EV4_IB0;
break;
case EV4_IB1:
if (in_use & EV4_IB1)
goto done;
in_use |= EV4_IB1;
break;
default:
gcc_unreachable ();
}
len += 4;
/* Haifa doesn't do well scheduling branches. */
if (JUMP_P (insn))
goto next_and_done;
next:
insn = next_nonnote_insn (insn);
if (!insn || ! INSN_P (insn))
goto done;
/* Let Haifa tell us where it thinks insn group boundaries are. */
if (GET_MODE (insn) == TImode)
goto done;
if (GET_CODE (insn) == CLOBBER || GET_CODE (insn) == USE)
goto next;
}
next_and_done:
insn = next_nonnote_insn (insn);
done:
*plen = len;
*pin_use = in_use;
return insn;
}
/* IN_USE is a mask of the slots currently filled within the insn group.
The mask bits come from alphaev5_pipe above. If EV5_E01 is set, then
the insn in EV5_E0 can be swapped by the hardware into EV5_E1.
LEN is, of course, the length of the group in bytes. */
static rtx
alphaev5_next_group (rtx insn, int *pin_use, int *plen)
{
int len, in_use;
len = in_use = 0;
if (! INSN_P (insn)
|| GET_CODE (PATTERN (insn)) == CLOBBER
|| GET_CODE (PATTERN (insn)) == USE)
goto next_and_done;
while (1)
{
enum alphaev5_pipe pipe;
pipe = alphaev5_insn_pipe (insn);
switch (pipe)
{
case EV5_STOP:
/* Force complex instructions to start new groups. */
if (in_use)
goto done;
/* If this is a completely unrecognized insn, it's an asm.
We don't know how long it is, so record length as -1 to
signal a needed realignment. */
if (recog_memoized (insn) < 0)
len = -1;
else
len = get_attr_length (insn);
goto next_and_done;
/* ??? Most of the places below, we would like to assert never
happen, as it would indicate an error either in Haifa, or
in the scheduling description. Unfortunately, Haifa never
schedules the last instruction of the BB, so we don't have
an accurate TI bit to go off. */
case EV5_E01:
if (in_use & EV5_E0)
{
if (in_use & EV5_E1)
goto done;
in_use |= EV5_E1;
}
else
in_use |= EV5_E0 | EV5_E01;
break;
case EV5_E0:
if (in_use & EV5_E0)
{
if (!(in_use & EV5_E01) || (in_use & EV5_E1))
goto done;
in_use |= EV5_E1;
}
in_use |= EV5_E0;
break;
case EV5_E1:
if (in_use & EV5_E1)
goto done;
in_use |= EV5_E1;
break;
case EV5_FAM:
if (in_use & EV5_FA)
{
if (in_use & EV5_FM)
goto done;
in_use |= EV5_FM;
}
else
in_use |= EV5_FA | EV5_FAM;
break;
case EV5_FA:
if (in_use & EV5_FA)
goto done;
in_use |= EV5_FA;
break;
case EV5_FM:
if (in_use & EV5_FM)
goto done;
in_use |= EV5_FM;
break;
case EV5_NONE:
break;
default:
gcc_unreachable ();
}
len += 4;
/* Haifa doesn't do well scheduling branches. */
/* ??? If this is predicted not-taken, slotting continues, except
that no more IBR, FBR, or JSR insns may be slotted. */
if (JUMP_P (insn))
goto next_and_done;
next:
insn = next_nonnote_insn (insn);
if (!insn || ! INSN_P (insn))
goto done;
/* Let Haifa tell us where it thinks insn group boundaries are. */
if (GET_MODE (insn) == TImode)
goto done;
if (GET_CODE (insn) == CLOBBER || GET_CODE (insn) == USE)
goto next;
}
next_and_done:
insn = next_nonnote_insn (insn);
done:
*plen = len;
*pin_use = in_use;
return insn;
}
static rtx
alphaev4_next_nop (int *pin_use)
{
int in_use = *pin_use;
rtx nop;
if (!(in_use & EV4_IB0))
{
in_use |= EV4_IB0;
nop = gen_nop ();
}
else if ((in_use & (EV4_IBX|EV4_IB1)) == EV4_IBX)
{
in_use |= EV4_IB1;
nop = gen_nop ();
}
else if (TARGET_FP && !(in_use & EV4_IB1))
{
in_use |= EV4_IB1;
nop = gen_fnop ();
}
else
nop = gen_unop ();
*pin_use = in_use;
return nop;
}
static rtx
alphaev5_next_nop (int *pin_use)
{
int in_use = *pin_use;
rtx nop;
if (!(in_use & EV5_E1))
{
in_use |= EV5_E1;
nop = gen_nop ();
}
else if (TARGET_FP && !(in_use & EV5_FA))
{
in_use |= EV5_FA;
nop = gen_fnop ();
}
else if (TARGET_FP && !(in_use & EV5_FM))
{
in_use |= EV5_FM;
nop = gen_fnop ();
}
else
nop = gen_unop ();
*pin_use = in_use;
return nop;
}
/* The instruction group alignment main loop. */
static void
alpha_align_insns (unsigned int max_align,
rtx (*next_group) (rtx, int *, int *),
rtx (*next_nop) (int *))
{
/* ALIGN is the known alignment for the insn group. */
unsigned int align;
/* OFS is the offset of the current insn in the insn group. */
int ofs;
int prev_in_use, in_use, len, ldgp;
rtx i, next;
/* Let shorten branches care for assigning alignments to code labels. */
shorten_branches (get_insns ());
if (align_functions < 4)
align = 4;
else if ((unsigned int) align_functions < max_align)
align = align_functions;
else
align = max_align;
ofs = prev_in_use = 0;
i = get_insns ();
if (NOTE_P (i))
i = next_nonnote_insn (i);
ldgp = alpha_function_needs_gp ? 8 : 0;
while (i)
{
next = (*next_group) (i, &in_use, &len);
/* When we see a label, resync alignment etc. */
if (LABEL_P (i))
{
unsigned int new_align = 1 << label_to_alignment (i);
if (new_align >= align)
{
align = new_align < max_align ? new_align : max_align;
ofs = 0;
}
else if (ofs & (new_align-1))
ofs = (ofs | (new_align-1)) + 1;
gcc_assert (!len);
}
/* Handle complex instructions special. */
else if (in_use == 0)
{
/* Asms will have length < 0. This is a signal that we have
lost alignment knowledge. Assume, however, that the asm
will not mis-align instructions. */
if (len < 0)
{
ofs = 0;
align = 4;
len = 0;
}
}
/* If the known alignment is smaller than the recognized insn group,
realign the output. */
else if ((int) align < len)
{
unsigned int new_log_align = len > 8 ? 4 : 3;
rtx prev, where;
where = prev = prev_nonnote_insn (i);
if (!where || !LABEL_P (where))
where = i;
/* Can't realign between a call and its gp reload. */
if (! (TARGET_EXPLICIT_RELOCS
&& prev && CALL_P (prev)))
{
emit_insn_before (gen_realign (GEN_INT (new_log_align)), where);
align = 1 << new_log_align;
ofs = 0;
}
}
/* We may not insert padding inside the initial ldgp sequence. */
else if (ldgp > 0)
ldgp -= len;
/* If the group won't fit in the same INT16 as the previous,
we need to add padding to keep the group together. Rather
than simply leaving the insn filling to the assembler, we
can make use of the knowledge of what sorts of instructions
were issued in the previous group to make sure that all of
the added nops are really free. */
else if (ofs + len > (int) align)
{
int nop_count = (align - ofs) / 4;
rtx where;
/* Insert nops before labels, branches, and calls to truly merge
the execution of the nops with the previous instruction group. */
where = prev_nonnote_insn (i);
if (where)
{
if (LABEL_P (where))
{
rtx where2 = prev_nonnote_insn (where);
if (where2 && JUMP_P (where2))
where = where2;
}
else if (NONJUMP_INSN_P (where))
where = i;
}
else
where = i;
do
emit_insn_before ((*next_nop)(&prev_in_use), where);
while (--nop_count);
ofs = 0;
}
ofs = (ofs + len) & (align - 1);
prev_in_use = in_use;
i = next;
}
}
/* Insert an unop between sibcall or noreturn function call and GP load. */
static void
alpha_pad_function_end (void)
{
rtx insn, next;
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
{
if (! (CALL_P (insn)
&& (SIBLING_CALL_P (insn)
|| find_reg_note (insn, REG_NORETURN, NULL_RTX))))
continue;
next = next_active_insn (insn);
if (next)
{
rtx pat = PATTERN (next);
if (GET_CODE (pat) == SET
&& GET_CODE (SET_SRC (pat)) == UNSPEC_VOLATILE
&& XINT (SET_SRC (pat), 1) == UNSPECV_LDGP1)
emit_insn_after (gen_unop (), insn);
}
}
}
/* Machine dependent reorg pass. */
static void
alpha_reorg (void)
{
/* Workaround for a linker error that triggers when an exception
handler immediatelly follows a sibcall or a noreturn function.
In the sibcall case:
The instruction stream from an object file:
1d8: 00 00 fb 6b jmp (t12)
1dc: 00 00 ba 27 ldah gp,0(ra)
1e0: 00 00 bd 23 lda gp,0(gp)
1e4: 00 00 7d a7 ldq t12,0(gp)
1e8: 00 40 5b 6b jsr ra,(t12),1ec <__funcZ+0x1ec>
was converted in the final link pass to:
12003aa88: 67 fa ff c3 br 120039428 <...>
12003aa8c: 00 00 fe 2f unop
12003aa90: 00 00 fe 2f unop
12003aa94: 48 83 7d a7 ldq t12,-31928(gp)
12003aa98: 00 40 5b 6b jsr ra,(t12),12003aa9c <__func+0x1ec>
And in the noreturn case:
The instruction stream from an object file:
54: 00 40 5b 6b jsr ra,(t12),58 <__func+0x58>
58: 00 00 ba 27 ldah gp,0(ra)
5c: 00 00 bd 23 lda gp,0(gp)
60: 00 00 7d a7 ldq t12,0(gp)
64: 00 40 5b 6b jsr ra,(t12),68 <__func+0x68>
was converted in the final link pass to:
fdb24: a0 03 40 d3 bsr ra,fe9a8 <_called_func+0x8>
fdb28: 00 00 fe 2f unop
fdb2c: 00 00 fe 2f unop
fdb30: 30 82 7d a7 ldq t12,-32208(gp)
fdb34: 00 40 5b 6b jsr ra,(t12),fdb38 <__func+0x68>
GP load instructions were wrongly cleared by the linker relaxation
pass. This workaround prevents removal of GP loads by inserting
an unop instruction between a sibcall or noreturn function call and
exception handler prologue. */
if (current_function_has_exception_handlers ())
alpha_pad_function_end ();
if (alpha_tp != ALPHA_TP_PROG || flag_exceptions)
alpha_handle_trap_shadows ();
/* Due to the number of extra trapb insns, don't bother fixing up
alignment when trap precision is instruction. Moreover, we can
only do our job when sched2 is run. */
if (optimize && !optimize_size
&& alpha_tp != ALPHA_TP_INSN
&& flag_schedule_insns_after_reload)
{
if (alpha_tune == PROCESSOR_EV4)
alpha_align_insns (8, alphaev4_next_group, alphaev4_next_nop);
else if (alpha_tune == PROCESSOR_EV5)
alpha_align_insns (16, alphaev5_next_group, alphaev5_next_nop);
}
}
#if !TARGET_ABI_UNICOSMK
#ifdef HAVE_STAMP_H
#include <stamp.h>
#endif
static void
alpha_file_start (void)
{
#ifdef OBJECT_FORMAT_ELF
/* If emitting dwarf2 debug information, we cannot generate a .file
directive to start the file, as it will conflict with dwarf2out
file numbers. So it's only useful when emitting mdebug output. */
targetm.asm_file_start_file_directive = (write_symbols == DBX_DEBUG);
#endif
default_file_start ();
#ifdef MS_STAMP
fprintf (asm_out_file, "\t.verstamp %d %d\n", MS_STAMP, LS_STAMP);
#endif
fputs ("\t.set noreorder\n", asm_out_file);
fputs ("\t.set volatile\n", asm_out_file);
if (!TARGET_ABI_OPEN_VMS)
fputs ("\t.set noat\n", asm_out_file);
if (TARGET_EXPLICIT_RELOCS)
fputs ("\t.set nomacro\n", asm_out_file);
if (TARGET_SUPPORT_ARCH | TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX)
{
const char *arch;
if (alpha_cpu == PROCESSOR_EV6 || TARGET_FIX || TARGET_CIX)
arch = "ev6";
else if (TARGET_MAX)
arch = "pca56";
else if (TARGET_BWX)
arch = "ev56";
else if (alpha_cpu == PROCESSOR_EV5)
arch = "ev5";
else
arch = "ev4";
fprintf (asm_out_file, "\t.arch %s\n", arch);
}
}
#endif
#ifdef OBJECT_FORMAT_ELF
/* Since we don't have a .dynbss section, we should not allow global
relocations in the .rodata section. */
static int
alpha_elf_reloc_rw_mask (void)
{
return flag_pic ? 3 : 2;
}
/* Return a section for X. The only special thing we do here is to
honor small data. */
static section *
alpha_elf_select_rtx_section (enum machine_mode mode, rtx x,
unsigned HOST_WIDE_INT align)
{
if (TARGET_SMALL_DATA && GET_MODE_SIZE (mode) <= g_switch_value)
/* ??? Consider using mergeable sdata sections. */
return sdata_section;
else
return default_elf_select_rtx_section (mode, x, align);
}
static unsigned int
alpha_elf_section_type_flags (tree decl, const char *name, int reloc)
{
unsigned int flags = 0;
if (strcmp (name, ".sdata") == 0
|| strncmp (name, ".sdata.", 7) == 0
|| strncmp (name, ".gnu.linkonce.s.", 16) == 0
|| strcmp (name, ".sbss") == 0
|| strncmp (name, ".sbss.", 6) == 0
|| strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
flags = SECTION_SMALL;
flags |= default_section_type_flags (decl, name, reloc);
return flags;
}
#endif /* OBJECT_FORMAT_ELF */
/* Structure to collect function names for final output in link section. */
/* Note that items marked with GTY can't be ifdef'ed out. */
enum links_kind {KIND_UNUSED, KIND_LOCAL, KIND_EXTERN};
enum reloc_kind {KIND_LINKAGE, KIND_CODEADDR};
struct GTY(()) alpha_links
{
int num;
const char *target;
rtx linkage;
enum links_kind lkind;
enum reloc_kind rkind;
};
struct GTY(()) alpha_funcs
{
int num;
splay_tree GTY ((param1_is (char *), param2_is (struct alpha_links *)))
links;
};
static GTY ((param1_is (char *), param2_is (struct alpha_links *)))
splay_tree alpha_links_tree;
static GTY ((param1_is (tree), param2_is (struct alpha_funcs *)))
splay_tree alpha_funcs_tree;
static GTY(()) int alpha_funcs_num;
#if TARGET_ABI_OPEN_VMS
/* Return the VMS argument type corresponding to MODE. */
enum avms_arg_type
alpha_arg_type (enum machine_mode mode)
{
switch (mode)
{
case SFmode:
return TARGET_FLOAT_VAX ? FF : FS;
case DFmode:
return TARGET_FLOAT_VAX ? FD : FT;
default:
return I64;
}
}
/* Return an rtx for an integer representing the VMS Argument Information
register value. */
rtx
alpha_arg_info_reg_val (CUMULATIVE_ARGS cum)
{
unsigned HOST_WIDE_INT regval = cum.num_args;
int i;
for (i = 0; i < 6; i++)
regval |= ((int) cum.atypes[i]) << (i * 3 + 8);
return GEN_INT (regval);
}
/* Register the need for a (fake) .linkage entry for calls to function NAME.
IS_LOCAL is 1 if this is for a definition, 0 if this is for a real call.
Return a SYMBOL_REF suited to the call instruction. */
rtx
alpha_need_linkage (const char *name, int is_local)
{
splay_tree_node node;
struct alpha_links *al;
const char *target;
tree id;
if (name[0] == '*')
name++;
if (is_local)
{
struct alpha_funcs *cfaf;
if (!alpha_funcs_tree)
alpha_funcs_tree = splay_tree_new_ggc
(splay_tree_compare_pointers,
ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_s,
ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_node_s);
cfaf = ggc_alloc_alpha_funcs ();
cfaf->links = 0;
cfaf->num = ++alpha_funcs_num;
splay_tree_insert (alpha_funcs_tree,
(splay_tree_key) current_function_decl,
(splay_tree_value) cfaf);
}
if (alpha_links_tree)
{
/* Is this name already defined? */
node = splay_tree_lookup (alpha_links_tree, (splay_tree_key) name);
if (node)
{
al = (struct alpha_links *) node->value;
if (is_local)
{
/* Defined here but external assumed. */
if (al->lkind == KIND_EXTERN)
al->lkind = KIND_LOCAL;
}
else
{
/* Used here but unused assumed. */
if (al->lkind == KIND_UNUSED)
al->lkind = KIND_LOCAL;
}
return al->linkage;
}
}
else
alpha_links_tree = splay_tree_new_ggc
((splay_tree_compare_fn) strcmp,
ggc_alloc_splay_tree_str_alpha_links_splay_tree_s,
ggc_alloc_splay_tree_str_alpha_links_splay_tree_node_s);
al = ggc_alloc_alpha_links ();
name = ggc_strdup (name);
/* Assume external if no definition. */
al->lkind = (is_local ? KIND_UNUSED : KIND_EXTERN);
/* Ensure we have an IDENTIFIER so assemble_name can mark it used
and find the ultimate alias target like assemble_name. */
id = get_identifier (name);
target = NULL;
while (IDENTIFIER_TRANSPARENT_ALIAS (id))
{
id = TREE_CHAIN (id);
target = IDENTIFIER_POINTER (id);
}
al->target = target ? target : name;
al->linkage = gen_rtx_SYMBOL_REF (Pmode, name);
splay_tree_insert (alpha_links_tree, (splay_tree_key) name,
(splay_tree_value) al);
return al->linkage;
}
/* Return a SYMBOL_REF representing the reference to the .linkage entry
of function FUNC built for calls made from CFUNDECL. LFLAG is 1 if
this is the reference to the linkage pointer value, 0 if this is the
reference to the function entry value. RFLAG is 1 if this a reduced
reference (code address only), 0 if this is a full reference. */
rtx
alpha_use_linkage (rtx func, tree cfundecl, int lflag, int rflag)
{
splay_tree_node cfunnode;
struct alpha_funcs *cfaf;
struct alpha_links *al;
const char *name = XSTR (func, 0);
cfaf = (struct alpha_funcs *) 0;
al = (struct alpha_links *) 0;
cfunnode = splay_tree_lookup (alpha_funcs_tree, (splay_tree_key) cfundecl);
cfaf = (struct alpha_funcs *) cfunnode->value;
if (cfaf->links)
{
splay_tree_node lnode;
/* Is this name already defined? */
lnode = splay_tree_lookup (cfaf->links, (splay_tree_key) name);
if (lnode)
al = (struct alpha_links *) lnode->value;
}
else
cfaf->links = splay_tree_new_ggc
((splay_tree_compare_fn) strcmp,
ggc_alloc_splay_tree_str_alpha_links_splay_tree_s,
ggc_alloc_splay_tree_str_alpha_links_splay_tree_node_s);
if (!al)
{
size_t name_len;
size_t buflen;
char *linksym;
splay_tree_node node = 0;
struct alpha_links *anl;
if (name[0] == '*')
name++;
name_len = strlen (name);
linksym = (char *) alloca (name_len + 50);
al = ggc_alloc_alpha_links ();
al->num = cfaf->num;
al->target = NULL;
node = splay_tree_lookup (alpha_links_tree, (splay_tree_key) name);
if (node)
{
anl = (struct alpha_links *) node->value;
al->lkind = anl->lkind;
name = anl->target;
}
sprintf (linksym, "$%d..%s..lk", cfaf->num, name);
buflen = strlen (linksym);
al->linkage = gen_rtx_SYMBOL_REF
(Pmode, ggc_alloc_string (linksym, buflen + 1));
splay_tree_insert (cfaf->links, (splay_tree_key) name,
(splay_tree_value) al);
}
if (rflag)
al->rkind = KIND_CODEADDR;
else
al->rkind = KIND_LINKAGE;
if (lflag)
return gen_rtx_MEM (Pmode, plus_constant (al->linkage, 8));
else
return al->linkage;
}
static int
alpha_write_one_linkage (splay_tree_node node, void *data)
{
const char *const name = (const char *) node->key;
struct alpha_links *link = (struct alpha_links *) node->value;
FILE *stream = (FILE *) data;
fprintf (stream, "$%d..%s..lk:\n", link->num, name);
if (link->rkind == KIND_CODEADDR)
{
if (link->lkind == KIND_LOCAL)
{
/* Local and used */
fprintf (stream, "\t.quad %s..en\n", name);
}
else
{
/* External and used, request code address. */
fprintf (stream, "\t.code_address %s\n", name);
}
}
else
{
if (link->lkind == KIND_LOCAL)
{
/* Local and used, build linkage pair. */
fprintf (stream, "\t.quad %s..en\n", name);
fprintf (stream, "\t.quad %s\n", name);
}
else
{
/* External and used, request linkage pair. */
fprintf (stream, "\t.linkage %s\n", name);
}
}
return 0;
}
static void
alpha_write_linkage (FILE *stream, const char *funname, tree fundecl)
{
splay_tree_node node;
struct alpha_funcs *func;
fprintf (stream, "\t.link\n");
fprintf (stream, "\t.align 3\n");
in_section = NULL;
node = splay_tree_lookup (alpha_funcs_tree, (splay_tree_key) fundecl);
func = (struct alpha_funcs *) node->value;
fputs ("\t.name ", stream);
assemble_name (stream, funname);
fputs ("..na\n", stream);
ASM_OUTPUT_LABEL (stream, funname);
fprintf (stream, "\t.pdesc ");
assemble_name (stream, funname);
fprintf (stream, "..en,%s\n",
alpha_procedure_type == PT_STACK ? "stack"
: alpha_procedure_type == PT_REGISTER ? "reg" : "null");
if (func->links)
{
splay_tree_foreach (func->links, alpha_write_one_linkage, stream);
/* splay_tree_delete (func->links); */
}
}
/* Switch to an arbitrary section NAME with attributes as specified
by FLAGS. ALIGN specifies any known alignment requirements for
the section; 0 if the default should be used. */
static void
vms_asm_named_section (const char *name, unsigned int flags,
tree decl ATTRIBUTE_UNUSED)
{
fputc ('\n', asm_out_file);
fprintf (asm_out_file, ".section\t%s", name);
if (flags & SECTION_DEBUG)
fprintf (asm_out_file, ",NOWRT");
fputc ('\n', asm_out_file);
}
/* Record an element in the table of global constructors. SYMBOL is
a SYMBOL_REF of the function to be called; PRIORITY is a number
between 0 and MAX_INIT_PRIORITY.
Differs from default_ctors_section_asm_out_constructor in that the
width of the .ctors entry is always 64 bits, rather than the 32 bits
used by a normal pointer. */
static void
vms_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
{
switch_to_section (ctors_section);
assemble_align (BITS_PER_WORD);
assemble_integer (symbol, UNITS_PER_WORD, BITS_PER_WORD, 1);
}
static void
vms_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
{
switch_to_section (dtors_section);
assemble_align (BITS_PER_WORD);
assemble_integer (symbol, UNITS_PER_WORD, BITS_PER_WORD, 1);
}
#else
rtx
alpha_need_linkage (const char *name ATTRIBUTE_UNUSED,
int is_local ATTRIBUTE_UNUSED)
{
return NULL_RTX;
}
rtx
alpha_use_linkage (rtx func ATTRIBUTE_UNUSED,
tree cfundecl ATTRIBUTE_UNUSED,
int lflag ATTRIBUTE_UNUSED,
int rflag ATTRIBUTE_UNUSED)
{
return NULL_RTX;
}
#endif /* TARGET_ABI_OPEN_VMS */
#if TARGET_ABI_UNICOSMK
/* This evaluates to true if we do not know how to pass TYPE solely in
registers. This is the case for all arguments that do not fit in two
registers. */
static bool
unicosmk_must_pass_in_stack (enum machine_mode mode, const_tree type)
{
if (type == NULL)
return false;
if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
return true;
if (TREE_ADDRESSABLE (type))
return true;
return ALPHA_ARG_SIZE (mode, type, 0) > 2;
}
/* Define the offset between two registers, one to be eliminated, and the
other its replacement, at the start of a routine. */
int
unicosmk_initial_elimination_offset (int from, int to)
{
int fixed_size;
fixed_size = alpha_sa_size();
if (fixed_size != 0)
fixed_size += 48;
if (from == FRAME_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
return -fixed_size;
else if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM)
return 0;
else if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
return (ALPHA_ROUND (crtl->outgoing_args_size)
+ ALPHA_ROUND (get_frame_size()));
else if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
return (ALPHA_ROUND (fixed_size)
+ ALPHA_ROUND (get_frame_size()
+ crtl->outgoing_args_size));
else
gcc_unreachable ();
}
/* Output the module name for .ident and .end directives. We have to strip
directories and add make sure that the module name starts with a letter
or '$'. */
static void
unicosmk_output_module_name (FILE *file)
{
const char *name = lbasename (main_input_filename);
unsigned len = strlen (name);
char *clean_name = alloca (len + 2);
char *ptr = clean_name;
/* CAM only accepts module names that start with a letter or '$'. We
prefix the module name with a '$' if necessary. */
if (!ISALPHA (*name))
*ptr++ = '$';
memcpy (ptr, name, len + 1);
clean_symbol_name (clean_name);
fputs (clean_name, file);
}
/* Output the definition of a common variable. */
void
unicosmk_output_common (FILE *file, const char *name, int size, int align)
{
tree name_tree;
printf ("T3E__: common %s\n", name);
in_section = NULL;
fputs("\t.endp\n\n\t.psect ", file);
assemble_name(file, name);
fprintf(file, ",%d,common\n", floor_log2 (align / BITS_PER_UNIT));
fprintf(file, "\t.byte\t0:%d\n", size);
/* Mark the symbol as defined in this module. */
name_tree = get_identifier (name);
TREE_ASM_WRITTEN (name_tree) = 1;
}
#define SECTION_PUBLIC SECTION_MACH_DEP
#define SECTION_MAIN (SECTION_PUBLIC << 1)
static int current_section_align;
/* A get_unnamed_section callback for switching to the text section. */
static void
unicosmk_output_text_section_asm_op (const void *data ATTRIBUTE_UNUSED)
{
static int count = 0;
fprintf (asm_out_file, "\t.endp\n\n\t.psect\tgcc@text___%d,code\n", count++);
}
/* A get_unnamed_section callback for switching to the data section. */
static void
unicosmk_output_data_section_asm_op (const void *data ATTRIBUTE_UNUSED)
{
static int count = 1;
fprintf (asm_out_file, "\t.endp\n\n\t.psect\tgcc@data___%d,data\n", count++);
}
/* Implement TARGET_ASM_INIT_SECTIONS.
The Cray assembler is really weird with respect to sections. It has only
named sections and you can't reopen a section once it has been closed.
This means that we have to generate unique names whenever we want to
reenter the text or the data section. */
static void
unicosmk_init_sections (void)
{
text_section = get_unnamed_section (SECTION_CODE,
unicosmk_output_text_section_asm_op,
NULL);
data_section = get_unnamed_section (SECTION_WRITE,
unicosmk_output_data_section_asm_op,
NULL);
readonly_data_section = data_section;
}
static unsigned int
unicosmk_section_type_flags (tree decl, const char *name,
int reloc ATTRIBUTE_UNUSED)
{
unsigned int flags = default_section_type_flags (decl, name, reloc);
if (!decl)
return flags;
if (TREE_CODE (decl) == FUNCTION_DECL)
{
current_section_align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
if (align_functions_log > current_section_align)
current_section_align = align_functions_log;
if (! strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "main"))
flags |= SECTION_MAIN;
}
else
current_section_align = floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT);
if (TREE_PUBLIC (decl))
flags |= SECTION_PUBLIC;
return flags;
}
/* Generate a section name for decl and associate it with the
declaration. */
static void
unicosmk_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED)
{
const char *name;
int len;
gcc_assert (decl);
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
name = default_strip_name_encoding (name);
len = strlen (name);
if (TREE_CODE (decl) == FUNCTION_DECL)
{
char *string;
/* It is essential that we prefix the section name here because
otherwise the section names generated for constructors and
destructors confuse collect2. */
string = alloca (len + 6);
sprintf (string, "code@%s", name);
DECL_SECTION_NAME (decl) = build_string (len + 5, string);
}
else if (TREE_PUBLIC (decl))
DECL_SECTION_NAME (decl) = build_string (len, name);
else
{
char *string;
string = alloca (len + 6);
sprintf (string, "data@%s", name);
DECL_SECTION_NAME (decl) = build_string (len + 5, string);
}
}
/* Switch to an arbitrary section NAME with attributes as specified
by FLAGS. ALIGN specifies any known alignment requirements for
the section; 0 if the default should be used. */
static void
unicosmk_asm_named_section (const char *name, unsigned int flags,
tree decl ATTRIBUTE_UNUSED)
{
const char *kind;
/* Close the previous section. */
fputs ("\t.endp\n\n", asm_out_file);
/* Find out what kind of section we are opening. */
if (flags & SECTION_MAIN)
fputs ("\t.start\tmain\n", asm_out_file);
if (flags & SECTION_CODE)
kind = "code";
else if (flags & SECTION_PUBLIC)
kind = "common";
else
kind = "data";
if (current_section_align != 0)
fprintf (asm_out_file, "\t.psect\t%s,%d,%s\n", name,
current_section_align, kind);
else
fprintf (asm_out_file, "\t.psect\t%s,%s\n", name, kind);
}
static void
unicosmk_insert_attributes (tree decl, tree *attr_ptr ATTRIBUTE_UNUSED)
{
if (DECL_P (decl)
&& (TREE_PUBLIC (decl) || TREE_CODE (decl) == FUNCTION_DECL))
unicosmk_unique_section (decl, 0);
}
/* Output an alignment directive. We have to use the macro 'gcc@code@align'
in code sections because .align fill unused space with zeroes. */
void
unicosmk_output_align (FILE *file, int align)
{
if (inside_function)
fprintf (file, "\tgcc@code@align\t%d\n", align);
else
fprintf (file, "\t.align\t%d\n", align);
}
/* Add a case vector to the current function's list of deferred case
vectors. Case vectors have to be put into a separate section because CAM
does not allow data definitions in code sections. */
void
unicosmk_defer_case_vector (rtx lab, rtx vec)
{
struct machine_function *machine = cfun->machine;
vec = gen_rtx_EXPR_LIST (VOIDmode, lab, vec);
machine->addr_list = gen_rtx_EXPR_LIST (VOIDmode, vec,
machine->addr_list);
}
/* Output a case vector. */
static void
unicosmk_output_addr_vec (FILE *file, rtx vec)
{
rtx lab = XEXP (vec, 0);
rtx body = XEXP (vec, 1);
int vlen = XVECLEN (body, 0);
int idx;
(*targetm.asm_out.internal_label) (file, "L", CODE_LABEL_NUMBER (lab));
for (idx = 0; idx < vlen; idx++)
{
ASM_OUTPUT_ADDR_VEC_ELT
(file, CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
}
}
/* Output current function's deferred case vectors. */
static void
unicosmk_output_deferred_case_vectors (FILE *file)
{
struct machine_function *machine = cfun->machine;
rtx t;
if (machine->addr_list == NULL_RTX)
return;
switch_to_section (data_section);
for (t = machine->addr_list; t; t = XEXP (t, 1))
unicosmk_output_addr_vec (file, XEXP (t, 0));
}
/* Generate the name of the SSIB section for the current function. */
#define SSIB_PREFIX "__SSIB_"
#define SSIB_PREFIX_LEN 7
static const char *
unicosmk_ssib_name (void)
{
/* This is ok since CAM won't be able to deal with names longer than that
anyway. */
static char name[256];
rtx x;
const char *fnname;
int len;
x = DECL_RTL (cfun->decl);
gcc_assert (MEM_P (x));
x = XEXP (x, 0);
gcc_assert (GET_CODE (x) == SYMBOL_REF);
fnname = XSTR (x, 0);
len = strlen (fnname);
if (len + SSIB_PREFIX_LEN > 255)
len = 255 - SSIB_PREFIX_LEN;
strcpy (name, SSIB_PREFIX);
strncpy (name + SSIB_PREFIX_LEN, fnname, len);
name[len + SSIB_PREFIX_LEN] = 0;
return name;
}
/* Set up the dynamic subprogram information block (DSIB) and update the
frame pointer register ($15) for subroutines which have a frame. If the
subroutine doesn't have a frame, simply increment $15. */
static void
unicosmk_gen_dsib (unsigned long *imaskP)
{
if (alpha_procedure_type == PT_STACK)
{
const char *ssib_name;
rtx mem;
/* Allocate 64 bytes for the DSIB. */
FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
GEN_INT (-64))));
emit_insn (gen_blockage ());
/* Save the return address. */
mem = gen_frame_mem (DImode, plus_constant (stack_pointer_rtx, 56));
FRP (emit_move_insn (mem, gen_rtx_REG (DImode, REG_RA)));
(*imaskP) &= ~(1UL << REG_RA);
/* Save the old frame pointer. */
mem = gen_frame_mem (DImode, plus_constant (stack_pointer_rtx, 48));
FRP (emit_move_insn (mem, hard_frame_pointer_rtx));
(*imaskP) &= ~(1UL << HARD_FRAME_POINTER_REGNUM);
emit_insn (gen_blockage ());
/* Store the SSIB pointer. */
ssib_name = ggc_strdup (unicosmk_ssib_name ());
mem = gen_frame_mem (DImode, plus_constant (stack_pointer_rtx, 32));
FRP (emit_move_insn (gen_rtx_REG (DImode, 5),
gen_rtx_SYMBOL_REF (Pmode, ssib_name)));
FRP (emit_move_insn (mem, gen_rtx_REG (DImode, 5)));
/* Save the CIW index. */
mem = gen_frame_mem (DImode, plus_constant (stack_pointer_rtx, 24));
FRP (emit_move_insn (mem, gen_rtx_REG (DImode, 25)));
emit_insn (gen_blockage ());
/* Set the new frame pointer. */
FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx,
stack_pointer_rtx, GEN_INT (64))));
}
else
{
/* Increment the frame pointer register to indicate that we do not
have a frame. */
emit_insn (gen_adddi3 (hard_frame_pointer_rtx,
hard_frame_pointer_rtx, const1_rtx));
}
}
/* Output the static subroutine information block for the current
function. */
static void
unicosmk_output_ssib (FILE *file, const char *fnname)
{
int len;
int i;
rtx x;
rtx ciw;
struct machine_function *machine = cfun->machine;
in_section = NULL;
fprintf (file, "\t.endp\n\n\t.psect\t%s%s,data\n", user_label_prefix,
unicosmk_ssib_name ());
/* Some required stuff and the function name length. */
len = strlen (fnname);
fprintf (file, "\t.quad\t^X20008%2.2X28\n", len);
/* Saved registers
??? We don't do that yet. */
fputs ("\t.quad\t0\n", file);
/* Function address. */
fputs ("\t.quad\t", file);
assemble_name (file, fnname);
putc ('\n', file);
fputs ("\t.quad\t0\n", file);
fputs ("\t.quad\t0\n", file);
/* Function name.
??? We do it the same way Cray CC does it but this could be
simplified. */
for( i = 0; i < len; i++ )
fprintf (file, "\t.byte\t%d\n", (int)(fnname[i]));
if( (len % 8) == 0 )
fputs ("\t.quad\t0\n", file);
else
fprintf (file, "\t.bits\t%d : 0\n", (8 - (len % 8))*8);
/* All call information words used in the function. */
for (x = machine->first_ciw; x; x = XEXP (x, 1))
{
ciw = XEXP (x, 0);
#if HOST_BITS_PER_WIDE_INT == 32
fprintf (file, "\t.quad\t" HOST_WIDE_INT_PRINT_DOUBLE_HEX "\n",
CONST_DOUBLE_HIGH (ciw), CONST_DOUBLE_LOW (ciw));
#else
fprintf (file, "\t.quad\t" HOST_WIDE_INT_PRINT_HEX "\n", INTVAL (ciw));
#endif
}
}
/* Add a call information word (CIW) to the list of the current function's
CIWs and return its index.
X is a CONST_INT or CONST_DOUBLE representing the CIW. */
rtx
unicosmk_add_call_info_word (rtx x)
{
rtx node;
struct machine_function *machine = cfun->machine;
node = gen_rtx_EXPR_LIST (VOIDmode, x, NULL_RTX);
if (machine->first_ciw == NULL_RTX)
machine->first_ciw = node;
else
XEXP (machine->last_ciw, 1) = node;
machine->last_ciw = node;
++machine->ciw_count;
return GEN_INT (machine->ciw_count
+ strlen (current_function_name ())/8 + 5);
}
/* The Cray assembler doesn't accept extern declarations for symbols which
are defined in the same file. We have to keep track of all global
symbols which are referenced and/or defined in a source file and output
extern declarations for those which are referenced but not defined at
the end of file. */
/* List of identifiers for which an extern declaration might have to be
emitted. */
/* FIXME: needs to use GC, so it can be saved and restored for PCH. */
struct unicosmk_extern_list
{
struct unicosmk_extern_list *next;
const char *name;
};
static struct unicosmk_extern_list *unicosmk_extern_head = 0;
/* Output extern declarations which are required for every asm file. */
static void
unicosmk_output_default_externs (FILE *file)
{
static const char *const externs[] =
{ "__T3E_MISMATCH" };
int i;
int n;
n = ARRAY_SIZE (externs);
for (i = 0; i < n; i++)
fprintf (file, "\t.extern\t%s\n", externs[i]);
}
/* Output extern declarations for global symbols which are have been
referenced but not defined. */
static void
unicosmk_output_externs (FILE *file)
{
struct unicosmk_extern_list *p;
const char *real_name;
int len;
tree name_tree;
len = strlen (user_label_prefix);
for (p = unicosmk_extern_head; p != 0; p = p->next)
{
/* We have to strip the encoding and possibly remove user_label_prefix
from the identifier in order to handle -fleading-underscore and
explicit asm names correctly (cf. gcc.dg/asm-names-1.c). */
real_name = default_strip_name_encoding (p->name);
if (len && p->name[0] == '*'
&& !memcmp (real_name, user_label_prefix, len))
real_name += len;
name_tree = get_identifier (real_name);
if (! TREE_ASM_WRITTEN (name_tree))
{
TREE_ASM_WRITTEN (name_tree) = 1;
fputs ("\t.extern\t", file);
assemble_name (file, p->name);
putc ('\n', file);
}
}
}
/* Record an extern. */
void
unicosmk_add_extern (const char *name)
{
struct unicosmk_extern_list *p;
p = (struct unicosmk_extern_list *)
xmalloc (sizeof (struct unicosmk_extern_list));
p->next = unicosmk_extern_head;
p->name = name;
unicosmk_extern_head = p;
}
/* The Cray assembler generates incorrect code if identifiers which
conflict with register names are used as instruction operands. We have
to replace such identifiers with DEX expressions. */
/* Structure to collect identifiers which have been replaced by DEX
expressions. */
/* FIXME: needs to use GC, so it can be saved and restored for PCH. */
struct unicosmk_dex {
struct unicosmk_dex *next;
const char *name;
};
/* List of identifiers which have been replaced by DEX expressions. The DEX
number is determined by the position in the list. */
static struct unicosmk_dex *unicosmk_dex_list = NULL;
/* The number of elements in the DEX list. */
static int unicosmk_dex_count = 0;
/* Check if NAME must be replaced by a DEX expression. */
static int
unicosmk_special_name (const char *name)
{
if (name[0] == '*')
++name;
if (name[0] == '$')
++name;
if (name[0] != 'r' && name[0] != 'f' && name[0] != 'R' && name[0] != 'F')
return 0;
switch (name[1])
{
case '1': case '2':
return (name[2] == '\0' || (ISDIGIT (name[2]) && name[3] == '\0'));
case '3':
return (name[2] == '\0'
|| ((name[2] == '0' || name[2] == '1') && name[3] == '\0'));
default:
return (ISDIGIT (name[1]) && name[2] == '\0');
}
}
/* Return the DEX number if X must be replaced by a DEX expression and 0
otherwise. */
static int
unicosmk_need_dex (rtx x)
{
struct unicosmk_dex *dex;
const char *name;
int i;
if (GET_CODE (x) != SYMBOL_REF)
return 0;
name = XSTR (x,0);
if (! unicosmk_special_name (name))
return 0;
i = unicosmk_dex_count;
for (dex = unicosmk_dex_list; dex; dex = dex->next)
{
if (! strcmp (name, dex->name))
return i;
--i;
}
dex = (struct unicosmk_dex *) xmalloc (sizeof (struct unicosmk_dex));
dex->name = name;
dex->next = unicosmk_dex_list;
unicosmk_dex_list = dex;
++unicosmk_dex_count;
return unicosmk_dex_count;
}
/* Output the DEX definitions for this file. */
static void
unicosmk_output_dex (FILE *file)
{
struct unicosmk_dex *dex;
int i;
if (unicosmk_dex_list == NULL)
return;
fprintf (file, "\t.dexstart\n");
i = unicosmk_dex_count;
for (dex = unicosmk_dex_list; dex; dex = dex->next)
{
fprintf (file, "\tDEX (%d) = ", i);
assemble_name (file, dex->name);
putc ('\n', file);
--i;
}
fprintf (file, "\t.dexend\n");
}
/* Output text that to appear at the beginning of an assembler file. */
static void
unicosmk_file_start (void)
{
int i;
fputs ("\t.ident\t", asm_out_file);
unicosmk_output_module_name (asm_out_file);
fputs ("\n\n", asm_out_file);
/* The Unicos/Mk assembler uses different register names. Instead of trying
to support them, we simply use micro definitions. */
/* CAM has different register names: rN for the integer register N and fN
for the floating-point register N. Instead of trying to use these in
alpha.md, we define the symbols $N and $fN to refer to the appropriate
register. */
for (i = 0; i < 32; ++i)
fprintf (asm_out_file, "$%d <- r%d\n", i, i);
for (i = 0; i < 32; ++i)
fprintf (asm_out_file, "$f%d <- f%d\n", i, i);
putc ('\n', asm_out_file);
/* The .align directive fill unused space with zeroes which does not work
in code sections. We define the macro 'gcc@code@align' which uses nops
instead. Note that it assumes that code sections always have the
biggest possible alignment since . refers to the current offset from
the beginning of the section. */
fputs ("\t.macro gcc@code@align n\n", asm_out_file);
fputs ("gcc@n@bytes = 1 << n\n", asm_out_file);
fputs ("gcc@here = . % gcc@n@bytes\n", asm_out_file);
fputs ("\t.if ne, gcc@here, 0\n", asm_out_file);
fputs ("\t.repeat (gcc@n@bytes - gcc@here) / 4\n", asm_out_file);
fputs ("\tbis r31,r31,r31\n", asm_out_file);
fputs ("\t.endr\n", asm_out_file);
fputs ("\t.endif\n", asm_out_file);
fputs ("\t.endm gcc@code@align\n\n", asm_out_file);
/* Output extern declarations which should always be visible. */
unicosmk_output_default_externs (asm_out_file);
/* Open a dummy section. We always need to be inside a section for the
section-switching code to work correctly.
??? This should be a module id or something like that. I still have to
figure out what the rules for those are. */
fputs ("\n\t.psect\t$SG00000,data\n", asm_out_file);
}
/* Output text to appear at the end of an assembler file. This includes all
pending extern declarations and DEX expressions. */
static void
unicosmk_file_end (void)
{
fputs ("\t.endp\n\n", asm_out_file);
/* Output all pending externs. */
unicosmk_output_externs (asm_out_file);
/* Output dex definitions used for functions whose names conflict with
register names. */
unicosmk_output_dex (asm_out_file);
fputs ("\t.end\t", asm_out_file);
unicosmk_output_module_name (asm_out_file);
putc ('\n', asm_out_file);
}
#else
static void
unicosmk_output_deferred_case_vectors (FILE *file ATTRIBUTE_UNUSED)
{}
static void
unicosmk_gen_dsib (unsigned long *imaskP ATTRIBUTE_UNUSED)
{}
static void
unicosmk_output_ssib (FILE * file ATTRIBUTE_UNUSED,
const char * fnname ATTRIBUTE_UNUSED)
{}
rtx
unicosmk_add_call_info_word (rtx x ATTRIBUTE_UNUSED)
{
return NULL_RTX;
}
static int
unicosmk_need_dex (rtx x ATTRIBUTE_UNUSED)
{
return 0;
}
#endif /* TARGET_ABI_UNICOSMK */
static void
alpha_init_libfuncs (void)
{
if (TARGET_ABI_UNICOSMK)
{
/* Prevent gcc from generating calls to __divsi3. */
set_optab_libfunc (sdiv_optab, SImode, 0);
set_optab_libfunc (udiv_optab, SImode, 0);
/* Use the functions provided by the system library
for DImode integer division. */
set_optab_libfunc (sdiv_optab, DImode, "$sldiv");
set_optab_libfunc (udiv_optab, DImode, "$uldiv");
}
else if (TARGET_ABI_OPEN_VMS)
{
/* Use the VMS runtime library functions for division and
remainder. */
set_optab_libfunc (sdiv_optab, SImode, "OTS$DIV_I");
set_optab_libfunc (sdiv_optab, DImode, "OTS$DIV_L");
set_optab_libfunc (udiv_optab, SImode, "OTS$DIV_UI");
set_optab_libfunc (udiv_optab, DImode, "OTS$DIV_UL");
set_optab_libfunc (smod_optab, SImode, "OTS$REM_I");
set_optab_libfunc (smod_optab, DImode, "OTS$REM_L");
set_optab_libfunc (umod_optab, SImode, "OTS$REM_UI");
set_optab_libfunc (umod_optab, DImode, "OTS$REM_UL");
abort_libfunc = init_one_libfunc ("decc$abort");
memcmp_libfunc = init_one_libfunc ("decc$memcmp");
#ifdef MEM_LIBFUNCS_INIT
MEM_LIBFUNCS_INIT;
#endif
}
}
/* On the Alpha, we use this to disable the floating-point registers
when they don't exist. */
static void
alpha_conditional_register_usage (void)
{
int i;
if (! TARGET_FPREGS)
for (i = 32; i < 63; i++)
fixed_regs[i] = call_used_regs[i] = 1;
}
/* Initialize the GCC target structure. */
#if TARGET_ABI_OPEN_VMS
# undef TARGET_ATTRIBUTE_TABLE
# define TARGET_ATTRIBUTE_TABLE vms_attribute_table
# undef TARGET_CAN_ELIMINATE
# define TARGET_CAN_ELIMINATE alpha_vms_can_eliminate
#endif
#undef TARGET_IN_SMALL_DATA_P
#define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p
#if TARGET_ABI_UNICOSMK
# undef TARGET_INSERT_ATTRIBUTES
# define TARGET_INSERT_ATTRIBUTES unicosmk_insert_attributes
# undef TARGET_SECTION_TYPE_FLAGS
# define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
# undef TARGET_ASM_UNIQUE_SECTION
# define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section
#undef TARGET_ASM_FUNCTION_RODATA_SECTION
#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
# undef TARGET_ASM_GLOBALIZE_LABEL
# define TARGET_ASM_GLOBALIZE_LABEL hook_void_FILEptr_constcharptr
# undef TARGET_MUST_PASS_IN_STACK
# define TARGET_MUST_PASS_IN_STACK unicosmk_must_pass_in_stack
#endif
#undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
#undef TARGET_ASM_ALIGNED_DI_OP
#define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
/* Default unaligned ops are provided for ELF systems. To get unaligned
data for non-ELF systems, we have to turn off auto alignment. */
#if !defined (OBJECT_FORMAT_ELF) || TARGET_ABI_OPEN_VMS
#undef TARGET_ASM_UNALIGNED_HI_OP
#define TARGET_ASM_UNALIGNED_HI_OP "\t.align 0\n\t.word\t"
#undef TARGET_ASM_UNALIGNED_SI_OP
#define TARGET_ASM_UNALIGNED_SI_OP "\t.align 0\n\t.long\t"
#undef TARGET_ASM_UNALIGNED_DI_OP
#define TARGET_ASM_UNALIGNED_DI_OP "\t.align 0\n\t.quad\t"
#endif
#ifdef OBJECT_FORMAT_ELF
#undef TARGET_ASM_RELOC_RW_MASK
#define TARGET_ASM_RELOC_RW_MASK alpha_elf_reloc_rw_mask
#undef TARGET_ASM_SELECT_RTX_SECTION
#define TARGET_ASM_SELECT_RTX_SECTION alpha_elf_select_rtx_section
#undef TARGET_SECTION_TYPE_FLAGS
#define TARGET_SECTION_TYPE_FLAGS alpha_elf_section_type_flags
#endif
#undef TARGET_ASM_FUNCTION_END_PROLOGUE
#define TARGET_ASM_FUNCTION_END_PROLOGUE alpha_output_function_end_prologue
#undef TARGET_INIT_LIBFUNCS
#define TARGET_INIT_LIBFUNCS alpha_init_libfuncs
#undef TARGET_LEGITIMIZE_ADDRESS
#define TARGET_LEGITIMIZE_ADDRESS alpha_legitimize_address
#if TARGET_ABI_UNICOSMK
#undef TARGET_ASM_FILE_START
#define TARGET_ASM_FILE_START unicosmk_file_start
#undef TARGET_ASM_FILE_END
#define TARGET_ASM_FILE_END unicosmk_file_end
#else
#undef TARGET_ASM_FILE_START
#define TARGET_ASM_FILE_START alpha_file_start
#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
#endif
#undef TARGET_SCHED_ADJUST_COST
#define TARGET_SCHED_ADJUST_COST alpha_adjust_cost
#undef TARGET_SCHED_ISSUE_RATE
#define TARGET_SCHED_ISSUE_RATE alpha_issue_rate
#undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
#define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD \
alpha_multipass_dfa_lookahead
#undef TARGET_HAVE_TLS
#define TARGET_HAVE_TLS HAVE_AS_TLS
#undef TARGET_BUILTIN_DECL
#define TARGET_BUILTIN_DECL alpha_builtin_decl
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS alpha_init_builtins
#undef TARGET_EXPAND_BUILTIN
#define TARGET_EXPAND_BUILTIN alpha_expand_builtin
#undef TARGET_FOLD_BUILTIN
#define TARGET_FOLD_BUILTIN alpha_fold_builtin
#undef TARGET_FUNCTION_OK_FOR_SIBCALL
#define TARGET_FUNCTION_OK_FOR_SIBCALL alpha_function_ok_for_sibcall
#undef TARGET_CANNOT_COPY_INSN_P
#define TARGET_CANNOT_COPY_INSN_P alpha_cannot_copy_insn_p
#undef TARGET_CANNOT_FORCE_CONST_MEM
#define TARGET_CANNOT_FORCE_CONST_MEM alpha_cannot_force_const_mem
#if TARGET_ABI_OSF
#undef TARGET_ASM_OUTPUT_MI_THUNK
#define TARGET_ASM_OUTPUT_MI_THUNK alpha_output_mi_thunk_osf
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
#undef TARGET_STDARG_OPTIMIZE_HOOK
#define TARGET_STDARG_OPTIMIZE_HOOK alpha_stdarg_optimize_hook
#endif
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS alpha_rtx_costs
#undef TARGET_ADDRESS_COST
#define TARGET_ADDRESS_COST hook_int_rtx_bool_0
#undef TARGET_MACHINE_DEPENDENT_REORG
#define TARGET_MACHINE_DEPENDENT_REORG alpha_reorg
#undef TARGET_PROMOTE_FUNCTION_MODE
#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
#undef TARGET_PROMOTE_PROTOTYPES
#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_false
#undef TARGET_RETURN_IN_MEMORY
#define TARGET_RETURN_IN_MEMORY alpha_return_in_memory
#undef TARGET_PASS_BY_REFERENCE
#define TARGET_PASS_BY_REFERENCE alpha_pass_by_reference
#undef TARGET_SETUP_INCOMING_VARARGS
#define TARGET_SETUP_INCOMING_VARARGS alpha_setup_incoming_varargs
#undef TARGET_STRICT_ARGUMENT_NAMING
#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
#undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
#define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
#undef TARGET_SPLIT_COMPLEX_ARG
#define TARGET_SPLIT_COMPLEX_ARG alpha_split_complex_arg
#undef TARGET_GIMPLIFY_VA_ARG_EXPR
#define TARGET_GIMPLIFY_VA_ARG_EXPR alpha_gimplify_va_arg
#undef TARGET_ARG_PARTIAL_BYTES
#define TARGET_ARG_PARTIAL_BYTES alpha_arg_partial_bytes
#undef TARGET_FUNCTION_ARG
#define TARGET_FUNCTION_ARG alpha_function_arg
#undef TARGET_FUNCTION_ARG_ADVANCE
#define TARGET_FUNCTION_ARG_ADVANCE alpha_function_arg_advance
#undef TARGET_TRAMPOLINE_INIT
#define TARGET_TRAMPOLINE_INIT alpha_trampoline_init
#undef TARGET_INSTANTIATE_DECLS
#define TARGET_INSTANTIATE_DECLS alpha_instantiate_decls
#undef TARGET_SECONDARY_RELOAD
#define TARGET_SECONDARY_RELOAD alpha_secondary_reload
#undef TARGET_SCALAR_MODE_SUPPORTED_P
#define TARGET_SCALAR_MODE_SUPPORTED_P alpha_scalar_mode_supported_p
#undef TARGET_VECTOR_MODE_SUPPORTED_P
#define TARGET_VECTOR_MODE_SUPPORTED_P alpha_vector_mode_supported_p
#undef TARGET_BUILD_BUILTIN_VA_LIST
#define TARGET_BUILD_BUILTIN_VA_LIST alpha_build_builtin_va_list
#undef TARGET_EXPAND_BUILTIN_VA_START
#define TARGET_EXPAND_BUILTIN_VA_START alpha_va_start
/* The Alpha architecture does not require sequential consistency. See
http://www.cs.umd.edu/~pugh/java/memoryModel/AlphaReordering.html
for an example of how it can be violated in practice. */
#undef TARGET_RELAXED_ORDERING
#define TARGET_RELAXED_ORDERING true
#undef TARGET_DEFAULT_TARGET_FLAGS
#define TARGET_DEFAULT_TARGET_FLAGS \
(TARGET_DEFAULT | TARGET_CPU_DEFAULT | TARGET_DEFAULT_EXPLICIT_RELOCS)
#undef TARGET_HANDLE_OPTION
#define TARGET_HANDLE_OPTION alpha_handle_option
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE alpha_option_override
#undef TARGET_OPTION_OPTIMIZATION_TABLE
#define TARGET_OPTION_OPTIMIZATION_TABLE alpha_option_optimization_table
#ifdef TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
#undef TARGET_MANGLE_TYPE
#define TARGET_MANGLE_TYPE alpha_mangle_type
#endif
#undef TARGET_LEGITIMATE_ADDRESS_P
#define TARGET_LEGITIMATE_ADDRESS_P alpha_legitimate_address_p
#undef TARGET_CONDITIONAL_REGISTER_USAGE
#define TARGET_CONDITIONAL_REGISTER_USAGE alpha_conditional_register_usage
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-alpha.h"
|