# Copyright (C) 2006-2012 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # mainmenu "OpenWrt Configuration" config HAVE_DOT_CONFIG bool default y source "target/Config.in" menu "Target Images" menuconfig TARGET_ROOTFS_INITRAMFS bool "ramdisk" default y if USES_INITRAMFS help Embed the rootfs into the kernel (initramfs) choice prompt "Compression" default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips default TARGET_INITRAMFS_COMPRESSION_NONE depends TARGET_ROOTFS_INITRAMFS help Select ramdisk compression. config TARGET_INITRAMFS_COMPRESSION_NONE bool "none" config TARGET_INITRAMFS_COMPRESSION_GZIP bool "gzip" config TARGET_INITRAMFS_COMPRESSION_BZIP2 bool "bzip2" config TARGET_INITRAMFS_COMPRESSION_LZMA bool "lzma" config TARGET_INITRAMFS_COMPRESSION_LZO bool "lzo" config TARGET_INITRAMFS_COMPRESSION_XZ bool "xz" endchoice config EXTERNAL_CPIO string prompt "Use external cpio" if TARGET_ROOTFS_INITRAMFS default "" help Kernel uses specified external cpio as INITRAMFS_SOURCE comment "Root filesystem archives" config TARGET_ROOTFS_CPIOGZ bool "cpio.gz" default y if USES_CPIOGZ help Build a compressed cpio archive of the the root filesystem config TARGET_ROOTFS_TARGZ bool "tar.gz" default y if USES_TARGZ help Build a compressed tar archive of the the root filesystem comment "Root filesystem images" config TARGET_ROOTFS_EXT4FS bool "ext4" default y if USES_EXT4 depends !TARGET_ROOTFS_INITRAMFS help Ext4 file system with some free space for uml images config TARGET_ROOTFS_ISO bool "iso" default n depends on TARGET_x86_generic depends !TARGET_ROOTFS_INITRAMFS help Create some bootable ISO image config TARGET_ROOTFS_JFFS2 bool "jffs2" default y if USES_JFFS2 depends !TARGET_ROOTFS_INITRAMFS help Build a jffs2 root filesystem config TARGET_ROOTFS_SQUASHFS bool "squashfs" default y if USES_SQUASHFS depends !TARGET_ROOTFS_INITRAMFS help Build a squashfs-lzma root filesystem config TARGET_ROOTFS_UBIFS bool "ubifs" default y if USES_UBIFS depends !TARGET_ROOTFS_INITRAMFS && USES_UBIFS help Build a ubifs root filesystem comment "Image Options" source "target/linux/*/image/Config.in" config TARGET_ROOTFS_PARTSIZE int "Root filesystem partition size (in MB)" depends X86_GRUB_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532 default 48 help Allows you to change the root filesystem partition size config TARGET_ROOTFS_MAXINODE int "Maximum number of inodes in root filesystem" depends TARGET_ROOTFS_EXT4FS default 6000 help Allows you to change the maximum number of inodes in the root filesystem config TARGET_ROOTFS_RESERVED_PCT int "Percentage of reserved blocks in root filesystem" depends TARGET_ROOTFS_EXT4FS default 0 help Allows you to change the percentage of reserved blocks in the root filesystem endmenu menu "Global build settings" config ALL bool "Select all packages by default" default n comment "General build options" config DISPLAY_SUPPORT bool "Show packages that require graphics support (local or remote)" default n config BUILD_PATENTED default y bool "Compile with support for patented functionality" help When this option is disabled, software which provides patented functionality will not be built. In case software provides optional support for patented functionality, this optional support will get disabled for this package. config BUILD_NLS default n bool "Compile with full language support" help When this option is enabled, packages are built with the full versions of iconv and GNU gettext instead of the default OpenWrt stubs. If uClibc is used, it is also built with locale support. config BUILD_STATIC_TOOLS default n bool "Attempt to link host utilities statically" help Linking host utilities like sed or firmware-utils statically increases the portability of the generated ImageBuilder and SDK tarballs, however it may fail on some Linux distributions. config SHADOW_PASSWORDS bool prompt "Enable shadow password support" default y help Enable shadow password support. config CLEAN_IPKG bool prompt "Remove ipkg/opkg status data files in final images" default n help This removes all ipkg/opkg status data files from the target directory before building the root fs config COLLECT_KERNEL_DEBUG bool prompt "Collect kernel debug information" select KERNEL_DEBUG_INFO default n help This collects debugging symbols from the kernel and all compiled modules. Useful for release builds, so that kernel issues can be debugged offline later. comment "Kernel build options" config KERNEL_DEBUG_FS bool "Compile the kernel with Debug FileSystem enabled" default y help debugfs is a virtual file system that kernel developers use to put debugging files into. Enable this option to be able to read and write to these files. config KERNEL_PERF_EVENTS bool default n config KERNEL_PROFILING bool "Compile the kernel with profiling enabled" default n select KERNEL_PERF_EVENTS help Enable the extended profiling support mechanisms used by profilers such as OProfile. config KERNEL_KALLSYMS bool "Compile the kernel with symbol table information" default y help This will give you more information in stack traces from kernel oopses config KERNEL_FTRACE bool "Compile the kernel with tracing support" default n config KERNEL_ENABLE_DEFAULT_TRACERS bool "Trace process context switches and events" depends on KERNEL_FTRACE default n config KERNEL_DEBUG_KERNEL bool default n config KERNEL_DEBUG_INFO bool "Compile the kernel with debug information" default y select KERNEL_DEBUG_KERNEL help This will compile your kernel and modules with debug information. config KERNEL_DEBUG_LL_UART_NONE bool default n depends on arm config KERNEL_DEBUG_LL bool default n depends on arm select KERNEL_DEBUG_LL_UART_NONE help ARM low level debugging config KERNEL_EARLY_PRINTK bool "Compile the kernel with early printk" default n depends on arm select KERNEL_DEBUG_KERNEL select KERNEL_DEBUG_LL if arm help Compile the kernel with early printk support. This is only useful for debugging purposes to send messages over the serial console in early boot. Enable this to debug early boot problems. config KERNEL_AIO bool "Compile the kernel with asynchronous IO support" default n config KERNEL_DIRECT_IO bool "Compile the kernel with direct IO support" default n config KERNEL_MAGIC_SYSRQ bool "Compile the kernel with SysRq support" default y config KERNEL_COREDUMP bool config KERNEL_ELF_CORE bool "Enable process core dump support" select KERNEL_COREDUMP default y config KERNEL_PROVE_LOCKING bool "Enable kernel lock checking" select KERNEL_DEBUG_KERNEL default n config KERNEL_PRINTK_TIME bool "Enable printk timestamps" default y config KERNEL_RELAY bool # # CGROUP support symbols # config KERNEL_FREEZER bool default y if KERNEL_CGROUP_FREEZER depends KERNEL_CGROUPS config KERNEL_CGROUP_FREEZER bool depends KERNEL_CGROUPS config KERNEL_CGROUP_DEVICE bool depends KERNEL_CGROUPS config KERNEL_CPUSETS bool default y if KERNEL_CGROUP_CPUACCT depends KERNEL_CGROUPS config KERNEL_PROC_PID_CPUSET bool default y if KERNEL_CGROUP_CPUACCT depends KERNEL_CGROUPS config KERNEL_CGROUP_CPUACCT bool depends KERNEL_CGROUPS config KERNEL_RESOURCE_COUNTERS bool default y if KERNEL_CGROUP_MEM_RES_CTLR depends KERNEL_CGROUPS config KERNEL_CGROUP_MEM_RES_CTLR bool depends KERNEL_CGROUPS config KERNEL_CGROUP_MEM_RES_CTLR_SWAP bool depends KERNEL_CGROUPS config KERNEL_CGROUP_MEM_RES_CTLR_SWAP_ENABLED bool depends KERNEL_CGROUPS config KERNEL_CGROUP_MEM_RES_CTLR_KMEM bool depends KERNEL_CGROUPS config KERNEL_CGROUP_PERF bool depends KERNEL_CGROUPS config KERNEL_CFS_BANDWIDTH bool default y if KERNEL_FAIR_GROUP_SCHED depends KERNEL_CGROUP_SCHED config KERNEL_FAIR_GROUP_SCHED bool default y if KERNEL_CGROUP_SCHED depends KERNEL_CGROUP_SCHED config KERNEL_RT_GROUP_SCHED bool default y if KERNEL_CGROUP_SCHED depends KERNEL_CGROUP_SCHED config KERNEL_CGROUP_SCHED bool depends KERNEL_CGROUPS config KERNEL_NET_CLS_CGROUP bool depends KERNEL_CGROUPS config KERNEL_NETPRIO_CGROUP bool depends KERNEL_CGROUPS config KERNEL_BLK_CGROUP bool depends KERNEL_CGROUPS config KERNEL_DEBUG_BLK_CGROUP bool default n if KERNEL_CGROUPS depends KERNEL_CGROUPS config KERNEL_CGROUPS bool "Enable kernel cgroups" default n select KERNEL_CGROUP_FREEZER select KERNEL_CGROUP_DEVICE select KERNEL_CGROUP_CPUACCT select KERNEL_CGROUP_MEM_RES_CTLR select KERNEL_CGROUP_MEM_RES_CTLR_SWAP select KERNEL_CGROUP_MEM_RES_CTLR_SWAP_ENABLED select KERNEL_CGROUP_MEM_RES_CTLR_KMEM select KERNEL_CGROUP_PERF select KERNEL_CGROUP_SCHED select KERNEL_NET_CLS_CGROUP select KERNEL_NETPRIO_CGROUP select KERNEL_BLK_CGROUP # # Namespace support symbols # config KERNEL_UTS_NS bool depends KERNEL_NAMESPACES config KERNEL_IPC_NS bool depends KERNEL_NAMESPACES config KERNEL_USER_NS bool depends KERNEL_NAMESPACES config KERNEL_PID_NS bool depends KERNEL_NAMESPACES config KERNEL_NET_NS bool depends KERNEL_NAMESPACES config KERNEL_DEVPTS_MULTIPLE_INSTANCES bool depends KERNEL_NAMESPACES config KERNEL_NAMESPACES bool "Enable kernel namespaces" default n select KERNEL_UTS_NS select KERNEL_IPC_NS select KERNEL_USER_NS select KERNEL_PID_NS select KERNEL_NET_NS select KERNEL_DEVPTS_MULTIPLE_INSTANCES comment "Package build options" config DEBUG bool prompt "Compile packages with debugging info" default n help Adds -g3 to the CFLAGS config IPV6 bool prompt "Enable IPv6 support in packages" default y help Enable IPV6 support in packages (passes --enable-ipv6 to configure scripts). config PKG_BUILD_PARALLEL bool prompt "Compile certain packages parallelized" default y help This adds a -jX option to certain packages that are known to behave well for parallel build. By default the package make processes use the main jobserver, in which case this option only takes effect when you add -jX to the make command. If you are unsure, select N. config PKG_BUILD_USE_JOBSERVER bool prompt "Use top-level make jobserver for packages" depends on PKG_BUILD_PARALLEL default y help This passes the main make process jobserver fds to package builds, enabling full parallelization across different packages Note that disabling this may overcommit CPU resources depending on the -j level of the main make process, the number of package submake jobs selected below and the number of actual CPUs present. Example: If the main make is passed a -j4 and the submake -j is also set to 4, we may end up with 16 parallel make processes in the worst case. config PKG_BUILD_JOBS int prompt "Number of package submake jobs (2-512)" range 2 512 default 2 depends on PKG_BUILD_PARALLEL && !PKG_BUILD_USE_JOBSERVER help The number of jobs (-jX) to pass to packages submake. config PKG_DEFAULT_PARALLEL bool prompt "Parallelize the default package build rule (May break build)" depends on PKG_BUILD_PARALLEL depends on BROKEN default n help Always set the default package build rules to parallel build. WARNING: This may break build or kill your cat, as it builds packages with multiple jobs that are probably not tested in a parallel build environment. Only say Y, if you don't mind fixing broken packages. Before reporting build bugs, set this to N and re-run the build. comment "Stripping options" choice prompt "Binary stripping method" default USE_STRIP if EXTERNAL_TOOLCHAIN default USE_STRIP if USE_GLIBC || USE_EGLIBC || USE_MUSL default USE_SSTRIP help Select the binary stripping method you wish to use. config NO_STRIP bool "none" help This will install unstripped binaries (useful for native compiling/debugging) config USE_STRIP bool "strip" help This will install binaries stripped using strip from binutils config USE_SSTRIP bool "sstrip" depends !DEBUG depends !USE_GLIBC depends !USE_EGLIBC help This will install binaries stripped using sstrip endchoice config STRIP_ARGS string prompt "Strip arguments" depends USE_STRIP default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG default "--strip-all" help Specifies arguments passed to the strip command when stripping binaries config STRIP_KERNEL_EXPORTS bool "Strip unnecessary exports from the kernel image" depends BROKEN help Reduces kernel size by stripping unused kernel exports from the kernel image Note that this might make the kernel incompatible with any kernel modules that were not selected at the time the kernel image was created config USE_MKLIBS bool "Strip unnecessary functions from libraries" help Reduces libraries to only those functions that are necessary for using all selected packages (including those selected as ) Note that this will make the system libraries incompatible with most of the packages that are not selected during the build process if INSTALL_LIBSTDCPP choice prompt "Preferred standard C++ library" default USE_LIBSTDCXX if USE_EGLIBC default USE_UCLIBCXX help Select the preferred standard C++ library for all packages that support this. config USE_UCLIBCXX bool "uClibc++" config USE_LIBSTDCXX bool "libstdc++" endchoice endif endmenu menuconfig DEVEL bool "Advanced configuration options (for developers)" default n config BROKEN bool "Show broken platforms / packages" if DEVEL default n config DOWNLOAD_FOLDER string "Download folder" if DEVEL default "" config LOCALMIRROR string "Local mirror for source packages" if DEVEL default "" config AUTOREBUILD bool "Automatic rebuild of packages" if DEVEL default y help Automatically rebuild packages when their files change config BUILD_SUFFIX string "Build suffix to append to the BUILD_DIR variable" if DEVEL default "" help Build suffix to append to the BUILD_DIR variable, i.e: build_dir_suffix config TARGET_ROOTFS_DIR string "Override the default TARGET_ROOTFS_DIR variable" if DEVEL default "" help Override the default TARGET_ROOTFS_DIR variable content $(BUILD_DIR) with custom path. Use this option to re-define the location of the target root file system directory. config CCACHE bool "Use ccache" if DEVEL default n help Compiler cache; see http://ccache.samba.org/ config EXTERNAL_KERNEL_TREE string "Use external kernel tree" if DEVEL default "" config KERNEL_GIT_CLONE_URI string "Enter git repository to clone" if DEVEL default "" help Enter the full git repository path i.e.: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git This will create a git clone of the kernel in your build directory. config KERNEL_GIT_LOCAL_REPOSITORY string "Enter path to local reference repository" if DEVEL default "" help Enter a full pathname to a local reference git repository. In this instance, the --refererence option of git clone will be used thus creating a quick local clone of your repo. config BUILD_LOG bool "Enable log files during build process" if DEVEL help If enabled log files will be written to the ./log directory config SRC_TREE_OVERRIDE bool "Enable package source tree override" if DEVEL help If enabled, you can force a package to use a git tree as source code instead of the normal tarball. Create a symlink 'git-src' in the package directory, pointing to the .git tree that you want to pull the source code from menuconfig TARGET_OPTIONS bool "Target Options" if DEVEL config TARGET_OPTIMIZATION string "Target Optimizations" if TARGET_OPTIONS default DEFAULT_TARGET_OPTIMIZATION help Optimizations to use when building for the target host. config SOFT_FLOAT bool "Use software floating point by default" if TARGET_OPTIONS default y depends on (arm || armeb || powerpc || mipsel || mips) && !HAS_FPU help If your target CPU does not have a Floating Point Unit (FPU) or a kernel FPU emulator, but you still wish to support floating point functions, then everything will need to be compiled with soft floating point support (-msoft-float). Most people will answer N. source "toolchain/Config.in" source "target/imagebuilder/Config.in" source "target/sdk/Config.in" source "target/toolchain/Config.in" source "tmp/.config-package.in" ref='#n407'>407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368
--- a/configure
+++ b/configure
@@ -2690,6 +2690,9 @@ case "${target}" in
   ip2k-*-*)
     noconfigdirs="$noconfigdirs target-libiberty target-libstdc++-v3 ${libgcj}"
     ;;
+  ubicom32-*-*)
+    noconfigdirs="$noconfigdirs target-libffi"
+    ;;
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
--- /dev/null
+++ b/gcc/config/ubicom32/constraints.md
@@ -0,0 +1,149 @@
+; Constraint definitions for Ubicom32
+
+; Copyright (C) 2009 Free Software Foundation, Inc.
+; Contributed by Ubicom, Inc.
+
+; This file is part of GCC.
+
+; GCC is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published
+; by the Free Software Foundation; either version 3, or (at your
+; option) any later version.
+
+; GCC is distributed in the hope that it will be useful, but WITHOUT
+; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+; License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+(define_register_constraint "a" "ALL_ADDRESS_REGS"
+  "An An register.")
+
+(define_register_constraint "d" "DATA_REGS"
+  "A Dn register.")
+
+(define_register_constraint "h" "ACC_REGS"
+  "An accumulator register.")
+
+(define_register_constraint "l" "ACC_LO_REGS"
+  "An accn_lo register.")
+
+(define_register_constraint "Z" "FDPIC_REG"
+  "The FD-PIC GOT pointer: A0.")
+
+(define_constraint "I"
+  "An 8-bit signed constant value."
+  (and (match_code "const_int")
+       (match_test "(ival >= -128) && (ival <= 127)")))
+
+(define_constraint "Q"
+  "An 8-bit signed constant value represented as unsigned."
+  (and (match_code "const_int")
+       (match_test "(ival >= 0x00) && (ival <= 0xff)")))
+
+(define_constraint "R"
+  "An 8-bit signed constant value represented as unsigned."
+  (and (match_code "const_int")
+       (match_test "((ival >= 0x0000) && (ival <= 0x007f)) || ((ival >= 0xff80) && (ival <= 0xffff))")))
+
+(define_constraint "J"
+  "A 7-bit unsigned constant value."
+  (and (match_code "const_int")
+       (match_test "(ival >= 0) && (ival <= 127)")))
+
+(define_constraint "K"
+  "A 7-bit unsigned constant value shifted << 1."
+  (and (match_code "const_int")
+       (match_test "(ival >= 0) && (ival <= 254) && ((ival & 1) == 0)")))
+
+(define_constraint "L"
+  "A 7-bit unsigned constant value shifted << 2."
+  (and (match_code "const_int")
+       (match_test "(ival >= 0) && (ival <= 508) && ((ival & 3) == 0)")))
+
+(define_constraint "M"
+  "A 5-bit unsigned constant value."
+  (and (match_code "const_int")
+       (match_test "(ival >= 0) && (ival <= 31)")))
+
+(define_constraint "N"
+  "A signed 16 bit constant value."
+  (and (match_code "const_int")
+       (match_test "(ival >= -32768) && (ival <= 32767)")))
+
+(define_constraint "O"
+  "An exact bitmask of contiguous 1 bits starting at bit 0."
+  (and (match_code "const_int")
+       (match_test "exact_log2 (ival + 1) != -1")))
+
+(define_constraint "P"
+  "A 7-bit negative constant value shifted << 2."
+  (and (match_code "const_int")
+       (match_test "(ival >= -504) && (ival <= 0) && ((ival & 3) == 0)")))
+
+(define_constraint "S"
+  "A symbolic reference."
+  (match_code "symbol_ref"))
+
+(define_constraint "Y"
+  "An FD-PIC symbolic reference."
+  (and (match_test "TARGET_FDPIC")
+       (match_test "GET_CODE (op) == UNSPEC")
+       (ior (match_test "XINT (op, 1) == UNSPEC_FDPIC_GOT")
+	    (match_test "XINT (op, 1) == UNSPEC_FDPIC_GOT_FUNCDESC"))))
+
+(define_memory_constraint "T1"
+  "A memory operand that can be used for .1 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (match_test "GET_MODE (op) == QImode")))
+
+(define_memory_constraint "T2"
+  "A memory operand that can be used for .2 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (match_test "GET_MODE (op) == HImode")))
+
+(define_memory_constraint "T4"
+  "A memory operand that can be used for .4 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (ior (match_test "GET_MODE (op) == SImode")
+	    (match_test "GET_MODE (op) == DImode")
+	    (match_test "GET_MODE (op) == SFmode"))))
+
+(define_memory_constraint "U1"
+  "An offsettable memory operand that can be used for .1 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (match_test "GET_MODE (op) == QImode")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
+
+(define_memory_constraint "U2"
+  "An offsettable memory operand that can be used for .2 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (match_test "GET_MODE (op) == HImode")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
+
+(define_memory_constraint "U4"
+  "An offsettable memory operand that can be used for .4 instruction."
+  (and (match_test "memory_operand (op, GET_MODE(op))")
+       (ior (match_test "GET_MODE (op) == SImode")
+	    (match_test "GET_MODE (op) == DImode")
+	    (match_test "GET_MODE (op) == SFmode"))
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
+       (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
+       (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
+
--- /dev/null
+++ b/gcc/config/ubicom32/crti.S
@@ -0,0 +1,54 @@
+/* Specialized code needed to support construction and destruction of
+   file-scope objects in C++ and Java code, and to support exception handling.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
+
+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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files
+   compiled with GCC to produce an executable, this does not cause
+   the resulting executable to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.  */
+
+/*
+ * This file just supplies function prologues for the .init and .fini
+ * sections.  It is linked in before crtbegin.o.
+ */
+	.file   "crti.o"
+	.ident  "GNU C crti.o"
+
+	.section .init
+	.align	2
+	.globl	_init
+	.type	_init, @function
+_init:
+	move.4 -4(sp)++, a5
+#ifdef __UBICOM32_FDPIC__
+	move.4 -4(sp)++, a0
+#endif
+
+	.section .fini
+	.align	2
+	.globl	_fini
+	.type	_fini, @function
+_fini:
+	move.4 -4(sp)++, a5
+#ifdef __UBICOM32_FDPIC__
+	move.4 -4(sp)++, a0
+#endif
--- /dev/null
+++ b/gcc/config/ubicom32/crtn.S
@@ -0,0 +1,47 @@
+/* Specialized code needed to support construction and destruction of
+   file-scope objects in C++ and Java code, and to support exception handling.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
+
+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, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files
+   compiled with GCC to produce an executable, this does not cause
+   the resulting executable to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.  */
+
+/*
+ * This file supplies function epilogues for the .init and .fini sections.
+ * It is linked in after all other files.
+ */
+
+	.file   "crtn.o"
+	.ident  "GNU C crtn.o"
+
+	.section .init
+#ifdef __UBICOM32_FDPIC__
+	move.4	a0, (sp)4++
+#endif
+	ret	(sp)4++
+
+	.section .fini
+#ifdef __UBICOM32_FDPIC__
+	move.4	a0, (sp)4++
+#endif
+	ret	(sp)4++
--- /dev/null
+++ b/gcc/config/ubicom32/elf.h
@@ -0,0 +1,29 @@
+#undef  STARTFILE_SPEC
+#define STARTFILE_SPEC "\
+%{msim:%{!shared:crt0%O%s}} \
+crti%O%s crtbegin%O%s"
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC	"crtend%O%s crtn%O%s"
+
+#ifdef __UBICOM32_FDPIC__
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)			\
+  asm (SECTION_OP);							\
+  asm ("move.4 a0, 0(sp);\n\t"						\
+       "call a5," USER_LABEL_PREFIX #FUNC ";");				\
+  asm (TEXT_SECTION_ASM_OP);
+#endif
+
+#undef SUBTARGET_DRIVER_SELF_SPECS
+#define SUBTARGET_DRIVER_SELF_SPECS \
+     "%{mfdpic:-msim} "
+
+#define NO_IMPLICIT_EXTERN_C
+
+/*
+ * We need this to compile crtbegin/crtend. This should really be picked
+ * up from elfos.h but at the moment including elfos.h causes other more
+ * serous linker issues.
+ */
+#define INIT_SECTION_ASM_OP	"\t.section\t.init"
+#define FINI_SECTION_ASM_OP	"\t.section\t.fini"
--- /dev/null
+++ b/gcc/config/ubicom32/linux.h
@@ -0,0 +1,80 @@
+/* Definitions of target machine for Ubicom32-uclinux
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Don't assume anything about the header files.  */
+#define NO_IMPLICIT_EXTERN_C
+
+#undef  LIB_SPEC
+#define LIB_SPEC  \
+	"%{pthread:-lpthread} " \
+	"-lc"
+
+#undef LINK_GCC_C_SEQUENCE_SPEC
+#define LINK_GCC_C_SEQUENCE_SPEC \
+  "%{static:--start-group} %G %L %{static:--end-group} " \
+  "%{!static: %G}"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "%{!shared: %{pg|p|profile:gcrt1%O%s;pie:Scrt1%O%s;:crt1%O%s}} " \
+  "crtreloc%O%s crti%O%s %{shared|pie:crtbeginS%O%s;:crtbegin%O%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  "%{shared|pie:crtendS%O%s;:crtend%O%s} crtn%O%s"
+
+/* taken from linux.h */
+/* The GNU C++ standard library requires that these macros be defined.  */
+#undef CPLUSPLUS_CPP_SPEC
+#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
+
+#define TARGET_OS_CPP_BUILTINS()				\
+    do {							\
+	builtin_define_std ("__UBICOM32__");			\
+	builtin_define_std ("__ubicom32__");			\
+	builtin_define ("__gnu_linux__");			\
+	builtin_define_std ("linux");				\
+	builtin_define_std ("unix");				\
+	builtin_assert ("system=linux");			\
+	builtin_assert ("system=unix");				\
+	builtin_assert ("system=posix");			\
+    } while (0)
+
+#define OBJECT_FORMAT_ELF
+
+
+#undef DRIVER_SELF_SPECS
+#define DRIVER_SELF_SPECS \
+  "%{!mno-fdpic:-mfdpic}"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{mfdpic: -m elf32ubicom32fdpic -z text } %{shared} %{pie} \
+  %{static:-dn -Bstatic} \
+  %{shared:-G -Bdynamic} \
+  %{!shared: %{!static: \
+   %{rdynamic:-export-dynamic} \
+   %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}} \
+   %{static}} "
+
+/*
+#define MD_UNWIND_SUPPORT "config/bfin/linux-unwind.h"
+*/
--- /dev/null
+++ b/gcc/config/ubicom32/predicates.md
@@ -0,0 +1,327 @@
+; Predicate definitions for Ubicom32.
+
+; Copyright (C) 2009 Free Software Foundation, Inc.
+; Contributed by Ubicom, Inc.
+
+; This file is part of GCC.
+
+; GCC is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published
+; by the Free Software Foundation; either version 3, or (at your
+; option) any later version.
+
+; GCC is distributed in the hope that it will be useful, but WITHOUT
+; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+; License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+(define_predicate "ubicom32_move_operand"
+  (match_code "const_int, const_double, const, mem, subreg, reg, lo_sum")
+{
+  if (CONST_INT_P (op))
+    return true;
+
+  if (GET_CODE (op) == CONST_DOUBLE)
+    return true;
+  
+  if (GET_CODE (op) == CONST)
+    return memory_address_p (mode, op);
+
+  if (GET_MODE (op) != mode)
+    return false;
+
+  if (MEM_P (op))
+    return memory_address_p (mode, XEXP (op, 0));
+  
+  if (GET_CODE (op) == SUBREG) {
+      op = SUBREG_REG (op);
+
+      if (REG_P (op))
+	return true;
+  
+      if (! MEM_P (op))
+	return false;
+
+      /* Paradoxical SUBREG.  */
+      if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (op)))
+	return false;
+
+      return memory_address_p (GET_MODE (op), XEXP (op, 0));
+    }
+
+  return register_operand (op, mode);
+})
+
+;; Returns true if OP is either a symbol reference or a sum of a
+;; symbol reference and a constant.
+
+(define_predicate "ubicom32_symbolic_address_operand"
+  (match_code "symbol_ref, label_ref, const")
+{
+  switch (GET_CODE (op))
+    {
+    case SYMBOL_REF:
+    case LABEL_REF:
+      return true;
+
+    case CONST:
+      op = XEXP (op, 0);
+      return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
+	       || GET_CODE (XEXP (op, 0)) == LABEL_REF)
+	      && CONST_INT_P (XEXP (op, 1)));
+
+    default:
+      return false;
+    }
+})
+
+;; Return true if operand is the uClinux FD-PIC register.
+
+(define_predicate "ubicom32_fdpic_operand"
+  (match_code "reg")
+{
+  if (! TARGET_FDPIC)
+    return false;
+
+  if (!REG_P (op))
+    return false;
+
+  if (GET_MODE (op) != mode && mode != VOIDmode)
+    return false;
+
+  if (REGNO (op) != FDPIC_REGNUM && REGNO (op) < FIRST_PSEUDO_REGISTER)
+    return false;
+
+  return true;
+})
+
+(define_predicate "ubicom32_fdpic_got_offset_operand"
+  (match_code "unspec")
+{
+  if (! TARGET_FDPIC)
+    return false;
+
+  if (GET_CODE (op) != UNSPEC)
+    return false;
+
+  if (XINT (op, 1) != UNSPEC_FDPIC_GOT
+      && XINT (op, 1) != UNSPEC_FDPIC_GOT_FUNCDESC)
+    return false;
+
+  return true;
+})
+
+(define_predicate "ubicom32_arith_operand"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+  return (ubicom32_move_operand (op, mode)
+	  && ! ubicom32_symbolic_address_operand (op, mode)
+	  && (! CONST_INT_P (op)
+	      || satisfies_constraint_I (op)));
+})
+
+(define_predicate "ubicom32_arith_operand_dot1"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+  return (ubicom32_move_operand (op, mode)
+	  && ! ubicom32_symbolic_address_operand (op, mode)
+	  && (! CONST_INT_P (op)
+	      || satisfies_constraint_Q (op)));
+})
+
+(define_predicate "ubicom32_arith_operand_dot2"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+  return (ubicom32_move_operand (op, mode)
+	  && ! ubicom32_symbolic_address_operand (op, mode)
+	  && (! CONST_INT_P (op)
+	      || satisfies_constraint_R (op)));
+})
+
+(define_predicate "ubicom32_compare_operand"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+ return (ubicom32_move_operand (op, mode)
+	  && ! ubicom32_symbolic_address_operand (op, mode)
+	  && (! CONST_INT_P (op)
+	      || satisfies_constraint_N (op)));
+})
+
+(define_predicate "ubicom32_compare_operator"
+  (match_code "compare"))
+
+(define_predicate "ubicom32_and_or_si3_operand"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+  return (ubicom32_arith_operand (op, mode)
+	  || (CONST_INT_P (op)
+	      && ((exact_log2 (INTVAL (op) + 1) != -1
+		   && exact_log2 (INTVAL (op) + 1) <= 31)
+		  || (exact_log2 (INTVAL (op)) != -1
+		      && exact_log2 (INTVAL (op)) <= 31)
+		  || (exact_log2 (~INTVAL (op)) != -1
+		      && exact_log2 (~INTVAL (op)) <= 31))));
+})
+
+(define_predicate "ubicom32_and_or_hi3_operand"
+  (match_code "subreg, reg, const_int, lo_sum, mem")
+{
+  return (ubicom32_arith_operand (op, mode)
+	  || (CONST_INT_P (op)
+	      && exact_log2 (INTVAL (op) + 1) != -1
+	      && exact_log2 (INTVAL (op) + 1) <= 15));
+})
+
+(define_predicate "ubicom32_mem_or_address_register_operand"
+  (match_code "subreg, reg, mem")
+{
+  unsigned int regno;
+
+  if (MEM_P (op)
+      && memory_operand (op, mode))
+    return true;
+
+  if (REG_P (op))
+    regno = REGNO (op);
+  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
+    {
+      int offset;
+      if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
+	offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
+      else
+	offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
+				      GET_MODE (SUBREG_REG (op)),
+				      SUBREG_BYTE (op),
+				      GET_MODE (op));
+      regno = REGNO (SUBREG_REG (op)) + offset;
+    }
+  else
+    return false;
+
+  return (regno >= FIRST_PSEUDO_REGISTER 
+	  || REGNO_REG_CLASS (regno) == FDPIC_REG
+	  || REGNO_REG_CLASS (regno) == ADDRESS_REGS);
+})
+
+(define_predicate "ubicom32_data_register_operand"
+  (match_code "subreg, reg")
+{
+  unsigned int regno;
+
+  if (REG_P (op))
+    regno = REGNO (op);
+  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
+    {
+      int offset;
+      if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
+	offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
+      else
+	offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
+				      GET_MODE (SUBREG_REG (op)),
+				      SUBREG_BYTE (op),
+				      GET_MODE (op));
+      regno = REGNO (SUBREG_REG (op)) + offset;
+    }
+  else
+    return false;
+
+  return ((regno >= FIRST_PSEUDO_REGISTER 
+	   && regno != REGNO (virtual_stack_vars_rtx))
+	  || REGNO_REG_CLASS (regno) == DATA_REGS);
+})
+
+(define_predicate "ubicom32_address_register_operand"
+  (match_code "subreg, reg")
+{
+  unsigned int regno;
+
+  if (REG_P (op))
+    regno = REGNO (op);
+  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
+    {
+      int offset;
+      if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
+	offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
+      else
+	offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
+				      GET_MODE (SUBREG_REG (op)),
+				      SUBREG_BYTE (op),
+				      GET_MODE (op));
+      regno = REGNO (SUBREG_REG (op)) + offset;
+    }
+  else
+    return false;
+
+  return (regno >= FIRST_PSEUDO_REGISTER 
+	  || REGNO_REG_CLASS (regno) == FDPIC_REG
+	  || REGNO_REG_CLASS (regno) == ADDRESS_REGS);
+})
+
+(define_predicate "ubicom32_acc_lo_register_operand"
+  (match_code "subreg, reg")
+{
+  unsigned int regno;
+
+  if (REG_P (op))
+    regno = REGNO (op);
+  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
+    {
+      int offset;
+      if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
+	offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
+      else
+	offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
+				      GET_MODE (SUBREG_REG (op)),
+				      SUBREG_BYTE (op),
+				      GET_MODE (op));
+      regno = REGNO (SUBREG_REG (op)) + offset;
+    }
+  else
+    return false;
+
+  return ((regno >= FIRST_PSEUDO_REGISTER 
+	   && regno != REGNO (virtual_stack_vars_rtx))
+	  || REGNO_REG_CLASS (regno) == ACC_LO_REGS);
+})
+
+(define_predicate "ubicom32_acc_hi_register_operand"
+  (match_code "subreg, reg")
+{
+  unsigned int regno;
+
+  if (REG_P (op))
+    regno = REGNO (op);
+  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
+    {
+      int offset;
+      if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
+	offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
+      else
+	offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
+				      GET_MODE (SUBREG_REG (op)),
+				      SUBREG_BYTE (op),
+				      GET_MODE (op));
+      regno = REGNO (SUBREG_REG (op)) + offset;
+    }
+  else
+    return false;
+
+  return ((regno >= FIRST_PSEUDO_REGISTER 
+	   && regno != REGNO (virtual_stack_vars_rtx))
+	  || REGNO_REG_CLASS (regno) == ACC_REGS);
+})
+
+(define_predicate "ubicom32_call_address_operand"
+  (match_code "symbol_ref, subreg, reg")
+{
+  return (GET_CODE (op) == SYMBOL_REF || REG_P (op));
+})
+
+(define_special_predicate "ubicom32_cc_register_operand"
+  (and (match_code "reg")
+       (match_test "REGNO (op) == CC_REGNUM")))
+
--- /dev/null
+++ b/gcc/config/ubicom32/t-ubicom32
@@ -0,0 +1,52 @@
+# Name of assembly file containing libgcc1 functions.
+# This entry must be present, but it can be empty if the target does
+# not need any assembler functions to support its code generation.
+CROSS_LIBGCC1 =
+
+# Alternatively if assembler functions *are* needed then define the
+# entries below:
+# CROSS_LIBGCC1 = libgcc1-asm.a
+
+LIB2FUNCS_EXTRA = \
+	$(srcdir)/config/udivmodsi4.c \
+	$(srcdir)/config/divmod.c \
+	$(srcdir)/config/udivmod.c
+
+# If any special flags are necessary when building libgcc2 put them here.
+#
+# TARGET_LIBGCC2_CFLAGS = 
+
+# We want fine grained libraries, so use the new code to build the
+# floating point emulation libraries.
+FPBIT = fp-bit.c
+DPBIT = dp-bit.c
+
+fp-bit.c: $(srcdir)/config/fp-bit.c
+	echo '#define FLOAT'				> fp-bit.c
+	cat $(srcdir)/config/fp-bit.c			>> fp-bit.c
+
+dp-bit.c: $(srcdir)/config/fp-bit.c
+	cat $(srcdir)/config/fp-bit.c > dp-bit.c
+
+# Commented out to speed up compiler development!
+#
+# MULTILIB_OPTIONS = march=ubicom32v1/march=ubicom32v2/march=ubicom32v3/march=ubicom32v4
+# MULTILIB_DIRNAMES = ubicom32v1 ubicom32v2 ubicom32v3 ubicom32v4
+
+MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
+MULTILIB_OPTIONS += mfdpic
+MULTILIB_OPTIONS += mno-ipos-abi/mipos-abi
+MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
+
+# Assemble startup files.
+$(T)crti.o: $(srcdir)/config/ubicom32/crti.S $(GCC_PASSES)
+	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+	-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/ubicom32/crti.S
+
+$(T)crtn.o: $(srcdir)/config/ubicom32/crtn.S $(GCC_PASSES)
+	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+	-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/ubicom32/crtn.S
+
+# these parts are required because uClibc ldso needs them to link.
+# they are not in the specfile so they will not be included automatically.
+EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crtbeginS.o crtendS.o crti.o crtn.o
--- /dev/null
+++ b/gcc/config/ubicom32/t-ubicom32-linux
@@ -0,0 +1,35 @@
+# Name of assembly file containing libgcc1 functions.
+# This entry must be present, but it can be empty if the target does
+# not need any assembler functions to support its code generation.
+CROSS_LIBGCC1 =
+
+# Alternatively if assembler functions *are* needed then define the
+# entries below:
+# CROSS_LIBGCC1 = libgcc1-asm.a
+
+LIB2FUNCS_EXTRA = \
+	$(srcdir)/config/udivmodsi4.c \
+	$(srcdir)/config/divmod.c \
+	$(srcdir)/config/udivmod.c
+
+# If any special flags are necessary when building libgcc2 put them here.
+#
+# TARGET_LIBGCC2_CFLAGS =
+
+# We want fine grained libraries, so use the new code to build the
+# floating point emulation libraries.
+FPBIT = fp-bit.c
+DPBIT = dp-bit.c
+
+fp-bit.c: $(srcdir)/config/fp-bit.c
+	echo '#define FLOAT'				> fp-bit.c
+	cat $(srcdir)/config/fp-bit.c			>> fp-bit.c
+
+dp-bit.c: $(srcdir)/config/fp-bit.c
+	cat $(srcdir)/config/fp-bit.c > dp-bit.c
+
+# We only support v3 and v4 ISAs for uClinux.
+
+MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
+
+#EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crtbeginS.o crtendS.o
--- /dev/null
+++ b/gcc/config/ubicom32/t-ubicom32-uclinux
@@ -0,0 +1,35 @@
+# Name of assembly file containing libgcc1 functions.
+# This entry must be present, but it can be empty if the target does
+# not need any assembler functions to support its code generation.
+CROSS_LIBGCC1 =
+
+# Alternatively if assembler functions *are* needed then define the
+# entries below:
+# CROSS_LIBGCC1 = libgcc1-asm.a
+
+LIB2FUNCS_EXTRA = \
+	$(srcdir)/config/udivmodsi4.c \
+	$(srcdir)/config/divmod.c \
+	$(srcdir)/config/udivmod.c
+
+# If any special flags are necessary when building libgcc2 put them here.
+#
+# TARGET_LIBGCC2_CFLAGS = 
+
+# We want fine grained libraries, so use the new code to build the
+# floating point emulation libraries.
+FPBIT = fp-bit.c
+DPBIT = dp-bit.c
+
+fp-bit.c: $(srcdir)/config/fp-bit.c
+	echo '#define FLOAT'				> fp-bit.c
+	cat $(srcdir)/config/fp-bit.c			>> fp-bit.c
+
+dp-bit.c: $(srcdir)/config/fp-bit.c
+	cat $(srcdir)/config/fp-bit.c > dp-bit.c
+
+# We only support v3 and v4 ISAs for uClinux.
+
+MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
+
+EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o # crtbeginS.o crtendS.o
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32-modes.def
@@ -0,0 +1,30 @@
+/* Definitions of target machine for GNU compiler, Ubicom32 architecture.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Some insns set all condition code flags, some only set the Z and N flags, and
+   some only set the Z flag.  */
+
+CC_MODE (CCW);
+CC_MODE (CCWZN);
+CC_MODE (CCWZ);
+CC_MODE (CCS);
+CC_MODE (CCSZN);
+CC_MODE (CCSZ);
+
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32-protos.h
@@ -0,0 +1,84 @@
+/* Function prototypes for Ubicom IP3000.
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GNU CC.
+
+   GNU CC 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.
+
+   GNU CC 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 GNU CC; see the file COPYING.  If not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef RTX_CODE
+
+#ifdef TREE_CODE
+extern void ubicom32_va_start (tree, rtx);
+#endif /* TREE_CODE */
+
+extern void ubicom32_print_operand (FILE *, rtx, int);
+extern void ubicom32_print_operand_address (FILE *, rtx);
+
+extern void ubicom32_conditional_register_usage (void);
+extern enum reg_class ubicom32_preferred_reload_class (rtx, enum reg_class);
+extern int ubicom32_regno_ok_for_index_p (int, int);
+extern void ubicom32_expand_movsi (rtx *);
+extern void ubicom32_expand_addsi3 (rtx *);
+extern int ubicom32_emit_mult_sequence (rtx *);
+extern void ubicom32_emit_move_const_int (rtx, rtx);
+extern bool ubicom32_legitimate_constant_p (rtx);
+extern bool ubicom32_legitimate_address_p (enum machine_mode, rtx, int);
+extern rtx ubicom32_legitimize_address (rtx, rtx, enum machine_mode);
+extern rtx ubicom32_legitimize_reload_address (rtx, enum machine_mode, int, int);
+extern void ubicom32_canonicalize_comparison (enum rtx_code *code, rtx *op0, rtx *op1);
+extern int ubicom32_mode_dependent_address_p (rtx);
+extern void ubicom32_output_cond_jump (rtx, rtx, rtx);
+extern void ubicom32_expand_eh_return (rtx *);
+extern void ubicom32_expand_call_fdpic (rtx *);
+extern void ubicom32_expand_call_value_fdpic (rtx *);
+extern enum machine_mode ubicom32_select_cc_mode (RTX_CODE, rtx, rtx);
+extern rtx ubicom32_gen_compare_reg (RTX_CODE, rtx, rtx);
+extern int ubicom32_shiftable_const_int (int);
+#endif /* RTX_CODE */
+
+#ifdef TREE_CODE
+extern void init_cumulative_args (CUMULATIVE_ARGS *cum,
+				  tree fntype,
+				  struct rtx_def *libname,
+				  int indirect);
+extern struct rtx_def *function_arg (CUMULATIVE_ARGS *,
+				     enum machine_mode, tree, int);
+extern struct rtx_def *function_incoming_arg (CUMULATIVE_ARGS *,
+					      enum machine_mode,
+					      tree, int);
+extern int function_arg_partial_nregs (CUMULATIVE_ARGS *,
+				       enum machine_mode, tree, int);
+extern struct rtx_def *ubicom32_va_arg (tree, tree);
+extern int ubicom32_reg_parm_stack_space (tree);
+#endif /* TREE_CODE */
+
+extern struct rtx_def * ubicom32_builtin_saveregs (void);
+extern void asm_file_start (FILE *);
+extern void ubicom32_expand_prologue (void);
+extern void ubicom32_expand_epilogue (void);
+extern int ubicom32_initial_elimination_offset (int, int);
+extern int ubicom32_regno_ok_for_base_p (int, int);
+extern bool ubicom32_hard_regno_mode_ok (unsigned int, enum machine_mode);
+extern int ubicom32_can_use_return_insn_p (void);
+extern rtx ubicom32_return_addr_rtx (int, rtx);
+extern void ubicom32_optimization_options (int, int);
+extern void ubicom32_override_options (void);
+extern bool ubicom32_match_cc_mode (rtx, enum machine_mode);
+
+extern int ubicom32_reorg_completed;
+
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32.c
@@ -0,0 +1,2881 @@
+/* Subroutines for insn-output.c for Ubicom32
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "tree.h"
+#include "regs.h"
+#include "hard-reg-set.h"
+#include "real.h"
+#include "insn-config.h"
+#include "conditions.h"
+#include "insn-flags.h"
+#include "output.h"
+#include "insn-attr.h"
+#include "insn-codes.h"
+#include "flags.h"
+#include "recog.h"
+#include "expr.h"
+#include "function.h"
+#include "obstack.h"
+#include "toplev.h"
+#include "tm_p.h"
+#include "tm-constrs.h"
+#include "basic-block.h"
+#include "integrate.h"
+#include "target.h"
+#include "target-def.h"
+#include "reload.h"
+#include "df.h"
+#include "langhooks.h"
+#include "optabs.h"
+
+static tree ubicom32_handle_fndecl_attribute (tree *, tree, tree, int, bool *);
+static void ubicom32_layout_frame (void);
+static void ubicom32_function_prologue (FILE *, HOST_WIDE_INT);
+static void ubicom32_function_epilogue (FILE *, HOST_WIDE_INT);
+static bool ubicom32_rtx_costs (rtx, int, int, int *, bool speed);
+static bool ubicom32_fixed_condition_code_regs (unsigned int *,
+						unsigned int *);
+static enum machine_mode ubicom32_cc_modes_compatible (enum machine_mode,
+						       enum machine_mode);
+static int ubicom32_naked_function_p (void);
+static void ubicom32_machine_dependent_reorg (void);
+static bool ubicom32_assemble_integer (rtx, unsigned int, int);
+static void ubicom32_asm_init_sections (void);
+static int ubicom32_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,tree, 
+				       bool);
+static bool ubicom32_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+					enum machine_mode mode, const_tree type,
+					bool named ATTRIBUTE_UNUSED);
+static bool ubicom32_callee_copies (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+				    enum machine_mode mode, const_tree type,
+				    bool named ATTRIBUTE_UNUSED);
+
+static bool ubicom32_return_in_memory (const_tree type, 
+				       const_tree fntype ATTRIBUTE_UNUSED);
+static bool ubicom32_is_base_reg (rtx, int);
+static void ubicom32_init_builtins (void);
+static rtx ubicom32_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+static tree ubicom32_fold_builtin (tree, tree, bool);
+static int ubicom32_get_valid_offset_mask (enum machine_mode);
+static bool ubicom32_cannot_force_const_mem (rtx);
+
+/* Case values threshold */
+int ubicom32_case_values_threshold = 6;
+
+/* Nonzero if this chip supports the Ubicom32 v3 ISA.  */
+int ubicom32_v3 = 1;
+
+/* Nonzero if this chip supports the Ubicom32 v4 ISA.  */
+int ubicom32_v4 = 1;
+
+/* Valid attributes:
+   naked - don't generate function prologue/epilogue and `ret' command.  */
+const struct attribute_spec ubicom32_attribute_table[] =
+{
+  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
+  { "naked", 0, 0, true,  false, false, ubicom32_handle_fndecl_attribute },
+  { NULL,    0, 0, false, false, false, NULL }
+};
+
+#undef TARGET_ASM_FUNCTION_PROLOGUE
+#define TARGET_ASM_FUNCTION_PROLOGUE ubicom32_function_prologue
+
+#undef TARGET_ASM_FUNCTION_EPILOGUE
+#define TARGET_ASM_FUNCTION_EPILOGUE ubicom32_function_epilogue
+
+#undef TARGET_ATTRIBUTE_TABLE
+#define TARGET_ATTRIBUTE_TABLE ubicom32_attribute_table
+
+/* All addresses cost the same amount.  */
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_bool_0
+
+#undef TARGET_RTX_COSTS
+#define TARGET_RTX_COSTS ubicom32_rtx_costs
+
+#undef TARGET_FIXED_CONDITION_CODE_REGS
+#define TARGET_FIXED_CONDITION_CODE_REGS ubicom32_fixed_condition_code_regs
+
+#undef TARGET_CC_MODES_COMPATIBLE
+#define TARGET_CC_MODES_COMPATIBLE ubicom32_cc_modes_compatible
+
+#undef TARGET_MACHINE_DEPENDENT_REORG
+#define TARGET_MACHINE_DEPENDENT_REORG ubicom32_machine_dependent_reorg
+
+#undef  TARGET_ASM_INTEGER
+#define TARGET_ASM_INTEGER ubicom32_assemble_integer
+
+#undef TARGET_ASM_INIT_SECTIONS
+#define TARGET_ASM_INIT_SECTIONS ubicom32_asm_init_sections
+
+#undef TARGET_ARG_PARTIAL_BYTES
+#define TARGET_ARG_PARTIAL_BYTES ubicom32_arg_partial_bytes
+
+#undef TARGET_PASS_BY_REFERENCE
+#define TARGET_PASS_BY_REFERENCE ubicom32_pass_by_reference
+
+#undef TARGET_CALLEE_COPIES
+#define TARGET_CALLEE_COPIES ubicom32_callee_copies
+
+#undef TARGET_RETURN_IN_MEMORY
+#define TARGET_RETURN_IN_MEMORY ubicom32_return_in_memory
+
+#undef TARGET_INIT_BUILTINS
+#define TARGET_INIT_BUILTINS ubicom32_init_builtins
+
+#undef TARGET_EXPAND_BUILTIN
+#define TARGET_EXPAND_BUILTIN ubicom32_expand_builtin
+
+#undef TARGET_FOLD_BUILTIN
+#define TARGET_FOLD_BUILTIN ubicom32_fold_builtin
+
+#undef TARGET_CANNOT_FORCE_CONST_MEM
+#define TARGET_CANNOT_FORCE_CONST_MEM ubicom32_cannot_force_const_mem
+
+struct gcc_target targetm = TARGET_INITIALIZER;
+
+static char save_regs[FIRST_PSEUDO_REGISTER];
+static int nregs;
+static int frame_size;
+int ubicom32_stack_size = 0;	/* size of allocated stack (including frame) */
+int ubicom32_can_use_calli_to_ret;
+
+#define STACK_UNIT_BOUNDARY (STACK_BOUNDARY / BITS_PER_UNIT)
+#define ROUND_CALL_BLOCK_SIZE(BYTES) \
+  (((BYTES) + (STACK_UNIT_BOUNDARY - 1)) & ~(STACK_UNIT_BOUNDARY - 1))
+
+/* In case of a PRE_INC, POST_INC, PRE_DEC, POST_DEC memory reference, we
+   must report the mode of the memory reference from PRINT_OPERAND to
+   PRINT_OPERAND_ADDRESS.  */
+enum machine_mode output_memory_reference_mode;
+
+/* Flag for some split insns from the ubicom32.md.  */
+int ubicom32_reorg_completed;
+
+enum reg_class const ubicom32_regclass_map[FIRST_PSEUDO_REGISTER] =
+{
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  DATA_REGS, 
+  FDPIC_REG, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ADDRESS_REGS, 
+  ACC_REGS,
+  ACC_LO_REGS,
+  ACC_REGS,
+  ACC_LO_REGS,
+  SOURCE3_REG,
+  ADDRESS_REGS,
+  NO_REGS,			/* CC_REG must be NO_REGS */
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS,
+  SPECIAL_REGS
+};
+
+rtx ubicom32_compare_op0;
+rtx ubicom32_compare_op1;
+
+/* Handle command line option overrides.  */
+
+void
+ubicom32_override_options (void)
+{
+  flag_pic = 0;
+
+  if (strcmp (ubicom32_arch_name, "ubicom32v1") == 0) {
+    /* If we have a version 1 architecture then we want to avoid using jump
+       tables.  */
+    ubicom32_case_values_threshold = 30000;
+    ubicom32_v3 = 0;
+    ubicom32_v4 = 0;
+  } else if (strcmp (ubicom32_arch_name, "ubicom32v2") == 0) {
+    ubicom32_v3 = 0;
+    ubicom32_v4 = 0;
+  } else if (strcmp (ubicom32_arch_name, "ubicom32v3") == 0) {
+    ubicom32_v3 = 1;
+    ubicom32_v4 = 0;
+  } else if (strcmp (ubicom32_arch_name, "ubicom32v4") == 0) {
+    ubicom32_v3 = 1;
+    ubicom32_v4 = 1;
+  }
+
+  /* There is no single unaligned SI op for PIC code.  Sometimes we
+     need to use ".4byte" and sometimes we need to use ".picptr".
+     See ubicom32_assemble_integer for details.  */
+  if (TARGET_FDPIC)
+    targetm.asm_out.unaligned_op.si = 0;
+}
+
+void
+ubicom32_conditional_register_usage (void)
+{
+  /* If we're using the old ipOS ABI we need to make D10 through D13
+     caller-clobbered.  */
+  if (TARGET_IPOS_ABI)
+    {
+      call_used_regs[D10_REGNUM] = 1;
+      call_used_regs[D11_REGNUM] = 1;
+      call_used_regs[D12_REGNUM] = 1;
+      call_used_regs[D13_REGNUM] = 1;
+    }
+}
+
+/* We have some number of optimizations that don't really work for the Ubicom32
+   architecture so we deal with them here.  */
+
+void
+ubicom32_optimization_options (int level ATTRIBUTE_UNUSED,
+			       int size ATTRIBUTE_UNUSED)
+{
+  /* The tree IVOPTs pass seems to do really bad things for the Ubicom32
+     architecture - it tends to turn things that would happily use pre/post
+     increment/decrement into operations involving unecessary loop
+     indicies.  */
+  flag_ivopts = 0;
+
+  /* We have problems where DSE at the RTL level misses partial stores
+     to the stack.  For now we disable it to avoid this.  */
+  flag_dse = 0;
+}
+
+/* Print operand X using operand code CODE to assembly language output file
+   FILE.  */
+
+void
+ubicom32_print_operand (FILE *file, rtx x, int code)
+{
+  switch (code)
+    {
+    case 'A':
+      /* Identify the correct accumulator to use.  */
+      if (REGNO (x) == ACC0_HI_REGNUM || REGNO (x) == ACC0_LO_REGNUM)
+	fprintf (file, "acc0");
+      else if (REGNO (x) == ACC1_HI_REGNUM || REGNO (x) == ACC1_LO_REGNUM)
+	fprintf (file, "acc1");
+      else
+	abort ();
+      break;
+
+    case 'b':
+    case 'B':
+      {
+	enum machine_mode mode;
+
+	mode = GET_MODE (XEXP (x, 0));
+
+	/* These are normal and reversed branches.  */
+	switch (code == 'b' ? GET_CODE (x) : reverse_condition (GET_CODE (x)))
+	  {
+	  case NE:
+	    fprintf (file, "ne");
+	    break;
+
+	  case EQ:
+	    fprintf (file, "eq");
+	    break;
+
+	  case GE:
+	    if (mode == CCSZNmode || mode == CCWZNmode)
+	      fprintf (file, "pl");
+	    else
+	      fprintf (file, "ge");
+	    break;
+
+	  case GT:
+	    fprintf (file, "gt");
+	    break;
+
+	  case LE:
+	    fprintf (file, "le");
+	    break;
+
+	  case LT:
+	    if (mode == CCSZNmode || mode == CCWZNmode)
+	      fprintf (file, "mi");
+	    else
+	      fprintf (file, "lt");
+	    break;
+
+	  case GEU:
+	    fprintf (file, "cs");
+	    break;
+
+	  case GTU:
+	    fprintf (file, "hi");
+	    break;
+
+	  case LEU:
+	    fprintf (file, "ls");
+	    break;
+
+	  case LTU:
+	    fprintf (file, "cc");
+	    break;
+
+	  default:
+	    abort ();
+	  }
+      }
+      break;
+
+    case 'C':
+      /* This is used for the operand to a call instruction;
+	 if it's a REG, enclose it in parens, else output
+	 the operand normally.  */
+      if (REG_P (x))
+	{
+	  fputc ('(', file);
+	  ubicom32_print_operand (file, x, 0);
+	  fputc (')', file);
+	}
+      else
+	ubicom32_print_operand (file, x, 0);
+      break;
+
+    case 'd':
+      /* Bit operations we need bit numbers. */
+      fprintf (file, "%d", exact_log2 (INTVAL (x)));
+      break;
+
+    case 'D':
+      /* Bit operations we need bit numbers. */
+      fprintf (file, "%d", exact_log2 (~ INTVAL (x)));
+      break;
+
+    case 'E':
+      /* For lea, which we use to add address registers.
+	 We don't want the '#' on a constant. */
+      if (CONST_INT_P (x))
+	{
+	  fprintf (file, "%ld", INTVAL (x));
+	  break;
+	}
+      /* FALL THROUGH */
+
+    default:
+      switch (GET_CODE (x))
+	{
+	case MEM:
+	  output_memory_reference_mode = GET_MODE (x);
+	  output_address (XEXP (x, 0));
+	  break;
+
+	case PLUS:
+	  output_address (x);
+	  break;
+
+	case REG:
+	  fprintf (file, "%s", reg_names[REGNO (x)]);
+	  break;
+
+	case SUBREG:
+	  fprintf (file, "%s", reg_names[subreg_regno (x)]);
+	  break;
+
+	/* This will only be single precision....  */
+	case CONST_DOUBLE:
+	  {
+	    unsigned long val;
+	    REAL_VALUE_TYPE rv;
+
+	    REAL_VALUE_FROM_CONST_DOUBLE (rv, x);
+	    REAL_VALUE_TO_TARGET_SINGLE (rv, val);
+	    fprintf (file, "0x%lx", val);
+	    break;
+	  }
+
+	case CONST_INT:
+	case SYMBOL_REF:
+	case CONST:
+	case LABEL_REF:
+	case CODE_LABEL:
+	case LO_SUM:
+	  ubicom32_print_operand_address (file, x);
+	  break;
+
+	case HIGH:
+	  fprintf (file, "#%%hi(");
+	  ubicom32_print_operand_address (file, XEXP (x, 0));
+	  fprintf (file, ")");
+	  break;
+
+	case UNSPEC:
+	  switch (XINT (x, 1))
+	    {
+	    case UNSPEC_FDPIC_GOT:
+	      fprintf (file, "#%%got_lo(");
+	      ubicom32_print_operand_address (file, XVECEXP (x, 0, 0));
+	      fprintf (file, ")");
+	      break;
+
+	    case UNSPEC_FDPIC_GOT_FUNCDESC:
+	      fprintf (file, "#%%got_funcdesc_lo(");
+	      ubicom32_print_operand_address (file, XVECEXP (x, 0, 0));
+	      fprintf (file, ")");
+	      break;
+
+	    default:
+	      abort ();
+	    }
+          break;
+
+	default:
+	  abort ();
+	}
+      break;
+   }
+}
+
+/* Output assembly language output for the address ADDR to FILE.  */
+
+void
+ubicom32_print_operand_address (FILE *file, rtx addr)
+{
+  switch (GET_CODE (addr))
+    {
+    case POST_INC:
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "%d++", GET_MODE_SIZE (output_memory_reference_mode));
+      break;
+
+    case PRE_INC:
+      fprintf (file, "%d", GET_MODE_SIZE (output_memory_reference_mode));
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "++");
+      break;
+
+    case POST_DEC:
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "%d++", -GET_MODE_SIZE (output_memory_reference_mode));
+      break;
+
+    case PRE_DEC:
+      fprintf (file, "%d", -GET_MODE_SIZE (output_memory_reference_mode));
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "++");
+      break;
+
+    case POST_MODIFY:
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "%ld++", INTVAL (XEXP (XEXP (addr,1), 1)));
+      break;
+
+    case PRE_MODIFY:
+      fprintf (file, "%ld", INTVAL (XEXP (XEXP (addr,1), 1)));
+      ubicom32_print_operand_address (file, XEXP (addr, 0));
+      fprintf (file, "++");
+      break;
+
+    case REG:
+      fputc ('(', file);
+      fprintf (file, "%s", reg_names[REGNO (addr)]); 
+      fputc (')', file);
+      break;
+
+    case PLUS:
+      {
+	rtx base = XEXP (addr, 0);
+	rtx index = XEXP (addr, 1); 
+
+ 	/* Switch around addresses of the form index * scaling + base.  */
+ 	if (! ubicom32_is_base_reg (base, 1))
+ 	  {
+ 	    rtx tmp = base;
+ 	    base = index;
+ 	    index = tmp;
+ 	  }
+
+	if (CONST_INT_P (index)) 
+	  {
+	    fprintf (file, "%ld", INTVAL (index)); 
+	    fputc ('(', file);
+	    fputs (reg_names[REGNO (base)], file); 
+	  }
+ 	else if (GET_CODE (index) == MULT
+ 	         || REG_P (index))
+	  {
+ 	    if (GET_CODE (index) == MULT)
+ 	      index = XEXP (index, 0);
+	    fputc ('(', file);
+	    fputs (reg_names[REGNO (base)], file); 
+	    fputc (',', file);
+	    fputs (reg_names[REGNO (index)], file); 
+	  }
+	else 
+	  abort (); 
+
+	fputc (')', file);
+	break;
+      }
+
+    case LO_SUM:
+      fprintf (file, "%%lo(");
+      ubicom32_print_operand (file, XEXP (addr, 1), 'L');
+      fprintf (file, ")(");
+      ubicom32_print_operand (file, XEXP (addr, 0), 0);
+      fprintf (file, ")");
+      break;
+
+    case CONST_INT:
+      fputc ('#', file);
+      output_addr_const (file, addr); 
+      break;
+
+    default:
+      output_addr_const (file, addr);
+      break;
+    }
+}
+
+/* X and Y are two things to compare using CODE.  Emit the compare insn and
+   return the rtx for the cc reg in the proper mode.  */
+
+rtx
+ubicom32_gen_compare_reg (enum rtx_code code, rtx x, rtx y)
+{
+  enum machine_mode mode = SELECT_CC_MODE (code, x, y);
+  rtx cc_reg;
+
+  cc_reg = gen_rtx_REG (mode, CC_REGNUM);
+
+  emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
+			  gen_rtx_COMPARE (mode, x, y)));
+
+  return cc_reg;
+}
+
+/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
+   return the mode to be used for the comparison.  */
+
+enum machine_mode
+ubicom32_select_cc_mode (enum rtx_code op, rtx x, rtx y)
+{
+  /* Is this a short compare?  */
+  if (GET_MODE (x) == QImode
+      || GET_MODE (x) == HImode
+      || GET_MODE (y) == QImode
+      || GET_MODE (y) == HImode)
+    {
+      switch (op)
+	{
+	case EQ :
+	case NE :
+	  return CCSZmode;
+
+	case GE:
+	case LT:
+	  if (y == const0_rtx)
+	    return CCSZNmode;
+
+	default :
+	  return CCSmode;
+	}
+    }
+
+  /* We have a word compare.  */
+  switch (op)
+    {
+    case EQ :
+    case NE :
+      return CCWZmode;
+
+    case GE :
+    case LT :
+      if (y == const0_rtx)
+	return CCWZNmode;
+
+    default :
+      return CCWmode;
+    }
+}
+
+/* Return TRUE or FALSE depending on whether the first SET in INSN
+   has source and destination with matching CC modes, and that the
+   CC mode is at least as constrained as REQ_MODE.  */
+bool
+ubicom32_match_cc_mode (rtx insn, enum machine_mode req_mode)
+{
+  rtx set;
+  enum machine_mode set_mode;
+
+  set = PATTERN (insn);
+  if (GET_CODE (set) == PARALLEL)
+    set = XVECEXP (set, 0, 0);
+  gcc_assert (GET_CODE (set) == SET);
+  gcc_assert (GET_CODE (SET_SRC (set)) == COMPARE);
+
+  /* SET_MODE is the mode we have in the instruction.  This must either
+     be the same or less restrictive that the required mode REQ_MODE.  */
+  set_mode = GET_MODE (SET_DEST (set));
+
+  switch (req_mode)
+    {
+    case CCSZmode:
+      if (set_mode != CCSZmode)
+	return 0;
+      break;
+
+    case CCSZNmode:
+      if (set_mode != CCSZmode
+	  && set_mode != CCSZNmode)
+	return 0;
+      break;
+
+    case CCSmode:
+      if (set_mode != CCSmode
+	  && set_mode != CCSZmode
+	  && set_mode != CCSZNmode)
+	return 0;
+      break;
+
+    case CCWZmode:
+      if (set_mode != CCWZmode)
+	return 0;
+      break;
+
+    case CCWZNmode:
+      if (set_mode != CCWZmode
+	  && set_mode != CCWZNmode)
+	return 0;
+      break;
+
+    case CCWmode:
+      if (set_mode != CCWmode
+	  && set_mode != CCWZmode
+	  && set_mode != CCWZNmode)
+	return 0;
+      break;
+
+    default:
+      gcc_unreachable ();
+    }
+
+  return (GET_MODE (SET_SRC (set)) == set_mode);
+}
+
+/* Replace the comparison OP0 CODE OP1 by a semantically equivalent one
+   that we can implement more efficiently.  */
+
+void
+ubicom32_canonicalize_comparison (enum rtx_code *code, rtx *op0, rtx *op1)
+{
+  /* If we have a REG and a MEM then compare the MEM with the REG and not
+     the other way round.  */
+  if (REG_P (*op0) && MEM_P (*op1))
+    {
+      rtx tem = *op0;
+      *op0 = *op1;
+      *op1 = tem;
+      *code = swap_condition (*code);
+      return;
+    }
+
+  /* If we have a REG and a CONST_INT then we may want to reverse things
+     if the constant can be represented as an "I" constraint.  */
+  if (REG_P (*op0) && CONST_INT_P (*op1) && satisfies_constraint_I (*op1))
+    {
+      rtx tem = *op0;
+      *op0 = *op1;
+      *op1 = tem;
+      *code = swap_condition (*code);
+      return;
+    }
+}
+
+/* Return the fixed registers used for condition codes.  */
+
+static bool
+ubicom32_fixed_condition_code_regs (unsigned int *p1, unsigned int *p2)
+{
+  *p1 = CC_REGNUM;
+  *p2 = INVALID_REGNUM;
+ 
+  return true;
+}
+
+/* If two condition code modes are compatible, return a condition code
+   mode which is compatible with both.  Otherwise, return
+   VOIDmode.  */
+
+static enum machine_mode
+ubicom32_cc_modes_compatible (enum machine_mode m1, enum machine_mode m2)
+{
+  if (m1 == m2)
+    return m1;
+
+  if (GET_MODE_CLASS (m1) != MODE_CC || GET_MODE_CLASS (m2) != MODE_CC)
+    return VOIDmode;
+
+  switch (m1)
+    {
+    case CCWmode:
+      if (m2 == CCWZNmode || m2 == CCWZmode)
+	return m1;
+
+      return VOIDmode;
+
+    case CCWZNmode:
+      if (m2 == CCWmode)
+	return m2;
+
+      if (m2 == CCWZmode)
+	return m1;
+
+      return VOIDmode;
+
+    case CCWZmode:
+      if (m2 == CCWmode || m2 == CCWZNmode)
+	return m2;
+
+      return VOIDmode;
+
+    case CCSmode:
+      if (m2 == CCSZNmode || m2 == CCSZmode)
+	return m1;
+
+      return VOIDmode;
+
+    case CCSZNmode:
+      if (m2 == CCSmode)
+	return m2;
+
+      if (m2 == CCSZmode)
+	return m1;
+
+      return VOIDmode;
+
+    case CCSZmode:
+      if (m2 == CCSmode || m2 == CCSZNmode)
+	return m2;
+
+      return VOIDmode;
+
+    default:
+      gcc_unreachable ();
+    }
+}
+
+static rtx
+ubicom32_legitimize_fdpic_address_symbol (rtx orig, rtx reg, rtx fdpic_reg)
+{
+  int unspec;
+  rtx got_offs;
+  rtx got_offs_scaled;
+  rtx plus_scaled;
+  rtx tmp;
+  rtx new_rtx;
+
+  gcc_assert (reg != 0);
+
+  if (GET_CODE (orig) == SYMBOL_REF
+      && SYMBOL_REF_FUNCTION_P (orig))
+    unspec = UNSPEC_FDPIC_GOT_FUNCDESC;
+  else
+    unspec = UNSPEC_FDPIC_GOT;
+
+  got_offs = gen_reg_rtx (SImode);
+  tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, orig), unspec);
+  emit_move_insn (got_offs, tmp);
+
+  got_offs_scaled = gen_rtx_MULT (SImode, got_offs, GEN_INT (4));
+  plus_scaled = gen_rtx_PLUS (Pmode, fdpic_reg, got_offs_scaled);
+  new_rtx = gen_const_mem (Pmode, plus_scaled);
+  emit_move_insn (reg, new_rtx);
+
+  return reg;
+}
+
+static rtx
+ubicom32_legitimize_fdpic_address (rtx orig, rtx reg, rtx fdpic_reg)
+{
+  rtx addr = orig;
+  rtx new_rtx = orig;
+
+  if (GET_CODE (addr) == CONST || GET_CODE (addr) == PLUS)
+    {
+      rtx base;
+
+      if (GET_CODE (addr) == CONST)
+	{
+	  addr = XEXP (addr, 0);
+	  gcc_assert (GET_CODE (addr) == PLUS);
+	}
+
+      base = ubicom32_legitimize_fdpic_address_symbol (XEXP (addr, 0), reg, fdpic_reg);
+      return gen_rtx_PLUS (Pmode, base, XEXP (addr, 1));
+    }
+
+  return new_rtx;
+}
+
+/* Code generation.  */
+
+void
+ubicom32_expand_movsi (rtx *operands)
+{
+  if (GET_CODE (operands[1]) == SYMBOL_REF
+      || (GET_CODE (operands[1]) == CONST
+	  && GET_CODE (XEXP (operands[1], 0)) == PLUS
+	  && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
+      || CONSTANT_ADDRESS_P (operands[1]))
+    {
+      if (TARGET_FDPIC)
+	{
+	  rtx tmp;
+	  rtx fdpic_reg;
+
+	  gcc_assert (can_create_pseudo_p ());
+	  tmp = gen_reg_rtx (Pmode);
+	  fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
+	  if (GET_CODE (operands[1]) == SYMBOL_REF
+	      || GET_CODE (operands[1]) == LABEL_REF)
+	    operands[1] = ubicom32_legitimize_fdpic_address_symbol (operands[1], tmp, fdpic_reg);
+	  else
+	    operands[1] = ubicom32_legitimize_fdpic_address (operands[1], tmp, fdpic_reg);
+	}
+      else
+	{
+	  rtx tmp;
+	  enum machine_mode mode;
+
+	  /* We want to avoid reusing operand 0 if we can because it limits
+	     our ability to optimize later.  */
+	  tmp = ! can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode);
+
+	  mode = GET_MODE (operands[0]);
+	  emit_insn (gen_rtx_SET (VOIDmode, tmp,
+				  gen_rtx_HIGH (mode, operands[1])));
+	  operands[1] = gen_rtx_LO_SUM (mode, tmp, operands[1]);
+	  if (can_create_pseudo_p() && ! REG_P (operands[0]))
+	    {
+	      tmp = gen_reg_rtx (mode);
+	      emit_insn (gen_rtx_SET (VOIDmode, tmp, operands[1]));
+	      operands[1] = tmp;
+	    }
+	}
+    }
+}
+
+/* Emit code for addsi3.  */
+
+void
+ubicom32_expand_addsi3 (rtx *operands)
+{
+  rtx op, clob;
+
+  if (can_create_pseudo_p ())
+    {
+      /* If we have a non-data reg for operand 1 then prefer that over
+         a CONST_INT in operand 2.  */
+      if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	  && CONST_INT_P (operands[2]))
+	operands[2] = copy_to_mode_reg (SImode, operands[2]);
+
+      if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+	operands[2] = copy_to_mode_reg (SImode, operands[2]);
+    }
+
+  /* Emit the instruction.  */
+
+  op = gen_rtx_SET (VOIDmode, operands[0],
+		    gen_rtx_PLUS (SImode, operands[1], operands[2]));
+
+  if (! can_create_pseudo_p ())
+    {
+      /* Reload doesn't know about the flags register, and doesn't know that
+         it doesn't want to clobber it.  We can only do this with PLUS.  */
+      emit_insn (op);
+    }
+  else
+    {
+      clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, CC_REGNUM));
+      emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, op, clob)));
+    }
+}
+
+/* Emit code for mulsi3.  Return 1 if we have generated all the code
+   necessary to do the multiplication.  */
+
+int
+ubicom32_emit_mult_sequence (rtx *operands)
+{
+  if (! ubicom32_v4)
+    {
+      rtx a1, a1_1, a2;
+      rtx b1, b1_1, b2;
+      rtx mac_lo_rtx;
+      rtx t1, t2, t3;
+
+      /* Give up if we cannot create new pseudos.  */
+      if (!can_create_pseudo_p())
+	return 0;
+
+      /* Synthesize 32-bit multiplication using 16-bit operations:
+     
+	 a1 = highpart (a)
+	 a2 = lowpart (a)
+
+	 b1 = highpart (b)
+	 b2 = lowpart (b)
+
+	 c = (a1 * b1) << 32 + (a1 * b2) << 16 + (a2 * b1) << 16 + a2 * b2
+	   =        0        + (a1 * b2) << 16 + (a2 * b1) << 16 + a2 * b2
+	                       ^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^   ^^^^^^^
+			           Signed             Signed      Unsigned  */
+
+      if (!ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
+	{
+	  rtx op1;
+
+	  op1 = gen_reg_rtx (SImode);
+	  emit_move_insn (op1, operands[1]);
+	  operands[1] = op1;
+	}
+
+      if (!ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
+	{
+	  rtx op2;
+
+	  op2 = gen_reg_rtx (SImode);
+	  emit_move_insn (op2, operands[2]);
+	  operands[2] = op2;
+	}
+
+      /* a1 = highpart (a)  */
+      a1 = gen_reg_rtx (HImode);
+      a1_1 = gen_reg_rtx (SImode);
+      emit_insn (gen_ashrsi3 (a1_1, operands[1], GEN_INT (16)));
+      emit_move_insn (a1, gen_lowpart (HImode, a1_1));
+
+      /* a2 = lowpart (a)  */
+      a2 = gen_reg_rtx (HImode);
+      emit_move_insn (a2, gen_lowpart (HImode, operands[1]));
+
+      /* b1 = highpart (b)  */
+      b1 = gen_reg_rtx (HImode);
+      b1_1 = gen_reg_rtx (SImode);
+      emit_insn (gen_ashrsi3 (b1_1, operands[2], GEN_INT (16)));
+      emit_move_insn (b1, gen_lowpart (HImode, b1_1));
+
+      /* b2 = lowpart (b)  */
+      b2 = gen_reg_rtx (HImode);
+      emit_move_insn (b2, gen_lowpart (HImode, operands[2]));
+
+      /* t1 = (a1 * b2) << 16  */
+      t1 = gen_reg_rtx (SImode);
+      mac_lo_rtx = gen_rtx_REG (SImode, ACC0_LO_REGNUM);
+      emit_insn (gen_mulhisi3 (mac_lo_rtx, a1, b2));
+      emit_insn (gen_ashlsi3 (t1, mac_lo_rtx, GEN_INT (16)));
+
+      /* t2 = (a2 * b1) << 16  */
+      t2 = gen_reg_rtx (SImode);
+      emit_insn (gen_mulhisi3 (mac_lo_rtx, a2, b1));
+      emit_insn (gen_ashlsi3 (t2, mac_lo_rtx, GEN_INT (16)));
+
+      /* mac_lo = a2 * b2  */
+      emit_insn (gen_umulhisi3 (mac_lo_rtx, a2, b2));
+
+      /* t3 = t1 + t2  */
+      t3 = gen_reg_rtx (SImode);
+      emit_insn (gen_addsi3 (t3, t1, t2));
+
+      /* c = t3 + mac_lo_rtx  */
+      emit_insn (gen_addsi3 (operands[0], mac_lo_rtx, t3));
+
+      return 1;
+    }
+  else
+    {
+      rtx acc_rtx;
+
+      /* Give up if we cannot create new pseudos.  */
+      if (!can_create_pseudo_p())
+	return 0;
+
+      if (!ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
+        {
+	  rtx op1;
+
+	  op1 = gen_reg_rtx (SImode);
+	  emit_move_insn (op1, operands[1]);
+	  operands[1] = op1;
+	}
+
+      if (!ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
+	{
+	  rtx op2;
+
+	  op2 = gen_reg_rtx (SImode);
+	  emit_move_insn (op2, operands[2]);
+	  operands[2] = op2;
+	}
+
+      acc_rtx = gen_reg_rtx (DImode);
+      emit_insn (gen_umulsidi3 (acc_rtx, operands[1], operands[2]));
+      emit_move_insn (operands[0], gen_lowpart (SImode, acc_rtx));
+
+      return 1;
+    }
+}
+
+/* Move the integer value VAL into OPERANDS[0].  */
+
+void
+ubicom32_emit_move_const_int (rtx dest, rtx imm)
+{
+  rtx xoperands[2];
+  
+  xoperands[0] = dest;
+  xoperands[1] = imm;
+
+  /* Treat mem destinations separately.  Values must be explicitly sign
+     extended.  */
+  if (MEM_P (dest))
+    {
+      rtx low_hword_mem;
+      rtx low_hword_addr;
+
+      /* Emit shorter sequence for signed 7-bit quantities.  */
+      if (satisfies_constraint_I (imm))
+	{
+          output_asm_insn ("move.4\t%0, %1", xoperands);
+          return;
+	}
+
+      /* Special case for pushing constants.  */
+      if (GET_CODE (XEXP (dest, 0)) == PRE_DEC
+	  && XEXP (XEXP (dest, 0), 0) == stack_pointer_rtx)
+	{
+	  output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
+	  output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
+	  return;
+	}
+
+      /* See if we can add 2 to the original address.  This is only
+	 possible if the original address is of the form REG or
+	 REG+const.  */
+      low_hword_addr = plus_constant (XEXP (dest, 0), 2);
+      if (ubicom32_legitimate_address_p (HImode, low_hword_addr, 1))
+	{
+	  low_hword_mem = gen_rtx_MEM (HImode, low_hword_addr);
+	  MEM_COPY_ATTRIBUTES (low_hword_mem, dest);
+	  output_asm_insn ("movei\t%0, #%%hi(%E1)", xoperands);
+	  xoperands[0] = low_hword_mem;
+	  output_asm_insn ("movei\t%0, #%%lo(%E1)", xoperands);
+	  return;
+	}
+
+      /* The original address is too complex.  We need to use a
+	 scratch memory by (sp) and move that to the original
+	 destination.  */
+      if (! reg_mentioned_p (stack_pointer_rtx, dest))
+	{
+	  output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
+	  output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
+	  output_asm_insn ("move.4\t%0, (sp)4++", xoperands);
+	  return;
+	}
+
+      /* Our address mentions the stack pointer so we need to
+	 use our scratch data register here as well as scratch
+	 memory.  */
+      output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
+      output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
+      output_asm_insn ("move.4\td15, (sp)4++", xoperands);
+      output_asm_insn ("move.4\t%0, d15", xoperands);
+      return;
+    }
+
+  /* Move into registers are zero extended by default.  */
+  if (! REG_P (dest))
+    abort ();
+
+  if (satisfies_constraint_N (imm))
+    {
+      output_asm_insn ("movei\t%0, %1", xoperands);
+      return;
+    }
+
+  if (INTVAL (xoperands[1]) >= 0xff80
+      && INTVAL (xoperands[1]) < 0x10000)
+    {
+      xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 0x10000);
+      output_asm_insn ("move.2\t%0, %1", xoperands);
+      return;
+    }
+
+  if ((REGNO_REG_CLASS (REGNO (xoperands[0])) == ADDRESS_REGS
+       || REGNO_REG_CLASS (REGNO (xoperands[0])) == FDPIC_REG)
+      && ((INTVAL (xoperands[1]) & 0x80000000) == 0))
+    {
+      output_asm_insn ("moveai\t%0, #%%hi(%E1)", xoperands);
+      if ((INTVAL (xoperands[1]) & 0x7f) != 0)
+	output_asm_insn ("lea.1\t%0, %%lo(%E1)(%0)", xoperands);
+      return;
+    }
+
+  if ((INTVAL (xoperands[1]) & 0xffff0000) == 0)
+    {
+      output_asm_insn ("movei\t%0, #%%lo(%E1)", xoperands);
+      output_asm_insn ("move.2\t%0, %0", xoperands);
+      return;
+    }
+
+  /* This is very expensive.  The constant is so large that we
+     need to use the stack to do the load.  */
+  output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
+  output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
+  output_asm_insn ("move.4\t%0, (sp)4++", xoperands);
+}
+
+/* Stack layout. Prologue/Epilogue.  */
+
+static int save_regs_size;
+
+static void 
+ubicom32_layout_frame (void)
+{
+  int regno;
+  
+  memset ((char *) &save_regs[0], 0, sizeof (save_regs));
+  nregs = 0;
+  frame_size = get_frame_size ();
+
+  if (frame_pointer_needed || df_regs_ever_live_p (FRAME_POINTER_REGNUM))
+    {
+      save_regs[FRAME_POINTER_REGNUM] = 1;
+      ++nregs;
+    }
+
+  if (current_function_is_leaf && ! df_regs_ever_live_p (LINK_REGNO))
+    ubicom32_can_use_calli_to_ret = 1;
+  else
+    {
+      ubicom32_can_use_calli_to_ret = 0;
+      save_regs[LINK_REGNO] = 1;
+      ++nregs;
+    }
+
+  /* Figure out which register(s) needs to be saved.  */
+  for (regno = 0; regno <= LAST_ADDRESS_REGNUM; regno++)
+	if (df_regs_ever_live_p(regno)
+	&& ! call_used_regs[regno]
+	&& ! fixed_regs[regno]
+	&& ! save_regs[regno])
+    {
+      save_regs[regno] = 1;
+      ++nregs;
+    }
+
+  save_regs_size = 4 * nregs;
+}
+
+static void
+ubicom32_emit_add_movsi (int regno, int adj)
+{
+  rtx x;
+  rtx reg = gen_rtx_REG (SImode, regno);
+
+  adj += 4;
+  if (adj > 8 * 4) 
+    {
+      x = emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+				 GEN_INT (-adj)));
+      RTX_FRAME_RELATED_P (x) = 1;
+      x = emit_move_insn (gen_rtx_MEM (SImode, stack_pointer_rtx), reg);
+    }
+  else
+    {
+      rtx addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx,
+				     gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+						   GEN_INT (-adj)));
+      x = emit_move_insn (gen_rtx_MEM (SImode, addr), reg);
+    }
+  RTX_FRAME_RELATED_P (x) = 1;      
+}
+
+void
+ubicom32_expand_prologue (void)
+{
+  rtx x;
+  int regno;
+  int outgoing_args_size = crtl->outgoing_args_size;
+  int adj;
+
+  if (ubicom32_naked_function_p ())
+    return;
+
+  ubicom32_builtin_saveregs ();
+  
+  ubicom32_layout_frame ();
+  adj = (outgoing_args_size + get_frame_size () + save_regs_size
+	 + crtl->args.pretend_args_size);
+  
+  if (!adj)
+    ;
+  else if (outgoing_args_size + save_regs_size < 508
+	   && get_frame_size () + save_regs_size > 508)
+    {
+      int i = 0;
+      x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+		      GEN_INT (-adj));
+      x = emit_insn (x);
+      RTX_FRAME_RELATED_P (x) = 1;
+
+      for (regno = LAST_ADDRESS_REGNUM; regno >= 0; --regno)
+	if (save_regs[regno] && regno != LINK_REGNO)
+	  {
+	    x = gen_rtx_MEM (SImode,
+			     gen_rtx_PLUS (Pmode,
+					   stack_pointer_rtx,
+					   GEN_INT (i * 4 + outgoing_args_size)));
+	    x = emit_move_insn (x, gen_rtx_REG (SImode, regno));
+	    RTX_FRAME_RELATED_P (x) = 1;
+	    ++i;
+	  }
+      if (save_regs[LINK_REGNO])
+	{
+	  x = gen_rtx_MEM (SImode,
+			   gen_rtx_PLUS (Pmode,
+					 stack_pointer_rtx,
+					 GEN_INT (i * 4 + outgoing_args_size)));
+	  x = emit_move_insn (x, gen_rtx_REG (SImode, LINK_REGNO));
+	  RTX_FRAME_RELATED_P (x) = 1;
+	}
+    }
+  else
+    {
+      int regno;
+      int adj = get_frame_size () + crtl->args.pretend_args_size;
+      int i = 0;
+
+      if (save_regs[LINK_REGNO])
+	{
+	  ubicom32_emit_add_movsi (LINK_REGNO, adj);
+	  ++i;
+	}
+      
+      for (regno = 0; regno <= LAST_ADDRESS_REGNUM; ++regno)
+	if (save_regs[regno] && regno != LINK_REGNO)
+	  {
+	    if (i)
+	      {
+		rtx mem = gen_rtx_MEM (SImode,
+				       gen_rtx_PRE_DEC (Pmode,
+							stack_pointer_rtx));
+		x = emit_move_insn (mem, gen_rtx_REG (SImode, regno));
+		RTX_FRAME_RELATED_P (x) = 1;
+	      }
+	    else
+	      ubicom32_emit_add_movsi (regno, adj);
+	    ++i;
+	  }
+      
+      if (outgoing_args_size || (!i && adj))
+	{
+	  x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+			  GEN_INT (-outgoing_args_size - (i ? 0 : adj)));
+	  x = emit_insn (x);
+	  RTX_FRAME_RELATED_P (x) = 1;
+	}
+    }
+
+  if (frame_pointer_needed)
+    {
+      int fp_adj = save_regs_size + outgoing_args_size;
+      x = gen_addsi3 (frame_pointer_rtx, stack_pointer_rtx,
+		      GEN_INT (fp_adj));
+      x = emit_insn (x);
+      RTX_FRAME_RELATED_P (x) = 1;
+    }
+}
+
+void
+ubicom32_expand_epilogue (void)
+{
+  rtx x;
+  int regno;
+  int outgoing_args_size = crtl->outgoing_args_size;
+  int adj;
+  int i;
+
+  if (ubicom32_naked_function_p ())
+    {
+      emit_jump_insn (gen_return_internal (gen_rtx_REG (SImode,
+						        LINK_REGNO)));
+      return;
+    }
+
+  if (cfun->calls_alloca)
+    {
+      x = gen_addsi3 (stack_pointer_rtx, frame_pointer_rtx,
+		      GEN_INT (-save_regs_size));
+      emit_insn (x);
+      outgoing_args_size = 0;
+    }
+  
+  if (outgoing_args_size)
+    {
+      x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+		      GEN_INT (outgoing_args_size));
+      emit_insn (x);
+    }
+
+  i = 0;
+  for (regno = LAST_ADDRESS_REGNUM; regno >= 0; --regno)
+    if (save_regs[regno] && regno != LINK_REGNO)
+      {
+	x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
+	emit_move_insn (gen_rtx_REG (SImode, regno), x);
+	++i;
+      }
+
+  /* Do we have to adjust the stack after we've finished restoring regs?  */
+  adj = get_frame_size() + crtl->args.pretend_args_size;
+  if (cfun->stdarg)
+    adj += UBICOM32_FUNCTION_ARG_REGS * UNITS_PER_WORD;
+ 
+#if 0
+  if (crtl->calls_eh_return && 0)
+    {
+      if (save_regs[LINK_REGNO])
+        {
+          x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
+          emit_move_insn (gen_rtx_REG (SImode, LINK_REGNO), x);
+        }
+
+      if (adj)
+        {
+          x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+			  GEN_INT (adj));
+          x = emit_insn (x);
+        }
+
+      /* Perform the additional bump for __throw.  */
+      emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+			     EH_RETURN_STACKADJ_RTX));
+      emit_jump_insn (gen_eh_return_internal ());
+      return;
+    }
+#endif
+
+  if (save_regs[LINK_REGNO])
+    {
+      if (adj >= 4 && adj <= (6 * 4))
+        {
+	  x = GEN_INT (adj + 4);
+          emit_jump_insn (gen_return_from_post_modify_sp (x));
+	  return;
+        }
+
+      if (adj == 0)
+	{
+          x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
+          emit_jump_insn (gen_return_internal (x));
+          return;
+	}
+
+      x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
+      emit_move_insn (gen_rtx_REG (SImode, LINK_REGNO), x);
+    }
+
+  if (adj)
+    {
+      x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
+		      GEN_INT (adj));
+      x = emit_insn (x);
+      adj = 0;
+    }
+
+  /* Given that we've just done all the hard work here we may as well use
+     a calli to return.  */
+  ubicom32_can_use_calli_to_ret = 1;
+  emit_jump_insn (gen_return_internal (gen_rtx_REG (SImode, LINK_REGNO)));
+}
+
+void
+ubicom32_expand_call_fdpic (rtx *operands)
+{
+  rtx c;
+  rtx addr;
+  rtx fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
+
+  addr = XEXP (operands[0], 0);
+
+  c = gen_call_fdpic (addr, operands[1], fdpic_reg);
+  emit_call_insn (c);
+}
+
+void
+ubicom32_expand_call_value_fdpic (rtx *operands)
+{
+  rtx c;
+  rtx addr;
+  rtx fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
+
+  addr = XEXP (operands[1], 0);
+
+  c = gen_call_value_fdpic (operands[0], addr, operands[2], fdpic_reg);
+  emit_call_insn (c);
+}
+
+void
+ubicom32_expand_eh_return (rtx *operands)
+{
+  if (REG_P (operands[0])
+      || REGNO (operands[0]) != EH_RETURN_STACKADJ_REGNO)
+    {
+      rtx sp = EH_RETURN_STACKADJ_RTX;
+      emit_move_insn (sp, operands[0]);
+      operands[0] = sp;
+    }
+
+  if (REG_P (operands[1])
+      || REGNO (operands[1]) != EH_RETURN_HANDLER_REGNO)
+    {
+      rtx ra = EH_RETURN_HANDLER_RTX;
+      emit_move_insn (ra, operands[1]);
+      operands[1] = ra;
+    }
+}
+
+/* Compute the offsets between eliminable registers.  */
+
+int
+ubicom32_initial_elimination_offset (int from, int to)
+{
+  ubicom32_layout_frame ();
+  if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
+    return save_regs_size + crtl->outgoing_args_size;
+
+  if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
+    return get_frame_size ()/* + save_regs_size */;
+
+  if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
+    return get_frame_size ()
+	   + crtl->outgoing_args_size
+	   + save_regs_size;
+
+  return 0;
+}
+
+/* Return 1 if it is appropriate to emit `ret' instructions in the
+   body of a function.  Do this only if the epilogue is simple, needing a
+   couple of insns.  Prior to reloading, we can't tell how many registers
+   must be saved, so return 0 then.  Return 0 if there is no frame
+   marker to de-allocate.
+
+   If NON_SAVING_SETJMP is defined and true, then it is not possible
+   for the epilogue to be simple, so return 0.  This is a special case
+   since NON_SAVING_SETJMP will not cause regs_ever_live to change
+   until final, but jump_optimize may need to know sooner if a
+   `return' is OK.  */
+
+int
+ubicom32_can_use_return_insn_p (void)
+{
+  if (! reload_completed || frame_pointer_needed)
+    return 0;
+
+  return 1;
+}
+
+/* Attributes and CC handling.  */
+
+/* Handle an attribute requiring a FUNCTION_DECL; arguments as in
+   struct attribute_spec.handler.  */
+static tree
+ubicom32_handle_fndecl_attribute (tree *node, tree name,
+			      tree args ATTRIBUTE_UNUSED,
+			      int flags ATTRIBUTE_UNUSED,
+			      bool *no_add_attrs)
+{
+  if (TREE_CODE (*node) != FUNCTION_DECL)
+    {
+      warning ("'%s' attribute only applies to functions",
+	       IDENTIFIER_POINTER (name));
+      *no_add_attrs = true;
+    }
+
+  return NULL_TREE;
+}
+
+/* A C expression that places additional restrictions on the register class to
+   use when it is necessary to copy value X into a register in class CLASS.
+   The value is a register class; perhaps CLASS, or perhaps another, smaller
+   class.  On many machines, the following definition is safe:
+
+        #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
+
+   Sometimes returning a more restrictive class makes better code.  For
+   example, on the 68000, when X is an integer constant that is in range for a
+   `moveq' instruction, the value of this macro is always `DATA_REGS' as long
+   as CLASS includes the data registers.  Requiring a data register guarantees
+   that a `moveq' will be used.
+
+   If X is a `const_double', by returning `NO_REGS' you can force X into a
+   memory constant.  This is useful on certain machines where immediate
+   floating values cannot be loaded into certain kinds of registers.  */
+
+enum reg_class
+ubicom32_preferred_reload_class (rtx x, enum reg_class class)
+{
+  /* If a symbolic constant, HIGH or a PLUS is reloaded,
+     it is most likely being used as an address, so
+     prefer ADDRESS_REGS.  If 'class' is not a superset
+     of ADDRESS_REGS, e.g. DATA_REGS, then reject this reload.  */
+  if (GET_CODE (x) == PLUS
+      || GET_CODE (x) == HIGH
+      || GET_CODE (x) == LABEL_REF
+      || GET_CODE (x) == SYMBOL_REF
+      || GET_CODE (x) == CONST)
+    {
+      if (reg_class_subset_p (ALL_ADDRESS_REGS, class))
+	return ALL_ADDRESS_REGS;
+
+      return NO_REGS;
+    }
+
+  return class;
+}
+
+/* Function arguments and varargs.  */
+
+int
+ubicom32_reg_parm_stack_space (tree fndecl)
+{
+  return 0;
+  
+  if (fndecl
+      && TYPE_ARG_TYPES (TREE_TYPE (fndecl)) != 0
+      && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))) 
+	  != void_type_node))
+    return UBICOM32_FUNCTION_ARG_REGS * UNITS_PER_WORD;
+
+  return 0;
+}
+
+/* Flush the argument registers to the stack for a stdarg function;
+   return the new argument pointer.  */
+
+rtx
+ubicom32_builtin_saveregs (void)
+{
+  int regno;
+  
+  if (! cfun->stdarg)
+    return 0;
+  
+  for (regno = UBICOM32_FUNCTION_ARG_REGS - 1; regno >= 0; --regno)
+    emit_move_insn (gen_rtx_MEM (SImode,
+				 gen_rtx_PRE_DEC (SImode,
+						  stack_pointer_rtx)),
+		    gen_rtx_REG (SImode, regno));
+  
+  return stack_pointer_rtx;
+}
+
+void
+ubicom32_va_start (tree valist, rtx nextarg)
+{
+  std_expand_builtin_va_start (valist, nextarg);
+}
+
+rtx
+ubicom32_va_arg (tree valist, tree type)
+{
+  HOST_WIDE_INT size, rsize;
+  tree addr, incr, tmp;
+  rtx addr_rtx;
+  int indirect = 0;
+
+  /* Round up sizeof(type) to a word.  */
+  size = int_size_in_bytes (type);
+  rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD;
+
+  /* Large types are passed by reference.  */
+  if (size > 8)
+    {
+      indirect = 1;
+      size = rsize = UNITS_PER_WORD;
+    }
+
+  incr = valist;
+  addr = incr = save_expr (incr);
+
+  /* FIXME Nat's version - is it correct?  */
+  tmp = fold_convert (ptr_type_node, size_int (rsize));
+  tmp = build2 (PLUS_EXPR, ptr_type_node, incr, tmp);
+  incr = fold (tmp);
+
+  /* FIXME Nat's version - is it correct? */
+  incr = build2 (MODIFY_EXPR, ptr_type_node, valist, incr);
+
+  TREE_SIDE_EFFECTS (incr) = 1;
+  expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+  addr_rtx = expand_expr (addr, NULL, Pmode, EXPAND_NORMAL);
+
+  if (size < UNITS_PER_WORD)
+    emit_insn (gen_addsi3 (addr_rtx, addr_rtx,
+			   GEN_INT (UNITS_PER_WORD - size)));
+
+  if (indirect)
+    {
+      addr_rtx = force_reg (Pmode, addr_rtx);
+      addr_rtx = gen_rtx_MEM (Pmode, addr_rtx);
+      set_mem_alias_set (addr_rtx, get_varargs_alias_set ());
+    }
+
+  return addr_rtx;
+}
+
+void
+init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname,
+		      int indirect ATTRIBUTE_UNUSED)
+{
+  cum->nbytes = 0;
+
+  if (!libname)
+    {
+      cum->stdarg = (TYPE_ARG_TYPES (fntype) != 0
+		     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
+			 != void_type_node));
+    }
+}
+
+/* Return an RTX to represent where a value in mode MODE will be passed
+   to a function.  If the result is 0, the argument will be pushed.  */
+
+rtx
+function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
+	      int named ATTRIBUTE_UNUSED)
+{
+  rtx result = 0;
+  int size, align;
+  int nregs = UBICOM32_FUNCTION_ARG_REGS;
+  
+  /* Figure out the size of the object to be passed.  */
+  if (mode == BLKmode)
+    size = int_size_in_bytes (type);
+  else
+    size = GET_MODE_SIZE (mode);
+
+  /* Figure out the alignment of the object to be passed.  */
+  align = size;
+
+  cum->nbytes = (cum->nbytes + 3) & ~3;
+
+  /* Don't pass this arg via a register if all the argument registers
+     are used up.  */
+  if (cum->nbytes >= nregs * UNITS_PER_WORD)
+    return 0;
+
+  /* Don't pass this arg via a register if it would be split between
+     registers and memory.  */
+  result = gen_rtx_REG (mode, cum->nbytes / UNITS_PER_WORD);
+
+  return result;
+}
+
+rtx
+function_incoming_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
+		       int named ATTRIBUTE_UNUSED)
+{
+  if (cfun->stdarg)
+    return 0;
+
+  return function_arg (cum, mode, type, named);
+}
+
+
+/* Implement hook TARGET_ARG_PARTIAL_BYTES.
+
+   Returns the number of bytes at the beginning of an argument that
+   must be put in registers.  The value must be zero for arguments
+   that are passed entirely in registers or that are entirely pushed
+   on the stack.  */
+static int
+ubicom32_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			    tree type, bool named ATTRIBUTE_UNUSED)
+{
+  int size, diff;
+
+  int nregs = UBICOM32_FUNCTION_ARG_REGS;
+
+  /* round up to full word */
+  cum->nbytes = (cum->nbytes + 3) & ~3;
+
+  if (targetm.calls.pass_by_reference (cum, mode, type, named))
+      return 0;
+
+  /* number of bytes left in registers */
+  diff = nregs*UNITS_PER_WORD - cum->nbytes;
+
+  /* regs all used up */
+  if (diff <= 0)
+    return 0;
+
+  /* Figure out the size of the object to be passed.  */
+  if (mode == BLKmode)
+    size = int_size_in_bytes (type);
+  else
+    size = GET_MODE_SIZE (mode);
+
+  /* enough space left in regs for size */
+  if (size <= diff)
+    return 0;
+
+  /* put diff bytes in regs and rest on stack */
+  return diff;
+
+}
+
+static bool
+ubicom32_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+			    enum machine_mode mode, const_tree type,
+			    bool named ATTRIBUTE_UNUSED)
+{
+  int size;
+
+  if (type)
+    size = int_size_in_bytes (type);
+  else
+    size = GET_MODE_SIZE (mode);
+
+  return size <= 0 || size > 8;
+}
+
+static bool
+ubicom32_callee_copies (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+			enum machine_mode mode, const_tree type,
+			bool named ATTRIBUTE_UNUSED)
+{
+  int size;
+
+  if (type)
+    size = int_size_in_bytes (type);
+  else
+    size = GET_MODE_SIZE (mode);
+
+  return size <= 0 || size > 8;
+}
+ 
+static bool
+ubicom32_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
+{
+  int size, mode;
+
+  if (!type)
+    return true;
+
+  size = int_size_in_bytes(type);
+  if (size > 8) 
+    return true;
+
+  mode = TYPE_MODE(type);
+  if (mode == BLKmode)
+    return true;
+
+  return false;
+}
+
+/* Return true if a given register number REGNO is acceptable for machine
+   mode MODE.  */
+bool
+ubicom32_hard_regno_mode_ok (unsigned int regno, enum machine_mode mode)
+{
+  /* If we're not at least a v3 ISA then ACC0_HI is only 16 bits.  */
+  if (! ubicom32_v3)
+    {
+      if (regno == ACC0_HI_REGNUM)
+	return (mode == QImode || mode == HImode);
+    }
+
+  /* Only the flags reg can hold CCmode.  */
+  if (GET_MODE_CLASS (mode) == MODE_CC)
+    return regno == CC_REGNUM;
+
+  /* We restrict the choice of DImode registers to only being address,
+     data or accumulator regs.  We also restrict them to only start on
+     even register numbers so we never have to worry about partial
+     overlaps between operands in instructions.  */
+  if (GET_MODE_SIZE (mode) > 4)
+    {
+      switch (REGNO_REG_CLASS (regno))
+	{
+	case ADDRESS_REGS:
+	case DATA_REGS:
+	case ACC_REGS:
+	  return (regno & 1) == 0;
+
+        default:
+	  return false;
+	}
+    }
+
+  return true;
+}
+
+/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
+   and check its validity for a certain class.
+   We have two alternate definitions for each of them.
+   The usual definition accepts all pseudo regs; the other rejects
+   them unless they have been allocated suitable hard regs.
+   The symbol REG_OK_STRICT causes the latter definition to be used.
+
+   Most source files want to accept pseudo regs in the hope that
+   they will get allocated to the class that the insn wants them to be in.
+   Source files for reload pass need to be strict.
+   After reload, it makes no difference, since pseudo regs have
+   been eliminated by then.  
+
+   These assume that REGNO is a hard or pseudo reg number.
+   They give nonzero only if REGNO is a hard reg of the suitable class
+   or a pseudo reg currently allocated to a suitable hard reg.
+   Since they use reg_renumber, they are safe only once reg_renumber
+   has been allocated, which happens in local-alloc.c.  */
+
+int
+ubicom32_regno_ok_for_base_p (int regno, int strict)
+{
+  if ((regno >= FIRST_ADDRESS_REGNUM && regno <= STACK_POINTER_REGNUM) 
+      || (!strict
+	  && (regno >= FIRST_PSEUDO_REGISTER
+	      || regno == ARG_POINTER_REGNUM))
+      || (strict && (reg_renumber 
+		     && reg_renumber[regno] >= FIRST_ADDRESS_REGNUM
+		     && reg_renumber[regno] <= STACK_POINTER_REGNUM)))
+    return 1;
+
+  return 0;
+}
+
+int
+ubicom32_regno_ok_for_index_p (int regno, int strict)
+{
+  if ((regno >= FIRST_DATA_REGNUM && regno <= LAST_DATA_REGNUM)
+      || (!strict && regno >= FIRST_PSEUDO_REGISTER)
+      || (strict && (reg_renumber 
+		     && reg_renumber[regno] >= FIRST_DATA_REGNUM
+		     && reg_renumber[regno] <= LAST_DATA_REGNUM)))
+    return 1;
+
+  return 0;
+}
+
+/* Returns 1 if X is a valid index register.  STRICT is 1 if only hard
+   registers should be accepted.  Accept either REG or SUBREG where a
+   register is valid.  */
+
+static bool
+ubicom32_is_index_reg (rtx x, int strict)
+{
+  if ((REG_P (x) && ubicom32_regno_ok_for_index_p (REGNO (x), strict))
+      || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))
+	  && ubicom32_regno_ok_for_index_p (REGNO (SUBREG_REG (x)), strict)))
+    return true;
+
+  return false;
+}
+
+/* Return 1 if X is a valid index for a memory address.  */
+
+static bool
+ubicom32_is_index_expr (enum machine_mode mode, rtx x, int strict)
+{
+  /* Immediate index must be an unsigned 7-bit offset multiple of 1, 2
+     or 4 depending on mode.  */
+  if (CONST_INT_P (x))
+    {
+      switch (mode)
+	{
+	case QImode:
+	  return satisfies_constraint_J (x);
+	  
+	case HImode:
+	  return satisfies_constraint_K (x);
+
+	case SImode:
+	case SFmode:
+	  return satisfies_constraint_L (x);
+
+	case DImode:
+	  return satisfies_constraint_L (x)
+		 && satisfies_constraint_L (GEN_INT (INTVAL (x) + 4));
+	  
+	default:	  
+	  return false;
+	}
+    }
+
+  if (mode != SImode && mode != HImode && mode != QImode)
+    return false;
+
+  /* Register index scaled by mode of operand: REG + REG * modesize.
+     Valid scaled index registers are:
+
+     SImode	(mult (dreg) 4))
+     HImode	(mult (dreg) 2))
+     QImode	(mult (dreg) 1))  */
+  if (GET_CODE (x) == MULT
+      && ubicom32_is_index_reg (XEXP (x, 0), strict)
+      && CONST_INT_P (XEXP (x, 1))
+      && INTVAL (XEXP (x, 1)) == (HOST_WIDE_INT)GET_MODE_SIZE (mode))
+    return true;
+
+  /* REG + REG addressing is allowed for QImode.  */
+  if (ubicom32_is_index_reg (x, strict) && mode == QImode)
+    return true;
+
+  return false;
+}
+
+static bool
+ubicom32_is_valid_offset (enum machine_mode mode, HOST_WIDE_INT offs)
+{
+  if (offs < 0)
+    return false;
+
+  switch (mode)
+    {
+    case QImode:
+      return offs <= 127;
+
+    case HImode:
+      return offs <= 254;
+
+    case SImode:
+    case SFmode:
+      return offs <= 508;
+
+    case DImode:
+      return offs <= 504;
+
+    default:
+      return false;
+    }
+}
+
+static int
+ubicom32_get_valid_offset_mask (enum machine_mode mode)
+{
+  switch (mode)
+    {
+    case QImode:
+      return 127;
+
+    case HImode:
+      return 255;
+
+    case SImode:
+    case SFmode:
+      return 511;
+
+    case DImode:
+      return 255;
+
+    default:
+      return 0;
+    }
+}
+
+/* Returns 1 if X is a valid base register.  STRICT is 1 if only hard
+   registers should be accepted.  Accept either REG or SUBREG where a
+   register is valid.  */
+
+static bool
+ubicom32_is_base_reg (rtx x, int strict)
+{
+  if ((REG_P (x) && ubicom32_regno_ok_for_base_p (REGNO (x), strict))
+      || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))
+	  && ubicom32_regno_ok_for_base_p (REGNO (SUBREG_REG (x)), strict)))
+    return true;
+
+  return false;
+}
+
+static bool
+ubicom32_cannot_force_const_mem (rtx x ATTRIBUTE_UNUSED)
+{
+  return TARGET_FDPIC;
+}
+
+/* Determine if X is a legitimate constant.  */
+
+bool
+ubicom32_legitimate_constant_p (rtx x)
+{
+  /* Among its other duties, LEGITIMATE_CONSTANT_P decides whether
+     a constant can be entered into reg_equiv_constant[].  If we return true,
+     reload can create new instances of the constant whenever it likes.
+
+     The idea is therefore to accept as many constants as possible (to give
+     reload more freedom) while rejecting constants that can only be created
+     at certain times.  In particular, anything with a symbolic component will
+     require use of the pseudo FDPIC register, which is only available before
+     reload.  */
+  if (TARGET_FDPIC)
+    {
+      if (GET_CODE (x) == SYMBOL_REF
+	  || (GET_CODE (x) == CONST
+	      && GET_CODE (XEXP (x, 0)) == PLUS
+	      && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF)
+	  || CONSTANT_ADDRESS_P (x))
+	return false;
+
+      return true;
+    }
+
+  /* For non-PIC code anything goes!  */
+  return true;
+}
+
+/* Address validation.  */
+
+bool
+ubicom32_legitimate_address_p (enum machine_mode mode, rtx x, int strict)
+{
+  if (TARGET_DEBUG_ADDRESS)
+    {									
+      fprintf (stderr, "\n==> GO_IF_LEGITIMATE_ADDRESS%s\n",
+	       (strict) ? " (STRICT)" : "");
+      debug_rtx (x);
+    }									
+
+  if (CONSTANT_ADDRESS_P (x))
+    return false;
+
+  if (ubicom32_is_base_reg (x, strict)) 
+    return true;
+
+  if ((GET_CODE (x) == POST_INC 
+       || GET_CODE (x) == PRE_INC 
+       || GET_CODE (x) == POST_DEC 
+       || GET_CODE (x) == PRE_DEC)
+      && REG_P (XEXP (x, 0))
+      && ubicom32_is_base_reg (XEXP (x, 0), strict)
+      && mode != DImode)
+    return true;
+
+  if ((GET_CODE (x) == PRE_MODIFY || GET_CODE (x) == POST_MODIFY)
+      && ubicom32_is_base_reg (XEXP (x, 0), strict)
+      && GET_CODE (XEXP (x, 1)) == PLUS
+      && rtx_equal_p (XEXP (x, 0), XEXP (XEXP (x, 1), 0))
+      && CONST_INT_P (XEXP (XEXP (x, 1), 1))
+      && mode != DImode)
+    {
+      HOST_WIDE_INT disp = INTVAL (XEXP (XEXP (x, 1), 1));
+      switch (mode)
+	{
+	case QImode:
+	  return disp >= -8 && disp <= 7;
+	  
+	case HImode:
+	  return disp >= -16 && disp <= 14 && ! (disp & 1);
+	  
+	case SImode:
+	  return disp >= -32 && disp <= 28 && ! (disp & 3);
+	  
+	default:
+	  return false;
+	}
+    }
+  
+  /* Accept base + index * scale.  */
+  if (GET_CODE (x) == PLUS
+      && ubicom32_is_base_reg (XEXP (x, 0), strict)
+      && ubicom32_is_index_expr (mode, XEXP (x, 1), strict))
+    return true;
+
+  /* Accept index * scale + base.  */
+  if (GET_CODE (x) == PLUS
+      && ubicom32_is_base_reg (XEXP (x, 1), strict)
+      && ubicom32_is_index_expr (mode, XEXP (x, 0), strict))
+    return true;
+
+  if (! TARGET_FDPIC)
+    {
+      /* Accept (lo_sum (reg) (symbol_ref)) that can be used as a mem+7bits
+	 displacement operand:
+
+	 moveai a1, #%hi(SYM)
+	 move.4 d3, %lo(SYM)(a1)  */
+      if (GET_CODE (x) == LO_SUM
+	  && ubicom32_is_base_reg (XEXP (x, 0), strict)
+	  && (GET_CODE (XEXP (x, 1)) == SYMBOL_REF
+	      || GET_CODE (XEXP (x, 1)) == LABEL_REF /* FIXME: wrong */)
+	  && mode != DImode)
+	return true;
+    }
+
+  if (TARGET_DEBUG_ADDRESS)
+    fprintf (stderr, "\nNot a legitimate address.\n");
+
+  return false;
+}
+
+rtx
+ubicom32_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
+			     enum machine_mode mode)
+{
+  if (mode == BLKmode)
+    return NULL_RTX;
+
+  if (GET_CODE (x) == PLUS
+      && REG_P (XEXP (x, 0))
+      && ! REGNO_PTR_FRAME_P (REGNO (XEXP (x, 0))) 
+      && CONST_INT_P (XEXP (x, 1))
+      && ! ubicom32_is_valid_offset (mode, INTVAL (XEXP (x, 1))))
+    {
+      rtx base;
+      rtx plus;
+      rtx new_rtx;
+      HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
+      HOST_WIDE_INT low = val & ubicom32_get_valid_offset_mask (mode);
+      HOST_WIDE_INT high = val ^ low;
+
+      if (val < 0)
+	return NULL_RTX;
+
+      if (! low)
+	return NULL_RTX;
+
+      /* Reload the high part into a base reg; leave the low part
+	 in the mem directly.  */
+      base = XEXP (x, 0);
+      if (! ubicom32_is_base_reg (base, 0))
+	base = copy_to_mode_reg (Pmode, base);
+
+      plus = expand_simple_binop (Pmode, PLUS,
+				  gen_int_mode (high, Pmode),
+				  base, NULL, 0, OPTAB_WIDEN);
+      new_rtx = plus_constant (plus, low);
+
+      return new_rtx;
+    }
+
+  return NULL_RTX;
+}
+
+/* Try a machine-dependent way of reloading an illegitimate address AD
+   operand.  If we find one, push the reload and and return the new address.
+
+   MODE is the mode of the enclosing MEM.  OPNUM is the operand number
+   and TYPE is the reload type of the current reload.  */
+
+rtx 
+ubicom32_legitimize_reload_address (rtx ad, enum machine_mode mode,
+				    int opnum, int type)
+{
+  /* Is this an address that we've already fixed up?  If it is then
+     recognize it and move on.  */
+  if (GET_CODE (ad) == PLUS
+      && GET_CODE (XEXP (ad, 0)) == PLUS
+      && REG_P (XEXP (XEXP (ad, 0), 0))
+      && CONST_INT_P (XEXP (XEXP (ad, 0), 1))
+      && CONST_INT_P (XEXP (ad, 1)))
+    {
+      push_reload (XEXP (ad, 0), NULL_RTX, &XEXP (ad, 0), NULL,
+		   BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
+		   opnum, (enum reload_type) type);
+      return ad;
+    }
+
+  /* Have we got an address where the offset is simply out of range?  If
+     yes then reload the range as a high part and smaller offset.  */
+  if (GET_CODE (ad) == PLUS
+      && REG_P (XEXP (ad, 0))
+      && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER
+      && REGNO_OK_FOR_BASE_P (REGNO (XEXP (ad, 0)))
+      && CONST_INT_P (XEXP (ad, 1))
+      && ! ubicom32_is_valid_offset (mode, INTVAL (XEXP (ad, 1))))
+    {
+      rtx temp;
+      rtx new_rtx;
+
+      HOST_WIDE_INT val = INTVAL (XEXP (ad, 1));
+      HOST_WIDE_INT low = val & ubicom32_get_valid_offset_mask (mode);
+      HOST_WIDE_INT high = val ^ low;
+
+      /* Reload the high part into a base reg; leave the low part
+	 in the mem directly.  */
+      temp = gen_rtx_PLUS (Pmode, XEXP (ad, 0), GEN_INT (high));
+      new_rtx = gen_rtx_PLUS (Pmode, temp, GEN_INT (low));
+
+      push_reload (XEXP (new_rtx, 0), NULL_RTX, &XEXP (new_rtx, 0), NULL,
+		   BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
+		   opnum, (enum reload_type) type);
+      return new_rtx;
+    }
+
+  /* If we're presented with an pre/post inc/dec then we must force this
+     to be done in an address register.  The register allocator should
+     work this out for itself but at times ends up trying to use the wrong
+     class.  If we get the wrong class then reload will end up generating
+     at least 3 instructions whereas this way we can hopefully keep it to
+     just 2.  */
+  if ((GET_CODE (ad) == POST_INC 
+       || GET_CODE (ad) == PRE_INC 
+       || GET_CODE (ad) == POST_DEC 
+       || GET_CODE (ad) == PRE_DEC)
+      && REG_P (XEXP (ad, 0))
+      && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER
+      && ! REGNO_OK_FOR_BASE_P (REGNO (XEXP (ad, 0))))
+    {
+      push_reload (XEXP (ad, 0), XEXP (ad, 0), &XEXP (ad, 0), &XEXP (ad, 0),
+		   BASE_REG_CLASS, GET_MODE (XEXP (ad, 0)), GET_MODE (XEXP (ad, 0)), 0, 0,
+		   opnum, RELOAD_OTHER);
+      return ad;
+    }
+
+  return NULL_RTX;
+}
+
+/* Compute a (partial) cost for rtx X.  Return true if the complete
+   cost has been computed, and false if subexpressions should be
+   scanned.  In either case, *TOTAL contains the cost result.  */
+
+static bool
+ubicom32_rtx_costs (rtx x, int code, int outer_code, int *total,
+		    bool speed ATTRIBUTE_UNUSED)
+{
+  enum machine_mode mode = GET_MODE (x);
+
+  switch (code)
+    {
+    case CONST_INT:
+      /* Very short constants often fold into instructions so
+         we pretend that they don't cost anything!  This is
+	 really important as regards zero values as otherwise
+	 the compiler has a nasty habit of wanting to reuse
+	 zeroes that are in regs but that tends to pessimize
+	 the code.  */
+      if (satisfies_constraint_I (x))
+	{
+	  *total = 0;
+	  return true;
+	}
+
+      /* Bit clearing costs nothing  */
+      if (outer_code == AND
+	  && exact_log2 (~INTVAL (x)) != -1)
+	{
+	  *total = 0;
+	  return true;
+	}
+
+      /* Masking the lower set of bits costs nothing.  */
+      if (outer_code == AND
+	  && exact_log2 (INTVAL (x) + 1) != -1)
+	{
+	  *total = 0;
+	  return true;
+	}
+
+      /* Bit setting costs nothing.  */
+      if (outer_code == IOR
+	  && exact_log2 (INTVAL (x)) != -1)
+	{
+	  *total = 0;
+	  return true;
+	}
+
+      /* Larger constants that can be loaded via movei aren't too
+         bad.  If we're just doing a set they cost nothing extra.  */
+      if (satisfies_constraint_N (x))
+	{
+	  if (mode == DImode)
+	    *total = COSTS_N_INSNS (2);
+	  else 
+	    *total = COSTS_N_INSNS (1);
+	  return true;
+	}
+
+      if (mode == DImode)
+	*total = COSTS_N_INSNS (5);
+      else
+        *total = COSTS_N_INSNS (3);
+      return true;
+
+    case CONST_DOUBLE:
+      /* We don't optimize CONST_DOUBLEs well nor do we relax them well,
+	 so their cost is very high.  */
+      *total = COSTS_N_INSNS (6);
+      return true;
+
+    case CONST:
+    case SYMBOL_REF:
+    case MEM:
+      *total = 0;
+      return true;
+
+    case IF_THEN_ELSE:
+      *total = COSTS_N_INSNS (1);
+      return true;
+
+    case LABEL_REF:
+    case HIGH:
+    case LO_SUM:
+    case BSWAP:
+    case PLUS:
+    case MINUS:
+    case AND:
+    case IOR:
+    case XOR:
+    case ASHIFT:
+    case ASHIFTRT:
+    case LSHIFTRT:
+    case NEG:
+    case NOT:
+    case SIGN_EXTEND:
+    case ZERO_EXTEND:
+    case ZERO_EXTRACT:
+      if (outer_code == SET)
+	{
+	  if (mode == DImode)
+	    *total = COSTS_N_INSNS (2);
+	  else
+	    *total = COSTS_N_INSNS (1);
+	}
+      return true;
+
+    case COMPARE:
+      if (outer_code == SET)
+	{
+	  if (GET_MODE (XEXP (x, 0)) == DImode
+	      || GET_MODE (XEXP (x, 1)) == DImode)
+	    *total = COSTS_N_INSNS (2);
+	  else
+	    *total = COSTS_N_INSNS (1);
+	}
+      return true;
+
+    case UMOD:
+    case UDIV:
+    case MOD:
+    case DIV:
+      if (outer_code == SET)
+	{
+	  if (mode == DImode)
+	    *total = COSTS_N_INSNS (600);
+	  else
+	    *total = COSTS_N_INSNS (200);
+	}
+      return true;
+
+    case MULT:
+      if (outer_code == SET)
+	{
+	  if (! ubicom32_v4)
+	    {
+	      if (mode == DImode)
+		*total = COSTS_N_INSNS (15);
+	      else
+		*total = COSTS_N_INSNS (5);
+	    }
+	  else
+	    {
+	      if (mode == DImode)
+		*total = COSTS_N_INSNS (6);
+	      else
+		*total = COSTS_N_INSNS (2);
+	    }
+	}
+      return true;
+
+    case UNSPEC:
+      if (XINT (x, 1) == UNSPEC_FDPIC_GOT
+	  || XINT (x, 1) == UNSPEC_FDPIC_GOT_FUNCDESC)
+	*total = 0;
+      return true;
+
+    default:
+      return false;
+    }
+}
+
+/* Return 1 if ADDR can have different meanings depending on the machine
+   mode of the memory reference it is used for or if the address is
+   valid for some modes but not others.
+
+   Autoincrement and autodecrement addresses typically have
+   mode-dependent effects because the amount of the increment or
+   decrement is the size of the operand being addressed.  Some machines
+   have other mode-dependent addresses. Many RISC machines have no
+   mode-dependent addresses.
+
+   You may assume that ADDR is a valid address for the machine.  */
+
+int
+ubicom32_mode_dependent_address_p (rtx addr)
+{
+  if (GET_CODE (addr) == POST_INC 
+      || GET_CODE (addr) == PRE_INC 
+      || GET_CODE (addr) == POST_DEC 
+      || GET_CODE (addr) == PRE_DEC 
+      || GET_CODE (addr) == POST_MODIFY 
+      || GET_CODE (addr) == PRE_MODIFY)
+    return 1;
+
+  return 0;
+}
+
+static void
+ubicom32_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
+{
+  fprintf (file, "/* frame/pretend: %ld/%d save_regs: %d out_args: %d  %s */\n",
+	   get_frame_size (), crtl->args.pretend_args_size,
+	   save_regs_size, crtl->outgoing_args_size,
+	   current_function_is_leaf ? "leaf" : "nonleaf");
+}
+
+static void
+ubicom32_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
+			    HOST_WIDE_INT size ATTRIBUTE_UNUSED)
+{
+  ubicom32_reorg_completed = 0;  
+}
+
+static void
+ubicom32_machine_dependent_reorg (void)
+{
+#if 0 /* Commenting out this optimization until it is fixed */
+  if (optimize)
+    {
+      compute_bb_for_insn ();
+
+      /* Do a very simple CSE pass over just the hard registers.  */
+      reload_cse_regs (get_insns ());
+
+      /* Reload_cse_regs can eliminate potentially-trapping MEMs.
+	 Remove any EH edges associated with them.  */
+      if (flag_non_call_exceptions)
+	purge_all_dead_edges ();
+    }
+#endif
+  ubicom32_reorg_completed = 1;
+}
+
+void
+ubicom32_output_cond_jump (rtx insn, rtx cond, rtx target)
+{
+  rtx note;
+  int mostly_false_jump;
+  rtx xoperands[2];
+  rtx cc_reg;
+
+  note = find_reg_note (insn, REG_BR_PROB, 0);
+  mostly_false_jump = !note || (INTVAL (XEXP (note, 0))
+				<= REG_BR_PROB_BASE / 2);
+
+  xoperands[0] = target;
+  xoperands[1] = cond;
+  cc_reg = XEXP (cond, 0);
+
+  if (GET_MODE (cc_reg) == CCWmode
+      || GET_MODE (cc_reg) == CCWZmode
+      || GET_MODE (cc_reg) == CCWZNmode)
+    {
+      if (mostly_false_jump)
+        output_asm_insn ("jmp%b1.w.f\t%0", xoperands);
+      else
+        output_asm_insn ("jmp%b1.w.t\t%0", xoperands);
+      return;
+    }
+
+  if (GET_MODE (cc_reg) == CCSmode
+      || GET_MODE (cc_reg) == CCSZmode
+      || GET_MODE (cc_reg) == CCSZNmode)
+    {
+      if (mostly_false_jump)
+        output_asm_insn ("jmp%b1.s.f\t%0", xoperands);
+      else
+        output_asm_insn ("jmp%b1.s.t\t%0", xoperands);
+      return;
+    }
+
+  abort ();
+}
+
+/* Return non-zero if FUNC is a naked function.  */
+
+static int
+ubicom32_naked_function_p (void)
+{
+  return lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl)) != NULL_TREE;
+}
+
+/* Return an RTX indicating where the return address to the
+   calling function can be found.  */
+rtx
+ubicom32_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
+{
+  if (count != 0)
+    return NULL_RTX;
+
+  return get_hard_reg_initial_val (Pmode, LINK_REGNO);
+}
+
+/*
+ * ubicom32_readonly_data_section: This routtine handles code
+ * at the start of readonly data sections
+ */
+static void
+ubicom32_readonly_data_section (const void *data ATTRIBUTE_UNUSED)
+{
+  static int num = 0;
+  if (in_section == readonly_data_section){
+    fprintf (asm_out_file, "%s", DATA_SECTION_ASM_OP);
+    if (flag_data_sections){
+      fprintf (asm_out_file, ".rodata%d", num);
+      fprintf (asm_out_file, ",\"a\"");
+    }
+    fprintf (asm_out_file, "\n");
+  }
+  num++;
+}
+
+/*
+ * ubicom32_text_section: not in readonly section
+ */
+static void
+ubicom32_text_section(const void *data ATTRIBUTE_UNUSED)
+{
+  fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
+}
+
+/*
+ * ubicom32_data_section: not in readonly section
+ */
+static void
+ubicom32_data_section(const void *data ATTRIBUTE_UNUSED)
+{
+  fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
+}
+
+/*
+ * ubicom32_asm_init_sections: This routine implements special
+ * section handling
+ */
+static void
+ubicom32_asm_init_sections(void)
+{
+  text_section = get_unnamed_section(SECTION_CODE, ubicom32_text_section, NULL);
+
+  data_section = get_unnamed_section(SECTION_WRITE, ubicom32_data_section, NULL);
+
+  readonly_data_section = get_unnamed_section(0, ubicom32_readonly_data_section, NULL);
+}
+
+/*
+ * ubicom32_profiler:  This routine would call
+ * mcount to support prof and gprof if mcount
+ * was supported. Currently, do nothing.
+ */
+void
+ubicom32_profiler(void)
+{
+}
+
+/* Initialise the builtin functions.  Start by initialising
+   descriptions of different types of functions (e.g., void fn(int),
+   int fn(void)), and then use these to define the builtins. */
+static void
+ubicom32_init_builtins (void)
+{
+  tree endlink;
+  tree short_unsigned_endlink;
+  tree unsigned_endlink;
+  tree short_unsigned_ftype_short_unsigned;
+  tree unsigned_ftype_unsigned;
+
+  endlink = void_list_node;
+
+  short_unsigned_endlink
+    = tree_cons (NULL_TREE, short_unsigned_type_node, endlink);
+
+  unsigned_endlink
+    = tree_cons (NULL_TREE, unsigned_type_node, endlink);
+
+  short_unsigned_ftype_short_unsigned
+    = build_function_type (short_unsigned_type_node, short_unsigned_endlink);
+
+  unsigned_ftype_unsigned
+    = build_function_type (unsigned_type_node, unsigned_endlink);
+
+  /* Initialise the byte swap function. */
+  add_builtin_function ("__builtin_ubicom32_swapb_2",
+  			short_unsigned_ftype_short_unsigned,
+			UBICOM32_BUILTIN_UBICOM32_SWAPB_2,
+			BUILT_IN_MD, NULL,
+			NULL_TREE);
+
+  /* Initialise the byte swap function. */
+  add_builtin_function ("__builtin_ubicom32_swapb_4",
+  			unsigned_ftype_unsigned,
+			UBICOM32_BUILTIN_UBICOM32_SWAPB_4,
+			BUILT_IN_MD, NULL,
+			NULL_TREE);
+}
+
+/* Given a builtin function taking 2 operands (i.e., target + source),
+   emit the RTL for the underlying instruction. */
+static rtx
+ubicom32_expand_builtin_2op (enum insn_code icode, tree arglist, rtx target)
+{
+  tree arg0;
+  rtx op0, pat;
+  enum machine_mode tmode, mode0;
+
+  /* Grab the incoming argument and emit its RTL. */
+  arg0 = TREE_VALUE (arglist);
+  op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
+
+  /* Determine the modes of the instruction operands. */
+  tmode = insn_data[icode].operand[0].mode;
+  mode0 = insn_data[icode].operand[1].mode;
+
+  /* Ensure that the incoming argument RTL is in a register of the
+     correct mode. */
+  if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
+    op0 = copy_to_mode_reg (mode0, op0);
+
+  /* If there isn't a suitable target, emit a target register. */
+  if (target == 0
+      || GET_MODE (target) != tmode
+      || !(*insn_data[icode].operand[0].predicate) (target, tmode))
+    target = gen_reg_rtx (tmode);
+
+  /* Emit and return the new instruction. */
+  pat = GEN_FCN (icode) (target, op0);
+  if (!pat)
+    return 0;
+  emit_insn (pat);
+
+  return target;
+}
+
+/* Expand a call to a builtin function. */
+static rtx
+ubicom32_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
+			 enum machine_mode mode ATTRIBUTE_UNUSED,
+			 int ignore ATTRIBUTE_UNUSED)
+{
+  tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
+  tree arglist = CALL_EXPR_ARGS(exp);
+  int fcode = DECL_FUNCTION_CODE (fndecl);
+
+  switch (fcode)
+    {
+    case UBICOM32_BUILTIN_UBICOM32_SWAPB_2:
+      return ubicom32_expand_builtin_2op (CODE_FOR_bswaphi, arglist, target);
+
+    case UBICOM32_BUILTIN_UBICOM32_SWAPB_4:
+      return ubicom32_expand_builtin_2op (CODE_FOR_bswapsi, arglist, target);
+
+    default:
+      gcc_unreachable();
+    }
+
+  /* Should really do something sensible here.  */
+  return NULL_RTX;
+}
+
+/* Fold any constant argument for a swapb.2 instruction.  */
+static tree
+ubicom32_fold_builtin_ubicom32_swapb_2 (tree fndecl, tree arglist)
+{
+  tree arg0;
+
+  arg0 = TREE_VALUE (arglist);
+
+  /* Optimize constant value.  */
+  if (TREE_CODE (arg0) == INTEGER_CST)
+    {
+      HOST_WIDE_INT v;
+      HOST_WIDE_INT res;
+
+      v = TREE_INT_CST_LOW (arg0);
+      res = ((v >> 8) & 0xff)
+	     | ((v & 0xff) << 8);
+
+      return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), res);
+    }
+
+  return NULL_TREE;
+}
+
+/* Fold any constant argument for a swapb.4 instruction.  */
+static tree
+ubicom32_fold_builtin_ubicom32_swapb_4 (tree fndecl, tree arglist)
+{
+  tree arg0;
+
+  arg0 = TREE_VALUE (arglist);
+
+  /* Optimize constant value.  */
+  if (TREE_CODE (arg0) == INTEGER_CST)
+    {
+      unsigned HOST_WIDE_INT v;
+      unsigned HOST_WIDE_INT res;
+
+      v = TREE_INT_CST_LOW (arg0);
+      res = ((v >> 24) & 0xff)
+	     | (((v >> 16) & 0xff) << 8)
+	     | (((v >> 8) & 0xff) << 16)
+	     | ((v & 0xff) << 24);
+
+      return build_int_cst_wide (TREE_TYPE (TREE_TYPE (fndecl)), res, 0);
+    }
+
+  return NULL_TREE;
+}
+
+/* Fold any constant arguments for builtin functions.  */
+static tree
+ubicom32_fold_builtin (tree fndecl, tree arglist, bool ignore ATTRIBUTE_UNUSED)
+{
+  switch (DECL_FUNCTION_CODE (fndecl))
+    {
+    case UBICOM32_BUILTIN_UBICOM32_SWAPB_2:
+      return ubicom32_fold_builtin_ubicom32_swapb_2 (fndecl, arglist);
+
+    case UBICOM32_BUILTIN_UBICOM32_SWAPB_4:
+      return ubicom32_fold_builtin_ubicom32_swapb_4 (fndecl, arglist);
+
+    default:
+      return NULL;
+    }
+}
+
+/* Implementation of TARGET_ASM_INTEGER.  When using FD-PIC, we need to
+   tell the assembler to generate pointers to function descriptors in
+   some cases.  */
+static bool
+ubicom32_assemble_integer (rtx value, unsigned int size, int aligned_p)
+{
+  if (TARGET_FDPIC && size == UNITS_PER_WORD)
+    {
+      if (GET_CODE (value) == SYMBOL_REF
+	  && SYMBOL_REF_FUNCTION_P (value))
+	{
+	  fputs ("\t.picptr\t%funcdesc(", asm_out_file);
+	  output_addr_const (asm_out_file, value);
+	  fputs (")\n", asm_out_file);
+	  return true;
+	}
+
+      if (!aligned_p)
+	{
+	  /* We've set the unaligned SI op to NULL, so we always have to
+	     handle the unaligned case here.  */
+	  assemble_integer_with_op ("\t.4byte\t", value);
+	  return true;
+	}
+    }
+
+  return default_assemble_integer (value, size, aligned_p);
+}
+
+/* If the constant I can be constructed by shifting a source-1 immediate
+   by a constant number of bits then return the bit count.  If not
+   return 0.  */
+
+int
+ubicom32_shiftable_const_int (int i)
+{
+  int shift = 0;
+
+  /* Note that any constant that can be represented as an immediate to
+     a movei instruction is automatically ignored here in the interests
+     of the clarity of the output asm code.  */
+  if (i >= -32768 && i <= 32767)
+    return 0;
+
+  /* Find the number of trailing zeroes.  We could use __builtin_ctz
+     here but it's not obvious if this is supported on all build
+     compilers so we err on the side of caution.  */
+  if ((i & 0xffff) == 0)
+    {
+      shift += 16;
+      i >>= 16;
+    }
+
+  if ((i & 0xff) == 0)
+    {
+      shift += 8;
+      i >>= 8;
+    }
+
+  if ((i & 0xf) == 0)
+    {
+      shift += 4;
+      i >>= 4;
+    }
+
+  if ((i & 0x3) == 0)
+    {
+      shift += 2;
+      i >>= 2;
+    }
+
+  if ((i & 0x1) == 0)
+    {
+      shift += 1;
+      i >>= 1;
+    }
+
+  if (i >= -128 && i <= 127)
+    return shift;
+
+  return 0;
+}
+
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32.h
@@ -0,0 +1,1564 @@
+/* Definitions of target machine for Ubicom32
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+
+
+#define OBJECT_FORMAT_ELF
+
+/* Run-time target specifications. */
+
+/* Target CPU builtins.  */
+#define TARGET_CPU_CPP_BUILTINS()			\
+  do							\
+    {							\
+      builtin_define_std ("__UBICOM32__");		\
+      builtin_define_std ("__ubicom32__");		\
+							\
+      if (TARGET_FDPIC)					\
+	{						\
+	  builtin_define ("__UBICOM32_FDPIC__");	\
+	  builtin_define ("__FDPIC__");			\
+	}						\
+    }							\
+  while (0)
+
+#ifndef TARGET_DEFAULT
+#define TARGET_DEFAULT 0
+#endif
+
+extern int ubicom32_case_values_threshold;
+
+/* Nonzero if this chip supports the Ubicom32 v3 ISA.  */
+extern int ubicom32_v3;
+
+/* Nonzero if this chip supports the Ubicom32 v4 ISA.  */
+extern int ubicom32_v4;
+
+extern int ubicom32_stack_size;
+
+/* Flag for whether we can use calli instead of ret in returns.  */
+extern int ubicom32_can_use_calli_to_ret;
+
+/* This macro is a C statement to print on `stderr' a string describing the
+   particular machine description choice.  Every machine description should
+   define `TARGET_VERSION'. */
+#define TARGET_VERSION fprintf (stderr, " (UBICOM32)");
+
+/* We don't need a frame pointer to debug things.  Doing this means
+   that gcc can turn on -fomit-frame-pointer when '-O' is specified.  */
+#define CAN_DEBUG_WITHOUT_FP
+
+/* We need to handle processor-specific options.  */
+#define OVERRIDE_OPTIONS ubicom32_override_options ()
+
+#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \
+  ubicom32_optimization_options (LEVEL, SIZE)
+
+/* For Ubicom32 the least significant bit has the lowest bit number
+   so we define this to be 0.  */
+#define BITS_BIG_ENDIAN 0
+
+/* For Ubicom32 the most significant byte in a word has the lowest
+   number.  */
+#define BYTES_BIG_ENDIAN 1
+
+/* For Ubicom32, in a multiword object, the most signifant word has the
+   lowest number.  */
+#define WORDS_BIG_ENDIAN 1
+
+/* Ubicom32 has 8 bits per byte.  */
+#define BITS_PER_UNIT 8
+
+/* Ubicom32 has 32 bits per word.  */
+#define BITS_PER_WORD 32
+
+/* Width of a word, in units (bytes).  */
+#define UNITS_PER_WORD 4
+
+/* Width of a pointer, in bits.  */
+#define POINTER_SIZE 32
+
+/* Alias for pointers.  Ubicom32 is a 32-bit architecture so we use
+   SImode.  */
+#define Pmode SImode
+
+/* Normal alignment required for function parameters on the stack, in
+   bits.  */
+#define PARM_BOUNDARY 32
+
+/* We need to maintain the stack on a 32-bit boundary.  */
+#define STACK_BOUNDARY 32
+
+/* Alignment required for a function entry point, in bits.  */
+#define FUNCTION_BOUNDARY 32
+
+/* Alias for the machine mode used for memory references to functions being
+   called, in `call' RTL expressions.  We use byte-oriented addresses
+   here.  */
+#define FUNCTION_MODE QImode
+
+/* Biggest alignment that any data type can require on this machine,
+   in bits.  */
+#define BIGGEST_ALIGNMENT 32
+
+/* this default to BIGGEST_ALIGNMENT unless defined       */
+/* ART: What's the correct value here? Default is (((unsigned int)1<<28)*8)*/
+#undef MAX_OFILE_ALIGNMENT
+#define MAX_OFILE_ALIGNMENT (128 * 8)
+
+/* Alignment in bits to be given to a structure bit field that follows an empty
+   field such as `int : 0;'.  */
+#define EMPTY_FIELD_BOUNDARY 32
+
+/* All structures must be a multiple of 32 bits in size.  */
+#define STRUCTURE_SIZE_BOUNDARY 32
+
+/* A bit-field declared as `int' forces `int' alignment for the struct.  */
+#define PCC_BITFIELD_TYPE_MATTERS 1
+
+/* For Ubicom32 we absolutely require that data be aligned with nominal
+   alignment.  */
+#define STRICT_ALIGNMENT 1
+
+/* Make strcpy of constants fast.  */
+#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
+  (TREE_CODE (EXP) == STRING_CST	\
+   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
+
+/* Define this macro as an expression for the alignment of a structure
+   (given by STRUCT as a tree node) if the alignment computed in the
+   usual way is COMPUTED and the alignment explicitly specified was
+   SPECIFIED. */
+#define DATA_ALIGNMENT(TYPE, ALIGN)					\
+  ((((ALIGN) < BITS_PER_WORD)						\
+    && (TREE_CODE (TYPE) == ARRAY_TYPE					\
+	|| TREE_CODE (TYPE) == UNION_TYPE				\
+	|| TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
+
+#define LOCAL_ALIGNMENT(TYPE,ALIGN) DATA_ALIGNMENT(TYPE,ALIGN)
+
+/* For Ubicom32 we default to unsigned chars.  */
+#define DEFAULT_SIGNED_CHAR 0
+
+/* Machine-specific data register numbers.  */
+#define FIRST_DATA_REGNUM 0
+#define D10_REGNUM 10
+#define D11_REGNUM 11
+#define D12_REGNUM 12
+#define D13_REGNUM 13
+#define LAST_DATA_REGNUM 15
+
+/* Machine-specific address register numbers.  */
+#define FIRST_ADDRESS_REGNUM 16
+#define LAST_ADDRESS_REGNUM 22
+
+/* Register numbers used for passing a function's static chain pointer.  If
+   register windows are used, the register number as seen by the called
+   function is `STATIC_CHAIN_INCOMING_REGNUM', while the register number as
+   seen by the calling function is `STATIC_CHAIN_REGNUM'.  If these registers
+   are the same, `STATIC_CHAIN_INCOMING_REGNUM' need not be defined.
+
+   The static chain register need not be a fixed register.
+
+   If the static chain is passed in memory, these macros should not be defined;
+   instead, the next two macros should be defined.  */
+#define STATIC_CHAIN_REGNUM (FIRST_ADDRESS_REGNUM + 1)
+
+/* The register number of the frame pointer register, which is used to access
+   automatic variables in the stack frame.  We generally eliminate this anyway
+   for Ubicom32 but we make it A6 by default.  */
+#define FRAME_POINTER_REGNUM (LAST_ADDRESS_REGNUM)
+
+/* The register number of the stack pointer register, which is also be a
+   fixed register according to `FIXED_REGISTERS'.  For Ubicom32 we don't
+   have a hardware requirement about which register this is, but by convention
+   we use A7.  */
+#define STACK_POINTER_REGNUM (LAST_ADDRESS_REGNUM + 1)
+
+/* Machine-specific accumulator register numbers.  */
+#define ACC0_HI_REGNUM 24
+#define ACC0_LO_REGNUM 25
+#define ACC1_HI_REGNUM 26
+#define ACC1_LO_REGNUM 27
+
+/* source3 register number */
+#define SOURCE3_REGNUM 28
+
+/* The register number of the arg pointer register, which is used to access the
+   function's argument list.  On some machines, this is the same as the frame
+   pointer register.  On some machines, the hardware determines which register
+   this is.  On other machines, you can choose any register you wish for this
+   purpose.  If this is not the same register as the frame pointer register,
+   then you must mark it as a fixed register according to `FIXED_REGISTERS', or
+   arrange to be able to eliminate it.  */
+#define ARG_POINTER_REGNUM 29
+
+/* Pseudo-reg for condition code.  */
+#define CC_REGNUM 30
+
+/* Interrupt set/clear registers.  */
+#define INT_SET0_REGNUM 31
+#define INT_SET1_REGNUM 32
+#define INT_CLR0_REGNUM 33
+#define INT_CLR1_REGNUM 34
+
+/* Scratchpad registers.  */
+#define SCRATCHPAD0_REGNUM 35
+#define SCRATCHPAD1_REGNUM 36
+#define SCRATCHPAD2_REGNUM 37
+#define SCRATCHPAD3_REGNUM 38
+
+/* FDPIC register.  */
+#define FDPIC_REGNUM 16
+
+/* Number of hardware registers known to the compiler.  They receive numbers 0
+   through `FIRST_PSEUDO_REGISTER-1'; thus, the first pseudo register's number
+   really is assigned the number `FIRST_PSEUDO_REGISTER'.  */
+#define FIRST_PSEUDO_REGISTER 39
+
+/* An initializer that says which registers are used for fixed purposes all
+   throughout the compiled code and are therefore not available for general
+   allocation.  These would include the stack pointer, the frame pointer
+   (except on machines where that can be used as a general register when no
+   frame pointer is needed), the program counter on machines where that is
+   considered one of the addressable registers, and any other numbered register
+   with a standard use.
+
+   This information is expressed as a sequence of numbers, separated by commas
+   and surrounded by braces.  The Nth number is 1 if register N is fixed, 0
+   otherwise.
+
+   The table initialized from this macro, and the table initialized by the
+   following one, may be overridden at run time either automatically, by the
+   actions of the macro `CONDITIONAL_REGISTER_USAGE', or by the user with the
+   command options `-ffixed-REG', `-fcall-used-REG' and `-fcall-saved-REG'.  */
+#define FIXED_REGISTERS					\
+  {							\
+    0, 0, 0, 0, 0, 0, 0, 0,	/* d0 - d7 */		\
+    0, 0, 0, 0, 0, 0, 0, 1,	/* d8 - d15 */		\
+    0, 0, 0, 0, 0, 0, 0, 1,	/* a0 - a7 */		\
+    0, 0,			/* acc0 hi/lo */	\
+    0, 0,			/* acc1 hi/lo */	\
+    0,				/* source3 */		\
+    1,				/* arg */		\
+    1,				/* cc */		\
+    1, 1,			/* int_set[01] */	\
+    1, 1,			/* int_clr[01] */	\
+    1, 1, 1, 1			/* scratchpad[0123] */	\
+  }
+
+/* Like `FIXED_REGISTERS' but has 1 for each register that is clobbered (in
+   general) by function calls as well as for fixed registers.  This macro
+   therefore identifies the registers that are not available for general
+   allocation of values that must live across function calls.
+
+   If a register has 0 in `CALL_USED_REGISTERS', the compiler automatically
+   saves it on function entry and restores it on function exit, if the register
+   is used within the function.  */
+#define CALL_USED_REGISTERS				\
+  {							\
+    1, 1, 1, 1, 1, 1, 1, 1,	/* d0 - d7 */		\
+    1, 1, 0, 0, 0, 0, 1, 1,	/* d8 - d15 */		\
+    1, 0, 0, 1, 1, 1, 0, 1,	/* a0 - a7 */		\
+    1, 1,			/* acc0 hi/lo */	\
+    1, 1,			/* acc1 hi/lo */	\
+    1,				/* source3 */		\
+    1,				/* arg */		\
+    1,				/* cc */		\
+    1, 1,			/* int_set[01] */	\
+    1, 1,			/* int_clr[01] */	\
+    1, 1, 1, 1			/* scratchpad[0123] */	\
+  }
+
+/* How to refer to registers in assembler output.
+   This sequence is indexed by compiler's hard-register-number (see above).  */
+
+/* A C initializer containing the assembler's names for the machine registers,
+   each one as a C string constant.  This is what translates register numbers
+   in the compiler into assembler language.  */
+#define REGISTER_NAMES						\
+  {								\
+    "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",		\
+    "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15",	\
+    "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",		\
+    "acc0_hi", "acc0_lo",					\
+    "acc1_hi", "acc1_lo",					\
+    "source3",							\
+    "arg",							\
+    "cc",							\
+    "int_set0", "int_set1",					\
+    "int_clr0", "int_clr1",					\
+    "scratchpad0", "scratchpad1", "scratchpad2", "scratchpad3"	\
+  }
+
+#define CONDITIONAL_REGISTER_USAGE				\
+  ubicom32_conditional_register_usage ();
+
+/* Order of allocation of registers.  */
+
+/* If defined, an initializer for a vector of integers, containing the numbers
+   of hard registers in the order in which GNU CC should prefer to use them
+   (from most preferred to least).
+
+   For Ubicom32 we try using caller-clobbered data registers first, then
+   callee-saved data registers, then caller-clobbered address registers,
+   then callee-saved address registers and finally everything else.
+
+   The caller-clobbered registers are usually slightly cheaper to use because
+   there's no need to save/restore.  */
+#define REG_ALLOC_ORDER						\
+  {								\
+    0, 1, 2, 3, 4,		/* d0 - d4 */			\
+    5, 6, 7, 8, 9,		/* d5 - d9 */			\
+    14,				/* d14 */			\
+    10, 11, 12, 13,		/* d10 - d13 */			\
+    19, 20, 16, 21,		/* a3, a4, a0, a5 */		\
+    17, 18, 22,			/* a1, a2, a6 */		\
+    24, 25,			/* acc0 hi/lo */		\
+    26, 27,			/* acc0 hi/lo */		\
+    28				/* source3 */			\
+  }
+
+/* C expression for the number of consecutive hard registers, starting at
+   register number REGNO, required to hold a value of mode MODE.  */
+#define HARD_REGNO_NREGS(REGNO, MODE) \
+  ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
+
+/* Most registers can hold QImode, HImode and SImode values but we have to
+   be able to indicate any hard registers that cannot hold values with some
+   modes.  */
+#define HARD_REGNO_MODE_OK(REGNO, MODE) \
+  ubicom32_hard_regno_mode_ok(REGNO, MODE)
+
+/* We can rename most registers aside from the FDPIC register if we're using
+   FDPIC.  */
+#define HARD_REGNO_RENAME_OK(from, to) (TARGET_FDPIC ? ((to) != FDPIC_REGNUM) : 1)
+
+/* A C expression that is nonzero if it is desirable to choose register
+   allocation so as to avoid move instructions between a value of mode MODE1
+   and a value of mode MODE2.
+
+   If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R, MODE2)' are
+   ever different for any R, then `MODES_TIEABLE_P (MODE1, MODE2)' must be
+   zero.  */
+#define MODES_TIEABLE_P(MODE1, MODE2) 1
+
+/* An enumeral type that must be defined with all the register class names as
+   enumeral values.  `NO_REGS' must be first.  `ALL_REGS' must be the last
+   register class, followed by one more enumeral value, `LIM_REG_CLASSES',
+   which is not a register class but rather tells how many classes there are.
+
+   Each register class has a number, which is the value of casting the class
+   name to type `int'.  The number serves as an index in many of the tables
+   described below.  */
+
+enum reg_class
+{
+  NO_REGS,
+  DATA_REGS,
+  FDPIC_REG,
+  ADDRESS_REGS,
+  ALL_ADDRESS_REGS,
+  ACC_LO_REGS,
+  ACC_REGS,
+  CC_REG,
+  DATA_ACC_REGS,
+  SOURCE3_REG,
+  SPECIAL_REGS,
+  GENERAL_REGS,
+  ALL_REGS,
+  LIM_REG_CLASSES
+};
+
+/* The number of distinct register classes.  */
+#define N_REG_CLASSES (int) LIM_REG_CLASSES
+
+/* An initializer containing the names of the register classes as C string
+   constants.  These names are used in writing some of the debugging dumps.  */
+
+#define REG_CLASS_NAMES		\
+{				\
+  "NO_REGS",			\
+  "DATA_REGS",			\
+  "FDPIC_REG",			\
+  "ADDRESS_REGS",		\
+  "ALL_ADDRESS_REGS",		\
+  "ACC_LO_REGS",		\
+  "ACC_REGS",			\
+  "CC_REG",			\
+  "DATA_ACC_REGS",		\
+  "SOURCE3_REG",		\
+  "SPECIAL_REGS",		\
+  "GENERAL_REGS",		\
+  "ALL_REGS",			\
+  "LIM_REGS"			\
+}
+
+/* An initializer containing the contents of the register classes, as integers
+   which are bit masks.  The Nth integer specifies the contents of class N.
+   The way the integer MASK is interpreted is that register R is in the class
+   if `MASK & (1 << R)' is 1.
+
+   When the machine has more than 32 registers, an integer does not suffice.
+   Then the integers are replaced by sub-initializers, braced groupings
+   containing several integers.  Each sub-initializer must be suitable as an
+   initializer for the type `HARD_REG_SET' which is defined in
+   `hard-reg-set.h'.  */
+#define REG_CLASS_CONTENTS					\
+{								\
+  {0x00000000, 0x00000000},	/* No regs */			\
+  {0x0000ffff, 0x00000000},	/* DATA_REGS */			\
+  {0x00010000, 0x00000000},	/* FDPIC_REG */			\
+  {0x20fe0000, 0x00000000},	/* ADDRESS_REGS */		\
+  {0x20ff0000, 0x00000000},	/* ALL_ADDRESS_REGS */		\
+  {0x0a000000, 0x00000000},	/* ACC_LO_REGS */		\
+  {0x0f000000, 0x00000000},	/* ACC_REGS */			\
+  {0x40000000, 0x00000000},	/* CC_REG */			\
+  {0x0f00ffff, 0x00000000},	/* DATA_ACC_REGS */		\
+  {0x10000000, 0x00000000},	/* SOURGE3_REG */		\
+  {0x80000000, 0x0000007f},	/* SPECIAL_REGS */		\
+  {0xbfffffff, 0x0000007f},	/* GENERAL_REGS */		\
+  {0xbfffffff, 0x0000007f}	/* ALL_REGS	*/		\
+}
+
+extern enum reg_class const ubicom32_regclass_map[FIRST_PSEUDO_REGISTER];
+
+/* A C expression whose value is a register class containing hard register
+   REGNO.  In general there is more than one such class; choose a class which
+   is "minimal", meaning that no smaller class also contains the register.  */
+#define REGNO_REG_CLASS(REGNO) (ubicom32_regclass_map[REGNO])
+
+#define IRA_COVER_CLASSES		\
+{					\
+  GENERAL_REGS,				\
+  LIM_REG_CLASSES			\
+}
+
+/* Ubicom32 base registers must be address registers since addresses can
+   only be reached via address registers.  */
+#define BASE_REG_CLASS ALL_ADDRESS_REGS
+
+/* Ubicom32 index registers must be data registers since we cannot add
+   two address registers together to form an address.  */
+#define INDEX_REG_CLASS DATA_REGS
+
+/* A C expression which is nonzero if register number NUM is suitable for use
+   as a base register in operand addresses.  It may be either a suitable hard
+   register or a pseudo register that has been allocated such a hard register.  */
+
+#ifndef REG_OK_STRICT
+#define REGNO_OK_FOR_BASE_P(regno) \
+  ubicom32_regno_ok_for_base_p (regno, 0)
+#else
+#define REGNO_OK_FOR_BASE_P(regno) \
+  ubicom32_regno_ok_for_base_p (regno, 1)
+#endif
+
+/* A C expression which is nonzero if register number NUM is suitable for use
+   as an index register in operand addresses.  It may be either a suitable hard
+   register or a pseudo register that has been allocated such a hard register.
+
+   The difference between an index register and a base register is that the
+   index register may be scaled.  If an address involves the sum of two
+   registers, neither one of them scaled, then either one may be labeled the
+   "base" and the other the "index"; but whichever labeling is used must fit
+   the machine's constraints of which registers may serve in each capacity.
+   The compiler will try both labelings, looking for one that is valid, and
+   will reload one or both registers only if neither labeling works.  */
+#ifndef REG_OK_STRICT
+#define REGNO_OK_FOR_INDEX_P(regno) \
+  ubicom32_regno_ok_for_index_p (regno, 0)
+#else
+#define REGNO_OK_FOR_INDEX_P(regno) \
+  ubicom32_regno_ok_for_index_p (regno, 1)
+#endif
+
+/* Attempt to restrict the register class we need to copy value X intoto the
+   would-be register class CLASS.  Most things are fine for Ubicom32 but we
+   have to restrict certain types of address loads.  */
+#define PREFERRED_RELOAD_CLASS(X, CLASS) \
+  ubicom32_preferred_reload_class (X, CLASS)
+
+/* A C expression for the maximum number of consecutive registers of
+   class CLASS needed to hold a value of mode MODE.  For Ubicom32 this
+   is pretty much identical to HARD_REGNO_NREGS.  */
+#define CLASS_MAX_NREGS(CLASS, MODE)	\
+  ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
+
+/* For Ubicom32 the stack grows downwards when we push a word onto the stack
+   - i.e. it moves to a smaller address.  */
+#define STACK_GROWS_DOWNWARD 1
+
+/* Offset from the frame pointer to the first local variable slot to
+   be allocated.  */
+#define STARTING_FRAME_OFFSET 0
+
+/* Offset from the argument pointer register to the first argument's
+   address.  */
+#define FIRST_PARM_OFFSET(FNDECL) 0
+
+/* A C expression whose value is RTL representing the value of the return
+   address for the frame COUNT steps up from the current frame, after the
+   prologue.  FRAMEADDR is the frame pointer of the COUNT frame, or the frame
+   pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME' is
+   defined.
+
+   The value of the expression must always be the correct address when COUNT is
+   zero, but may be `NULL_RTX' if there is not way to determine the return
+   address of other frames.  */
+#define RETURN_ADDR_RTX(COUNT, FRAME) \
+  ubicom32_return_addr_rtx (COUNT, FRAME)
+
+/* Register That Address the Stack Frame.  */
+
+/* We don't actually require a frame pointer in most functions with the
+   Ubicom32 architecture so we allow it to be eliminated.  */
+#define FRAME_POINTER_REQUIRED 0
+
+/* Macro that defines a table of register pairs used to eliminate unecessary
+   registers that point into the stack frame.
+
+   For Ubicom32 we don't generally need an arg pointer of a frame pointer
+   so we allow the arg pointer to be replaced by either the frame pointer or
+   the stack pointer.  We also allow the frame pointer to be replaced by
+   the stack pointer.  */
+#define ELIMINABLE_REGS					\
+{							\
+  {ARG_POINTER_REGNUM,	 STACK_POINTER_REGNUM},		\
+  {ARG_POINTER_REGNUM,	 FRAME_POINTER_REGNUM},		\
+  {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}		\
+}
+
+/* Let the compiler know that we want to use the ELIMINABLE_REGS macro
+   above.  */
+#define CAN_ELIMINATE(FROM, TO) 1
+
+/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It specifies the
+   initial difference between the specified pair of registers.  This macro must
+   be defined if `ELIMINABLE_REGS' is defined.  */
+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
+  (OFFSET) = ubicom32_initial_elimination_offset (FROM, TO)
+
+/* If defined, the maximum amount of space required for outgoing arguments will
+   be computed and placed into the variable
+   `current_function_outgoing_args_size'.  No space will be pushed onto the
+   stack for each call; instead, the function prologue should increase the
+   stack frame size by this amount.
+
+   Defining both `PUSH_ROUNDING' and `ACCUMULATE_OUTGOING_ARGS' is not
+   proper.  */
+#define ACCUMULATE_OUTGOING_ARGS 1
+
+/* Define this macro if functions should assume that stack space has been
+   allocated for arguments even when their values are passed in registers.
+
+   The value of this macro is the size, in bytes, of the area reserved for
+   arguments passed in registers for the function represented by FNDECL.
+
+   This space can be allocated by the caller, or be a part of the
+   machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
+   which.  */
+#define REG_PARM_STACK_SPACE(FNDECL) ubicom32_reg_parm_stack_space(FNDECL)
+
+/* A C expression that should indicate the number of bytes of its own arguments
+   that a function pops on returning, or 0 if the function pops no arguments
+   and the caller must therefore pop them all after the function returns.
+
+   FUNDECL is a C variable whose value is a tree node that describes the
+   function in question.  Normally it is a node of type `FUNCTION_DECL' that
+   describes the declaration of the function.  From this it is possible to
+   obtain the DECL_MACHINE_ATTRIBUTES of the function.
+
+   FUNTYPE is a C variable whose value is a tree node that describes the
+   function in question.  Normally it is a node of type `FUNCTION_TYPE' that
+   describes the data type of the function.  From this it is possible to obtain
+   the data types of the value and arguments (if known).
+
+   When a call to a library function is being considered, FUNTYPE will contain
+   an identifier node for the library function.  Thus, if you need to
+   distinguish among various library functions, you can do so by their names.
+   Note that "library function" in this context means a function used to
+   perform arithmetic, whose name is known specially in the compiler and was
+   not mentioned in the C code being compiled.
+
+   STACK-SIZE is the number of bytes of arguments passed on the stack.  If a
+   variable number of bytes is passed, it is zero, and argument popping will
+   always be the responsibility of the calling function.
+
+   On the Vax, all functions always pop their arguments, so the definition of
+   this macro is STACK-SIZE.  On the 68000, using the standard calling
+   convention, no functions pop their arguments, so the value of the macro is
+   always 0 in this case.  But an alternative calling convention is available
+   in which functions that take a fixed number of arguments pop them but other
+   functions (such as `printf') pop nothing (the caller pops all).  When this
+   convention is in use, FUNTYPE is examined to determine whether a function
+   takes a fixed number of arguments.  */
+#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
+
+/* A C expression that controls whether a function argument is passed in a
+   register, and which register.
+
+   The arguments are CUM, of type CUMULATIVE_ARGS, which summarizes (in a way
+   defined by INIT_CUMULATIVE_ARGS and FUNCTION_ARG_ADVANCE) all of the previous
+   arguments so far passed in registers; MODE, the machine mode of the argument;
+   TYPE, the data type of the argument as a tree node or 0 if that is not known
+   (which happens for C support library functions); and NAMED, which is 1 for an
+   ordinary argument and 0 for nameless arguments that correspond to `...' in the
+   called function's prototype.
+
+   The value of the expression should either be a `reg' RTX for the hard
+   register in which to pass the argument, or zero to pass the argument on the
+   stack.
+
+   For machines like the Vax and 68000, where normally all arguments are
+   pushed, zero suffices as a definition.
+
+   The usual way to make the ANSI library `stdarg.h' work on a machine where
+   some arguments are usually passed in registers, is to cause nameless
+   arguments to be passed on the stack instead.  This is done by making
+   `FUNCTION_ARG' return 0 whenever NAMED is 0.
+
+   You may use the macro `MUST_PASS_IN_STACK (MODE, TYPE)' in the definition of
+   this macro to determine if this argument is of a type that must be passed in
+   the stack.  If `REG_PARM_STACK_SPACE' is not defined and `FUNCTION_ARG'
+   returns non-zero for such an argument, the compiler will abort.  If
+   `REG_PARM_STACK_SPACE' is defined, the argument will be computed in the
+   stack and then loaded into a register.  */
+#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
+  function_arg (&CUM, MODE, TYPE, NAMED)
+
+#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
+  function_incoming_arg (&CUM, MODE, TYPE, NAMED)
+
+/* A C expression for the number of words, at the beginning of an argument,
+   must be put in registers.  The value must be zero for arguments that are
+   passed entirely in registers or that are entirely pushed on the stack.
+
+   On some machines, certain arguments must be passed partially in registers
+   and partially in memory.  On these machines, typically the first N words of
+   arguments are passed in registers, and the rest on the stack.  If a
+   multi-word argument (a `double' or a structure) crosses that boundary, its
+   first few words must be passed in registers and the rest must be pushed.
+   This macro tells the compiler when this occurs, and how many of the words
+   should go in registers.
+
+   `FUNCTION_ARG' for these arguments should return the first register to be
+   used by the caller for this argument; likewise `FUNCTION_INCOMING_ARG', for
+   the called function.  */
+
+/* A C expression that indicates when an argument must be passed by reference.
+   If nonzero for an argument, a copy of that argument is made in memory and a
+   pointer to the argument is passed instead of the argument itself.  The
+   pointer is passed in whatever way is appropriate for passing a pointer to
+   that type.
+
+   On machines where `REG_PARM_STACK_SPACE' is not defined, a suitable
+   definition of this macro might be
+	#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED)  \
+	  MUST_PASS_IN_STACK (MODE, TYPE)  */
+
+/* If defined, a C expression that indicates when it is the called function's
+   responsibility to make a copy of arguments passed by invisible reference.
+   Normally, the caller makes a copy and passes the address of the copy to the
+   routine being called.  When FUNCTION_ARG_CALLEE_COPIES is defined and is
+   nonzero, the caller does not make a copy.  Instead, it passes a pointer to
+   the "live" value.  The called function must not modify this value.  If it
+   can be determined that the value won't be modified, it need not make a copy;
+   otherwise a copy must be made.  */
+
+/* A C type for declaring a variable that is used as the first argument of
+   `FUNCTION_ARG' and other related values.  For some target machines, the type
+   `int' suffices and can hold the number of bytes of argument so far.
+
+   There is no need to record in `CUMULATIVE_ARGS' anything about the arguments
+   that have been passed on the stack.  The compiler has other variables to
+   keep track of that.  For target machines on which all arguments are passed
+   on the stack, there is no need to store anything in `CUMULATIVE_ARGS';
+   however, the data structure must exist and should not be empty, so use
+   `int'.  */
+struct cum_arg
+{
+  int nbytes;
+  int reg;
+  int stdarg;
+};
+#define CUMULATIVE_ARGS struct cum_arg
+
+/* A C statement (sans semicolon) for initializing the variable CUM for the
+   state at the beginning of the argument list.  The variable has type
+   `CUMULATIVE_ARGS'.  The value of FNTYPE is the tree node for the data type
+   of the function which will receive the args, or 0 if the args are to a
+   compiler support library function.  The value of INDIRECT is nonzero when
+   processing an indirect call, for example a call through a function pointer.
+   The value of INDIRECT is zero for a call to an explicitly named function, a
+   library function call, or when `INIT_CUMULATIVE_ARGS' is used to find
+   arguments for the function being compiled.
+
+   When processing a call to a compiler support library function, LIBNAME
+   identifies which one.  It is a `symbol_ref' rtx which contains the name of
+   the function, as a string.  LIBNAME is 0 when an ordinary C function call is
+   being processed.  Thus, each time this macro is called, either LIBNAME or
+   FNTYPE is nonzero, but never both of them at once.  */
+
+#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT, NAMED_ARGS)	\
+ init_cumulative_args (&(CUM), FNTYPE, LIBNAME, INDIRECT);
+
+/* A C statement (sans semicolon) to update the summarizer variable CUM to
+   advance past an argument in the argument list.  The values MODE, TYPE and
+   NAMED describe that argument.  Once this is done, the variable CUM is
+   suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
+
+   This macro need not do anything if the argument in question was passed on
+   the stack.  The compiler knows how to track the amount of stack space used
+   for arguments without any special help.  */
+#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)	\
+ ((CUM).nbytes += ((MODE) != BLKmode			\
+		   ? (GET_MODE_SIZE (MODE) + 3) & ~3	\
+		   : (int_size_in_bytes (TYPE) + 3) & ~3))
+
+/* For the Ubicom32 we define the upper function argument register here.  */
+#define UBICOM32_FUNCTION_ARG_REGS 10
+
+/* A C expression that is nonzero if REGNO is the number of a hard register in
+   which function arguments are sometimes passed.  This does *not* include
+   implicit arguments such as the static chain and the structure-value address.
+   On many machines, no registers can be used for this purpose since all
+   function arguments are pushed on the stack.  */
+#define FUNCTION_ARG_REGNO_P(N) ((N) < UBICOM32_FUNCTION_ARG_REGS)
+
+
+/* How Scalar Function Values are Returned.  */
+
+/* The number of the hard register that is used to return a scalar value from a
+   function call.  */
+#define RETURN_VALUE_REGNUM 0
+
+/* A C expression to create an RTX representing the place where a function
+   returns a value of data type VALTYPE.  VALTYPE is a tree node representing a
+   data type.  Write `TYPE_MODE (VALTYPE)' to get the machine mode used to
+   represent that type.  On many machines, only the mode is relevant.
+   (Actually, on most machines, scalar values are returned in the same place
+   regardless of mode).
+
+   If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same promotion
+   rules specified in `PROMOTE_MODE' if VALTYPE is a scalar type.
+
+   If the precise function being called is known, FUNC is a tree node
+   (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This makes it
+   possible to use a different value-returning convention for specific
+   functions when all their calls are known.
+
+   `FUNCTION_VALUE' is not used for return vales with aggregate data types,
+   because these are returned in another way.  See `STRUCT_VALUE_REGNUM' and
+   related macros, below.  */
+#define FUNCTION_VALUE(VALTYPE, FUNC) \
+  gen_rtx_REG (TYPE_MODE (VALTYPE), FIRST_DATA_REGNUM)
+
+/* A C expression to create an RTX representing the place where a library
+   function returns a value of mode MODE.
+
+   Note that "library function" in this context means a compiler support
+   routine, used to perform arithmetic, whose name is known specially by the
+   compiler and was not mentioned in the C code being compiled.
+
+   The definition of `LIBRARY_VALUE' need not be concerned aggregate data
+   types, because none of the library functions returns such types.  */
+#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, FIRST_DATA_REGNUM)
+
+/* A C expression that is nonzero if REGNO is the number of a hard register in
+   which the values of called function may come back.
+
+   A register whose use for returning values is limited to serving as the
+   second of a pair (for a value of type `double', say) need not be recognized
+   by this macro.  So for most machines, this definition suffices:
+
+	#define FUNCTION_VALUE_REGNO_P(N) ((N) == RETURN)
+
+   If the machine has register windows, so that the caller and the called
+   function use different registers for the return value, this macro should
+   recognize only the caller's register numbers.  */
+#define FUNCTION_VALUE_REGNO_P(N) ((N) == FIRST_DATA_REGNUM)
+
+
+/* How Large Values are Returned.  */
+
+/* A C expression which can inhibit the returning of certain function values in
+   registers, based on the type of value.  A nonzero value says to return the
+   function value in memory, just as large structures are always returned.
+   Here TYPE will be a C expression of type `tree', representing the data type
+   of the value.
+
+   Note that values of mode `BLKmode' must be explicitly handled by this macro.
+   Also, the option `-fpcc-struct-return' takes effect regardless of this
+   macro.  On most systems, it is possible to leave the macro undefined; this
+   causes a default definition to be used, whose value is the constant 1 for
+   `BLKmode' values, and 0 otherwise.
+
+   Do not use this macro to indicate that structures and unions should always
+   be returned in memory.  You should instead use `DEFAULT_PCC_STRUCT_RETURN'
+   to indicate this.  */
+#define RETURN_IN_MEMORY(TYPE)  \
+  (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
+
+/* Define this macro to be 1 if all structure and union return values must be
+   in memory.  Since this results in slower code, this should be defined only
+   if needed for compatibility with other compilers or with an ABI.  If you
+   define this macro to be 0, then the conventions used for structure and union
+   return values are decided by the `RETURN_IN_MEMORY' macro.
+
+   If not defined, this defaults to the value 1.  */
+#define DEFAULT_PCC_STRUCT_RETURN 0
+
+/*   If the structure value address is not passed in a register, define
+     `STRUCT_VALUE' as an expression returning an RTX for the place
+     where the address is passed.  If it returns 0, the address is
+     passed as an "invisible" first argument.  */
+#define STRUCT_VALUE 0
+
+/* Define this macro as a C expression that is nonzero if the return
+   instruction or the function epilogue ignores the value of the stack pointer;
+   in other words, if it is safe to delete an instruction to adjust the stack
+   pointer before a return from the function.
+
+   Note that this macro's value is relevant only for functions for which frame
+   pointers are maintained.  It is never safe to delete a final stack
+   adjustment in a function that has no frame pointer, and the compiler knows
+   this regardless of `EXIT_IGNORE_STACK'.  */
+#define EXIT_IGNORE_STACK 1
+
+/* A C statement or compound statement to output to FILE some assembler code to
+   call the profiling subroutine `mcount'.  Before calling, the assembler code
+   must load the address of a counter variable into a register where `mcount'
+   expects to find the address.  The name of this variable is `LP' followed by
+   the number LABELNO, so you would generate the name using `LP%d' in a
+   `fprintf'.
+
+   The details of how the address should be passed to `mcount' are determined
+   by your operating system environment, not by GNU CC.  To figure them out,
+   compile a small program for profiling using the system's installed C
+   compiler and look at the assembler code that results.
+
+   This declaration must be present, but it can be an abort if profiling is
+   not implemented.  */
+
+#define FUNCTION_PROFILER(file, labelno) ubicom32_profiler(file, labelno)
+
+/* A C statement to output, on the stream FILE, assembler code for a block of
+   data that contains the constant parts of a trampoline.  This code should not
+   include a label--the label is taken care of automatically.  */
+#if 0
+#define TRAMPOLINE_TEMPLATE(FILE)			\
+  do {							\
+    fprintf (FILE, "\tadd -4,sp\n");			\
+    fprintf (FILE, "\t.long 0x0004fffa\n");		\
+    fprintf (FILE, "\tmov (0,sp),a0\n");		\
+    fprintf (FILE, "\tadd 4,sp\n");			\
+    fprintf (FILE, "\tmov (13,a0),a1\n");		\
+    fprintf (FILE, "\tmov (17,a0),a0\n");		\
+    fprintf (FILE, "\tjmp (a0)\n");			\
+    fprintf (FILE, "\t.long 0\n");			\
+    fprintf (FILE, "\t.long 0\n");			\
+  } while (0)
+#endif
+
+/* A C expression for the size in bytes of the trampoline, as an integer.  */
+#define TRAMPOLINE_SIZE 0x1b
+
+/* Alignment required for trampolines, in bits.
+
+   If you don't define this macro, the value of `BIGGEST_ALIGNMENT' is used for
+   aligning trampolines.  */
+#define TRAMPOLINE_ALIGNMENT 32
+
+/* A C statement to initialize the variable parts of a trampoline.  ADDR is an
+   RTX for the address of the trampoline; FNADDR is an RTX for the address of
+   the nested function; STATIC_CHAIN is an RTX for the static chain value that
+   should be passed to the function when it is called.  */
+#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
+{									\
+  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 0x14)),	\
+		 (CXT));						\
+  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 0x18)),	\
+		 (FNADDR));						\
+}
+
+/* Ubicom32 supports pre and post increment/decrement addressing.  */
+#define HAVE_POST_INCREMENT 1
+#define HAVE_PRE_INCREMENT 1
+#define HAVE_POST_DECREMENT 1
+#define HAVE_PRE_DECREMENT 1
+
+/* Ubicom32 supports pre and post address side-effects with constants
+   other than the size of the memory operand.  */
+#define HAVE_PRE_MODIFY_DISP 1
+#define HAVE_POST_MODIFY_DISP 1
+
+/* A C expression that is 1 if the RTX X is a constant which is a valid
+   address.  On most machines, this can be defined as `CONSTANT_P (X)',
+   but a few machines are more restrictive in which constant addresses
+   are supported.
+
+   `CONSTANT_P' accepts integer-values expressions whose values are not
+   explicitly known, such as `symbol_ref', `label_ref', and `high'
+   expressions and `const' arithmetic expressions, in addition to
+   `const_int' and `const_double' expressions.  */
+#define CONSTANT_ADDRESS_P(X)						\
+  (GET_CODE (X) == LABEL_REF						\
+   || (GET_CODE (X) == CONST						\
+       && GET_CODE (XEXP (X, 0)) == PLUS				\
+       && GET_CODE (XEXP (XEXP (X, 0), 0)) == LABEL_REF))
+
+/* Ubicom32 supports a maximum of 2 registers in a valid memory address.
+   One is always an address register while a second, optional, one may be a
+   data register.  */
+#define MAX_REGS_PER_ADDRESS 2
+
+/* A C compound statement with a conditional `goto LABEL;' executed if X (an
+   RTX) is a legitimate memory address on the target machine for a memory
+   operand of mode MODE.
+
+   It usually pays to define several simpler macros to serve as subroutines for
+   this one.  Otherwise it may be too complicated to understand.
+
+   This macro must exist in two variants: a strict variant and a non-strict
+   one.  The strict variant is used in the reload pass.  It must be defined so
+   that any pseudo-register that has not been allocated a hard register is
+   considered a memory reference.  In contexts where some kind of register is
+   required, a pseudo-register with no hard register must be rejected.
+
+   The non-strict variant is used in other passes.  It must be defined to
+   accept all pseudo-registers in every context where some kind of register is
+   required.
+
+   Compiler source files that want to use the strict variant of this macro
+   define the macro `REG_OK_STRICT'.  You should use an `#ifdef REG_OK_STRICT'
+   conditional to define the strict variant in that case and the non-strict
+   variant otherwise.
+
+   Subroutines to check for acceptable registers for various purposes (one for
+   base registers, one for index registers, and so on) are typically among the
+   subroutines used to define `GO_IF_LEGITIMATE_ADDRESS'.  Then only these
+   subroutine macros need have two variants; the higher levels of macros may be
+   the same whether strict or not.
+
+   Normally, constant addresses which are the sum of a `symbol_ref' and an
+   integer are stored inside a `const' RTX to mark them as constant.
+   Therefore, there is no need to recognize such sums specifically as
+   legitimate addresses.  Normally you would simply recognize any `const' as
+   legitimate.
+
+   Usually `PRINT_OPERAND_ADDRESS' is not prepared to handle constant sums that
+   are not marked with `const'.  It assumes that a naked `plus' indicates
+   indexing.  If so, then you *must* reject such naked constant sums as
+   illegitimate addresses, so that none of them will be given to
+   `PRINT_OPERAND_ADDRESS'.
+
+   On some machines, whether a symbolic address is legitimate depends on the
+   section that the address refers to.  On these machines, define the macro
+   `ENCODE_SECTION_INFO' to store the information into the `symbol_ref', and
+   then check for it here.  When you see a `const', you will have to look
+   inside it to find the `symbol_ref' in order to determine the section.
+
+   The best way to modify the name string is by adding text to the beginning,
+   with suitable punctuation to prevent any ambiguity.  Allocate the new name
+   in `saveable_obstack'.  You will have to modify `ASM_OUTPUT_LABELREF' to
+   remove and decode the added text and output the name accordingly, and define
+   `STRIP_NAME_ENCODING' to access the original name string.
+
+   You can check the information stored here into the `symbol_ref' in the
+   definitions of the macros `GO_IF_LEGITIMATE_ADDRESS' and
+   `PRINT_OPERAND_ADDRESS'.  */
+/* On the ubicom32, the value in the address register must be
+   in the same memory space/segment as the effective address.
+
+   This is problematical for reload since it does not understand
+   that base+index != index+base in a memory reference.  */
+
+#ifdef REG_OK_STRICT
+#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)	\
+  if (ubicom32_legitimate_address_p (MODE, X, 1)) goto ADDR;
+#else
+#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)	\
+  if (ubicom32_legitimate_address_p (MODE, X, 0)) goto ADDR;
+#endif
+
+/* Try machine-dependent ways of modifying an illegitimate address
+   to be legitimate.  If we find one, return the new, valid address.
+   This macro is used in only one place: `memory_address' in explow.c.
+
+   OLDX is the address as it was before break_out_memory_refs was called.
+   In some cases it is useful to look at this to decide what needs to be done.
+
+   MODE and WIN are passed so that this macro can use
+   GO_IF_LEGITIMATE_ADDRESS.
+
+   It is always safe for this macro to do nothing.  It exists to recognize
+   opportunities to optimize the output.
+
+   On RS/6000, first check for the sum of a register with a constant
+   integer that is out of range.  If so, generate code to add the
+   constant with the low-order 16 bits masked to the register and force
+   this result into another register (this can be done with `cau').
+   Then generate an address of REG+(CONST&0xffff), allowing for the
+   possibility of bit 16 being a one.
+
+   Then check for the sum of a register and something not constant, try to
+   load the other things into a register and return the sum.  */
+
+#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)				\
+{									\
+   rtx result = ubicom32_legitimize_address ((X), (OLDX), (MODE));	\
+   if (result != NULL_RTX)						\
+     {									\
+       (X) = result;							\
+       goto WIN;							\
+     }									\
+}
+
+/* Try a machine-dependent way of reloading an illegitimate address
+   operand.  If we find one, push the reload and jump to WIN.  This
+   macro is used in only one place: `find_reloads_address' in reload.c.  */
+#define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN)	\
+{									\
+  rtx new_rtx = ubicom32_legitimize_reload_address ((AD), (MODE), (OPNUM), (int)(TYPE));	\
+  if (new_rtx)								\
+    {									\
+      (AD) = new_rtx;							\
+      goto WIN;								\
+    }									\
+}
+
+/* A C statement or compound statement with a conditional `goto LABEL;'
+   executed if memory address X (an RTX) can have different meanings depending
+   on the machine mode of the memory reference it is used for or if the address
+   is valid for some modes but not others.
+
+   Autoincrement and autodecrement addresses typically have mode-dependent
+   effects because the amount of the increment or decrement is the size of the
+   operand being addressed.  Some machines have other mode-dependent addresses.
+   Many RISC machines have no mode-dependent addresses.
+
+   You may assume that ADDR is a valid address for the machine.  */
+#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)	\
+  if (ubicom32_mode_dependent_address_p (ADDR))		\
+    goto LABEL;
+
+/* A C expression that is nonzero if X is a legitimate constant for an
+   immediate operand on the target machine.  You can assume that X
+   satisfies `CONSTANT_P', so you need not check this.  In fact, `1' is
+   a suitable definition for this macro on machines where anything
+   `CONSTANT_P' is valid.  */
+#define LEGITIMATE_CONSTANT_P(X) \
+  ubicom32_legitimate_constant_p ((X))
+
+/* Moves between registers are pretty-much single instructions for
+   Ubicom32.  We make this the default "2" that gcc likes.  */
+#define REGISTER_MOVE_COST(MODE, FROM, TO) 2
+
+/* This is a little bit of magic from the S390 port that wins 2% on code
+   size when building the Linux kernel!  Unfortunately while it wins on
+   that size the user-space apps built using FD-PIC don't improve and the
+   performance is lower because we put more pressure on the caches.  We may
+   want this back on some future CPU that has higher cache performance.  */
+/* #define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) 0.5 */
+
+/* Moves between registers and memory are more expensive than between
+   registers because we have caches and write buffers that slow things
+   down!  */
+#define MEMORY_MOVE_COST(MODE, CLASS, IN) 2
+
+/* A fall-through branch is very low cost but anything that changes the PC
+   incurs a major pipeline hazard.  We don't make the full extent of this
+   hazard visible because we hope that multiple threads will absorb much
+   of the cost and so we don't want a jump being replaced with, say, 7
+   instructions.  */
+#define BRANCH_COST(SPEED_P, PREDICTABLE_P) \
+  ((PREDICTABLE_P) ? 1 : 3)
+
+/* Define this macro as a C expression which is nonzero if accessing less than
+   a word of memory (i.e. a `char' or a `short') is no faster than accessing a
+   word of memory, i.e., if such access require more than one instruction or if
+   there is no difference in cost between byte and (aligned) word loads.
+
+   When this macro is not defined, the compiler will access a field by finding
+   the smallest containing object; when it is defined, a fullword load will be
+   used if alignment permits.  Unless bytes accesses are faster than word
+   accesses, using word accesses is preferable since it may eliminate
+   subsequent memory access if subsequent accesses occur to other fields in the
+   same word of the structure, but to different bytes.  */
+#define SLOW_BYTE_ACCESS 0
+
+/* The number of scalar move insns which should be generated instead of a
+   string move insn or a library call.  Increasing the value will always make
+   code faster, but eventually incurs high cost in increased code size.
+
+   If you don't define this, a reasonable default is used.  */
+/* According to expr.c, a value of around 6 should minimize code size.  */
+#define MOVE_RATIO(SPEED) 6
+
+/* We're much better off calling a constant function address with the
+   Ubicom32 architecture because we have an opcode for doing so.  Don't
+   let the compiler extract function addresses as common subexpressions
+   into an address register.  */
+#define NO_FUNCTION_CSE
+
+#define SELECT_CC_MODE(OP, X, Y) ubicom32_select_cc_mode (OP, X, Y)
+
+#define REVERSIBLE_CC_MODE(MODE) 1
+
+/* Canonicalize a comparison from one we don't have to one we do have.  */
+#define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
+  ubicom32_canonicalize_comparison (&(CODE), &(OP0), &(OP1))
+
+/* Dividing the output into sections.  */
+
+/* A C expression whose value is a string containing the assembler operation
+   that should precede instructions and read-only data.  Normally `".text"' is
+   right.  */
+#define TEXT_SECTION_ASM_OP "\t.section .text"
+
+/* A C expression whose value is a string containing the assembler operation to
+   identify the following data as writable initialized data.  Normally
+   `".data"' is right.  */
+#define DATA_SECTION_ASM_OP "\t.section .data"
+
+
+/* If defined, a C expression whose value is a string containing the
+   assembler operation to identify the following data as
+   uninitialized global data.  If not defined, and neither
+   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
+   uninitialized global data will be output in the data section if
+   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
+   used.  */
+#define BSS_SECTION_ASM_OP "\t.section .bss"
+
+/* This is how we tell the assembler that a symbol is weak.  */
+
+#define ASM_WEAKEN_LABEL(FILE, NAME)	\
+  do					\
+    {					\
+      fputs ("\t.weak\t", (FILE));	\
+      assemble_name ((FILE), (NAME));	\
+      fputc ('\n', (FILE));		\
+    }					\
+  while (0)
+
+/* The Overall Framework of an Assembler File.  */
+
+#undef SET_ASM_OP
+#define SET_ASM_OP "\t.set\t"
+
+/* A C string constant describing how to begin a comment in the target
+   assembler language.  The compiler assumes that the comment will end at the
+   end of the line.  */
+#define ASM_COMMENT_START ";"
+
+/* A C string constant for text to be output before each `asm' statement or
+   group of consecutive ones.  Normally this is `"#APP"', which is a comment
+   that has no effect on most assemblers but tells the GNU assembler that it
+   must check the lines that follow for all valid assembler constructs.  */
+#define ASM_APP_ON "#APP\n"
+
+/* A C string constant for text to be output after each `asm' statement or
+   group of consecutive ones.  Normally this is `"#NO_APP"', which tells the
+   GNU assembler to resume making the time-saving assumptions that are valid
+   for ordinary compiler output.  */
+#define ASM_APP_OFF "#NO_APP\n"
+
+/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a separate,
+   explicit argument.  If you define this macro, it is used in place of
+   `ASM_OUTPUT_BSS', and gives you more flexibility in handling the required
+   alignment of the variable.  The alignment is specified as the number of
+   bits.
+
+   Try to use function `asm_output_aligned_bss' defined in file `varasm.c' when
+   defining this macro.  */
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+  asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
+
+/* A C expression to assign to OUTVAR (which is a variable of type `char *') a
+   newly allocated string made from the string NAME and the number NUMBER, with
+   some suitable punctuation added.  Use `alloca' to get space for the string.
+
+   The string will be used as an argument to `ASM_OUTPUT_LABELREF' to produce
+   an assembler label for an internal static variable whose name is NAME.
+   Therefore, the string must be such as to result in valid assembler code.
+   The argument NUMBER is different each time this macro is executed; it
+   prevents conflicts between similarly-named internal static variables in
+   different scopes.
+
+   Ideally this string should not be a valid C identifier, to prevent any
+   conflict with the user's own symbols.  Most assemblers allow periods or
+   percent signs in assembler symbols; putting at least one of these between
+   the name and the number will suffice.  */
+#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)	\
+  ((OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),	\
+   sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
+
+#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM)	\
+  sprintf (STRING, "*.%s%ld", PREFIX, (long)(NUM))
+/* A C statement to store into the string STRING a label whose name
+   is made from the string PREFIX and the number NUM.
+
+   This string, when output subsequently by `assemble_name', should
+   produce the output that `(*targetm.asm_out.internal_label)' would produce
+   with the same PREFIX and NUM.
+
+   If the string begins with `*', then `assemble_name' will output
+   the rest of the string unchanged.  It is often convenient for
+   `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way.  If the
+   string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to
+   output the string, and may change it.  (Of course,
+   `ASM_OUTPUT_LABELREF' is also part of your machine description, so
+   you should know what it does on your machine.)  */
+
+/* This says how to output assembler code to declare an
+   uninitialized external linkage data object.  Under SVR4,
+   the linker seems to want the alignment of data objects
+   to depend on their types.  We do exactly that here.  */
+
+#define COMMON_ASM_OP	"\t.comm\t"
+
+#undef  ASM_OUTPUT_COMMON
+#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)		\
+  do								\
+    {								\
+      fprintf ((FILE), "%s", COMMON_ASM_OP);			\
+      assemble_name ((FILE), (NAME));				\
+      fprintf ((FILE), ", %u\n", (SIZE));			\
+    }								\
+  while (0)
+
+/* This says how to output assembler code to declare an
+   uninitialized internal linkage data object.  Under SVR4,
+   the linker seems to want the alignment of data objects
+   to depend on their types.  We do exactly that here.  */
+#define LOCAL_ASM_OP	"\t.lcomm\t"
+
+#undef  ASM_OUTPUT_LOCAL
+#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)		\
+  do								\
+    {								\
+      fprintf ((FILE), "%s", LOCAL_ASM_OP);			\
+      assemble_name ((FILE), (NAME));				\
+      fprintf ((FILE), ", %u\n", (SIZE));			\
+    }								\
+  while (0)
+
+/* Globalizing directive for a label.  */
+#define GLOBAL_ASM_OP ".global\t"
+
+/* Output the operand of an instruction.  */
+#define PRINT_OPERAND(FILE, X, CODE) \
+  ubicom32_print_operand(FILE, X, CODE)
+
+/* Output the address of an operand.  */
+#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
+  ubicom32_print_operand_address (FILE, ADDR)
+
+/* A C expression to output to STREAM some assembler code which will push hard
+   register number REGNO onto the stack.  The code need not be optimal, since
+   this macro is used only when profiling.  */
+#define ASM_OUTPUT_REG_PUSH(FILE, REGNO)
+
+/* A C expression to output to STREAM some assembler code which will pop hard
+   register number REGNO off of the stack.  The code need not be optimal, since
+   this macro is used only when profiling.  */
+#define ASM_OUTPUT_REG_POP(FILE, REGNO)
+
+/* This macro should be provided on machines where the addresses in a dispatch
+   table are relative to the table's own address.
+
+   The definition should be a C statement to output to the stdio stream STREAM
+   an assembler pseudo-instruction to generate a difference between two labels.
+   VALUE and REL are the numbers of two internal labels.  The definitions of
+   these labels are output using `ASM_OUTPUT_INTERNAL_LABEL', and they must be
+   printed in the same way here.  For example,
+
+	fprintf (STREAM, "\t.word L%d-L%d\n", VALUE, REL)  */
+#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
+  fprintf (FILE, "\t%s .L%d-.L%d\n", ".long", VALUE, REL)
+
+/* This macro should be provided on machines where the addresses in a dispatch
+   table are absolute.
+
+   The definition should be a C statement to output to the stdio stream STREAM
+   an assembler pseudo-instruction to generate a reference to a label.  VALUE
+   is the number of an internal label whose definition is output using
+   `ASM_OUTPUT_INTERNAL_LABEL'.  For example,
+
+	fprintf (STREAM, "\t.word L%d\n", VALUE)  */
+#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
+  fprintf (STREAM, "\t.word .L%d\n", VALUE)
+
+/* Switch into a generic section.  */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
+
+/* Assembler Commands for Alignment.  */
+
+#define ASM_OUTPUT_SKIP(STREAM, N) fprintf (STREAM, "\t.skip %d,0\n", N)
+/* A C statement to output to the stdio stream STREAM an assembler
+   instruction to advance the location counter by NBYTES bytes.
+   Those bytes should be zero when loaded.  NBYTES will be a C
+   expression of type `int'.  */
+
+/* A C statement to output to the stdio stream STREAM an assembler command to
+   advance the location counter to a multiple of 2 to the POWER bytes.  POWER
+   will be a C expression of type `int'.  */
+#define ASM_OUTPUT_ALIGN(FILE, LOG)	\
+  if ((LOG) != 0)			\
+    fprintf (FILE, "\t.align %d\n", (LOG))
+
+/* A C expression that returns the DBX register number for the compiler
+   register number REGNO.  In simple cases, the value of this expression may be
+   REGNO itself.  But sometimes there are some registers that the compiler
+   knows about and DBX does not, or vice versa.  In such cases, some register
+   may need to have one number in the compiler and another for DBX.
+
+   If two registers have consecutive numbers inside GNU CC, and they can be
+   used as a pair to hold a multiword value, then they *must* have consecutive
+   numbers after renumbering with `DBX_REGISTER_NUMBER'.  Otherwise, debuggers
+   will be unable to access such a pair, because they expect register pairs to
+   be consecutive in their own numbering scheme.
+
+   If you find yourself defining `DBX_REGISTER_NUMBER' in way that does not
+   preserve register pairs, then what you must do instead is redefine the
+   actual register numbering scheme.
+
+   This declaration is required.  */
+#define DBX_REGISTER_NUMBER(REGNO) REGNO
+
+/* A C expression that returns the integer offset value for an automatic
+   variable having address X (an RTL expression).  The default computation
+   assumes that X is based on the frame-pointer and gives the offset from the
+   frame-pointer.  This is required for targets that produce debugging output
+   for DBX or COFF-style debugging output for SDB and allow the frame-pointer
+   to be eliminated when the `-g' options is used.  */
+#define DEBUGGER_AUTO_OFFSET(X)						\
+  ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)			\
+    + (frame_pointer_needed						\
+       ? 0 : -initial_elimination_offset (FRAME_POINTER_REGNUM,		\
+					  STACK_POINTER_REGNUM)))
+
+/* A C expression that returns the integer offset value for an argument having
+   address X (an RTL expression).  The nominal offset is OFFSET.  */
+#define DEBUGGER_ARG_OFFSET(OFFSET, X)					\
+  ((GET_CODE (X) == PLUS ? OFFSET : 0)					\
+    + (frame_pointer_needed						\
+       ? 0 : -initial_elimination_offset (ARG_POINTER_REGNUM,		\
+					  STACK_POINTER_REGNUM)))
+
+/* A C expression that returns the type of debugging output GNU CC produces
+   when the user specifies `-g' or `-ggdb'.  Define this if you have arranged
+   for GNU CC to support more than one format of debugging output.  Currently,
+   the allowable values are `DBX_DEBUG', `SDB_DEBUG', `DWARF_DEBUG',
+   `DWARF2_DEBUG', and `XCOFF_DEBUG'.
+
+   The value of this macro only affects the default debugging output; the user
+   can always get a specific type of output by using `-gstabs', `-gcoff',
+   `-gdwarf-1', `-gdwarf-2', or `-gxcoff'.
+
+   Defined in svr4.h.
+*/
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+
+/* Define this macro if GNU CC should produce dwarf version 2 format debugging
+   output in response to the `-g' option.
+
+   To support optional call frame debugging information, you must also define
+   `INCOMING_RETURN_ADDR_RTX' and either set `RTX_FRAME_RELATED_P' on the
+   prologue insns if you use RTL for the prologue, or call `dwarf2out_def_cfa'
+   and `dwarf2out_reg_save' as appropriate from `FUNCTION_PROLOGUE' if you
+   don't.
+
+   Defined in svr4.h.  */
+
+#define DWARF2_DEBUGGING_INFO 1
+/*#define DWARF2_UNWIND_INFO 1*/
+#define DWARF2_UNWIND_INFO 0
+#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNO)
+#define INCOMING_FRAME_SP_OFFSET 0
+#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_REGNO)
+#define EH_RETURN_FIRST 9
+#define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + EH_RETURN_FIRST : INVALID_REGNUM)
+
+/* The EH_RETURN_STACKADJ_RTX macro returns RTL which describes the
+   location used to store the amount to ajdust the stack.  This is
+   usually a registers that is available from end of the function's body
+   to the end of the epilogue. Thus, this cannot be a register used as a
+   temporary by the epilogue.
+
+   This must be an integer register.  */
+#define EH_RETURN_STACKADJ_REGNO	11
+#define EH_RETURN_STACKADJ_RTX		\
+	gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
+
+/* The EH_RETURN_HANDLER_RTX macro returns RTL which describes the
+   location used to store the address the processor should jump to
+   catch exception.  This is usually a registers that is available from
+   end of the function's body to the end of the epilogue. Thus, this
+   cannot be a register used as a temporary by the epilogue.
+
+   This must be an address register.  */
+#define EH_RETURN_HANDLER_REGNO		18
+#define EH_RETURN_HANDLER_RTX		\
+	gen_rtx_REG (Pmode, EH_RETURN_HANDLER_REGNO)
+
+/* #define DWARF2_DEBUGGING_INFO */
+
+/* Define this macro if GNU CC should produce dwarf version 2-style
+   line numbers.  This usually requires extending the assembler to
+   support them, and #defining DWARF2_LINE_MIN_INSN_LENGTH in the
+   assembler configuration header files.  */
+/* #define DWARF2_ASM_LINE_DEBUG_INFO 1 */
+
+
+/* An alias for a machine mode name.  This is the machine mode that elements
+   of a jump-table have.  */
+#define CASE_VECTOR_MODE Pmode
+
+/* Smallest number of different values for which it is best to use a
+   jump-table instead of a tree of conditional branches.  For most Ubicom32
+   targets this is quite small, but for the v1 architecture implementations
+   we had very little data memory and so heavily prefer the tree approach
+   rather than the jump tables.  */
+#define CASE_VALUES_THRESHOLD ubicom32_case_values_threshold
+
+/* Register operations within the Ubicom32 architecture always operate on
+   the whole register word and not just the sub-bits required for the opcode
+   mode size.  */
+#define WORD_REGISTER_OPERATIONS
+
+/* The maximum number of bytes that a single instruction can move quickly from
+   memory to memory.  */
+#define MOVE_MAX 4
+
+/* A C expression that is nonzero if on this machine the number of bits
+   actually used for the count of a shift operation is equal to the number of
+   bits needed to represent the size of the object being shifted.  When this
+   macro is non-zero, the compiler will assume that it is safe to omit a
+   sign-extend, zero-extend, and certain bitwise `and' instructions that
+   truncates the count of a shift operation.  On machines that have
+   instructions that act on bitfields at variable positions, which may include
+   `bit test' instructions, a nonzero `SHIFT_COUNT_TRUNCATED' also enables
+   deletion of truncations of the values that serve as arguments to bitfield
+   instructions.
+
+   If both types of instructions truncate the count (for shifts) and position
+   (for bitfield operations), or if no variable-position bitfield instructions
+   exist, you should define this macro.
+
+   However, on some machines, such as the 80386 and the 680x0, truncation only
+   applies to shift operations and not the (real or pretended) bitfield
+   operations.  Define `SHIFT_COUNT_TRUNCATED' to be zero on such machines.
+   Instead, add patterns to the `md' file that include the implied truncation
+   of the shift instructions.
+
+   You need not define this macro if it would always have the value of zero.  */
+#define SHIFT_COUNT_TRUNCATED 1
+
+/* A C expression which is nonzero if on this machine it is safe to "convert"
+   an integer of INPREC bits to one of OUTPREC bits (where OUTPREC is smaller
+   than INPREC) by merely operating on it as if it had only OUTPREC bits.
+
+   On many machines, this expression can be 1.
+
+   When `TRULY_NOOP_TRUNCATION' returns 1 for a pair of sizes for modes for
+   which `MODES_TIEABLE_P' is 0, suboptimal code can result.  If this is the
+   case, making `TRULY_NOOP_TRUNCATION' return 0 in such cases may improve
+   things.  */
+#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
+
+/* A C string constant that tells the GNU CC driver program options to pass
+   to the assembler.  It can also specify how to translate options you give
+   to GNU CC into options for GNU CC to pass to the assembler.  See the
+   file `sun3.h' for an example of this.
+
+   Defined in svr4.h.  */
+#undef ASM_SPEC
+#define ASM_SPEC \
+  "%{march=*:-m%*} %{!march=*:-mubicom32v4} %{mfdpic:-mfdpic}"
+
+#define LINK_SPEC "\
+%{h*} %{v:-V} \
+%{b} \
+%{mfdpic:-melf32ubicom32fdpic -z text} \
+%{static:-dn -Bstatic} \
+%{shared:-G -Bdynamic} \
+%{symbolic:-Bsymbolic} \
+%{G*} \
+%{YP,*} \
+%{Qy:} %{!Qn:-Qy}"
+
+#undef STARTFILE_SPEC
+#undef ENDFILE_SPEC
+
+/* The svr4.h LIB_SPEC with -leval and --*group tacked on */
+
+#undef  LIB_SPEC
+#define LIB_SPEC "%{!shared:%{!symbolic:--start-group -lc -leval -lgcc --end-group}}"
+
+#undef HAVE_GAS_SHF_MERGE
+#define HAVE_GAS_SHF_MERGE 0
+
+#define HANDLE_SYSV_PRAGMA 1
+#undef HANDLE_PRAGMA_PACK
+
+typedef void (*ubicom32_func_ptr) (void);
+
+/* Define builtins for selected special-purpose instructions. */
+enum ubicom32_builtins
+{
+  UBICOM32_BUILTIN_UBICOM32_SWAPB_2,
+  UBICOM32_BUILTIN_UBICOM32_SWAPB_4
+};
+
+extern rtx ubicom32_compare_op0;
+extern rtx ubicom32_compare_op1;
+
+#define TYPE_ASM_OP	"\t.type\t"
+#define TYPE_OPERAND_FMT	"@%s"
+
+#ifndef ASM_DECLARE_RESULT
+#define ASM_DECLARE_RESULT(FILE, RESULT)
+#endif
+
+/* These macros generate the special .type and .size directives which
+   are used to set the corresponding fields of the linker symbol table
+   entries in an ELF object file under SVR4.  These macros also output
+   the starting labels for the relevant functions/objects.  */
+
+/* Write the extra assembler code needed to declare a function properly.
+   Some svr4 assemblers need to also have something extra said about the
+   function's return value.  We allow for that here.  */
+
+#ifndef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)		\
+  do								\
+    {								\
+      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");	\
+      ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));		\
+      ASM_OUTPUT_LABEL (FILE, NAME);				\
+    }								\
+  while (0)
+#endif
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32.md
@@ -0,0 +1,3753 @@
+; GCC machine description for Ubicom32
+;
+; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+; Foundation, Inc.
+; Contributed by Ubicom, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 3, or (at your option)
+; any later version.
+;
+; GCC is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+(define_constants
+  [(AUX_DATA_REGNO 15)
+   (LINK_REGNO     21)
+   (SP_REGNO       23)
+   (ACC0_HI_REGNO  24)
+   (ACC1_HI_REGNO  26)
+   (CC_REGNO       30)])
+
+(define_constants
+  [(UNSPEC_FDPIC_GOT 0)
+   (UNSPEC_FDPIC_GOT_FUNCDESC 1)])
+
+(define_constants
+  [(UNSPEC_VOLATILE_LOAD_FDPIC_FUNCDESC 0)])
+
+;; Types of instructions (for scheduling purposes).
+
+(define_attr "type" "mul,addr,other"
+  (const_string "other"))
+
+; Define instruction scheduling characteristics.  We can only issue
+; one instruction per clock so we don't need to define CPU units.
+;
+(define_automaton "ubicom32")
+
+(define_cpu_unit "i_pipeline" "ubicom32");
+
+; We have a 4 cycle hazard associated with address calculations which
+; seems rather tricky to avoid so we go with a defensive assumption
+; that almost anything can be used to generate addresses.
+;
+;(define_insn_reservation "ubicom32_other" 4
+;			 (eq_attr "type" "other")
+;			 "i_pipeline")
+
+; Some moves don't generate hazards.
+;
+;(define_insn_reservation "ubicom32_addr" 1
+;			 (eq_attr "type" "addr")
+;			 "i_pipeline")
+
+; We need 3 cycles between a multiply instruction and any use of the
+; matching accumulator register(s).
+;
+(define_insn_reservation "ubicom32_mul" 4
+			 (eq_attr "type" "mul")
+			 "i_pipeline")
+
+(define_attr "length" ""
+  (const_int 4))
+
+(include "predicates.md")
+(include "constraints.md")
+
+; 8-bit move with no change to the flags reg.
+;
+(define_insn "movqi"
+  [(set (match_operand:QI 0 "nonimmediate_operand" "=rm")
+	(match_operand:QI 1 "ubicom32_move_operand"  "g"))]
+  ""
+  "move.1\\t%0, %1")
+
+; Combiner-generated 8-bit move with the zero flag set accordingly.
+;
+(define_insn "movqi_ccszn"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:QI 0 "nonimmediate_operand" "rm")
+		 (const_int 0)))
+   (set (match_operand:QI 1 "nonimmediate_operand"	   "=rm")
+	(match_dup 0))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "ext.1\\t%1, %0")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:QI 0 "nonimmediate_operand" "")
+	(match_operand:QI 1 "nonimmediate_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(match_operator 3 "ubicom32_compare_operator"
+	  [(match_dup 0)
+	   (const_int 0)]))]
+  "(GET_MODE (operands[2]) == CCSZNmode
+    || GET_MODE (operands[2]) == CCSZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:QI 0 "nonimmediate_operand" "")
+	(match_operand:QI 1 "nonimmediate_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(match_operator 3 "ubicom32_compare_operator"
+	  [(match_dup 1)
+	   (const_int 0)]))]
+  "(GET_MODE (operands[2]) == CCSZNmode
+    || GET_MODE (operands[2]) == CCSZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; 16-bit move with no change to the flags reg.
+;
+(define_insn "movhi"
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
+	(match_operand:HI 1 "ubicom32_move_operand"  "g"))]
+  ""
+  "*
+   {
+     if (CONST_INT_P (operands[1]))
+       return \"movei\\t%0, %1\";
+
+     return \"move.2\\t%0, %1\";
+   }")
+
+; Combiner-generated 16-bit move with the zero flag set accordingly.
+;
+(define_insn "movhi_ccszn"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:HI 0 "nonimmediate_operand" "rm")
+		 (const_int 0)))
+   (set (match_operand:HI 1 "nonimmediate_operand"	   "=rm")
+	(match_dup 0))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "ext.2\\t%1, %0")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:HI 0 "nonimmediate_operand" "")
+	(match_operand:HI 1 "nonimmediate_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(match_operator 3 "ubicom32_compare_operator"
+	  [(match_dup 0)
+	   (const_int 0)]))]
+  "(GET_MODE (operands[2]) == CCSZNmode
+    || GET_MODE (operands[2]) == CCSZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:HI 0 "nonimmediate_operand" "")
+	(match_operand:HI 1 "nonimmediate_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(match_operator 3 "ubicom32_compare_operator"
+	  [(match_dup 1)
+	   (const_int 0)]))]
+  "(GET_MODE (operands[2]) == CCSZNmode
+    || GET_MODE (operands[2]) == CCSZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; 32-bit move with no change to the flags reg.
+;
+(define_expand "movsi"
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "general_operand" ""))]
+  ""
+  "{
+     /* Convert any complexities in operand 1 into something that can just
+        fall into the default expander code.  */
+     ubicom32_expand_movsi (operands);
+   }")
+
+(define_insn "movsi_high"
+  [(set (match_operand:SI 0 "ubicom32_address_register_operand"		"=a")
+	(high:SI (match_operand:SI 1 "ubicom32_symbolic_address_operand" "s")))]
+  ""
+  "moveai\\t%0, #%%hi(%E1)")
+
+(define_insn "movsi_lo_sum"
+  [(set (match_operand:SI 0 "nonimmediate_operand"			 "=rm")
+	(lo_sum:SI (match_operand:SI 1 "ubicom32_address_register_operand" "a")
+                   (match_operand:SI 2 "immediate_operand"		   "s")))]
+  ""
+  "lea.1\\t%0, %%lo(%E2)(%1)")
+
+(define_insn "movsi_internal"
+  [(set (match_operand:SI 0 "nonimmediate_operand"   "=rm")
+	(match_operand:SI 1 "ubicom32_move_operand" "rmnY"))]
+  ""
+  "*
+   {
+     if (CONST_INT_P (operands[1]))
+       {
+         ubicom32_emit_move_const_int (operands[0], operands[1]);
+         return \"\";
+       }
+
+     if (GET_CODE (operands[1]) == CONST_DOUBLE)
+       {
+         HOST_WIDE_INT i = CONST_DOUBLE_LOW (operands[1]);
+
+         ubicom32_emit_move_const_int (operands[0], GEN_INT (i));
+         return \"\";
+       }
+
+     if (ubicom32_address_register_operand (operands[0], VOIDmode)
+	 && register_operand (operands[1], VOIDmode))
+       {
+	 if (ubicom32_address_register_operand (operands[1], VOIDmode))
+	   return \"lea.1\\t%0, 0(%1)\";
+
+	 /* Use movea here to utilize the hazard bypass in the >= v4 ISA.  */
+         if (ubicom32_v4)
+	   return \"movea\\t%0, %1\";
+
+         return \"move.4\\t%0, %1\";
+       }
+
+     return \"move.4\\t%0, %1\";
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; constants of value 2^n by using a bset.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(exact_log2 (INTVAL (operands[1])) > 14
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 0)
+	   (ior:SI (const_int 0)
+		   (match_dup 1)))
+      (clobber (reg:CC CC_REGNO))])]
+  "")
+
+; If we're not dependent on the state of the condition codes we can construct
+; constants of value ~(2^n) by using a bclr.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(exact_log2 (~INTVAL (operands[1])) > 14
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 0)
+	   (and:SI (const_int -1)
+		   (match_dup 1)))
+      (clobber (reg:CC CC_REGNO))])]
+  "")
+
+; For 32-bit constants that have bits 0 through 24 and bit 31 set the same
+; we can use swapb.4!
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(ubicom32_v4
+    && (INTVAL (operands[1]) & 0xffffffff) != 0xffffffff
+    && (INTVAL (operands[1]) & 0xffffffff) != 0
+    && ((INTVAL (operands[1]) & 0x80ffffff) == 0
+	|| (INTVAL (operands[1]) & 0x80ffffff) == 0x80ffffff))"
+  [(set (match_dup 0)
+	(bswap:SI (match_dup 2)))]
+  "{
+     operands[2] = GEN_INT (INTVAL (operands[1]) >> 24);
+   }")
+
+; If this is a write of a constant to memory look to see if we can usefully
+; transform this into 2 smaller writes.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "memory_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "! satisfies_constraint_I (operands[1])
+   && ubicom32_legitimate_address_p (HImode, plus_constant (XEXP (operands[0], 0), 2), 1)"
+  [(set (match_dup 4) (match_dup 2))
+   (set (match_dup 5) (match_dup 3))]
+  "{
+     rtx low_hword_addr;
+
+     operands[2] = gen_highpart_mode (HImode, SImode, operands[1]);
+     operands[3] = gen_lowpart (HImode, operands[1]);
+
+     operands[4] = gen_rtx_MEM (HImode, XEXP (operands[0], 0));
+     MEM_COPY_ATTRIBUTES (operands[4], operands[0]);
+
+     low_hword_addr = plus_constant (XEXP (operands[0], 0), 2);
+     operands[5] = gen_rtx_MEM (HImode, low_hword_addr);
+     MEM_COPY_ATTRIBUTES (operands[5], operands[0]);
+   }")
+
+; If we're writing memory and we've not found a better way to do this then
+; try loading into a D register and then copying to memory.  This will
+; perform the fewest possible memory read/writes.
+;
+(define_peephole2
+  [(match_scratch:SI 2 "d")
+   (set (match_operand:SI 0 "memory_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "! satisfies_constraint_I (operands[1])"
+  [(set (match_dup 2) (match_dup 1))
+   (set (match_dup 0) (match_dup 2))]
+  "")
+
+; If we're not dependent on the state of the condition codes we can construct
+; constants of value (2^n - 1) by using an lsr.4.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(exact_log2 (INTVAL (operands[1]) + 1) > 14
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 0)
+	   (lshiftrt:SI (const_int -1)
+			(match_dup 2)))
+      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[2] = GEN_INT (32 - exact_log2 (INTVAL (operands[1]) + 1));
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; constants of value (2^n - 1) by using an lsr.4.
+;
+(define_peephole2
+  [(match_scratch:SI 2 "d")
+   (set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(exact_log2 (INTVAL (operands[1]) + 1) > 14
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 2)
+	   (lshiftrt:SI (const_int -1)
+			(match_dup 3)))
+      (clobber (reg:CC CC_REGNO))])
+   (set (match_dup 0)
+	(match_dup 2))]
+  "{
+     operands[3] = GEN_INT (32 - exact_log2 (INTVAL (operands[1]) + 1));
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; some other constants by using an lsl.4 to shift 7 bits left by some
+; constant.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(ubicom32_shiftable_const_int (INTVAL (operands[1]))
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 0)
+	   (ashift:SI (match_dup 2)
+		      (match_dup 3)))
+      (clobber (reg:CC CC_REGNO))])]
+  "{
+     int shift = ubicom32_shiftable_const_int (INTVAL (operands[1]));
+     operands[2] = GEN_INT (INTVAL (operands[1]) >> shift);
+     operands[3] = GEN_INT (shift);
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; some other constants by using an lsl.4 to shift 7 bits left by some
+; constant.
+;
+(define_peephole2
+  [(match_scratch:SI 2 "d")
+   (set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(ubicom32_shiftable_const_int (INTVAL (operands[1]))
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(parallel
+     [(set (match_dup 2)
+	   (ashift:SI (match_dup 3)
+		      (match_dup 4)))
+      (clobber (reg:CC CC_REGNO))])
+   (set (match_dup 0)
+	(match_dup 2))]
+  "{
+     int shift = ubicom32_shiftable_const_int (INTVAL (operands[1]));
+     operands[3] = GEN_INT (INTVAL (operands[1]) >> shift);
+     operands[4] = GEN_INT (shift);
+   }")
+
+; For some 16-bit unsigned constants that have bit 15 set we can use
+; swapb.2!
+;
+; Note that the movsi code emits the same sequence but by using a peephole2
+; we split the pattern early enough to allow instruction scheduling to
+; occur.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(ubicom32_v4
+    && (INTVAL (operands[1]) & 0xffff80ff) == 0x80ff)"
+  [(set (match_dup 0)
+	(zero_extend:SI (bswap:HI (match_dup 2))))]
+  "{
+     HOST_WIDE_INT i = INTVAL (operands[1]) >> 8;
+     if (i >= 0x80)
+       i -= 0x100;
+     operands[2] = GEN_INT (i);
+   }")
+
+; In general for a 16-bit unsigned constant that has bit 15 set
+; then we need a movei/move.2 pair unless we can represent it
+; via just a move.2.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(INTVAL (operands[1]) & 0xffff8000) == 0x8000
+    && (INTVAL (operands[1]) & 0xffff) < 0xff80"
+  [(set (match_dup 2)
+	(match_dup 1))
+   (set (match_dup 0)
+	(zero_extend:SI (match_dup 2)))]
+  "{
+     operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; 32-bit constants that have bits 16 through 31 set to arbitrary values
+; and have bits 0 through 15 set to something representable as a default
+; source-1 immediate - we use movei/shmrg.2
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(((INTVAL (operands[1]) >= 0x8000
+      && INTVAL (operands[1]) < 0xff80)
+     || INTVAL (operands[1]) >= 0x10000
+     || INTVAL (operands[1]) < -0x8000)
+    && ((INTVAL (operands[1]) & 0xffff) >= 0xff80
+	|| (INTVAL (operands[1]) & 0xffff) < 0x80)
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(set (match_dup 0)
+	(match_dup 2))
+   (parallel
+     [(set (match_dup 0)
+	   (ior:SI
+	     (ashift:SI (match_dup 0)
+			(const_int 16))
+	     (zero_extend:SI
+	       (match_dup 3))))
+      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[2] = gen_highpart_mode (HImode, SImode, operands[1]);
+     operands[3] = gen_lowpart (HImode, operands[1]);
+   }")
+
+; Exactly the same as the peephole2 preceding except that this targets a
+; general register instead of D register.  Hopefully the later optimization
+; passes will notice that the value ended up in a D register first here
+; and eliminate away the other register!
+;
+(define_peephole2
+  [(match_scratch:SI 2 "d")
+   (set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(((INTVAL (operands[1]) >= 0x8000
+      && INTVAL (operands[1]) < 0xff80)
+     || INTVAL (operands[1]) >= 0x10000
+     || INTVAL (operands[1]) < -0x8000)
+    && ((INTVAL (operands[1]) & 0xffff) >= 0xff80
+	|| (INTVAL (operands[1]) & 0xffff) < 0x80)
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(set (match_dup 2)
+	(match_dup 3))
+   (parallel
+     [(set (match_dup 2)
+	   (ior:SI
+	     (ashift:SI (match_dup 2)
+			(const_int 16))
+	     (zero_extend:SI
+	       (match_dup 4))))
+      (clobber (reg:CC CC_REGNO))])
+   (set (match_dup 0)
+	(match_dup 2))]
+  "{
+     operands[3] = gen_highpart_mode (HImode, SImode, operands[1]);
+     operands[4] = gen_lowpart (HImode, operands[1]);
+   }")
+
+; If we have a load of a large integer constant which does not have bit 31
+; set and we have a spare A reg then construct it with a moveai/lea.1 pair
+; instead.  This avoids constructing it in 3 instructions on the stack.
+;
+; Note that we have to be careful not to match anything that matches
+; something we can do in a single instruction!  There aren't many such
+; constants but there are some.
+;
+(define_peephole2
+  [(match_scratch:SI 2 "a")
+   (set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))]
+  "(! (INTVAL (operands[1]) & 0x80000000)
+    && ((INTVAL (operands[1]) >= 0x8000
+	 && INTVAL (operands[1]) < 0xff80)
+	|| INTVAL (operands[1]) >= 0x10000))"
+  [(set (match_dup 2)
+	(match_dup 3))
+   (set (match_dup 0)
+	(plus:SI (match_dup 2)
+		 (match_dup 4)))]
+  "{
+     HOST_WIDE_INT i = INTVAL (operands[1]);
+     operands[3] = GEN_INT (i & 0xffffff80);
+     operands[4] = GEN_INT (i & 0x7f);
+   }")
+
+; If we're not dependent on the state of the condition codes we can construct
+; a 32-bit constant with a movei/movei/shmrg.2 sequence if possible.
+;
+(define_peephole2
+  [(match_scratch:HI 2 "d")
+   (set (match_operand:SI 0 "ubicom32_data_register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))
+   (match_dup 2)]
+  "(INTVAL (operands[1]) & 0x80000000
+    && INTVAL (operands[1]) < -0x8000
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(set (match_dup 0)
+	(match_dup 3))
+   (set (match_dup 2)
+	(match_dup 4))
+   (parallel
+     [(set (match_dup 0)
+	   (ior:SI
+	     (ashift:SI (match_dup 0)
+			(const_int 16))
+	     (zero_extend:SI
+	       (match_dup 2))))
+      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[3] = gen_highpart_mode (HImode, SImode, operands[1]);
+     operands[4] = gen_lowpart (HImode, operands[1]);
+   }")
+
+; Exactly the same as the peephole2 preceding except that this targets a
+; general register instead of D register.  Hopefully the later optimization
+; passes will notice that the value ended up in a D register first here
+; and eliminate away the other register!
+;
+(define_peephole2
+  [(match_scratch:SI 2 "d")
+   (match_scratch:HI 3 "d")
+   (set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))
+   (match_dup 3)]
+  "(INTVAL (operands[1]) & 0x80000000
+    && INTVAL (operands[1]) < -0x8000
+    && peep2_regno_dead_p (0, CC_REGNO))"
+  [(set (match_dup 2)
+	(match_dup 4))
+   (set (match_dup 3)
+	(match_dup 5))
+   (parallel
+     [(set (match_dup 2)
+	   (ior:SI
+	     (ashift:SI (match_dup 2)
+			(const_int 16))
+	     (zero_extend:SI
+	       (match_dup 3))))
+      (clobber (reg:CC CC_REGNO))])
+   (set (match_dup 0)
+	(match_dup 2))]
+  "{
+     operands[4] = gen_highpart_mode (HImode, SImode, operands[1]);
+     operands[5] = gen_lowpart (HImode, operands[1]);
+   }")
+
+(define_insn "movsi_fdpic_got_offset"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"   "=d")
+	(match_operand:SI 1 "ubicom32_fdpic_got_offset_operand" "Y"))]
+  ""
+  "movei\\t%0, %1")
+
+; The explicit MEM inside the UNSPEC prevents the compiler from moving
+; the load before a branch after a NULL test, or before a store that
+; initializes a function descriptor.
+
+(define_insn_and_split "load_fdpic_funcdesc"
+  [(set (match_operand:SI 0 "ubicom32_address_register_operand" "=a")
+	(unspec_volatile:SI [(mem:SI (match_operand:SI 1 "address_operand" "p"))]
+			     UNSPEC_VOLATILE_LOAD_FDPIC_FUNCDESC))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 0)
+	(mem:SI (match_dup 1)))])
+
+; Combiner-generated 32-bit move with the zero flag set accordingly.
+;
+(define_insn "movsi_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "nonimmediate_operand" "rm, d")
+		 (const_int 0)))
+   (set (match_operand:SI 1 "nonimmediate_operand"	    "=d,rm")
+	(match_dup 0))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   lsl.4\\t%1, %0, #0
+   add.4\\t%1, #0, %0")
+
+; Combiner-generated 32-bit move with all flags set accordingly.
+;
+(define_insn "movsi_ccw"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		 (const_int 0)))
+   (set (match_operand:SI 1 "nonimmediate_operand"		    "=rm")
+	(match_dup 0))]
+  "ubicom32_match_cc_mode(insn, CCWmode)"
+  "add.4\\t%1, #0, %0")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (parallel
+     [(set (match_operand 2 "ubicom32_cc_register_operand" "")
+	   (match_operator 3 "ubicom32_compare_operator"
+	     [(match_dup 0)
+	      (const_int 0)]))
+      (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
+  "(GET_MODE (operands[2]) == CCWZNmode
+    || GET_MODE (operands[2]) == CCWZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(match_operand:SI 1 "ubicom32_data_register_operand" ""))
+   (parallel
+     [(set (match_operand 2 "ubicom32_cc_register_operand" "")
+	   (match_operator 3 "ubicom32_compare_operator"
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
+  "(GET_MODE (operands[2]) == CCWZNmode
+    || GET_MODE (operands[2]) == CCWZmode)"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 0)
+	   (match_dup 1))])]
+   "")
+
+; Combine isn't very good at merging some types of operations so we
+; have to make do with a peephole.  It's not as effective but it's better
+; than doing nothing.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (parallel
+     [(set (match_operand 2 "ubicom32_cc_register_operand" "")
+	   (match_operator 3 "ubicom32_compare_operator"
+	     [(match_dup 0)
+	      (const_int 0)]))
+      (set (match_operand:SI 4 "ubicom32_data_register_operand" "")
+	   (match_dup 0))])]
+  "(peep2_reg_dead_p (2, operands[0])
+    && (GET_MODE (operands[2]) == CCWZNmode
+	|| GET_MODE (operands[2]) == CCWZmode))"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (set (match_dup 4)
+	   (match_dup 1))])]
+   "")
+
+; Register renaming may make a general reg into a D reg in which case
+; we may be able to simplify a compare.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (parallel
+     [(set (match_operand 2 "ubicom32_cc_register_operand" "")
+	   (match_operator 3 "ubicom32_compare_operator"
+	     [(match_dup 0)
+	      (const_int 0)]))
+      (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
+  "(peep2_reg_dead_p (2, operands[0])
+    && (GET_MODE (operands[2]) == CCWZNmode
+	|| GET_MODE (operands[2]) == CCWZmode))"
+  [(parallel
+     [(set (match_dup 2)
+	   (match_op_dup 3
+	     [(match_dup 1)
+	      (const_int 0)]))
+      (clobber (match_dup 4))])]
+   "")
+
+(define_insn_and_split "movdi"
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
+	(match_operand:DI 1 "general_operand"	  "rmi,ri"))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2) (match_dup 3))
+   (set (match_dup 4) (match_dup 5))]
+  "{
+     rtx dest_low;
+     rtx src_low;
+
+     dest_low = gen_lowpart (SImode, operands[0]);
+     src_low = gen_lowpart (SImode, operands[1]);
+
+     if (REG_P (operands[0])
+	 && REG_P (operands[1])
+	 && REGNO (operands[0]) < REGNO (operands[1]))
+       {
+	 operands[2] = gen_highpart (SImode, operands[0]);
+	 operands[3] = gen_highpart_mode (SImode, DImode, operands[1]);
+	 operands[4] = dest_low;
+	 operands[5] = src_low;
+       }
+     else if (reg_mentioned_p (dest_low, src_low))
+       {
+	 operands[2] = gen_highpart (SImode, operands[0]);
+	 operands[3] = gen_highpart_mode (SImode, DImode, operands[1]);
+	 operands[4] = dest_low;
+	 operands[5] = src_low;
+       }
+     else
+       {
+	 operands[2] = dest_low;
+	 operands[3] = src_low;
+	 operands[4] = gen_highpart (SImode, operands[0]);
+	 operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
+       }
+   }"
+  [(set_attr "length" "8")])
+
+; Combiner-generated 64-bit move with all flags set accordingly.
+;
+(define_insn "movdi_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:DI 0 "nonimmediate_operand" "d, m,   r")
+		 (const_int 0)))
+   (set (match_operand:DI 1 "nonimmediate_operand"	 "=&rm,rm,!&rm")
+	(match_dup 0))
+   (clobber (match_scratch:SI 2				   "=X, d,   d"))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_highpart (SImode, operands[0]);
+     operands[6] = gen_highpart (SImode, operands[1]);
+
+     if (ubicom32_data_register_operand (operands[0], VOIDmode))
+       return \"add.4\\t%4, #0, %3\;addc\\t%6, #0, %5\";
+
+     return \"movei\\t%2, #0\;add.4\\t%4, %3, %2\;addc\\t%6, %5, %2\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "movdi_ccw"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:DI 0 "nonimmediate_operand" "d, m,   r")
+		 (const_int 0)))
+   (set (match_operand:DI 1 "nonimmediate_operand"	 "=&rm,rm,!&rm")
+	(match_dup 0))
+   (clobber (match_scratch:SI 2				   "=X, d,   d"))]
+  "ubicom32_match_cc_mode(insn, CCWmode)"
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_highpart (SImode, operands[0]);
+     operands[6] = gen_highpart (SImode, operands[1]);
+
+     if (ubicom32_data_register_operand (operands[0], VOIDmode))
+       return \"add.4\\t%4, #0, %3\;addc\\t%6, #0, %5\";
+
+     return \"movei\\t%2, #0\;add.4\\t%4, %3, %2\;addc\\t%6, %5, %2\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "movsf"
+  [(set (match_operand:SF 0 "nonimmediate_operand"  "=!d,*rm")
+	(match_operand:SF 1 "ubicom32_move_operand" "rmF,rmF"))]
+  ""
+  "*
+   {
+     if (GET_CODE (operands[1]) == CONST_DOUBLE)
+       {
+	 HOST_WIDE_INT val;
+	 REAL_VALUE_TYPE rv;
+
+	 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
+	 REAL_VALUE_TO_TARGET_SINGLE (rv, val);
+
+	 ubicom32_emit_move_const_int (operands[0], GEN_INT (val));
+	 return \"\";
+       }
+
+     return \"move.4\\t%0, %1\";
+   }")
+
+(define_insn "zero_extendqihi2"
+  [(set (match_operand:HI 0 "register_operand"			   "=r")
+	(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "move.1\\t%0, %1")
+
+(define_insn "zero_extendqisi2"
+  [(set (match_operand:SI 0 "register_operand"			   "=r")
+	(zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "move.1\\t%0, %1")
+
+(define_insn "zero_extendqisi2_ccwz_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm"))
+          (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"	     "=d")
+	(zero_extend:SI (match_dup 1)))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "shmrg.1\\t%0, %1, #0")
+
+(define_insn "zero_extendhisi2"
+  [(set (match_operand:SI 0 "register_operand"			   "=r")
+	(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "move.2\\t%0, %1")
+
+(define_insn "zero_extendhisi2_ccwz_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm"))
+          (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"	     "=d")
+	(zero_extend:SI (match_dup 1)))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "shmrg.2\\t%0, %1, #0")
+
+(define_insn_and_split "zero_extendqidi2"
+  [(set (match_operand:DI 0 "register_operand"			   "=r")
+	(zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2)
+	(zero_extend:SI (match_dup 1)))
+   (set (match_dup 3)
+	(const_int 0))]
+  "{
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_highpart (SImode, operands[0]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn_and_split "zero_extendhidi2"
+  [(set (match_operand:DI 0 "register_operand"			   "=r")
+	(zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2)
+	(zero_extend:SI (match_dup 1)))
+   (set (match_dup 3)
+	(const_int 0))]
+  "{
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_highpart (SImode, operands[0]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn_and_split "zero_extendsidi2"
+  [(set (match_operand:DI 0 "nonimmediate_operand"		  "=rm")
+	(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2)
+	(match_dup 1))
+   (set (match_dup 3)
+	(const_int 0))]
+  "{
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_highpart (SImode, operands[0]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "extendqihi2"
+  [(set (match_operand:HI 0 "register_operand"			   "=r")
+	(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "rm")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "ext.1\\t%0, %1")
+
+(define_insn "extendqisi2"
+  [(set (match_operand:SI 0 "register_operand"			   "=r")
+	(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "ext.1\\t%0, %1")
+
+(define_insn "extendhisi2"
+  [(set (match_operand:SI 0 "register_operand"			   "=r")
+	(sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "ext.2\\t%0, %1")
+
+(define_insn_and_split "extendsidi2"
+  [(set (match_operand:DI 0 "nonimmediate_operand"		   "=d")
+	(sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2)
+	(match_dup 1))
+   (parallel
+     [(set (match_dup 3)
+	   (ashiftrt:SI (match_dup 2)
+		        (const_int 31)))
+      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_highpart (SImode, operands[0]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "bswaphi"
+  [(set (match_operand:HI 0 "nonimmediate_operand"	       "=rm")
+	(bswap:HI (match_operand:HI 1 "ubicom32_arith_operand" "rmI")))]
+  "(ubicom32_v4)"
+  "swapb.2\\t%0, %1");
+
+(define_insn "bswaphisi"
+  [(set (match_operand:SI 0 "register_operand"			  "=r")
+	(zero_extend:SI
+	  (bswap:HI (match_operand:HI 1 "ubicom32_arith_operand" "rmI"))))]
+  "(ubicom32_v4)"
+  "swapb.2\\t%0, %1");
+
+(define_insn "bswapsi"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	       "=rm")
+	(bswap:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")))]
+  "(ubicom32_v4)"
+  "swapb.4\\t%0, %1");
+
+(define_insn "tstqi_ext1"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:QI 0 "nonimmediate_operand" "rm")
+		 (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "ext.1\\t#0, %0")
+
+(define_expand "cmpqi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:QI 0 "ubicom32_arith_operand" "")
+		 (match_operand:QI 1 "ubicom32_data_register_operand" "")))]
+  "(ubicom32_v4)"
+  "{
+     ubicom32_compare_op0 = operands[0];
+     ubicom32_compare_op1 = operands[1];
+     DONE;
+   }")
+
+(define_insn "sub1_ccs"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:QI 0 "ubicom32_arith_operand"       "rmI")
+		 (match_operand:QI 1 "ubicom32_data_register_operand" "d")))]
+  "(ubicom32_v4)"
+  "sub.1\\t#0, %0, %1")
+
+; If we're testing for equality we don't have to worry about reversing conditions.
+;
+(define_insn "sub1_ccsz_1"
+  [(set (reg:CCSZ CC_REGNO)
+	(compare:CCSZ (match_operand:QI 0 "nonimmediate_operand"	  "rm")
+		      (match_operand:QI 1 "ubicom32_data_register_operand" "d")))]
+  "(ubicom32_v4)"
+  "sub.1\\t#0, %0, %1")
+
+(define_insn "sub1_ccsz_2"
+  [(set (reg:CCSZ CC_REGNO)
+	(compare:CCSZ (match_operand:QI 0 "ubicom32_data_register_operand" "d")
+		      (match_operand:QI 1 "ubicom32_arith_operand"	 "rmI")))]
+  "(ubicom32_v4)"
+  "sub.1\\t#0, %1, %0")
+
+; When the combiner runs it doesn't have any insight into whether or not an argument
+; to a compare is spilled to the stack and therefore can't swap the comparison in
+; an attempt to use sub.1 more effectively.  We peephole this case here.
+;
+(define_peephole2
+  [(set (match_operand:QI 0 "register_operand" "")
+	(match_operand:QI 1 "ubicom32_arith_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(compare (match_operand:QI 3 "ubicom32_data_register_operand" "")
+		 (match_dup 0)))
+   (set (pc)
+	(if_then_else (match_operator 4 "comparison_operator"
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_operand 5 "" ""))
+		      (pc)))]
+  "(peep2_reg_dead_p (2, operands[0])
+    && peep2_regno_dead_p (3, CC_REGNO))"
+  [(set (match_dup 2)
+	(compare (match_dup 1)
+		 (match_dup 3)))
+   (set (pc)
+	(if_then_else (match_op_dup 6
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_dup 5))
+		      (pc)))]
+  "{
+     rtx cc_reg;
+
+     cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
+     operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
+	 			   GET_MODE (operands[4]),
+				   cc_reg,
+				   const0_rtx);
+   }")
+
+(define_insn "tsthi_ext2"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:HI 0 "nonimmediate_operand" "rm")
+		 (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "ext.2\\t#0, %0")
+
+(define_expand "cmphi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:HI 0 "ubicom32_arith_operand" "")
+		 (match_operand:HI 1 "ubicom32_compare_operand" "")))]
+  ""
+  "{
+     do
+       {
+	 /* Is this a cmpi? */
+	 if (CONST_INT_P (operands[1]))
+	   break;
+
+	 /* Must be a sub.2 - if necessary copy an operand into a reg.  */
+	 if (! ubicom32_data_register_operand (operands[1], HImode))
+	   operands[1] = copy_to_mode_reg (HImode, operands[1]);
+       }
+     while (0);
+
+     ubicom32_compare_op0 = operands[0];
+     ubicom32_compare_op1 = operands[1];
+     DONE;
+   }")
+
+(define_insn "cmpi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:HI 0 "nonimmediate_operand" "rm")
+		 (match_operand 1 "const_int_operand"	     "N")))]
+  ""
+  "cmpi\\t%0, %1")
+
+(define_insn "sub2_ccs"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:HI 0 "ubicom32_arith_operand"	    "rmI")
+		 (match_operand:HI 1 "ubicom32_data_register_operand" "d")))]
+  ""
+  "sub.2\\t#0, %0, %1")
+
+; If we're testing for equality we don't have to worry about reversing conditions.
+;
+(define_insn "sub2_ccsz_1"
+  [(set (reg:CCSZ CC_REGNO)
+	(compare:CCSZ (match_operand:HI 0 "nonimmediate_operand"	  "rm")
+		      (match_operand:HI 1 "ubicom32_data_register_operand" "d")))]
+  ""
+  "sub.2\\t#0, %0, %1")
+
+(define_insn "sub2_ccsz_2"
+  [(set (reg:CCSZ CC_REGNO)
+	(compare:CCSZ (match_operand:HI 0 "ubicom32_data_register_operand" "d")
+		      (match_operand:HI 1 "ubicom32_arith_operand"	 "rmI")))]
+  ""
+  "sub.2\\t#0, %1, %0")
+
+; When the combiner runs it doesn't have any insight into whether or not an argument
+; to a compare is spilled to the stack and therefore can't swap the comparison in
+; an attempt to use sub.2 more effectively.  We peephole this case here.
+;
+(define_peephole2
+  [(set (match_operand:HI 0 "register_operand" "")
+	(match_operand:HI 1 "ubicom32_arith_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(compare (match_operand:HI 3 "ubicom32_data_register_operand" "")
+		 (match_dup 0)))
+   (set (pc)
+	(if_then_else (match_operator 4 "comparison_operator"
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_operand 5 "" ""))
+		      (pc)))]
+  "(peep2_reg_dead_p (2, operands[0])
+    && peep2_regno_dead_p (3, CC_REGNO))"
+  [(set (match_dup 2)
+	(compare (match_dup 1)
+		 (match_dup 3)))
+   (set (pc)
+	(if_then_else (match_op_dup 6
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_dup 5))
+		      (pc)))]
+  "{
+     rtx cc_reg;
+
+     cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
+     operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
+	 			   GET_MODE (operands[4]),
+				   cc_reg,
+				   const0_rtx);
+   }")
+
+(define_insn_and_split "tstsi_lsl4"
+  [(set (match_operand 0 "ubicom32_cc_register_operand" "=r")
+	(match_operator 1 "ubicom32_compare_operator"
+	  [(match_operand:SI 2 "nonimmediate_operand"   "rm")
+	   (const_int 0)]))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "#"
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  [(parallel
+     [(set (match_dup 0)
+	   (match_op_dup 1
+	     [(match_dup 2)
+	      (const_int 0)]))
+      (clobber (match_dup 3))])]
+  "{
+     operands[3] = gen_reg_rtx (SImode);
+   }")
+
+(define_insn "tstsi_lsl4_d"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "nonimmediate_operand" "rm")
+		 (const_int 0)))
+   (clobber (match_operand:SI 1 "ubicom32_data_register_operand" "=d"))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "lsl.4\\t%1, %0, #0")
+
+; Comparison for equality with -1.
+;
+(define_insn "cmpsi_not4_ccwz"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "nonimmediate_operand" "rm")
+		 (const_int -1)))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "not.4\\t#0, %0")
+
+(define_expand "cmpsi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "ubicom32_arith_operand" "")
+		 (match_operand:SI 1 "ubicom32_compare_operand" "")))]
+  ""
+  "{
+     do
+       {
+	 /* Is this a cmpi?  We can't take a memory address as cmpi takes
+            16-bit operands.  */
+	 if (register_operand (operands[0], SImode)
+	     && CONST_INT_P (operands[1])
+	     && satisfies_constraint_N (operands[1]))
+	   break;
+
+	 /* Must be a sub.4 - if necessary copy an operand into a reg.  */
+	 if (! ubicom32_data_register_operand (operands[1], SImode))
+	   operands[1] = copy_to_mode_reg (SImode, operands[1]);
+       }
+     while (0);
+
+     ubicom32_compare_op0 = operands[0];
+     ubicom32_compare_op1 = operands[1];
+     DONE;
+   }")
+
+(define_insn "cmpsi_cmpi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "register_operand" "r")
+		 (match_operand 1 "const_int_operand"   "N")))]
+  "(satisfies_constraint_N (operands[1]))"
+  "cmpi\\t%0, %1")
+
+(define_insn "cmpsi_sub4"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "ubicom32_arith_operand"	    "rmI")
+		 (match_operand:SI 1 "ubicom32_data_register_operand" "d")))]
+  ""
+  "sub.4\\t#0, %0, %1")
+
+; If we're testing for equality we don't have to worry about reversing conditions.
+;
+(define_insn "cmpsi_sub4_ccwz_1"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "nonimmediate_operand"	     "rm")
+		 (match_operand:SI 1 "ubicom32_data_register_operand" "d")))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "sub.4\\t#0, %0, %1")
+
+(define_insn "cmpsi_sub4_ccwz_2"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		 (match_operand:SI 1 "nonimmediate_operand"	     "rm")))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "sub.4\\t#0, %1, %0")
+
+; When the combiner runs it doesn't have any insight into whether or not an argument
+; to a compare is spilled to the stack and therefore can't swap the comparison in
+; an attempt to use sub.4 more effectively.  We peephole this case here.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "ubicom32_arith_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(compare (match_operand:SI 3 "ubicom32_data_register_operand" "")
+		 (match_dup 0)))
+   (set (pc)
+	(if_then_else (match_operator 4 "comparison_operator"
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_operand 5 "" ""))
+		      (pc)))]
+  "(peep2_reg_dead_p (2, operands[0])
+    && peep2_regno_dead_p (3, CC_REGNO))"
+  [(set (match_dup 2)
+	(compare (match_dup 1)
+		 (match_dup 3)))
+   (set (pc)
+	(if_then_else (match_op_dup 6
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_dup 5))
+		      (pc)))]
+  "{
+     rtx cc_reg;
+
+     cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
+     operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
+	 			   GET_MODE (operands[4]),
+				   cc_reg,
+				   const0_rtx);
+   }")
+
+(define_insn_and_split "tstdi_or4"
+  [(set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ (match_operand:DI 0 "nonimmediate_operand" "rm")
+		      (const_int 0)))]
+  ""
+  "#"
+  ""
+  [(parallel
+     [(set (reg:CCWZ CC_REGNO)
+	   (compare:CCWZ (match_dup 0)
+			 (const_int 0)))
+      (clobber (match_dup 1))])]
+  "{
+     operands[1] = gen_reg_rtx (SImode);
+   }")
+
+(define_insn "tstdi_or4_d"
+  [(set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ (match_operand:DI 0 "nonimmediate_operand" "rm")
+		      (const_int 0)))
+   (clobber (match_operand:SI 1 "ubicom32_data_register_operand" "=d"))]
+  ""
+  "*
+   {
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_highpart_mode (SImode, DImode, operands[0]);
+
+     if (ubicom32_data_register_operand (operands[0], GET_MODE (operands[0])))
+       return \"or.4\\t#0, %2, %3\";
+
+     return \"move.4\\t%1, %2\;or.4\\t%1, %3, %1\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_expand "cmpdi"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:DI 0 "ubicom32_arith_operand" "")
+		 (match_operand:DI 1 "ubicom32_data_register_operand" "")))]
+  ""
+  "{
+     ubicom32_compare_op0 = operands[0];
+     ubicom32_compare_op1 = operands[1];
+     DONE;
+   }")
+
+(define_insn "cmpdi_sub4subc"
+  [(set (reg CC_REGNO)
+	(compare (match_operand:DI 0 "ubicom32_arith_operand"	    "rmI")
+		 (match_operand:DI 1 "ubicom32_data_register_operand" "d")))]
+  ""
+  "*
+   {
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_lowpart (SImode, operands[1]);
+     operands[4] = gen_highpart_mode (SImode, DImode, operands[0]);
+     operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
+
+     return \"sub.4\\t#0, %2, %3\;subc\\t#0, %4, %5\";
+   }"
+  [(set_attr "length" "8")])
+
+; When the combiner runs it doesn't have any insight into whether or not an argument
+; to a compare is spilled to the stack and therefore can't swap the comparison in
+; an attempt to use sub.4/subc more effectively.  We peephole this case here.
+;
+(define_peephole2
+  [(set (match_operand:DI 0 "register_operand" "")
+	(match_operand:DI 1 "ubicom32_arith_operand" ""))
+   (set (match_operand 2 "ubicom32_cc_register_operand" "")
+	(compare (match_operand:DI 3 "ubicom32_data_register_operand" "")
+		 (match_dup 0)))
+   (set (pc)
+	(if_then_else (match_operator 4 "comparison_operator"
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_operand 5 "" ""))
+		      (pc)))]
+  "(peep2_reg_dead_p (2, operands[0])
+    && peep2_regno_dead_p (3, CC_REGNO))"
+  [(set (match_dup 2)
+	(compare (match_dup 1)
+		 (match_dup 3)))
+   (set (pc)
+	(if_then_else (match_op_dup 6
+			[(match_dup 2)
+			 (const_int 0)])
+		      (label_ref (match_dup 5))
+		      (pc)))]
+  "{
+     rtx cc_reg;
+
+     cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
+     operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
+	 			   GET_MODE (operands[4]),
+				   cc_reg,
+				   const0_rtx);
+   }")
+
+(define_insn "btst"
+  [(set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ
+	  (zero_extract:SI
+	    (match_operand:SI 0 "nonimmediate_operand"   "rm")
+	    (const_int 1)
+	    (match_operand:SI 1 "ubicom32_arith_operand" "dM"))
+	  (const_int 0)))]
+  ""
+  "btst\\t%0, %1")
+
+(define_insn "bfextu_ccwz_null"
+  [(set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ
+	  (zero_extract:SI
+	    (match_operand:SI 0 "nonimmediate_operand" "rm")
+	    (match_operand 1 "const_int_operand"        "M")
+	    (const_int 0))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2			       "=d"))]
+  ""
+  "bfextu\\t%2, %0, %1")
+
+(define_expand "addqi3"
+  [(parallel
+     [(set (match_operand:QI 0 "memory_operand" "")
+	   (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
+		    (match_operand:QI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], QImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+   }")
+
+(define_insn "addqi3_add1"
+  [(set (match_operand:QI 0 "memory_operand"		       "=m, m")
+	(plus:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		 (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "@
+   add.1\\t%0, %2, %1
+   add.1\\t%0, %1, %2")
+
+(define_insn "addqi3_add1_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (neg:QI (match_operand:QI 0 "nonimmediate_operand" "%d,rm"))
+	  (match_operand:QI 1 "ubicom32_arith_operand"      "rmI, d")))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "@
+   add.1\\t#0, %1, %0
+   add.1\\t#0, %0, %1")
+
+(define_expand "addhi3"
+  [(parallel
+     [(set (match_operand:HI 0 "memory_operand" "")
+	   (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
+		    (match_operand:HI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     if (!memory_operand (operands[0], HImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+   }")
+
+(define_insn "addhi3_add2"
+  [(set (match_operand:HI 0 "memory_operand"		       "=m, m")
+	(plus:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		 (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   add.2\\t%0, %2, %1
+   add.2\\t%0, %1, %2")
+
+(define_insn "addhi3_add2_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (neg:HI (match_operand:HI 0 "nonimmediate_operand" "%d,rm"))
+	  (match_operand:HI 1 "ubicom32_arith_operand"      "rmI, d")))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "@
+   add.2\\t#0, %1, %0
+   add.2\\t#0, %0, %1")
+
+(define_expand "addsi3"
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	(plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
+		 (match_operand:SI 2 "ubicom32_move_operand" "")))]
+  ""
+  "{
+     ubicom32_expand_addsi3 (operands);
+     DONE;
+   }")
+
+; We start with an instruction pattern that can do all sorts of interesting
+; things but we split out any uses of lea or pdec instructions because
+; those instructions don't clobber the condition codes.
+;
+(define_insn_and_split "addsi3_1"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	   "=rm,rm,rm,rm,rm, rm,rm")
+	(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%a, a, a, a, a,  d,rm")
+		 (match_operand:SI 2 "ubicom32_move_operand" "L, K, J, P, d,rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   #
+   #
+   #
+   #
+   #
+   add.4\\t%0, %2, %1
+   add.4\\t%0, %1, %2"
+  "(reload_completed
+    && ubicom32_address_register_operand (operands[1], GET_MODE (operands[1])))"
+  [(set (match_dup 0)
+	(plus:SI (match_dup 1)
+		 (match_dup 2)))]
+  ""
+)
+
+(define_insn "addsi3_1_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (plus:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		   (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"	        "=rm,rm")
+	(plus:SI (match_dup 1)
+		 (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   add.4\\t%0, %2, %1
+   add.4\\t%0, %1, %2")
+
+(define_insn "addsi3_1_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (neg:SI (match_operand:SI 0 "nonimmediate_operand" "%d,rm"))
+	  (match_operand:SI 1 "ubicom32_arith_operand"      "rmI, d")))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   add.4\\t#0, %1, %0
+   add.4\\t#0, %0, %1")
+
+(define_insn_and_split "addsi3_2"
+  [(set (match_operand:SI 0 "nonimmediate_operand"			"=rm,rm,rm,rm,rm,rm")
+	(plus:SI (match_operand:SI 1 "ubicom32_address_register_operand" "%a, a, a, a, a, a")
+		 (match_operand:SI 2 "ubicom32_move_operand"		  "L, K, J, P, d, n")))]
+  ""
+  "@
+   lea.4\\t%0, %E2(%1)
+   lea.2\\t%0, %E2(%1)
+   lea.1\\t%0, %E2(%1)
+   pdec\\t%0, %n2(%1)
+   lea.1\\t%0, (%1,%2)
+   #"
+  "(reload_completed
+    && ! satisfies_constraint_L (operands[2])
+    && ! satisfies_constraint_K (operands[2])
+    && ! satisfies_constraint_J (operands[2])
+    && ! satisfies_constraint_P (operands[2])
+    && ! ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))"
+  [(set (reg:SI AUX_DATA_REGNO)
+  	(match_dup 2))
+   (set (match_dup 0)
+	(plus:SI (match_dup 1)
+		 (reg:SI AUX_DATA_REGNO)))]
+  ""
+)
+
+(define_insn "lea_2"
+  [(set (match_operand:SI 0 "nonimmediate_operand"			     "=rm")
+	(plus:SI (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+			  (const_int 2))
+		 (match_operand:SI 2 "ubicom32_address_register_operand"       "a")))]
+  ""
+  "lea.2\\t%0, (%2,%1)")
+
+(define_insn "lea_4"
+  [(set (match_operand:SI 0 "nonimmediate_operand"			     "=rm")
+	(plus:SI (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+			  (const_int 4))
+		 (match_operand:SI 2 "ubicom32_address_register_operand"       "a")))]
+  ""
+  "lea.4\\t%0, (%2,%1)")
+
+(define_expand "adddi3"
+  [(parallel
+     [(set (match_operand:DI 0 "nonimmediate_operand" "")
+	   (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
+		    (match_operand:DI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+   }")
+
+; We construct a 64-bit add from 32-bit operations.  Note that we use the
+; & constraint to prevent overlapping registers being allocated.  We do
+; allow identical registers though as that won't break anything.
+;
+(define_insn "adddi3_add4addc"
+  [(set (match_operand:DI 0 "nonimmediate_operand"	      "=&r,&r,rm,  d,  m, m")
+	(plus:DI (match_operand:DI 1 "nonimmediate_operand"    "%d,rm, 0,  0,  d,rm")
+		 (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d, d,rmI,rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart (SImode, operands[1]);
+     operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
+
+     if (ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
+       return \"add.4\\t%3, %4, %5\;addc\\t%6, %7, %8\";
+
+     return \"add.4\\t%3, %5, %4\;addc\\t%6, %8, %7\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "adddi3_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (plus:DI (match_operand:DI 1 "nonimmediate_operand"    "%d,rm, 0,  0,  d,rm")
+		   (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d, d,rmI,rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:DI 0 "nonimmediate_operand"		"=&r,&r,rm,  d,  m, m")
+	(plus:DI (match_dup 1)
+		 (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+
+     if (ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
+       {
+	 operands[4] = gen_lowpart (SImode, operands[1]);
+	 operands[5] = gen_lowpart (SImode, operands[2]);
+	 operands[7] = gen_highpart (SImode, operands[1]);
+	 operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
+       }
+     else
+       {
+	 operands[4] = gen_lowpart (SImode, operands[2]);
+	 operands[5] = gen_lowpart (SImode, operands[1]);
+	 operands[7] = gen_highpart (SImode, operands[2]);
+	 operands[8] = gen_highpart (SImode, operands[1]);
+       }
+
+     return \"add.4\\t%3, %5, %4\;addc\\t%6, %8, %7\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "adddi3_ccwz_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (neg:DI (match_operand:DI 0 "nonimmediate_operand" "%d,rm"))
+	  (match_operand:DI 1 "ubicom32_arith_operand"      "rmI, d")))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "*
+   {
+     if (ubicom32_data_register_operand (operands[0], GET_MODE (operands[0])))
+       {
+	 operands[2] = gen_lowpart (SImode, operands[0]);
+	 operands[3] = gen_lowpart (SImode, operands[1]);
+	 operands[4] = gen_highpart (SImode, operands[0]);
+	 operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
+       }
+     else
+       {
+	 operands[2] = gen_lowpart (SImode, operands[1]);
+	 operands[3] = gen_lowpart (SImode, operands[0]);
+	 operands[4] = gen_highpart (SImode, operands[1]);
+	 operands[5] = gen_highpart (SImode, operands[0]);
+       }
+
+     return \"add.4\\t#0, %3, %2\;addc\\t#0, %5, %4\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_expand "subqi3"
+  [(parallel
+     [(set (match_operand:QI 0 "memory_operand" "")
+	   (minus:QI (match_operand:QI 1 "ubicom32_arith_operand" "")
+		     (match_operand:QI 2 "ubicom32_data_register_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], QImode))
+       FAIL;
+   }")
+
+(define_insn "subqi3_sub1"
+  [(set (match_operand:QI 0 "memory_operand"			      "=m")
+	(minus:QI (match_operand:QI 1 "ubicom32_arith_operand"	     "rmI")
+		  (match_operand:QI 2 "ubicom32_data_register_operand" "d")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "sub.1\\t%0, %1, %2")
+
+(define_expand "subhi3"
+  [(parallel
+     [(set (match_operand:HI 0 "memory_operand" "")
+	   (minus:HI (match_operand:HI 1 "ubicom32_arith_operand" "")
+		     (match_operand:HI 2 "ubicom32_data_register_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], HImode))
+       FAIL;
+   }")
+
+(define_insn "subhi3_sub2"
+  [(set (match_operand:HI 0 "memory_operand"			      "=m")
+	(minus:HI (match_operand:HI 1 "ubicom32_arith_operand"	     "rmI")
+		  (match_operand:HI 2 "ubicom32_data_register_operand" "d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "sub.2\\t%0, %1, %2")
+
+(define_insn "subsi3"
+  [(set (match_operand:SI 0 "nonimmediate_operand"		     "=rm")
+	(minus:SI (match_operand:SI 1 "ubicom32_arith_operand"	     "rmI")
+		  (match_operand:SI 2 "ubicom32_data_register_operand" "d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "sub.4\\t%0, %1, %2")
+
+(define_insn "subsi3_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (minus:SI (match_operand:SI 1 "ubicom32_arith_operand"       "rmI")
+		    (match_operand:SI 2 "ubicom32_data_register_operand" "d"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"		       "=rm")
+	(minus:SI (match_dup 1)
+		  (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "sub.4\\t%0, %1, %2")
+
+; We construct a 64-bit add from 32-bit operations.  Note that we use the
+; & constraint to prevent overlapping registers being allocated.  We do
+; allow identical registers though as that won't break anything.
+;
+(define_insn "subdi3"
+  [(set (match_operand:DI 0 "nonimmediate_operand"		     "=&r,r,  d,  m")
+	(minus:DI (match_operand:DI 1 "ubicom32_arith_operand"	     "rmI,0,rmI,rmI")
+		  (match_operand:DI 2 "ubicom32_data_register_operand" "d,d,  0,  d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart_mode (SImode, DImode, operands[1]);
+     operands[8] = gen_highpart (SImode, operands[2]);
+
+     return \"sub.4\\t%3, %4, %5\;subc\\t%6, %7, %8\";
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "subdi3_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (minus:DI (match_operand:DI 1 "ubicom32_arith_operand"       "rmI,rmI")
+		    (match_operand:DI 2 "ubicom32_data_register_operand" "d,  d"))
+	  (const_int 0)))
+   (set (match_operand:DI 0 "nonimmediate_operand"		       "=&r,  m")
+	(minus:DI (match_dup 1)
+		  (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "*
+   {
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart_mode (SImode, DImode, operands[1]);
+     operands[8] = gen_highpart (SImode, operands[2]);
+
+     return \"sub.4\\t%3, %4, %5\;subc\\t%6, %7, %8\";
+   }"
+  [(set_attr "length" "8")])
+
+;(define_insn "negqi2"
+;  [(set (match_operand:QI 0 "nonimmediate_operand"		   "=rm")
+;	(neg:QI (match_operand:QI 1 "ubicom32_data_register_operand" "d")))
+;   (clobber (reg:CC CC_REGNO))]
+;  "(ubicom32_v4)"
+;  "sub.1\\t%0, #0, %1")
+
+;(define_insn "neghi2"
+;  [(set (match_operand:HI 0 "nonimmediate_operand"		   "=rm")
+;	(neg:HI (match_operand:HI 1 "ubicom32_data_register_operand" "d")))
+;   (clobber (reg:CC CC_REGNO))]
+;  ""
+;  "sub.2\\t%0, #0, %1")
+
+(define_insn "negsi2"
+  [(set (match_operand:SI 0 "nonimmediate_operand"		   "=rm")
+	(neg:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "sub.4\\t%0, #0, %1")
+
+(define_insn_and_split "negdi2"
+  [(set (match_operand:DI 0 "nonimmediate_operand"		  "=&rm")
+	(neg:DI (match_operand:DI 1 "ubicom32_data_register_operand" "d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  "reload_completed"
+  [(parallel [(set (match_dup 0)
+		   (minus:DI (const_int 0)
+			     (match_dup 1)))
+	      (clobber (reg:CC CC_REGNO))])]
+  ""
+  [(set_attr "length" "8")])
+
+(define_insn "umulhisi3"
+  [(set (match_operand:SI 0 "ubicom32_acc_lo_register_operand"	     "=l, l")
+	(mult:SI
+	  (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "%d,rm"))
+	  (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm, d"))))
+   (clobber (reg:HI ACC0_HI_REGNO))
+   (clobber (reg:HI ACC1_HI_REGNO))]
+  ""
+  "@
+   mulu\\t%A0, %2, %1
+   mulu\\t%A0, %1, %2"
+  [(set_attr "type" "mul,mul")])
+
+(define_insn "mulhisi3"
+  [(set (match_operand:SI 0 "ubicom32_acc_lo_register_operand"	     "=l, l")
+	(mult:SI
+	  (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "%d,rm"))
+	  (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm, d"))))
+   (clobber (reg:HI ACC0_HI_REGNO))
+   (clobber (reg:HI ACC1_HI_REGNO))]
+  ""
+  "@
+   muls\\t%A0, %2, %1
+   muls\\t%A0, %1, %2"
+  [(set_attr "type" "mul,mul")])
+
+(define_expand "mulsi3"
+  [(set (match_operand:SI 0 "ubicom32_acc_hi_register_operand" "")
+	(mult:SI (match_operand:SI 1 "ubicom32_arith_operand" "")
+		 (match_operand:SI 2 "ubicom32_arith_operand" "")))]
+  ""
+  "{
+     if (ubicom32_emit_mult_sequence (operands))
+       DONE;
+   }")
+
+(define_insn "umulsidi3"
+  [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand"	     "=h, h")
+	(mult:DI
+	  (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%d,rm"))
+	  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm, d"))))]
+  "(ubicom32_v4)"
+  "@
+   mulu.4\\t%A0, %2, %1
+   mulu.4\\t%A0, %1, %2"
+  [(set_attr "type" "mul,mul")])
+
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
+	(mult:DI
+	  (zero_extend:DI (match_dup 0))
+	  (zero_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))))]
+  "(peep2_reg_dead_p (2, operands[0])
+    || REGNO (operands[0]) == REGNO (operands[2])
+    || REGNO (operands[0]) == REGNO (operands[2]) + 1)
+   && ! rtx_equal_p (operands[0], operands[3])"
+  [(set (match_dup 2)
+	(mult:DI
+	  (zero_extend:DI (match_dup 1))
+	  (zero_extend:DI (match_dup 3))))]
+  "")
+
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
+	(mult:DI
+	  (zero_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))
+	  (zero_extend:DI (match_dup 0))))]
+  "(peep2_reg_dead_p (2, operands[0])
+    || REGNO (operands[0]) == REGNO (operands[2])
+    || REGNO (operands[0]) == REGNO (operands[2]) + 1)
+   && ! rtx_equal_p (operands[0], operands[3])"
+  [(set (match_dup 2)
+	(mult:DI
+	  (zero_extend:DI (match_dup 1))
+	  (zero_extend:DI (match_dup 3))))]
+  "")
+
+(define_insn "umulsidi3_const"
+  [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand"		       "=h")
+	(mult:DI
+	  (zero_extend:DI (match_operand:SI 1 "ubicom32_data_register_operand" "%d"))
+	  (match_operand 2 "const_int_operand"					"I")))]
+  "(ubicom32_v4 && satisfies_constraint_I (operands[2]))"
+  "mulu.4\\t%A0, %2, %1"
+  [(set_attr "type" "mul")])
+
+(define_insn "mulsidi3"
+  [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand"	     "=h, h")
+	(mult:DI
+	  (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%d,rm"))
+	  (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm, d"))))]
+  "(ubicom32_v4)"
+  "@
+   muls.4\\t%A0, %2, %1
+   muls.4\\t%A0, %1, %2"
+  [(set_attr "type" "mul,mul")])
+
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
+	(mult:DI
+	  (sign_extend:DI (match_dup 0))
+	  (sign_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))))]
+  "(peep2_reg_dead_p (2, operands[0])
+    || REGNO (operands[0]) == REGNO (operands[2])
+    || REGNO (operands[0]) == REGNO (operands[2]) + 1)
+   && ! rtx_equal_p (operands[0], operands[3])"
+  [(set (match_dup 2)
+	(mult:DI
+	  (sign_extend:DI (match_dup 1))
+	  (sign_extend:DI (match_dup 3))))]
+  "")
+
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "nonimmediate_operand" ""))
+   (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
+	(mult:DI
+	  (sign_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))
+	  (sign_extend:DI (match_dup 0))))]
+  "(peep2_reg_dead_p (2, operands[0])
+    || REGNO (operands[0]) == REGNO (operands[2])
+    || REGNO (operands[0]) == REGNO (operands[2]) + 1)
+   && ! rtx_equal_p (operands[0], operands[3])"
+  [(set (match_dup 2)
+	(mult:DI
+	  (sign_extend:DI (match_dup 1))
+	  (sign_extend:DI (match_dup 3))))]
+  "")
+
+(define_insn "mulsidi3_const"
+  [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand"		       "=h")
+	(mult:DI
+	  (sign_extend:DI (match_operand:SI 1 "ubicom32_data_register_operand" "%d"))
+	  (match_operand 2 "const_int_operand"					"I")))]
+  "(ubicom32_v4 && satisfies_constraint_I (operands[2]))"
+  "muls.4\\t%A0, %2, %1"
+  [(set_attr "type" "mul")])
+
+(define_expand "andqi3"
+  [(parallel
+     [(set (match_operand:QI 0 "memory_operand" "")
+	   (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
+		   (match_operand:QI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], QImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+   }")
+
+(define_insn "andqi3_and1"
+  [(set (match_operand:QI 0 "memory_operand"		      "=m, m")
+	(and:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "@
+   and.1\\t%0, %2, %1
+   and.1\\t%0, %1, %2")
+
+(define_insn "andqi3_and1_ccszn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:QI 0 "memory_operand"		        "=m, m")
+	(and:QI (match_dup 1)
+		(match_dup 2)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "@
+   and.1\\t%0, %2, %1
+   and.1\\t%0, %1, %2")
+
+(define_insn "andqi3_and1_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:QI (match_operand:QI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:QI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "@
+   and.1\\t#0, %1, %0
+   and.1\\t#0, %0, %1")
+
+(define_insn "and1_ccszn_null_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
+		    (match_operand:SI 1 "ubicom32_arith_operand"	 "rI"))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "and.1\\t#0, %1, %0")
+
+(define_insn "and1_ccszn_null_2"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		    (subreg:SI
+		      (match_operand:QI 1 "memory_operand"		 "m")
+		      0))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "and.1\\t#0, %1, %0")
+
+(define_insn "and1_ccszn_null_3"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (and:SI (subreg:SI
+		      (match_operand:QI 0 "memory_operand"		 "m")
+		      0)
+		    (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "and.1\\t#0, %0, %1")
+
+(define_expand "andhi3"
+  [(parallel
+     [(set (match_operand:HI 0 "memory_operand" "")
+	   (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
+		   (match_operand:HI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     if (!memory_operand (operands[0], HImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+   }")
+
+(define_insn "andhi3_and2"
+  [(set (match_operand:HI 0 "memory_operand"		      "=m, m")
+	(and:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   and.2\\t%0, %2, %1
+   and.2\\t%0, %1, %2")
+
+(define_insn "andhi3_and2_ccszn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:HI 0 "memory_operand"		        "=m, m")
+	(and:HI (match_dup 1)
+		(match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "@
+   and.2\\t%0, %2, %1
+   and.2\\t%0, %1, %2")
+
+(define_insn "andhi3_and2_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:HI (match_operand:HI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:HI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "@
+   and.2\\t#0, %1, %0
+   and.2\\t#0, %0, %1")
+
+(define_insn "and2_ccszn_null_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
+		    (match_operand:SI 1 "ubicom32_arith_operand"	 "rI"))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "and.2\\t#0, %1, %0")
+
+(define_insn "and2_ccszn_null_2"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		    (subreg:SI
+		      (match_operand:HI 1 "memory_operand"		 "m")
+		      0))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "and.2\\t#0, %1, %0")
+
+(define_insn "and2_ccszn_null_3"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (and:SI (subreg:SI
+		      (match_operand:HI 0 "memory_operand"		 "m")
+		      0)
+		    (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "and.2\\t#0, %0, %1")
+
+(define_expand "andsi3"
+  [(parallel
+     [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	   (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
+		   (match_operand:SI 2 "ubicom32_and_or_si3_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     do
+       {
+	 /* Is this a bfextu?  */
+	 if (ubicom32_data_register_operand (operands[0], SImode)
+	     && CONST_INT_P (operands[2])
+	     && exact_log2 (INTVAL (operands[2]) + 1) != -1)
+	   break;
+
+	 /* Is this a bclr?  */
+	 if (CONST_INT_P (operands[2])
+	     && exact_log2 (~INTVAL (operands[2])) != -1)
+	   break;
+
+	 /* Must be an and.4  */
+	 if (!ubicom32_data_register_operand (operands[1], SImode))
+	   operands[1] = copy_to_mode_reg (SImode, operands[1]);
+
+	 if (!ubicom32_arith_operand (operands[2], SImode))
+	   operands[2] = copy_to_mode_reg (SImode, operands[2]);
+       }
+     while (0);
+   }")
+
+(define_insn "andsi3_bfextu"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
+  	(and:SI (match_operand:SI 1 "nonimmediate_operand"  "%rm")
+		(match_operand:SI 2 "const_int_operand"	      "O")))
+   (clobber (reg:CC CC_REGNO))]
+  "(satisfies_constraint_O (operands[2]))"
+  "*
+   {
+     operands[3] = GEN_INT (exact_log2 (INTVAL (operands[2]) + 1));
+
+     return \"bfextu\\t%0, %1, %3\";
+   }")
+
+(define_insn "andsi3_bfextu_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:SI (match_operand:SI 1 "nonimmediate_operand" "%rm")
+		  (match_operand:SI 2 "const_int_operand"      "O"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"  "=d")
+	(and:SI (match_dup 1)
+		(match_dup 2)))]
+  "(satisfies_constraint_O (operands[2])
+    && ubicom32_match_cc_mode(insn, CCWZmode))"
+  "*
+   {
+     operands[3] = GEN_INT (exact_log2 (INTVAL (operands[2]) + 1));
+
+     return \"bfextu\\t%0, %1, %3\";
+   }")
+
+(define_insn "andsi3_bfextu_ccwz_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:SI (match_operand:SI 0 "nonimmediate_operand" "%rm")
+		  (match_operand:SI 1 "const_int_operand"      "O"))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2				      "=d"))]
+  "(satisfies_constraint_O (operands[1])
+    && ubicom32_match_cc_mode(insn, CCWZmode))"
+  "*
+   {
+     operands[3] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+
+     return \"bfextu\\t%2, %0, %3\";
+   }")
+
+(define_insn "andsi3_bclr"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	      "=rm")
+	(and:SI (match_operand:SI 1 "ubicom32_arith_operand" "%rmI")
+		(match_operand:SI 2 "const_int_operand"	        "n")))
+   (clobber (reg:CC CC_REGNO))]
+  "(exact_log2 (~INTVAL (operands[2])) != -1)"
+  "bclr\\t%0, %1, #%D2")
+
+(define_insn "andsi3_and4"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	     "=rm,rm")
+	(and:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   and.4\\t%0, %2, %1
+   and.4\\t%0, %1, %2")
+
+(define_insn "andsi3_and4_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"	       "=rm,rm")
+	(and:SI (match_dup 1)
+		(match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   and.4\\t%0, %2, %1
+   and.4\\t%0, %1, %2")
+
+(define_insn "andsi3_and4_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:SI (match_operand:SI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   and.4\\t#0, %1, %0
+   and.4\\t#0, %0, %1")
+
+(define_insn "andsi3_lsr4_ccwz_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (and:SI (match_operand:SI 0 "nonimmediate_operand" "%rm")
+		  (match_operand:SI 1 "const_int_operand"      "n"))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2				      "=d"))]
+  "(exact_log2 ((~(INTVAL (operands[1]))) + 1) != -1
+    && ubicom32_match_cc_mode(insn, CCWZmode))"
+  "*
+   {
+     operands[3] = GEN_INT (exact_log2 ((~(INTVAL (operands[1]))) + 1));
+
+     return \"lsr.4\\t%2, %0, %3\";
+   }")
+
+; We really would like the combiner to recognize this scenario and deal with
+; it but unfortunately it tries to canonicalize zero_extract ops on MEMs
+; into QImode operations and we can't match them in any useful way.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(match_operand:SI 1 "const_int_operand" ""))
+   (set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ
+	  (and:SI (match_operand:SI 2 "nonimmediate_operand" "")
+		  (match_dup 0))
+	  (const_int 0)))]
+  "(exact_log2 (INTVAL (operands[1])) != -1
+    && peep2_reg_dead_p (2, operands[0]))"
+  [(set (reg:CCWZ CC_REGNO)
+	(compare:CCWZ
+	  (zero_extract:SI
+	    (match_dup 2)
+	    (const_int 1)
+	    (match_dup 3))
+	  (const_int 0)))]
+  "{
+     operands[3] = GEN_INT (exact_log2 (INTVAL (operands[1])));
+   }")
+
+(define_expand "anddi3"
+  [(parallel
+     [(set (match_operand:DI 0 "nonimmediate_operand" "")
+	   (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
+		   (match_operand:DI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+   }")
+
+(define_insn_and_split "anddi3_and4"
+  [(set (match_operand:DI 0 "nonimmediate_operand"	     "=&r,&r,  d,rm,  m, m")
+	(and:DI (match_operand:DI 1 "nonimmediate_operand"    "%d,rm,  0, 0,  d,rm")
+		(match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  "reload_completed"
+  [(parallel [(set (match_dup 3)
+		   (and:SI (match_dup 4)
+			   (match_dup 5)))
+	      (clobber (reg:CC CC_REGNO))])
+   (parallel [(set (match_dup 6)
+		   (and:SI (match_dup 7)
+			   (match_dup 8)))
+	      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart (SImode, operands[1]);
+     operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_expand "iorqi3"
+  [(parallel
+     [(set (match_operand:QI 0 "memory_operand" "")
+	   (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
+		   (match_operand:QI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], QImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+   }")
+
+(define_insn "iorqi3_or1"
+  [(set (match_operand:QI 0 "memory_operand"		      "=m, m")
+	(ior:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "@
+   or.1\\t%0, %2, %1
+   or.1\\t%0, %1, %2")
+
+(define_expand "iorhi3"
+  [(parallel
+     [(set (match_operand:HI 0 "memory_operand" "")
+	   (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
+		   (match_operand:HI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     if (!memory_operand (operands[0], HImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+   }")
+
+(define_insn "iorhi3_or2"
+  [(set (match_operand:HI 0 "memory_operand"		      "=m, m")
+	(ior:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   or.2\\t%0, %2, %1
+   or.2\\t%0, %1, %2")
+
+(define_expand "iorsi3"
+  [(parallel
+     [(set (match_operand:SI 0 "nonimmediate_operand" "")
+	   (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
+		   (match_operand:SI 2 "ubicom32_and_or_si3_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     do
+       {
+	 /* Is this a bset?  */
+	 if (CONST_INT_P (operands[2])
+	     && exact_log2 (INTVAL (operands[2])) != -1)
+	   break;
+
+	 /* Must be an or.4  */
+	 if (!ubicom32_data_register_operand (operands[1], SImode))
+	   operands[1] = copy_to_mode_reg (SImode, operands[1]);
+
+	 if (!ubicom32_arith_operand (operands[2], SImode))
+	   operands[2] = copy_to_mode_reg (SImode, operands[2]);
+       } 
+     while (0);
+   }")
+
+(define_insn "iorsi3_bset"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	      "=rm")
+  	(ior:SI (match_operand:SI 1 "ubicom32_arith_operand" "%rmI")
+		(match_operand 2 "const_int_operand"	        "n")))
+   (clobber (reg:CC CC_REGNO))]
+  "(exact_log2 (INTVAL (operands[2])) != -1)"
+  "bset\\t%0, %1, #%d2")
+
+(define_insn "iorsi3_or4"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	     "=rm,rm")
+	(ior:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   or.4\\t%0, %2, %1
+   or.4\\t%0, %1, %2")
+
+(define_insn "iorsi3_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ior:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"	       "=rm,rm")
+	(ior:SI (match_dup 1)
+		(match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   or.4\\t%0, %2, %1
+   or.4\\t%0, %1, %2")
+
+(define_insn "iorsi3_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ior:SI (match_operand:SI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   or.4\\t#0, %1, %0
+   or.4\\t#0, %0, %1")
+
+(define_expand "iordi3"
+  [(parallel
+     [(set (match_operand:DI 0 "nonimmediate_operand" "")
+	   (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
+		   (match_operand:DI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+   }")
+
+(define_insn_and_split "iordi3_or4"
+  [(set (match_operand:DI 0 "nonimmediate_operand"	     "=&r,&r,  d,rm,  m, m")
+	(ior:DI (match_operand:DI 1 "nonimmediate_operand"    "%d,rm,  0, 0,  d,rm")
+		(match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  "reload_completed"
+  [(parallel [(set (match_dup 3)
+		   (ior:SI (match_dup 4)
+			   (match_dup 5)))
+	      (clobber (reg:CC CC_REGNO))])
+   (parallel [(set (match_dup 6)
+		   (ior:SI (match_dup 7)
+			   (match_dup 8)))
+	      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart (SImode, operands[1]);
+     operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_expand "xorqi3"
+  [(parallel
+     [(set (match_operand:QI 0 "memory_operand" "")
+	   (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
+		   (match_operand:QI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  "(ubicom32_v4)"
+  "{
+     if (!memory_operand (operands[0], QImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (QImode, operands[2]);
+   }")
+
+(define_insn "xorqi3_xor1"
+  [(set (match_operand:QI 0 "memory_operand"		      "=m, m")
+	(xor:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "@
+   xor.1\\t%0, %2, %1
+   xor.1\\t%0, %1, %2")
+
+(define_insn "xorqi3_xor1_ccszn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:QI (match_operand:QI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:QI 0 "memory_operand"		        "=m, m")
+	(xor:QI (match_dup 1)
+		(match_dup 2)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "@
+   xor.1\\t%0, %2, %1
+   xor.1\\t%0, %1, %2")
+
+(define_insn "xorqi3_xor1_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:QI (match_operand:QI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:QI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "@
+   xor.1\\t#0, %1, %0
+   xor.1\\t#0, %0, %1")
+
+(define_insn "xor1_ccszn_null_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
+		    (match_operand:SI 1 "ubicom32_arith_operand"	 "rI"))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "xor.1\\t#0, %1, %0")
+
+(define_insn "xor1_ccszn_null_2"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		    (subreg:SI
+		      (match_operand:QI 1 "memory_operand"		 "m")
+		      0))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "xor.1\\t#0, %1, %0")
+
+(define_insn "xor1_ccwzn_null_3"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:QI
+	    (xor:SI (subreg:SI
+		      (match_operand:QI 0 "memory_operand"		 "m")
+		      0)
+		    (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
+	    3)
+	  (const_int 0)))]
+  "(ubicom32_v4
+    && ubicom32_match_cc_mode(insn, CCSZNmode))"
+  "xor.1\\t#0, %0, %1")
+
+(define_expand "xorhi3"
+  [(parallel
+     [(set (match_operand:HI 0 "memory_operand" "")
+	   (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
+		   (match_operand:HI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     if (!memory_operand (operands[0], HImode))
+       FAIL;
+
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (HImode, operands[2]);
+   }")
+
+(define_insn "xorhi3_xor2"
+  [(set (match_operand:HI 0 "memory_operand"		      "=m, m")
+	(xor:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   xor.2\\t%0, %2, %1
+   xor.2\\t%0, %1, %2")
+
+(define_insn "xorhi3_xor2_ccszn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:HI (match_operand:HI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:HI 0 "memory_operand"		        "=m, m")
+	(xor:HI (match_dup 1)
+		(match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "@
+   xor.2\\t%0, %2, %1
+   xor.2\\t%0, %1, %2")
+
+(define_insn "xorhi3_xor2_ccszn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:HI (match_operand:HI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:HI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "@
+   xor.2\\t#0, %1, %0
+   xor.2\\t#0, %0, %1")
+
+(define_insn "xor2_ccszn_null_1"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
+		    (match_operand:SI 1 "ubicom32_arith_operand"	 "rI"))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "xor.2\\t#0, %1, %0")
+
+(define_insn "xor2_ccszn_null_2"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
+		    (subreg:SI
+		      (match_operand:HI 1 "memory_operand"		 "m")
+		      0))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "xor.2\\t#0, %1, %0")
+
+(define_insn "xor2_ccszn_null_3"
+  [(set (reg CC_REGNO)
+	(compare
+	  (subreg:HI
+	    (xor:SI (subreg:SI
+		      (match_operand:HI 0 "memory_operand"		 "m")
+		      0)
+		    (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
+	    2)
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCSZNmode)"
+  "xor.2\\t#0, %0, %1")
+
+(define_insn "xorsi3"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	     "=rm,rm")
+	(xor:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		(match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "@
+   xor.4\\t%0, %2, %1
+   xor.4\\t%0, %1, %2")
+
+(define_insn "xorsi3_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:SI (match_operand:SI 1 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"	       "=rm,rm")
+	(xor:SI (match_dup 1)
+		(match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   xor.4\\t%0, %2, %1
+   xor.4\\t%0, %1, %2")
+
+(define_insn "xorsi3_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (xor:SI (match_operand:SI 0 "nonimmediate_operand"    "%d,rm")
+		  (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "@
+   xor.4\\t#0, %1, %0
+   xor.4\\t#0, %0, %1")
+
+(define_expand "xordi3"
+  [(parallel
+     [(set (match_operand:DI 0 "nonimmediate_operand" "")
+	   (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
+		   (match_operand:DI 2 "ubicom32_arith_operand" "")))
+      (clobber (reg:CC CC_REGNO))])]
+  ""
+  "{
+     /* If we have a non-data reg for operand 1 then prefer that over
+        a CONST_INT in operand 2.  */
+     if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
+	 && CONST_INT_P (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+
+     if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
+       operands[2] = copy_to_mode_reg (DImode, operands[2]);
+   }")
+
+(define_insn_and_split "xordi3_xor4"
+  [(set (match_operand:DI 0 "nonimmediate_operand"	     "=&r,&r,  d,rm,  m, m")
+	(xor:DI (match_operand:DI 1 "nonimmediate_operand"    "%d,rm,  0, 0,  d,rm")
+		(match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  "reload_completed"
+  [(parallel [(set (match_dup 3)
+		   (xor:SI (match_dup 4)
+			   (match_dup 5)))
+	      (clobber (reg:CC CC_REGNO))])
+   (parallel [(set (match_dup 6)
+		   (xor:SI (match_dup 7)
+			   (match_dup 8)))
+	      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[3] = gen_lowpart (SImode, operands[0]);
+     operands[4] = gen_lowpart (SImode, operands[1]);
+     operands[5] = gen_lowpart (SImode, operands[2]);
+     operands[6] = gen_highpart (SImode, operands[0]);
+     operands[7] = gen_highpart (SImode, operands[1]);
+     operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
+   }"
+  [(set_attr "length" "8")])
+
+(define_insn "not2_2"
+  [(set (match_operand:HI 0 "memory_operand"		        "=m")
+	(subreg:HI
+	  (not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI"))
+	  2))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "not.2\\t%0, %1")
+
+(define_insn "one_cmplsi2"
+  [(set (match_operand:SI 0 "nonimmediate_operand"	     "=rm")
+	(not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "not.4\\t%0, %1")
+
+(define_insn "one_cmplsi2_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "nonimmediate_operand"	       "=rm")
+	(not:SI (match_dup 1)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "not.4\\t%0, %1")
+
+(define_insn "one_cmplsi2_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (not:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI"))
+	  (const_int 0)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "not.4\\t#0, %0")
+
+(define_insn_and_split "one_cmpldi2"
+  [(set (match_operand:DI 0 "nonimmediate_operand"	   "=&rm")
+	(not:DI (match_operand:DI 1 "nonimmediate_operand" "rmI0")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "#"
+  ""
+  [(parallel [(set (match_dup 2)
+		   (not:SI (match_dup 3)))
+	      (clobber (reg:CC CC_REGNO))])
+   (parallel [(set (match_dup 4)
+		   (not:SI (match_dup 5)))
+	      (clobber (reg:CC CC_REGNO))])]
+  "{
+     operands[2] = gen_lowpart (SImode, operands[0]);
+     operands[3] = gen_lowpart (SImode, operands[1]);
+     operands[4] = gen_highpart (SImode, operands[0]);
+     operands[5] = gen_highpart (SImode, operands[1]);
+   }"
+  [(set_attr "length" "8")])
+
+; Conditional jump instructions
+
+(define_expand "beq"
+  [(set (pc)
+	(if_then_else (eq (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (EQ, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bne"
+  [(set (pc)
+	(if_then_else (ne (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (NE, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bgt"
+  [(set (pc)
+	(if_then_else (gt (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (GT, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "ble"
+  [(set (pc)
+	(if_then_else (le (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (LE, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bge"
+  [(set (pc)
+	(if_then_else (ge (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (GE, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "blt"
+  [(set (pc)
+	(if_then_else (lt (match_dup 1)
+			  (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (LT, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bgtu"
+  [(set (pc)
+	(if_then_else (gtu (match_dup 1)
+			   (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (GTU, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bleu"
+  [(set (pc)
+	(if_then_else (leu (match_dup 1)
+			   (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (LEU, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bgeu"
+  [(set (pc)
+	(if_then_else (geu (match_dup 1)
+			   (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (GEU, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_expand "bltu"
+  [(set (pc)
+	(if_then_else (ltu (match_dup 1)
+			   (const_int 0))
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "{
+     operands[1] = ubicom32_gen_compare_reg (LTU, ubicom32_compare_op0,
+					     ubicom32_compare_op1);
+   }")
+
+(define_insn "jcc"
+  [(set (pc)
+	(if_then_else (match_operator 1 "comparison_operator"
+			[(match_operand 2 "ubicom32_cc_register_operand" "")
+			 (const_int 0)])
+		      (label_ref (match_operand 0 "" ""))
+		      (pc)))]
+  ""
+  "*
+   {
+     ubicom32_output_cond_jump (insn, operands[1], operands[0]);
+     return \"\";
+   }")
+
+; Reverse branch - reverse our comparison condition so that we can
+; branch in the opposite sense.
+;
+(define_insn_and_split "jcc_reverse"
+  [(set (pc)
+	(if_then_else (match_operator 1 "comparison_operator"
+			[(match_operand 2 "ubicom32_cc_register_operand" "")
+			 (const_int 0)])
+		      (pc)
+		      (label_ref (match_operand 0 "" ""))))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (pc)
+	(if_then_else (match_dup 3)
+		      (label_ref (match_dup 0))
+		      (pc)))]
+  "{
+     rtx cc_reg;
+
+     cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
+     operands[3] = gen_rtx_fmt_ee (reverse_condition (GET_CODE (operands[1])),
+	 			   GET_MODE (operands[1]),
+				   cc_reg,
+				   const0_rtx);
+   }")
+
+(define_insn "jump"
+  [(set (pc)
+	(label_ref (match_operand 0 "" "")))]
+  ""
+  "jmpt\\t%l0")
+
+(define_expand "indirect_jump"
+  [(parallel [(set (pc)
+  		   (match_operand:SI 0 "register_operand" ""))
+	      (clobber (match_dup 0))])]
+  ""
+  "")
+
+(define_insn "indirect_jump_internal"
+  [(set (pc)
+ 	(match_operand:SI 0 "register_operand" "a"))
+  (clobber (match_dup 0))]
+  ""
+  "calli\\t%0,0(%0)")
+
+; Program Space: The table contains instructions, typically jumps. 
+; CALL An,TABLE_SIZE(PC)	;An = Jump Table Base Address. 
+; <Jump Table is Here>	;An -> Here. 
+; LEA Ak, (An,Dn) 	;Ak -> Table Entry
+; JMP/CALL (Ak) 
+
+(define_expand "tablejump"
+  [(parallel [(set (pc)
+  		   (match_operand:SI 0 "nonimmediate_operand" ""))
+	      (use (label_ref (match_operand 1 "" "")))])]
+  ""
+  "")
+
+(define_insn "tablejump_internal"
+  [(set (pc)
+	(match_operand:SI 0 "nonimmediate_operand" "rm"))
+   (use (label_ref (match_operand 1 "" "")))]
+  ""
+  "ret\\t%0")
+
+; Call subroutine with no return value.
+;
+(define_expand "call"
+  [(call (match_operand:QI 0 "general_operand" "")
+	 (match_operand:SI 1 "general_operand" ""))]
+  ""
+  "{
+     if (TARGET_FDPIC)
+       {
+	 ubicom32_expand_call_fdpic (operands);
+	 DONE;
+       }
+
+     if (! ubicom32_call_address_operand (XEXP (operands[0], 0), VOIDmode))
+       XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
+   }")
+
+; We expand to a simple form that doesn't clobber the link register and
+; then split to a form that does.  This allows the RTL optimizers that
+; run before the splitter to have the opportunity to eliminate the call
+; without marking A5 as being clobbered and this in turn avoids saves
+; and returns in a number of cases.
+;
+(define_insn_and_split "call_1"
+  [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
+	 (match_operand:SI 1 "general_operand"			     "g,g"))]
+  "! TARGET_FDPIC"
+  "#"
+  ""
+  [(parallel
+     [(call (mem:QI (match_dup 0))
+	    (match_dup 1))
+      (clobber (reg:SI LINK_REGNO))])]
+  "")
+
+(define_insn "call_slow"
+  [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
+	 (match_operand:SI 1 "general_operand"			     "g,g"))
+   (clobber (reg:SI LINK_REGNO))]
+  "(! TARGET_FDPIC && ! TARGET_FASTCALL)"
+  "@
+   calli\\ta5, 0(%0)
+   moveai\\ta5, #%%hi(%C0)\;calli\\ta5, %%lo(%C0)(a5)")
+
+(define_insn "call_fast"
+  [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
+	 (match_operand:SI 1 "general_operand"			     "g,g"))
+   (clobber (reg:SI LINK_REGNO))]
+  "(! TARGET_FDPIC && TARGET_FASTCALL)"
+  "@
+   calli\\ta5, 0(%0)
+   call\\ta5, %C0")
+
+; We expand to a simple form that doesn't clobber the link register and
+; then split to a form that does.  This allows the RTL optimizers that
+; run before the splitter to have the opportunity to eliminate the call
+; without marking A5 as being clobbered and this in turn avoids saves
+; and returns in a number of cases.
+;
+(define_insn_and_split "call_fdpic"
+  [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
+	 (match_operand:SI 1 "general_operand"			     "g,g"))
+   (use (match_operand:SI 2 "ubicom32_fdpic_operand"		     "Z,Z"))]
+  "TARGET_FDPIC"
+  "#"
+  ""
+  [(parallel
+     [(call (mem:QI (match_dup 0))
+	    (match_dup 1))
+      (use (match_dup 2))
+      (clobber (reg:SI LINK_REGNO))])]
+  "")
+
+(define_insn "call_fdpic_clobber"
+  [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
+	 (match_operand:SI 1 "general_operand"			     "g,g"))
+   (use (match_operand:SI 2 "ubicom32_fdpic_operand"		     "Z,Z"))
+   (clobber (reg:SI LINK_REGNO))]
+  "TARGET_FDPIC"
+  "@
+   move.4\\ta5, 0(%0)\;move.4\\t%2, 4(%0)\;calli\\ta5, 0(a5)
+   call\\ta5, %C0")
+
+; Call subroutine, returning value in operand 0
+; (which must be a hard register).
+;
+(define_expand "call_value"
+  [(set (match_operand 0 "" "")
+	(call (match_operand:QI 1 "general_operand" "")
+	      (match_operand:SI 2 "general_operand" "")))]
+  ""
+  "{
+     if (TARGET_FDPIC)
+       {
+	 ubicom32_expand_call_value_fdpic (operands);
+	 DONE;
+       }
+
+     if (! ubicom32_call_address_operand (XEXP (operands[1], 0), VOIDmode))
+       XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
+   }")
+
+; We expand to a simple form that doesn't clobber the link register and
+; then split to a form that does.  This allows the RTL optimizers that
+; run before the splitter to have the opportunity to eliminate the call
+; without marking A5 as being clobbered and this in turn avoids saves
+; and returns in a number of cases.
+;
+(define_insn_and_split "call_value_1"
+  [(set (match_operand 0 "register_operand"				 "=r,r")
+	(call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
+	      (match_operand:SI 2 "general_operand"			  "g,g")))]
+  "! TARGET_FDPIC"
+  "#"
+  ""
+  [(parallel
+     [(set (match_dup 0)
+	   (call (mem:QI (match_dup 1))
+		 (match_dup 2)))
+      (clobber (reg:SI LINK_REGNO))])]
+  "")
+
+(define_insn "call_value_slow"
+  [(set (match_operand 0 "register_operand"				 "=r,r")
+	(call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
+	      (match_operand:SI 2 "general_operand"			  "g,g")))
+   (clobber (reg:SI LINK_REGNO))]
+  "(! TARGET_FDPIC && ! TARGET_FASTCALL)"
+  "@
+   calli\\ta5, 0(%1)
+   moveai\\ta5, #%%hi(%C1)\;calli\\ta5, %%lo(%C1)(a5)")
+
+(define_insn "call_value_fast"
+  [(set (match_operand 0 "register_operand"				 "=r,r")
+	(call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
+	      (match_operand:SI 2 "general_operand"			  "g,g")))
+   (clobber (reg:SI LINK_REGNO))]
+  "(! TARGET_FDPIC && TARGET_FASTCALL)"
+  "@
+   calli\\ta5, 0(%1)
+   call\\ta5, %C1")
+
+; We expand to a simple form that doesn't clobber the link register and
+; then split to a form that does.  This allows the RTL optimizers that
+; run before the splitter to have the opportunity to eliminate the call
+; without marking A5 as being clobbered and this in turn avoids saves
+; and returns in a number of cases.
+;
+(define_insn_and_split "call_value_fdpic"
+  [(set (match_operand 0 "register_operand"				 "=r,r")
+	(call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
+	      (match_operand:SI 2 "general_operand"			  "g,g")))
+   (use (match_operand:SI 3 "ubicom32_fdpic_operand"			  "Z,Z"))]
+  "TARGET_FDPIC"
+  "#"
+  ""
+  [(parallel
+     [(set (match_dup 0)
+	   (call (mem:QI (match_dup 1))
+		 (match_dup 2)))
+      (use (match_dup 3))
+      (clobber (reg:SI LINK_REGNO))])]
+  "")
+
+(define_insn "call_value_fdpic_clobber"
+  [(set (match_operand 0 "register_operand"				 "=r,r")
+	(call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
+	      (match_operand:SI 2 "general_operand"			  "g,g")))
+   (use (match_operand:SI 3 "ubicom32_fdpic_operand"			  "Z,Z"))
+   (clobber (reg:SI LINK_REGNO))]
+  "TARGET_FDPIC"
+  "@
+   move.4\\ta5, 0(%1)\;move.4\\t%3, 4(%1)\;calli\\ta5, 0(a5)
+   call\\ta5, %C1")
+
+(define_expand "untyped_call"
+  [(parallel [(call (match_operand 0 "" "")
+                    (const_int 0))
+              (match_operand 1 "" "")
+              (match_operand 2 "" "")])]
+  ""
+  "{
+     int i;
+
+     emit_call_insn (gen_call (operands[0], const0_rtx));
+
+     for (i = 0; i < XVECLEN (operands[2], 0); i++)
+       {
+         rtx set = XVECEXP (operands[2], 0, i);
+         emit_move_insn (SET_DEST (set), SET_SRC (set));
+       }
+     DONE;
+   }")
+
+(define_insn "lsl1_1"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(ashift:SI (subreg:SI
+		     (match_operand:QI 1 "memory_operand"	  "m")
+		     0)
+		   (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "lsl.1\\t%0, %1, %2")
+
+; The combiner gets rather creative about left shifts of sub-word memory
+; operands because it's uncertain about whether the memory is sign or
+; zero extended.  It only wants zero-extended behaviour and so throws
+; in an extra and operation.
+;
+(define_insn "lsl1_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
+	(and:SI
+	  (ashift:SI (subreg:SI
+		       (match_operand:QI 1 "memory_operand"   "m")
+		       0)
+		     (match_operand:SI 2 "const_int_operand"  "M"))
+	  (match_operand:SI 3 "const_int_operand"	      "n")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && INTVAL (operands[3]) == (0xff << INTVAL (operands[2])))"
+  "lsl.1\\t%0, %1, %2")
+
+(define_insn "lsl2_1"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(ashift:SI (subreg:SI
+		     (match_operand:HI 1 "memory_operand"	  "m")
+		     0)
+		   (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "lsl.2\\t%0, %1, %2")
+
+; The combiner gets rather creative about left shifts of sub-word memory
+; operands because it's uncertain about whether the memory is sign or
+; zero extended.  It only wants zero-extended behaviour and so throws
+; in an extra and operation.
+;
+(define_insn "lsl2_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
+	(and:SI
+	  (ashift:SI (subreg:SI
+		       (match_operand:HI 1 "memory_operand"   "m")
+		       0)
+		     (match_operand:SI 2 "const_int_operand"  "M"))
+	  (match_operand:SI 3 "const_int_operand"	      "n")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && INTVAL (operands[3]) == (0xffff << INTVAL (operands[2])))"
+  "lsl.2\\t%0, %1, %2")
+
+(define_insn "ashlsi3"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(ashift:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
+		   (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "lsl.4\\t%0, %1, %2")
+
+(define_insn "lshlsi3_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ashift:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
+		     (match_operand:SI 2 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"	   "=d")
+	(ashift:SI (match_dup 1)
+		   (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "lsl.4\\t%0, %1, %2")
+
+(define_insn "lshlsi3_ccwz_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ashift:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI")
+		     (match_operand:SI 1 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2					   "=d"))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "lsl.4\\t%2, %0, %1")
+
+; The combiner finds this canonical form for what is in essence a right
+; shift.
+;
+(define_insn "asr1_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(sign_extract:SI (match_operand:QI 1 "memory_operand"	  "m")
+			 (match_operand:SI 2 "const_int_operand"  "M")
+			 (match_operand:SI 3 "const_int_operand"  "M")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && (INTVAL (operands[2]) + INTVAL (operands[3]) == 8))"
+  "asr.1\\t%0, %1, %3")
+
+; The combiner finds this canonical form for what is in essence a right
+; shift.
+;
+(define_insn "asr2_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(sign_extract:SI (match_operand:HI 1 "memory_operand"	  "m")
+			 (match_operand:SI 2 "const_int_operand"  "M")
+			 (match_operand:SI 3 "const_int_operand"  "M")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && (INTVAL (operands[2]) + INTVAL (operands[3]) == 16))"
+  "asr.2\\t%0, %1, %3")
+
+(define_insn "ashrsi3"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	   "=d")
+	(ashiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmJ")
+		     (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "asr.4\\t%0, %1, %2")
+
+(define_insn "ashrsi3_ccwzn"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ashiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmJ")
+		       (match_operand:SI 2 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"	     "=d")
+	(ashiftrt:SI (match_dup 1)
+		     (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "asr.4\\t%0, %1, %2")
+
+(define_insn "ashrsi3_ccwzn_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (ashiftrt:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmJ")
+		       (match_operand:SI 1 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2					     "=d"))]
+  "ubicom32_match_cc_mode(insn, CCWZNmode)"
+  "asr.4\\t%2, %0, %1")
+
+(define_insn "lsr1_1"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(lshiftrt:SI (subreg:SI
+		       (match_operand:QI 1 "memory_operand"	  "m")
+		       0)
+		   (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "lsr.1\\t%0, %1, %2")
+
+; The combiner finds this canonical form for what is in essence a right
+; shift.
+;
+(define_insn "lsr1_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(zero_extract:SI (match_operand:QI 1 "memory_operand"	  "m")
+			 (match_operand:SI 2 "const_int_operand"  "M")
+			 (match_operand:SI 3 "const_int_operand"  "M")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && (INTVAL (operands[2]) + INTVAL (operands[3]) == 8))"
+  "lsr.1\\t%0, %1, %3")
+
+(define_insn "lsr2_1"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(lshiftrt:SI (subreg:SI
+		       (match_operand:HI 1 "memory_operand"	  "m")
+		       0)
+		   (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4)"
+  "lsr.2\\t%0, %1, %2")
+
+; The combiner finds this canonical form for what is in essence a right
+; shift.
+;
+(define_insn "lsr2_2"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	 "=d")
+	(zero_extract:SI (match_operand:HI 1 "memory_operand"	  "m")
+			 (match_operand:SI 2 "const_int_operand"  "M")
+			 (match_operand:SI 3 "const_int_operand"  "M")))
+   (clobber (reg:CC CC_REGNO))]
+  "(ubicom32_v4
+    && (INTVAL (operands[2]) + INTVAL (operands[3]) == 16))"
+  "lsr.2\\t%0, %1, %3")
+
+(define_insn "lshrsi3"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	   "=d")
+	(lshiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
+		     (match_operand:SI 2 "ubicom32_arith_operand"  "dM")))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "lsr.4\\t%0, %1, %2")
+
+(define_insn "lshrsi3_ccwz"
+  [(set (reg CC_REGNO)
+	(compare
+	  (lshiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
+		       (match_operand:SI 2 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (set (match_operand:SI 0 "ubicom32_data_register_operand"	     "=d")
+	(lshiftrt:SI (match_dup 1)
+		     (match_dup 2)))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "lsr.4\\t%0, %1, %2")
+
+(define_insn "lshrsi3_ccwz_null"
+  [(set (reg CC_REGNO)
+	(compare
+	  (lshiftrt:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI")
+		       (match_operand:SI 1 "ubicom32_arith_operand"  "dM"))
+	  (const_int 0)))
+   (clobber (match_scratch:SI 2					     "=d"))]
+  "ubicom32_match_cc_mode(insn, CCWZmode)"
+  "lsr.4\\t%2, %0, %1")
+
+(define_expand "prologue"
+  [(const_int 0)]
+  ""
+  "{
+     ubicom32_expand_prologue ();
+     DONE;
+   }")
+
+(define_expand "epilogue"
+  [(return)]
+  ""
+  "{
+     ubicom32_expand_epilogue ();
+     DONE;
+   }")
+
+(define_expand "return"
+  [(return)]
+  ""
+  "{
+     ubicom32_expand_epilogue ();
+     DONE;
+   }")
+
+(define_expand "_eh_return"
+  [(use (match_operand:SI 0 "register_operand" "r"))
+   (use (match_operand:SI 1 "register_operand" "r"))]
+  ""
+  "{
+     ubicom32_expand_eh_return (operands);
+     DONE;
+   }")
+
+; XXX - it looks almost certain that we could make return_internal use a Dn
+; register too.  In that instance we'd have to use a ret instruction
+; rather than a calli but it might save cycles.
+;
+(define_insn "return_internal"
+  [(const_int 2)
+   (return)
+   (use (match_operand:SI 0 "ubicom32_mem_or_address_register_operand" "rm"))]
+  ""
+  "*
+   {
+     if (REG_P (operands[0]) && REGNO (operands[0]) == LINK_REGNO
+	 && ubicom32_can_use_calli_to_ret)
+       return \"calli\\t%0, 0(%0)\";
+
+     return \"ret\\t%0\";
+   }")
+
+(define_insn "return_from_post_modify_sp"
+  [(parallel
+     [(const_int 2)
+      (return)
+      (use (mem:SI (post_modify:SI
+		     (reg:SI SP_REGNO)
+		     (plus:SI (reg:SI SP_REGNO)
+			      (match_operand:SI 0 "const_int_operand" "n")))))])]
+  "INTVAL (operands[0]) >= 4 && INTVAL (operands[0]) <= 7 * 4"
+  "ret\\t(sp)%E0++")
+
+;(define_insn "eh_return_internal"
+;  [(const_int 4)
+;   (return)
+;   (use (reg:SI 34))]
+;  ""
+;  "ret\\ta2")
+
+; No operation, needed in case the user uses -g but not -O.
+(define_expand "nop"
+  [(const_int 0)]
+  ""
+  "")
+
+(define_insn "nop_internal"
+  [(const_int 0)]
+  ""
+  "nop")
+
+; The combiner will generate this pattern given shift and add operations.
+; The canonical form that the combiner wants to use appears to be multiplies
+; instead of shifts even if the compiled sources use shifts.
+;
+(define_insn "shmrg1_add"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	       "=d")
+  	(plus:SI
+	  (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+		   (const_int 256))
+	  (zero_extend:SI
+	    (match_operand:QI 2 "ubicom32_arith_operand"	      "rmI"))))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "shmrg.1\\t%0, %2, %1")
+
+; The combiner will generate this pattern given shift and or operations.
+;
+(define_insn "shmrg1_ior"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"		 "=d")
+  	(ior:SI
+	  (ashift:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+		     (const_int 8))
+	  (zero_extend:SI
+	    (match_operand:QI 2 "ubicom32_arith_operand"		"rmI"))))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "shmrg.1\\t%0, %2, %1")
+
+; The combiner will generate this pattern given shift and add operations.
+; The canonical form that the combiner wants to use appears to be multiplies
+; instead of shifts even if the compiled sources use shifts.
+;
+(define_insn "shmrg2_add"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"	       "=d")
+  	(plus:SI
+	  (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+		   (const_int 65536))
+	  (zero_extend:SI
+	    (match_operand:HI 2 "ubicom32_arith_operand"	      "rmI"))))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "shmrg.2\\t%0, %2, %1")
+
+; The combiner will generate this pattern given shift and or operations.
+;
+(define_insn "shmrg2_ior"
+  [(set (match_operand:SI 0 "ubicom32_data_register_operand"		 "=d")
+  	(ior:SI
+	  (ashift:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
+		     (const_int 16))
+	  (zero_extend:SI
+	    (match_operand:HI 2 "ubicom32_arith_operand"		"rmI"))))
+   (clobber (reg:CC CC_REGNO))]
+  ""
+  "shmrg.2\\t%0, %2, %1")
+
+; Match the case where we load a word from the stack but then discard the
+; upper 16 bits.  We turn this into a zero-extended load of that useful
+; 16 bits direct from the stack where possible.
+;
+
+; XXX - do these peephole2 ops actually work after the CCmode conversion?
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(mem:SI (plus:SI (reg:SI SP_REGNO)
+			 (match_operand:SI 1 "const_int_operand" ""))))
+   (set (match_operand:SI 2 "nonimmediate_operand" "")
+	(zero_extend:SI (match_operand:HI 3 "register_operand" "")))]
+  "(INTVAL (operands[1]) <= 252
+    && REGNO (operands[3]) == REGNO (operands[0])
+    && ((peep2_reg_dead_p (2, operands[0])
+	 && ! reg_mentioned_p (operands[0], operands[2]))
+        || rtx_equal_p (operands[0], operands[2])))"
+  [(set (match_dup 2)
+	(zero_extend:SI (mem:HI (plus:SI (reg:SI SP_REGNO)
+					 (match_dup 4)))))]
+  "{
+     operands[4] = GEN_INT (INTVAL (operands[1]) + 2);
+   }")
+
+; Match the case where we load a word from the stack but then discard the
+; upper 16 bits.  We turn this into a 16-bit load of that useful
+; 16 bits direct from the stack where possible.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(mem:SI (plus:SI (reg:SI SP_REGNO)
+			 (match_operand:SI 1 "const_int_operand" ""))))
+   (set (match_operand:HI 2 "nonimmediate_operand" "")
+	(match_operand:HI 3 "register_operand" ""))]
+  "(INTVAL (operands[1]) <= 252
+    && REGNO (operands[3]) == REGNO (operands[0])
+    && ((peep2_reg_dead_p (2, operands[0])
+	 && ! reg_mentioned_p (operands[0], operands[2]))
+        || rtx_equal_p (operands[0], operands[2])))"
+  [(set (match_dup 2)
+	(mem:HI (plus:SI (reg:SI SP_REGNO)
+			 (match_dup 4))))]
+  "{
+     operands[4] = GEN_INT (INTVAL (operands[1]) + 2);
+   }")
+
+; Match the case where we load a word from the stack but then discard the
+; upper 24 bits.  We turn this into a zero-extended load of that useful
+; 8 bits direct from the stack where possible.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(mem:SI (plus:SI (reg:SI SP_REGNO)
+			 (match_operand:SI 1 "const_int_operand" ""))))
+   (set (match_operand:SI 2 "nonimmediate_operand" "")
+	(zero_extend:SI (match_operand:QI 3 "register_operand" "")))]
+  "(INTVAL (operands[1]) <= 124
+    && REGNO (operands[3]) == REGNO (operands[0])
+    && ((peep2_reg_dead_p (2, operands[0])
+	 && ! reg_mentioned_p (operands[0], operands[2]))
+        || rtx_equal_p (operands[0], operands[2])))"
+  [(set (match_dup 2)
+	(zero_extend:SI (mem:QI (plus:SI (reg:SI SP_REGNO)
+					 (match_dup 4)))))]
+  "{
+     operands[4] = GEN_INT (INTVAL (operands[1]) + 3);
+   }")
+
+; Match the case where we load a word from the stack but then discard the
+; upper 24 bits.  We turn this into an 8-bit load of that useful
+; 8 bits direct from the stack where possible.
+;
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(mem:SI (plus:SI (reg:SI SP_REGNO)
+			 (match_operand:SI 1 "const_int_operand" ""))))
+   (set (match_operand:QI 2 "nonimmediate_operand" "")
+	(match_operand:QI 3 "register_operand" ""))]
+  "(INTVAL (operands[1]) <= 124
+    && REGNO (operands[3]) == REGNO (operands[0])
+    && ((peep2_reg_dead_p (2, operands[0])
+	 && ! reg_mentioned_p (operands[0], operands[2]))
+        || rtx_equal_p (operands[0], operands[2])))"
+  [(set (match_dup 2)
+	(mem:QI (plus:SI (reg:SI SP_REGNO)
+			 (match_dup 4))))]
+  "{
+     operands[4] = GEN_INT (INTVAL (operands[1]) + 3);
+   }")
+
--- /dev/null
+++ b/gcc/config/ubicom32/ubicom32.opt
@@ -0,0 +1,27 @@
+mdebug-address
+Target RejectNegative Report Undocumented Mask(DEBUG_ADDRESS)
+Debug addresses
+
+mdebug-context
+Target RejectNegative Report Undocumented Mask(DEBUG_CONTEXT)
+Debug contexts
+
+march=
+Target Report Var(ubicom32_arch_name) Init("ubicom32v4") Joined
+Specify the name of the target architecture
+
+mfdpic
+Target Report Mask(FDPIC)
+Enable Function Descriptor PIC mode
+
+minline-plt
+Target Report Mask(INLINE_PLT)
+Enable inlining of PLT in function calls
+
+mfastcall
+Target Report Mask(FASTCALL)
+Enable default fast (call) calling sequence for smaller applications
+
+mipos-abi
+Target Report Mask(IPOS_ABI)
+Enable the ipOS ABI in which D10-D13 are caller-clobbered
--- /dev/null
+++ b/gcc/config/ubicom32/uclinux.h
@@ -0,0 +1,67 @@
+/* Definitions of target machine for Ubicom32-uclinux
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
+   Contributed by Ubicom, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Don't assume anything about the header files.  */
+#define NO_IMPLICIT_EXTERN_C
+
+#undef  LIB_SPEC
+#define LIB_SPEC  \
+	"%{pthread:-lpthread} " \
+	"%{!shared:%{!symbolic: -lc}} "
+
+
+#undef LINK_GCC_C_SEQUENCE_SPEC
+#define LINK_GCC_C_SEQUENCE_SPEC \
+  "%{!shared:--start-group} %G %L %{!shared:--end-group}%{shared:%G} "
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+	"%{!shared: crt1%O%s}" \
+	" crti%O%s crtbegin%O%s"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "crtend%O%s crtn%O%s"
+
+/* This macro applies on top of OBJECT_FORMAT_ELF and indicates that
+   we want to support both flat and ELF output.  */
+#define OBJECT_FORMAT_FLAT
+
+#undef DRIVER_SELF_SPECS
+#define DRIVER_SELF_SPECS \
+  "%{!mno-fastcall:-mfastcall}"
+
+/* taken from linux.h */
+/* The GNU C++ standard library requires that these macros be defined.  */
+#undef CPLUSPLUS_CPP_SPEC
+#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
+
+#define TARGET_OS_CPP_BUILTINS()				\
+    do {							\
+	builtin_define_std ("__UBICOM32__");			\
+	builtin_define_std ("__ubicom32__");			\
+	builtin_define ("__gnu_linux__");			\
+	builtin_define_std ("linux");				\
+	builtin_define_std ("unix");				\
+	builtin_assert ("system=linux");			\
+	builtin_assert ("system=unix");				\
+	builtin_assert ("system=posix");			\
+    } while (0)
--- /dev/null
+++ b/gcc/config/ubicom32/xm-ubicom32.h
@@ -0,0 +1,36 @@
+/* Configuration for Ubicom's Ubicom32 architecture.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+   Foundation, Inc.
+   Contributed by Ubicom Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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.
+
+GNU CC 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 GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* #defines that need visibility everywhere.  */
+#define FALSE 0
+#define TRUE 1
+
+/* This describes the machine the compiler is hosted on.  */
+#define HOST_BITS_PER_CHAR 8
+#define HOST_BITS_PER_SHORT 16
+#define HOST_BITS_PER_INT 32
+#define HOST_BITS_PER_LONG 32
+#define HOST_BITS_PER_LONGLONG 64
+
+/* Arguments to use with `exit'.  */
+#define SUCCESS_EXIT_CODE 0
+#define FATAL_EXIT_CODE 33
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2340,6 +2340,34 @@ spu-*-elf*)
 	c_target_objs="${c_target_objs} spu-c.o"
 	cxx_target_objs="${cxx_target_objs} spu-c.o"
 	;;
+ubicom32-*-elf)
+	xm_file=ubicom32/xm-ubicom32.h
+	tm_file="${tm_file} ubicom32/elf.h" # still need dbxelf.h elfos.h
+	tmake_file=ubicom32/t-ubicom32
+	;;
+ubicom32-*-uclinux*)
+	xm_file=ubicom32/xm-ubicom32.h
+	tm_file="${tm_file} ubicom32/elf.h ubicom32/uclinux.h"  # still need dbxelf.h elfos.h linux.h
+	tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+	extra_options="${extra_options} linux.opt"
+	tmake_file=ubicom32/t-ubicom32-uclinux
+	use_collect2=no
+	;;
+ubicom32-*-linux-uclibc)
+	xm_file=ubicom32/xm-ubicom32.h
+	tm_file="${tm_file} ubicom32/elf.h linux.h ubicom32/linux.h"  # still need dbxelf.h elfos.h
+	tmake_file="t-slibgcc-elf-ver ubicom32/t-ubicom32-linux"
+	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+	use_collect2=no
+	;;
+ubicom32-*-linux*)
+	xm_file=ubicom32/xm-ubicom32.h
+	tm_file="${tm_file} ubicom32/elf.h linux.h ubicom32/linux.h"  # still need dbxelf.h elfos.h
+	tmake_file="t-slibgcc-elf-ver ubicom32/t-ubicom32-linux"
+	tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+	use_collect2=no
+	;;
 v850e1-*-*)
 	target_cpu_default="TARGET_CPU_v850e1"
 	tm_file="dbxelf.h elfos.h svr4.h v850/v850.h"
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -551,6 +551,15 @@ sparc64-*-netbsd*)
 	;;
 spu-*-elf*)
 	;;
+ubicom32*-*-elf*)
+	;;
+ubicom32*-*-uclinux*)
+        ;;
+ubicom32*-*-linux*)
+	# No need to build crtbeginT.o on uClibc systems.  Should probably
+	# be moved to the OS specific section above.
+	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+        ;;
 v850e1-*-*)
 	;;
 v850e-*-*)