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
|
;; Machine description the Motorola MCore
;; Copyright (C) 1993, 1999, 2000, 2004, 2005
;; Free Software Foundation, Inc.
;; Contributed by Motorola.
;; 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 2, 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 COPYING. If not, write to
;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
;; -------------------------------------------------------------------------
;; Attributes
;; -------------------------------------------------------------------------
; Target CPU.
(define_attr "type" "brcond,branch,jmp,load,store,move,alu,shift"
(const_string "alu"))
;; If a branch destination is within -2048..2047 bytes away from the
;; instruction it can be 2 bytes long. All other conditional branches
;; are 10 bytes long, and all other unconditional branches are 8 bytes.
;;
;; the assembler handles the long-branch span case for us if we use
;; the "jb*" mnemonics for jumps/branches. This pushes the span
;; calculations and the literal table placement into the assembler,
;; where their interactions can be managed in a single place.
;; All MCORE instructions are two bytes long.
(define_attr "length" "" (const_int 2))
;; Scheduling. We only model a simple load latency.
(define_insn_reservation "any_insn" 1
(eq_attr "type" "!load")
"nothing")
(define_insn_reservation "memory" 2
(eq_attr "type" "load")
"nothing")
(include "predicates.md")
;; -------------------------------------------------------------------------
;; Test and bit test
;; -------------------------------------------------------------------------
(define_insn ""
[(set (reg:SI 17)
(sign_extract:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 1)
(match_operand:SI 1 "mcore_literal_K_operand" "K")))]
""
"btsti %0,%1"
[(set_attr "type" "shift")])
(define_insn ""
[(set (reg:SI 17)
(zero_extract:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 1)
(match_operand:SI 1 "mcore_literal_K_operand" "K")))]
""
"btsti %0,%1"
[(set_attr "type" "shift")])
;;; This is created by combine.
(define_insn ""
[(set (reg:CC 17)
(ne:CC (zero_extract:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 1)
(match_operand:SI 1 "mcore_literal_K_operand" "K"))
(const_int 0)))]
""
"btsti %0,%1"
[(set_attr "type" "shift")])
;; Created by combine from conditional patterns below (see sextb/btsti rx,31)
(define_insn ""
[(set (reg:CC 17)
(ne:CC (lshiftrt:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 7))
(const_int 0)))]
"GET_CODE(operands[0]) == SUBREG &&
GET_MODE(SUBREG_REG(operands[0])) == QImode"
"btsti %0,7"
[(set_attr "type" "shift")])
(define_insn ""
[(set (reg:CC 17)
(ne:CC (lshiftrt:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 15))
(const_int 0)))]
"GET_CODE(operands[0]) == SUBREG &&
GET_MODE(SUBREG_REG(operands[0])) == HImode"
"btsti %0,15"
[(set_attr "type" "shift")])
(define_split
[(set (pc)
(if_then_else (ne (eq:CC (zero_extract:SI
(match_operand:SI 0 "mcore_arith_reg_operand" "")
(const_int 1)
(match_operand:SI 1 "mcore_literal_K_operand" ""))
(const_int 0))
(const_int 0))
(label_ref (match_operand 2 "" ""))
(pc)))]
""
[(set (reg:CC 17)
(zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1)))
(set (pc) (if_then_else (eq (reg:CC 17) (const_int 0))
(label_ref (match_dup 2))
(pc)))]
"")
(define_split
[(set (pc)
(if_then_else (eq (ne:CC (zero_extract:SI
(match_operand:SI 0 "mcore_arith_reg_operand" "")
(const_int 1)
(match_operand:SI 1 "mcore_literal_K_operand" ""))
(const_int 0))
(const_int 0))
(label_ref (match_operand 2 "" ""))
(pc)))]
""
[(set (reg:CC 17)
(zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1)))
(set (pc) (if_then_else (eq (reg:CC 17) (const_int 0))
(label_ref (match_dup 2))
(pc)))]
"")
;; XXX - disabled by nickc because it fails on libiberty/fnmatch.c
;;
;; ; Experimental - relax immediates for and, andn, or, and tst to allow
;; ; any immediate value (or an immediate at all -- or, andn, & tst).
;; ; This is done to allow bit field masks to fold together in combine.
;; ; The reload phase will force the immediate into a register at the
;; ; very end. This helps in some cases, but hurts in others: we'd
;; ; really like to cse these immediates. However, there is a phase
;; ; ordering problem here. cse picks up individual masks and cse's
;; ; those, but not folded masks (cse happens before combine). It's
;; ; not clear what the best solution is because we really want cse
;; ; before combine (leaving the bit field masks alone). To pick up
;; ; relaxed immediates use -mrelax-immediates. It might take some
;; ; experimenting to see which does better (i.e. regular imms vs.
;; ; arbitrary imms) for a particular code. BRC
;;
;; (define_insn ""
;; [(set (reg:CC 17)
;; (ne:CC (and:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
;; (match_operand:SI 1 "mcore_arith_any_imm_operand" "rI"))
;; (const_int 0)))]
;; "TARGET_RELAX_IMM"
;; "tst %0,%1")
;;
;; (define_insn ""
;; [(set (reg:CC 17)
;; (ne:CC (and:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
;; (match_operand:SI 1 "mcore_arith_M_operand" "r"))
;; (const_int 0)))]
;; "!TARGET_RELAX_IMM"
;; "tst %0,%1")
(define_insn ""
[(set (reg:CC 17)
(ne:CC (and:SI (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_M_operand" "r"))
(const_int 0)))]
""
"tst %0,%1")
(define_split
[(parallel[
(set (reg:CC 17)
(ne:CC (ne:SI (leu:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r"))
(const_int 0))
(const_int 0)))
(clobber (match_operand:CC 2 "mcore_arith_reg_operand" "=r"))])]
""
[(set (reg:CC 17) (ne:SI (match_dup 0) (const_int 0)))
(set (reg:CC 17) (leu:CC (match_dup 0) (match_dup 1)))])
;; -------------------------------------------------------------------------
;; SImode signed integer comparisons
;; -------------------------------------------------------------------------
(define_insn "decne_t"
[(set (reg:CC 17) (ne:CC (plus:SI (match_operand:SI 0 "mcore_arith_reg_operand" "+r")
(const_int -1))
(const_int 0)))
(set (match_dup 0)
(plus:SI (match_dup 0)
(const_int -1)))]
""
"decne %0")
;; The combiner seems to prefer the following to the former.
;;
(define_insn ""
[(set (reg:CC 17) (ne:CC (match_operand:SI 0 "mcore_arith_reg_operand" "+r")
(const_int 1)))
(set (match_dup 0)
(plus:SI (match_dup 0)
(const_int -1)))]
""
"decne %0")
(define_insn "cmpnesi_t"
[(set (reg:CC 17) (ne:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"cmpne %0,%1")
(define_insn "cmpneisi_t"
[(set (reg:CC 17) (ne:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_K_operand" "K")))]
""
"cmpnei %0,%1")
(define_insn "cmpgtsi_t"
[(set (reg:CC 17) (gt:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"cmplt %1,%0")
(define_insn ""
[(set (reg:CC 17) (gt:CC (plus:SI
(match_operand:SI 0 "mcore_arith_reg_operand" "+r")
(const_int -1))
(const_int 0)))
(set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
""
"decgt %0")
(define_insn "cmpltsi_t"
[(set (reg:CC 17) (lt:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"cmplt %0,%1")
; cmplti is 1-32
(define_insn "cmpltisi_t"
[(set (reg:CC 17) (lt:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_J_operand" "J")))]
""
"cmplti %0,%1")
; covers cmplti x,0
(define_insn ""
[(set (reg:CC 17) (lt:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 0)))]
""
"btsti %0,31")
(define_insn ""
[(set (reg:CC 17) (lt:CC (plus:SI
(match_operand:SI 0 "mcore_arith_reg_operand" "+r")
(const_int -1))
(const_int 0)))
(set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
""
"declt %0")
;; -------------------------------------------------------------------------
;; SImode unsigned integer comparisons
;; -------------------------------------------------------------------------
(define_insn "cmpgeusi_t"
[(set (reg:CC 17) (geu:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"cmphs %0,%1")
(define_insn "cmpgeusi_0"
[(set (reg:CC 17) (geu:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(const_int 0)))]
""
"cmpnei %0, 0")
(define_insn "cmpleusi_t"
[(set (reg:CC 17) (leu:CC (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"cmphs %1,%0")
;; We save the compare operands in the cmpxx patterns and use them when
;; we generate the branch.
;; We accept constants here, in case we can modify them to ones which
;; are more efficient to load. E.g. change 'x <= 62' to 'x < 63'.
(define_expand "cmpsi"
[(set (reg:CC 17) (compare:CC (match_operand:SI 0 "mcore_compare_operand" "")
(match_operand:SI 1 "nonmemory_operand" "")))]
""
"
{ arch_compare_op0 = operands[0];
arch_compare_op1 = operands[1];
DONE;
}")
;; -------------------------------------------------------------------------
;; Logical operations
;; -------------------------------------------------------------------------
;; Logical AND clearing a single bit. andsi3 knows that we have this
;; pattern and allows the constant literal pass through.
;;
;; RBE 2/97: don't need this pattern any longer...
;; RBE: I don't think we need both "S" and exact_log2() clauses.
;;(define_insn ""
;; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
;; (and:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
;; (match_operand:SI 2 "const_int_operand" "S")))]
;; "mcore_arith_S_operand (operands[2])"
;; "bclri %0,%Q2")
;;
(define_insn "andnsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(and:SI (not:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r"))
(match_operand:SI 2 "mcore_arith_reg_operand" "0")))]
""
"andn %0,%1")
(define_expand "andsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(and:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "nonmemory_operand" "")))]
""
"
{
if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0
&& ! mcore_arith_S_operand (operands[2]))
{
int not_value = ~ INTVAL (operands[2]);
if ( CONST_OK_FOR_I (not_value)
|| CONST_OK_FOR_M (not_value)
|| CONST_OK_FOR_N (not_value))
{
operands[2] = copy_to_mode_reg (SImode, GEN_INT (not_value));
emit_insn (gen_andnsi3 (operands[0], operands[2], operands[1]));
DONE;
}
}
if (! mcore_arith_K_S_operand (operands[2], SImode))
operands[2] = copy_to_mode_reg (SImode, operands[2]);
}")
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(and:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0,r,0")
(match_operand:SI 2 "mcore_arith_any_imm_operand" "r,K,0,S")))]
"TARGET_RELAX_IMM"
"*
{
switch (which_alternative)
{
case 0: return \"and %0,%2\";
case 1: return \"andi %0,%2\";
case 2: return \"and %0,%1\";
/* case -1: return \"bclri %0,%Q2\"; will not happen */
case 3: return mcore_output_bclri (operands[0], INTVAL (operands[2]));
default: gcc_unreachable ();
}
}")
;; This was the old "S" which was "!(2^n)" */
;; case -1: return \"bclri %0,%Q2\"; will not happen */
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(and:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0,r,0")
(match_operand:SI 2 "mcore_arith_K_S_operand" "r,K,0,S")))]
"!TARGET_RELAX_IMM"
"*
{
switch (which_alternative)
{
case 0: return \"and %0,%2\";
case 1: return \"andi %0,%2\";
case 2: return \"and %0,%1\";
case 3: return mcore_output_bclri (operands[0], INTVAL (operands[2]));
default: gcc_unreachable ();
}
}")
;(define_insn "iorsi3"
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
; (ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
; (match_operand:SI 2 "mcore_arith_reg_operand" "r")))]
; ""
; "or %0,%2")
; need an expand to resolve ambiguity betw. the two iors below.
(define_expand "iorsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "nonmemory_operand" "")))]
""
"
{
if (! mcore_arith_M_operand (operands[2], SImode))
operands[2] = copy_to_mode_reg (SImode, operands[2]);
}")
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r")
(ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0,0,0")
(match_operand:SI 2 "mcore_arith_any_imm_operand" "r,M,T")))]
"TARGET_RELAX_IMM"
"*
{
switch (which_alternative)
{
case 0: return \"or %0,%2\";
case 1: return \"bseti %0,%P2\";
case 2: return mcore_output_bseti (operands[0], INTVAL (operands[2]));
default: gcc_unreachable ();
}
}")
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r")
(ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0,0,0")
(match_operand:SI 2 "mcore_arith_M_operand" "r,M,T")))]
"!TARGET_RELAX_IMM"
"*
{
switch (which_alternative)
{
case 0: return \"or %0,%2\";
case 1: return \"bseti %0,%P2\";
case 2: return mcore_output_bseti (operands[0], INTVAL (operands[2]));
default: gcc_unreachable ();
}
}")
;(define_insn ""
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
; (ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
; (match_operand:SI 2 "const_int_operand" "M")))]
; "exact_log2 (INTVAL (operands[2])) >= 0"
; "bseti %0,%P2")
;(define_insn ""
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
; (ior:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
; (match_operand:SI 2 "const_int_operand" "i")))]
; "mcore_num_ones (INTVAL (operands[2])) < 3"
; "* return mcore_output_bseti (operands[0], INTVAL (operands[2]));")
(define_insn "xorsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(xor:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
(match_operand:SI 2 "mcore_arith_reg_operand" "r")))]
""
"xor %0,%2")
; these patterns give better code then gcc invents if
; left to its own devices
(define_insn "anddi3"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=r")
(and:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
(match_operand:DI 2 "mcore_arith_reg_operand" "r")))]
""
"and %0,%2\;and %R0,%R2"
[(set_attr "length" "4")])
(define_insn "iordi3"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=r")
(ior:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
(match_operand:DI 2 "mcore_arith_reg_operand" "r")))]
""
"or %0,%2\;or %R0,%R2"
[(set_attr "length" "4")])
(define_insn "xordi3"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=r")
(xor:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
(match_operand:DI 2 "mcore_arith_reg_operand" "r")))]
""
"xor %0,%2\;xor %R0,%R2"
[(set_attr "length" "4")])
;; -------------------------------------------------------------------------
;; Shifts and rotates
;; -------------------------------------------------------------------------
;; Only allow these if the shift count is a convenient constant.
(define_expand "rotlsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(rotate:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "nonmemory_operand" "")))]
""
"if (! mcore_literal_K_operand (operands[2], SImode))
FAIL;
")
;; We can only do constant rotates, which is what this pattern provides.
;; The combiner will put it together for us when we do:
;; (x << N) | (x >> (32 - N))
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(rotate:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
(match_operand:SI 2 "mcore_literal_K_operand" "K")))]
""
"rotli %0,%2"
[(set_attr "type" "shift")])
(define_insn "ashlsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r")
(ashift:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0")
(match_operand:SI 2 "mcore_arith_K_operand_not_0" "r,K")))]
""
"@
lsl %0,%2
lsli %0,%2"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(ashift:SI (const_int 1)
(match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"bgenr %0,%1"
[(set_attr "type" "shift")])
(define_insn "ashrsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r")
(ashiftrt:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0")
(match_operand:SI 2 "mcore_arith_K_operand_not_0" "r,K")))]
""
"@
asr %0,%2
asri %0,%2"
[(set_attr "type" "shift")])
(define_insn "lshrsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r")
(lshiftrt:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0")
(match_operand:SI 2 "mcore_arith_K_operand_not_0" "r,K")))]
""
"@
lsr %0,%2
lsri %0,%2"
[(set_attr "type" "shift")])
;(define_expand "ashldi3"
; [(parallel[(set (match_operand:DI 0 "mcore_arith_reg_operand" "")
; (ashift:DI (match_operand:DI 1 "mcore_arith_reg_operand" "")
; (match_operand:DI 2 "immediate_operand" "")))
;
; (clobber (reg:CC 17))])]
;
; ""
; "
;{
; if (GET_CODE (operands[2]) != CONST_INT
; || INTVAL (operands[2]) != 1)
; FAIL;
;}")
;
;(define_insn ""
; [(set (match_operand:DI 0 "mcore_arith_reg_operand" "=r")
; (ashift:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")
; (const_int 1)))
; (clobber (reg:CC 17))]
; ""
; "lsli %R0,0\;rotli %0,0"
; [(set_attr "length" "4") (set_attr "type" "shift")])
;; -------------------------------------------------------------------------
;; Index instructions
;; -------------------------------------------------------------------------
;; The second of each set of patterns is borrowed from the alpha.md file.
;; These variants of the above insns can occur if the second operand
;; is the frame pointer. This is a kludge, but there doesn't
;; seem to be a way around it. Only recognize them while reloading.
;; We must use reload_operand for some operands in case frame pointer
;; elimination put a MEM with invalid address there. Otherwise,
;; the result of the substitution will not match this pattern, and reload
;; will not be able to correctly fix the result.
;; indexing longlongs or doubles (8 bytes)
(define_insn "indexdi_t"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(plus:SI (mult:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 8))
(match_operand:SI 2 "mcore_arith_reg_operand" "0")))]
""
"*
if (! mcore_is_same_reg (operands[1], operands[2]))
{
output_asm_insn (\"ixw\\t%0,%1\", operands);
output_asm_insn (\"ixw\\t%0,%1\", operands);
}
else
{
output_asm_insn (\"ixh\\t%0,%1\", operands);
output_asm_insn (\"ixh\\t%0,%1\", operands);
}
return \"\";
"
;; if operands[1] == operands[2], the first option above is wrong! -- dac
;; was this... -- dac
;; ixw %0,%1\;ixw %0,%1"
[(set_attr "length" "4")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_reload_operand" "=r,r,r")
(plus:SI (plus:SI (mult:SI (match_operand:SI 1 "mcore_reload_operand" "r,r,r")
(const_int 8))
(match_operand:SI 2 "mcore_arith_reg_operand" "0,0,0"))
(match_operand:SI 3 "mcore_addsub_operand" "r,J,L")))]
"reload_in_progress"
"@
ixw %0,%1\;ixw %0,%1\;addu %0,%3
ixw %0,%1\;ixw %0,%1\;addi %0,%3
ixw %0,%1\;ixw %0,%1\;subi %0,%M3"
[(set_attr "length" "6")])
;; indexing longs (4 bytes)
(define_insn "indexsi_t"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(plus:SI (mult:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 4))
(match_operand:SI 2 "mcore_arith_reg_operand" "0")))]
""
"ixw %0,%1")
(define_insn ""
[(set (match_operand:SI 0 "mcore_reload_operand" "=r,r,r")
(plus:SI (plus:SI (mult:SI (match_operand:SI 1 "mcore_reload_operand" "r,r,r")
(const_int 4))
(match_operand:SI 2 "mcore_arith_reg_operand" "0,0,0"))
(match_operand:SI 3 "mcore_addsub_operand" "r,J,L")))]
"reload_in_progress"
"@
ixw %0,%1\;addu %0,%3
ixw %0,%1\;addi %0,%3
ixw %0,%1\;subi %0,%M3"
[(set_attr "length" "4")])
;; indexing shorts (2 bytes)
(define_insn "indexhi_t"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(plus:SI (mult:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 2))
(match_operand:SI 2 "mcore_arith_reg_operand" "0")))]
""
"ixh %0,%1")
(define_insn ""
[(set (match_operand:SI 0 "mcore_reload_operand" "=r,r,r")
(plus:SI (plus:SI (mult:SI (match_operand:SI 1 "mcore_reload_operand" "r,r,r")
(const_int 2))
(match_operand:SI 2 "mcore_arith_reg_operand" "0,0,0"))
(match_operand:SI 3 "mcore_addsub_operand" "r,J,L")))]
"reload_in_progress"
"@
ixh %0,%1\;addu %0,%3
ixh %0,%1\;addi %0,%3
ixh %0,%1\;subi %0,%M3"
[(set_attr "length" "4")])
;;
;; Other sizes may be handy for indexing.
;; the tradeoffs to consider when adding these are
;; code size, execution time [vs. mul it is easy to win],
;; and register pressure -- these patterns don't use an extra
;; register to build the offset from the base
;; and whether the compiler will not come up with some other idiom.
;;
;; -------------------------------------------------------------------------
;; Addition, Subtraction instructions
;; -------------------------------------------------------------------------
(define_expand "addsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "nonmemory_operand" "")))]
""
"
{
extern int flag_omit_frame_pointer;
/* If this is an add to the frame pointer, then accept it as is so
that we can later fold in the fp/sp offset from frame pointer
elimination. */
if (flag_omit_frame_pointer
&& GET_CODE (operands[1]) == REG
&& (REGNO (operands[1]) == VIRTUAL_STACK_VARS_REGNUM
|| REGNO (operands[1]) == FRAME_POINTER_REGNUM))
{
emit_insn (gen_addsi3_fp (operands[0], operands[1], operands[2]));
DONE;
}
/* Convert adds to subtracts if this makes loading the constant cheaper.
But only if we are allowed to generate new pseudos. */
if (! (reload_in_progress || reload_completed)
&& GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < -32)
{
int neg_value = - INTVAL (operands[2]);
if ( CONST_OK_FOR_I (neg_value)
|| CONST_OK_FOR_M (neg_value)
|| CONST_OK_FOR_N (neg_value))
{
operands[2] = copy_to_mode_reg (SImode, GEN_INT (neg_value));
emit_insn (gen_subsi3 (operands[0], operands[1], operands[2]));
DONE;
}
}
if (! mcore_addsub_operand (operands[2], SImode))
operands[2] = copy_to_mode_reg (SImode, operands[2]);
}")
;; RBE: for some constants which are not in the range which allows
;; us to do a single operation, we will try a paired addi/addi instead
;; of a movi/addi. This relieves some register pressure at the expense
;; of giving away some potential constant reuse.
;;
;; RBE 6/17/97: this didn't buy us anything, but I keep the pattern
;; for later reference
;;
;; (define_insn "addsi3_i2"
;; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
;; (plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
;; (match_operand:SI 2 "const_int_operand" "g")))]
;; "GET_CODE(operands[2]) == CONST_INT
;; && ((INTVAL (operands[2]) > 32 && INTVAL(operands[2]) <= 64)
;; || (INTVAL (operands[2]) < -32 && INTVAL(operands[2]) >= -64))"
;; "*
;; {
;; int n = INTVAL(operands[2]);
;; if (n > 0)
;; {
;; operands[2] = GEN_INT(n - 32);
;; return \"addi\\t%0,32\;addi\\t%0,%2\";
;; }
;; else
;; {
;; n = (-n);
;; operands[2] = GEN_INT(n - 32);
;; return \"subi\\t%0,32\;subi\\t%0,%2\";
;; }
;; }"
;; [(set_attr "length" "4")])
(define_insn "addsi3_i"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r")
(plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0,0,0")
(match_operand:SI 2 "mcore_addsub_operand" "r,J,L")))]
""
"@
addu %0,%2
addi %0,%2
subi %0,%M2")
;; This exists so that address computations based on the frame pointer
;; can be folded in when frame pointer elimination occurs. Ordinarily
;; this would be bad because it allows insns which would require reloading,
;; but without it, we get multiple adds where one would do.
(define_insn "addsi3_fp"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r")
(plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0,0,0")
(match_operand:SI 2 "immediate_operand" "r,J,L")))]
"flag_omit_frame_pointer
&& (reload_in_progress || reload_completed || REGNO (operands[1]) == FRAME_POINTER_REGNUM)"
"@
addu %0,%2
addi %0,%2
subi %0,%M2")
;; RBE: for some constants which are not in the range which allows
;; us to do a single operation, we will try a paired addi/addi instead
;; of a movi/addi. This relieves some register pressure at the expense
;; of giving away some potential constant reuse.
;;
;; RBE 6/17/97: this didn't buy us anything, but I keep the pattern
;; for later reference
;;
;; (define_insn "subsi3_i2"
;; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
;; (plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
;; (match_operand:SI 2 "const_int_operand" "g")))]
;; "TARGET_RBETEST && GET_CODE(operands[2]) == CONST_INT
;; && ((INTVAL (operands[2]) > 32 && INTVAL(operands[2]) <= 64)
;; || (INTVAL (operands[2]) < -32 && INTVAL(operands[2]) >= -64))"
;; "*
;; {
;; int n = INTVAL(operands[2]);
;; if ( n > 0)
;; {
;; operands[2] = GEN_INT( n - 32);
;; return \"subi\\t%0,32\;subi\\t%0,%2\";
;; }
;; else
;; {
;; n = (-n);
;; operands[2] = GEN_INT(n - 32);
;; return \"addi\\t%0,32\;addi\\t%0,%2\";
;; }
;; }"
;; [(set_attr "length" "4")])
;(define_insn "subsi3"
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
; (minus:SI (match_operand:SI 1 "mcore_arith_K_operand" "0,0,r,K")
; (match_operand:SI 2 "mcore_arith_J_operand" "r,J,0,0")))]
; ""
; "@
; sub %0,%2
; subi %0,%2
; rsub %0,%1
; rsubi %0,%1")
(define_insn "subsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r")
(minus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,0,r")
(match_operand:SI 2 "mcore_arith_J_operand" "r,J,0")))]
""
"@
subu %0,%2
subi %0,%2
rsub %0,%1")
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(minus:SI (match_operand:SI 1 "mcore_literal_K_operand" "K")
(match_operand:SI 2 "mcore_arith_reg_operand" "0")))]
""
"rsubi %0,%1")
(define_insn "adddi3"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
(match_operand:DI 2 "mcore_arith_reg_operand" "r")))
(clobber (reg:CC 17))]
""
"*
{
if (TARGET_LITTLE_END)
return \"cmplt %0,%0\;addc %0,%2\;addc %R0,%R2\";
return \"cmplt %R0,%R0\;addc %R0,%R2\;addc %0,%2\";
}"
[(set_attr "length" "6")])
;; special case for "longlong += 1"
(define_insn ""
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")
(const_int 1)))
(clobber (reg:CC 17))]
""
"*
{
if (TARGET_LITTLE_END)
return \"addi %0,1\;cmpnei %0,0\;incf %R0\";
return \"addi %R0,1\;cmpnei %R0,0\;incf %0\";
}"
[(set_attr "length" "6")])
;; special case for "longlong -= 1"
(define_insn ""
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")
(const_int -1)))
(clobber (reg:CC 17))]
""
"*
{
if (TARGET_LITTLE_END)
return \"cmpnei %0,0\;decf %R0\;subi %0,1\";
return \"cmpnei %R0,0\;decf %0\;subi %R0,1\";
}"
[(set_attr "length" "6")])
;; special case for "longlong += const_int"
;; we have to use a register for the const_int because we don't
;; have an unsigned compare immediate... only +/- 1 get to
;; play the no-extra register game because they compare with 0.
;; This winds up working out for any literal that is synthesized
;; with a single instruction. The more complicated ones look
;; like the get broken into subreg's to get initialized too soon
;; for us to catch here. -- RBE 4/25/96
;; only allow for-sure positive values.
(define_insn ""
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")
(match_operand:SI 2 "const_int_operand" "r")))
(clobber (reg:CC 17))]
"GET_CODE (operands[2]) == CONST_INT
&& INTVAL (operands[2]) > 0 && ! (INTVAL (operands[2]) & 0x80000000)"
"*
{
gcc_assert (GET_MODE (operands[2]) == SImode);
if (TARGET_LITTLE_END)
return \"addu %0,%2\;cmphs %0,%2\;incf %R0\";
return \"addu %R0,%2\;cmphs %R0,%2\;incf %0\";
}"
[(set_attr "length" "6")])
;; optimize "long long" + "unsigned long"
;; won't trigger because of how the extension is expanded upstream.
;; (define_insn ""
;; [(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
;; (plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
;; (zero_extend:DI (match_operand:SI 2 "mcore_arith_reg_operand" "r"))))
;; (clobber (reg:CC 17))]
;; "0"
;; "cmplt %R0,%R0\;addc %R0,%2\;inct %0"
;; [(set_attr "length" "6")])
;; optimize "long long" + "signed long"
;; won't trigger because of how the extension is expanded upstream.
;; (define_insn ""
;; [(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
;; (plus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "%0")
;; (sign_extend:DI (match_operand:SI 2 "mcore_arith_reg_operand" "r"))))
;; (clobber (reg:CC 17))]
;; "0"
;; "cmplt %R0,%R0\;addc %R0,%2\;inct %0\;btsti %2,31\;dect %0"
;; [(set_attr "length" "6")])
(define_insn "subdi3"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(minus:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")
(match_operand:DI 2 "mcore_arith_reg_operand" "r")))
(clobber (reg:CC 17))]
""
"*
{
if (TARGET_LITTLE_END)
return \"cmphs %0,%0\;subc %0,%2\;subc %R0,%R2\";
return \"cmphs %R0,%R0\;subc %R0,%R2\;subc %0,%2\";
}"
[(set_attr "length" "6")])
;; -------------------------------------------------------------------------
;; Multiplication instructions
;; -------------------------------------------------------------------------
(define_insn "mulsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(mult:SI (match_operand:SI 1 "mcore_arith_reg_operand" "%0")
(match_operand:SI 2 "mcore_arith_reg_operand" "r")))]
""
"mult %0,%2")
;;
;; 32/32 signed division -- added to the MCORE instruction set spring 1997
;;
;; Different constraints based on the architecture revision...
;;
(define_expand "divsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(div:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
"TARGET_DIV"
"")
;; MCORE Revision 1.50: restricts the divisor to be in r1. (6/97)
;;
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(div:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
(match_operand:SI 2 "mcore_arith_reg_operand" "b")))]
"TARGET_DIV"
"divs %0,%2")
;;
;; 32/32 signed division -- added to the MCORE instruction set spring 1997
;;
;; Different constraints based on the architecture revision...
;;
(define_expand "udivsi3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(udiv:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
"TARGET_DIV"
"")
;; MCORE Revision 1.50: restricts the divisor to be in r1. (6/97)
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(udiv:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
(match_operand:SI 2 "mcore_arith_reg_operand" "b")))]
"TARGET_DIV"
"divu %0,%2")
;; -------------------------------------------------------------------------
;; Unary arithmetic
;; -------------------------------------------------------------------------
(define_insn "negsi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(neg:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")))]
""
"*
{
return \"rsubi %0,0\";
}")
(define_insn "abssi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(abs:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")))]
""
"abs %0")
(define_insn "negdi2"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=&r")
(neg:DI (match_operand:DI 1 "mcore_arith_reg_operand" "0")))
(clobber (reg:CC 17))]
""
"*
{
if (TARGET_LITTLE_END)
return \"cmpnei %0,0\\n\\trsubi %0,0\\n\\tnot %R0\\n\\tincf %R0\";
return \"cmpnei %R0,0\\n\\trsubi %R0,0\\n\\tnot %0\\n\\tincf %0\";
}"
[(set_attr "length" "8")])
(define_insn "one_cmplsi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(not:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")))]
""
"not %0")
;; -------------------------------------------------------------------------
;; Zero extension instructions
;; -------------------------------------------------------------------------
(define_expand "zero_extendhisi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(zero_extend:SI (match_operand:HI 1 "mcore_arith_reg_operand" "")))]
""
"")
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r")
(zero_extend:SI (match_operand:HI 1 "general_operand" "0,m")))]
""
"@
zexth %0
ld.h %0,%1"
[(set_attr "type" "shift,load")])
;; ldh gives us a free zero-extension. The combiner picks up on this.
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:SI (mem:HI (match_operand:SI 1 "mcore_arith_reg_operand" "r"))))]
""
"ld.h %0,(%1)"
[(set_attr "type" "load")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:SI (mem:HI (plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(match_operand:SI 2 "const_int_operand" "")))))]
"(INTVAL (operands[2]) >= 0) &&
(INTVAL (operands[2]) < 32) &&
((INTVAL (operands[2])&1) == 0)"
"ld.h %0,(%1,%2)"
[(set_attr "type" "load")])
(define_expand "zero_extendqisi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(zero_extend:SI (match_operand:QI 1 "general_operand" "")))]
""
"")
;; RBE: XXX: we don't recognize that the xtrb3 kills the CC register.
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,b,r")
(zero_extend:SI (match_operand:QI 1 "general_operand" "0,r,m")))]
""
"@
zextb %0
xtrb3 %0,%1
ld.b %0,%1"
[(set_attr "type" "shift,shift,load")])
;; ldb gives us a free zero-extension. The combiner picks up on this.
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:SI (mem:QI (match_operand:SI 1 "mcore_arith_reg_operand" "r"))))]
""
"ld.b %0,(%1)"
[(set_attr "type" "load")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:SI (mem:QI (plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(match_operand:SI 2 "const_int_operand" "")))))]
"(INTVAL (operands[2]) >= 0) &&
(INTVAL (operands[2]) < 16)"
"ld.b %0,(%1,%2)"
[(set_attr "type" "load")])
(define_expand "zero_extendqihi2"
[(set (match_operand:HI 0 "mcore_arith_reg_operand" "")
(zero_extend:HI (match_operand:QI 1 "general_operand" "")))]
""
"")
;; RBE: XXX: we don't recognize that the xtrb3 kills the CC register.
(define_insn ""
[(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r,b,r")
(zero_extend:HI (match_operand:QI 1 "general_operand" "0,r,m")))]
""
"@
zextb %0
xtrb3 %0,%1
ld.b %0,%1"
[(set_attr "type" "shift,shift,load")])
;; ldb gives us a free zero-extension. The combiner picks up on this.
;; this doesn't catch references that are into a structure.
;; note that normally the compiler uses the above insn, unless it turns
;; out that we're dealing with a volatile...
(define_insn ""
[(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:HI (mem:QI (match_operand:SI 1 "mcore_arith_reg_operand" "r"))))]
""
"ld.b %0,(%1)"
[(set_attr "type" "load")])
(define_insn ""
[(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r")
(zero_extend:HI (mem:QI (plus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(match_operand:SI 2 "const_int_operand" "")))))]
"(INTVAL (operands[2]) >= 0) &&
(INTVAL (operands[2]) < 16)"
"ld.b %0,(%1,%2)"
[(set_attr "type" "load")])
;; -------------------------------------------------------------------------
;; Sign extension instructions
;; -------------------------------------------------------------------------
(define_expand "extendsidi2"
[(set (match_operand:DI 0 "mcore_arith_reg_operand" "=r")
(match_operand:SI 1 "mcore_arith_reg_operand" "r"))]
""
"
{
int low, high;
if (TARGET_LITTLE_END)
low = 0, high = 4;
else
low = 4, high = 0;
emit_insn (gen_rtx_SET (VOIDmode, gen_rtx_SUBREG (SImode, operands[0], low),
operands[1]));
emit_insn (gen_rtx_SET (VOIDmode, gen_rtx_SUBREG (SImode, operands[0], high),
gen_rtx_ASHIFTRT (SImode,
gen_rtx_SUBREG (SImode, operands[0], low),
GEN_INT (31))));
DONE;
}"
)
(define_insn "extendhisi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(sign_extend:SI (match_operand:HI 1 "mcore_arith_reg_operand" "0")))]
""
"sexth %0")
(define_insn "extendqisi2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(sign_extend:SI (match_operand:QI 1 "mcore_arith_reg_operand" "0")))]
""
"sextb %0")
(define_insn "extendqihi2"
[(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r")
(sign_extend:HI (match_operand:QI 1 "mcore_arith_reg_operand" "0")))]
""
"sextb %0")
;; -------------------------------------------------------------------------
;; Move instructions
;; -------------------------------------------------------------------------
;; SImode
(define_expand "movsi"
[(set (match_operand:SI 0 "general_operand" "")
(match_operand:SI 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (SImode, operands[1]);
}")
(define_insn ""
[(set (match_operand:SI 0 "mcore_general_movdst_operand" "=r,r,a,r,a,r,m")
(match_operand:SI 1 "mcore_general_movsrc_operand" "r,P,i,c,R,m,r"))]
"(register_operand (operands[0], SImode)
|| register_operand (operands[1], SImode))"
"* return mcore_output_move (insn, operands, SImode);"
[(set_attr "type" "move,move,move,move,load,load,store")])
;;
;; HImode
;;
(define_expand "movhi"
[(set (match_operand:HI 0 "general_operand" "")
(match_operand:HI 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (HImode, operands[1]);
else if (CONSTANT_P (operands[1])
&& (GET_CODE (operands[1]) != CONST_INT
|| (! CONST_OK_FOR_I (INTVAL (operands[1]))
&& ! CONST_OK_FOR_M (INTVAL (operands[1]))
&& ! CONST_OK_FOR_N (INTVAL (operands[1]))))
&& ! reload_completed && ! reload_in_progress)
{
rtx reg = gen_reg_rtx (SImode);
emit_insn (gen_movsi (reg, operands[1]));
operands[1] = gen_lowpart (HImode, reg);
}
}")
(define_insn ""
[(set (match_operand:HI 0 "mcore_general_movdst_operand" "=r,r,a,r,r,m")
(match_operand:HI 1 "mcore_general_movsrc_operand" "r,P,i,c,m,r"))]
"(register_operand (operands[0], HImode)
|| register_operand (operands[1], HImode))"
"* return mcore_output_move (insn, operands, HImode);"
[(set_attr "type" "move,move,move,move,load,store")])
;;
;; QImode
;;
(define_expand "movqi"
[(set (match_operand:QI 0 "general_operand" "")
(match_operand:QI 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (QImode, operands[1]);
else if (CONSTANT_P (operands[1])
&& (GET_CODE (operands[1]) != CONST_INT
|| (! CONST_OK_FOR_I (INTVAL (operands[1]))
&& ! CONST_OK_FOR_M (INTVAL (operands[1]))
&& ! CONST_OK_FOR_N (INTVAL (operands[1]))))
&& ! reload_completed && ! reload_in_progress)
{
rtx reg = gen_reg_rtx (SImode);
emit_insn (gen_movsi (reg, operands[1]));
operands[1] = gen_lowpart (QImode, reg);
}
}")
(define_insn ""
[(set (match_operand:QI 0 "mcore_general_movdst_operand" "=r,r,a,r,r,m")
(match_operand:QI 1 "mcore_general_movsrc_operand" "r,P,i,c,m,r"))]
"(register_operand (operands[0], QImode)
|| register_operand (operands[1], QImode))"
"* return mcore_output_move (insn, operands, QImode);"
[(set_attr "type" "move,move,move,move,load,store")])
;; DImode
(define_expand "movdi"
[(set (match_operand:DI 0 "general_operand" "")
(match_operand:DI 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (DImode, operands[1]);
else if (GET_CODE (operands[1]) == CONST_INT
&& ! CONST_OK_FOR_I (INTVAL (operands[1]))
&& ! CONST_OK_FOR_M (INTVAL (operands[1]))
&& ! CONST_OK_FOR_N (INTVAL (operands[1])))
{
int i;
for (i = 0; i < UNITS_PER_WORD * 2; i += UNITS_PER_WORD)
emit_move_insn (simplify_gen_subreg (SImode, operands[0], DImode, i),
simplify_gen_subreg (SImode, operands[1], DImode, i));
DONE;
}
}")
(define_insn "movdi_i"
[(set (match_operand:DI 0 "general_operand" "=r,r,r,r,a,r,m")
(match_operand:DI 1 "mcore_general_movsrc_operand" "I,M,N,r,R,m,r"))]
""
"* return mcore_output_movedouble (operands, DImode);"
[(set_attr "length" "4") (set_attr "type" "move,move,move,move,load,load,store")])
;; SFmode
(define_expand "movsf"
[(set (match_operand:SF 0 "general_operand" "")
(match_operand:SF 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (SFmode, operands[1]);
}")
(define_insn "movsf_i"
[(set (match_operand:SF 0 "general_operand" "=r,r,m")
(match_operand:SF 1 "general_operand" "r,m,r"))]
""
"@
mov %0,%1
ld.w %0,%1
st.w %1,%0"
[(set_attr "type" "move,load,store")])
;; DFmode
(define_expand "movdf"
[(set (match_operand:DF 0 "general_operand" "")
(match_operand:DF 1 "general_operand" ""))]
""
"
{
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (DFmode, operands[1]);
}")
(define_insn "movdf_k"
[(set (match_operand:DF 0 "general_operand" "=r,r,m")
(match_operand:DF 1 "general_operand" "r,m,r"))]
""
"* return mcore_output_movedouble (operands, DFmode);"
[(set_attr "length" "4") (set_attr "type" "move,load,store")])
;; Load/store multiple
;; ??? This is not currently used.
(define_insn "ldm"
[(set (match_operand:TI 0 "mcore_arith_reg_operand" "=r")
(mem:TI (match_operand:SI 1 "mcore_arith_reg_operand" "r")))]
""
"ldq %U0,(%1)")
;; ??? This is not currently used.
(define_insn "stm"
[(set (mem:TI (match_operand:SI 0 "mcore_arith_reg_operand" "r"))
(match_operand:TI 1 "mcore_arith_reg_operand" "r"))]
""
"stq %U1,(%0)")
(define_expand "load_multiple"
[(match_par_dup 3 [(set (match_operand:SI 0 "" "")
(match_operand:SI 1 "" ""))
(use (match_operand:SI 2 "" ""))])]
""
"
{
int regno, count, i;
/* Support only loading a constant number of registers from memory and
only if at least two registers. The last register must be r15. */
if (GET_CODE (operands[2]) != CONST_INT
|| INTVAL (operands[2]) < 2
|| GET_CODE (operands[1]) != MEM
|| XEXP (operands[1], 0) != stack_pointer_rtx
|| GET_CODE (operands[0]) != REG
|| REGNO (operands[0]) + INTVAL (operands[2]) != 16)
FAIL;
count = INTVAL (operands[2]);
regno = REGNO (operands[0]);
operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
for (i = 0; i < count; i++)
XVECEXP (operands[3], 0, i)
= gen_rtx_SET (VOIDmode,
gen_rtx_REG (SImode, regno + i),
gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx,
i * 4)));
}")
(define_insn ""
[(match_parallel 0 "mcore_load_multiple_operation"
[(set (match_operand:SI 1 "mcore_arith_reg_operand" "=r")
(mem:SI (match_operand:SI 2 "register_operand" "r")))])]
"GET_CODE (operands[2]) == REG && REGNO (operands[2]) == STACK_POINTER_REGNUM"
"ldm %1-r15,(%2)")
(define_expand "store_multiple"
[(match_par_dup 3 [(set (match_operand:SI 0 "" "")
(match_operand:SI 1 "" ""))
(use (match_operand:SI 2 "" ""))])]
""
"
{
int regno, count, i;
/* Support only storing a constant number of registers to memory and
only if at least two registers. The last register must be r15. */
if (GET_CODE (operands[2]) != CONST_INT
|| INTVAL (operands[2]) < 2
|| GET_CODE (operands[0]) != MEM
|| XEXP (operands[0], 0) != stack_pointer_rtx
|| GET_CODE (operands[1]) != REG
|| REGNO (operands[1]) + INTVAL (operands[2]) != 16)
FAIL;
count = INTVAL (operands[2]);
regno = REGNO (operands[1]);
operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
for (i = 0; i < count; i++)
XVECEXP (operands[3], 0, i)
= gen_rtx_SET (VOIDmode,
gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx,
i * 4)),
gen_rtx_REG (SImode, regno + i));
}")
(define_insn ""
[(match_parallel 0 "mcore_store_multiple_operation"
[(set (mem:SI (match_operand:SI 2 "register_operand" "r"))
(match_operand:SI 1 "mcore_arith_reg_operand" "r"))])]
"GET_CODE (operands[2]) == REG && REGNO (operands[2]) == STACK_POINTER_REGNUM"
"stm %1-r15,(%2)")
;; ------------------------------------------------------------------------
;; Define the real conditional branch instructions.
;; ------------------------------------------------------------------------
(define_insn "branch_true"
[(set (pc) (if_then_else (ne (reg:CC 17) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"jbt %l0"
[(set_attr "type" "brcond")])
(define_insn "branch_false"
[(set (pc) (if_then_else (eq (reg:CC 17) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"jbf %l0"
[(set_attr "type" "brcond")])
(define_insn "inverse_branch_true"
[(set (pc) (if_then_else (ne (reg:CC 17) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"jbf %l0"
[(set_attr "type" "brcond")])
(define_insn "inverse_branch_false"
[(set (pc) (if_then_else (eq (reg:CC 17) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"jbt %l0"
[(set_attr "type" "brcond")])
;; Conditional branch insns
;; At top-level, condition test are eq/ne, because we
;; are comparing against the condition register (which
;; has the result of the true relational test
; There is no beq compare, so we reverse the branch arms.
(define_expand "beq"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"
{
operands[1] = mcore_gen_compare_reg (EQ);
}")
(define_expand "bne"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
operands[1] = mcore_gen_compare_reg (NE);
}")
; check whether (GT A imm) can become (LE A imm) with the branch reversed.
; if so, emit a (LT A imm + 1) in place of the (LE A imm). BRC
(define_expand "bgt"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
if (mcore_modify_comparison (LE))
{
emit_jump_insn (gen_reverse_blt (operands[0]));
DONE;
}
operands[1] = mcore_gen_compare_reg (GT);
}")
; There is no ble compare, so we reverse the branch arms.
; reversed the condition and branch arms for ble -- the check_dbra_loop()
; transformation assumes that ble uses a branch-true with the label as
; as the target. BRC
; check whether (LE A imm) can become (LT A imm + 1).
(define_expand "ble"
[(set (pc) (if_then_else (eq (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
if (mcore_modify_comparison (LE))
{
emit_jump_insn (gen_blt (operands[0]));
DONE;
}
operands[1] = mcore_gen_compare_reg (LE);
}")
; make generating a reversed blt simple
(define_expand "reverse_blt"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"
{
operands[1] = mcore_gen_compare_reg (LT);
}")
(define_expand "blt"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LT);
}")
; There is no bge compare, so we reverse the branch arms.
(define_expand "bge"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"
{
operands[1] = mcore_gen_compare_reg (GE);
}")
; There is no gtu compare, so we reverse the branch arms
;(define_expand "bgtu"
; [(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
; (pc)
; (label_ref (match_operand 0 "" ""))))]
; ""
; "
;{
; if (GET_CODE (arch_compare_op1) == CONST_INT
; && INTVAL (arch_compare_op1) == 0)
; operands[1] = mcore_gen_compare_reg (NE);
; else
; { if (mcore_modify_comparison (GTU))
; {
; emit_jump_insn (gen_bgeu (operands[0]));
; DONE;
; }
; operands[1] = mcore_gen_compare_reg (LEU);
; }
;}")
(define_expand "bgtu"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"
{
if (GET_CODE (arch_compare_op1) == CONST_INT
&& INTVAL (arch_compare_op1) == 0)
{
/* The inverse of '> 0' for an unsigned test is
'== 0' but we do not have such an instruction available.
Instead we must reverse the branch (back to the normal
ordering) and test '!= 0'. */
operands[1] = mcore_gen_compare_reg (NE);
emit_jump_insn (gen_rtx_SET (VOIDmode,
pc_rtx,
gen_rtx_IF_THEN_ELSE (VOIDmode,
gen_rtx_NE (VOIDmode,
operands[1],
const0_rtx),
gen_rtx_LABEL_REF (VOIDmode,operands[0]),
pc_rtx)));
DONE;
}
operands[1] = mcore_gen_compare_reg (GTU);
}")
(define_expand "bleu"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LEU);
}")
; There is no bltu compare, so we reverse the branch arms
(define_expand "bltu"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(pc)
(label_ref (match_operand 0 "" ""))))]
""
"
{
operands[1] = mcore_gen_compare_reg (LTU);
}")
(define_expand "bgeu"
[(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
(label_ref (match_operand 0 "" ""))
(pc)))]
""
"
{
operands[1] = mcore_gen_compare_reg (GEU);
}")
;; ------------------------------------------------------------------------
;; Jump and linkage insns
;; ------------------------------------------------------------------------
(define_insn "jump_real"
[(set (pc)
(label_ref (match_operand 0 "" "")))]
""
"jbr %l0"
[(set_attr "type" "branch")])
(define_expand "jump"
[(set (pc) (label_ref (match_operand 0 "" "")))]
""
"
{
emit_jump_insn (gen_jump_real (operand0));
DONE;
}
")
(define_insn "indirect_jump"
[(set (pc)
(match_operand:SI 0 "mcore_arith_reg_operand" "r"))]
""
"jmp %0"
[(set_attr "type" "jmp")])
(define_expand "call"
[(parallel[(call (match_operand:SI 0 "" "")
(match_operand 1 "" ""))
(clobber (reg:SI 15))])]
""
"
{
if (GET_CODE (operands[0]) == MEM
&& ! register_operand (XEXP (operands[0], 0), SImode)
&& ! mcore_symbolic_address_p (XEXP (operands[0], 0)))
operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
force_reg (Pmode, XEXP (operands[0], 0)));
}")
(define_insn "call_internal"
[(call (mem:SI (match_operand:SI 0 "mcore_call_address_operand" "riR"))
(match_operand 1 "" ""))
(clobber (reg:SI 15))]
""
"* return mcore_output_call (operands, 0);")
(define_expand "call_value"
[(parallel[(set (match_operand 0 "register_operand" "")
(call (match_operand:SI 1 "" "")
(match_operand 2 "" "")))
(clobber (reg:SI 15))])]
""
"
{
if (GET_CODE (operands[0]) == MEM
&& ! register_operand (XEXP (operands[0], 0), SImode)
&& ! mcore_symbolic_address_p (XEXP (operands[0], 0)))
operands[1] = gen_rtx_MEM (GET_MODE (operands[1]),
force_reg (Pmode, XEXP (operands[1], 0)));
}")
(define_insn "call_value_internal"
[(set (match_operand 0 "register_operand" "=r")
(call (mem:SI (match_operand:SI 1 "mcore_call_address_operand" "riR"))
(match_operand 2 "" "")))
(clobber (reg:SI 15))]
""
"* return mcore_output_call (operands, 1);")
(define_insn "call_value_struct"
[(parallel [(set (match_parallel 0 ""
[(expr_list (match_operand 3 "register_operand" "") (match_operand 4 "immediate_operand" ""))
(expr_list (match_operand 5 "register_operand" "") (match_operand 6 "immediate_operand" ""))])
(call (match_operand:SI 1 "" "")
(match_operand 2 "" "")))
(clobber (reg:SI 15))])]
""
"* return mcore_output_call (operands, 1);"
)
;; ------------------------------------------------------------------------
;; Misc insns
;; ------------------------------------------------------------------------
(define_insn "nop"
[(const_int 0)]
""
"or r0,r0")
(define_insn "tablejump"
[(set (pc)
(match_operand:SI 0 "mcore_arith_reg_operand" "r"))
(use (label_ref (match_operand 1 "" "")))]
""
"jmp %0"
[(set_attr "type" "jmp")])
(define_insn "*return"
[(return)]
"reload_completed && ! mcore_naked_function_p ()"
"jmp r15"
[(set_attr "type" "jmp")])
(define_insn "*no_return"
[(return)]
"reload_completed && mcore_naked_function_p ()"
""
[(set_attr "length" "0")]
)
(define_expand "prologue"
[(const_int 0)]
""
"mcore_expand_prolog (); DONE;")
(define_expand "epilogue"
[(return)]
""
"mcore_expand_epilog ();")
;; ------------------------------------------------------------------------
;; Scc instructions
;; ------------------------------------------------------------------------
(define_insn "mvc"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(ne:SI (reg:CC 17) (const_int 0)))]
""
"mvc %0"
[(set_attr "type" "move")])
(define_insn "mvcv"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(eq:SI (reg:CC 17) (const_int 0)))]
""
"mvcv %0"
[(set_attr "type" "move")])
; in 0.97 use (LE 0) with (LT 1) and complement c. BRC
(define_split
[(parallel[
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (gt:CC (match_operand:SI 1 "mcore_arith_reg_operand" "")
(const_int 0))
(const_int 0)))
(clobber (reg:SI 17))])]
""
[(set (reg:CC 17)
(lt:CC (match_dup 1) (const_int 1)))
(set (match_dup 0) (eq:SI (reg:CC 17) (const_int 0)))])
(define_expand "seq"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (NE);
}")
(define_expand "sne"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (NE);
}")
(define_expand "slt"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LT);
}")
; make generating a LT with the comparison reversed easy. BRC
(define_expand "reverse_slt"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LT);
}")
(define_expand "sge"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LT);
}")
; check whether (GT A imm) can become (LE A imm) with the comparison
; reversed. if so, emit a (LT A imm + 1) in place of the (LE A imm). BRC
(define_expand "sgt"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (match_dup 1) (const_int 0)))]
""
"
{
if (mcore_modify_comparison (LE))
{
emit_insn (gen_reverse_slt (operands[0]));
DONE;
}
operands[1] = mcore_gen_compare_reg (GT);
}")
(define_expand "sle"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
if (mcore_modify_comparison (LE))
{
emit_insn (gen_slt (operands[0]));
DONE;
}
operands[1] = mcore_gen_compare_reg (GT);
}")
(define_expand "sltu"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (GEU);
}")
(define_expand "sgeu"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (GEU);
}")
(define_expand "sgtu"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(eq:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LEU);
}")
(define_expand "sleu"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(ne:SI (match_dup 1) (const_int 0)))]
""
"
{
operands[1] = mcore_gen_compare_reg (LEU);
}")
(define_insn "incscc"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(plus:SI (ne (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_reg_operand" "0")))]
""
"inct %0")
(define_insn "incscc_false"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(plus:SI (eq (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_reg_operand" "0")))]
""
"incf %0")
(define_insn "decscc"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(minus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
(ne (reg:CC 17) (const_int 0))))]
""
"dect %0")
(define_insn "decscc_false"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(minus:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0")
(eq (reg:CC 17) (const_int 0))))]
""
"decf %0")
;; ------------------------------------------------------------------------
;; Conditional move patterns.
;; ------------------------------------------------------------------------
(define_expand "smaxsi3"
[(set (reg:CC 17)
(lt:CC (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(if_then_else:SI (eq (reg:CC 17) (const_int 0))
(match_dup 1) (match_dup 2)))]
""
"")
(define_split
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(smax:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
""
[(set (reg:CC 17)
(lt:SI (match_dup 1) (match_dup 2)))
(set (match_dup 0)
(if_then_else:SI (eq (reg:CC 17) (const_int 0))
(match_dup 1) (match_dup 2)))]
"")
; no tstgt in 0.97, so just use cmplti (btsti x,31) and reverse move
; condition BRC
(define_split
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(smax:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(const_int 0)))]
""
[(set (reg:CC 17)
(lt:CC (match_dup 1) (const_int 0)))
(set (match_dup 0)
(if_then_else:SI (eq (reg:CC 17) (const_int 0))
(match_dup 1) (const_int 0)))]
"")
(define_expand "sminsi3"
[(set (reg:CC 17)
(lt:CC (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(if_then_else:SI (ne (reg:CC 17) (const_int 0))
(match_dup 1) (match_dup 2)))]
""
"")
(define_split
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(smin:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
""
[(set (reg:CC 17)
(lt:SI (match_dup 1) (match_dup 2)))
(set (match_dup 0)
(if_then_else:SI (ne (reg:CC 17) (const_int 0))
(match_dup 1) (match_dup 2)))]
"")
;(define_split
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
; (smin:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
; (const_int 0)))]
; ""
; [(set (reg:CC 17)
; (gt:CC (match_dup 1) (const_int 0)))
; (set (match_dup 0)
; (if_then_else:SI (eq (reg:CC 17) (const_int 0))
; (match_dup 1) (const_int 0)))]
; "")
; changed these unsigned patterns to use geu instead of ltu. it appears
; that the c-torture & ssrl test suites didn't catch these! only showed
; up in friedman's clib work. BRC 7/7/95
(define_expand "umaxsi3"
[(set (reg:CC 17)
(geu:CC (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(if_then_else:SI (eq (reg:CC 17) (const_int 0))
(match_dup 2) (match_dup 1)))]
""
"")
(define_split
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(umax:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
""
[(set (reg:CC 17)
(geu:SI (match_dup 1) (match_dup 2)))
(set (match_dup 0)
(if_then_else:SI (eq (reg:CC 17) (const_int 0))
(match_dup 2) (match_dup 1)))]
"")
(define_expand "uminsi3"
[(set (reg:CC 17)
(geu:CC (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(if_then_else:SI (ne (reg:CC 17) (const_int 0))
(match_dup 2) (match_dup 1)))]
""
"")
(define_split
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(umin:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "mcore_arith_reg_operand" "")))]
""
[(set (reg:CC 17)
(geu:SI (match_dup 1) (match_dup 2)))
(set (match_dup 0)
(if_then_else:SI (ne (reg:CC 17) (const_int 0))
(match_dup 2) (match_dup 1)))]
"")
;; ------------------------------------------------------------------------
;; conditional move patterns really start here
;; ------------------------------------------------------------------------
;; the "movtK" patterns are experimental. they are intended to account for
;; gcc's mucking on code such as:
;;
;; free_ent = ((block_compress) ? 257 : 256 );
;;
;; these patterns help to get a tstne/bgeni/inct (or equivalent) sequence
;; when both arms have constants that are +/- 1 of each other.
;;
;; note in the following patterns that the "movtK" ones should be the first
;; one defined in each sequence. this is because the general pattern also
;; matches, so use ordering to determine priority (it's easier this way than
;; adding conditions to the general patterns). BRC
;;
;; the U and Q constraints are necessary to ensure that reload does the
;; 'right thing'. U constrains the operand to 0 and Q to 1 for use in the
;; clrt & clrf and clrt/inct & clrf/incf patterns. BRC 6/26
;;
;; ??? there appears to be some problems with these movtK patterns for ops
;; other than eq & ne. need to fix. 6/30 BRC
;; ------------------------------------------------------------------------
;; ne
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_1"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(ne (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
" GET_CODE (operands[1]) == CONST_INT
&& GET_CODE (operands[2]) == CONST_INT
&& ( (INTVAL (operands[1]) - INTVAL (operands[2]) == 1)
|| (INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov (operands, 1, NULL);"
[(set_attr "length" "4")])
(define_insn "movt0"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(ne (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movt %0,%1
movf %0,%2
clrt %0
clrf %0")
;; ------------------------------------------------------------------------
;; eq
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(eq (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
" GET_CODE (operands[1]) == CONST_INT
&& GET_CODE (operands[2]) == CONST_INT
&& ( (INTVAL (operands[1]) - INTVAL (operands[2]) == 1)
|| (INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov (operands, 0, NULL);"
[(set_attr "length" "4")])
(define_insn "movf0"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(eq (reg:CC 17) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movf %0,%1
movt %0,%2
clrf %0
clrt %0")
; turns lsli rx,imm/btsti rx,31 into btsti rx,imm. not done by a peephole
; because the instructions are not adjacent (peepholes are related by posn -
; not by dataflow). BRC
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (eq (zero_extract:SI
(match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 1)
(match_operand:SI 2 "mcore_literal_K_operand" "K,K,K,K"))
(const_int 0))
(match_operand:SI 3 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 4 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
btsti %1,%2\;movf %0,%3
btsti %1,%2\;movt %0,%4
btsti %1,%2\;clrf %0
btsti %1,%2\;clrt %0"
[(set_attr "length" "4")])
; turns sextb rx/btsti rx,31 into btsti rx,7. must be QImode to be safe. BRC
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (eq (lshiftrt:SI
(match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 7))
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
"GET_CODE (operands[1]) == SUBREG &&
GET_MODE (SUBREG_REG (operands[1])) == QImode"
"@
btsti %1,7\;movf %0,%2
btsti %1,7\;movt %0,%3
btsti %1,7\;clrf %0
btsti %1,7\;clrt %0"
[(set_attr "length" "4")])
;; ------------------------------------------------------------------------
;; ne
;; ------------------------------------------------------------------------
;; Combine creates this from an andn instruction in a scc sequence.
;; We must recognize it to get conditional moves generated.
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(ne (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_O_operand" "O")
(match_operand:SI 3 "mcore_arith_O_operand" "O")))]
" GET_CODE (operands[2]) == CONST_INT
&& GET_CODE (operands[3]) == CONST_INT
&& ( (INTVAL (operands[2]) - INTVAL (operands[3]) == 1)
|| (INTVAL (operands[3]) - INTVAL (operands[2]) == 1))"
"*
{
rtx out_operands[4];
out_operands[0] = operands[0];
out_operands[1] = operands[2];
out_operands[2] = operands[3];
out_operands[3] = operands[1];
return mcore_output_cmov (out_operands, 1, \"cmpnei %3,0\");
}"
[(set_attr "length" "6")])
(define_insn "movt2"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (ne (match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
cmpnei %1,0\;movt %0,%2
cmpnei %1,0\;movf %0,%3
cmpnei %1,0\;clrt %0
cmpnei %1,0\;clrf %0"
[(set_attr "length" "4")])
; turns lsli rx,imm/btsti rx,31 into btsti rx,imm. not done by a peephole
; because the instructions are not adjacent (peepholes are related by posn -
; not by dataflow). BRC
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (ne (zero_extract:SI
(match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 1)
(match_operand:SI 2 "mcore_literal_K_operand" "K,K,K,K"))
(const_int 0))
(match_operand:SI 3 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 4 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
btsti %1,%2\;movt %0,%3
btsti %1,%2\;movf %0,%4
btsti %1,%2\;clrt %0
btsti %1,%2\;clrf %0"
[(set_attr "length" "4")])
; turns sextb rx/btsti rx,31 into btsti rx,7. must be QImode to be safe. BRC
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (ne (lshiftrt:SI
(match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 7))
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
"GET_CODE (operands[1]) == SUBREG &&
GET_MODE (SUBREG_REG (operands[1])) == QImode"
"@
btsti %1,7\;movt %0,%2
btsti %1,7\;movf %0,%3
btsti %1,7\;clrt %0
btsti %1,7\;clrf %0"
[(set_attr "length" "4")])
;; ------------------------------------------------------------------------
;; eq/eq
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_4"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(eq (eq:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[1]) == CONST_INT &&
GET_CODE (operands[2]) == CONST_INT &&
((INTVAL (operands[1]) - INTVAL (operands[2]) == 1) ||
(INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov(operands, 1, NULL);"
[(set_attr "length" "4")])
(define_insn "movt3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(eq (eq:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movt %0,%1
movf %0,%2
clrt %0
clrf %0")
;; ------------------------------------------------------------------------
;; eq/ne
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_5"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(eq (ne:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[1]) == CONST_INT &&
GET_CODE (operands[2]) == CONST_INT &&
((INTVAL (operands[1]) - INTVAL (operands[2]) == 1) ||
(INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov (operands, 0, NULL);"
[(set_attr "length" "4")])
(define_insn "movf1"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(eq (ne:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movf %0,%1
movt %0,%2
clrf %0
clrt %0")
;; ------------------------------------------------------------------------
;; eq
;; ------------------------------------------------------------------------
;; Combine creates this from an andn instruction in a scc sequence.
;; We must recognize it to get conditional moves generated.
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_6"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(eq (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_O_operand" "O")
(match_operand:SI 3 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[1]) == CONST_INT &&
GET_CODE (operands[2]) == CONST_INT &&
((INTVAL (operands[2]) - INTVAL (operands[3]) == 1) ||
(INTVAL (operands[3]) - INTVAL (operands[2]) == 1))"
"*
{
rtx out_operands[4];
out_operands[0] = operands[0];
out_operands[1] = operands[2];
out_operands[2] = operands[3];
out_operands[3] = operands[1];
return mcore_output_cmov (out_operands, 0, \"cmpnei %3,0\");
}"
[(set_attr "length" "6")])
(define_insn "movf3"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (eq (match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
cmpnei %1,0\;movf %0,%2
cmpnei %1,0\;movt %0,%3
cmpnei %1,0\;clrf %0
cmpnei %1,0\;clrt %0"
[(set_attr "length" "4")])
;; ------------------------------------------------------------------------
;; ne/eq
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_7"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(ne (eq:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[1]) == CONST_INT &&
GET_CODE (operands[2]) == CONST_INT &&
((INTVAL (operands[1]) - INTVAL (operands[2]) == 1) ||
(INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov (operands, 0, NULL);"
[(set_attr "length" "4")])
(define_insn "movf4"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(ne (eq:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movf %0,%1
movt %0,%2
clrf %0
clrt %0")
;; ------------------------------------------------------------------------
;; ne/ne
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_8"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(ne (ne:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_O_operand" "O")
(match_operand:SI 2 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[1]) == CONST_INT &&
GET_CODE (operands[2]) == CONST_INT &&
((INTVAL (operands[1]) - INTVAL (operands[2]) == 1) ||
(INTVAL (operands[2]) - INTVAL (operands[1]) == 1))"
"* return mcore_output_cmov (operands, 1, NULL);"
[(set_attr "length" "4")])
(define_insn "movt4"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI
(ne (ne:SI (reg:CC 17) (const_int 0)) (const_int 0))
(match_operand:SI 1 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 2 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
movt %0,%1
movf %0,%2
clrt %0
clrf %0")
;; Also need patterns to recognize lt/ge, since otherwise the compiler will
;; try to output not/asri/tstne/movf.
;; ------------------------------------------------------------------------
;; lt
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_9"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(lt (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_O_operand" "O")
(match_operand:SI 3 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[2]) == CONST_INT &&
GET_CODE (operands[3]) == CONST_INT &&
((INTVAL (operands[2]) - INTVAL (operands[3]) == 1) ||
(INTVAL (operands[3]) - INTVAL (operands[2]) == 1))"
"*
{
rtx out_operands[4];
out_operands[0] = operands[0];
out_operands[1] = operands[2];
out_operands[2] = operands[3];
out_operands[3] = operands[1];
return mcore_output_cmov (out_operands, 1, \"btsti %3,31\");
}"
[(set_attr "length" "6")])
(define_insn "movt5"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (lt (match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
btsti %1,31\;movt %0,%2
btsti %1,31\;movf %0,%3
btsti %1,31\;clrt %0
btsti %1,31\;clrf %0"
[(set_attr "length" "4")])
;; ------------------------------------------------------------------------
;; ge
;; ------------------------------------------------------------------------
; experimental conditional move with two constants +/- 1 BRC
(define_insn "movtK_10"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(if_then_else:SI
(ge (match_operand:SI 1 "mcore_arith_reg_operand" "r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_O_operand" "O")
(match_operand:SI 3 "mcore_arith_O_operand" "O")))]
"GET_CODE (operands[2]) == CONST_INT &&
GET_CODE (operands[3]) == CONST_INT &&
((INTVAL (operands[2]) - INTVAL (operands[3]) == 1) ||
(INTVAL (operands[3]) - INTVAL (operands[2]) == 1))"
"*
{
rtx out_operands[4];
out_operands[0] = operands[0];
out_operands[1] = operands[2];
out_operands[2] = operands[3];
out_operands[3] = operands[1];
return mcore_output_cmov (out_operands, 0, \"btsti %3,31\");
}"
[(set_attr "length" "6")])
(define_insn "movf5"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,r,r,r")
(if_then_else:SI (ge (match_operand:SI 1 "mcore_arith_reg_operand" "r,r,r,r")
(const_int 0))
(match_operand:SI 2 "mcore_arith_imm_operand" "r,0,U,0")
(match_operand:SI 3 "mcore_arith_imm_operand" "0,r,0,U")))]
""
"@
btsti %1,31\;movf %0,%2
btsti %1,31\;movt %0,%3
btsti %1,31\;clrf %0
btsti %1,31\;clrt %0"
[(set_attr "length" "4")])
;; ------------------------------------------------------------------------
;; Bitfield extract (xtrbN)
;; ------------------------------------------------------------------------
; sometimes we're better off using QI/HI mode and letting the machine indep.
; part expand insv and extv.
;
; e.g., sequences like:a [an insertion]
;
; ldw r8,(r6)
; movi r7,0x00ffffff
; and r8,r7 r7 dead
; stw r8,(r6) r8 dead
;
; become:
;
; movi r8,0
; stb r8,(r6) r8 dead
;
; it looks like always using SI mode is a win except in this type of code
; (when adjacent bit fields collapse on a byte or halfword boundary). when
; expanding with SI mode, non-adjacent bit field masks fold, but with QI/HI
; mode, they do not. one thought is to add some peepholes to cover cases
; like the above, but this is not a general solution.
;
; -mword-bitfields expands/inserts using SI mode. otherwise, do it with
; the smallest mode possible (using the machine indep. expansions). BRC
;(define_expand "extv"
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
; (sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
; (match_operand:SI 2 "const_int_operand" "")
; (match_operand:SI 3 "const_int_operand" "")))
; (clobber (reg:CC 17))]
; ""
; "
;{
; if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) % 8 != 0)
; {
; if (TARGET_W_FIELD)
; {
; rtx lshft = GEN_INT (32 - (INTVAL (operands[2]) + INTVAL (operands[3])));
; rtx rshft = GEN_INT (32 - INTVAL (operands[2]));
;
; emit_insn (gen_rtx_SET (SImode, operands[0], operands[1]));
; emit_insn (gen_rtx_SET (SImode, operands[0],
; gen_rtx_ASHIFT (SImode, operands[0], lshft)));
; emit_insn (gen_rtx_SET (SImode, operands[0],
; gen_rtx_ASHIFTRT (SImode, operands[0], rshft)));
; DONE;
; }
; else
; FAIL;
; }
;}")
(define_expand "extv"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "const_int_operand" "")
(match_operand:SI 3 "const_int_operand" "")))
(clobber (reg:CC 17))]
""
"
{
if (INTVAL (operands[2]) == 8 && INTVAL (operands[3]) % 8 == 0)
{
/* 8 bit field, aligned properly, use the xtrb[0123]+sext sequence. */
/* not DONE, not FAIL, but let the RTL get generated.... */
}
else if (TARGET_W_FIELD)
{
/* Arbitrary placement; note that the tree->rtl generator will make
something close to this if we return FAIL */
rtx lshft = GEN_INT (32 - (INTVAL (operands[2]) + INTVAL (operands[3])));
rtx rshft = GEN_INT (32 - INTVAL (operands[2]));
rtx tmp1 = gen_reg_rtx (SImode);
rtx tmp2 = gen_reg_rtx (SImode);
emit_insn (gen_rtx_SET (SImode, tmp1, operands[1]));
emit_insn (gen_rtx_SET (SImode, tmp2,
gen_rtx_ASHIFT (SImode, tmp1, lshft)));
emit_insn (gen_rtx_SET (SImode, operands[0],
gen_rtx_ASHIFTRT (SImode, tmp2, rshft)));
DONE;
}
else
{
/* Let the caller choose an alternate sequence. */
FAIL;
}
}")
(define_expand "extzv"
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(zero_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "")
(match_operand:SI 2 "const_int_operand" "")
(match_operand:SI 3 "const_int_operand" "")))
(clobber (reg:CC 17))]
""
"
{
if (INTVAL (operands[2]) == 8 && INTVAL (operands[3]) % 8 == 0)
{
/* 8 bit field, aligned properly, use the xtrb[0123] sequence. */
/* Let the template generate some RTL.... */
}
else if (CONST_OK_FOR_K ((1 << INTVAL (operands[2])) - 1))
{
/* A narrow bit-field (<=5 bits) means we can do a shift to put
it in place and then use an andi to extract it.
This is as good as a shiftleft/shiftright. */
rtx shifted;
rtx mask = GEN_INT ((1 << INTVAL (operands[2])) - 1);
if (INTVAL (operands[3]) == 0)
{
shifted = operands[1];
}
else
{
rtx rshft = GEN_INT (INTVAL (operands[3]));
shifted = gen_reg_rtx (SImode);
emit_insn (gen_rtx_SET (SImode, shifted,
gen_rtx_LSHIFTRT (SImode, operands[1], rshft)));
}
emit_insn (gen_rtx_SET (SImode, operands[0],
gen_rtx_AND (SImode, shifted, mask)));
DONE;
}
else if (TARGET_W_FIELD)
{
/* Arbitrary pattern; play shift/shift games to get it.
* this is pretty much what the caller will do if we say FAIL */
rtx lshft = GEN_INT (32 - (INTVAL (operands[2]) + INTVAL (operands[3])));
rtx rshft = GEN_INT (32 - INTVAL (operands[2]));
rtx tmp1 = gen_reg_rtx (SImode);
rtx tmp2 = gen_reg_rtx (SImode);
emit_insn (gen_rtx_SET (SImode, tmp1, operands[1]));
emit_insn (gen_rtx_SET (SImode, tmp2,
gen_rtx_ASHIFT (SImode, tmp1, lshft)));
emit_insn (gen_rtx_SET (SImode, operands[0],
gen_rtx_LSHIFTRT (SImode, tmp2, rshft)));
DONE;
}
else
{
/* Make the compiler figure out some alternative mechanism. */
FAIL;
}
/* Emit the RTL pattern; something will match it later. */
}")
(define_expand "insv"
[(set (zero_extract:SI (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "const_int_operand" "")
(match_operand:SI 2 "const_int_operand" ""))
(match_operand:SI 3 "general_operand" ""))
(clobber (reg:CC 17))]
""
"
{
if (mcore_expand_insv (operands))
{
DONE;
}
else
{
FAIL;
}
}")
;;
;; the xtrb[0123] instructions handily get at 8-bit fields on nice boundaries.
;; but then, they do force you through r1.
;;
;; the combiner will build such patterns for us, so we'll make them available
;; for its use.
;;
;; Note that we have both SIGNED and UNSIGNED versions of these...
;;
;;
;; These no longer worry about the clobbering of CC bit; not sure this is
;; good...
;;
;; the SIGNED versions of these
;;
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,b")
(sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,r") (const_int 8) (const_int 24)))]
""
"@
asri %0,24
xtrb0 %0,%1\;sextb %0"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=b")
(sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r") (const_int 8) (const_int 16)))]
""
"xtrb1 %0,%1\;sextb %0"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=b")
(sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r") (const_int 8) (const_int 8)))]
""
"xtrb2 %0,%1\;sextb %0"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(sign_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0") (const_int 8) (const_int 0)))]
""
"sextb %0"
[(set_attr "type" "shift")])
;; the UNSIGNED uses of xtrb[0123]
;;
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,b")
(zero_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,r") (const_int 8) (const_int 24)))]
""
"@
lsri %0,24
xtrb0 %0,%1"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=b")
(zero_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r") (const_int 8) (const_int 16)))]
""
"xtrb1 %0,%1"
[(set_attr "type" "shift")])
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=b")
(zero_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "r") (const_int 8) (const_int 8)))]
""
"xtrb2 %0,%1"
[(set_attr "type" "shift")])
;; This can be peepholed if it follows a ldb ...
(define_insn ""
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r,b")
(zero_extract:SI (match_operand:SI 1 "mcore_arith_reg_operand" "0,r") (const_int 8) (const_int 0)))]
""
"@
zextb %0
xtrb3 %0,%1\;zextb %0"
[(set_attr "type" "shift")])
;; ------------------------------------------------------------------------
;; Block move - adapted from m88k.md
;; ------------------------------------------------------------------------
(define_expand "movmemsi"
[(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
(mem:BLK (match_operand:BLK 1 "" "")))
(use (match_operand:SI 2 "general_operand" ""))
(use (match_operand:SI 3 "immediate_operand" ""))])]
""
"
{
if (mcore_expand_block_move (operands))
DONE;
else
FAIL;
}")
;; ;;; ??? These patterns are meant to be generated from expand_block_move,
;; ;;; but they currently are not.
;;
;; (define_insn ""
;; [(set (match_operand:QI 0 "mcore_arith_reg_operand" "=r")
;; (match_operand:BLK 1 "mcore_general_movsrc_operand" "m"))]
;; ""
;; "ld.b %0,%1"
;; [(set_attr "type" "load")])
;;
;; (define_insn ""
;; [(set (match_operand:HI 0 "mcore_arith_reg_operand" "=r")
;; (match_operand:BLK 1 "mcore_general_movsrc_operand" "m"))]
;; ""
;; "ld.h %0,%1"
;; [(set_attr "type" "load")])
;;
;; (define_insn ""
;; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
;; (match_operand:BLK 1 "mcore_general_movsrc_operand" "m"))]
;; ""
;; "ld.w %0,%1"
;; [(set_attr "type" "load")])
;;
;; (define_insn ""
;; [(set (match_operand:BLK 0 "mcore_general_movdst_operand" "=m")
;; (match_operand:QI 1 "mcore_arith_reg_operand" "r"))]
;; ""
;; "st.b %1,%0"
;; [(set_attr "type" "store")])
;;
;; (define_insn ""
;; [(set (match_operand:BLK 0 "mcore_general_movdst_operand" "=m")
;; (match_operand:HI 1 "mcore_arith_reg_operand" "r"))]
;; ""
;; "st.h %1,%0"
;; [(set_attr "type" "store")])
;;
;; (define_insn ""
;; [(set (match_operand:BLK 0 "mcore_general_movdst_operand" "=m")
;; (match_operand:SI 1 "mcore_arith_reg_operand" "r"))]
;; ""
;; "st.w %1,%0"
;; [(set_attr "type" "store")])
;; ------------------------------------------------------------------------
;; Misc Optimizing quirks
;; ------------------------------------------------------------------------
;; pair to catch constructs like: (int *)((p+=4)-4) which happen
;; in stdarg/varargs traversal. This changes a 3 insn sequence to a 2
;; insn sequence. -- RBE 11/30/95
(define_insn ""
[(parallel[
(set (match_operand:SI 0 "mcore_arith_reg_operand" "=r")
(match_operand:SI 1 "mcore_arith_reg_operand" "+r"))
(set (match_dup 1) (plus:SI (match_dup 1) (match_operand 2 "mcore_arith_any_imm_operand" "")))])]
"GET_CODE(operands[2]) == CONST_INT"
"#"
[(set_attr "length" "4")])
(define_split
[(parallel[
(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "mcore_arith_reg_operand" ""))
(set (match_dup 1) (plus:SI (match_dup 1) (match_operand 2 "mcore_arith_any_imm_operand" "")))])]
"GET_CODE(operands[2]) == CONST_INT &&
operands[0] != operands[1]"
[(set (match_dup 0) (match_dup 1))
(set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))])
;;; Peepholes
; note: in the following patterns, use mcore_is_dead() to ensure that the
; reg we may be trashing really is dead. reload doesn't always mark
; deaths, so mcore_is_dead() (see mcore.c) scans forward to find its death. BRC
;;; A peephole to convert the 3 instruction sequence generated by reload
;;; to load a FP-offset address into a 2 instruction sequence.
;;; ??? This probably never matches anymore.
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "const_int_operand" "J"))
(set (match_dup 0) (neg:SI (match_dup 0)))
(set (match_dup 0)
(plus:SI (match_dup 0)
(match_operand:SI 2 "mcore_arith_reg_operand" "r")))]
"CONST_OK_FOR_J (INTVAL (operands[1]))"
"error\;mov %0,%2\;subi %0,%1")
;; Moves of inlinable constants are done late, so when a 'not' is generated
;; it is never combined with the following 'and' to generate an 'andn' b/c
;; the combiner never sees it. use a peephole to pick up this case (happens
;; mostly with bitfields) BRC
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(match_operand:SI 1 "const_int_operand" "i"))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "r")
(and:SI (match_dup 2) (match_dup 0)))]
"mcore_const_trick_uses_not (INTVAL (operands[1])) &&
operands[0] != operands[2] &&
mcore_is_dead (insn, operands[0])"
"* return mcore_output_andn (insn, operands);")
; when setting or clearing just two bits, it's cheapest to use two bseti's
; or bclri's. only happens when relaxing immediates. BRC
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "const_int_operand" ""))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "")
(ior:SI (match_dup 2) (match_dup 0)))]
"TARGET_HARDLIT && mcore_num_ones (INTVAL (operands[1])) == 2 &&
mcore_is_dead (insn, operands[0])"
"* return mcore_output_bseti (operands[2], INTVAL (operands[1]));")
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "const_int_operand" ""))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "")
(and:SI (match_dup 2) (match_dup 0)))]
"TARGET_HARDLIT && mcore_num_zeros (INTVAL (operands[1])) == 2 &&
mcore_is_dead (insn, operands[0])"
"* return mcore_output_bclri (operands[2], INTVAL (operands[1]));")
; change an and with a mask that has a single cleared bit into a bclri. this
; handles QI and HI mode values using the knowledge that the most significant
; bits don't matter.
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "const_int_operand" ""))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "")
(and:SI (match_operand:SI 3 "mcore_arith_reg_operand" "")
(match_dup 0)))]
"GET_CODE (operands[3]) == SUBREG &&
GET_MODE (SUBREG_REG (operands[3])) == QImode &&
mcore_num_zeros (INTVAL (operands[1]) | 0xffffff00) == 1 &&
mcore_is_dead (insn, operands[0])"
"*
if (! mcore_is_same_reg (operands[2], operands[3]))
output_asm_insn (\"mov\\t%2,%3\", operands);
return mcore_output_bclri (operands[2], INTVAL (operands[1]) | 0xffffff00);")
/* Do not fold these together -- mode is lost at final output phase. */
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "const_int_operand" ""))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "")
(and:SI (match_operand:SI 3 "mcore_arith_reg_operand" "")
(match_dup 0)))]
"GET_CODE (operands[3]) == SUBREG &&
GET_MODE (SUBREG_REG (operands[3])) == HImode &&
mcore_num_zeros (INTVAL (operands[1]) | 0xffff0000) == 1 &&
operands[2] == operands[3] &&
mcore_is_dead (insn, operands[0])"
"*
if (! mcore_is_same_reg (operands[2], operands[3]))
output_asm_insn (\"mov\\t%2,%3\", operands);
return mcore_output_bclri (operands[2], INTVAL (operands[1]) | 0xffff0000);")
; This peephole helps when using -mwide-bitfields to widen fields so they
; collapse. This, however, has the effect that a narrower mode is not used
; when desirable.
;
; e.g., sequences like:
;
; ldw r8,(r6)
; movi r7,0x00ffffff
; and r8,r7 r7 dead
; stw r8,(r6) r8 dead
;
; get peepholed to become:
;
; movi r8,0
; stb r8,(r6) r8 dead
;
; Do only easy addresses that have no offset. This peephole is also applied
; to halfwords. We need to check that the load is non-volatile before we get
; rid of it.
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "memory_operand" ""))
(set (match_operand:SI 2 "mcore_arith_reg_operand" "")
(match_operand:SI 3 "const_int_operand" ""))
(set (match_dup 0) (and:SI (match_dup 0) (match_dup 2)))
(set (match_operand:SI 4 "memory_operand" "") (match_dup 0))]
"mcore_is_dead (insn, operands[0]) &&
! MEM_VOLATILE_P (operands[1]) &&
mcore_is_dead (insn, operands[2]) &&
(mcore_byte_offset (INTVAL (operands[3])) > -1 ||
mcore_halfword_offset (INTVAL (operands[3])) > -1) &&
! MEM_VOLATILE_P (operands[4]) &&
GET_CODE (XEXP (operands[4], 0)) == REG"
"*
{
int ofs;
enum machine_mode mode;
rtx base_reg = XEXP (operands[4], 0);
if ((ofs = mcore_byte_offset (INTVAL (operands[3]))) > -1)
mode = QImode;
else if ((ofs = mcore_halfword_offset (INTVAL (operands[3]))) > -1)
mode = HImode;
else
gcc_unreachable ();
if (ofs > 0)
operands[4] = gen_rtx_MEM (mode,
gen_rtx_PLUS (SImode, base_reg, GEN_INT(ofs)));
else
operands[4] = gen_rtx_MEM (mode, base_reg);
if (mode == QImode)
return \"movi %0,0\\n\\tst.b %0,%4\";
return \"movi %0,0\\n\\tst.h %0,%4\";
}")
; from sop11. get btsti's for (LT A 0) where A is a QI or HI value
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(sign_extend:SI (match_operand:QI 1 "mcore_arith_reg_operand" "0")))
(set (reg:CC 17)
(lt:CC (match_dup 0)
(const_int 0)))]
"mcore_is_dead (insn, operands[0])"
"btsti %0,7")
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "r")
(sign_extend:SI (match_operand:HI 1 "mcore_arith_reg_operand" "0")))
(set (reg:CC 17)
(lt:CC (match_dup 0)
(const_int 0)))]
"mcore_is_dead (insn, operands[0])"
"btsti %0,15")
; Pick up a tst. This combination happens because the immediate is not
; allowed to fold into one of the operands of the tst. Does not happen
; when relaxing immediates. BRC
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(match_operand:SI 1 "mcore_arith_reg_operand" ""))
(set (match_dup 0)
(and:SI (match_dup 0)
(match_operand:SI 2 "mcore_literal_K_operand" "")))
(set (reg:CC 17) (ne:CC (match_dup 0) (const_int 0)))]
"mcore_is_dead (insn, operands[0])"
"movi %0,%2\;tst %1,%0")
(define_peephole
[(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
(if_then_else:SI (ne (zero_extract:SI
(match_operand:SI 1 "mcore_arith_reg_operand" "")
(const_int 1)
(match_operand:SI 2 "mcore_literal_K_operand" ""))
(const_int 0))
(match_operand:SI 3 "mcore_arith_imm_operand" "")
(match_operand:SI 4 "mcore_arith_imm_operand" "")))
(set (reg:CC 17) (ne:CC (match_dup 0) (const_int 0)))]
""
"*
{
unsigned int op0 = REGNO (operands[0]);
if (GET_CODE (operands[3]) == REG)
{
if (REGNO (operands[3]) == op0 && GET_CODE (operands[4]) == CONST_INT
&& INTVAL (operands[4]) == 0)
return \"btsti %1,%2\\n\\tclrf %0\";
else if (GET_CODE (operands[4]) == REG)
{
if (REGNO (operands[4]) == op0)
return \"btsti %1,%2\\n\\tmovf %0,%3\";
else if (REGNO (operands[3]) == op0)
return \"btsti %1,%2\\n\\tmovt %0,%4\";
}
gcc_unreachable ();
}
else if (GET_CODE (operands[3]) == CONST_INT
&& INTVAL (operands[3]) == 0
&& GET_CODE (operands[4]) == REG)
return \"btsti %1,%2\\n\\tclrt %0\";
gcc_unreachable ();
}")
; experimental - do the constant folding ourselves. note that this isn't
; re-applied like we'd really want. i.e., four ands collapse into two
; instead of one. this is because peepholes are applied as a sliding
; window. the peephole does not generate new rtl's, but instead slides
; across the rtl's generating machine instructions. it would be nice
; if the peephole optimizer is changed to re-apply patterns and to gen
; new rtl's. this is more flexible. the pattern below helps when we're
; not using relaxed immediates. BRC
;(define_peephole
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "")
; (match_operand:SI 1 "const_int_operand" ""))
; (set (match_operand:SI 2 "mcore_arith_reg_operand" "")
; (and:SI (match_dup 2) (match_dup 0)))
; (set (match_dup 0)
; (match_operand:SI 3 "const_int_operand" ""))
; (set (match_dup 2)
; (and:SI (match_dup 2) (match_dup 0)))]
; "!TARGET_RELAX_IMM && mcore_is_dead (insn, operands[0]) &&
; mcore_const_ok_for_inline (INTVAL (operands[1]) & INTVAL (operands[3]))"
; "*
;{
; rtx out_operands[2];
; out_operands[0] = operands[0];
; out_operands[1] = GEN_INT (INTVAL (operands[1]) & INTVAL (operands[3]));
;
; output_inline_const (SImode, out_operands);
;
; output_asm_insn (\"and %2,%0\", operands);
;
; return \"\";
;}")
; BRC: for inlining get rid of extra test - experimental
;(define_peephole
; [(set (match_operand:SI 0 "mcore_arith_reg_operand" "r")
; (ne:SI (reg:CC 17) (const_int 0)))
; (set (reg:CC 17) (ne:CC (match_dup 0) (const_int 0)))
; (set (pc)
; (if_then_else (eq (reg:CC 17) (const_int 0))
; (label_ref (match_operand 1 "" ""))
; (pc)))]
; ""
; "*
;{
; if (get_attr_length (insn) == 10)
; {
; output_asm_insn (\"bt 2f\\n\\tjmpi [1f]\", operands);
; output_asm_insn (\".align 2\\n1:\", operands);
; output_asm_insn (\".long %1\\n2:\", operands);
; return \"\";
; }
; return \"bf %l1\";
;}")
;;; Special patterns for dealing with the constant pool.
;;; 4 byte integer in line.
(define_insn "consttable_4"
[(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 0)]
""
"*
{
assemble_integer (operands[0], 4, BITS_PER_WORD, 1);
return \"\";
}"
[(set_attr "length" "4")])
;;; align to a four byte boundary.
(define_insn "align_4"
[(unspec_volatile [(const_int 0)] 1)]
""
".align 2")
;;; Handle extra constant pool entries created during final pass.
(define_insn "consttable_end"
[(unspec_volatile [(const_int 0)] 2)]
""
"* return mcore_output_jump_label_table ();")
;;
;; Stack allocation -- in particular, for alloca().
;; this is *not* what we use for entry into functions.
;;
;; This is how we allocate stack space. If we are allocating a
;; constant amount of space and we know it is less than 4096
;; bytes, we need do nothing.
;;
;; If it is more than 4096 bytes, we need to probe the stack
;; periodically.
;;
;; operands[1], the distance is a POSITIVE number indicating that we
;; are allocating stack space
;;
(define_expand "allocate_stack"
[(set (reg:SI 0)
(plus:SI (reg:SI 0)
(match_operand:SI 1 "general_operand" "")))
(set (match_operand:SI 0 "register_operand" "=r")
(match_dup 2))]
""
"
{
/* If he wants no probing, just do it for him. */
if (mcore_stack_increment == 0)
{
emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,operands[1]));
;; emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
DONE;
}
/* For small constant growth, we unroll the code. */
if (GET_CODE (operands[1]) == CONST_INT
&& INTVAL (operands[1]) < 8 * STACK_UNITS_MAXSTEP)
{
int left = INTVAL(operands[1]);
/* If it's a long way, get close enough for a last shot. */
if (left >= STACK_UNITS_MAXSTEP)
{
rtx tmp = gen_reg_rtx (Pmode);
emit_insn (gen_movsi (tmp, GEN_INT (STACK_UNITS_MAXSTEP)));
do
{
rtx memref = gen_rtx_MEM (SImode, stack_pointer_rtx);
MEM_VOLATILE_P (memref) = 1;
emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, tmp));
emit_insn (gen_movsi (memref, stack_pointer_rtx));
left -= STACK_UNITS_MAXSTEP;
}
while (left > STACK_UNITS_MAXSTEP);
}
/* Perform the final adjustment. */
emit_insn (gen_addsi3 (stack_pointer_rtx,stack_pointer_rtx,GEN_INT(-left)));
;; emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
DONE;
}
else
{
rtx out_label = 0;
rtx loop_label = gen_label_rtx ();
rtx step = gen_reg_rtx (Pmode);
rtx tmp = gen_reg_rtx (Pmode);
rtx memref;
#if 1
emit_insn (gen_movsi (tmp, operands[1]));
emit_insn (gen_movsi (step, GEN_INT(STACK_UNITS_MAXSTEP)));
if (GET_CODE (operands[1]) != CONST_INT)
{
out_label = gen_label_rtx ();
emit_insn (gen_cmpsi (step, tmp)); /* quick out */
emit_jump_insn (gen_bgeu (out_label));
}
/* Run a loop that steps it incrementally. */
emit_label (loop_label);
/* Extend a step, probe, and adjust remaining count. */
emit_insn(gen_subsi3(stack_pointer_rtx, stack_pointer_rtx, step));
memref = gen_rtx_MEM (SImode, stack_pointer_rtx);
MEM_VOLATILE_P (memref) = 1;
emit_insn(gen_movsi(memref, stack_pointer_rtx));
emit_insn(gen_subsi3(tmp, tmp, step));
/* Loop condition -- going back up. */
emit_insn (gen_cmpsi (step, tmp));
emit_jump_insn (gen_bltu (loop_label));
if (out_label)
emit_label (out_label);
/* Bump the residual. */
emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, tmp));
;; emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
DONE;
#else
/* simple one-shot -- ensure register and do a subtract.
* This does NOT comply with the ABI. */
emit_insn (gen_movsi (tmp, operands[1]));
emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, tmp));
;; emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
DONE;
#endif
}
}")
|