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
|
;; Machine Description for Renesas RX processors
;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
;; Contributed by Red Hat.
;; 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/>.
;; This code iterator is used for sign- and zero- extensions.
(define_mode_iterator small_int_modes [(HI "") (QI "")])
;; This code iterator is used for max and min operations.
(define_mode_iterator int_modes [(SI "") (HI "") (QI "")])
;; We do not handle DFmode here because it is either
;; the same as SFmode, or if -m64bit-doubles is active
;; then all operations on doubles have to be handled by
;; library functions.
(define_mode_iterator register_modes
[(SF "") (SI "") (HI "") (QI "")])
(define_constants
[
(SP_REG 0)
(CC_REG 16)
(UNSPEC_LOW_REG 0)
(UNSPEC_HIGH_REG 1)
(UNSPEC_RTE 10)
(UNSPEC_RTFI 11)
(UNSPEC_NAKED 12)
(UNSPEC_CONST 13)
(UNSPEC_MOVSTR 20)
(UNSPEC_MOVMEM 21)
(UNSPEC_SETMEM 22)
(UNSPEC_STRLEN 23)
(UNSPEC_CMPSTRN 24)
(UNSPEC_BUILTIN_BRK 30)
(UNSPEC_BUILTIN_CLRPSW 31)
(UNSPEC_BUILTIN_INT 32)
(UNSPEC_BUILTIN_MACHI 33)
(UNSPEC_BUILTIN_MACLO 34)
(UNSPEC_BUILTIN_MULHI 35)
(UNSPEC_BUILTIN_MULLO 36)
(UNSPEC_BUILTIN_MVFACHI 37)
(UNSPEC_BUILTIN_MVFACMI 38)
(UNSPEC_BUILTIN_MVFC 39)
(UNSPEC_BUILTIN_MVFCP 40)
(UNSPEC_BUILTIN_MVTACHI 41)
(UNSPEC_BUILTIN_MVTACLO 42)
(UNSPEC_BUILTIN_MVTC 43)
(UNSPEC_BUILTIN_MVTIPL 44)
(UNSPEC_BUILTIN_RACW 45)
(UNSPEC_BUILTIN_REVW 46)
(UNSPEC_BUILTIN_RMPA 47)
(UNSPEC_BUILTIN_ROUND 48)
(UNSPEC_BUILTIN_SAT 49)
(UNSPEC_BUILTIN_SETPSW 50)
(UNSPEC_BUILTIN_WAIT 51)
(UNSPEC_PID_ADDR 52)
]
)
(define_attr "length" "" (const_int 8))
(include "predicates.md")
(include "constraints.md")
;; Pipeline description.
;; The RX only has a single pipeline. It has five stages (fetch,
;; decode, execute, memory access, writeback) each of which normally
;; takes a single CPU clock cycle.
;; The timings attribute consists of two numbers, the first is the
;; throughput, which is the number of cycles the instruction takes
;; to execute and generate a result. The second is the latency
;; which is the effective number of cycles the instruction takes to
;; execute if its result is used by the following instruction. The
;; latency is always greater than or equal to the throughput.
;; These values were taken from tables 2.13 and 2.14 in section 2.8
;; of the RX610 Group Hardware Manual v0.11
;; Note - it would be nice to use strings rather than integers for
;; the possible values of this attribute, so that we can have the
;; gcc build mechanism check for values that are not supported by
;; the reservations below. But this will not work because the code
;; in rx_adjust_sched_cost() needs integers not strings.
(define_attr "timings" "" (const_int 11))
(define_automaton "pipelining")
(define_cpu_unit "throughput" "pipelining")
(define_insn_reservation "throughput__1_latency__1" 1
(eq_attr "timings" "11") "throughput")
(define_insn_reservation "throughput__1_latency__2" 2
(eq_attr "timings" "12") "throughput,nothing")
(define_insn_reservation "throughput__2_latency__2" 1
(eq_attr "timings" "22") "throughput*2")
(define_insn_reservation "throughput__3_latency__3" 1
(eq_attr "timings" "33") "throughput*3")
(define_insn_reservation "throughput__3_latency__4" 2
(eq_attr "timings" "34") "throughput*3,nothing")
(define_insn_reservation "throughput__4_latency__4" 1
(eq_attr "timings" "44") "throughput*4")
(define_insn_reservation "throughput__4_latency__5" 2
(eq_attr "timings" "45") "throughput*4,nothing")
(define_insn_reservation "throughput__5_latency__5" 1
(eq_attr "timings" "55") "throughput*5")
(define_insn_reservation "throughput__5_latency__6" 2
(eq_attr "timings" "56") "throughput*5,nothing")
(define_insn_reservation "throughput__6_latency__6" 1
(eq_attr "timings" "66") "throughput*6")
(define_insn_reservation "throughput_10_latency_10" 1
(eq_attr "timings" "1010") "throughput*10")
(define_insn_reservation "throughput_11_latency_11" 1
(eq_attr "timings" "1111") "throughput*11")
(define_insn_reservation "throughput_16_latency_16" 1
(eq_attr "timings" "1616") "throughput*16")
(define_insn_reservation "throughput_18_latency_18" 1
(eq_attr "timings" "1818") "throughput*18")
;; ----------------------------------------------------------------------------
;; Comparisons
;; Note - we do not specify the two instructions necessary to perform
;; a compare-and-branch in the cbranchsi4 pattern because that would
;; allow the comparison to be moved away from the jump before the reload
;; pass has completed. That would be problematical because reload can
;; generate ADDSI3 instructions which would corrupt the PSW flags.
(define_expand "cbranchsi4"
[(set (pc)
(if_then_else
(match_operator 0 "comparison_operator"
[(match_operand:SI 1 "register_operand")
(match_operand:SI 2 "rx_source_operand")])
(label_ref (match_operand 3 ""))
(pc)))]
""
)
(define_insn_and_split "*cbranchsi4"
[(set (pc)
(if_then_else
(match_operator 3 "comparison_operator"
[(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "rx_source_operand" "riQ")])
(match_operand 2 "label_ref_operand" "")
(pc)))]
""
"#"
"reload_completed"
[(const_int 0)]
{
rx_split_cbranch (CCmode, GET_CODE (operands[3]),
operands[0], operands[1], operands[2]);
DONE;
})
(define_insn "*cmpsi"
[(set (reg:CC CC_REG)
(compare:CC (match_operand:SI 0 "register_operand" "r,r,r,r,r,r,r")
(match_operand:SI 1 "rx_source_operand" "r,Uint04,Int08,Sint16,Sint24,i,Q")))]
"reload_completed"
"cmp\t%Q1, %0"
[(set_attr "timings" "11,11,11,11,11,11,33")
(set_attr "length" "2,2,3,4,5,6,5")]
)
;; Canonical method for representing TST.
(define_insn_and_split "*cbranchsi4_tst"
[(set (pc)
(if_then_else
(match_operator 3 "rx_zs_comparison_operator"
[(and:SI (match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "rx_source_operand" "riQ"))
(const_int 0)])
(match_operand 2 "label_ref_operand" "")
(pc)))]
""
"#"
"reload_completed"
[(const_int 0)]
{
rx_split_cbranch (CC_ZSmode, GET_CODE (operands[3]),
XEXP (operands[3], 0), XEXP (operands[3], 1),
operands[2]);
DONE;
})
;; Various other ways that GCC codes "var & const"
(define_insn_and_split "*cbranchsi4_tst_ext"
[(set (pc)
(if_then_else
(match_operator 4 "rx_z_comparison_operator"
[(zero_extract:SI
(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "rx_constshift_operand" "")
(match_operand:SI 2 "rx_constshift_operand" ""))
(const_int 0)])
(match_operand 3 "label_ref_operand" "")
(pc)))]
""
"#"
"reload_completed"
[(const_int 0)]
{
HOST_WIDE_INT mask;
rtx x;
mask = 1;
mask <<= INTVAL (operands[1]);
mask -= 1;
mask <<= INTVAL (operands[2]);
x = gen_rtx_AND (SImode, operands[0], gen_int_mode (mask, SImode));
rx_split_cbranch (CC_ZSmode, GET_CODE (operands[4]),
x, const0_rtx, operands[3]);
DONE;
})
(define_insn "*tstsi"
[(set (reg:CC_ZS CC_REG)
(compare:CC_ZS
(and:SI (match_operand:SI 0 "register_operand" "r,r,r")
(match_operand:SI 1 "rx_source_operand" "r,i,Q"))
(const_int 0)))]
"reload_completed"
"tst\t%Q1, %0"
[(set_attr "timings" "11,11,33")
(set_attr "length" "3,7,6")]
)
(define_expand "cbranchsf4"
[(set (pc)
(if_then_else
(match_operator 0 "rx_fp_comparison_operator"
[(match_operand:SF 1 "register_operand")
(match_operand:SF 2 "rx_source_operand")])
(label_ref (match_operand 3 ""))
(pc)))]
"ALLOW_RX_FPU_INSNS"
)
(define_insn_and_split "*cbranchsf4"
[(set (pc)
(if_then_else
(match_operator 3 "rx_fp_comparison_operator"
[(match_operand:SF 0 "register_operand" "r")
(match_operand:SF 1 "rx_source_operand" "rFQ")])
(match_operand 2 "label_ref_operand" "")
(pc)))]
"ALLOW_RX_FPU_INSNS"
"#"
"&& reload_completed"
[(const_int 0)]
{
rx_split_cbranch (CC_Fmode, GET_CODE (operands[3]),
operands[0], operands[1], operands[2]);
DONE;
})
(define_insn "*cmpsf"
[(set (reg:CC_F CC_REG)
(compare:CC_F
(match_operand:SF 0 "register_operand" "r,r,r")
(match_operand:SF 1 "rx_source_operand" "r,F,Q")))]
"ALLOW_RX_FPU_INSNS && reload_completed"
"fcmp\t%1, %0"
[(set_attr "timings" "11,11,33")
(set_attr "length" "3,7,5")]
)
;; Flow Control Instructions:
(define_insn "*conditional_branch"
[(set (pc)
(if_then_else
(match_operator 1 "comparison_operator"
[(reg CC_REG) (const_int 0)])
(label_ref (match_operand 0 "" ""))
(pc)))]
"reload_completed"
"b%B1\t%0"
[(set_attr "length" "8") ;; This length is wrong, but it is
;; too hard to compute statically.
(set_attr "timings" "33")] ;; The timing assumes that the branch is taken.
)
;; ----------------------------------------------------------------------------
(define_insn "jump"
[(set (pc)
(label_ref (match_operand 0 "" "")))]
""
"bra\t%0"
[(set_attr "length" "4")
(set_attr "timings" "33")]
)
(define_insn "indirect_jump"
[(set (pc)
(match_operand:SI 0 "register_operand" "r"))]
""
"jmp\t%0"
[(set_attr "length" "2")
(set_attr "timings" "33")]
)
(define_insn "tablejump"
[(set (pc)
(match_operand:SI 0 "register_operand" "r"))
(use (label_ref (match_operand 1 "" "")))]
""
{ return TARGET_PID ? (TARGET_AS100_SYNTAX ? "\n?:\tbra\t%0"
: "\n1:\tbra\t%0")
: "\n1:jmp\t%0";
}
[(set_attr "timings" "33")
(set_attr "length" "2")]
)
(define_expand "return"
[(return)]
"rx_can_use_simple_return ()"
"rx_expand_epilogue (false); DONE;"
)
(define_insn "simple_return"
[(simple_return)]
""
"rts"
[(set_attr "length" "1")
(set_attr "timings" "55")]
)
;; Unspec used so that the constant will not be invalid
;; if -mmax-constant-size has been specified.
(define_insn "deallocate_and_return"
[(set (reg:SI SP_REG)
(plus:SI (reg:SI SP_REG)
(const:SI (unspec:SI [(match_operand 0 "const_int_operand" "n")] UNSPEC_CONST))))
(return)]
""
"rtsd\t%0"
[(set_attr "length" "2")
(set_attr "timings" "55")]
)
(define_insn "pop_and_return"
[(match_parallel 1 "rx_rtsd_vector"
[(set (reg:SI SP_REG)
(plus:SI (reg:SI SP_REG)
(match_operand:SI 0 "const_int_operand" "n")))])
(return)]
"reload_completed"
{
rx_emit_stack_popm (operands, false);
return "";
}
[(set_attr "length" "3")
(set_attr "timings" "56")]
)
(define_insn "fast_interrupt_return"
[(unspec_volatile [(return)] UNSPEC_RTFI) ]
""
"rtfi"
[(set_attr "length" "2")
(set_attr "timings" "33")]
)
(define_insn "exception_return"
[(unspec_volatile [(return)] UNSPEC_RTE) ]
""
"rte"
[(set_attr "length" "2")
(set_attr "timings" "66")]
)
(define_insn "naked_return"
[(unspec_volatile [(return)] UNSPEC_NAKED) ]
""
"; Naked function: epilogue provided by programmer."
)
;; Note - the following set of patterns do not use the "memory_operand"
;; predicate or an "m" constraint because we do not allow symbol_refs
;; or label_refs as legitimate memory addresses. This matches the
;; behaviour of most of the RX instructions. Only the call/branch
;; instructions are allowed to refer to symbols/labels directly.
;; The call operands are in QImode because that is the value of
;; FUNCTION_MODE
(define_expand "call"
[(call (match_operand:QI 0 "general_operand")
(match_operand:SI 1 "general_operand"))]
""
{
rtx dest = XEXP (operands[0], 0);
if (! rx_call_operand (dest, Pmode))
dest = force_reg (Pmode, dest);
emit_call_insn (gen_call_internal (dest));
DONE;
}
)
(define_insn "call_internal"
[(call (mem:QI (match_operand:SI 0 "rx_call_operand" "r,Symbol"))
(const_int 0))
(clobber (reg:CC CC_REG))]
""
"@
jsr\t%0
bsr\t%A0"
[(set_attr "length" "2,4")
(set_attr "timings" "33")]
)
(define_expand "call_value"
[(set (match_operand 0 "register_operand")
(call (match_operand:QI 1 "general_operand")
(match_operand:SI 2 "general_operand")))]
""
{
rtx dest = XEXP (operands[1], 0);
if (! rx_call_operand (dest, Pmode))
dest = force_reg (Pmode, dest);
emit_call_insn (gen_call_value_internal (operands[0], dest));
DONE;
}
)
(define_insn "call_value_internal"
[(set (match_operand 0 "register_operand" "=r,r")
(call (mem:QI (match_operand:SI 1 "rx_call_operand" "r,Symbol"))
(const_int 0)))
(clobber (reg:CC CC_REG))]
""
"@
jsr\t%1
bsr\t%A1"
[(set_attr "length" "2,4")
(set_attr "timings" "33")]
)
;; Note - we do not allow indirect sibcalls (with the address
;; held in a register) because we cannot guarantee that the register
;; chosen will be a call-used one. If it is a call-saved register,
;; then the epilogue code will corrupt it by popping the saved value
;; off of the stack.
(define_expand "sibcall"
[(parallel
[(call (mem:QI (match_operand:SI 0 "rx_symbolic_call_operand"))
(match_operand:SI 1 "general_operand"))
(return)])]
""
{
if (MEM_P (operands[0]))
operands[0] = XEXP (operands[0], 0);
emit_call_insn (gen_sibcall_internal (operands[0]));
DONE;
}
)
(define_insn "sibcall_internal"
[(call (mem:QI (match_operand:SI 0 "rx_symbolic_call_operand" "Symbol"))
(const_int 0))
(return)]
""
"bra\t%A0"
[(set_attr "length" "4")
(set_attr "timings" "33")]
)
(define_expand "sibcall_value"
[(parallel
[(set (match_operand 0 "register_operand")
(call (mem:QI (match_operand:SI 1 "rx_symbolic_call_operand"))
(match_operand:SI 2 "general_operand")))
(return)])]
""
{
if (MEM_P (operands[1]))
operands[1] = XEXP (operands[1], 0);
emit_call_insn (gen_sibcall_value_internal (operands[0], operands[1]));
DONE;
}
)
(define_insn "sibcall_value_internal"
[(set (match_operand 0 "register_operand" "=r")
(call (mem:QI (match_operand:SI 1 "rx_symbolic_call_operand" "Symbol"))
(const_int 0)))
(return)]
""
"bra\t%A1"
[(set_attr "length" "4")
(set_attr "timings" "33")]
)
;; Function Prologue/Epilogue Instructions
(define_expand "prologue"
[(const_int 0)]
""
"rx_expand_prologue (); DONE;"
)
(define_expand "epilogue"
[(return)]
""
"rx_expand_epilogue (false); DONE;"
)
(define_expand "sibcall_epilogue"
[(return)]
""
"rx_expand_epilogue (true); DONE;"
)
;; Move Instructions
;; Note - we do not allow memory to memory moves, even though the ISA
;; supports them. The reason is that the conditions on such moves are
;; too restrictive, specifically the source addressing mode is limited
;; by the destination addressing mode and vice versa. (For example it
;; is not possible to use indexed register indirect addressing for one
;; of the operands if the other operand is anything other than a register,
;; but it is possible to use register relative addressing when the other
;; operand also uses register relative or register indirect addressing).
;;
;; GCC does not support computing legitimate addresses based on the
;; nature of other operands involved in the instruction, and reload is
;; not smart enough to cope with a whole variety of different memory
;; addressing constraints, so it is simpler and safer to just refuse
;; to support memory to memory moves.
(define_expand "mov<register_modes:mode>"
[(set (match_operand:register_modes 0 "general_operand")
(match_operand:register_modes 1 "general_operand"))]
""
{
if (MEM_P (operands[0]) && MEM_P (operands[1]))
operands[1] = copy_to_mode_reg (<register_modes:MODE>mode, operands[1]);
operands[0] = rx_maybe_pidify_operand (operands[0], 0);
operands[1] = rx_maybe_pidify_operand (operands[1], 0);
if (GET_CODE (operands[0]) != REG
&& GET_CODE (operands[1]) == PLUS)
operands[1] = copy_to_mode_reg (<register_modes:MODE>mode, operands[1]);
if (GET_CODE (operands[1]) == PLUS && GET_MODE (operands[1]) == SImode)
{
emit_insn (gen_addsi3 (operands[0], XEXP (operands[1], 0), XEXP (operands[1], 1)));
DONE;
}
if (CONST_INT_P (operand1)
&& ! rx_is_legitimate_constant (<register_modes:MODE>mode, operand1))
FAIL;
}
)
(define_insn "*mov<register_modes:mode>_internal"
[(set (match_operand:register_modes
0 "nonimmediate_operand" "=r,r,r,r,r,r,m,Q,Q,Q,Q,r")
(match_operand:register_modes
1 "general_operand" "Int08,Sint16,Sint24,i,r,m,r,Int08,Sint16,Sint24,i,RpdaRpid"))]
""
{ return rx_gen_move_template (operands, false); }
[(set_attr "length" "3,4,5,6,2,4,6,5,6,7,8,8")
(set_attr "timings" "11,11,11,11,11,12,11,11,11,11,11,11")]
)
(define_insn "extend<small_int_modes:mode>si2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(sign_extend:SI (match_operand:small_int_modes
1 "nonimmediate_operand" "r,m")))]
""
{ return rx_gen_move_template (operands, false); }
[(set_attr "length" "2,6")
(set_attr "timings" "11,12")]
)
(define_insn "zero_extend<small_int_modes:mode>si2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(zero_extend:SI (match_operand:small_int_modes
1 "nonimmediate_operand" "r,m")))]
""
{ return rx_gen_move_template (operands, true); }
[(set_attr "length" "2,4")
(set_attr "timings" "11,12")]
)
(define_insn "stack_push"
[(set (reg:SI SP_REG)
(minus:SI (reg:SI SP_REG)
(const_int 4)))
(set (mem:SI (reg:SI SP_REG))
(match_operand:SI 0 "register_operand" "r"))]
""
"push.l\t%0"
[(set_attr "length" "2")]
)
(define_insn "stack_pushm"
[(match_parallel 1 "rx_store_multiple_vector"
[(set (reg:SI SP_REG)
(minus:SI (reg:SI SP_REG)
(match_operand:SI 0 "const_int_operand" "n")))])]
"reload_completed"
{
rx_emit_stack_pushm (operands);
return "";
}
[(set_attr "length" "2")
(set_attr "timings" "44")] ;; The timing is a guesstimate average timing.
)
(define_insn "stack_pop"
[(set (match_operand:SI 0 "register_operand" "=r")
(mem:SI (reg:SI SP_REG)))
(set (reg:SI SP_REG)
(plus:SI (reg:SI SP_REG)
(const_int 4)))]
""
"pop\t%0"
[(set_attr "length" "2")
(set_attr "timings" "12")]
)
(define_insn "stack_popm"
[(match_parallel 1 "rx_load_multiple_vector"
[(set (reg:SI SP_REG)
(plus:SI (reg:SI SP_REG)
(match_operand:SI 0 "const_int_operand" "n")))])]
"reload_completed"
{
rx_emit_stack_popm (operands, true);
return "";
}
[(set_attr "length" "2")
(set_attr "timings" "45")] ;; The timing is a guesstimate average timing.
)
(define_insn_and_split "cstoresi4"
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operator:SI 1 "comparison_operator"
[(match_operand:SI 2 "register_operand" "r")
(match_operand:SI 3 "rx_source_operand" "riQ")]))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(const_int 0)]
{
rtx flags, x;
flags = gen_rtx_REG (CCmode, CC_REG);
x = gen_rtx_COMPARE (CCmode, operands[2], operands[3]);
x = gen_rtx_SET (VOIDmode, flags, x);
emit_insn (x);
x = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode, flags, const0_rtx);
x = gen_rtx_SET (VOIDmode, operands[0], x);
emit_insn (x);
DONE;
})
(define_insn "*sccc"
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operator:SI 1 "comparison_operator"
[(reg CC_REG) (const_int 0)]))]
"reload_completed"
"sc%B1.L\t%0"
[(set_attr "length" "3")]
)
(define_insn_and_split "cstoresf4"
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operator:SI 1 "rx_fp_comparison_operator"
[(match_operand:SF 2 "register_operand" "r")
(match_operand:SF 3 "rx_source_operand" "rFQ")]))]
"ALLOW_RX_FPU_INSNS"
"#"
"reload_completed"
[(const_int 0)]
{
rtx flags, x;
flags = gen_rtx_REG (CC_Fmode, CC_REG);
x = gen_rtx_COMPARE (CC_Fmode, operands[2], operands[3]);
x = gen_rtx_SET (VOIDmode, flags, x);
emit_insn (x);
x = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode, flags, const0_rtx);
x = gen_rtx_SET (VOIDmode, operands[0], x);
emit_insn (x);
DONE;
})
(define_expand "movsicc"
[(parallel
[(set (match_operand:SI 0 "register_operand")
(if_then_else:SI (match_operand:SI 1 "comparison_operator")
(match_operand:SI 2 "nonmemory_operand")
(match_operand:SI 3 "nonmemory_operand")))
(clobber (reg:CC CC_REG))])]
""
{
/* One operand must be a constant or a register, the other must be a register. */
if ( ! CONSTANT_P (operands[2])
&& ! CONSTANT_P (operands[3])
&& ! (REG_P (operands[2]) && REG_P (operands[3])))
FAIL;
})
(define_insn_and_split "*movsicc"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(if_then_else:SI
(match_operator 5 "comparison_operator"
[(match_operand:SI 3 "register_operand" "r,r,r")
(match_operand:SI 4 "rx_source_operand" "riQ,riQ,riQ")])
(match_operand:SI 1 "nonmemory_operand" "i,ri,r")
(match_operand:SI 2 "nonmemory_operand" "ri,i,r")))
(clobber (reg:CC CC_REG))]
"(CONSTANT_P (operands[1]) || CONSTANT_P (operands[2]))
|| (REG_P (operands[1]) && REG_P (operands[2]))"
"#"
"&& reload_completed"
[(const_int 0)]
{
rtx x, flags, op0, op1, op2;
enum rtx_code cmp_code;
flags = gen_rtx_REG (CCmode, CC_REG);
x = gen_rtx_COMPARE (CCmode, operands[3], operands[4]);
emit_insn (gen_rtx_SET (VOIDmode, flags, x));
cmp_code = GET_CODE (operands[5]);
op0 = operands[0];
op1 = operands[1];
op2 = operands[2];
/* If OP2 is the constant, reverse the sense of the move.
Likewise if both operands are registers but OP1 == OP0. */
if ((! CONSTANT_P (operands[1]) && CONSTANT_P (operands[2]))
|| (REG_P (operands[1]) && REG_P (operands[2])
&& rtx_equal_p (op0, op1)))
{
x = op1, op1 = op2, op2 = x;
cmp_code = reverse_condition (cmp_code);
}
/* If OP2 does not match the output, copy it into place. We have allowed
these alternatives so that the destination can legitimately be one of
the comparison operands without increasing register pressure. */
if (! rtx_equal_p (op0, op2))
emit_move_insn (op0, op2);
x = gen_rtx_fmt_ee (cmp_code, VOIDmode, flags, const0_rtx);
x = gen_rtx_IF_THEN_ELSE (SImode, x, op1, op0);
emit_insn (gen_rtx_SET (VOIDmode, op0, x));
DONE;
})
(define_insn "*stcc"
[(set (match_operand:SI 0 "register_operand" "+r,r,r,r")
(if_then_else:SI
(match_operator 2 "rx_z_comparison_operator"
[(reg CC_REG) (const_int 0)])
(match_operand:SI 1 "immediate_operand" "Sint08,Sint16,Sint24,i")
(match_dup 0)))]
"reload_completed
&& ((GET_CODE (operands[2]) == EQ) || (GET_CODE (operands[2]) == NE))"
{
if (GET_CODE (operands[2]) == EQ)
return "stz\t%1, %0";
else
return "stnz\t%1, %0";
}
[(set_attr "length" "4,5,6,7")]
)
(define_insn "*stcc_reg"
[(set (match_operand:SI 0 "register_operand" "+r,r,r,r,r,r")
(if_then_else:SI
(match_operator 2 "comparison_operator"
[(reg CC_REG) (const_int 0)])
(match_operand:SI 1 "nonmemory_operand"
"r,Uint04,Sint08,Sint16,Sint24,i")
(match_dup 0)))]
"reload_completed"
{
PUT_CODE (operands[2], reverse_condition (GET_CODE (operands[2])));
return "b%B2 1f\n\tmov %1, %0\n1:";
}
[(set_attr "length" "3,3,4,5,6,7")]
)
;; Arithmetic Instructions
(define_insn "abssi2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(abs:SI (match_operand:SI 1 "register_operand" "0,r")))
(clobber (reg:CC CC_REG))]
""
"@
abs\t%0
abs\t%1, %0"
[(set_attr "length" "2,3")]
)
(define_insn "*abssi2_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(abs:SI (match_operand:SI 1 "register_operand" "0,r")))
(set (reg CC_REG)
(compare (abs:SI (match_dup 1))
(const_int 0)))]
;; Note - although the ABS instruction does set the O bit in the processor
;; status word, it does not do so in a way that is comparable with the CMP
;; instruction. Hence we use CC_ZSmode rather than CC_ZSOmode.
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
abs\t%0
abs\t%1, %0"
[(set_attr "length" "2,3")]
)
(define_expand "addsi3"
[(parallel [(set (match_operand:SI 0 "register_operand" "")
(plus:SI (match_operand:SI 1 "register_operand" "")
(match_operand:SI 2 "rx_source_operand" "")))
(clobber (reg:CC CC_REG))])]
""
"
operands[0] = rx_maybe_pidify_operand (operands[0], 1);
operands[1] = rx_maybe_pidify_operand (operands[1], 1);
operands[2] = rx_maybe_pidify_operand (operands[2], 1);
"
)
(define_insn "addsi3_internal"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r,r,r,r,r,r")
(plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,0,r,r,r,r,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,NEGint4,Sint08,Sint16,Sint24,i,0,r,Sint08,Sint16,Sint24,i,Q")))
(clobber (reg:CC CC_REG))]
""
"@
add\t%2, %0
add\t%2, %0
sub\t%N2, %0
add\t%2, %0
add\t%2, %0
add\t%2, %0
add\t%2, %0
add\t%1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,2,3,4,5,6,2,3,3,4,5,6,5")]
)
(define_insn "*addsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r,r,r,r,r,r")
(plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,0,r,r,r,r,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,NEGint4,Sint08,Sint16,Sint24,i,0,r,Sint08,Sint16,Sint24,i,Q")))
(set (reg CC_REG)
(compare (plus:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSCmode)"
"@
add\t%2, %0
add\t%2, %0
sub\t%N2, %0
add\t%2, %0
add\t%2, %0
add\t%2, %0
add\t%2, %0
add\t%1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%2, %1, %0
add\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,2,3,4,5,6,2,3,3,4,5,6,5")]
)
;; A helper to expand the above with the CC_MODE filled in.
(define_expand "addsi3_flags"
[(parallel [(set (match_operand:SI 0 "register_operand")
(plus:SI (match_operand:SI 1 "register_operand")
(match_operand:SI 2 "rx_source_operand")))
(set (reg:CC_ZSC CC_REG)
(compare:CC_ZSC (plus:SI (match_dup 1) (match_dup 2))
(const_int 0)))])]
)
(define_insn "adc_internal"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(plus:SI
(plus:SI
(ltu:SI (reg:CC CC_REG) (const_int 0))
(match_operand:SI 1 "register_operand" "%0,0,0,0,0,0"))
(match_operand:SI 2 "rx_source_operand" "r,Sint08,Sint16,Sint24,i,Q")))
(clobber (reg:CC CC_REG))]
"reload_completed"
"adc\t%2, %0"
[(set_attr "timings" "11,11,11,11,11,33")
(set_attr "length" "3,4,5,6,7,6")]
)
(define_insn "*adc_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(plus:SI
(plus:SI
(ltu:SI (reg:CC CC_REG) (const_int 0))
(match_operand:SI 1 "register_operand" "%0,0,0,0,0,0"))
(match_operand:SI 2 "rx_source_operand" "r,Sint08,Sint16,Sint24,i,Q")))
(set (reg CC_REG)
(compare
(plus:SI
(plus:SI
(ltu:SI (reg:CC CC_REG) (const_int 0))
(match_dup 1))
(match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSCmode)"
"adc\t%2, %0"
[(set_attr "timings" "11,11,11,11,11,33")
(set_attr "length" "3,4,5,6,7,6")]
)
;; Peepholes to match:
;; (set (reg A) (reg B))
;; (set (CC) (compare:CC (reg A/reg B) (const_int 0)))
;; and replace them with the addsi3_flags pattern, using an add
;; of zero to copy the register and set the condition code bits.
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(match_operand:SI 1 "register_operand"))
(set (reg:CC CC_REG)
(compare:CC (match_dup 0)
(const_int 0)))]
""
[(parallel [(set (match_dup 0)
(plus:SI (match_dup 1) (const_int 0)))
(set (reg:CC_ZSC CC_REG)
(compare:CC_ZSC (plus:SI (match_dup 1) (const_int 0))
(const_int 0)))])]
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(match_operand:SI 1 "register_operand"))
(set (reg:CC CC_REG)
(compare:CC (match_dup 1)
(const_int 0)))]
""
[(parallel [(set (match_dup 0)
(plus:SI (match_dup 1) (const_int 0)))
(set (reg:CC_ZSC CC_REG)
(compare:CC_ZSC (plus:SI (match_dup 1) (const_int 0))
(const_int 0)))])]
)
(define_expand "adddi3"
[(set (match_operand:DI 0 "register_operand")
(plus:DI (match_operand:DI 1 "register_operand")
(match_operand:DI 2 "rx_source_operand")))]
""
{
rtx op0l, op0h, op1l, op1h, op2l, op2h;
op0l = gen_lowpart (SImode, operands[0]);
op1l = gen_lowpart (SImode, operands[1]);
op2l = gen_lowpart (SImode, operands[2]);
op0h = gen_highpart (SImode, operands[0]);
op1h = gen_highpart (SImode, operands[1]);
op2h = gen_highpart_mode (SImode, DImode, operands[2]);
emit_insn (gen_adddi3_internal (op0l, op0h, op1l, op2l, op1h, op2h));
DONE;
})
(define_insn_and_split "adddi3_internal"
[(set (match_operand:SI 0 "register_operand" "=&r")
(plus:SI (match_operand:SI 2 "register_operand" "r")
(match_operand:SI 3 "rx_source_operand" "riQ")))
(set (match_operand:SI 1 "register_operand" "=r")
(plus:SI
(plus:SI
(ltu:SI (plus:SI (match_dup 2) (match_dup 3)) (match_dup 2))
(match_operand:SI 4 "register_operand" "%1"))
(match_operand:SI 5 "rx_source_operand" "riQ")))
(clobber (match_scratch:SI 6 "=&r"))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(const_int 0)]
{
rtx op0l = operands[0];
rtx op0h = operands[1];
rtx op1l = operands[2];
rtx op2l = operands[3];
rtx op1h = operands[4];
rtx op2h = operands[5];
rtx scratch = operands[6];
rtx x;
if (reg_overlap_mentioned_p (op0l, op1h))
{
emit_move_insn (scratch, op0l);
op1h = scratch;
if (reg_overlap_mentioned_p (op0l, op2h))
op2h = scratch;
}
else if (reg_overlap_mentioned_p (op0l, op2h))
{
emit_move_insn (scratch, op0l);
op2h = scratch;
}
if (rtx_equal_p (op0l, op1l))
;
/* It is preferable that op0l == op1l... */
else if (rtx_equal_p (op0l, op2l))
x = op1l, op1l = op2l, op2l = x;
/* ... but it is only a requirement if op2l == MEM. */
else if (MEM_P (op2l))
{
/* Let's hope that we still have a scratch register free. */
gcc_assert (op1h != scratch);
emit_move_insn (scratch, op2l);
op2l = scratch;
}
emit_insn (gen_addsi3_flags (op0l, op1l, op2l));
if (rtx_equal_p (op0h, op1h))
;
else if (rtx_equal_p (op0h, op2h))
x = op1h, op1h = op2h, op2h = x;
else
{
emit_move_insn (op0h, op1h);
op1h = op0h;
}
emit_insn (gen_adc_internal (op0h, op1h, op2h));
DONE;
})
(define_insn "andsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r")
(and:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,Sint08,Sint16,Sint24,i,0,r,Q")))
(clobber (reg:CC CC_REG))]
""
"@
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%1, %0
and\t%2, %1, %0
and\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,3,4,5,6,2,5,5")]
)
(define_insn "*andsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r")
(and:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,Sint08,Sint16,Sint24,i,0,r,Q")))
(set (reg CC_REG)
(compare (and:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%2, %0
and\t%1, %0
and\t%2, %1, %0
and\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,3,4,5,6,2,5,5")]
)
;; Byte swap (single 32-bit value).
(define_insn "bswapsi2"
[(set (match_operand:SI 0 "register_operand" "=r")
(bswap:SI (match_operand:SI 1 "register_operand" "r")))]
""
"revl\t%1, %0"
[(set_attr "length" "3")]
)
;; Byte swap (single 16-bit value). Note - we ignore the swapping of the high 16-bits.
(define_insn "bswaphi2"
[(set (match_operand:HI 0 "register_operand" "=r")
(bswap:HI (match_operand:HI 1 "register_operand" "r")))]
""
"revw\t%1, %0"
[(set_attr "length" "3")]
)
(define_insn "divsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(div:SI (match_operand:SI 1 "register_operand" "0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand" "r,Sint08,Sint16,Sint24,i,Q")))
(clobber (reg:CC CC_REG))]
""
"div\t%Q2, %0"
[(set_attr "timings" "1111") ;; Strictly speaking the timing should be
;; 2222, but that is a worst case sceanario.
(set_attr "length" "3,4,5,6,7,6")]
)
(define_insn "udivsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(udiv:SI (match_operand:SI 1 "register_operand" "0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand" "r,Sint08,Sint16,Sint24,i,Q")))
(clobber (reg:CC CC_REG))]
""
"divu\t%Q2, %0"
[(set_attr "timings" "1010") ;; Strictly speaking the timing should be
;; 2020, but that is a worst case sceanario.
(set_attr "length" "3,4,5,6,7,6")]
)
;; Note - these patterns are suppressed in big-endian mode because they
;; generate a little endian result. ie the most significant word of the
;; result is placed in the higher numbered register of the destination
;; register pair.
(define_insn "mulsidi3"
[(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r")
(mult:DI (sign_extend:DI (match_operand:SI
1 "register_operand" "%0,0,0,0,0,0"))
(sign_extend:DI (match_operand:SI
2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q"))))]
"! TARGET_BIG_ENDIAN_DATA"
"emul\t%Q2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "22,22,22,22,22,44")]
)
;; See comment for mulsidi3.
;; Note - the zero_extends are to distinguish this pattern from the
;; mulsidi3 pattern. Immediate mode addressing is not supported
;; because gcc cannot handle the expression: (zero_extend (const_int)).
(define_insn "umulsidi3"
[(set (match_operand:DI 0 "register_operand" "=r,r")
(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0,0"))
(zero_extend:DI (match_operand:SI 2 "rx_compare_operand" "r,Q"))))]
"! TARGET_BIG_ENDIAN_DATA"
"emulu\t%Q2, %0"
[(set_attr "length" "3,6")
(set_attr "timings" "22,44")]
)
(define_insn "smaxsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(smax:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))]
""
"max\t%Q2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "11,11,11,11,11,33")]
)
(define_insn "sminsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(smin:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))]
""
"min\t%Q2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "11,11,11,11,11,33")]
)
(define_insn "umax<small_int_modes:mode>3_u"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(smax:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
(zero_extend:SI (match_operand:small_int_modes 2 "rx_minmaxex_operand"
"r,Sint08,Sint16,Sint24,i,Q"))))]
""
"max\t%R2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "11,11,11,11,11,33")]
)
(define_insn "umin<small_int_modes:mode>3_ur"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(smin:SI (zero_extend:SI (match_operand:small_int_modes 2 "rx_minmaxex_operand"
"r,Sint08,Sint16,Sint24,i,Q"))
(match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")))]
""
"min\t%R2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "11,11,11,11,11,33")]
)
(define_insn "umax<small_int_modes:mode>3_ur"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(smax:SI (zero_extend:SI (match_operand:small_int_modes 2 "rx_minmaxex_operand"
"r,Sint08,Sint16,Sint24,i,Q"))
(match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")))]
""
"max\t%R2, %0"
[(set_attr "length" "3,4,5,6,7,6")
(set_attr "timings" "11,11,11,11,11,33")]
)
(define_expand "umax<small_int_modes:mode>3"
[(set (match_dup 4)
(zero_extend:SI (match_operand:small_int_modes 1 "register_operand" "%0,0,0,0,0,0")))
(set (match_dup 3)
(smax:SI (match_dup 4)
(match_operand:small_int_modes 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))
(set (match_operand:small_int_modes 0 "register_operand" "=r,r,r,r,r,r")
(match_dup 6))
]
""
"operands[3] = gen_reg_rtx (SImode);
operands[4] = gen_reg_rtx (SImode);
operands[5] = gen_reg_rtx (SImode);
operands[6] = gen_rtx_SUBREG (GET_MODE (operands[0]), operands[3],
TARGET_BIG_ENDIAN_DATA ? (GET_MODE (operands[0]) == HImode ? 2 : 3) : 0);
if (GET_CODE (operands[2]) != CONST_INT)
{
emit_move_insn (operands[5], gen_rtx_ZERO_EXTEND (SImode, operands[2]));
operands[2] = operands[5];
}
"
)
(define_expand "umin<small_int_modes:mode>3"
[(set (match_dup 4)
(zero_extend:SI (match_operand:small_int_modes 1 "register_operand" "%0,0,0,0,0,0")))
(set (match_dup 3)
(smin:SI (match_dup 4)
(match_operand:small_int_modes 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))
(set (match_operand:small_int_modes 0 "register_operand" "=r,r,r,r,r,r")
(match_dup 6))
]
""
"operands[3] = gen_reg_rtx (SImode);
operands[4] = gen_reg_rtx (SImode);
operands[5] = gen_reg_rtx (SImode);
operands[6] = gen_rtx_SUBREG (GET_MODE (operands[0]), operands[3],
TARGET_BIG_ENDIAN_DATA ? (GET_MODE (operands[0]) == HImode ? 2 : 3) : 0);
if (GET_CODE (operands[2]) != CONST_INT)
{
emit_move_insn (operands[5], gen_rtx_ZERO_EXTEND (SImode, operands[2]));
operands[2] = operands[5];
}
"
)
(define_insn "mulsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r")
(mult:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,0,r,r")
(match_operand:SI 2 "rx_source_operand"
"r,Uint04,Sint08,Sint16,Sint24,i,Q,0,r")))]
""
"@
mul\t%2, %0
mul\t%2, %0
mul\t%2, %0
mul\t%2, %0
mul\t%2, %0
mul\t%Q2, %0
mul\t%Q2, %0
mul\t%1, %0
mul\t%2, %1, %0"
[(set_attr "length" "2,2,3,4,5,6,5,2,3")
(set_attr "timings" "11,11,11,11,11,11,33,11,11")]
)
(define_insn "negsi2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(neg:SI (match_operand:SI 1 "register_operand" "0,r")))
(clobber (reg:CC CC_REG))]
""
"@
neg\t%0
neg\t%1, %0"
[(set_attr "length" "2,3")]
)
;; Note that the O and C flags are not set as per a normal compare,
;; and thus are unusable in that context.
(define_insn "*negsi2_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(neg:SI (match_operand:SI 1 "register_operand" "0,r")))
(set (reg CC_REG)
(compare (neg:SI (match_dup 1))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
neg\t%0
neg\t%1, %0"
[(set_attr "length" "2,3")]
)
(define_insn "one_cmplsi2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(not:SI (match_operand:SI 1 "register_operand" "0,r")))
(clobber (reg:CC CC_REG))]
""
"@
not\t%0
not\t%1, %0"
[(set_attr "length" "2,3")]
)
(define_insn "*one_cmplsi2_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(not:SI (match_operand:SI 1 "register_operand" "0,r")))
(set (reg CC_REG)
(compare (not:SI (match_dup 1))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
not\t%0
not\t%1, %0"
[(set_attr "length" "2,3")]
)
(define_insn "iorsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r")
(ior:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,Sint08,Sint16,Sint24,i,0,r,Q")))
(clobber (reg:CC CC_REG))]
""
"@
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%Q2, %0
or\t%1, %0
or\t%2, %1, %0
or\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,3,4,5,6,2,3,5")]
)
(define_insn "*iorsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r,r")
(ior:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,Sint08,Sint16,Sint24,i,0,r,Q")))
(set (reg CC_REG)
(compare (ior:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%2, %0
or\t%Q2, %0
or\t%1, %0
or\t%2, %1, %0
or\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,11,11,11,33")
(set_attr "length" "2,2,3,4,5,6,2,3,5")]
)
(define_insn "rotlsi3"
[(set (match_operand:SI 0 "register_operand" "=r")
(rotate:SI (match_operand:SI 1 "register_operand" "0")
(match_operand:SI 2 "rx_shift_operand" "rn")))
(clobber (reg:CC CC_REG))]
""
"rotl\t%2, %0"
[(set_attr "length" "3")]
)
(define_insn "*rotlsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r")
(rotate:SI (match_operand:SI 1 "register_operand" "0")
(match_operand:SI 2 "rx_shift_operand" "rn")))
(set (reg CC_REG)
(compare (rotate:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"rotl\t%2, %0"
[(set_attr "length" "3")]
)
(define_insn "rotrsi3"
[(set (match_operand:SI 0 "register_operand" "=r")
(rotatert:SI (match_operand:SI 1 "register_operand" "0")
(match_operand:SI 2 "rx_shift_operand" "rn")))
(clobber (reg:CC CC_REG))]
""
"rotr\t%2, %0"
[(set_attr "length" "3")]
)
(define_insn "*rotrsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r")
(rotatert:SI (match_operand:SI 1 "register_operand" "0")
(match_operand:SI 2 "rx_shift_operand" "rn")))
(set (reg CC_REG)
(compare (rotatert:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"rotr\t%2, %0"
[(set_attr "length" "3")]
)
(define_insn "ashrsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(clobber (reg:CC CC_REG))]
""
"@
shar\t%2, %0
shar\t%2, %0
shar\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
(define_insn "*ashrsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(set (reg CC_REG)
(compare (ashiftrt:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
shar\t%2, %0
shar\t%2, %0
shar\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
(define_insn "lshrsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(clobber (reg:CC CC_REG))]
""
"@
shlr\t%2, %0
shlr\t%2, %0
shlr\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
(define_insn "*lshrsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(set (reg CC_REG)
(compare (lshiftrt:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
shlr\t%2, %0
shlr\t%2, %0
shlr\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
(define_insn "ashlsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(clobber (reg:CC CC_REG))]
""
"@
shll\t%2, %0
shll\t%2, %0
shll\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
(define_insn "*ashlsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
(match_operand:SI 2 "rx_shift_operand" "r,n,n")))
(set (reg CC_REG)
(compare (ashift:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"@
shll\t%2, %0
shll\t%2, %0
shll\t%2, %1, %0"
[(set_attr "length" "3,2,3")]
)
;; Saturate to 32-bits
(define_insn_and_split "ssaddsi3"
[(set (match_operand:SI 0 "register_operand" "=r")
(ss_plus:SI (match_operand:SI 1 "register_operand" "r")
(match_operand:SI 2 "rx_source_operand" "riQ")))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(parallel [(set (match_dup 0)
(plus:SI (match_dup 1) (match_dup 2)))
(set (reg:CC_ZSC CC_REG)
(compare:CC_ZSC
(plus:SI (match_dup 1) (match_dup 2))
(const_int 0)))])
(set (match_dup 0)
(unspec:SI [(match_dup 0) (reg:CC CC_REG)]
UNSPEC_BUILTIN_SAT))]
""
)
(define_insn "*sat"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(match_operand:SI 1 "register_operand" "0")
(reg:CC CC_REG)]
UNSPEC_BUILTIN_SAT))]
"reload_completed"
"sat\t%0"
[(set_attr "length" "2")]
)
(define_insn "subsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
(minus:SI (match_operand:SI 1 "register_operand" "0,0,0,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,n,r,Q")))
(clobber (reg:CC CC_REG))]
""
"@
sub\t%2, %0
sub\t%2, %0
add\t%N2, %0
sub\t%2, %1, %0
sub\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,33")
(set_attr "length" "2,2,6,3,5")]
)
;; Note that the O flag is set as if (compare op1 op2) not for
;; what is described here, (compare op0 0).
(define_insn "*subsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
(minus:SI (match_operand:SI 1 "register_operand" "0,0,0,r,0")
(match_operand:SI 2 "rx_source_operand" "r,Uint04,n,r,Q")))
(set (reg CC_REG)
(compare (minus:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSCmode)"
"@
sub\t%2, %0
sub\t%2, %0
add\t%N2, %0
sub\t%2, %1, %0
sub\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,33")
(set_attr "length" "2,2,6,3,5")]
)
;; A helper to expand the above with the CC_MODE filled in.
(define_expand "subsi3_flags"
[(parallel [(set (match_operand:SI 0 "register_operand")
(minus:SI (match_operand:SI 1 "register_operand")
(match_operand:SI 2 "rx_source_operand")))
(set (reg:CC_ZSC CC_REG)
(compare:CC_ZSC (minus:SI (match_dup 1) (match_dup 2))
(const_int 0)))])]
)
(define_insn "sbb_internal"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(minus:SI
(minus:SI
(match_operand:SI 1 "register_operand" " 0,0")
(match_operand:SI 2 "rx_compare_operand" " r,Q"))
(geu:SI (reg:CC CC_REG) (const_int 0))))
(clobber (reg:CC CC_REG))]
"reload_completed"
"sbb\t%2, %0"
[(set_attr "timings" "11,33")
(set_attr "length" "3,6")]
)
(define_insn "*sbb_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(minus:SI
(minus:SI
(match_operand:SI 1 "register_operand" " 0,0")
(match_operand:SI 2 "rx_compare_operand" " r,Q"))
(geu:SI (reg:CC CC_REG) (const_int 0))))
(set (reg CC_REG)
(compare
(minus:SI
(minus:SI (match_dup 1) (match_dup 2))
(geu:SI (reg:CC CC_REG) (const_int 0)))
(const_int 0)))]
"reload_completed"
"sbb\t%2, %0"
[(set_attr "timings" "11,33")
(set_attr "length" "3,6")]
)
(define_expand "subdi3"
[(set (match_operand:DI 0 "register_operand")
(minus:DI (match_operand:DI 1 "register_operand")
(match_operand:DI 2 "register_operand")))]
""
{
rtx op0l, op0h, op1l, op1h, op2l, op2h;
op0l = gen_lowpart (SImode, operands[0]);
op1l = gen_lowpart (SImode, operands[1]);
op2l = gen_lowpart (SImode, operands[2]);
op0h = gen_highpart (SImode, operands[0]);
op1h = gen_highpart (SImode, operands[1]);
op2h = gen_highpart_mode (SImode, DImode, operands[2]);
emit_insn (gen_subdi3_internal (op0l, op0h, op1l, op2l, op1h, op2h));
DONE;
})
(define_insn_and_split "subdi3_internal"
[(set (match_operand:SI 0 "register_operand" "=&r,&r")
(minus:SI (match_operand:SI 2 "register_operand" " 0, r")
(match_operand:SI 3 "rx_compare_operand" "rQ, r")))
(set (match_operand:SI 1 "register_operand" "= r, r")
(minus:SI
(minus:SI
(match_operand:SI 4 "register_operand" " 1, 1")
(match_operand:SI 5 "rx_compare_operand" " rQ,rQ"))
(geu:SI (match_dup 2) (match_dup 3))))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(const_int 0)]
{
emit_insn (gen_subsi3_flags (operands[0], operands[2], operands[3]));
emit_insn (gen_sbb_internal (operands[1], operands[4], operands[5]));
DONE;
})
(define_insn "xorsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(xor:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))
(clobber (reg:CC CC_REG))]
""
"xor\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,33")
(set_attr "length" "3,4,5,6,7,6")]
)
(define_insn "*xorsi3_flags"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(xor:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
(match_operand:SI 2 "rx_source_operand"
"r,Sint08,Sint16,Sint24,i,Q")))
(set (reg CC_REG)
(compare (xor:SI (match_dup 1) (match_dup 2))
(const_int 0)))]
"reload_completed && rx_match_ccmode (insn, CC_ZSmode)"
"xor\t%Q2, %0"
[(set_attr "timings" "11,11,11,11,11,33")
(set_attr "length" "3,4,5,6,7,6")]
)
;; A set of peepholes to catch extending loads followed by arithmetic operations.
;; We use iterators where possible to reduce the amount of typing and hence the
;; possibilities for typos.
(define_code_iterator extend_types [(zero_extend "") (sign_extend "")])
(define_code_attr letter [(zero_extend "R") (sign_extend "Q")])
(define_code_iterator memex_commutative [(plus "") (and "") (ior "") (xor "")])
(define_code_iterator memex_noncomm [(div "") (udiv "") (minus "")])
(define_code_iterator memex_nocc [(smax "") (smin "") (mult "")])
(define_code_attr op [(plus "add") (and "and") (div "div") (udiv "divu") (smax "max") (smin "min") (mult "mul") (ior "or") (minus "sub") (xor "xor")])
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(parallel [(set (match_operand:SI 2 "register_operand")
(memex_commutative:SI (match_dup 0)
(match_dup 2)))
(clobber (reg:CC CC_REG))])]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(parallel [(set:SI (match_dup 2)
(memex_commutative:SI (match_dup 2)
(extend_types:SI (match_dup 1))))
(clobber (reg:CC CC_REG))])]
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(parallel [(set (match_operand:SI 2 "register_operand")
(memex_commutative:SI (match_dup 2)
(match_dup 0)))
(clobber (reg:CC CC_REG))])]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(parallel [(set:SI (match_dup 2)
(memex_commutative:SI (match_dup 2)
(extend_types:SI (match_dup 1))))
(clobber (reg:CC CC_REG))])]
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(parallel [(set (match_operand:SI 2 "register_operand")
(memex_noncomm:SI (match_dup 2)
(match_dup 0)))
(clobber (reg:CC CC_REG))])]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(parallel [(set:SI (match_dup 2)
(memex_noncomm:SI (match_dup 2)
(extend_types:SI (match_dup 1))))
(clobber (reg:CC CC_REG))])]
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(set (match_operand:SI 2 "register_operand")
(memex_nocc:SI (match_dup 0)
(match_dup 2)))]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(set:SI (match_dup 2)
(memex_nocc:SI (match_dup 2)
(extend_types:SI (match_dup 1))))]
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(set (match_operand:SI 2 "register_operand")
(memex_nocc:SI (match_dup 2)
(match_dup 0)))]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(set:SI (match_dup 2)
(memex_nocc:SI (match_dup 2)
(extend_types:SI (match_dup 1))))]
)
(define_insn "<memex_commutative:code>si3_<extend_types:code><small_int_modes:mode>"
[(set (match_operand:SI 0 "register_operand" "=r")
(memex_commutative:SI (match_operand:SI 1 "register_operand" "%0")
(extend_types:SI (match_operand:small_int_modes 2 "rx_restricted_mem_operand" "Q"))))
(clobber (reg:CC CC_REG))]
"(optimize < 3 || optimize_size)"
"<memex_commutative:op>\t%<extend_types:letter>2, %0"
[(set_attr "timings" "33")
(set_attr "length" "5")] ;; This length is corrected in rx_adjust_insn_length
)
(define_insn "<memex_noncomm:code>si3_<extend_types:code><small_int_modes:mode>"
[(set (match_operand:SI 0 "register_operand" "=r")
(memex_noncomm:SI (match_operand:SI 1 "register_operand" "0")
(extend_types:SI (match_operand:small_int_modes 2 "rx_restricted_mem_operand" "Q"))))
(clobber (reg:CC CC_REG))]
"(optimize < 3 || optimize_size)"
"<memex_noncomm:op>\t%<extend_types:letter>2, %0"
[(set_attr "timings" "33")
(set_attr "length" "5")] ;; This length is corrected in rx_adjust_insn_length
)
(define_insn "<memex_nocc:code>si3_<extend_types:code><small_int_modes:mode>"
[(set (match_operand:SI 0 "register_operand" "=r")
(memex_nocc:SI (match_operand:SI 1 "register_operand" "%0")
(extend_types:SI (match_operand:small_int_modes 2 "rx_restricted_mem_operand" "Q"))))]
"(optimize < 3 || optimize_size)"
"<memex_nocc:op>\t%<extend_types:letter>2, %0"
[(set_attr "timings" "33")
(set_attr "length" "5")] ;; This length is corrected in rx_adjust_insn_length
)
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand")))
(set (reg:CC CC_REG)
(compare:CC (match_operand:SI 2 "register_operand")
(match_dup 0)))]
"peep2_regno_dead_p (2, REGNO (operands[0])) && (optimize < 3 || optimize_size)"
[(set (reg:CC CC_REG)
(compare:CC (match_dup 2)
(extend_types:SI (match_dup 1))))]
)
;; Convert:
;; (set (reg1) (sign_extend (mem))
;; (set (reg2) (zero_extend (reg1))
;; into
;; (set (reg2) (zero_extend (mem)))
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(sign_extend:SI (match_operand:small_int_modes 1 "memory_operand")))
(set (match_operand:SI 2 "register_operand")
(zero_extend:SI (match_operand:small_int_modes 3 "register_operand")))]
"REGNO (operands[0]) == REGNO (operands[3])
&& (REGNO (operands[0]) == REGNO (operands[2])
|| peep2_regno_dead_p (2, REGNO (operands[0])))"
[(set (match_dup 2)
(zero_extend:SI (match_dup 1)))]
)
;; Remove the redundant sign extension from:
;; (set (reg) (extend (mem)))
;; (set (reg) (extend (reg)))
(define_peephole2
[(set (match_operand:SI 0 "register_operand")
(extend_types:SI (match_operand:small_int_modes 1 "memory_operand")))
(set (match_dup 0)
(extend_types:SI (match_operand:small_int_modes 2 "register_operand")))]
"REGNO (operands[0]) == REGNO (operands[2])"
[(set (match_dup 0) (extend_types:SI (match_dup 1)))]
)
(define_insn "comparesi3_<extend_types:code><small_int_modes:mode>"
[(set (reg:CC CC_REG)
(compare:CC (match_operand:SI 0 "register_operand" "r")
(extend_types:SI (match_operand:small_int_modes 1 "rx_restricted_mem_operand" "Q"))))]
"(optimize < 3 || optimize_size)"
"cmp\t%<extend_types:letter>1, %0"
[(set_attr "timings" "33")
(set_attr "length" "5")] ;; This length is corrected in rx_adjust_insn_length
)
;; Floating Point Instructions
(define_insn "addsf3"
[(set (match_operand:SF 0 "register_operand" "=r,r,r")
(plus:SF (match_operand:SF 1 "register_operand" "%0,0,0")
(match_operand:SF 2 "rx_source_operand" "r,F,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"fadd\t%2, %0"
[(set_attr "timings" "44,44,66")
(set_attr "length" "3,7,5")]
)
(define_insn "divsf3"
[(set (match_operand:SF 0 "register_operand" "=r,r,r")
(div:SF (match_operand:SF 1 "register_operand" "0,0,0")
(match_operand:SF 2 "rx_source_operand" "r,F,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"fdiv\t%2, %0"
[(set_attr "timings" "1616,1616,1818")
(set_attr "length" "3,7,5")]
)
(define_insn "mulsf3"
[(set (match_operand:SF 0 "register_operand" "=r,r,r")
(mult:SF (match_operand:SF 1 "register_operand" "%0,0,0")
(match_operand:SF 2 "rx_source_operand" "r,F,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"fmul\t%2, %0"
[(set_attr "timings" "33,33,55")
(set_attr "length" "3,7,5")]
)
(define_insn "subsf3"
[(set (match_operand:SF 0 "register_operand" "=r,r,r")
(minus:SF (match_operand:SF 1 "register_operand" "0,0,0")
(match_operand:SF 2 "rx_source_operand" "r,F,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"fsub\t%Q2, %0"
[(set_attr "timings" "44,44,66")
(set_attr "length" "3,7,5")]
)
(define_insn "fix_truncsfsi2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(fix:SI (match_operand:SF 1 "rx_compare_operand" "r,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"ftoi\t%Q1, %0"
[(set_attr "timings" "22,44")
(set_attr "length" "3,5")]
)
(define_insn "floatsisf2"
[(set (match_operand:SF 0 "register_operand" "=r,r")
(float:SF (match_operand:SI 1 "rx_compare_operand" "r,Q")))
(clobber (reg:CC CC_REG))]
"ALLOW_RX_FPU_INSNS"
"itof\t%Q1, %0"
[(set_attr "timings" "22,44")
(set_attr "length" "3,6")]
)
;; Bit manipulation instructions.
;; ??? The *_in_memory patterns will not be matched without further help.
;; At one time we had the insv expander generate them, but I suspect that
;; in general we get better performance by exposing the register load to
;; the optimizers.
;;
;; An alternate solution would be to re-organize these patterns such
;; that allow both register and memory operands. This would allow the
;; register allocator to spill and not load the register operand. This
;; would be possible only for operations for which we have a constant
;; bit offset, so that we can adjust the address by ofs/8 and replace
;; the offset in the insn by ofs%8.
(define_insn "*bitset"
[(set (match_operand:SI 0 "register_operand" "=r")
(ior:SI (ashift:SI (const_int 1)
(match_operand:SI 1 "rx_shift_operand" "ri"))
(match_operand:SI 2 "register_operand" "0")))]
""
"bset\t%1, %0"
[(set_attr "length" "3")]
)
(define_insn "*bitset_in_memory"
[(set (match_operand:QI 0 "rx_restricted_mem_operand" "+Q")
(ior:QI (ashift:QI (const_int 1)
(match_operand:QI 1 "nonmemory_operand" "ri"))
(match_dup 0)))]
""
"bset\t%1, %0.B"
[(set_attr "length" "3")
(set_attr "timings" "33")]
)
(define_insn "*bitinvert"
[(set (match_operand:SI 0 "register_operand" "=r")
(xor:SI (ashift:SI (const_int 1)
(match_operand:SI 1 "rx_shift_operand" "ri"))
(match_operand:SI 2 "register_operand" "0")))]
""
"bnot\t%1, %0"
[(set_attr "length" "3")]
)
(define_insn "*bitinvert_in_memory"
[(set (match_operand:QI 0 "rx_restricted_mem_operand" "+Q")
(xor:QI (ashift:QI (const_int 1)
(match_operand:QI 1 "nonmemory_operand" "ri"))
(match_dup 0)))]
""
"bnot\t%1, %0.B"
[(set_attr "length" "5")
(set_attr "timings" "33")]
)
(define_insn "*bitclr"
[(set (match_operand:SI 0 "register_operand" "=r")
(and:SI (not:SI
(ashift:SI
(const_int 1)
(match_operand:SI 1 "rx_shift_operand" "ri")))
(match_operand:SI 2 "register_operand" "0")))]
""
"bclr\t%1, %0"
[(set_attr "length" "3")]
)
(define_insn "*bitclr_in_memory"
[(set (match_operand:QI 0 "rx_restricted_mem_operand" "+Q")
(and:QI (not:QI
(ashift:QI
(const_int 1)
(match_operand:QI 1 "nonmemory_operand" "ri")))
(match_dup 0)))]
""
"bclr\t%1, %0.B"
[(set_attr "length" "3")
(set_attr "timings" "33")]
)
(define_insn "*insv_imm"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand" "+r")
(const_int 1)
(match_operand:SI 1 "rx_shift_operand" "ri"))
(match_operand:SI 2 "const_int_operand" ""))]
""
{
if (INTVAL (operands[2]) & 1)
return "bset\t%1, %0";
else
return "bclr\t%1, %0";
}
[(set_attr "length" "3")]
)
(define_insn_and_split "rx_insv_reg"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand" "+r")
(const_int 1)
(match_operand:SI 1 "const_int_operand" ""))
(match_operand:SI 2 "register_operand" "r"))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(set (zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1))
(match_dup 3))]
{
rtx flags, x;
/* Emit tst #1, op2. */
flags = gen_rtx_REG (CC_ZSmode, CC_REG);
x = gen_rtx_AND (SImode, operands[2], const1_rtx);
x = gen_rtx_COMPARE (CC_ZSmode, x, const0_rtx);
x = gen_rtx_SET (VOIDmode, flags, x);
emit_insn (x);
/* Emit bmne. */
operands[3] = gen_rtx_NE (SImode, flags, const0_rtx);
})
(define_insn_and_split "*insv_cond"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand" "+r")
(const_int 1)
(match_operand:SI 1 "const_int_operand" ""))
(match_operator:SI 4 "comparison_operator"
[(match_operand:SI 2 "register_operand" "r")
(match_operand:SI 3 "rx_source_operand" "riQ")]))
(clobber (reg:CC CC_REG))]
""
"#"
"reload_completed"
[(set (zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1))
(match_dup 4))]
{
rtx flags, x;
flags = gen_rtx_REG (CCmode, CC_REG);
x = gen_rtx_COMPARE (CCmode, operands[2], operands[3]);
x = gen_rtx_SET (VOIDmode, flags, x);
emit_insn (x);
operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
flags, const0_rtx);
})
(define_insn "*bmcc"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand" "+r")
(const_int 1)
(match_operand:SI 1 "const_int_operand" ""))
(match_operator:SI 2 "comparison_operator"
[(reg CC_REG) (const_int 0)]))]
"reload_completed"
"bm%B2\t%1, %0"
[(set_attr "length" "3")]
)
;; Work around the fact that X=Y<0 is preferentially expanded as a shift.
(define_insn_and_split "*insv_cond_lt"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand" "+r")
(const_int 1)
(match_operand:SI 1 "const_int_operand" ""))
(match_operator:SI 3 "rshift_operator"
[(match_operand:SI 2 "register_operand" "r")
(const_int 31)]))
(clobber (reg:CC CC_REG))]
""
"#"
""
[(parallel [(set (zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1))
(lt:SI (match_dup 2) (const_int 0)))
(clobber (reg:CC CC_REG))])]
""
)
(define_expand "insv"
[(set (zero_extract:SI
(match_operand:SI 0 "register_operand") ;; Destination
(match_operand:SI 1 "const_int_operand") ;; # of bits to set
(match_operand:SI 2 "nonmemory_operand")) ;; Starting bit
(match_operand:SI 3 "nonmemory_operand"))] ;; Bits to insert
""
{
/* We only handle single-bit inserts. */
if (!CONST_INT_P (operands[1]) || INTVAL (operands[1]) != 1)
FAIL;
/* Either the bit to insert or the position must be constant. */
if (CONST_INT_P (operands[3]))
operands[3] = GEN_INT (INTVAL (operands[3]) & 1);
else if (CONST_INT_P (operands[2]))
{
emit_insn (gen_rx_insv_reg (operands[0], operands[2], operands[3]));
DONE;
}
else
FAIL;
})
;; Atomic exchange operation.
(define_insn "sync_lock_test_and_setsi"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(match_operand:SI 1 "rx_compare_operand" "=r,Q"))
(set (match_dup 1)
(match_operand:SI 2 "register_operand" "0,0"))]
""
"xchg\t%1, %0"
[(set_attr "length" "3,6")
(set_attr "timings" "22")]
)
;; Block move functions.
(define_expand "movstr"
[(set (match_operand:BLK 1 "memory_operand") ;; Dest
(match_operand:BLK 2 "memory_operand")) ;; Source
(use (match_operand:SI 0 "register_operand")) ;; Updated Dest
]
""
{
rtx addr1 = gen_rtx_REG (SImode, 1);
rtx addr2 = gen_rtx_REG (SImode, 2);
rtx len = gen_rtx_REG (SImode, 3);
rtx dest_copy = gen_reg_rtx (SImode);
emit_move_insn (len, GEN_INT (-1));
emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
operands[1] = replace_equiv_address_nv (operands[1], addr1);
operands[2] = replace_equiv_address_nv (operands[2], addr2);
emit_move_insn (dest_copy, addr1);
emit_insn (gen_rx_movstr ());
emit_move_insn (len, GEN_INT (-1));
emit_insn (gen_rx_strend (operands[0], dest_copy));
DONE;
}
)
(define_insn "rx_movstr"
[(set (mem:BLK (reg:SI 1))
(mem:BLK (reg:SI 2)))
(unspec_volatile:BLK [(reg:SI 1) (reg:SI 2) (reg:SI 3)] UNSPEC_MOVSTR)
(clobber (reg:SI 1))
(clobber (reg:SI 2))
(clobber (reg:SI 3))]
""
"smovu"
[(set_attr "length" "2")
(set_attr "timings" "1111")] ;; The timing is a guesstimate.
)
(define_insn "rx_strend"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
(reg:SI 3)] UNSPEC_STRLEN))
(clobber (reg:SI 1))
(clobber (reg:SI 2))
(clobber (reg:SI 3))
(clobber (reg:CC CC_REG))
]
""
"mov\t%1, r1\n\tmov\t#0, r2\n\tsuntil.b\n\tmov\tr1, %0\n\tsub\t#1, %0"
[(set_attr "length" "10")
(set_attr "timings" "1111")] ;; The timing is a guesstimate.
)
(define_expand "movmemsi"
[(parallel
[(set (match_operand:BLK 0 "memory_operand") ;; Dest
(match_operand:BLK 1 "memory_operand")) ;; Source
(use (match_operand:SI 2 "register_operand")) ;; Length in bytes
(match_operand 3 "immediate_operand") ;; Align
(unspec_volatile:BLK [(reg:SI 1) (reg:SI 2) (reg:SI 3)] UNSPEC_MOVMEM)]
)]
""
{
rtx addr1 = gen_rtx_REG (SImode, 1);
rtx addr2 = gen_rtx_REG (SImode, 2);
rtx len = gen_rtx_REG (SImode, 3);
/* Do not use when the source or destination are volatile - the SMOVF
instruction will read and write in word sized blocks, which may be
outside of the valid address range. */
if (MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
FAIL;
if (MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))
FAIL;
if (REG_P (operands[0]) && (REGNO (operands[0]) == 2
|| REGNO (operands[0]) == 3))
FAIL;
if (REG_P (operands[1]) && (REGNO (operands[1]) == 1
|| REGNO (operands[1]) == 3))
FAIL;
if (REG_P (operands[2]) && (REGNO (operands[2]) == 1
|| REGNO (operands[2]) == 2))
FAIL;
emit_move_insn (addr1, force_operand (XEXP (operands[0], 0), NULL_RTX));
emit_move_insn (addr2, force_operand (XEXP (operands[1], 0), NULL_RTX));
emit_move_insn (len, force_operand (operands[2], NULL_RTX));
operands[0] = replace_equiv_address_nv (operands[0], addr1);
operands[1] = replace_equiv_address_nv (operands[1], addr2);
emit_insn (gen_rx_movmem ());
DONE;
}
)
(define_insn "rx_movmem"
[(set (mem:BLK (reg:SI 1))
(mem:BLK (reg:SI 2)))
(use (reg:SI 3))
(unspec_volatile:BLK [(reg:SI 1) (reg:SI 2) (reg:SI 3)] UNSPEC_MOVMEM)
(clobber (reg:SI 1))
(clobber (reg:SI 2))
(clobber (reg:SI 3))]
""
"smovf"
[(set_attr "length" "2")
(set_attr "timings" "1111")] ;; The timing is a guesstimate.
)
(define_expand "setmemsi"
[(set (match_operand:BLK 0 "memory_operand") ;; Dest
(match_operand:QI 2 "nonmemory_operand")) ;; Value
(use (match_operand:SI 1 "nonmemory_operand")) ;; Length
(match_operand 3 "immediate_operand") ;; Align
(unspec_volatile:BLK [(reg:SI 1) (reg:SI 2) (reg:SI 3)] UNSPEC_SETMEM)]
""
{
rtx addr = gen_rtx_REG (SImode, 1);
rtx val = gen_rtx_REG (QImode, 2);
rtx len = gen_rtx_REG (SImode, 3);
emit_move_insn (addr, force_operand (XEXP (operands[0], 0), NULL_RTX));
emit_move_insn (len, force_operand (operands[1], NULL_RTX));
emit_move_insn (val, operands[2]);
emit_insn (gen_rx_setmem ());
DONE;
}
)
(define_insn "rx_setmem"
[(set (mem:BLK (reg:SI 1))
(unspec_volatile:BLK [(reg:SI 1) (reg:SI 2) (reg:SI 3)] UNSPEC_SETMEM))
(clobber (reg:SI 1))
(clobber (reg:SI 3))]
""
"sstr.b"
[(set_attr "length" "2")
(set_attr "timings" "1111")] ;; The timing is a guesstimate.
)
(define_expand "cmpstrnsi"
[(set (match_operand:SI 0 "register_operand") ;; Result
(unspec_volatile:SI [(match_operand:BLK 1 "memory_operand") ;; String1
(match_operand:BLK 2 "memory_operand")] ;; String2
UNSPEC_CMPSTRN))
(use (match_operand:SI 3 "register_operand")) ;; Max Length
(match_operand:SI 4 "immediate_operand")] ;; Known Align
""
{
rtx str1 = gen_rtx_REG (SImode, 1);
rtx str2 = gen_rtx_REG (SImode, 2);
rtx len = gen_rtx_REG (SImode, 3);
emit_move_insn (str1, force_operand (XEXP (operands[1], 0), NULL_RTX));
emit_move_insn (str2, force_operand (XEXP (operands[2], 0), NULL_RTX));
emit_move_insn (len, force_operand (operands[3], NULL_RTX));
emit_insn (gen_rx_cmpstrn (operands[0], operands[1], operands[2]));
DONE;
}
)
(define_expand "cmpstrsi"
[(set (match_operand:SI 0 "register_operand") ;; Result
(unspec_volatile:SI [(match_operand:BLK 1 "memory_operand") ;; String1
(match_operand:BLK 2 "memory_operand")] ;; String2
UNSPEC_CMPSTRN))
(match_operand:SI 3 "immediate_operand")] ;; Known Align
""
{
rtx str1 = gen_rtx_REG (SImode, 1);
rtx str2 = gen_rtx_REG (SImode, 2);
rtx len = gen_rtx_REG (SImode, 3);
emit_move_insn (str1, force_reg (SImode, XEXP (operands[1], 0)));
emit_move_insn (str2, force_reg (SImode, XEXP (operands[2], 0)));
emit_move_insn (len, GEN_INT (-1));
emit_insn (gen_rx_cmpstrn (operands[0], operands[1], operands[2]));
DONE;
}
)
(define_insn "rx_cmpstrn"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec_volatile:SI [(reg:SI 1) (reg:SI 2) (reg:SI 3)]
UNSPEC_CMPSTRN))
(use (match_operand:BLK 1 "memory_operand" "m"))
(use (match_operand:BLK 2 "memory_operand" "m"))
(clobber (reg:SI 1))
(clobber (reg:SI 2))
(clobber (reg:SI 3))
(clobber (reg:CC CC_REG))]
""
"scmpu ; Perform the string comparison
mov #-1, %0 ; Set up -1 result (which cannot be created
; by the SC insn)
bnc ?+ ; If Carry is not set skip over
scne.L %0 ; Set result based on Z flag
?:
"
[(set_attr "length" "9")
(set_attr "timings" "1111")] ;; The timing is a guesstimate.
)
;; Builtin Functions
;;
;; GCC does not have the ability to generate the following instructions
;; on its own so they are provided as builtins instead. To use them from
;; a program for example invoke them as __builtin_rx_<insn_name>. For
;; example:
;;
;; int short_byte_swap (int arg) { return __builtin_rx_revw (arg); }
;;---------- Accumulator Support ------------------------
;; Multiply & Accumulate (high)
(define_insn "machi"
[(unspec:SI [(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "register_operand" "r")]
UNSPEC_BUILTIN_MACHI)]
""
"machi\t%0, %1"
[(set_attr "length" "3")]
)
;; Multiply & Accumulate (low)
(define_insn "maclo"
[(unspec:SI [(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "register_operand" "r")]
UNSPEC_BUILTIN_MACLO)]
""
"maclo\t%0, %1"
[(set_attr "length" "3")]
)
;; Multiply (high)
(define_insn "mulhi"
[(unspec:SI [(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "register_operand" "r")]
UNSPEC_BUILTIN_MULHI)]
""
"mulhi\t%0, %1"
[(set_attr "length" "3")]
)
;; Multiply (low)
(define_insn "mullo"
[(unspec:SI [(match_operand:SI 0 "register_operand" "r")
(match_operand:SI 1 "register_operand" "r")]
UNSPEC_BUILTIN_MULLO)]
""
"mullo\t%0, %1"
[(set_attr "length" "3")]
)
;; Move from Accumulator (high)
(define_insn "mvfachi"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(const_int 0)]
UNSPEC_BUILTIN_MVFACHI))]
""
"mvfachi\t%0"
[(set_attr "length" "3")]
)
;; Move from Accumulator (middle)
(define_insn "mvfacmi"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(const_int 0)]
UNSPEC_BUILTIN_MVFACMI))]
""
"mvfacmi\t%0"
[(set_attr "length" "3")]
)
;; Move to Accumulator (high)
(define_insn "mvtachi"
[(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
UNSPEC_BUILTIN_MVTACHI)]
""
"mvtachi\t%0"
[(set_attr "length" "3")]
)
;; Move to Accumulator (low)
(define_insn "mvtaclo"
[(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
UNSPEC_BUILTIN_MVTACLO)]
""
"mvtaclo\t%0"
[(set_attr "length" "3")]
)
;; Round Accumulator
(define_insn "racw"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "i")]
UNSPEC_BUILTIN_RACW)]
""
"racw\t%0"
[(set_attr "length" "3")]
)
;; Repeat multiply and accumulate
(define_insn "rmpa"
[(unspec:SI [(const_int 0) (reg:SI 1) (reg:SI 2) (reg:SI 3)
(reg:SI 4) (reg:SI 5) (reg:SI 6)]
UNSPEC_BUILTIN_RMPA)
(clobber (reg:SI 1))
(clobber (reg:SI 2))
(clobber (reg:SI 3))]
""
"rmpa"
[(set_attr "length" "2")
(set_attr "timings" "1010")]
)
;;---------- Arithmetic ------------------------
;; Byte swap (two 16-bit values).
(define_insn "revw"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(match_operand:SI 1 "register_operand" "r")]
UNSPEC_BUILTIN_REVW))]
""
"revw\t%1, %0"
[(set_attr "length" "3")]
)
;; Round to integer.
(define_insn "lrintsf2"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(unspec:SI [(match_operand:SF 1 "rx_compare_operand" "r,Q")]
UNSPEC_BUILTIN_ROUND))
(clobber (reg:CC CC_REG))]
""
"round\t%1, %0"
[(set_attr "timings" "22,44")
(set_attr "length" "3,5")]
)
;;---------- Control Registers ------------------------
;; Clear Processor Status Word
(define_insn "clrpsw"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "i")]
UNSPEC_BUILTIN_CLRPSW)
(clobber (reg:CC CC_REG))]
""
"clrpsw\t%F0"
[(set_attr "length" "2")]
)
;; Set Processor Status Word
(define_insn "setpsw"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "i")]
UNSPEC_BUILTIN_SETPSW)
(clobber (reg:CC CC_REG))]
""
"setpsw\t%F0"
[(set_attr "length" "2")]
)
;; Move from control register
(define_insn "mvfc"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec_volatile:SI [(match_operand:SI 1 "immediate_operand" "i")]
UNSPEC_BUILTIN_MVFC))]
""
"mvfc\t%C1, %0"
[(set_attr "length" "3")]
)
;; Move to control register
(define_insn "mvtc"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "i,i")
(match_operand:SI 1 "nonmemory_operand" "r,i")]
UNSPEC_BUILTIN_MVTC)]
""
"mvtc\t%1, %C0"
[(set_attr "length" "3,7")]
;; Ignore possible clobbering of the comparison flags in the
;; PSW register. This is a cc0 target so any cc0 setting
;; instruction will always be paired with a cc0 user, without
;; the possibility of this instruction being placed in between
;; them.
)
;; Move to interrupt priority level
(define_insn "mvtipl"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "Uint04")]
UNSPEC_BUILTIN_MVTIPL)]
""
"mvtipl\t%0"
[(set_attr "length" "3")]
)
;;---------- Interrupts ------------------------
;; Break
(define_insn "brk"
[(unspec_volatile [(const_int 0)]
UNSPEC_BUILTIN_BRK)]
""
"brk"
[(set_attr "length" "1")
(set_attr "timings" "66")]
)
;; Interrupt
(define_insn "int"
[(unspec_volatile:SI [(match_operand:SI 0 "immediate_operand" "i")]
UNSPEC_BUILTIN_INT)]
""
"int\t%0"
[(set_attr "length" "3")]
)
;; Wait
(define_insn "wait"
[(unspec_volatile [(const_int 0)]
UNSPEC_BUILTIN_WAIT)]
""
"wait"
[(set_attr "length" "2")]
)
;;---------- CoProcessor Support ------------------------
;; FIXME: The instructions are currently commented out because
;; the bit patterns have not been finalized, so the assembler
;; does not support them. Once they are decided and the assembler
;; supports them, enable the instructions here.
;; Move from co-processor register
(define_insn "mvfcp"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(match_operand:SI 1 "immediate_operand" "i")
(match_operand:SI 2 "immediate_operand" "i")]
UNSPEC_BUILTIN_MVFCP))]
""
"; mvfcp\t%1, %0, %2"
[(set_attr "length" "5")]
)
;;---------- Misc ------------------------
;; Required by cfglayout.c...
(define_insn "nop"
[(const_int 0)]
""
"nop"
[(set_attr "length" "1")]
)
(define_expand "pid_addr"
[(plus:SI (match_operand:SI 0)
(const:SI (unspec:SI [(match_operand:SI 1)] UNSPEC_PID_ADDR)))]
""
""
)
(define_insn "movdi"
[(set:DI (match_operand:DI 0 "nonimmediate_operand" "=rm")
(match_operand:DI 1 "general_operand" "rmi"))]
"TARGET_ENABLE_LRA || 1"
{ return rx_gen_move_template (operands, false); }
[(set_attr "length" "16")
(set_attr "timings" "22")]
)
(define_insn "movdf"
[(set:DF (match_operand:DF 0 "nonimmediate_operand" "=rm")
(match_operand:DF 1 "general_operand" "rmi"))]
"TARGET_ENABLE_LRA || 1"
{ return rx_gen_move_template (operands, false); }
[(set_attr "length" "16")
(set_attr "timings" "22")]
)
|