Add patches against gcc-3.4.6. Untested.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Aug 15 21:23:08 2007 +0000 (2007-08-15)
changeset 339bd5e0a849352
parent 338 43ff52fb85e6
child 340 d930e60e5ff2
Add patches against gcc-3.4.6. Untested.
patches/gcc/3.4.6/100-uclibc-conf.patch
patches/gcc/3.4.6/200-uclibc-locale.patch
patches/gcc/3.4.6/300-libstdc++-pic.patch
patches/gcc/3.4.6/304-index_macro.patch
patches/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch
patches/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch
patches/gcc/3.4.6/601-gcc34-arm-ldm.patch
patches/gcc/3.4.6/602-sdk-libstdc++-includes.patch
patches/gcc/3.4.6/700-pr15068-fix.patch
patches/gcc/3.4.6/71_all_sh-pr16665-fix.patch
patches/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch
patches/gcc/3.4.6/73_all_sh-pr20617.patch
patches/gcc/3.4.6/800-arm-bigendian.patch
patches/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch
patches/gcc/3.4.6/810-mips-xgot.patch
patches/gcc/3.4.6/900-nios2.patch
patches/gcc/3.4.6/arm-softfloat.patch
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gcc/3.4.6/100-uclibc-conf.patch	Wed Aug 15 21:23:08 2007 +0000
     1.3 @@ -0,0 +1,492 @@
     1.4 +diff -durN gcc-3.4.6.orig/boehm-gc/configure gcc-3.4.6/boehm-gc/configure
     1.5 +--- gcc-3.4.6.orig/boehm-gc/configure	2006-03-06 04:55:49.000000000 +0100
     1.6 ++++ gcc-3.4.6/boehm-gc/configure	2007-08-15 22:49:47.000000000 +0200
     1.7 +@@ -1947,6 +1947,11 @@
     1.8 +   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
     1.9 +   ;;
    1.10 + 
    1.11 ++linux-uclibc*)
    1.12 ++  lt_cv_deplibs_check_method=pass_all
    1.13 ++  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
    1.14 ++  ;;
    1.15 ++
    1.16 + netbsd*)
    1.17 +   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
    1.18 +     lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
    1.19 +diff -durN gcc-3.4.6.orig/boehm-gc/ltconfig gcc-3.4.6/boehm-gc/ltconfig
    1.20 +--- gcc-3.4.6.orig/boehm-gc/ltconfig	2002-11-20 16:59:07.000000000 +0100
    1.21 ++++ gcc-3.4.6/boehm-gc/ltconfig	2007-08-15 22:49:47.000000000 +0200
    1.22 +@@ -1981,6 +1981,23 @@
    1.23 +   fi
    1.24 +   ;;
    1.25 + 
    1.26 ++linux-uclibc*)
    1.27 ++  version_type=linux
    1.28 ++  need_lib_prefix=no
    1.29 ++  need_version=no
    1.30 ++  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
    1.31 ++  soname_spec='${libname}${release}.so$major'
    1.32 ++  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
    1.33 ++  shlibpath_var=LD_LIBRARY_PATH
    1.34 ++  shlibpath_overrides_runpath=no
    1.35 ++  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
    1.36 ++  file_magic_cmd=/usr/bin/file
    1.37 ++  file_magic_test_file=`echo /lib/libuClibc-*.so`
    1.38 ++
    1.39 ++  # Assume using the uClibc dynamic linker.
    1.40 ++  dynamic_linker="uClibc ld.so"
    1.41 ++  ;;
    1.42 ++
    1.43 + netbsd*)
    1.44 +   version_type=sunos
    1.45 +   if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
    1.46 +diff -durN gcc-3.4.6.orig/gcc/config/alpha/linux-elf.h gcc-3.4.6/gcc/config/alpha/linux-elf.h
    1.47 +--- gcc-3.4.6.orig/gcc/config/alpha/linux-elf.h	2003-09-27 06:48:30.000000000 +0200
    1.48 ++++ gcc-3.4.6/gcc/config/alpha/linux-elf.h	2007-08-15 22:49:47.000000000 +0200
    1.49 +@@ -27,7 +27,11 @@
    1.50 + #define SUBTARGET_EXTRA_SPECS \
    1.51 + { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
    1.52 + 
    1.53 ++#ifdef USE_UCLIBC
    1.54 ++#define ELF_DYNAMIC_LINKER	"/lib/ld-uClibc.so.0"
    1.55 ++#else
    1.56 + #define ELF_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
    1.57 ++#endif
    1.58 + 
    1.59 + #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax}		\
    1.60 +   %{O*:-O3} %{!O*:-O1}						\
    1.61 +diff -durN gcc-3.4.6.orig/gcc/config/arm/linux-elf.h gcc-3.4.6/gcc/config/arm/linux-elf.h
    1.62 +--- gcc-3.4.6.orig/gcc/config/arm/linux-elf.h	2004-01-31 07:18:40.000000000 +0100
    1.63 ++++ gcc-3.4.6/gcc/config/arm/linux-elf.h	2007-08-15 22:49:47.000000000 +0200
    1.64 +@@ -80,6 +80,11 @@
    1.65 + #define ENDFILE_SPEC \
    1.66 +   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
    1.67 + 
    1.68 ++#ifdef USE_UCLIBC
    1.69 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
    1.70 ++#else
    1.71 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
    1.72 ++#endif
    1.73 + #undef  LINK_SPEC
    1.74 + #define LINK_SPEC "%{h*} %{version:-v} \
    1.75 +    %{b} %{Wl,*:%*} \
    1.76 +@@ -87,7 +92,7 @@
    1.77 +    %{shared:-shared} \
    1.78 +    %{symbolic:-Bsymbolic} \
    1.79 +    %{rdynamic:-export-dynamic} \
    1.80 +-   %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
    1.81 ++   %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "} \
    1.82 +    -X \
    1.83 +    %{mbig-endian:-EB}" \
    1.84 +    SUBTARGET_EXTRA_LINK_SPEC
    1.85 +diff -durN gcc-3.4.6.orig/gcc/config/cris/linux.h gcc-3.4.6/gcc/config/cris/linux.h
    1.86 +--- gcc-3.4.6.orig/gcc/config/cris/linux.h	2003-11-29 04:08:13.000000000 +0100
    1.87 ++++ gcc-3.4.6/gcc/config/cris/linux.h	2007-08-15 22:49:47.000000000 +0200
    1.88 +@@ -79,6 +79,25 @@
    1.89 + #undef CRIS_DEFAULT_CPU_VERSION
    1.90 + #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
    1.91 + 
    1.92 ++#ifdef USE_UCLIBC
    1.93 ++
    1.94 ++#undef CRIS_SUBTARGET_VERSION
    1.95 ++#define CRIS_SUBTARGET_VERSION " - cris-axis-linux-uclibc"
    1.96 ++
    1.97 ++#undef CRIS_LINK_SUBTARGET_SPEC
    1.98 ++#define CRIS_LINK_SUBTARGET_SPEC \
    1.99 ++ "-mcrislinux\
   1.100 ++  -rpath-link include/asm/../..%s\
   1.101 ++  %{shared} %{static}\
   1.102 ++  %{symbolic:-Bdynamic} %{shlib:-Bdynamic} %{static:-Bstatic}\
   1.103 ++  %{!shared: \
   1.104 ++    %{!static: \
   1.105 ++      %{rdynamic:-export-dynamic} \
   1.106 ++      %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}} \
   1.107 ++  %{!r:%{O2|O3: --gc-sections}}"
   1.108 ++
   1.109 ++#else  /* USE_UCLIBC */
   1.110 ++
   1.111 + #undef CRIS_SUBTARGET_VERSION
   1.112 + #define CRIS_SUBTARGET_VERSION " - cris-axis-linux-gnu"
   1.113 + 
   1.114 +@@ -93,6 +112,8 @@
   1.115 +   %{!shared:%{!static:%{rdynamic:-export-dynamic}}}\
   1.116 +   %{!r:%{O2|O3: --gc-sections}}"
   1.117 + 
   1.118 ++#endif  /* USE_UCLIBC */
   1.119 ++
   1.120 + 
   1.121 + /* Node: Run-time Target */
   1.122 + 
   1.123 +diff -durN gcc-3.4.6.orig/gcc/config/i386/linux64.h gcc-3.4.6/gcc/config/i386/linux64.h
   1.124 +--- gcc-3.4.6.orig/gcc/config/i386/linux64.h	2003-11-29 04:08:13.000000000 +0100
   1.125 ++++ gcc-3.4.6/gcc/config/i386/linux64.h	2007-08-15 22:49:47.000000000 +0200
   1.126 +@@ -54,14 +54,21 @@
   1.127 +    When the -shared link option is used a final link is not being
   1.128 +    done.  */
   1.129 + 
   1.130 ++#ifdef USE_UCLIBC
   1.131 ++#define ELF32_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.132 ++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
   1.133 ++#else
   1.134 ++#define ELF32_DYNAMIC_LINKER "/lib/ld-linux.so.2"
   1.135 ++#define ELF64_DYNAMIC_LINKER "/lib64/ld-linux-x86-64.so.2"
   1.136 ++#endif
   1.137 + #undef	LINK_SPEC
   1.138 + #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
   1.139 +   %{shared:-shared} \
   1.140 +   %{!shared: \
   1.141 +     %{!static: \
   1.142 +       %{rdynamic:-export-dynamic} \
   1.143 +-      %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
   1.144 +-      %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
   1.145 ++      %{m32:%{!dynamic-linker:-dynamic-linker " ELF32_DYNAMIC_LINKER "}} \
   1.146 ++      %{!m32:%{!dynamic-linker:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}} \
   1.147 +     %{static:-static}}"
   1.148 + 
   1.149 + #define MULTILIB_DEFAULTS { "m64" }
   1.150 +diff -durN gcc-3.4.6.orig/gcc/config/i386/linux.h gcc-3.4.6/gcc/config/i386/linux.h
   1.151 +--- gcc-3.4.6.orig/gcc/config/i386/linux.h	2003-11-29 04:08:13.000000000 +0100
   1.152 ++++ gcc-3.4.6/gcc/config/i386/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.153 +@@ -110,22 +110,21 @@
   1.154 + 
   1.155 + #undef	LINK_SPEC
   1.156 + #ifdef USE_GNULIBC_1
   1.157 +-#define LINK_SPEC "-m elf_i386 %{shared:-shared} \
   1.158 +-  %{!shared: \
   1.159 +-    %{!ibcs: \
   1.160 +-      %{!static: \
   1.161 +-	%{rdynamic:-export-dynamic} \
   1.162 +-	%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
   1.163 +-	%{static:-static}}}"
   1.164 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.1"
   1.165 + #else
   1.166 ++#ifdef USE_UCLIBC
   1.167 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.168 ++#else
   1.169 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
   1.170 ++#endif
   1.171 ++#endif
   1.172 + #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
   1.173 +   %{!shared: \
   1.174 +     %{!ibcs: \
   1.175 +       %{!static: \
   1.176 + 	%{rdynamic:-export-dynamic} \
   1.177 +-	%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
   1.178 ++	%{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.179 + 	%{static:-static}}}"
   1.180 +-#endif
   1.181 + 
   1.182 + /* A C statement (sans semicolon) to output to the stdio stream
   1.183 +    FILE the assembler definition of uninitialized global DECL named
   1.184 +diff -durN gcc-3.4.6.orig/gcc/config/ia64/linux.h gcc-3.4.6/gcc/config/ia64/linux.h
   1.185 +--- gcc-3.4.6.orig/gcc/config/ia64/linux.h	2004-02-07 08:56:17.000000000 +0100
   1.186 ++++ gcc-3.4.6/gcc/config/ia64/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.187 +@@ -37,13 +37,18 @@
   1.188 + /* Define this for shared library support because it isn't in the main
   1.189 +    linux.h file.  */
   1.190 + 
   1.191 ++#ifdef USE_UCLIBC
   1.192 ++#define ELF_DYNAMIC_LINKER	"/lib/ld-uClibc.so.0"
   1.193 ++#else
   1.194 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
   1.195 ++#endif
   1.196 + #undef LINK_SPEC
   1.197 + #define LINK_SPEC "\
   1.198 +   %{shared:-shared} \
   1.199 +   %{!shared: \
   1.200 +     %{!static: \
   1.201 +       %{rdynamic:-export-dynamic} \
   1.202 +-      %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
   1.203 ++      %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.204 +       %{static:-static}}"
   1.205 + 
   1.206 + 
   1.207 +diff -durN gcc-3.4.6.orig/gcc/config/m68k/linux.h gcc-3.4.6/gcc/config/m68k/linux.h
   1.208 +--- gcc-3.4.6.orig/gcc/config/m68k/linux.h	2003-11-29 04:08:13.000000000 +0100
   1.209 ++++ gcc-3.4.6/gcc/config/m68k/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.210 +@@ -131,12 +131,17 @@
   1.211 + 
   1.212 + /* If ELF is the default format, we should not use /lib/elf.  */
   1.213 + 
   1.214 ++#ifdef USE_UCLIBC
   1.215 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.216 ++#else
   1.217 ++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
   1.218 ++#endif
   1.219 + #undef	LINK_SPEC
   1.220 + #define LINK_SPEC "-m m68kelf %{shared} \
   1.221 +   %{!shared: \
   1.222 +     %{!static: \
   1.223 +       %{rdynamic:-export-dynamic} \
   1.224 +-      %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
   1.225 ++      %{!dynamic-linker*:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.226 +     %{static}}"
   1.227 + 
   1.228 + /* For compatibility with linux/a.out */
   1.229 +diff -durN gcc-3.4.6.orig/gcc/config/mips/linux.h gcc-3.4.6/gcc/config/mips/linux.h
   1.230 +--- gcc-3.4.6.orig/gcc/config/mips/linux.h	2004-06-16 03:42:25.000000000 +0200
   1.231 ++++ gcc-3.4.6/gcc/config/mips/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.232 +@@ -109,6 +109,11 @@
   1.233 + 
   1.234 + /* Borrowed from sparc/linux.h */
   1.235 + #undef LINK_SPEC
   1.236 ++#ifdef USE_UCLIBC
   1.237 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.238 ++#else
   1.239 ++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
   1.240 ++#endif
   1.241 + #define LINK_SPEC \
   1.242 +  "%(endian_spec) \
   1.243 +   %{shared:-shared} \
   1.244 +@@ -116,7 +121,7 @@
   1.245 +     %{!ibcs: \
   1.246 +       %{!static: \
   1.247 +         %{rdynamic:-export-dynamic} \
   1.248 +-        %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
   1.249 ++        %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.250 +         %{static:-static}}}"
   1.251 + 
   1.252 + #undef SUBTARGET_ASM_SPEC
   1.253 +diff -durN gcc-3.4.6.orig/gcc/config/pa/pa-linux.h gcc-3.4.6/gcc/config/pa/pa-linux.h
   1.254 +--- gcc-3.4.6.orig/gcc/config/pa/pa-linux.h	2003-11-29 04:08:13.000000000 +0100
   1.255 ++++ gcc-3.4.6/gcc/config/pa/pa-linux.h	2007-08-15 22:49:47.000000000 +0200
   1.256 +@@ -77,13 +77,18 @@
   1.257 + /* Define this for shared library support because it isn't in the main
   1.258 +    linux.h file.  */
   1.259 + 
   1.260 ++#ifdef USE_UCLIBC
   1.261 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.262 ++#else
   1.263 ++#define ELF_DYNAMIC_LINKER "/lib/ld.so.1"
   1.264 ++#endif
   1.265 + #undef LINK_SPEC
   1.266 + #define LINK_SPEC "\
   1.267 +   %{shared:-shared} \
   1.268 +   %{!shared: \
   1.269 +     %{!static: \
   1.270 +       %{rdynamic:-export-dynamic} \
   1.271 +-      %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
   1.272 ++      %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.273 +       %{static:-static}}"
   1.274 + 
   1.275 + /* glibc's profiling functions don't need gcc to allocate counters.  */
   1.276 +diff -durN gcc-3.4.6.orig/gcc/config/rs6000/linux.h gcc-3.4.6/gcc/config/rs6000/linux.h
   1.277 +--- gcc-3.4.6.orig/gcc/config/rs6000/linux.h	2005-03-17 11:41:18.000000000 +0100
   1.278 ++++ gcc-3.4.6/gcc/config/rs6000/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.279 +@@ -69,7 +69,11 @@
   1.280 + #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
   1.281 + 
   1.282 + #undef	LINK_OS_DEFAULT_SPEC
   1.283 ++#ifdef USE_UCLIBC
   1.284 ++#define LINK_OS_DEFAULT_SPEC "%(link_os_linux_uclibc)"
   1.285 ++#else
   1.286 + #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
   1.287 ++#endif
   1.288 + 
   1.289 + #define LINK_GCC_C_SEQUENCE_SPEC \
   1.290 +   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
   1.291 +diff -durN gcc-3.4.6.orig/gcc/config/rs6000/sysv4.h gcc-3.4.6/gcc/config/rs6000/sysv4.h
   1.292 +--- gcc-3.4.6.orig/gcc/config/rs6000/sysv4.h	2005-10-30 00:35:37.000000000 +0200
   1.293 ++++ gcc-3.4.6/gcc/config/rs6000/sysv4.h	2007-08-15 22:49:47.000000000 +0200
   1.294 +@@ -949,6 +949,7 @@
   1.295 +   mcall-linux  : %(link_os_linux)       ; \
   1.296 +   mcall-gnu    : %(link_os_gnu)         ; \
   1.297 +   mcall-netbsd : %(link_os_netbsd)      ; \
   1.298 ++  mcall-linux-uclibc : %(link_os_linux_uclibc); \
   1.299 +   mcall-openbsd: %(link_os_openbsd)     ; \
   1.300 +                : %(link_os_default)     }"
   1.301 + 
   1.302 +@@ -1127,6 +1128,10 @@
   1.303 +   %{rdynamic:-export-dynamic} \
   1.304 +   %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
   1.305 + 
   1.306 ++#define LINK_OS_LINUX_UCLIBC_SPEC "-m elf32ppclinux %{!shared: %{!static: \
   1.307 ++  %{rdynamic:-export-dynamic} \
   1.308 ++  %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}}}"
   1.309 ++
   1.310 + #if defined(HAVE_LD_EH_FRAME_HDR)
   1.311 + # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
   1.312 + #endif
   1.313 +@@ -1293,6 +1298,7 @@
   1.314 +   { "link_os_sim",		LINK_OS_SIM_SPEC },			\
   1.315 +   { "link_os_freebsd",		LINK_OS_FREEBSD_SPEC },			\
   1.316 +   { "link_os_linux",		LINK_OS_LINUX_SPEC },			\
   1.317 ++  { "link_os_linux_uclibc",	LINK_OS_LINUX_UCLIBC_SPEC },		\
   1.318 +   { "link_os_gnu",		LINK_OS_GNU_SPEC },			\
   1.319 +   { "link_os_netbsd",		LINK_OS_NETBSD_SPEC },			\
   1.320 +   { "link_os_openbsd",		LINK_OS_OPENBSD_SPEC },			\
   1.321 +diff -durN gcc-3.4.6.orig/gcc/config/s390/linux.h gcc-3.4.6/gcc/config/s390/linux.h
   1.322 +--- gcc-3.4.6.orig/gcc/config/s390/linux.h	2003-11-29 04:08:13.000000000 +0100
   1.323 ++++ gcc-3.4.6/gcc/config/s390/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.324 +@@ -77,6 +77,13 @@
   1.325 + #define MULTILIB_DEFAULTS { "m31" }
   1.326 + #endif
   1.327 + 
   1.328 ++#ifdef USE_UCLIBC
   1.329 ++#define ELF31_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.330 ++#define ELF64_DYNAMIC_LINKER "/lib/ld64-uClibc.so.0"
   1.331 ++#else
   1.332 ++#define ELF31_DYNAMIC_LINKER "/lib/ld.so.1"
   1.333 ++#define ELF64_DYNAMIC_LINKER "/lib/ld64.so.1"
   1.334 ++#endif
   1.335 + #undef  LINK_SPEC
   1.336 + #define LINK_SPEC \
   1.337 +   "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
   1.338 +@@ -86,8 +93,8 @@
   1.339 +       %{!static: \
   1.340 + 	%{rdynamic:-export-dynamic} \
   1.341 + 	%{!dynamic-linker: \
   1.342 +-          %{m31:-dynamic-linker /lib/ld.so.1} \
   1.343 +-          %{m64:-dynamic-linker /lib/ld64.so.1}}}}"
   1.344 ++          %{m31:-dynamic-linker " ELF31_DYNAMIC_LINKER "} \
   1.345 ++          %{m64:-dynamic-linker " ELF64_DYNAMIC_LINKER "}}}}"
   1.346 + 
   1.347 + 
   1.348 + #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
   1.349 +diff -durN gcc-3.4.6.orig/gcc/config/sh/linux.h gcc-3.4.6/gcc/config/sh/linux.h
   1.350 +--- gcc-3.4.6.orig/gcc/config/sh/linux.h	2004-01-12 03:29:13.000000000 +0100
   1.351 ++++ gcc-3.4.6/gcc/config/sh/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.352 +@@ -73,11 +73,16 @@
   1.353 + #undef SUBTARGET_LINK_EMUL_SUFFIX
   1.354 + #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
   1.355 + #undef SUBTARGET_LINK_SPEC
   1.356 ++#ifdef USE_UCLIBC
   1.357 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.358 ++#else
   1.359 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
   1.360 ++#endif
   1.361 + #define SUBTARGET_LINK_SPEC \
   1.362 +   "%{shared:-shared} \
   1.363 +    %{!static: \
   1.364 +      %{rdynamic:-export-dynamic} \
   1.365 +-     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
   1.366 ++     %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.367 +    %{static:-static}"
   1.368 + 
   1.369 + #undef LIB_SPEC
   1.370 +diff -durN gcc-3.4.6.orig/gcc/config/sparc/linux64.h gcc-3.4.6/gcc/config/sparc/linux64.h
   1.371 +--- gcc-3.4.6.orig/gcc/config/sparc/linux64.h	2004-06-06 05:55:17.000000000 +0200
   1.372 ++++ gcc-3.4.6/gcc/config/sparc/linux64.h	2007-08-15 22:49:47.000000000 +0200
   1.373 +@@ -167,12 +167,17 @@
   1.374 +   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },	  \
   1.375 +   { "link_arch",	 LINK_ARCH_SPEC },
   1.376 +     
   1.377 ++#ifdef USE_UCLIBC
   1.378 ++#define ELF_DYNAMIC_LINKER	"/lib/ld-uClibc.so.0"
   1.379 ++#else
   1.380 ++#define ELF_DYNAMIC_LINKER  "/lib/ld-linux.so.2"
   1.381 ++#endif
   1.382 + #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
   1.383 +   %{!shared: \
   1.384 +     %{!ibcs: \
   1.385 +       %{!static: \
   1.386 +         %{rdynamic:-export-dynamic} \
   1.387 +-        %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
   1.388 ++        %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.389 +         %{static:-static}}} \
   1.390 + "
   1.391 + 
   1.392 +diff -durN gcc-3.4.6.orig/gcc/config/sparc/linux.h gcc-3.4.6/gcc/config/sparc/linux.h
   1.393 +--- gcc-3.4.6.orig/gcc/config/sparc/linux.h	2004-06-06 05:55:17.000000000 +0200
   1.394 ++++ gcc-3.4.6/gcc/config/sparc/linux.h	2007-08-15 22:49:47.000000000 +0200
   1.395 +@@ -162,13 +162,18 @@
   1.396 +         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
   1.397 +         %{static:-static}}}"
   1.398 + #else
   1.399 ++#ifdef USE_UCLIBC
   1.400 ++#define ELF_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
   1.401 ++#else
   1.402 ++#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2"
   1.403 ++#endif
   1.404 + #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
   1.405 +   %{!mno-relax:%{!r:-relax}} \
   1.406 +   %{!shared: \
   1.407 +     %{!ibcs: \
   1.408 +       %{!static: \
   1.409 +         %{rdynamic:-export-dynamic} \
   1.410 +-        %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
   1.411 ++        %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "}} \
   1.412 +         %{static:-static}}}"
   1.413 + #endif
   1.414 + 
   1.415 +diff -durN gcc-3.4.6.orig/gcc/config/t-linux-uclibc gcc-3.4.6/gcc/config/t-linux-uclibc
   1.416 +--- gcc-3.4.6.orig/gcc/config/t-linux-uclibc	1970-01-01 01:00:00.000000000 +0100
   1.417 ++++ gcc-3.4.6/gcc/config/t-linux-uclibc	2007-08-15 22:49:47.000000000 +0200
   1.418 +@@ -0,0 +1,5 @@
   1.419 ++# Remove glibc specific files added in t-linux
   1.420 ++SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES))
   1.421 ++
   1.422 ++# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc
   1.423 ++LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH))
   1.424 +diff -durN gcc-3.4.6.orig/gcc/config.gcc gcc-3.4.6/gcc/config.gcc
   1.425 +--- gcc-3.4.6.orig/gcc/config.gcc	2005-07-19 23:08:48.000000000 +0200
   1.426 ++++ gcc-3.4.6/gcc/config.gcc	2007-08-15 22:49:47.000000000 +0200
   1.427 +@@ -2322,6 +2322,12 @@
   1.428 + 	;;
   1.429 + esac
   1.430 + 
   1.431 ++# Rather than hook into each target, just do it after all the linux
   1.432 ++# targets have been processed
   1.433 ++case ${target} in
   1.434 ++*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc"
   1.435 ++esac
   1.436 ++
   1.437 + # Support for --with-cpu and related options (and a few unrelated options,
   1.438 + # too).
   1.439 + case ${with_cpu} in
   1.440 +diff -durN gcc-3.4.6.orig/libtool.m4 gcc-3.4.6/libtool.m4
   1.441 +--- gcc-3.4.6.orig/libtool.m4	2004-05-18 11:09:14.000000000 +0200
   1.442 ++++ gcc-3.4.6/libtool.m4	2007-08-15 22:49:47.000000000 +0200
   1.443 +@@ -689,6 +689,11 @@
   1.444 +   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   1.445 +   ;;
   1.446 + 
   1.447 ++linux-uclibc*)
   1.448 ++  lt_cv_deplibs_check_method=pass_all
   1.449 ++  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
   1.450 ++  ;;
   1.451 ++
   1.452 + netbsd*)
   1.453 +   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
   1.454 +     [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
   1.455 +diff -durN gcc-3.4.6.orig/ltconfig gcc-3.4.6/ltconfig
   1.456 +--- gcc-3.4.6.orig/ltconfig	2004-03-05 22:05:41.000000000 +0100
   1.457 ++++ gcc-3.4.6/ltconfig	2007-08-15 22:49:47.000000000 +0200
   1.458 +@@ -602,6 +602,7 @@
   1.459 + 
   1.460 + # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
   1.461 + case $host_os in
   1.462 ++linux-uclibc*) ;;
   1.463 + linux-gnu*) ;;
   1.464 + linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
   1.465 + esac
   1.466 +@@ -1262,6 +1263,24 @@
   1.467 +   dynamic_linker='GNU/Linux ld.so'
   1.468 +   ;;
   1.469 + 
   1.470 ++linux-uclibc*)
   1.471 ++  version_type=linux
   1.472 ++  need_lib_prefix=no
   1.473 ++  need_version=no
   1.474 ++  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
   1.475 ++  soname_spec='${libname}${release}.so$major'
   1.476 ++  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   1.477 ++  shlibpath_var=LD_LIBRARY_PATH
   1.478 ++  shlibpath_overrides_runpath=no
   1.479 ++  # This implies no fast_install, which is unacceptable.
   1.480 ++  # Some rework will be needed to allow for fast_install
   1.481 ++  # before this can be enabled.
   1.482 ++  # Note: copied from linux-gnu, and may not be appropriate.
   1.483 ++  hardcode_into_libs=yes
   1.484 ++  # Assume using the uClibc dynamic linker.
   1.485 ++  dynamic_linker="uClibc ld.so"
   1.486 ++  ;;
   1.487 ++
   1.488 + netbsd*)
   1.489 +   need_lib_prefix=no
   1.490 +   need_version=no
   1.491 +diff -durN gcc-3.4.6.orig/null gcc-3.4.6/null
   1.492 +--- gcc-3.4.6.orig/null	1970-01-01 01:00:00.000000000 +0100
   1.493 ++++ gcc-3.4.6/null	2007-08-15 22:49:47.000000000 +0200
   1.494 +@@ -0,0 +1 @@
   1.495 ++~/dev
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/gcc/3.4.6/200-uclibc-locale.patch	Wed Aug 15 21:23:08 2007 +0000
     2.3 @@ -0,0 +1,3255 @@
     2.4 +diff -durN gcc-3.4.6.orig/libstdc++-v3/acinclude.m4 gcc-3.4.6/libstdc++-v3/acinclude.m4
     2.5 +--- gcc-3.4.6.orig/libstdc++-v3/acinclude.m4	2004-10-28 23:52:41.000000000 +0200
     2.6 ++++ gcc-3.4.6/libstdc++-v3/acinclude.m4	2007-08-15 22:51:01.000000000 +0200
     2.7 +@@ -1015,7 +1015,7 @@
     2.8 +   AC_MSG_CHECKING([for C locale to use])
     2.9 +   GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
    2.10 +     [use MODEL for target locale package],
    2.11 +-    [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
    2.12 ++    [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
    2.13 +   
    2.14 +   # If they didn't use this option switch, or if they specified --enable
    2.15 +   # with no specific model, we'll have to look for one.  If they
    2.16 +@@ -1031,6 +1031,9 @@
    2.17 +   # Default to "generic".
    2.18 +   if test $enable_clocale_flag = auto; then
    2.19 +     case x${target_os} in
    2.20 ++      x*-uclibc*)
    2.21 ++        enable_clocale_flag=uclibc
    2.22 ++        ;;
    2.23 +       xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
    2.24 +         AC_EGREP_CPP([_GLIBCXX_ok], [
    2.25 +         #include <features.h>
    2.26 +@@ -1157,6 +1160,41 @@
    2.27 +       CTIME_CC=config/locale/generic/time_members.cc
    2.28 +       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
    2.29 +       ;;
    2.30 ++    uclibc)
    2.31 ++      AC_MSG_RESULT(uclibc)
    2.32 ++
    2.33 ++      # Declare intention to use gettext, and add support for specific
    2.34 ++      # languages.
    2.35 ++      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
    2.36 ++      ALL_LINGUAS="de fr"
    2.37 ++
    2.38 ++      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
    2.39 ++      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
    2.40 ++      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
    2.41 ++        USE_NLS=yes
    2.42 ++      fi
    2.43 ++      # Export the build objects.
    2.44 ++      for ling in $ALL_LINGUAS; do \
    2.45 ++        glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
    2.46 ++        glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
    2.47 ++      done
    2.48 ++      AC_SUBST(glibcxx_MOFILES)
    2.49 ++      AC_SUBST(glibcxx_POFILES)
    2.50 ++
    2.51 ++      CLOCALE_H=config/locale/uclibc/c_locale.h
    2.52 ++      CLOCALE_CC=config/locale/uclibc/c_locale.cc
    2.53 ++      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
    2.54 ++      CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
    2.55 ++      CCOLLATE_CC=config/locale/uclibc/collate_members.cc
    2.56 ++      CCTYPE_CC=config/locale/uclibc/ctype_members.cc
    2.57 ++      CMESSAGES_H=config/locale/uclibc/messages_members.h
    2.58 ++      CMESSAGES_CC=config/locale/uclibc/messages_members.cc
    2.59 ++      CMONEY_CC=config/locale/uclibc/monetary_members.cc
    2.60 ++      CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
    2.61 ++      CTIME_H=config/locale/uclibc/time_members.h
    2.62 ++      CTIME_CC=config/locale/uclibc/time_members.cc
    2.63 ++      CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
    2.64 ++      ;;
    2.65 +   esac
    2.66 + 
    2.67 +   # This is where the testsuite looks for locale catalogs, using the
    2.68 +diff -durN gcc-3.4.6.orig/libstdc++-v3/aclocal.m4 gcc-3.4.6/libstdc++-v3/aclocal.m4
    2.69 +--- gcc-3.4.6.orig/libstdc++-v3/aclocal.m4	2004-10-28 23:52:41.000000000 +0200
    2.70 ++++ gcc-3.4.6/libstdc++-v3/aclocal.m4	2007-08-15 22:51:01.000000000 +0200
    2.71 +@@ -1044,6 +1044,9 @@
    2.72 +   # Default to "generic".
    2.73 +   if test $enable_clocale_flag = auto; then
    2.74 +     case x${target_os} in
    2.75 ++      x*-uclibc*)
    2.76 ++	enable_clocale_flag=uclibc
    2.77 ++	;;
    2.78 +       xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
    2.79 +         AC_EGREP_CPP([_GLIBCXX_ok], [
    2.80 +         #include <features.h>
    2.81 +@@ -1170,6 +1173,41 @@
    2.82 +       CTIME_CC=config/locale/generic/time_members.cc
    2.83 +       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
    2.84 +       ;;
    2.85 ++    uclibc)
    2.86 ++      AC_MSG_RESULT(uclibc)
    2.87 ++
    2.88 ++      # Declare intention to use gettext, and add support for specific
    2.89 ++      # languages.
    2.90 ++      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
    2.91 ++      ALL_LINGUAS="de fr"
    2.92 ++
    2.93 ++      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
    2.94 ++      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
    2.95 ++      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
    2.96 ++        USE_NLS=yes
    2.97 ++      fi
    2.98 ++      # Export the build objects.
    2.99 ++      for ling in $ALL_LINGUAS; do \
   2.100 ++        glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
   2.101 ++        glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
   2.102 ++      done
   2.103 ++      AC_SUBST(glibcxx_MOFILES)
   2.104 ++      AC_SUBST(glibcxx_POFILES)
   2.105 ++
   2.106 ++      CLOCALE_H=config/locale/uclibc/c_locale.h
   2.107 ++      CLOCALE_CC=config/locale/uclibc/c_locale.cc
   2.108 ++      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
   2.109 ++      CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
   2.110 ++      CCOLLATE_CC=config/locale/uclibc/collate_members.cc
   2.111 ++      CCTYPE_CC=config/locale/uclibc/ctype_members.cc
   2.112 ++      CMESSAGES_H=config/locale/uclibc/messages_members.h
   2.113 ++      CMESSAGES_CC=config/locale/uclibc/messages_members.cc
   2.114 ++      CMONEY_CC=config/locale/uclibc/monetary_members.cc
   2.115 ++      CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
   2.116 ++      CTIME_H=config/locale/uclibc/time_members.h
   2.117 ++      CTIME_CC=config/locale/uclibc/time_members.cc
   2.118 ++      CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
   2.119 ++      ;;
   2.120 +   esac
   2.121 + 
   2.122 +   # This is where the testsuite looks for locale catalogs, using the
   2.123 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c_locale.cc
   2.124 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc	1970-01-01 01:00:00.000000000 +0100
   2.125 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c_locale.cc	2007-08-15 22:51:01.000000000 +0200
   2.126 +@@ -0,0 +1,160 @@
   2.127 ++// Wrapper for underlying C-language localization -*- C++ -*-
   2.128 ++
   2.129 ++// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
   2.130 ++//
   2.131 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.132 ++// software; you can redistribute it and/or modify it under the
   2.133 ++// terms of the GNU General Public License as published by the
   2.134 ++// Free Software Foundation; either version 2, or (at your option)
   2.135 ++// any later version.
   2.136 ++
   2.137 ++// This library is distributed in the hope that it will be useful,
   2.138 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.139 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.140 ++// GNU General Public License for more details.
   2.141 ++
   2.142 ++// You should have received a copy of the GNU General Public License along
   2.143 ++// with this library; see the file COPYING.  If not, write to the Free
   2.144 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.145 ++// USA.
   2.146 ++
   2.147 ++// As a special exception, you may use this file as part of a free software
   2.148 ++// library without restriction.  Specifically, if other files instantiate
   2.149 ++// templates or use macros or inline functions from this file, or you compile
   2.150 ++// this file and link it with other files to produce an executable, this
   2.151 ++// file does not by itself cause the resulting executable to be covered by
   2.152 ++// the GNU General Public License.  This exception does not however
   2.153 ++// invalidate any other reasons why the executable file might be covered by
   2.154 ++// the GNU General Public License.
   2.155 ++
   2.156 ++//
   2.157 ++// ISO C++ 14882: 22.8  Standard locale categories.
   2.158 ++//
   2.159 ++
   2.160 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
   2.161 ++
   2.162 ++#include <cerrno>  // For errno
   2.163 ++#include <locale>
   2.164 ++#include <stdexcept>
   2.165 ++#include <langinfo.h>
   2.166 ++#include <bits/c++locale_internal.h>
   2.167 ++
   2.168 ++#ifndef __UCLIBC_HAS_XLOCALE__
   2.169 ++#define __strtol_l(S, E, B, L)      strtol((S), (E), (B))
   2.170 ++#define __strtoul_l(S, E, B, L)     strtoul((S), (E), (B))
   2.171 ++#define __strtoll_l(S, E, B, L)     strtoll((S), (E), (B))
   2.172 ++#define __strtoull_l(S, E, B, L)    strtoull((S), (E), (B))
   2.173 ++#define __strtof_l(S, E, L)         strtof((S), (E))
   2.174 ++#define __strtod_l(S, E, L)         strtod((S), (E))
   2.175 ++#define __strtold_l(S, E, L)        strtold((S), (E))
   2.176 ++#warning should dummy __newlocale check for C|POSIX ?
   2.177 ++#define __newlocale(a, b, c)        NULL
   2.178 ++#define __freelocale(a)             ((void)0)
   2.179 ++#define __duplocale(a)              __c_locale()
   2.180 ++#endif
   2.181 ++
   2.182 ++namespace std 
   2.183 ++{
   2.184 ++  template<>
   2.185 ++    void
   2.186 ++    __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, 
   2.187 ++		   const __c_locale& __cloc)
   2.188 ++    {
   2.189 ++      if (!(__err & ios_base::failbit))
   2.190 ++	{
   2.191 ++	  char* __sanity;
   2.192 ++	  errno = 0;
   2.193 ++	  float __f = __strtof_l(__s, &__sanity, __cloc);
   2.194 ++          if (__sanity != __s && errno != ERANGE)
   2.195 ++	    __v = __f;
   2.196 ++	  else
   2.197 ++	    __err |= ios_base::failbit;
   2.198 ++	}
   2.199 ++    }
   2.200 ++
   2.201 ++  template<>
   2.202 ++    void
   2.203 ++    __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, 
   2.204 ++		   const __c_locale& __cloc)
   2.205 ++    {
   2.206 ++      if (!(__err & ios_base::failbit))
   2.207 ++	{
   2.208 ++	  char* __sanity;
   2.209 ++	  errno = 0;
   2.210 ++	  double __d = __strtod_l(__s, &__sanity, __cloc);
   2.211 ++          if (__sanity != __s && errno != ERANGE)
   2.212 ++	    __v = __d;
   2.213 ++	  else
   2.214 ++	    __err |= ios_base::failbit;
   2.215 ++	}
   2.216 ++    }
   2.217 ++
   2.218 ++  template<>
   2.219 ++    void
   2.220 ++    __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
   2.221 ++		   const __c_locale& __cloc)
   2.222 ++    {
   2.223 ++      if (!(__err & ios_base::failbit))
   2.224 ++	{
   2.225 ++	  char* __sanity;
   2.226 ++	  errno = 0;
   2.227 ++	  long double __ld = __strtold_l(__s, &__sanity, __cloc);
   2.228 ++          if (__sanity != __s && errno != ERANGE)
   2.229 ++	    __v = __ld;
   2.230 ++	  else
   2.231 ++	    __err |= ios_base::failbit;
   2.232 ++	}
   2.233 ++    }
   2.234 ++
   2.235 ++  void
   2.236 ++  locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, 
   2.237 ++				    __c_locale __old)
   2.238 ++  {
   2.239 ++    __cloc = __newlocale(1 << LC_ALL, __s, __old);
   2.240 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.241 ++    if (!__cloc)
   2.242 ++      {
   2.243 ++	// This named locale is not supported by the underlying OS.
   2.244 ++	__throw_runtime_error(__N("locale::facet::_S_create_c_locale "
   2.245 ++			      "name not valid"));
   2.246 ++      }
   2.247 ++#endif
   2.248 ++  }
   2.249 ++  
   2.250 ++  void
   2.251 ++  locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
   2.252 ++  {
   2.253 ++    if (_S_get_c_locale() != __cloc)
   2.254 ++      __freelocale(__cloc); 
   2.255 ++  }
   2.256 ++
   2.257 ++  __c_locale
   2.258 ++  locale::facet::_S_clone_c_locale(__c_locale& __cloc)
   2.259 ++  { return __duplocale(__cloc); }
   2.260 ++} // namespace std
   2.261 ++
   2.262 ++namespace __gnu_cxx
   2.263 ++{
   2.264 ++  const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
   2.265 ++    {
   2.266 ++      "LC_CTYPE", 
   2.267 ++      "LC_NUMERIC",
   2.268 ++      "LC_TIME", 
   2.269 ++      "LC_COLLATE", 
   2.270 ++      "LC_MONETARY",
   2.271 ++      "LC_MESSAGES", 
   2.272 ++#if _GLIBCXX_NUM_CATEGORIES != 0
   2.273 ++      "LC_PAPER", 
   2.274 ++      "LC_NAME", 
   2.275 ++      "LC_ADDRESS",
   2.276 ++      "LC_TELEPHONE", 
   2.277 ++      "LC_MEASUREMENT", 
   2.278 ++      "LC_IDENTIFICATION" 
   2.279 ++#endif
   2.280 ++    };
   2.281 ++}
   2.282 ++
   2.283 ++namespace std
   2.284 ++{
   2.285 ++  const char* const* const locale::_S_categories = __gnu_cxx::category_names;
   2.286 ++}  // namespace std
   2.287 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c_locale.h gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c_locale.h
   2.288 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c_locale.h	1970-01-01 01:00:00.000000000 +0100
   2.289 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c_locale.h	2007-08-15 22:51:01.000000000 +0200
   2.290 +@@ -0,0 +1,115 @@
   2.291 ++// Wrapper for underlying C-language localization -*- C++ -*-
   2.292 ++
   2.293 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
   2.294 ++//
   2.295 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.296 ++// software; you can redistribute it and/or modify it under the
   2.297 ++// terms of the GNU General Public License as published by the
   2.298 ++// Free Software Foundation; either version 2, or (at your option)
   2.299 ++// any later version.
   2.300 ++
   2.301 ++// This library is distributed in the hope that it will be useful,
   2.302 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.303 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.304 ++// GNU General Public License for more details.
   2.305 ++
   2.306 ++// You should have received a copy of the GNU General Public License along
   2.307 ++// with this library; see the file COPYING.  If not, write to the Free
   2.308 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.309 ++// USA.
   2.310 ++
   2.311 ++// As a special exception, you may use this file as part of a free software
   2.312 ++// library without restriction.  Specifically, if other files instantiate
   2.313 ++// templates or use macros or inline functions from this file, or you compile
   2.314 ++// this file and link it with other files to produce an executable, this
   2.315 ++// file does not by itself cause the resulting executable to be covered by
   2.316 ++// the GNU General Public License.  This exception does not however
   2.317 ++// invalidate any other reasons why the executable file might be covered by
   2.318 ++// the GNU General Public License.
   2.319 ++
   2.320 ++//
   2.321 ++// ISO C++ 14882: 22.8  Standard locale categories.
   2.322 ++//
   2.323 ++
   2.324 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
   2.325 ++
   2.326 ++#ifndef _C_LOCALE_H
   2.327 ++#define _C_LOCALE_H 1
   2.328 ++
   2.329 ++#pragma GCC system_header
   2.330 ++
   2.331 ++#include <cstring>              // get std::strlen
   2.332 ++#include <cstdio>               // get std::snprintf or std::sprintf
   2.333 ++#include <clocale>
   2.334 ++#include <langinfo.h>		// For codecvt
   2.335 ++#ifdef __UCLIBC_MJN3_ONLY__
   2.336 ++#warning fix this
   2.337 ++#endif
   2.338 ++#ifdef __UCLIBC_HAS_LOCALE__
   2.339 ++#include <iconv.h>		// For codecvt using iconv, iconv_t
   2.340 ++#endif
   2.341 ++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
   2.342 ++#include <libintl.h> 		// For messages
   2.343 ++#endif
   2.344 ++
   2.345 ++#ifdef __UCLIBC_MJN3_ONLY__
   2.346 ++#warning what is _GLIBCXX_C_LOCALE_GNU for
   2.347 ++#endif
   2.348 ++#define _GLIBCXX_C_LOCALE_GNU 1
   2.349 ++
   2.350 ++#ifdef __UCLIBC_MJN3_ONLY__
   2.351 ++#warning fix categories
   2.352 ++#endif
   2.353 ++// #define _GLIBCXX_NUM_CATEGORIES 6
   2.354 ++#define _GLIBCXX_NUM_CATEGORIES 0
   2.355 ++ 
   2.356 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.357 ++namespace __gnu_cxx
   2.358 ++{
   2.359 ++  extern "C" __typeof(uselocale) __uselocale;
   2.360 ++}
   2.361 ++#endif
   2.362 ++
   2.363 ++namespace std
   2.364 ++{
   2.365 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.366 ++  typedef __locale_t		__c_locale;
   2.367 ++#else
   2.368 ++  typedef int*			__c_locale;
   2.369 ++#endif
   2.370 ++
   2.371 ++  // Convert numeric value of type _Tv to string and return length of
   2.372 ++  // string.  If snprintf is available use it, otherwise fall back to
   2.373 ++  // the unsafe sprintf which, in general, can be dangerous and should
   2.374 ++  // be avoided.
   2.375 ++  template<typename _Tv>
   2.376 ++    int
   2.377 ++    __convert_from_v(char* __out, const int __size, const char* __fmt,
   2.378 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.379 ++		     _Tv __v, const __c_locale& __cloc, int __prec)
   2.380 ++    {
   2.381 ++      __c_locale __old = __gnu_cxx::__uselocale(__cloc);
   2.382 ++#else
   2.383 ++		     _Tv __v, const __c_locale&, int __prec)
   2.384 ++    {
   2.385 ++# ifdef __UCLIBC_HAS_LOCALE__
   2.386 ++      char* __old = std::setlocale(LC_ALL, NULL);
   2.387 ++      char* __sav = new char[std::strlen(__old) + 1];
   2.388 ++      std::strcpy(__sav, __old);
   2.389 ++      std::setlocale(LC_ALL, "C");
   2.390 ++# endif
   2.391 ++#endif
   2.392 ++
   2.393 ++      const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
   2.394 ++
   2.395 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.396 ++      __gnu_cxx::__uselocale(__old);
   2.397 ++#elif defined __UCLIBC_HAS_LOCALE__
   2.398 ++      std::setlocale(LC_ALL, __sav);
   2.399 ++      delete [] __sav;
   2.400 ++#endif
   2.401 ++      return __ret;
   2.402 ++    }
   2.403 ++}
   2.404 ++
   2.405 ++#endif
   2.406 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c++locale_internal.h gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
   2.407 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/c++locale_internal.h	1970-01-01 01:00:00.000000000 +0100
   2.408 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/c++locale_internal.h	2007-08-15 22:51:01.000000000 +0200
   2.409 +@@ -0,0 +1,59 @@
   2.410 ++// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
   2.411 ++
   2.412 ++// Copyright (C) 2002, 2004 Free Software Foundation, Inc.
   2.413 ++//
   2.414 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.415 ++// software; you can redistribute it and/or modify it under the
   2.416 ++// terms of the GNU General Public License as published by the
   2.417 ++// Free Software Foundation; either version 2, or (at your option)
   2.418 ++// any later version.
   2.419 ++
   2.420 ++// This library is distributed in the hope that it will be useful,
   2.421 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.422 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.423 ++// GNU General Public License for more details.
   2.424 ++
   2.425 ++// You should have received a copy of the GNU General Public License along
   2.426 ++// with this library; see the file COPYING.  If not, write to the Free
   2.427 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.428 ++// USA.
   2.429 ++
   2.430 ++// As a special exception, you may use this file as part of a free software
   2.431 ++// library without restriction.  Specifically, if other files instantiate
   2.432 ++// templates or use macros or inline functions from this file, or you compile
   2.433 ++// this file and link it with other files to produce an executable, this
   2.434 ++// file does not by itself cause the resulting executable to be covered by
   2.435 ++// the GNU General Public License.  This exception does not however
   2.436 ++// invalidate any other reasons why the executable file might be covered by
   2.437 ++// the GNU General Public License.
   2.438 ++
   2.439 ++// Written by Jakub Jelinek <jakub@redhat.com>
   2.440 ++
   2.441 ++#include <clocale>
   2.442 ++
   2.443 ++#ifdef __UCLIBC_MJN3_ONLY__
   2.444 ++#warning clean this up
   2.445 ++#endif
   2.446 ++
   2.447 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.448 ++                                                  
   2.449 ++extern "C" __typeof(iswctype_l) __iswctype_l;
   2.450 ++extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
   2.451 ++extern "C" __typeof(strcoll_l) __strcoll_l;
   2.452 ++extern "C" __typeof(strftime_l) __strftime_l;
   2.453 ++extern "C" __typeof(strtod_l) __strtod_l;
   2.454 ++extern "C" __typeof(strtof_l) __strtof_l;
   2.455 ++extern "C" __typeof(strtold_l) __strtold_l;
   2.456 ++extern "C" __typeof(strxfrm_l) __strxfrm_l;
   2.457 ++extern "C" __typeof(towlower_l) __towlower_l;
   2.458 ++extern "C" __typeof(towupper_l) __towupper_l;
   2.459 ++extern "C" __typeof(wcscoll_l) __wcscoll_l;
   2.460 ++extern "C" __typeof(wcsftime_l) __wcsftime_l;
   2.461 ++extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
   2.462 ++extern "C" __typeof(wctype_l) __wctype_l;
   2.463 ++extern "C" __typeof(newlocale) __newlocale;
   2.464 ++extern "C" __typeof(freelocale) __freelocale;
   2.465 ++extern "C" __typeof(duplocale) __duplocale;
   2.466 ++extern "C" __typeof(uselocale) __uselocale;
   2.467 ++
   2.468 ++#endif // GLIBC 2.3 and later
   2.469 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/codecvt_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
   2.470 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/codecvt_members.cc	1970-01-01 01:00:00.000000000 +0100
   2.471 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/codecvt_members.cc	2007-08-15 22:51:01.000000000 +0200
   2.472 +@@ -0,0 +1,306 @@
   2.473 ++// std::codecvt implementation details, GNU version -*- C++ -*-
   2.474 ++
   2.475 ++// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
   2.476 ++//
   2.477 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.478 ++// software; you can redistribute it and/or modify it under the
   2.479 ++// terms of the GNU General Public License as published by the
   2.480 ++// Free Software Foundation; either version 2, or (at your option)
   2.481 ++// any later version.
   2.482 ++
   2.483 ++// This library is distributed in the hope that it will be useful,
   2.484 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.485 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.486 ++// GNU General Public License for more details.
   2.487 ++
   2.488 ++// You should have received a copy of the GNU General Public License along
   2.489 ++// with this library; see the file COPYING.  If not, write to the Free
   2.490 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.491 ++// USA.
   2.492 ++
   2.493 ++// As a special exception, you may use this file as part of a free software
   2.494 ++// library without restriction.  Specifically, if other files instantiate
   2.495 ++// templates or use macros or inline functions from this file, or you compile
   2.496 ++// this file and link it with other files to produce an executable, this
   2.497 ++// file does not by itself cause the resulting executable to be covered by
   2.498 ++// the GNU General Public License.  This exception does not however
   2.499 ++// invalidate any other reasons why the executable file might be covered by
   2.500 ++// the GNU General Public License.
   2.501 ++
   2.502 ++//
   2.503 ++// ISO C++ 14882: 22.2.1.5 - Template class codecvt
   2.504 ++//
   2.505 ++
   2.506 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
   2.507 ++
   2.508 ++#include <locale>
   2.509 ++#include <bits/c++locale_internal.h>
   2.510 ++
   2.511 ++namespace std
   2.512 ++{
   2.513 ++  // Specializations.
   2.514 ++#ifdef _GLIBCXX_USE_WCHAR_T
   2.515 ++  codecvt_base::result
   2.516 ++  codecvt<wchar_t, char, mbstate_t>::
   2.517 ++  do_out(state_type& __state, const intern_type* __from, 
   2.518 ++	 const intern_type* __from_end, const intern_type*& __from_next,
   2.519 ++	 extern_type* __to, extern_type* __to_end,
   2.520 ++	 extern_type*& __to_next) const
   2.521 ++  {
   2.522 ++    result __ret = ok;
   2.523 ++    state_type __tmp_state(__state);
   2.524 ++
   2.525 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.526 ++    __c_locale __old = __uselocale(_M_c_locale_codecvt);
   2.527 ++#endif
   2.528 ++
   2.529 ++    // wcsnrtombs is *very* fast but stops if encounters NUL characters:
   2.530 ++    // in case we fall back to wcrtomb and then continue, in a loop.
   2.531 ++    // NB: wcsnrtombs is a GNU extension
   2.532 ++    for (__from_next = __from, __to_next = __to;
   2.533 ++	 __from_next < __from_end && __to_next < __to_end
   2.534 ++	 && __ret == ok;)
   2.535 ++      {
   2.536 ++	const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
   2.537 ++						      __from_end - __from_next);
   2.538 ++	if (!__from_chunk_end)
   2.539 ++	  __from_chunk_end = __from_end;
   2.540 ++
   2.541 ++	__from = __from_next;
   2.542 ++	const size_t __conv = wcsnrtombs(__to_next, &__from_next,
   2.543 ++					 __from_chunk_end - __from_next,
   2.544 ++					 __to_end - __to_next, &__state);
   2.545 ++	if (__conv == static_cast<size_t>(-1))
   2.546 ++	  {
   2.547 ++	    // In case of error, in order to stop at the exact place we
   2.548 ++	    // have to start again from the beginning with a series of
   2.549 ++	    // wcrtomb.
   2.550 ++	    for (; __from < __from_next; ++__from)
   2.551 ++	      __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
   2.552 ++	    __state = __tmp_state;
   2.553 ++	    __ret = error;
   2.554 ++	  }
   2.555 ++	else if (__from_next && __from_next < __from_chunk_end)
   2.556 ++	  {
   2.557 ++	    __to_next += __conv;
   2.558 ++	    __ret = partial;
   2.559 ++	  }
   2.560 ++	else
   2.561 ++	  {
   2.562 ++	    __from_next = __from_chunk_end;
   2.563 ++	    __to_next += __conv;
   2.564 ++	  }
   2.565 ++
   2.566 ++	if (__from_next < __from_end && __ret == ok)
   2.567 ++	  {
   2.568 ++	    extern_type __buf[MB_LEN_MAX];
   2.569 ++	    __tmp_state = __state;
   2.570 ++	    const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
   2.571 ++	    if (__conv > static_cast<size_t>(__to_end - __to_next))
   2.572 ++	      __ret = partial;
   2.573 ++	    else
   2.574 ++	      {
   2.575 ++		memcpy(__to_next, __buf, __conv);
   2.576 ++		__state = __tmp_state;
   2.577 ++		__to_next += __conv;
   2.578 ++		++__from_next;
   2.579 ++	      }
   2.580 ++	  }
   2.581 ++      }
   2.582 ++
   2.583 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.584 ++    __uselocale(__old);
   2.585 ++#endif
   2.586 ++
   2.587 ++    return __ret; 
   2.588 ++  }
   2.589 ++  
   2.590 ++  codecvt_base::result
   2.591 ++  codecvt<wchar_t, char, mbstate_t>::
   2.592 ++  do_in(state_type& __state, const extern_type* __from, 
   2.593 ++	const extern_type* __from_end, const extern_type*& __from_next,
   2.594 ++	intern_type* __to, intern_type* __to_end,
   2.595 ++	intern_type*& __to_next) const
   2.596 ++  {
   2.597 ++    result __ret = ok;
   2.598 ++    state_type __tmp_state(__state);
   2.599 ++
   2.600 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.601 ++    __c_locale __old = __uselocale(_M_c_locale_codecvt);
   2.602 ++#endif
   2.603 ++
   2.604 ++    // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
   2.605 ++    // in case we store a L'\0' and then continue, in a loop.
   2.606 ++    // NB: mbsnrtowcs is a GNU extension
   2.607 ++    for (__from_next = __from, __to_next = __to;
   2.608 ++	 __from_next < __from_end && __to_next < __to_end
   2.609 ++	 && __ret == ok;)
   2.610 ++      {
   2.611 ++	const extern_type* __from_chunk_end;
   2.612 ++	__from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
   2.613 ++								  __from_end
   2.614 ++								  - __from_next));
   2.615 ++	if (!__from_chunk_end)
   2.616 ++	  __from_chunk_end = __from_end;
   2.617 ++
   2.618 ++	__from = __from_next;
   2.619 ++	size_t __conv = mbsnrtowcs(__to_next, &__from_next,
   2.620 ++				   __from_chunk_end - __from_next,
   2.621 ++				   __to_end - __to_next, &__state);
   2.622 ++	if (__conv == static_cast<size_t>(-1))
   2.623 ++	  {
   2.624 ++	    // In case of error, in order to stop at the exact place we
   2.625 ++	    // have to start again from the beginning with a series of
   2.626 ++	    // mbrtowc.
   2.627 ++	    for (;; ++__to_next, __from += __conv)
   2.628 ++	      {
   2.629 ++		__conv = mbrtowc(__to_next, __from, __from_end - __from,
   2.630 ++				 &__tmp_state);
   2.631 ++		if (__conv == static_cast<size_t>(-1)
   2.632 ++		    || __conv == static_cast<size_t>(-2))
   2.633 ++		  break;
   2.634 ++	      }
   2.635 ++	    __from_next = __from;
   2.636 ++	    __state = __tmp_state;	    
   2.637 ++	    __ret = error;
   2.638 ++	  }
   2.639 ++	else if (__from_next && __from_next < __from_chunk_end)
   2.640 ++	  {
   2.641 ++	    // It is unclear what to return in this case (see DR 382). 
   2.642 ++	    __to_next += __conv;
   2.643 ++	    __ret = partial;
   2.644 ++	  }
   2.645 ++	else
   2.646 ++	  {
   2.647 ++	    __from_next = __from_chunk_end;
   2.648 ++	    __to_next += __conv;
   2.649 ++	  }
   2.650 ++
   2.651 ++	if (__from_next < __from_end && __ret == ok)
   2.652 ++	  {
   2.653 ++	    if (__to_next < __to_end)
   2.654 ++	      {
   2.655 ++		// XXX Probably wrong for stateful encodings
   2.656 ++		__tmp_state = __state;		
   2.657 ++		++__from_next;
   2.658 ++		*__to_next++ = L'\0';
   2.659 ++	      }
   2.660 ++	    else
   2.661 ++	      __ret = partial;
   2.662 ++	  }
   2.663 ++      }
   2.664 ++
   2.665 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.666 ++    __uselocale(__old);
   2.667 ++#endif
   2.668 ++
   2.669 ++    return __ret; 
   2.670 ++  }
   2.671 ++
   2.672 ++  int 
   2.673 ++  codecvt<wchar_t, char, mbstate_t>::
   2.674 ++  do_encoding() const throw()
   2.675 ++  {
   2.676 ++    // XXX This implementation assumes that the encoding is
   2.677 ++    // stateless and is either single-byte or variable-width.
   2.678 ++    int __ret = 0;
   2.679 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.680 ++    __c_locale __old = __uselocale(_M_c_locale_codecvt);
   2.681 ++#endif
   2.682 ++    if (MB_CUR_MAX == 1)
   2.683 ++      __ret = 1;
   2.684 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.685 ++    __uselocale(__old);
   2.686 ++#endif
   2.687 ++    return __ret;
   2.688 ++  }  
   2.689 ++
   2.690 ++  int 
   2.691 ++  codecvt<wchar_t, char, mbstate_t>::
   2.692 ++  do_max_length() const throw()
   2.693 ++  {
   2.694 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.695 ++    __c_locale __old = __uselocale(_M_c_locale_codecvt);
   2.696 ++#endif
   2.697 ++    // XXX Probably wrong for stateful encodings.
   2.698 ++    int __ret = MB_CUR_MAX;
   2.699 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.700 ++    __uselocale(__old);
   2.701 ++#endif
   2.702 ++    return __ret;
   2.703 ++  }
   2.704 ++  
   2.705 ++  int 
   2.706 ++  codecvt<wchar_t, char, mbstate_t>::
   2.707 ++  do_length(state_type& __state, const extern_type* __from,
   2.708 ++	    const extern_type* __end, size_t __max) const
   2.709 ++  {
   2.710 ++    int __ret = 0;
   2.711 ++    state_type __tmp_state(__state);
   2.712 ++
   2.713 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.714 ++    __c_locale __old = __uselocale(_M_c_locale_codecvt);
   2.715 ++#endif
   2.716 ++
   2.717 ++    // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
   2.718 ++    // in case we advance past it and then continue, in a loop.
   2.719 ++    // NB: mbsnrtowcs is a GNU extension
   2.720 ++  
   2.721 ++    // A dummy internal buffer is needed in order for mbsnrtocws to consider
   2.722 ++    // its fourth parameter (it wouldn't with NULL as first parameter).
   2.723 ++    wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t) 
   2.724 ++							   * __max));
   2.725 ++    while (__from < __end && __max)
   2.726 ++      {
   2.727 ++	const extern_type* __from_chunk_end;
   2.728 ++	__from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
   2.729 ++								  __end
   2.730 ++								  - __from));
   2.731 ++	if (!__from_chunk_end)
   2.732 ++	  __from_chunk_end = __end;
   2.733 ++
   2.734 ++	const extern_type* __tmp_from = __from;
   2.735 ++	size_t __conv = mbsnrtowcs(__to, &__from,
   2.736 ++				   __from_chunk_end - __from,
   2.737 ++				   __max, &__state);
   2.738 ++	if (__conv == static_cast<size_t>(-1))
   2.739 ++	  {
   2.740 ++	    // In case of error, in order to stop at the exact place we
   2.741 ++	    // have to start again from the beginning with a series of
   2.742 ++	    // mbrtowc.
   2.743 ++	    for (__from = __tmp_from;; __from += __conv)
   2.744 ++	      {
   2.745 ++		__conv = mbrtowc(NULL, __from, __end - __from,
   2.746 ++				 &__tmp_state);
   2.747 ++		if (__conv == static_cast<size_t>(-1)
   2.748 ++		    || __conv == static_cast<size_t>(-2))
   2.749 ++		  break;
   2.750 ++	      }
   2.751 ++	    __state = __tmp_state;
   2.752 ++	    __ret += __from - __tmp_from;
   2.753 ++	    break;
   2.754 ++	  }
   2.755 ++	if (!__from)
   2.756 ++	  __from = __from_chunk_end;
   2.757 ++	
   2.758 ++	__ret += __from - __tmp_from;
   2.759 ++	__max -= __conv;
   2.760 ++
   2.761 ++	if (__from < __end && __max)
   2.762 ++	  {
   2.763 ++	    // XXX Probably wrong for stateful encodings
   2.764 ++	    __tmp_state = __state;
   2.765 ++	    ++__from;
   2.766 ++	    ++__ret;
   2.767 ++	    --__max;
   2.768 ++	  }
   2.769 ++      }
   2.770 ++
   2.771 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.772 ++    __uselocale(__old);
   2.773 ++#endif
   2.774 ++
   2.775 ++    return __ret; 
   2.776 ++  }
   2.777 ++#endif
   2.778 ++}
   2.779 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/collate_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/collate_members.cc
   2.780 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/collate_members.cc	1970-01-01 01:00:00.000000000 +0100
   2.781 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/collate_members.cc	2007-08-15 22:51:01.000000000 +0200
   2.782 +@@ -0,0 +1,80 @@
   2.783 ++// std::collate implementation details, GNU version -*- C++ -*-
   2.784 ++
   2.785 ++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
   2.786 ++//
   2.787 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.788 ++// software; you can redistribute it and/or modify it under the
   2.789 ++// terms of the GNU General Public License as published by the
   2.790 ++// Free Software Foundation; either version 2, or (at your option)
   2.791 ++// any later version.
   2.792 ++
   2.793 ++// This library is distributed in the hope that it will be useful,
   2.794 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.795 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.796 ++// GNU General Public License for more details.
   2.797 ++
   2.798 ++// You should have received a copy of the GNU General Public License along
   2.799 ++// with this library; see the file COPYING.  If not, write to the Free
   2.800 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.801 ++// USA.
   2.802 ++
   2.803 ++// As a special exception, you may use this file as part of a free software
   2.804 ++// library without restriction.  Specifically, if other files instantiate
   2.805 ++// templates or use macros or inline functions from this file, or you compile
   2.806 ++// this file and link it with other files to produce an executable, this
   2.807 ++// file does not by itself cause the resulting executable to be covered by
   2.808 ++// the GNU General Public License.  This exception does not however
   2.809 ++// invalidate any other reasons why the executable file might be covered by
   2.810 ++// the GNU General Public License.
   2.811 ++
   2.812 ++//
   2.813 ++// ISO C++ 14882: 22.2.4.1.2  collate virtual functions
   2.814 ++//
   2.815 ++
   2.816 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
   2.817 ++
   2.818 ++#include <locale>
   2.819 ++#include <bits/c++locale_internal.h>
   2.820 ++
   2.821 ++#ifndef __UCLIBC_HAS_XLOCALE__
   2.822 ++#define __strcoll_l(S1, S2, L)      strcoll((S1), (S2))
   2.823 ++#define __strxfrm_l(S1, S2, N, L)   strxfrm((S1), (S2), (N))
   2.824 ++#define __wcscoll_l(S1, S2, L)      wcscoll((S1), (S2))
   2.825 ++#define __wcsxfrm_l(S1, S2, N, L)   wcsxfrm((S1), (S2), (N))
   2.826 ++#endif
   2.827 ++
   2.828 ++namespace std
   2.829 ++{
   2.830 ++  // These are basically extensions to char_traits, and perhaps should
   2.831 ++  // be put there instead of here.
   2.832 ++  template<>
   2.833 ++    int 
   2.834 ++    collate<char>::_M_compare(const char* __one, const char* __two) const
   2.835 ++    { 
   2.836 ++      int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
   2.837 ++      return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
   2.838 ++    }
   2.839 ++  
   2.840 ++  template<>
   2.841 ++    size_t
   2.842 ++    collate<char>::_M_transform(char* __to, const char* __from, 
   2.843 ++				size_t __n) const 
   2.844 ++    { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
   2.845 ++
   2.846 ++#ifdef _GLIBCXX_USE_WCHAR_T
   2.847 ++  template<>
   2.848 ++    int 
   2.849 ++    collate<wchar_t>::_M_compare(const wchar_t* __one, 
   2.850 ++				 const wchar_t* __two) const
   2.851 ++    {
   2.852 ++      int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
   2.853 ++      return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
   2.854 ++    }
   2.855 ++  
   2.856 ++  template<>
   2.857 ++    size_t
   2.858 ++    collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
   2.859 ++				   size_t __n) const
   2.860 ++    { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
   2.861 ++#endif
   2.862 ++}
   2.863 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/ctype_members.cc
   2.864 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc	1970-01-01 01:00:00.000000000 +0100
   2.865 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/ctype_members.cc	2007-08-15 22:51:01.000000000 +0200
   2.866 +@@ -0,0 +1,300 @@
   2.867 ++// std::ctype implementation details, GNU version -*- C++ -*-
   2.868 ++
   2.869 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
   2.870 ++//
   2.871 ++// This file is part of the GNU ISO C++ Library.  This library is free
   2.872 ++// software; you can redistribute it and/or modify it under the
   2.873 ++// terms of the GNU General Public License as published by the
   2.874 ++// Free Software Foundation; either version 2, or (at your option)
   2.875 ++// any later version.
   2.876 ++
   2.877 ++// This library is distributed in the hope that it will be useful,
   2.878 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.879 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   2.880 ++// GNU General Public License for more details.
   2.881 ++
   2.882 ++// You should have received a copy of the GNU General Public License along
   2.883 ++// with this library; see the file COPYING.  If not, write to the Free
   2.884 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   2.885 ++// USA.
   2.886 ++
   2.887 ++// As a special exception, you may use this file as part of a free software
   2.888 ++// library without restriction.  Specifically, if other files instantiate
   2.889 ++// templates or use macros or inline functions from this file, or you compile
   2.890 ++// this file and link it with other files to produce an executable, this
   2.891 ++// file does not by itself cause the resulting executable to be covered by
   2.892 ++// the GNU General Public License.  This exception does not however
   2.893 ++// invalidate any other reasons why the executable file might be covered by
   2.894 ++// the GNU General Public License.
   2.895 ++
   2.896 ++//
   2.897 ++// ISO C++ 14882: 22.2.1.1.2  ctype virtual functions.
   2.898 ++//
   2.899 ++
   2.900 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
   2.901 ++
   2.902 ++#define _LIBC
   2.903 ++#include <locale>
   2.904 ++#undef _LIBC
   2.905 ++#include <bits/c++locale_internal.h>
   2.906 ++
   2.907 ++#ifndef __UCLIBC_HAS_XLOCALE__
   2.908 ++#define __wctype_l(S, L)           wctype((S))
   2.909 ++#define __towupper_l(C, L)         towupper((C))
   2.910 ++#define __towlower_l(C, L)         towlower((C))
   2.911 ++#define __iswctype_l(C, M, L)      iswctype((C), (M))
   2.912 ++#endif
   2.913 ++
   2.914 ++namespace std
   2.915 ++{
   2.916 ++  // NB: The other ctype<char> specializations are in src/locale.cc and
   2.917 ++  // various /config/os/* files.
   2.918 ++  template<>
   2.919 ++    ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
   2.920 ++    : ctype<char>(0, false, __refs) 
   2.921 ++    { 		
   2.922 ++      if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
   2.923 ++	{
   2.924 ++	  this->_S_destroy_c_locale(this->_M_c_locale_ctype);
   2.925 ++	  this->_S_create_c_locale(this->_M_c_locale_ctype, __s); 
   2.926 ++#ifdef __UCLIBC_HAS_XLOCALE__
   2.927 ++	  this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
   2.928 ++	  this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
   2.929 ++	  this->_M_table = this->_M_c_locale_ctype->__ctype_b;
   2.930 ++#endif
   2.931 ++	}
   2.932 ++    }
   2.933 ++
   2.934 ++#ifdef _GLIBCXX_USE_WCHAR_T  
   2.935 ++  ctype<wchar_t>::__wmask_type
   2.936 ++  ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
   2.937 ++  {
   2.938 ++    __wmask_type __ret;
   2.939 ++    switch (__m)
   2.940 ++      {
   2.941 ++      case space:
   2.942 ++	__ret = __wctype_l("space", _M_c_locale_ctype);
   2.943 ++	break;
   2.944 ++      case print:
   2.945 ++	__ret = __wctype_l("print", _M_c_locale_ctype);
   2.946 ++	break;
   2.947 ++      case cntrl:
   2.948 ++	__ret = __wctype_l("cntrl", _M_c_locale_ctype);
   2.949 ++	break;
   2.950 ++      case upper:
   2.951 ++	__ret = __wctype_l("upper", _M_c_locale_ctype);
   2.952 ++	break;
   2.953 ++      case lower:
   2.954 ++	__ret = __wctype_l("lower", _M_c_locale_ctype);
   2.955 ++	break;
   2.956 ++      case alpha:
   2.957 ++	__ret = __wctype_l("alpha", _M_c_locale_ctype);
   2.958 ++	break;
   2.959 ++      case digit:
   2.960 ++	__ret = __wctype_l("digit", _M_c_locale_ctype);
   2.961 ++	break;
   2.962 ++      case punct:
   2.963 ++	__ret = __wctype_l("punct", _M_c_locale_ctype);
   2.964 ++	break;
   2.965 ++      case xdigit:
   2.966 ++	__ret = __wctype_l("xdigit", _M_c_locale_ctype);
   2.967 ++	break;
   2.968 ++      case alnum:
   2.969 ++	__ret = __wctype_l("alnum", _M_c_locale_ctype);
   2.970 ++	break;
   2.971 ++      case graph:
   2.972 ++	__ret = __wctype_l("graph", _M_c_locale_ctype);
   2.973 ++	break;
   2.974 ++      default:
   2.975 ++	__ret = 0;
   2.976 ++      }
   2.977 ++    return __ret;
   2.978 ++  }
   2.979 ++  
   2.980 ++  wchar_t
   2.981 ++  ctype<wchar_t>::do_toupper(wchar_t __c) const
   2.982 ++  { return __towupper_l(__c, _M_c_locale_ctype); }
   2.983 ++
   2.984 ++  const wchar_t*
   2.985 ++  ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
   2.986 ++  {
   2.987 ++    while (__lo < __hi)
   2.988 ++      {
   2.989 ++        *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
   2.990 ++        ++__lo;
   2.991 ++      }
   2.992 ++    return __hi;
   2.993 ++  }
   2.994 ++  
   2.995 ++  wchar_t
   2.996 ++  ctype<wchar_t>::do_tolower(wchar_t __c) const
   2.997 ++  { return __towlower_l(__c, _M_c_locale_ctype); }
   2.998 ++  
   2.999 ++  const wchar_t*
  2.1000 ++  ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
  2.1001 ++  {
  2.1002 ++    while (__lo < __hi)
  2.1003 ++      {
  2.1004 ++        *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
  2.1005 ++        ++__lo;
  2.1006 ++      }
  2.1007 ++    return __hi;
  2.1008 ++  }
  2.1009 ++
  2.1010 ++  bool
  2.1011 ++  ctype<wchar_t>::
  2.1012 ++  do_is(mask __m, wchar_t __c) const
  2.1013 ++  { 
  2.1014 ++    // Highest bitmask in ctype_base == 10, but extra in "C"
  2.1015 ++    // library for blank.
  2.1016 ++    bool __ret = false;
  2.1017 ++    const size_t __bitmasksize = 11; 
  2.1018 ++    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  2.1019 ++      if (__m & _M_bit[__bitcur]
  2.1020 ++	  && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
  2.1021 ++	{
  2.1022 ++	  __ret = true;
  2.1023 ++	  break;
  2.1024 ++	}
  2.1025 ++    return __ret;    
  2.1026 ++  }
  2.1027 ++  
  2.1028 ++  const wchar_t* 
  2.1029 ++  ctype<wchar_t>::
  2.1030 ++  do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
  2.1031 ++  {
  2.1032 ++    for (; __lo < __hi; ++__vec, ++__lo)
  2.1033 ++      {
  2.1034 ++	// Highest bitmask in ctype_base == 10, but extra in "C"
  2.1035 ++	// library for blank.
  2.1036 ++	const size_t __bitmasksize = 11; 
  2.1037 ++	mask __m = 0;
  2.1038 ++	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  2.1039 ++	  if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
  2.1040 ++	    __m |= _M_bit[__bitcur];
  2.1041 ++	*__vec = __m;
  2.1042 ++      }
  2.1043 ++    return __hi;
  2.1044 ++  }
  2.1045 ++  
  2.1046 ++  const wchar_t* 
  2.1047 ++  ctype<wchar_t>::
  2.1048 ++  do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
  2.1049 ++  {
  2.1050 ++    while (__lo < __hi && !this->do_is(__m, *__lo))
  2.1051 ++      ++__lo;
  2.1052 ++    return __lo;
  2.1053 ++  }
  2.1054 ++
  2.1055 ++  const wchar_t*
  2.1056 ++  ctype<wchar_t>::
  2.1057 ++  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
  2.1058 ++  {
  2.1059 ++    while (__lo < __hi && this->do_is(__m, *__lo) != 0)
  2.1060 ++      ++__lo;
  2.1061 ++    return __lo;
  2.1062 ++  }
  2.1063 ++
  2.1064 ++  wchar_t
  2.1065 ++  ctype<wchar_t>::
  2.1066 ++  do_widen(char __c) const
  2.1067 ++  { return _M_widen[static_cast<unsigned char>(__c)]; }
  2.1068 ++
  2.1069 ++  const char* 
  2.1070 ++  ctype<wchar_t>::
  2.1071 ++  do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
  2.1072 ++  {
  2.1073 ++    while (__lo < __hi)
  2.1074 ++      {
  2.1075 ++	*__dest = _M_widen[static_cast<unsigned char>(*__lo)];
  2.1076 ++	++__lo;
  2.1077 ++	++__dest;
  2.1078 ++      }
  2.1079 ++    return __hi;
  2.1080 ++  }
  2.1081 ++
  2.1082 ++  char
  2.1083 ++  ctype<wchar_t>::
  2.1084 ++  do_narrow(wchar_t __wc, char __dfault) const
  2.1085 ++  {
  2.1086 ++    if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
  2.1087 ++      return _M_narrow[__wc];
  2.1088 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1089 ++    __c_locale __old = __uselocale(_M_c_locale_ctype);
  2.1090 ++#endif
  2.1091 ++    const int __c = wctob(__wc);
  2.1092 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1093 ++    __uselocale(__old);
  2.1094 ++#endif
  2.1095 ++    return (__c == EOF ? __dfault : static_cast<char>(__c)); 
  2.1096 ++  }
  2.1097 ++
  2.1098 ++  const wchar_t*
  2.1099 ++  ctype<wchar_t>::
  2.1100 ++  do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault, 
  2.1101 ++	    char* __dest) const
  2.1102 ++  {
  2.1103 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1104 ++    __c_locale __old = __uselocale(_M_c_locale_ctype);
  2.1105 ++#endif
  2.1106 ++    if (_M_narrow_ok)
  2.1107 ++      while (__lo < __hi)
  2.1108 ++	{
  2.1109 ++	  if (*__lo >= 0 && *__lo < 128)
  2.1110 ++	    *__dest = _M_narrow[*__lo];
  2.1111 ++	  else
  2.1112 ++	    {
  2.1113 ++	      const int __c = wctob(*__lo);
  2.1114 ++	      *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
  2.1115 ++	    }
  2.1116 ++	  ++__lo;
  2.1117 ++	  ++__dest;
  2.1118 ++	}
  2.1119 ++    else
  2.1120 ++      while (__lo < __hi)
  2.1121 ++	{
  2.1122 ++	  const int __c = wctob(*__lo);
  2.1123 ++	  *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
  2.1124 ++	  ++__lo;
  2.1125 ++	  ++__dest;
  2.1126 ++	}
  2.1127 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1128 ++    __uselocale(__old);
  2.1129 ++#endif
  2.1130 ++    return __hi;
  2.1131 ++  }
  2.1132 ++
  2.1133 ++  void
  2.1134 ++  ctype<wchar_t>::_M_initialize_ctype()
  2.1135 ++  {
  2.1136 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1137 ++    __c_locale __old = __uselocale(_M_c_locale_ctype);
  2.1138 ++#endif
  2.1139 ++    wint_t __i;
  2.1140 ++    for (__i = 0; __i < 128; ++__i)
  2.1141 ++      {
  2.1142 ++	const int __c = wctob(__i);
  2.1143 ++	if (__c == EOF)
  2.1144 ++	  break;
  2.1145 ++	else
  2.1146 ++	  _M_narrow[__i] = static_cast<char>(__c);
  2.1147 ++      }
  2.1148 ++    if (__i == 128)
  2.1149 ++      _M_narrow_ok = true;
  2.1150 ++    else
  2.1151 ++      _M_narrow_ok = false;
  2.1152 ++    for (size_t __j = 0;
  2.1153 ++	 __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
  2.1154 ++      _M_widen[__j] = btowc(__j);
  2.1155 ++
  2.1156 ++    for (size_t __k = 0; __k <= 11; ++__k)
  2.1157 ++      { 
  2.1158 ++	_M_bit[__k] = static_cast<mask>(_ISbit(__k));
  2.1159 ++	_M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
  2.1160 ++      }
  2.1161 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1162 ++    __uselocale(__old);
  2.1163 ++#endif
  2.1164 ++  }
  2.1165 ++#endif //  _GLIBCXX_USE_WCHAR_T
  2.1166 ++}
  2.1167 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/messages_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/messages_members.cc
  2.1168 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/messages_members.cc	1970-01-01 01:00:00.000000000 +0100
  2.1169 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/messages_members.cc	2007-08-15 22:51:01.000000000 +0200
  2.1170 +@@ -0,0 +1,100 @@
  2.1171 ++// std::messages implementation details, GNU version -*- C++ -*-
  2.1172 ++
  2.1173 ++// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  2.1174 ++//
  2.1175 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.1176 ++// software; you can redistribute it and/or modify it under the
  2.1177 ++// terms of the GNU General Public License as published by the
  2.1178 ++// Free Software Foundation; either version 2, or (at your option)
  2.1179 ++// any later version.
  2.1180 ++
  2.1181 ++// This library is distributed in the hope that it will be useful,
  2.1182 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.1183 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.1184 ++// GNU General Public License for more details.
  2.1185 ++
  2.1186 ++// You should have received a copy of the GNU General Public License along
  2.1187 ++// with this library; see the file COPYING.  If not, write to the Free
  2.1188 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.1189 ++// USA.
  2.1190 ++
  2.1191 ++// As a special exception, you may use this file as part of a free software
  2.1192 ++// library without restriction.  Specifically, if other files instantiate
  2.1193 ++// templates or use macros or inline functions from this file, or you compile
  2.1194 ++// this file and link it with other files to produce an executable, this
  2.1195 ++// file does not by itself cause the resulting executable to be covered by
  2.1196 ++// the GNU General Public License.  This exception does not however
  2.1197 ++// invalidate any other reasons why the executable file might be covered by
  2.1198 ++// the GNU General Public License.
  2.1199 ++
  2.1200 ++//
  2.1201 ++// ISO C++ 14882: 22.2.7.1.2  messages virtual functions
  2.1202 ++//
  2.1203 ++
  2.1204 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.1205 ++
  2.1206 ++#include <locale>
  2.1207 ++#include <bits/c++locale_internal.h>
  2.1208 ++
  2.1209 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.1210 ++#warning fix gettext stuff
  2.1211 ++#endif
  2.1212 ++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  2.1213 ++extern "C" char *__dcgettext(const char *domainname,
  2.1214 ++			     const char *msgid, int category);
  2.1215 ++#undef gettext
  2.1216 ++#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
  2.1217 ++#else
  2.1218 ++#undef gettext
  2.1219 ++#define gettext(msgid) (msgid)
  2.1220 ++#endif
  2.1221 ++
  2.1222 ++namespace std
  2.1223 ++{
  2.1224 ++  // Specializations.
  2.1225 ++  template<>
  2.1226 ++    string
  2.1227 ++    messages<char>::do_get(catalog, int, int, const string& __dfault) const
  2.1228 ++    {
  2.1229 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1230 ++      __c_locale __old = __uselocale(_M_c_locale_messages);
  2.1231 ++      const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
  2.1232 ++      __uselocale(__old);
  2.1233 ++      return string(__msg);
  2.1234 ++#elif defined __UCLIBC_HAS_LOCALE__
  2.1235 ++      char* __old = strdup(setlocale(LC_ALL, NULL));
  2.1236 ++      setlocale(LC_ALL, _M_name_messages);
  2.1237 ++      const char* __msg = gettext(__dfault.c_str());
  2.1238 ++      setlocale(LC_ALL, __old);
  2.1239 ++      free(__old);
  2.1240 ++      return string(__msg);
  2.1241 ++#else
  2.1242 ++      const char* __msg = gettext(__dfault.c_str());
  2.1243 ++      return string(__msg);
  2.1244 ++#endif
  2.1245 ++    }
  2.1246 ++
  2.1247 ++#ifdef _GLIBCXX_USE_WCHAR_T
  2.1248 ++  template<>
  2.1249 ++    wstring
  2.1250 ++    messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
  2.1251 ++    {
  2.1252 ++# ifdef __UCLIBC_HAS_XLOCALE__
  2.1253 ++      __c_locale __old = __uselocale(_M_c_locale_messages);
  2.1254 ++      char* __msg = gettext(_M_convert_to_char(__dfault));
  2.1255 ++      __uselocale(__old);
  2.1256 ++      return _M_convert_from_char(__msg);
  2.1257 ++# elif defined __UCLIBC_HAS_LOCALE__
  2.1258 ++      char* __old = strdup(setlocale(LC_ALL, NULL));
  2.1259 ++      setlocale(LC_ALL, _M_name_messages);
  2.1260 ++      char* __msg = gettext(_M_convert_to_char(__dfault));
  2.1261 ++      setlocale(LC_ALL, __old);
  2.1262 ++      free(__old);
  2.1263 ++      return _M_convert_from_char(__msg);
  2.1264 ++# else
  2.1265 ++      char* __msg = gettext(_M_convert_to_char(__dfault));
  2.1266 ++      return _M_convert_from_char(__msg);
  2.1267 ++# endif
  2.1268 ++    }
  2.1269 ++#endif
  2.1270 ++}
  2.1271 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-3.4.6/libstdc++-v3/config/locale/uclibc/messages_members.h
  2.1272 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/messages_members.h	1970-01-01 01:00:00.000000000 +0100
  2.1273 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/messages_members.h	2007-08-15 22:51:01.000000000 +0200
  2.1274 +@@ -0,0 +1,118 @@
  2.1275 ++// std::messages implementation details, GNU version -*- C++ -*-
  2.1276 ++
  2.1277 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2.1278 ++//
  2.1279 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.1280 ++// software; you can redistribute it and/or modify it under the
  2.1281 ++// terms of the GNU General Public License as published by the
  2.1282 ++// Free Software Foundation; either version 2, or (at your option)
  2.1283 ++// any later version.
  2.1284 ++
  2.1285 ++// This library is distributed in the hope that it will be useful,
  2.1286 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.1287 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.1288 ++// GNU General Public License for more details.
  2.1289 ++
  2.1290 ++// You should have received a copy of the GNU General Public License along
  2.1291 ++// with this library; see the file COPYING.  If not, write to the Free
  2.1292 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.1293 ++// USA.
  2.1294 ++
  2.1295 ++// As a special exception, you may use this file as part of a free software
  2.1296 ++// library without restriction.  Specifically, if other files instantiate
  2.1297 ++// templates or use macros or inline functions from this file, or you compile
  2.1298 ++// this file and link it with other files to produce an executable, this
  2.1299 ++// file does not by itself cause the resulting executable to be covered by
  2.1300 ++// the GNU General Public License.  This exception does not however
  2.1301 ++// invalidate any other reasons why the executable file might be covered by
  2.1302 ++// the GNU General Public License.
  2.1303 ++
  2.1304 ++//
  2.1305 ++// ISO C++ 14882: 22.2.7.1.2  messages functions
  2.1306 ++//
  2.1307 ++
  2.1308 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.1309 ++
  2.1310 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.1311 ++#warning fix prototypes for *textdomain funcs
  2.1312 ++#endif
  2.1313 ++#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  2.1314 ++extern "C" char *__textdomain(const char *domainname);
  2.1315 ++extern "C" char *__bindtextdomain(const char *domainname,
  2.1316 ++				  const char *dirname);
  2.1317 ++#else
  2.1318 ++#undef __textdomain
  2.1319 ++#undef __bindtextdomain
  2.1320 ++#define __textdomain(D)           ((void)0)
  2.1321 ++#define __bindtextdomain(D,P)     ((void)0)
  2.1322 ++#endif
  2.1323 ++
  2.1324 ++  // Non-virtual member functions.
  2.1325 ++  template<typename _CharT>
  2.1326 ++     messages<_CharT>::messages(size_t __refs)
  2.1327 ++     : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), 
  2.1328 ++     _M_name_messages(_S_get_c_name())
  2.1329 ++     { }
  2.1330 ++
  2.1331 ++  template<typename _CharT>
  2.1332 ++     messages<_CharT>::messages(__c_locale __cloc, const char* __s, 
  2.1333 ++				size_t __refs) 
  2.1334 ++     : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
  2.1335 ++     _M_name_messages(__s)
  2.1336 ++     {
  2.1337 ++       char* __tmp = new char[std::strlen(__s) + 1];
  2.1338 ++       std::strcpy(__tmp, __s);
  2.1339 ++       _M_name_messages = __tmp;
  2.1340 ++     }
  2.1341 ++
  2.1342 ++  template<typename _CharT>
  2.1343 ++    typename messages<_CharT>::catalog 
  2.1344 ++    messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc, 
  2.1345 ++			   const char* __dir) const
  2.1346 ++    { 
  2.1347 ++      __bindtextdomain(__s.c_str(), __dir);
  2.1348 ++      return this->do_open(__s, __loc); 
  2.1349 ++    }
  2.1350 ++
  2.1351 ++  // Virtual member functions.
  2.1352 ++  template<typename _CharT>
  2.1353 ++    messages<_CharT>::~messages()
  2.1354 ++    { 
  2.1355 ++      if (_M_name_messages != _S_get_c_name())
  2.1356 ++	delete [] _M_name_messages;
  2.1357 ++      _S_destroy_c_locale(_M_c_locale_messages); 
  2.1358 ++    }
  2.1359 ++
  2.1360 ++  template<typename _CharT>
  2.1361 ++    typename messages<_CharT>::catalog 
  2.1362 ++    messages<_CharT>::do_open(const basic_string<char>& __s, 
  2.1363 ++			      const locale&) const
  2.1364 ++    { 
  2.1365 ++      // No error checking is done, assume the catalog exists and can
  2.1366 ++      // be used.
  2.1367 ++      __textdomain(__s.c_str());
  2.1368 ++      return 0;
  2.1369 ++    }
  2.1370 ++
  2.1371 ++  template<typename _CharT>
  2.1372 ++    void    
  2.1373 ++    messages<_CharT>::do_close(catalog) const 
  2.1374 ++    { }
  2.1375 ++
  2.1376 ++   // messages_byname
  2.1377 ++   template<typename _CharT>
  2.1378 ++     messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
  2.1379 ++     : messages<_CharT>(__refs) 
  2.1380 ++     { 
  2.1381 ++       if (this->_M_name_messages != locale::facet::_S_get_c_name())
  2.1382 ++	 delete [] this->_M_name_messages;
  2.1383 ++       char* __tmp = new char[std::strlen(__s) + 1];
  2.1384 ++       std::strcpy(__tmp, __s);
  2.1385 ++       this->_M_name_messages = __tmp;
  2.1386 ++
  2.1387 ++       if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
  2.1388 ++	 {
  2.1389 ++	   this->_S_destroy_c_locale(this->_M_c_locale_messages);
  2.1390 ++	   this->_S_create_c_locale(this->_M_c_locale_messages, __s); 
  2.1391 ++	 }
  2.1392 ++     }
  2.1393 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/monetary_members.cc
  2.1394 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc	1970-01-01 01:00:00.000000000 +0100
  2.1395 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/monetary_members.cc	2007-08-15 22:51:01.000000000 +0200
  2.1396 +@@ -0,0 +1,698 @@
  2.1397 ++// std::moneypunct implementation details, GNU version -*- C++ -*-
  2.1398 ++
  2.1399 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2.1400 ++//
  2.1401 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.1402 ++// software; you can redistribute it and/or modify it under the
  2.1403 ++// terms of the GNU General Public License as published by the
  2.1404 ++// Free Software Foundation; either version 2, or (at your option)
  2.1405 ++// any later version.
  2.1406 ++
  2.1407 ++// This library is distributed in the hope that it will be useful,
  2.1408 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.1409 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.1410 ++// GNU General Public License for more details.
  2.1411 ++
  2.1412 ++// You should have received a copy of the GNU General Public License along
  2.1413 ++// with this library; see the file COPYING.  If not, write to the Free
  2.1414 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.1415 ++// USA.
  2.1416 ++
  2.1417 ++// As a special exception, you may use this file as part of a free software
  2.1418 ++// library without restriction.  Specifically, if other files instantiate
  2.1419 ++// templates or use macros or inline functions from this file, or you compile
  2.1420 ++// this file and link it with other files to produce an executable, this
  2.1421 ++// file does not by itself cause the resulting executable to be covered by
  2.1422 ++// the GNU General Public License.  This exception does not however
  2.1423 ++// invalidate any other reasons why the executable file might be covered by
  2.1424 ++// the GNU General Public License.
  2.1425 ++
  2.1426 ++//
  2.1427 ++// ISO C++ 14882: 22.2.6.3.2  moneypunct virtual functions
  2.1428 ++//
  2.1429 ++
  2.1430 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.1431 ++
  2.1432 ++#define _LIBC
  2.1433 ++#include <locale>
  2.1434 ++#undef _LIBC
  2.1435 ++#include <bits/c++locale_internal.h>
  2.1436 ++
  2.1437 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.1438 ++#warning optimize this for uclibc
  2.1439 ++#warning tailor for stub locale support
  2.1440 ++#endif
  2.1441 ++
  2.1442 ++#ifndef __UCLIBC_HAS_XLOCALE__
  2.1443 ++#define __nl_langinfo_l(N, L)         nl_langinfo((N))
  2.1444 ++#endif
  2.1445 ++
  2.1446 ++namespace std
  2.1447 ++{
  2.1448 ++  // Construct and return valid pattern consisting of some combination of:
  2.1449 ++  // space none symbol sign value
  2.1450 ++  money_base::pattern
  2.1451 ++  money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
  2.1452 ++  { 
  2.1453 ++    pattern __ret;
  2.1454 ++
  2.1455 ++    // This insanely complicated routine attempts to construct a valid
  2.1456 ++    // pattern for use with monyepunct. A couple of invariants:
  2.1457 ++
  2.1458 ++    // if (__precedes) symbol -> value
  2.1459 ++    // else value -> symbol
  2.1460 ++    
  2.1461 ++    // if (__space) space
  2.1462 ++    // else none
  2.1463 ++
  2.1464 ++    // none == never first
  2.1465 ++    // space never first or last
  2.1466 ++
  2.1467 ++    // Any elegant implementations of this are welcome.
  2.1468 ++    switch (__posn)
  2.1469 ++      {
  2.1470 ++      case 0:
  2.1471 ++      case 1:
  2.1472 ++	// 1 The sign precedes the value and symbol.
  2.1473 ++	__ret.field[0] = sign;
  2.1474 ++	if (__space)
  2.1475 ++	  {
  2.1476 ++	    // Pattern starts with sign.
  2.1477 ++	    if (__precedes)
  2.1478 ++	      {
  2.1479 ++		__ret.field[1] = symbol;
  2.1480 ++		__ret.field[3] = value;
  2.1481 ++	      }
  2.1482 ++	    else
  2.1483 ++	      {
  2.1484 ++		__ret.field[1] = value;
  2.1485 ++		__ret.field[3] = symbol;
  2.1486 ++	      }
  2.1487 ++	    __ret.field[2] = space;
  2.1488 ++	  }
  2.1489 ++	else
  2.1490 ++	  {
  2.1491 ++	    // Pattern starts with sign and ends with none.
  2.1492 ++	    if (__precedes)
  2.1493 ++	      {
  2.1494 ++		__ret.field[1] = symbol;
  2.1495 ++		__ret.field[2] = value;
  2.1496 ++	      }
  2.1497 ++	    else
  2.1498 ++	      {
  2.1499 ++		__ret.field[1] = value;
  2.1500 ++		__ret.field[2] = symbol;
  2.1501 ++	      }
  2.1502 ++	    __ret.field[3] = none;
  2.1503 ++	  }
  2.1504 ++	break;
  2.1505 ++      case 2:
  2.1506 ++	// 2 The sign follows the value and symbol.
  2.1507 ++	if (__space)
  2.1508 ++	  {
  2.1509 ++	    // Pattern either ends with sign.
  2.1510 ++	    if (__precedes)
  2.1511 ++	      {
  2.1512 ++		__ret.field[0] = symbol;
  2.1513 ++		__ret.field[2] = value;
  2.1514 ++	      }
  2.1515 ++	    else
  2.1516 ++	      {
  2.1517 ++		__ret.field[0] = value;
  2.1518 ++		__ret.field[2] = symbol;
  2.1519 ++	      }
  2.1520 ++	    __ret.field[1] = space;
  2.1521 ++	    __ret.field[3] = sign;
  2.1522 ++	  }
  2.1523 ++	else
  2.1524 ++	  {
  2.1525 ++	    // Pattern ends with sign then none.
  2.1526 ++	    if (__precedes)
  2.1527 ++	      {
  2.1528 ++		__ret.field[0] = symbol;
  2.1529 ++		__ret.field[1] = value;
  2.1530 ++	      }
  2.1531 ++	    else
  2.1532 ++	      {
  2.1533 ++		__ret.field[0] = value;
  2.1534 ++		__ret.field[1] = symbol;
  2.1535 ++	      }
  2.1536 ++	    __ret.field[2] = sign;
  2.1537 ++	    __ret.field[3] = none;
  2.1538 ++	  }
  2.1539 ++	break;
  2.1540 ++      case 3:
  2.1541 ++	// 3 The sign immediately precedes the symbol.
  2.1542 ++	if (__precedes)
  2.1543 ++	  {
  2.1544 ++	    __ret.field[0] = sign;
  2.1545 ++	    __ret.field[1] = symbol;	    
  2.1546 ++	    if (__space)
  2.1547 ++	      {
  2.1548 ++		__ret.field[2] = space;
  2.1549 ++		__ret.field[3] = value;
  2.1550 ++	      }
  2.1551 ++	    else
  2.1552 ++	      {
  2.1553 ++		__ret.field[2] = value;		
  2.1554 ++		__ret.field[3] = none;
  2.1555 ++	      }
  2.1556 ++	  }
  2.1557 ++	else
  2.1558 ++	  {
  2.1559 ++	    __ret.field[0] = value;
  2.1560 ++	    if (__space)
  2.1561 ++	      {
  2.1562 ++		__ret.field[1] = space;
  2.1563 ++		__ret.field[2] = sign;
  2.1564 ++		__ret.field[3] = symbol;
  2.1565 ++	      }
  2.1566 ++	    else
  2.1567 ++	      {
  2.1568 ++		__ret.field[1] = sign;
  2.1569 ++		__ret.field[2] = symbol;
  2.1570 ++		__ret.field[3] = none;
  2.1571 ++	      }
  2.1572 ++	  }
  2.1573 ++	break;
  2.1574 ++      case 4:
  2.1575 ++	// 4 The sign immediately follows the symbol.
  2.1576 ++	if (__precedes)
  2.1577 ++	  {
  2.1578 ++	    __ret.field[0] = symbol;
  2.1579 ++	    __ret.field[1] = sign;
  2.1580 ++	    if (__space)
  2.1581 ++	      {
  2.1582 ++		__ret.field[2] = space;
  2.1583 ++		__ret.field[3] = value;
  2.1584 ++	      }
  2.1585 ++	    else
  2.1586 ++	      {
  2.1587 ++		__ret.field[2] = value;
  2.1588 ++		__ret.field[3] = none;
  2.1589 ++	      }
  2.1590 ++	  }
  2.1591 ++	else
  2.1592 ++	  {
  2.1593 ++	    __ret.field[0] = value;
  2.1594 ++	    if (__space)
  2.1595 ++	      {
  2.1596 ++		__ret.field[1] = space;
  2.1597 ++		__ret.field[2] = symbol;
  2.1598 ++		__ret.field[3] = sign;
  2.1599 ++	      }
  2.1600 ++	    else
  2.1601 ++	      {
  2.1602 ++		__ret.field[1] = symbol;
  2.1603 ++		__ret.field[2] = sign;
  2.1604 ++		__ret.field[3] = none;
  2.1605 ++	      }
  2.1606 ++	  }
  2.1607 ++	break;
  2.1608 ++      default:
  2.1609 ++	;
  2.1610 ++      }
  2.1611 ++    return __ret;
  2.1612 ++  }
  2.1613 ++
  2.1614 ++  template<> 
  2.1615 ++    void
  2.1616 ++    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, 
  2.1617 ++						     const char*)
  2.1618 ++    {
  2.1619 ++      if (!_M_data)
  2.1620 ++	_M_data = new __moneypunct_cache<char, true>;
  2.1621 ++
  2.1622 ++      if (!__cloc)
  2.1623 ++	{
  2.1624 ++	  // "C" locale
  2.1625 ++	  _M_data->_M_decimal_point = '.';
  2.1626 ++	  _M_data->_M_thousands_sep = ',';
  2.1627 ++	  _M_data->_M_grouping = "";
  2.1628 ++	  _M_data->_M_grouping_size = 0;
  2.1629 ++	  _M_data->_M_curr_symbol = "";
  2.1630 ++	  _M_data->_M_curr_symbol_size = 0;
  2.1631 ++	  _M_data->_M_positive_sign = "";
  2.1632 ++	  _M_data->_M_positive_sign_size = 0;
  2.1633 ++	  _M_data->_M_negative_sign = "";
  2.1634 ++	  _M_data->_M_negative_sign_size = 0;
  2.1635 ++	  _M_data->_M_frac_digits = 0;
  2.1636 ++	  _M_data->_M_pos_format = money_base::_S_default_pattern;
  2.1637 ++	  _M_data->_M_neg_format = money_base::_S_default_pattern;
  2.1638 ++
  2.1639 ++	  for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  2.1640 ++	    _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
  2.1641 ++	}
  2.1642 ++      else
  2.1643 ++	{
  2.1644 ++	  // Named locale.
  2.1645 ++	  _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, 
  2.1646 ++							__cloc));
  2.1647 ++	  _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, 
  2.1648 ++							__cloc));
  2.1649 ++	  _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  2.1650 ++	  _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.1651 ++	  _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  2.1652 ++	  _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
  2.1653 ++
  2.1654 ++	  char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
  2.1655 ++	  if (!__nposn)
  2.1656 ++	    _M_data->_M_negative_sign = "()";
  2.1657 ++	  else
  2.1658 ++	    _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, 
  2.1659 ++							__cloc);
  2.1660 ++	  _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
  2.1661 ++
  2.1662 ++	  // _Intl == true
  2.1663 ++	  _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
  2.1664 ++	  _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
  2.1665 ++	  _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, 
  2.1666 ++						      __cloc));
  2.1667 ++	  char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
  2.1668 ++	  char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
  2.1669 ++	  char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
  2.1670 ++	  _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, 
  2.1671 ++							__pposn);
  2.1672 ++	  char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
  2.1673 ++	  char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
  2.1674 ++	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, 
  2.1675 ++							__nposn);
  2.1676 ++	}
  2.1677 ++    }
  2.1678 ++
  2.1679 ++  template<> 
  2.1680 ++    void
  2.1681 ++    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, 
  2.1682 ++						      const char*)
  2.1683 ++    {
  2.1684 ++      if (!_M_data)
  2.1685 ++	_M_data = new __moneypunct_cache<char, false>;
  2.1686 ++
  2.1687 ++      if (!__cloc)
  2.1688 ++	{
  2.1689 ++	  // "C" locale
  2.1690 ++	  _M_data->_M_decimal_point = '.';
  2.1691 ++	  _M_data->_M_thousands_sep = ',';
  2.1692 ++	  _M_data->_M_grouping = "";
  2.1693 ++	  _M_data->_M_grouping_size = 0;
  2.1694 ++	  _M_data->_M_curr_symbol = "";
  2.1695 ++	  _M_data->_M_curr_symbol_size = 0;
  2.1696 ++	  _M_data->_M_positive_sign = "";
  2.1697 ++	  _M_data->_M_positive_sign_size = 0;
  2.1698 ++	  _M_data->_M_negative_sign = "";
  2.1699 ++	  _M_data->_M_negative_sign_size = 0;
  2.1700 ++	  _M_data->_M_frac_digits = 0;
  2.1701 ++	  _M_data->_M_pos_format = money_base::_S_default_pattern;
  2.1702 ++	  _M_data->_M_neg_format = money_base::_S_default_pattern;
  2.1703 ++
  2.1704 ++	  for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  2.1705 ++	    _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
  2.1706 ++	}
  2.1707 ++      else
  2.1708 ++	{
  2.1709 ++	  // Named locale.
  2.1710 ++	  _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, 
  2.1711 ++							__cloc));
  2.1712 ++	  _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, 
  2.1713 ++							__cloc));
  2.1714 ++	  _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  2.1715 ++	  _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.1716 ++	  _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  2.1717 ++	  _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
  2.1718 ++
  2.1719 ++	  char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
  2.1720 ++	  if (!__nposn)
  2.1721 ++	    _M_data->_M_negative_sign = "()";
  2.1722 ++	  else
  2.1723 ++	    _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
  2.1724 ++							__cloc);
  2.1725 ++	  _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
  2.1726 ++
  2.1727 ++	  // _Intl == false
  2.1728 ++	  _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
  2.1729 ++	  _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
  2.1730 ++	  _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
  2.1731 ++	  char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
  2.1732 ++	  char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
  2.1733 ++	  char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
  2.1734 ++	  _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, 
  2.1735 ++							__pposn);
  2.1736 ++	  char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
  2.1737 ++	  char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
  2.1738 ++	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, 
  2.1739 ++							__nposn);
  2.1740 ++	}
  2.1741 ++    }
  2.1742 ++
  2.1743 ++  template<> 
  2.1744 ++    moneypunct<char, true>::~moneypunct()
  2.1745 ++    { delete _M_data; }
  2.1746 ++
  2.1747 ++  template<> 
  2.1748 ++    moneypunct<char, false>::~moneypunct()
  2.1749 ++    { delete _M_data; }
  2.1750 ++
  2.1751 ++#ifdef _GLIBCXX_USE_WCHAR_T
  2.1752 ++  template<> 
  2.1753 ++    void
  2.1754 ++    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, 
  2.1755 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1756 ++							const char*)
  2.1757 ++#else
  2.1758 ++							const char* __name)
  2.1759 ++#endif
  2.1760 ++    {
  2.1761 ++      if (!_M_data)
  2.1762 ++	_M_data = new __moneypunct_cache<wchar_t, true>;
  2.1763 ++
  2.1764 ++      if (!__cloc)
  2.1765 ++	{
  2.1766 ++	  // "C" locale
  2.1767 ++	  _M_data->_M_decimal_point = L'.';
  2.1768 ++	  _M_data->_M_thousands_sep = L',';
  2.1769 ++	  _M_data->_M_grouping = "";
  2.1770 ++	  _M_data->_M_grouping_size = 0;
  2.1771 ++	  _M_data->_M_curr_symbol = L"";
  2.1772 ++	  _M_data->_M_curr_symbol_size = 0;
  2.1773 ++	  _M_data->_M_positive_sign = L"";
  2.1774 ++	  _M_data->_M_positive_sign_size = 0;
  2.1775 ++	  _M_data->_M_negative_sign = L"";
  2.1776 ++	  _M_data->_M_negative_sign_size = 0;
  2.1777 ++	  _M_data->_M_frac_digits = 0;
  2.1778 ++	  _M_data->_M_pos_format = money_base::_S_default_pattern;
  2.1779 ++	  _M_data->_M_neg_format = money_base::_S_default_pattern;
  2.1780 ++
  2.1781 ++	  // Use ctype::widen code without the facet...
  2.1782 ++	  unsigned char uc;
  2.1783 ++	  for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  2.1784 ++	    {
  2.1785 ++	      uc = static_cast<unsigned char>(money_base::_S_atoms[__i]);
  2.1786 ++	      _M_data->_M_atoms[__i] = btowc(uc);
  2.1787 ++	    }
  2.1788 ++	}
  2.1789 ++      else
  2.1790 ++	{
  2.1791 ++	  // Named locale.
  2.1792 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1793 ++	  __c_locale __old = __uselocale(__cloc);
  2.1794 ++#else
  2.1795 ++	  // Switch to named locale so that mbsrtowcs will work.
  2.1796 ++	  char* __old = strdup(setlocale(LC_ALL, NULL));
  2.1797 ++	  setlocale(LC_ALL, __name);
  2.1798 ++#endif
  2.1799 ++
  2.1800 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.1801 ++#warning fix this... should be monetary
  2.1802 ++#endif
  2.1803 ++#ifdef __UCLIBC__
  2.1804 ++# ifdef __UCLIBC_HAS_XLOCALE__
  2.1805 ++	  _M_data->_M_decimal_point = __cloc->decimal_point_wc;
  2.1806 ++	  _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
  2.1807 ++# else
  2.1808 ++	  _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
  2.1809 ++	  _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
  2.1810 ++# endif
  2.1811 ++#else
  2.1812 ++	  union __s_and_w { const char *__s; unsigned int __w; } __u;
  2.1813 ++	  __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
  2.1814 ++	  _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
  2.1815 ++
  2.1816 ++	  __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
  2.1817 ++	  _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
  2.1818 ++#endif
  2.1819 ++	  _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  2.1820 ++	  _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.1821 ++
  2.1822 ++	  const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  2.1823 ++	  const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
  2.1824 ++	  const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
  2.1825 ++
  2.1826 ++	  wchar_t* __wcs_ps = 0;
  2.1827 ++	  wchar_t* __wcs_ns = 0;
  2.1828 ++	  const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
  2.1829 ++	  try
  2.1830 ++	    {
  2.1831 ++	      mbstate_t __state;
  2.1832 ++	      size_t __len = strlen(__cpossign);
  2.1833 ++	      if (__len)
  2.1834 ++		{
  2.1835 ++		  ++__len;
  2.1836 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.1837 ++		  __wcs_ps = new wchar_t[__len];
  2.1838 ++		  mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
  2.1839 ++		  _M_data->_M_positive_sign = __wcs_ps;
  2.1840 ++		}
  2.1841 ++	      else
  2.1842 ++		_M_data->_M_positive_sign = L"";
  2.1843 ++	      _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
  2.1844 ++	      
  2.1845 ++	      __len = strlen(__cnegsign);
  2.1846 ++	      if (!__nposn)
  2.1847 ++		_M_data->_M_negative_sign = L"()";
  2.1848 ++	      else if (__len)
  2.1849 ++		{ 
  2.1850 ++		  ++__len;
  2.1851 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.1852 ++		  __wcs_ns = new wchar_t[__len];
  2.1853 ++		  mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
  2.1854 ++		  _M_data->_M_negative_sign = __wcs_ns;
  2.1855 ++		}
  2.1856 ++	      else
  2.1857 ++		_M_data->_M_negative_sign = L"";
  2.1858 ++	      _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
  2.1859 ++	      
  2.1860 ++	      // _Intl == true.
  2.1861 ++	      __len = strlen(__ccurr);
  2.1862 ++	      if (__len)
  2.1863 ++		{
  2.1864 ++		  ++__len;
  2.1865 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.1866 ++		  wchar_t* __wcs = new wchar_t[__len];
  2.1867 ++		  mbsrtowcs(__wcs, &__ccurr, __len, &__state);
  2.1868 ++		  _M_data->_M_curr_symbol = __wcs;
  2.1869 ++		}
  2.1870 ++	      else
  2.1871 ++		_M_data->_M_curr_symbol = L"";
  2.1872 ++	      _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
  2.1873 ++	    }
  2.1874 ++	  catch (...)
  2.1875 ++	    {
  2.1876 ++	      delete _M_data;
  2.1877 ++	      _M_data = 0;
  2.1878 ++	      delete __wcs_ps;
  2.1879 ++	      delete __wcs_ns;	      
  2.1880 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1881 ++	      __uselocale(__old);
  2.1882 ++#else
  2.1883 ++	      setlocale(LC_ALL, __old);
  2.1884 ++	      free(__old);
  2.1885 ++#endif
  2.1886 ++	      __throw_exception_again;
  2.1887 ++	    } 
  2.1888 ++	  
  2.1889 ++	  _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, 
  2.1890 ++						      __cloc));
  2.1891 ++	  char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
  2.1892 ++	  char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
  2.1893 ++	  char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
  2.1894 ++	  _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, 
  2.1895 ++							__pposn);
  2.1896 ++	  char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
  2.1897 ++	  char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
  2.1898 ++	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, 
  2.1899 ++							__nposn);
  2.1900 ++
  2.1901 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1902 ++	  __uselocale(__old);
  2.1903 ++#else
  2.1904 ++	  setlocale(LC_ALL, __old);
  2.1905 ++	  free(__old);
  2.1906 ++#endif
  2.1907 ++	}
  2.1908 ++    }
  2.1909 ++
  2.1910 ++  template<> 
  2.1911 ++  void
  2.1912 ++  moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
  2.1913 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1914 ++						       const char*)
  2.1915 ++#else
  2.1916 ++                                                       const char* __name)
  2.1917 ++#endif
  2.1918 ++  {
  2.1919 ++    if (!_M_data)
  2.1920 ++      _M_data = new __moneypunct_cache<wchar_t, false>;
  2.1921 ++
  2.1922 ++    if (!__cloc)
  2.1923 ++	{
  2.1924 ++	  // "C" locale
  2.1925 ++	  _M_data->_M_decimal_point = L'.';
  2.1926 ++	  _M_data->_M_thousands_sep = L',';
  2.1927 ++	  _M_data->_M_grouping = "";
  2.1928 ++          _M_data->_M_grouping_size = 0;
  2.1929 ++	  _M_data->_M_curr_symbol = L"";
  2.1930 ++	  _M_data->_M_curr_symbol_size = 0;
  2.1931 ++	  _M_data->_M_positive_sign = L"";
  2.1932 ++	  _M_data->_M_positive_sign_size = 0;
  2.1933 ++	  _M_data->_M_negative_sign = L"";
  2.1934 ++	  _M_data->_M_negative_sign_size = 0;
  2.1935 ++	  _M_data->_M_frac_digits = 0;
  2.1936 ++	  _M_data->_M_pos_format = money_base::_S_default_pattern;
  2.1937 ++	  _M_data->_M_neg_format = money_base::_S_default_pattern;
  2.1938 ++
  2.1939 ++	  // Use ctype::widen code without the facet...
  2.1940 ++	  unsigned char uc;
  2.1941 ++	  for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  2.1942 ++	    {
  2.1943 ++	      uc = static_cast<unsigned char>(money_base::_S_atoms[__i]);
  2.1944 ++	      _M_data->_M_atoms[__i] = btowc(uc);
  2.1945 ++	    }
  2.1946 ++	}
  2.1947 ++      else
  2.1948 ++	{
  2.1949 ++	  // Named locale.
  2.1950 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.1951 ++	  __c_locale __old = __uselocale(__cloc);
  2.1952 ++#else
  2.1953 ++	  // Switch to named locale so that mbsrtowcs will work.
  2.1954 ++	  char* __old = strdup(setlocale(LC_ALL, NULL));
  2.1955 ++	  setlocale(LC_ALL, __name);
  2.1956 ++#endif
  2.1957 ++
  2.1958 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.1959 ++#warning fix this... should be monetary
  2.1960 ++#endif
  2.1961 ++#ifdef __UCLIBC__
  2.1962 ++# ifdef __UCLIBC_HAS_XLOCALE__
  2.1963 ++	  _M_data->_M_decimal_point = __cloc->decimal_point_wc;
  2.1964 ++	  _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
  2.1965 ++# else
  2.1966 ++	  _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
  2.1967 ++	  _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
  2.1968 ++# endif
  2.1969 ++#else
  2.1970 ++	  union __s_and_w { const char *__s; unsigned int __w; } __u;
  2.1971 ++	  __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
  2.1972 ++	  _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
  2.1973 ++
  2.1974 ++	  __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
  2.1975 ++	  _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
  2.1976 ++#endif
  2.1977 ++	  _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  2.1978 ++          _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.1979 ++
  2.1980 ++	  const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  2.1981 ++	  const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
  2.1982 ++	  const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
  2.1983 ++
  2.1984 ++	  wchar_t* __wcs_ps = 0;
  2.1985 ++	  wchar_t* __wcs_ns = 0;
  2.1986 ++	  const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
  2.1987 ++	  try
  2.1988 ++            {
  2.1989 ++              mbstate_t __state;
  2.1990 ++              size_t __len;
  2.1991 ++              __len = strlen(__cpossign);
  2.1992 ++              if (__len)
  2.1993 ++                {
  2.1994 ++		  ++__len;
  2.1995 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.1996 ++		  __wcs_ps = new wchar_t[__len];
  2.1997 ++		  mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
  2.1998 ++		  _M_data->_M_positive_sign = __wcs_ps;
  2.1999 ++		}
  2.2000 ++	      else
  2.2001 ++		_M_data->_M_positive_sign = L"";
  2.2002 ++              _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
  2.2003 ++	      
  2.2004 ++	      __len = strlen(__cnegsign);
  2.2005 ++	      if (!__nposn)
  2.2006 ++		_M_data->_M_negative_sign = L"()";
  2.2007 ++	      else if (__len)
  2.2008 ++		{ 
  2.2009 ++		  ++__len;
  2.2010 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.2011 ++		  __wcs_ns = new wchar_t[__len];
  2.2012 ++		  mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
  2.2013 ++		  _M_data->_M_negative_sign = __wcs_ns;
  2.2014 ++		}
  2.2015 ++	      else
  2.2016 ++		_M_data->_M_negative_sign = L"";
  2.2017 ++              _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
  2.2018 ++
  2.2019 ++	      // _Intl == true.
  2.2020 ++	      __len = strlen(__ccurr);
  2.2021 ++	      if (__len)
  2.2022 ++		{
  2.2023 ++		  ++__len;
  2.2024 ++		  memset(&__state, 0, sizeof(mbstate_t));
  2.2025 ++		  wchar_t* __wcs = new wchar_t[__len];
  2.2026 ++		  mbsrtowcs(__wcs, &__ccurr, __len, &__state);
  2.2027 ++		  _M_data->_M_curr_symbol = __wcs;
  2.2028 ++		}
  2.2029 ++	      else
  2.2030 ++		_M_data->_M_curr_symbol = L"";
  2.2031 ++              _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
  2.2032 ++	    }
  2.2033 ++          catch (...)
  2.2034 ++	    {
  2.2035 ++	      delete _M_data;
  2.2036 ++              _M_data = 0;
  2.2037 ++	      delete __wcs_ps;
  2.2038 ++	      delete __wcs_ns;	      
  2.2039 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2040 ++	      __uselocale(__old);
  2.2041 ++#else
  2.2042 ++	      setlocale(LC_ALL, __old);
  2.2043 ++	      free(__old);
  2.2044 ++#endif
  2.2045 ++              __throw_exception_again;
  2.2046 ++	    }
  2.2047 ++
  2.2048 ++	  _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
  2.2049 ++	  char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
  2.2050 ++	  char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
  2.2051 ++	  char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
  2.2052 ++	  _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, 
  2.2053 ++	                                                __pposn);
  2.2054 ++	  char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
  2.2055 ++	  char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
  2.2056 ++	  _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, 
  2.2057 ++	                                                __nposn);
  2.2058 ++
  2.2059 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2060 ++	  __uselocale(__old);
  2.2061 ++#else
  2.2062 ++	  setlocale(LC_ALL, __old);
  2.2063 ++	  free(__old);
  2.2064 ++#endif
  2.2065 ++	}
  2.2066 ++    }
  2.2067 ++
  2.2068 ++  template<> 
  2.2069 ++    moneypunct<wchar_t, true>::~moneypunct()
  2.2070 ++    {
  2.2071 ++      if (_M_data->_M_positive_sign_size)
  2.2072 ++	delete [] _M_data->_M_positive_sign;
  2.2073 ++      if (_M_data->_M_negative_sign_size
  2.2074 ++          && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
  2.2075 ++	delete [] _M_data->_M_negative_sign;
  2.2076 ++      if (_M_data->_M_curr_symbol_size)
  2.2077 ++	delete [] _M_data->_M_curr_symbol;
  2.2078 ++      delete _M_data;
  2.2079 ++    }
  2.2080 ++
  2.2081 ++  template<> 
  2.2082 ++    moneypunct<wchar_t, false>::~moneypunct()
  2.2083 ++    {
  2.2084 ++      if (_M_data->_M_positive_sign_size)
  2.2085 ++	delete [] _M_data->_M_positive_sign;
  2.2086 ++      if (_M_data->_M_negative_sign_size
  2.2087 ++          && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
  2.2088 ++	delete [] _M_data->_M_negative_sign;
  2.2089 ++      if (_M_data->_M_curr_symbol_size)
  2.2090 ++	delete [] _M_data->_M_curr_symbol;
  2.2091 ++      delete _M_data;
  2.2092 ++    }
  2.2093 ++#endif
  2.2094 ++}
  2.2095 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/numeric_members.cc
  2.2096 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc	1970-01-01 01:00:00.000000000 +0100
  2.2097 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/numeric_members.cc	2007-08-15 22:51:01.000000000 +0200
  2.2098 +@@ -0,0 +1,183 @@
  2.2099 ++// std::numpunct implementation details, GNU version -*- C++ -*-
  2.2100 ++
  2.2101 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2.2102 ++//
  2.2103 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2104 ++// software; you can redistribute it and/or modify it under the
  2.2105 ++// terms of the GNU General Public License as published by the
  2.2106 ++// Free Software Foundation; either version 2, or (at your option)
  2.2107 ++// any later version.
  2.2108 ++
  2.2109 ++// This library is distributed in the hope that it will be useful,
  2.2110 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2111 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2112 ++// GNU General Public License for more details.
  2.2113 ++
  2.2114 ++// You should have received a copy of the GNU General Public License along
  2.2115 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2116 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2117 ++// USA.
  2.2118 ++
  2.2119 ++// As a special exception, you may use this file as part of a free software
  2.2120 ++// library without restriction.  Specifically, if other files instantiate
  2.2121 ++// templates or use macros or inline functions from this file, or you compile
  2.2122 ++// this file and link it with other files to produce an executable, this
  2.2123 ++// file does not by itself cause the resulting executable to be covered by
  2.2124 ++// the GNU General Public License.  This exception does not however
  2.2125 ++// invalidate any other reasons why the executable file might be covered by
  2.2126 ++// the GNU General Public License.
  2.2127 ++
  2.2128 ++//
  2.2129 ++// ISO C++ 14882: 22.2.3.1.2  numpunct virtual functions
  2.2130 ++//
  2.2131 ++
  2.2132 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.2133 ++
  2.2134 ++#define _LIBC
  2.2135 ++#include <locale>
  2.2136 ++#undef _LIBC
  2.2137 ++#include <bits/c++locale_internal.h>
  2.2138 ++
  2.2139 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.2140 ++#warning tailor for stub locale support
  2.2141 ++#endif
  2.2142 ++#ifndef __UCLIBC_HAS_XLOCALE__
  2.2143 ++#define __nl_langinfo_l(N, L)         nl_langinfo((N))
  2.2144 ++#endif
  2.2145 ++
  2.2146 ++namespace std
  2.2147 ++{
  2.2148 ++  template<> 
  2.2149 ++    void
  2.2150 ++    numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
  2.2151 ++    {
  2.2152 ++      if (!_M_data)
  2.2153 ++	_M_data = new __numpunct_cache<char>;
  2.2154 ++
  2.2155 ++      if (!__cloc)
  2.2156 ++	{
  2.2157 ++	  // "C" locale
  2.2158 ++	  _M_data->_M_grouping = "";
  2.2159 ++	  _M_data->_M_grouping_size = 0;
  2.2160 ++	  _M_data->_M_use_grouping = false;
  2.2161 ++
  2.2162 ++	  _M_data->_M_decimal_point = '.';
  2.2163 ++	  _M_data->_M_thousands_sep = ',';
  2.2164 ++
  2.2165 ++	  for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
  2.2166 ++	    _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
  2.2167 ++
  2.2168 ++	  for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
  2.2169 ++	    _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
  2.2170 ++	}
  2.2171 ++      else
  2.2172 ++	{
  2.2173 ++	  // Named locale.
  2.2174 ++	  _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT, 
  2.2175 ++							__cloc));
  2.2176 ++	  _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP, 
  2.2177 ++							__cloc));
  2.2178 ++
  2.2179 ++	  // Check for NULL, which implies no grouping.
  2.2180 ++	  if (_M_data->_M_thousands_sep == '\0')
  2.2181 ++	    _M_data->_M_grouping = "";
  2.2182 ++	  else
  2.2183 ++	    _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  2.2184 ++	  _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.2185 ++	}
  2.2186 ++
  2.2187 ++      // NB: There is no way to extact this info from posix locales.
  2.2188 ++      // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
  2.2189 ++      _M_data->_M_truename = "true";
  2.2190 ++      _M_data->_M_truename_size = strlen(_M_data->_M_truename);
  2.2191 ++      // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
  2.2192 ++      _M_data->_M_falsename = "false";
  2.2193 ++      _M_data->_M_falsename_size = strlen(_M_data->_M_falsename);
  2.2194 ++    }
  2.2195 ++ 
  2.2196 ++  template<> 
  2.2197 ++    numpunct<char>::~numpunct()
  2.2198 ++    { delete _M_data; }
  2.2199 ++   
  2.2200 ++#ifdef _GLIBCXX_USE_WCHAR_T
  2.2201 ++  template<> 
  2.2202 ++    void
  2.2203 ++    numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
  2.2204 ++    {
  2.2205 ++      if (!_M_data)
  2.2206 ++	_M_data = new __numpunct_cache<wchar_t>;
  2.2207 ++
  2.2208 ++      if (!__cloc)
  2.2209 ++	{
  2.2210 ++	  // "C" locale
  2.2211 ++	  _M_data->_M_grouping = "";
  2.2212 ++	  _M_data->_M_grouping_size = 0;
  2.2213 ++	  _M_data->_M_use_grouping = false;
  2.2214 ++
  2.2215 ++	  _M_data->_M_decimal_point = L'.';
  2.2216 ++	  _M_data->_M_thousands_sep = L',';
  2.2217 ++
  2.2218 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2219 ++	  __c_locale __old = __uselocale(_S_get_c_locale());
  2.2220 ++#endif
  2.2221 ++	  // Use ctype::widen code without the facet...
  2.2222 ++	  unsigned char uc;
  2.2223 ++	  for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
  2.2224 ++	    {
  2.2225 ++	      uc = static_cast<unsigned char>(__num_base::_S_atoms_out[__i]);
  2.2226 ++	      _M_data->_M_atoms_out[__i] = btowc(uc);
  2.2227 ++	    }
  2.2228 ++
  2.2229 ++	  for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
  2.2230 ++	    {
  2.2231 ++	      uc = static_cast<unsigned char>(__num_base::_S_atoms_in[__j]);
  2.2232 ++	      _M_data->_M_atoms_in[__j] = btowc(uc);
  2.2233 ++	    }
  2.2234 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2235 ++	  __uselocale(__old);
  2.2236 ++#endif
  2.2237 ++	}
  2.2238 ++      else
  2.2239 ++	{
  2.2240 ++	  // Named locale.
  2.2241 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.2242 ++#warning fix this
  2.2243 ++#endif
  2.2244 ++#ifdef __UCLIBC__
  2.2245 ++# ifdef __UCLIBC_HAS_XLOCALE__
  2.2246 ++	  _M_data->_M_decimal_point = __cloc->decimal_point_wc;
  2.2247 ++	  _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
  2.2248 ++# else
  2.2249 ++	  _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
  2.2250 ++	  _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
  2.2251 ++# endif
  2.2252 ++#else
  2.2253 ++	  union __s_and_w { const char *__s; unsigned int __w; } __u;
  2.2254 ++	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
  2.2255 ++	  _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
  2.2256 ++
  2.2257 ++	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
  2.2258 ++	  _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
  2.2259 ++#endif
  2.2260 ++
  2.2261 ++	  if (_M_data->_M_thousands_sep == L'\0')
  2.2262 ++	    _M_data->_M_grouping = "";
  2.2263 ++	  else
  2.2264 ++	    _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  2.2265 ++	  _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2.2266 ++	}
  2.2267 ++
  2.2268 ++      // NB: There is no way to extact this info from posix locales.
  2.2269 ++      // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
  2.2270 ++      _M_data->_M_truename = L"true";
  2.2271 ++      _M_data->_M_truename_size = wcslen(_M_data->_M_truename);
  2.2272 ++      // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
  2.2273 ++      _M_data->_M_falsename = L"false";
  2.2274 ++      _M_data->_M_falsename_size = wcslen(_M_data->_M_falsename);
  2.2275 ++    }
  2.2276 ++
  2.2277 ++  template<> 
  2.2278 ++    numpunct<wchar_t>::~numpunct()
  2.2279 ++    { delete _M_data; }
  2.2280 ++ #endif
  2.2281 ++}
  2.2282 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/time_members.cc gcc-3.4.6/libstdc++-v3/config/locale/uclibc/time_members.cc
  2.2283 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/time_members.cc	1970-01-01 01:00:00.000000000 +0100
  2.2284 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/time_members.cc	2007-08-15 22:51:01.000000000 +0200
  2.2285 +@@ -0,0 +1,356 @@
  2.2286 ++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
  2.2287 ++
  2.2288 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2.2289 ++//
  2.2290 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2291 ++// software; you can redistribute it and/or modify it under the
  2.2292 ++// terms of the GNU General Public License as published by the
  2.2293 ++// Free Software Foundation; either version 2, or (at your option)
  2.2294 ++// any later version.
  2.2295 ++
  2.2296 ++// This library is distributed in the hope that it will be useful,
  2.2297 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2298 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2299 ++// GNU General Public License for more details.
  2.2300 ++
  2.2301 ++// You should have received a copy of the GNU General Public License along
  2.2302 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2303 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2304 ++// USA.
  2.2305 ++
  2.2306 ++// As a special exception, you may use this file as part of a free software
  2.2307 ++// library without restriction.  Specifically, if other files instantiate
  2.2308 ++// templates or use macros or inline functions from this file, or you compile
  2.2309 ++// this file and link it with other files to produce an executable, this
  2.2310 ++// file does not by itself cause the resulting executable to be covered by
  2.2311 ++// the GNU General Public License.  This exception does not however
  2.2312 ++// invalidate any other reasons why the executable file might be covered by
  2.2313 ++// the GNU General Public License.
  2.2314 ++
  2.2315 ++//
  2.2316 ++// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
  2.2317 ++// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
  2.2318 ++//
  2.2319 ++
  2.2320 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.2321 ++
  2.2322 ++#include <locale>
  2.2323 ++#include <bits/c++locale_internal.h>
  2.2324 ++
  2.2325 ++#ifdef __UCLIBC_MJN3_ONLY__
  2.2326 ++#warning tailor for stub locale support
  2.2327 ++#endif
  2.2328 ++#ifndef __UCLIBC_HAS_XLOCALE__
  2.2329 ++#define __nl_langinfo_l(N, L)         nl_langinfo((N))
  2.2330 ++#endif
  2.2331 ++
  2.2332 ++namespace std
  2.2333 ++{
  2.2334 ++  template<>
  2.2335 ++    void
  2.2336 ++    __timepunct<char>::
  2.2337 ++    _M_put(char* __s, size_t __maxlen, const char* __format, 
  2.2338 ++	   const tm* __tm) const
  2.2339 ++    {
  2.2340 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2341 ++      const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
  2.2342 ++					_M_c_locale_timepunct);
  2.2343 ++#else
  2.2344 ++      char* __old = strdup(setlocale(LC_ALL, NULL));
  2.2345 ++      setlocale(LC_ALL, _M_name_timepunct);
  2.2346 ++      const size_t __len = strftime(__s, __maxlen, __format, __tm);
  2.2347 ++      setlocale(LC_ALL, __old);
  2.2348 ++      free(__old);
  2.2349 ++#endif
  2.2350 ++      // Make sure __s is null terminated.
  2.2351 ++      if (__len == 0)
  2.2352 ++	__s[0] = '\0';
  2.2353 ++    }
  2.2354 ++
  2.2355 ++  template<> 
  2.2356 ++    void
  2.2357 ++    __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
  2.2358 ++    {
  2.2359 ++      if (!_M_data)
  2.2360 ++	_M_data = new __timepunct_cache<char>;
  2.2361 ++
  2.2362 ++      if (!__cloc)
  2.2363 ++	{
  2.2364 ++	  // "C" locale
  2.2365 ++	  _M_c_locale_timepunct = _S_get_c_locale();
  2.2366 ++
  2.2367 ++	  _M_data->_M_date_format = "%m/%d/%y";
  2.2368 ++	  _M_data->_M_date_era_format = "%m/%d/%y";
  2.2369 ++	  _M_data->_M_time_format = "%H:%M:%S";
  2.2370 ++	  _M_data->_M_time_era_format = "%H:%M:%S";
  2.2371 ++	  _M_data->_M_date_time_format = "";
  2.2372 ++	  _M_data->_M_date_time_era_format = "";
  2.2373 ++	  _M_data->_M_am = "AM";
  2.2374 ++	  _M_data->_M_pm = "PM";
  2.2375 ++	  _M_data->_M_am_pm_format = "";
  2.2376 ++
  2.2377 ++	  // Day names, starting with "C"'s Sunday.
  2.2378 ++	  _M_data->_M_day1 = "Sunday";
  2.2379 ++	  _M_data->_M_day2 = "Monday";
  2.2380 ++	  _M_data->_M_day3 = "Tuesday";
  2.2381 ++	  _M_data->_M_day4 = "Wednesday";
  2.2382 ++	  _M_data->_M_day5 = "Thursday";
  2.2383 ++	  _M_data->_M_day6 = "Friday";
  2.2384 ++	  _M_data->_M_day7 = "Saturday";
  2.2385 ++
  2.2386 ++	  // Abbreviated day names, starting with "C"'s Sun.
  2.2387 ++	  _M_data->_M_aday1 = "Sun";
  2.2388 ++	  _M_data->_M_aday2 = "Mon";
  2.2389 ++	  _M_data->_M_aday3 = "Tue";
  2.2390 ++	  _M_data->_M_aday4 = "Wed";
  2.2391 ++	  _M_data->_M_aday5 = "Thu";
  2.2392 ++	  _M_data->_M_aday6 = "Fri";
  2.2393 ++	  _M_data->_M_aday7 = "Sat";
  2.2394 ++
  2.2395 ++	  // Month names, starting with "C"'s January.
  2.2396 ++	  _M_data->_M_month01 = "January";
  2.2397 ++	  _M_data->_M_month02 = "February";
  2.2398 ++	  _M_data->_M_month03 = "March";
  2.2399 ++	  _M_data->_M_month04 = "April";
  2.2400 ++	  _M_data->_M_month05 = "May";
  2.2401 ++	  _M_data->_M_month06 = "June";
  2.2402 ++	  _M_data->_M_month07 = "July";
  2.2403 ++	  _M_data->_M_month08 = "August";
  2.2404 ++	  _M_data->_M_month09 = "September";
  2.2405 ++	  _M_data->_M_month10 = "October";
  2.2406 ++	  _M_data->_M_month11 = "November";
  2.2407 ++	  _M_data->_M_month12 = "December";
  2.2408 ++
  2.2409 ++	  // Abbreviated month names, starting with "C"'s Jan.
  2.2410 ++	  _M_data->_M_amonth01 = "Jan";
  2.2411 ++	  _M_data->_M_amonth02 = "Feb";
  2.2412 ++	  _M_data->_M_amonth03 = "Mar";
  2.2413 ++	  _M_data->_M_amonth04 = "Apr";
  2.2414 ++	  _M_data->_M_amonth05 = "May";
  2.2415 ++	  _M_data->_M_amonth06 = "Jun";
  2.2416 ++	  _M_data->_M_amonth07 = "Jul";
  2.2417 ++	  _M_data->_M_amonth08 = "Aug";
  2.2418 ++	  _M_data->_M_amonth09 = "Sep";
  2.2419 ++	  _M_data->_M_amonth10 = "Oct";
  2.2420 ++	  _M_data->_M_amonth11 = "Nov";
  2.2421 ++	  _M_data->_M_amonth12 = "Dec";
  2.2422 ++	}
  2.2423 ++      else
  2.2424 ++	{
  2.2425 ++	  _M_c_locale_timepunct = _S_clone_c_locale(__cloc); 
  2.2426 ++
  2.2427 ++	  _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
  2.2428 ++	  _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
  2.2429 ++	  _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
  2.2430 ++	  _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
  2.2431 ++	  _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
  2.2432 ++	  _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc);
  2.2433 ++	  _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
  2.2434 ++	  _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
  2.2435 ++	  _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
  2.2436 ++
  2.2437 ++	  // Day names, starting with "C"'s Sunday.
  2.2438 ++	  _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
  2.2439 ++	  _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
  2.2440 ++	  _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
  2.2441 ++	  _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
  2.2442 ++	  _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
  2.2443 ++	  _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
  2.2444 ++	  _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
  2.2445 ++
  2.2446 ++	  // Abbreviated day names, starting with "C"'s Sun.
  2.2447 ++	  _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
  2.2448 ++	  _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
  2.2449 ++	  _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
  2.2450 ++	  _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
  2.2451 ++	  _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
  2.2452 ++	  _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
  2.2453 ++	  _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
  2.2454 ++
  2.2455 ++	  // Month names, starting with "C"'s January.
  2.2456 ++	  _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
  2.2457 ++	  _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
  2.2458 ++	  _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
  2.2459 ++	  _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
  2.2460 ++	  _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
  2.2461 ++	  _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
  2.2462 ++	  _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
  2.2463 ++	  _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
  2.2464 ++	  _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
  2.2465 ++	  _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
  2.2466 ++	  _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
  2.2467 ++	  _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
  2.2468 ++
  2.2469 ++	  // Abbreviated month names, starting with "C"'s Jan.
  2.2470 ++	  _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
  2.2471 ++	  _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
  2.2472 ++	  _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
  2.2473 ++	  _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
  2.2474 ++	  _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
  2.2475 ++	  _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
  2.2476 ++	  _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
  2.2477 ++	  _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
  2.2478 ++	  _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
  2.2479 ++	  _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
  2.2480 ++	  _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
  2.2481 ++	  _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
  2.2482 ++	}
  2.2483 ++    }
  2.2484 ++
  2.2485 ++#ifdef _GLIBCXX_USE_WCHAR_T
  2.2486 ++  template<>
  2.2487 ++    void
  2.2488 ++    __timepunct<wchar_t>::
  2.2489 ++    _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format, 
  2.2490 ++	   const tm* __tm) const
  2.2491 ++    {
  2.2492 ++#ifdef __UCLIBC_HAS_XLOCALE__
  2.2493 ++      __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
  2.2494 ++      const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
  2.2495 ++					_M_c_locale_timepunct);
  2.2496 ++#else
  2.2497 ++      char* __old = strdup(setlocale(LC_ALL, NULL));
  2.2498 ++      setlocale(LC_ALL, _M_name_timepunct);
  2.2499 ++      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
  2.2500 ++      setlocale(LC_ALL, __old);
  2.2501 ++      free(__old);
  2.2502 ++#endif
  2.2503 ++      // Make sure __s is null terminated.
  2.2504 ++      if (__len == 0)
  2.2505 ++	__s[0] = L'\0';
  2.2506 ++    }
  2.2507 ++
  2.2508 ++  template<> 
  2.2509 ++    void
  2.2510 ++    __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
  2.2511 ++    {
  2.2512 ++      if (!_M_data)
  2.2513 ++	_M_data = new __timepunct_cache<wchar_t>;
  2.2514 ++
  2.2515 ++#warning wide time stuff
  2.2516 ++//       if (!__cloc)
  2.2517 ++	{
  2.2518 ++	  // "C" locale
  2.2519 ++	  _M_c_locale_timepunct = _S_get_c_locale();
  2.2520 ++
  2.2521 ++	  _M_data->_M_date_format = L"%m/%d/%y";
  2.2522 ++	  _M_data->_M_date_era_format = L"%m/%d/%y";
  2.2523 ++	  _M_data->_M_time_format = L"%H:%M:%S";
  2.2524 ++	  _M_data->_M_time_era_format = L"%H:%M:%S";
  2.2525 ++	  _M_data->_M_date_time_format = L"";
  2.2526 ++	  _M_data->_M_date_time_era_format = L"";
  2.2527 ++	  _M_data->_M_am = L"AM";
  2.2528 ++	  _M_data->_M_pm = L"PM";
  2.2529 ++	  _M_data->_M_am_pm_format = L"";
  2.2530 ++
  2.2531 ++	  // Day names, starting with "C"'s Sunday.
  2.2532 ++	  _M_data->_M_day1 = L"Sunday";
  2.2533 ++	  _M_data->_M_day2 = L"Monday";
  2.2534 ++	  _M_data->_M_day3 = L"Tuesday";
  2.2535 ++	  _M_data->_M_day4 = L"Wednesday";
  2.2536 ++	  _M_data->_M_day5 = L"Thursday";
  2.2537 ++	  _M_data->_M_day6 = L"Friday";
  2.2538 ++	  _M_data->_M_day7 = L"Saturday";
  2.2539 ++
  2.2540 ++	  // Abbreviated day names, starting with "C"'s Sun.
  2.2541 ++	  _M_data->_M_aday1 = L"Sun";
  2.2542 ++	  _M_data->_M_aday2 = L"Mon";
  2.2543 ++	  _M_data->_M_aday3 = L"Tue";
  2.2544 ++	  _M_data->_M_aday4 = L"Wed";
  2.2545 ++	  _M_data->_M_aday5 = L"Thu";
  2.2546 ++	  _M_data->_M_aday6 = L"Fri";
  2.2547 ++	  _M_data->_M_aday7 = L"Sat";
  2.2548 ++
  2.2549 ++	  // Month names, starting with "C"'s January.
  2.2550 ++	  _M_data->_M_month01 = L"January";
  2.2551 ++	  _M_data->_M_month02 = L"February";
  2.2552 ++	  _M_data->_M_month03 = L"March";
  2.2553 ++	  _M_data->_M_month04 = L"April";
  2.2554 ++	  _M_data->_M_month05 = L"May";
  2.2555 ++	  _M_data->_M_month06 = L"June";
  2.2556 ++	  _M_data->_M_month07 = L"July";
  2.2557 ++	  _M_data->_M_month08 = L"August";
  2.2558 ++	  _M_data->_M_month09 = L"September";
  2.2559 ++	  _M_data->_M_month10 = L"October";
  2.2560 ++	  _M_data->_M_month11 = L"November";
  2.2561 ++	  _M_data->_M_month12 = L"December";
  2.2562 ++
  2.2563 ++	  // Abbreviated month names, starting with "C"'s Jan.
  2.2564 ++	  _M_data->_M_amonth01 = L"Jan";
  2.2565 ++	  _M_data->_M_amonth02 = L"Feb";
  2.2566 ++	  _M_data->_M_amonth03 = L"Mar";
  2.2567 ++	  _M_data->_M_amonth04 = L"Apr";
  2.2568 ++	  _M_data->_M_amonth05 = L"May";
  2.2569 ++	  _M_data->_M_amonth06 = L"Jun";
  2.2570 ++	  _M_data->_M_amonth07 = L"Jul";
  2.2571 ++	  _M_data->_M_amonth08 = L"Aug";
  2.2572 ++	  _M_data->_M_amonth09 = L"Sep";
  2.2573 ++	  _M_data->_M_amonth10 = L"Oct";
  2.2574 ++	  _M_data->_M_amonth11 = L"Nov";
  2.2575 ++	  _M_data->_M_amonth12 = L"Dec";
  2.2576 ++	}
  2.2577 ++#if 0
  2.2578 ++      else
  2.2579 ++	{
  2.2580 ++	  _M_c_locale_timepunct = _S_clone_c_locale(__cloc); 
  2.2581 ++
  2.2582 ++	  _M_data->_M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc));
  2.2583 ++	  _M_data->_M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc));
  2.2584 ++	  _M_data->_M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc));
  2.2585 ++	  _M_data->_M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc));
  2.2586 ++	  _M_data->_M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc));
  2.2587 ++	  _M_data->_M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc));
  2.2588 ++	  _M_data->_M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc));
  2.2589 ++	  _M_data->_M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc));
  2.2590 ++	  _M_data->_M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc));
  2.2591 ++
  2.2592 ++	  // Day names, starting with "C"'s Sunday.
  2.2593 ++	  _M_data->_M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc));
  2.2594 ++	  _M_data->_M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc));
  2.2595 ++	  _M_data->_M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc));
  2.2596 ++	  _M_data->_M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc));
  2.2597 ++	  _M_data->_M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc));
  2.2598 ++	  _M_data->_M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc));
  2.2599 ++	  _M_data->_M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc));
  2.2600 ++
  2.2601 ++	  // Abbreviated day names, starting with "C"'s Sun.
  2.2602 ++	  _M_data->_M_aday1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc));
  2.2603 ++	  _M_data->_M_aday2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc));
  2.2604 ++	  _M_data->_M_aday3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc));
  2.2605 ++	  _M_data->_M_aday4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc));
  2.2606 ++	  _M_data->_M_aday5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc));
  2.2607 ++	  _M_data->_M_aday6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc));
  2.2608 ++	  _M_data->_M_aday7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc));
  2.2609 ++
  2.2610 ++	  // Month names, starting with "C"'s January.
  2.2611 ++	  _M_data->_M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc));
  2.2612 ++	  _M_data->_M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc));
  2.2613 ++	  _M_data->_M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc));
  2.2614 ++	  _M_data->_M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc));
  2.2615 ++	  _M_data->_M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc));
  2.2616 ++	  _M_data->_M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc));
  2.2617 ++	  _M_data->_M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc));
  2.2618 ++	  _M_data->_M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc));
  2.2619 ++	  _M_data->_M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc));
  2.2620 ++	  _M_data->_M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc));
  2.2621 ++	  _M_data->_M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc));
  2.2622 ++	  _M_data->_M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc));
  2.2623 ++
  2.2624 ++	  // Abbreviated month names, starting with "C"'s Jan.
  2.2625 ++	  _M_data->_M_amonth01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc));
  2.2626 ++	  _M_data->_M_amonth02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc));
  2.2627 ++	  _M_data->_M_amonth03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc));
  2.2628 ++	  _M_data->_M_amonth04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc));
  2.2629 ++	  _M_data->_M_amonth05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc));
  2.2630 ++	  _M_data->_M_amonth06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc));
  2.2631 ++	  _M_data->_M_amonth07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc));
  2.2632 ++	  _M_data->_M_amonth08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc));
  2.2633 ++	  _M_data->_M_amonth09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc));
  2.2634 ++	  _M_data->_M_amonth10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc));
  2.2635 ++	  _M_data->_M_amonth11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc));
  2.2636 ++	  _M_data->_M_amonth12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc));
  2.2637 ++	}
  2.2638 ++#endif // 0
  2.2639 ++    }
  2.2640 ++#endif
  2.2641 ++}
  2.2642 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-3.4.6/libstdc++-v3/config/locale/uclibc/time_members.h
  2.2643 +--- gcc-3.4.6.orig/libstdc++-v3/config/locale/uclibc/time_members.h	1970-01-01 01:00:00.000000000 +0100
  2.2644 ++++ gcc-3.4.6/libstdc++-v3/config/locale/uclibc/time_members.h	2007-08-15 22:51:01.000000000 +0200
  2.2645 +@@ -0,0 +1,68 @@
  2.2646 ++// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
  2.2647 ++
  2.2648 ++// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2.2649 ++//
  2.2650 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2651 ++// software; you can redistribute it and/or modify it under the
  2.2652 ++// terms of the GNU General Public License as published by the
  2.2653 ++// Free Software Foundation; either version 2, or (at your option)
  2.2654 ++// any later version.
  2.2655 ++
  2.2656 ++// This library is distributed in the hope that it will be useful,
  2.2657 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2658 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2659 ++// GNU General Public License for more details.
  2.2660 ++
  2.2661 ++// You should have received a copy of the GNU General Public License along
  2.2662 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2663 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2664 ++// USA.
  2.2665 ++
  2.2666 ++// As a special exception, you may use this file as part of a free software
  2.2667 ++// library without restriction.  Specifically, if other files instantiate
  2.2668 ++// templates or use macros or inline functions from this file, or you compile
  2.2669 ++// this file and link it with other files to produce an executable, this
  2.2670 ++// file does not by itself cause the resulting executable to be covered by
  2.2671 ++// the GNU General Public License.  This exception does not however
  2.2672 ++// invalidate any other reasons why the executable file might be covered by
  2.2673 ++// the GNU General Public License.
  2.2674 ++
  2.2675 ++//
  2.2676 ++// ISO C++ 14882: 22.2.5.1.2 - time_get functions
  2.2677 ++// ISO C++ 14882: 22.2.5.3.2 - time_put functions
  2.2678 ++//
  2.2679 ++
  2.2680 ++// Written by Benjamin Kosnik <bkoz@redhat.com>
  2.2681 ++
  2.2682 ++  template<typename _CharT>
  2.2683 ++    __timepunct<_CharT>::__timepunct(size_t __refs) 
  2.2684 ++    : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), 
  2.2685 ++    _M_name_timepunct(_S_get_c_name())
  2.2686 ++    { _M_initialize_timepunct(); }
  2.2687 ++
  2.2688 ++  template<typename _CharT>
  2.2689 ++    __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 
  2.2690 ++    : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL), 
  2.2691 ++    _M_name_timepunct(_S_get_c_name())
  2.2692 ++    { _M_initialize_timepunct(); }
  2.2693 ++
  2.2694 ++  template<typename _CharT>
  2.2695 ++    __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
  2.2696 ++				     size_t __refs) 
  2.2697 ++    : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), 
  2.2698 ++    _M_name_timepunct(__s)
  2.2699 ++    { 
  2.2700 ++      char* __tmp = new char[std::strlen(__s) + 1];
  2.2701 ++      std::strcpy(__tmp, __s);
  2.2702 ++      _M_name_timepunct = __tmp;
  2.2703 ++      _M_initialize_timepunct(__cloc); 
  2.2704 ++    }
  2.2705 ++
  2.2706 ++  template<typename _CharT>
  2.2707 ++    __timepunct<_CharT>::~__timepunct()
  2.2708 ++    { 
  2.2709 ++      if (_M_name_timepunct != _S_get_c_name())
  2.2710 ++	delete [] _M_name_timepunct;
  2.2711 ++      delete _M_data; 
  2.2712 ++      _S_destroy_c_locale(_M_c_locale_timepunct); 
  2.2713 ++    }
  2.2714 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_base.h gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_base.h
  2.2715 +--- gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_base.h	1970-01-01 01:00:00.000000000 +0100
  2.2716 ++++ gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_base.h	2007-08-15 22:51:01.000000000 +0200
  2.2717 +@@ -0,0 +1,58 @@
  2.2718 ++// Locale support -*- C++ -*-
  2.2719 ++
  2.2720 ++// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003
  2.2721 ++// Free Software Foundation, Inc.
  2.2722 ++//
  2.2723 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2724 ++// software; you can redistribute it and/or modify it under the
  2.2725 ++// terms of the GNU General Public License as published by the
  2.2726 ++// Free Software Foundation; either version 2, or (at your option)
  2.2727 ++// any later version.
  2.2728 ++
  2.2729 ++// This library is distributed in the hope that it will be useful,
  2.2730 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2731 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2732 ++// GNU General Public License for more details.
  2.2733 ++
  2.2734 ++// You should have received a copy of the GNU General Public License along
  2.2735 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2736 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2737 ++// USA.
  2.2738 ++
  2.2739 ++// As a special exception, you may use this file as part of a free software
  2.2740 ++// library without restriction.  Specifically, if other files instantiate
  2.2741 ++// templates or use macros or inline functions from this file, or you compile
  2.2742 ++// this file and link it with other files to produce an executable, this
  2.2743 ++// file does not by itself cause the resulting executable to be covered by
  2.2744 ++// the GNU General Public License.  This exception does not however
  2.2745 ++// invalidate any other reasons why the executable file might be covered by
  2.2746 ++// the GNU General Public License.
  2.2747 ++
  2.2748 ++//
  2.2749 ++// ISO C++ 14882: 22.1  Locales
  2.2750 ++//
  2.2751 ++  
  2.2752 ++// Information as gleaned from /usr/include/ctype.h
  2.2753 ++  
  2.2754 ++  struct ctype_base
  2.2755 ++  {
  2.2756 ++    // Note: In uClibc, the following two types depend on configuration.
  2.2757 ++ 
  2.2758 ++    // Non-standard typedefs.
  2.2759 ++    typedef const __ctype_touplow_t* __to_type;
  2.2760 ++
  2.2761 ++    // NB: Offsets into ctype<char>::_M_table force a particular size
  2.2762 ++    // on the mask type. Because of this, we don't use an enum.
  2.2763 ++    typedef __ctype_mask_t	mask;   
  2.2764 ++    static const mask upper    	= _ISupper;
  2.2765 ++    static const mask lower 	= _ISlower;
  2.2766 ++    static const mask alpha 	= _ISalpha;
  2.2767 ++    static const mask digit 	= _ISdigit;
  2.2768 ++    static const mask xdigit 	= _ISxdigit;
  2.2769 ++    static const mask space 	= _ISspace;
  2.2770 ++    static const mask print 	= _ISprint;
  2.2771 ++    static const mask graph 	= _ISalpha | _ISdigit | _ISpunct;
  2.2772 ++    static const mask cntrl 	= _IScntrl;
  2.2773 ++    static const mask punct 	= _ISpunct;
  2.2774 ++    static const mask alnum 	= _ISalpha | _ISdigit;
  2.2775 ++  };
  2.2776 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_inline.h gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_inline.h
  2.2777 +--- gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_inline.h	1970-01-01 01:00:00.000000000 +0100
  2.2778 ++++ gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_inline.h	2007-08-15 22:51:01.000000000 +0200
  2.2779 +@@ -0,0 +1,69 @@
  2.2780 ++// Locale support -*- C++ -*-
  2.2781 ++
  2.2782 ++// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
  2.2783 ++//
  2.2784 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2785 ++// software; you can redistribute it and/or modify it under the
  2.2786 ++// terms of the GNU General Public License as published by the
  2.2787 ++// Free Software Foundation; either version 2, or (at your option)
  2.2788 ++// any later version.
  2.2789 ++
  2.2790 ++// This library is distributed in the hope that it will be useful,
  2.2791 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2792 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2793 ++// GNU General Public License for more details.
  2.2794 ++
  2.2795 ++// You should have received a copy of the GNU General Public License along
  2.2796 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2797 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2798 ++// USA.
  2.2799 ++
  2.2800 ++// As a special exception, you may use this file as part of a free software
  2.2801 ++// library without restriction.  Specifically, if other files instantiate
  2.2802 ++// templates or use macros or inline functions from this file, or you compile
  2.2803 ++// this file and link it with other files to produce an executable, this
  2.2804 ++// file does not by itself cause the resulting executable to be covered by
  2.2805 ++// the GNU General Public License.  This exception does not however
  2.2806 ++// invalidate any other reasons why the executable file might be covered by
  2.2807 ++// the GNU General Public License.
  2.2808 ++
  2.2809 ++//
  2.2810 ++// ISO C++ 14882: 22.1  Locales
  2.2811 ++//
  2.2812 ++  
  2.2813 ++// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
  2.2814 ++// functions go in ctype.cc
  2.2815 ++  
  2.2816 ++  bool
  2.2817 ++  ctype<char>::
  2.2818 ++  is(mask __m, char __c) const
  2.2819 ++  { return _M_table[static_cast<unsigned char>(__c)] & __m; }
  2.2820 ++
  2.2821 ++  const char*
  2.2822 ++  ctype<char>::
  2.2823 ++  is(const char* __low, const char* __high, mask* __vec) const
  2.2824 ++  {
  2.2825 ++    while (__low < __high)
  2.2826 ++      *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
  2.2827 ++    return __high;
  2.2828 ++  }
  2.2829 ++
  2.2830 ++  const char*
  2.2831 ++  ctype<char>::
  2.2832 ++  scan_is(mask __m, const char* __low, const char* __high) const
  2.2833 ++  {
  2.2834 ++    while (__low < __high 
  2.2835 ++	   && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
  2.2836 ++      ++__low;
  2.2837 ++    return __low;
  2.2838 ++  }
  2.2839 ++
  2.2840 ++  const char*
  2.2841 ++  ctype<char>::
  2.2842 ++  scan_not(mask __m, const char* __low, const char* __high) const
  2.2843 ++  {
  2.2844 ++    while (__low < __high 
  2.2845 ++	   && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
  2.2846 ++      ++__low;
  2.2847 ++    return __low;
  2.2848 ++  }
  2.2849 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_noninline.h gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_noninline.h
  2.2850 +--- gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/ctype_noninline.h	1970-01-01 01:00:00.000000000 +0100
  2.2851 ++++ gcc-3.4.6/libstdc++-v3/config/os/uclibc/ctype_noninline.h	2007-08-15 22:51:01.000000000 +0200
  2.2852 +@@ -0,0 +1,92 @@
  2.2853 ++// Locale support -*- C++ -*-
  2.2854 ++
  2.2855 ++// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
  2.2856 ++// Free Software Foundation, Inc.
  2.2857 ++//
  2.2858 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2859 ++// software; you can redistribute it and/or modify it under the
  2.2860 ++// terms of the GNU General Public License as published by the
  2.2861 ++// Free Software Foundation; either version 2, or (at your option)
  2.2862 ++// any later version.
  2.2863 ++
  2.2864 ++// This library is distributed in the hope that it will be useful,
  2.2865 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2866 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2867 ++// GNU General Public License for more details.
  2.2868 ++
  2.2869 ++// You should have received a copy of the GNU General Public License along
  2.2870 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2871 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2872 ++// USA.
  2.2873 ++
  2.2874 ++// As a special exception, you may use this file as part of a free software
  2.2875 ++// library without restriction.  Specifically, if other files instantiate
  2.2876 ++// templates or use macros or inline functions from this file, or you compile
  2.2877 ++// this file and link it with other files to produce an executable, this
  2.2878 ++// file does not by itself cause the resulting executable to be covered by
  2.2879 ++// the GNU General Public License.  This exception does not however
  2.2880 ++// invalidate any other reasons why the executable file might be covered by
  2.2881 ++// the GNU General Public License.
  2.2882 ++
  2.2883 ++//
  2.2884 ++// ISO C++ 14882: 22.1  Locales
  2.2885 ++//
  2.2886 ++  
  2.2887 ++// Information as gleaned from /usr/include/ctype.h
  2.2888 ++
  2.2889 ++  const ctype_base::mask*
  2.2890 ++  ctype<char>::classic_table() throw()
  2.2891 ++  { return __C_ctype_b; }
  2.2892 ++
  2.2893 ++  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
  2.2894 ++		     size_t __refs) 
  2.2895 ++  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), 
  2.2896 ++  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
  2.2897 ++  {
  2.2898 ++    _M_toupper = __C_ctype_toupper;
  2.2899 ++    _M_tolower = __C_ctype_tolower;
  2.2900 ++    _M_table = __table ? __table : __C_ctype_b;
  2.2901 ++    memset(_M_widen, 0, sizeof(_M_widen));
  2.2902 ++    memset(_M_narrow, 0, sizeof(_M_narrow));
  2.2903 ++  }
  2.2904 ++
  2.2905 ++  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
  2.2906 ++  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), 
  2.2907 ++  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
  2.2908 ++  {
  2.2909 ++    _M_toupper = __C_ctype_toupper;
  2.2910 ++    _M_tolower = __C_ctype_tolower;
  2.2911 ++    _M_table = __table ? __table : __C_ctype_b;
  2.2912 ++    memset(_M_widen, 0, sizeof(_M_widen));
  2.2913 ++    memset(_M_narrow, 0, sizeof(_M_narrow));
  2.2914 ++  }
  2.2915 ++
  2.2916 ++  char
  2.2917 ++  ctype<char>::do_toupper(char __c) const
  2.2918 ++  { return _M_toupper[static_cast<unsigned char>(__c)]; }
  2.2919 ++
  2.2920 ++  const char*
  2.2921 ++  ctype<char>::do_toupper(char* __low, const char* __high) const
  2.2922 ++  {
  2.2923 ++    while (__low < __high)
  2.2924 ++      {
  2.2925 ++	*__low = _M_toupper[static_cast<unsigned char>(*__low)];
  2.2926 ++	++__low;
  2.2927 ++      }
  2.2928 ++    return __high;
  2.2929 ++  }
  2.2930 ++
  2.2931 ++  char
  2.2932 ++  ctype<char>::do_tolower(char __c) const
  2.2933 ++  { return _M_tolower[static_cast<unsigned char>(__c)]; }
  2.2934 ++
  2.2935 ++  const char* 
  2.2936 ++  ctype<char>::do_tolower(char* __low, const char* __high) const
  2.2937 ++  {
  2.2938 ++    while (__low < __high)
  2.2939 ++      {
  2.2940 ++	*__low = _M_tolower[static_cast<unsigned char>(*__low)];
  2.2941 ++	++__low;
  2.2942 ++      }
  2.2943 ++    return __high;
  2.2944 ++  }
  2.2945 +diff -durN gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/os_defines.h gcc-3.4.6/libstdc++-v3/config/os/uclibc/os_defines.h
  2.2946 +--- gcc-3.4.6.orig/libstdc++-v3/config/os/uclibc/os_defines.h	1970-01-01 01:00:00.000000000 +0100
  2.2947 ++++ gcc-3.4.6/libstdc++-v3/config/os/uclibc/os_defines.h	2007-08-15 22:51:01.000000000 +0200
  2.2948 +@@ -0,0 +1,44 @@
  2.2949 ++// Specific definitions for GNU/Linux  -*- C++ -*-
  2.2950 ++
  2.2951 ++// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
  2.2952 ++//
  2.2953 ++// This file is part of the GNU ISO C++ Library.  This library is free
  2.2954 ++// software; you can redistribute it and/or modify it under the
  2.2955 ++// terms of the GNU General Public License as published by the
  2.2956 ++// Free Software Foundation; either version 2, or (at your option)
  2.2957 ++// any later version.
  2.2958 ++
  2.2959 ++// This library is distributed in the hope that it will be useful,
  2.2960 ++// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2.2961 ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2.2962 ++// GNU General Public License for more details.
  2.2963 ++
  2.2964 ++// You should have received a copy of the GNU General Public License along
  2.2965 ++// with this library; see the file COPYING.  If not, write to the Free
  2.2966 ++// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2.2967 ++// USA.
  2.2968 ++
  2.2969 ++// As a special exception, you may use this file as part of a free software
  2.2970 ++// library without restriction.  Specifically, if other files instantiate
  2.2971 ++// templates or use macros or inline functions from this file, or you compile
  2.2972 ++// this file and link it with other files to produce an executable, this
  2.2973 ++// file does not by itself cause the resulting executable to be covered by
  2.2974 ++// the GNU General Public License.  This exception does not however
  2.2975 ++// invalidate any other reasons why the executable file might be covered by
  2.2976 ++// the GNU General Public License.
  2.2977 ++
  2.2978 ++#ifndef _GLIBCXX_OS_DEFINES
  2.2979 ++#define _GLIBCXX_OS_DEFINES 1
  2.2980 ++
  2.2981 ++// System-specific #define, typedefs, corrections, etc, go here.  This
  2.2982 ++// file will come before all others.
  2.2983 ++
  2.2984 ++// This keeps isanum, et al from being propagated as macros.
  2.2985 ++#define __NO_CTYPE 1
  2.2986 ++
  2.2987 ++#include <features.h>
  2.2988 ++
  2.2989 ++// We must not see the optimized string functions GNU libc defines.
  2.2990 ++#define __NO_STRING_INLINES
  2.2991 ++
  2.2992 ++#endif
  2.2993 +diff -durN gcc-3.4.6.orig/libstdc++-v3/configure gcc-3.4.6/libstdc++-v3/configure
  2.2994 +--- gcc-3.4.6.orig/libstdc++-v3/configure	2005-02-01 07:31:23.000000000 +0100
  2.2995 ++++ gcc-3.4.6/libstdc++-v3/configure	2007-08-15 22:51:01.000000000 +0200
  2.2996 +@@ -4012,6 +4012,11 @@
  2.2997 +   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
  2.2998 +   ;;
  2.2999 + 
  2.3000 ++linux-uclibc*)
  2.3001 ++  lt_cv_deplibs_check_method=pass_all
  2.3002 ++  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
  2.3003 ++  ;;
  2.3004 ++
  2.3005 + netbsd*)
  2.3006 +   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
  2.3007 +     lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
  2.3008 +@@ -5679,7 +5684,7 @@
  2.3009 +   enableval="$enable_clocale"
  2.3010 + 
  2.3011 +       case "$enableval" in
  2.3012 +-       generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
  2.3013 ++       generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
  2.3014 +        *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
  2.3015 + echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
  2.3016 +    { (exit 1); exit 1; }; } ;;
  2.3017 +@@ -5704,6 +5709,9 @@
  2.3018 +   # Default to "generic".
  2.3019 +   if test $enable_clocale_flag = auto; then
  2.3020 +     case x${target_os} in
  2.3021 ++      xlinux-uclibc*)
  2.3022 ++	enable_clocale_flag=uclibc
  2.3023 ++	;;
  2.3024 +       xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
  2.3025 +         cat >conftest.$ac_ext <<_ACEOF
  2.3026 + /* confdefs.h.  */
  2.3027 +@@ -5916,6 +5924,77 @@
  2.3028 +       CTIME_CC=config/locale/generic/time_members.cc
  2.3029 +       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2.3030 +       ;;
  2.3031 ++    uclibc)
  2.3032 ++      echo "$as_me:$LINENO: result: uclibc" >&5
  2.3033 ++echo "${ECHO_T}uclibc" >&6
  2.3034 ++
  2.3035 ++      # Declare intention to use gettext, and add support for specific
  2.3036 ++      # languages.
  2.3037 ++      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
  2.3038 ++      ALL_LINGUAS="de fr"
  2.3039 ++
  2.3040 ++      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
  2.3041 ++      # Extract the first word of "msgfmt", so it can be a program name with args.
  2.3042 ++set dummy msgfmt; ac_word=$2
  2.3043 ++echo "$as_me:$LINENO: checking for $ac_word" >&5
  2.3044 ++echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
  2.3045 ++if test "${ac_cv_prog_check_msgfmt+set}" = set; then
  2.3046 ++  echo $ECHO_N "(cached) $ECHO_C" >&6
  2.3047 ++else
  2.3048 ++  if test -n "$check_msgfmt"; then
  2.3049 ++  ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
  2.3050 ++else
  2.3051 ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  2.3052 ++for as_dir in $PATH
  2.3053 ++do
  2.3054 ++  IFS=$as_save_IFS
  2.3055 ++  test -z "$as_dir" && as_dir=.
  2.3056 ++  for ac_exec_ext in '' $ac_executable_extensions; do
  2.3057 ++  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
  2.3058 ++    ac_cv_prog_check_msgfmt="yes"
  2.3059 ++    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
  2.3060 ++    break 2
  2.3061 ++  fi
  2.3062 ++done
  2.3063 ++done
  2.3064 ++
  2.3065 ++  test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
  2.3066 ++fi
  2.3067 ++fi
  2.3068 ++check_msgfmt=$ac_cv_prog_check_msgfmt
  2.3069 ++if test -n "$check_msgfmt"; then
  2.3070 ++  echo "$as_me:$LINENO: result: $check_msgfmt" >&5
  2.3071 ++echo "${ECHO_T}$check_msgfmt" >&6
  2.3072 ++else
  2.3073 ++  echo "$as_me:$LINENO: result: no" >&5
  2.3074 ++echo "${ECHO_T}no" >&6
  2.3075 ++fi
  2.3076 ++
  2.3077 ++      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
  2.3078 ++        USE_NLS=yes
  2.3079 ++      fi
  2.3080 ++      # Export the build objects.
  2.3081 ++      for ling in $ALL_LINGUAS; do \
  2.3082 ++        glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
  2.3083 ++        glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
  2.3084 ++      done
  2.3085 ++
  2.3086 ++
  2.3087 ++
  2.3088 ++      CLOCALE_H=config/locale/uclibc/c_locale.h
  2.3089 ++      CLOCALE_CC=config/locale/uclibc/c_locale.cc
  2.3090 ++      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
  2.3091 ++      CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
  2.3092 ++      CCOLLATE_CC=config/locale/uclibc/collate_members.cc
  2.3093 ++      CCTYPE_CC=config/locale/uclibc/ctype_members.cc
  2.3094 ++      CMESSAGES_H=config/locale/uclibc/messages_members.h
  2.3095 ++      CMESSAGES_CC=config/locale/uclibc/messages_members.cc
  2.3096 ++      CMONEY_CC=config/locale/uclibc/monetary_members.cc
  2.3097 ++      CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
  2.3098 ++      CTIME_H=config/locale/uclibc/time_members.h
  2.3099 ++      CTIME_CC=config/locale/uclibc/time_members.cc
  2.3100 ++      CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
  2.3101 ++      ;;
  2.3102 +   esac
  2.3103 + 
  2.3104 +   # This is where the testsuite looks for locale catalogs, using the
  2.3105 +diff -durN gcc-3.4.6.orig/libstdc++-v3/configure.host gcc-3.4.6/libstdc++-v3/configure.host
  2.3106 +--- gcc-3.4.6.orig/libstdc++-v3/configure.host	2004-10-05 18:32:49.000000000 +0200
  2.3107 ++++ gcc-3.4.6/libstdc++-v3/configure.host	2007-08-15 22:51:01.000000000 +0200
  2.3108 +@@ -217,6 +217,12 @@
  2.3109 +     ;;
  2.3110 + esac
  2.3111 + 
  2.3112 ++# Override for uClibc since linux-uclibc gets mishandled above.
  2.3113 ++case "${host_os}" in
  2.3114 ++  *-uclibc*)
  2.3115 ++    os_include_dir="os/uclibc"
  2.3116 ++    ;;
  2.3117 ++esac
  2.3118 + 
  2.3119 + # Set any OS-dependent and CPU-dependent bits.
  2.3120 + # THIS TABLE IS SORTED.  KEEP IT THAT WAY.
  2.3121 +diff -durN gcc-3.4.6.orig/libstdc++-v3/crossconfig.m4 gcc-3.4.6/libstdc++-v3/crossconfig.m4
  2.3122 +--- gcc-3.4.6.orig/libstdc++-v3/crossconfig.m4	2005-02-01 07:31:23.000000000 +0100
  2.3123 ++++ gcc-3.4.6/libstdc++-v3/crossconfig.m4	2007-08-15 22:51:01.000000000 +0200
  2.3124 +@@ -138,6 +138,99 @@
  2.3125 + 	;;
  2.3126 +     esac
  2.3127 +     ;;
  2.3128 ++  *-uclibc*)
  2.3129 ++# Temporary hack until we implement the float versions of the libm funcs
  2.3130 ++    AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
  2.3131 ++      machine/endian.h machine/param.h sys/machine.h sys/types.h \
  2.3132 ++      fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
  2.3133 ++    SECTION_FLAGS='-ffunction-sections -fdata-sections'
  2.3134 ++    AC_SUBST(SECTION_FLAGS)
  2.3135 ++    GLIBCXX_CHECK_LINKER_FEATURES
  2.3136 ++    GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
  2.3137 ++    GLIBCXX_CHECK_WCHAR_T_SUPPORT
  2.3138 ++
  2.3139 ++    # For LFS.
  2.3140 ++    AC_DEFINE(HAVE_INT64_T)
  2.3141 ++    case "$target" in
  2.3142 ++      *-uclinux*)
  2.3143 ++        # Don't enable LFS with uClinux
  2.3144 ++        ;;
  2.3145 ++      *)
  2.3146 ++        AC_DEFINE(_GLIBCXX_USE_LFS)
  2.3147 ++    esac
  2.3148 ++
  2.3149 ++    # For showmanyc_helper().
  2.3150 ++    AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
  2.3151 ++    GLIBCXX_CHECK_POLL
  2.3152 ++    GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
  2.3153 ++
  2.3154 ++    # For xsputn_2().
  2.3155 ++    AC_CHECK_HEADERS(sys/uio.h)
  2.3156 ++    GLIBCXX_CHECK_WRITEV
  2.3157 ++
  2.3158 ++#     AC_DEFINE(HAVE_ACOSF)
  2.3159 ++#     AC_DEFINE(HAVE_ASINF)
  2.3160 ++#     AC_DEFINE(HAVE_ATANF)
  2.3161 ++#     AC_DEFINE(HAVE_ATAN2F)
  2.3162 ++    AC_DEFINE(HAVE_CEILF)
  2.3163 ++    AC_DEFINE(HAVE_COPYSIGN)
  2.3164 ++#     AC_DEFINE(HAVE_COPYSIGNF)
  2.3165 ++#     AC_DEFINE(HAVE_COSF)
  2.3166 ++#     AC_DEFINE(HAVE_COSHF)
  2.3167 ++#     AC_DEFINE(HAVE_EXPF)
  2.3168 ++#     AC_DEFINE(HAVE_FABSF)
  2.3169 ++    AC_DEFINE(HAVE_FINITE)
  2.3170 ++    AC_DEFINE(HAVE_FINITEF)
  2.3171 ++    AC_DEFINE(HAVE_FLOORF)
  2.3172 ++#     AC_DEFINE(HAVE_FMODF)
  2.3173 ++#     AC_DEFINE(HAVE_FREXPF)
  2.3174 ++    AC_DEFINE(HAVE_HYPOT)
  2.3175 ++#     AC_DEFINE(HAVE_HYPOTF)
  2.3176 ++    AC_DEFINE(HAVE_ISINF)
  2.3177 ++    AC_DEFINE(HAVE_ISINFF)
  2.3178 ++    AC_DEFINE(HAVE_ISNAN)
  2.3179 ++    AC_DEFINE(HAVE_ISNANF)
  2.3180 ++#     AC_DEFINE(HAVE_LOGF)
  2.3181 ++#     AC_DEFINE(HAVE_LOG10F)
  2.3182 ++#     AC_DEFINE(HAVE_MODFF)
  2.3183 ++#     AC_DEFINE(HAVE_SINF)
  2.3184 ++#     AC_DEFINE(HAVE_SINHF)
  2.3185 ++#     AC_DEFINE(HAVE_SINCOS)
  2.3186 ++#     AC_DEFINE(HAVE_SINCOSF)
  2.3187 ++    AC_DEFINE(HAVE_SQRTF)
  2.3188 ++#     AC_DEFINE(HAVE_TANF)
  2.3189 ++#     AC_DEFINE(HAVE_TANHF)
  2.3190 ++    if test x"long_double_math_on_this_cpu" = x"yes"; then
  2.3191 ++      AC_MSG_ERROR([long_double_math_on_this_cpu is yes!])
  2.3192 ++#       AC_DEFINE(HAVE_ACOSL)
  2.3193 ++#       AC_DEFINE(HAVE_ASINL)
  2.3194 ++#       AC_DEFINE(HAVE_ATANL)
  2.3195 ++#       AC_DEFINE(HAVE_ATAN2L)
  2.3196 ++#       AC_DEFINE(HAVE_CEILL)
  2.3197 ++#       AC_DEFINE(HAVE_COPYSIGNL)
  2.3198 ++#       AC_DEFINE(HAVE_COSL)
  2.3199 ++#       AC_DEFINE(HAVE_COSHL)
  2.3200 ++#       AC_DEFINE(HAVE_EXPL)
  2.3201 ++#       AC_DEFINE(HAVE_FABSL)
  2.3202 ++#       AC_DEFINE(HAVE_FINITEL)
  2.3203 ++#       AC_DEFINE(HAVE_FLOORL)
  2.3204 ++#       AC_DEFINE(HAVE_FMODL)
  2.3205 ++#       AC_DEFINE(HAVE_FREXPL)
  2.3206 ++#       AC_DEFINE(HAVE_HYPOTL)
  2.3207 ++#       AC_DEFINE(HAVE_ISINFL)
  2.3208 ++#       AC_DEFINE(HAVE_ISNANL)
  2.3209 ++#       AC_DEFINE(HAVE_LOGL)
  2.3210 ++#       AC_DEFINE(HAVE_LOG10L)
  2.3211 ++#       AC_DEFINE(HAVE_MODFL)
  2.3212 ++#       AC_DEFINE(HAVE_POWL)
  2.3213 ++#       AC_DEFINE(HAVE_SINL)
  2.3214 ++#       AC_DEFINE(HAVE_SINHL)
  2.3215 ++#       AC_DEFINE(HAVE_SINCOSL)
  2.3216 ++#       AC_DEFINE(HAVE_SQRTL)
  2.3217 ++#       AC_DEFINE(HAVE_TANL)
  2.3218 ++#       AC_DEFINE(HAVE_TANHL)
  2.3219 ++    fi
  2.3220 ++    ;;
  2.3221 +   *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-knetbsd*-gnu)
  2.3222 +     AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
  2.3223 +       machine/endian.h machine/param.h sys/machine.h sys/types.h \
  2.3224 +@@ -152,7 +245,7 @@
  2.3225 +     AC_DEFINE(HAVE_INT64_T)
  2.3226 +     case "$target" in
  2.3227 +       *-uclinux*)
  2.3228 +-        # Don't enable LFS with uClibc
  2.3229 ++        # Don't enable LFS with uClinux
  2.3230 +         ;;
  2.3231 +       *)
  2.3232 +         AC_DEFINE(_GLIBCXX_USE_LFS)
  2.3233 +diff -durN gcc-3.4.6.orig/libstdc++-v3/include/c_compatibility/wchar.h gcc-3.4.6/libstdc++-v3/include/c_compatibility/wchar.h
  2.3234 +--- gcc-3.4.6.orig/libstdc++-v3/include/c_compatibility/wchar.h	2003-12-09 04:51:46.000000000 +0100
  2.3235 ++++ gcc-3.4.6/libstdc++-v3/include/c_compatibility/wchar.h	2007-08-15 22:51:01.000000000 +0200
  2.3236 +@@ -101,7 +101,9 @@
  2.3237 + using std::wmemcpy;
  2.3238 + using std::wmemmove;
  2.3239 + using std::wmemset;
  2.3240 ++#if _GLIBCXX_HAVE_WCSFTIME
  2.3241 + using std::wcsftime;
  2.3242 ++#endif
  2.3243 + 
  2.3244 + #if _GLIBCXX_USE_C99
  2.3245 + using std::wcstold;
  2.3246 +diff -durN gcc-3.4.6.orig/libstdc++-v3/include/c_std/std_cwchar.h gcc-3.4.6/libstdc++-v3/include/c_std/std_cwchar.h
  2.3247 +--- gcc-3.4.6.orig/libstdc++-v3/include/c_std/std_cwchar.h	2004-07-20 10:52:12.000000000 +0200
  2.3248 ++++ gcc-3.4.6/libstdc++-v3/include/c_std/std_cwchar.h	2007-08-15 22:51:01.000000000 +0200
  2.3249 +@@ -179,7 +179,9 @@
  2.3250 +   using ::wcscoll;
  2.3251 +   using ::wcscpy;
  2.3252 +   using ::wcscspn;
  2.3253 ++#if _GLIBCXX_HAVE_WCSFTIME
  2.3254 +   using ::wcsftime;
  2.3255 ++#endif
  2.3256 +   using ::wcslen;
  2.3257 +   using ::wcsncat;
  2.3258 +   using ::wcsncmp;
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/patches/gcc/3.4.6/300-libstdc++-pic.patch	Wed Aug 15 21:23:08 2007 +0000
     3.3 @@ -0,0 +1,46 @@
     3.4 +diff -durN gcc-3.4.6.orig/libstdc++-v3/src/Makefile.am gcc-3.4.6/libstdc++-v3/src/Makefile.am
     3.5 +--- gcc-3.4.6.orig/libstdc++-v3/src/Makefile.am	2004-04-16 21:08:35.000000000 +0200
     3.6 ++++ gcc-3.4.6/libstdc++-v3/src/Makefile.am	2007-08-15 22:52:23.000000000 +0200
     3.7 +@@ -210,6 +210,10 @@
     3.8 + 	  $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
     3.9 + 
    3.10 + 
    3.11 ++install-exec-local:
    3.12 ++	$(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
    3.13 ++	$(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
    3.14 ++
    3.15 + # Added bits to build debug library.
    3.16 + if GLIBCXX_BUILD_DEBUG
    3.17 + all-local: build_debug
    3.18 +diff -durN gcc-3.4.6.orig/libstdc++-v3/src/Makefile.in gcc-3.4.6/libstdc++-v3/src/Makefile.in
    3.19 +--- gcc-3.4.6.orig/libstdc++-v3/src/Makefile.in	2004-04-16 21:08:35.000000000 +0200
    3.20 ++++ gcc-3.4.6/libstdc++-v3/src/Makefile.in	2007-08-15 22:52:23.000000000 +0200
    3.21 +@@ -592,7 +592,7 @@
    3.22 + 
    3.23 + install-data-am: install-data-local
    3.24 + 
    3.25 +-install-exec-am: install-toolexeclibLTLIBRARIES
    3.26 ++install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
    3.27 + 
    3.28 + install-info: install-info-am
    3.29 + 
    3.30 +@@ -625,6 +625,7 @@
    3.31 + 	distclean-tags distdir dvi dvi-am info info-am install \
    3.32 + 	install-am install-data install-data-am install-data-local \
    3.33 + 	install-exec install-exec-am install-info install-info-am \
    3.34 ++	install-exec-local \
    3.35 + 	install-man install-strip install-toolexeclibLTLIBRARIES \
    3.36 + 	installcheck installcheck-am installdirs maintainer-clean \
    3.37 + 	maintainer-clean-generic mostlyclean mostlyclean-compile \
    3.38 +@@ -709,6 +710,11 @@
    3.39 + install_debug:
    3.40 + 	(cd ${debugdir} && $(MAKE) \
    3.41 + 	toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
    3.42 ++
    3.43 ++install-exec-local:
    3.44 ++	$(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o
    3.45 ++	$(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
    3.46 ++
    3.47 + # Tell versions [3.59,3.63) of GNU make to not export all variables.
    3.48 + # Otherwise a system limit (for SysV at least) may be exceeded.
    3.49 + .NOEXPORT:
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/patches/gcc/3.4.6/304-index_macro.patch	Wed Aug 15 21:23:08 2007 +0000
     4.3 @@ -0,0 +1,26 @@
     4.4 +diff -durN gcc-3.4.6.orig/libstdc++-v3/include/ext/rope gcc-3.4.6/libstdc++-v3/include/ext/rope
     4.5 +--- gcc-3.4.6.orig/libstdc++-v3/include/ext/rope	2005-01-16 23:08:43.000000000 +0100
     4.6 ++++ gcc-3.4.6/libstdc++-v3/include/ext/rope	2007-08-15 22:53:37.000000000 +0200
     4.7 +@@ -58,6 +58,9 @@
     4.8 + #include <bits/allocator.h>
     4.9 + #include <ext/hash_fun.h>
    4.10 + 
    4.11 ++/* cope w/ index defined as macro, SuSv3 proposal */
    4.12 ++#undef index
    4.13 ++
    4.14 + # ifdef __GC
    4.15 + #   define __GC_CONST const
    4.16 + # else
    4.17 +diff -durN gcc-3.4.6.orig/libstdc++-v3/include/ext/ropeimpl.h gcc-3.4.6/libstdc++-v3/include/ext/ropeimpl.h
    4.18 +--- gcc-3.4.6.orig/libstdc++-v3/include/ext/ropeimpl.h	2004-09-08 15:36:04.000000000 +0200
    4.19 ++++ gcc-3.4.6/libstdc++-v3/include/ext/ropeimpl.h	2007-08-15 22:53:37.000000000 +0200
    4.20 +@@ -53,6 +53,9 @@
    4.21 + #include <ext/memory> // For uninitialized_copy_n
    4.22 + #include <ext/numeric> // For power
    4.23 + 
    4.24 ++/* cope w/ index defined as macro, SuSv3 proposal */
    4.25 ++#undef index
    4.26 ++
    4.27 + namespace __gnu_cxx
    4.28 + {
    4.29 +   using std::size_t;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/patches/gcc/3.4.6/600-gcc34-arm-ldm-peephole.patch	Wed Aug 15 21:23:08 2007 +0000
     5.3 @@ -0,0 +1,68 @@
     5.4 +diff -durN gcc-3.4.6.orig/gcc/config/arm/arm.c gcc-3.4.6/gcc/config/arm/arm.c
     5.5 +--- gcc-3.4.6.orig/gcc/config/arm/arm.c	2005-10-01 15:31:38.000000000 +0200
     5.6 ++++ gcc-3.4.6/gcc/config/arm/arm.c	2007-08-15 22:54:59.000000000 +0200
     5.7 +@@ -4857,6 +4857,11 @@
     5.8 +       *load_offset = unsorted_offsets[order[0]];
     5.9 +     }
    5.10 + 
    5.11 ++  /* For XScale a two-word LDM is a performance loss, so only do this if
    5.12 ++     size is more important.  See comments in arm_gen_load_multiple.  */
    5.13 ++  if (nops == 2 && arm_tune_xscale && !optimize_size)
    5.14 ++    return 0;
    5.15 ++
    5.16 +   if (unsorted_offsets[order[0]] == 0)
    5.17 +     return 1; /* ldmia */
    5.18 + 
    5.19 +@@ -5083,6 +5088,11 @@
    5.20 +       *load_offset = unsorted_offsets[order[0]];
    5.21 +     }
    5.22 + 
    5.23 ++  /* For XScale a two-word LDM is a performance loss, so only do this if
    5.24 ++     size is more important.  See comments in arm_gen_load_multiple.  */
    5.25 ++  if (nops == 2 && arm_tune_xscale && !optimize_size)
    5.26 ++    return 0;
    5.27 ++
    5.28 +   if (unsorted_offsets[order[0]] == 0)
    5.29 +     return 1; /* stmia */
    5.30 + 
    5.31 +diff -durN gcc-3.4.6.orig/gcc/config/arm/arm.md gcc-3.4.6/gcc/config/arm/arm.md
    5.32 +--- gcc-3.4.6.orig/gcc/config/arm/arm.md	2005-10-01 15:31:38.000000000 +0200
    5.33 ++++ gcc-3.4.6/gcc/config/arm/arm.md	2007-08-15 22:54:59.000000000 +0200
    5.34 +@@ -8811,13 +8811,16 @@
    5.35 +    (set_attr "length" "4,8,8")]
    5.36 + )
    5.37 + 
    5.38 ++; Try to convert LDR+LDR+arith into [add+]LDM+arith
    5.39 ++; On XScale, LDM is always slower than two LDRs, so only do this if
    5.40 ++; optimising for size.
    5.41 + (define_insn "*arith_adjacentmem"
    5.42 +   [(set (match_operand:SI 0 "s_register_operand" "=r")
    5.43 + 	(match_operator:SI 1 "shiftable_operator"
    5.44 + 	 [(match_operand:SI 2 "memory_operand" "m")
    5.45 + 	  (match_operand:SI 3 "memory_operand" "m")]))
    5.46 +    (clobber (match_scratch:SI 4 "=r"))]
    5.47 +-  "TARGET_ARM && adjacent_mem_locations (operands[2], operands[3])"
    5.48 ++  "TARGET_ARM && (!arm_tune_xscale || optimize_size) && adjacent_mem_locations (operands[2], operands[3])"
    5.49 +   "*
    5.50 +   {
    5.51 +     rtx ldm[3];
    5.52 +@@ -8852,6 +8855,8 @@
    5.53 +       }
    5.54 +    if (val1 && val2)
    5.55 +       {
    5.56 ++	/* This would be a loss on a Harvard core, but adjacent_mem_locations()
    5.57 ++	   will prevent it from happening.  */
    5.58 + 	rtx ops[3];
    5.59 + 	ldm[0] = ops[0] = operands[4];
    5.60 + 	ops[1] = XEXP (XEXP (operands[2], 0), 0);
    5.61 +diff -durN gcc-3.4.6.orig/gcc/genpeep.c gcc-3.4.6/gcc/genpeep.c
    5.62 +--- gcc-3.4.6.orig/gcc/genpeep.c	2003-07-05 07:27:22.000000000 +0200
    5.63 ++++ gcc-3.4.6/gcc/genpeep.c	2007-08-15 22:54:59.000000000 +0200
    5.64 +@@ -381,6 +381,7 @@
    5.65 +   printf ("#include \"recog.h\"\n");
    5.66 +   printf ("#include \"except.h\"\n\n");
    5.67 +   printf ("#include \"function.h\"\n\n");
    5.68 ++  printf ("#include \"flags.h\"\n\n");
    5.69 + 
    5.70 +   printf ("#ifdef HAVE_peephole\n");
    5.71 +   printf ("extern rtx peep_operand[];\n\n");
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/patches/gcc/3.4.6/601-gcc34-arm-ldm-peephole2.patch	Wed Aug 15 21:23:08 2007 +0000
     6.3 @@ -0,0 +1,32 @@
     6.4 +diff -durN gcc-3.4.6.orig/gcc/config/arm/arm.c gcc-3.4.6/gcc/config/arm/arm.c
     6.5 +--- gcc-3.4.6.orig/gcc/config/arm/arm.c	2007-08-15 22:57:51.000000000 +0200
     6.6 ++++ gcc-3.4.6/gcc/config/arm/arm.c	2007-08-15 22:57:51.000000000 +0200
     6.7 +@@ -4572,6 +4572,10 @@
     6.8 + int
     6.9 + adjacent_mem_locations (rtx a, rtx b)
    6.10 + {
    6.11 ++  /* We don't guarantee to preserve the order of these memory refs.  */
    6.12 ++  if (volatile_refs_p (a) || volatile_refs_p (b))
    6.13 ++    return 0;
    6.14 ++
    6.15 +   if ((GET_CODE (XEXP (a, 0)) == REG
    6.16 +        || (GET_CODE (XEXP (a, 0)) == PLUS
    6.17 + 	   && GET_CODE (XEXP (XEXP (a, 0), 1)) == CONST_INT))
    6.18 +@@ -4611,6 +4615,17 @@
    6.19 + 	return 0;
    6.20 + 
    6.21 +       val_diff = val1 - val0;
    6.22 ++
    6.23 ++      if (arm_ld_sched)
    6.24 ++	{
    6.25 ++	  /* If the target has load delay slots, then there's no benefit
    6.26 ++	     to using an ldm instruction unless the offset is zero and
    6.27 ++	     we are optimizing for size.  */
    6.28 ++	  return (optimize_size && (REGNO (reg0) == REGNO (reg1))
    6.29 ++		  && (val0 == 0 || val1 == 0 || val0 == 4 || val1 == 4)
    6.30 ++		  && (val_diff == 4 || val_diff == -4));
    6.31 ++	}
    6.32 ++
    6.33 +       return ((REGNO (reg0) == REGNO (reg1))
    6.34 + 	      && (val_diff == 4 || val_diff == -4));
    6.35 +     }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/patches/gcc/3.4.6/601-gcc34-arm-ldm.patch	Wed Aug 15 21:23:08 2007 +0000
     7.3 @@ -0,0 +1,120 @@
     7.4 +diff -durN gcc-3.4.6.orig/gcc/config/arm/arm.c gcc-3.4.6/gcc/config/arm/arm.c
     7.5 +--- gcc-3.4.6.orig/gcc/config/arm/arm.c	2007-08-15 22:56:20.000000000 +0200
     7.6 ++++ gcc-3.4.6/gcc/config/arm/arm.c	2007-08-15 22:56:20.000000000 +0200
     7.7 +@@ -8524,6 +8524,26 @@
     7.8 +   return_used_this_function = 0;  
     7.9 + }
    7.10 + 
    7.11 ++/* Return the number (counting from 0) of
    7.12 ++   the least significant set bit in MASK.  */
    7.13 ++
    7.14 ++#ifdef __GNUC__
    7.15 ++inline
    7.16 ++#endif
    7.17 ++static int
    7.18 ++number_of_first_bit_set (mask)
    7.19 ++     int mask;
    7.20 ++{
    7.21 ++  int bit;
    7.22 ++
    7.23 ++  for (bit = 0;
    7.24 ++       (mask & (1 << bit)) == 0;
    7.25 ++       ++bit)
    7.26 ++    continue;
    7.27 ++
    7.28 ++  return bit;
    7.29 ++}
    7.30 ++
    7.31 + const char *
    7.32 + arm_output_epilogue (rtx sibling)
    7.33 + {
    7.34 +@@ -8757,27 +8777,47 @@
    7.35 + 	  saved_regs_mask |=   (1 << PC_REGNUM);
    7.36 + 	}
    7.37 + 
    7.38 +-      /* Load the registers off the stack.  If we only have one register
    7.39 +-	 to load use the LDR instruction - it is faster.  */
    7.40 +-      if (saved_regs_mask == (1 << LR_REGNUM))
    7.41 +-	{
    7.42 +-	  /* The exception handler ignores the LR, so we do
    7.43 +-	     not really need to load it off the stack.  */
    7.44 +-	  if (eh_ofs)
    7.45 +-	    asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
    7.46 +-	  else
    7.47 +-	    asm_fprintf (f, "\tldr\t%r, [%r], #4\n", LR_REGNUM, SP_REGNUM);
    7.48 +-	}
    7.49 +-      else if (saved_regs_mask)
    7.50 ++      if (saved_regs_mask)
    7.51 + 	{
    7.52 +-	  if (saved_regs_mask & (1 << SP_REGNUM))
    7.53 +-	    /* Note - write back to the stack register is not enabled
    7.54 +-	       (ie "ldmfd sp!...").  We know that the stack pointer is
    7.55 +-	       in the list of registers and if we add writeback the
    7.56 +-	       instruction becomes UNPREDICTABLE.  */
    7.57 +-	    print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
    7.58 ++	  /* Load the registers off the stack.  If we only have one register
    7.59 ++	     to load use the LDR instruction - it is faster.  */
    7.60 ++	  if (bit_count (saved_regs_mask) == 1)
    7.61 ++	    {
    7.62 ++	      int reg = number_of_first_bit_set (saved_regs_mask);
    7.63 ++
    7.64 ++	      switch (reg)
    7.65 ++		{
    7.66 ++		case SP_REGNUM:
    7.67 ++		  /* Mustn't use base writeback when loading SP.  */
    7.68 ++		  asm_fprintf (f, "\tldr\t%r, [%r]\n", SP_REGNUM, SP_REGNUM);
    7.69 ++		  break;
    7.70 ++		  
    7.71 ++		case LR_REGNUM:
    7.72 ++		  if (eh_ofs)
    7.73 ++		    {
    7.74 ++		      /* The exception handler ignores the LR, so we do
    7.75 ++			 not really need to load it off the stack.  */
    7.76 ++		      asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
    7.77 ++		      break;
    7.78 ++		    }
    7.79 ++		  /* else fall through */
    7.80 ++		  
    7.81 ++		default:
    7.82 ++		  asm_fprintf (f, "\tldr\t%r, [%r], #4\n", reg, SP_REGNUM);
    7.83 ++		  break;
    7.84 ++		}
    7.85 ++	    }
    7.86 + 	  else
    7.87 +-	    print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
    7.88 ++	    {
    7.89 ++	      if (saved_regs_mask & (1 << SP_REGNUM))
    7.90 ++		/* Note - write back to the stack register is not enabled
    7.91 ++		   (ie "ldmfd sp!...").  We know that the stack pointer is
    7.92 ++		   in the list of registers and if we add writeback the
    7.93 ++		   instruction becomes UNPREDICTABLE.  */
    7.94 ++		print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
    7.95 ++	      else
    7.96 ++		print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
    7.97 ++	    }
    7.98 + 	}
    7.99 + 
   7.100 +       if (current_function_pretend_args_size)
   7.101 +@@ -11405,22 +11445,6 @@
   7.102 +     }
   7.103 + }
   7.104 + 
   7.105 +-/* Return the number (counting from 0) of
   7.106 +-   the least significant set bit in MASK.  */
   7.107 +-
   7.108 +-inline static int
   7.109 +-number_of_first_bit_set (int mask)
   7.110 +-{
   7.111 +-  int bit;
   7.112 +-
   7.113 +-  for (bit = 0;
   7.114 +-       (mask & (1 << bit)) == 0;
   7.115 +-       ++bit)
   7.116 +-    continue;
   7.117 +-
   7.118 +-  return bit;
   7.119 +-}
   7.120 +-
   7.121 + /* Generate code to return from a thumb function.
   7.122 +    If 'reg_containing_return_addr' is -1, then the return address is
   7.123 +    actually on the stack, at the stack pointer.  */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/patches/gcc/3.4.6/602-sdk-libstdc++-includes.patch	Wed Aug 15 21:23:08 2007 +0000
     8.3 @@ -0,0 +1,24 @@
     8.4 +diff -durN gcc-3.4.6.orig/libstdc++-v3/fragment.am gcc-3.4.6/libstdc++-v3/fragment.am
     8.5 +--- gcc-3.4.6.orig/libstdc++-v3/fragment.am	2003-08-27 02:38:28.000000000 +0200
     8.6 ++++ gcc-3.4.6/libstdc++-v3/fragment.am	2007-08-15 22:59:09.000000000 +0200
     8.7 +@@ -18,7 +18,7 @@
     8.8 + 	$(WARN_FLAGS) $(WERROR) -fdiagnostics-show-location=once
     8.9 + 
    8.10 + # -I/-D flags to pass when compiling.
    8.11 +-AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
    8.12 ++AM_CPPFLAGS = $(GLIBCXX_INCLUDES) -I$(toplevel_srcdir)/include
    8.13 + 
    8.14 + 
    8.15 + 
    8.16 +diff -durN gcc-3.4.6.orig/libstdc++-v3/libmath/Makefile.am gcc-3.4.6/libstdc++-v3/libmath/Makefile.am
    8.17 +--- gcc-3.4.6.orig/libstdc++-v3/libmath/Makefile.am	2003-08-27 23:29:43.000000000 +0200
    8.18 ++++ gcc-3.4.6/libstdc++-v3/libmath/Makefile.am	2007-08-15 22:59:09.000000000 +0200
    8.19 +@@ -32,7 +32,7 @@
    8.20 + 
    8.21 + libmath_la_SOURCES = stubs.c
    8.22 + 
    8.23 +-AM_CPPFLAGS = $(CANADIAN_INCLUDES)
    8.24 ++AM_CPPFLAGS = $(CANADIAN_INCLUDES) -I$(toplevel_srcdir)/include
    8.25 + 
    8.26 + # Only compiling "C" sources in this directory.
    8.27 + LIBTOOL = @LIBTOOL@ --tag CC
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/patches/gcc/3.4.6/700-pr15068-fix.patch	Wed Aug 15 21:23:08 2007 +0000
     9.3 @@ -0,0 +1,27 @@
     9.4 +diff -durN gcc-3.4.6.orig/gcc/flow.c gcc-3.4.6/gcc/flow.c
     9.5 +--- gcc-3.4.6.orig/gcc/flow.c	2005-09-01 22:51:09.000000000 +0200
     9.6 ++++ gcc-3.4.6/gcc/flow.c	2007-08-15 23:00:30.000000000 +0200
     9.7 +@@ -1884,6 +1884,7 @@
     9.8 + 	  rtx set_src = SET_SRC (pc_set (BB_END (bb)));
     9.9 + 	  rtx cond_true = XEXP (set_src, 0);
    9.10 + 	  rtx reg = XEXP (cond_true, 0);
    9.11 ++ 	  enum rtx_code inv_cond;
    9.12 + 
    9.13 + 	  if (GET_CODE (reg) == SUBREG)
    9.14 + 	    reg = SUBREG_REG (reg);
    9.15 +@@ -1892,11 +1893,13 @@
    9.16 + 	     in the form of a comparison of a register against zero.  
    9.17 + 	     If the condition is more complex than that, then it is safe
    9.18 + 	     not to record any information.  */
    9.19 +-	  if (GET_CODE (reg) == REG
    9.20 ++ 	  inv_cond = reversed_comparison_code (cond_true, BB_END (bb));
    9.21 ++ 	  if (inv_cond != UNKNOWN
    9.22 ++	      && GET_CODE (reg) == REG
    9.23 + 	      && XEXP (cond_true, 1) == const0_rtx)
    9.24 + 	    {
    9.25 + 	      rtx cond_false
    9.26 +-		= gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond_true)),
    9.27 ++		= gen_rtx_fmt_ee (inv_cond,
    9.28 + 				  GET_MODE (cond_true), XEXP (cond_true, 0),
    9.29 + 				  XEXP (cond_true, 1));
    9.30 + 	      if (GET_CODE (XEXP (set_src, 1)) == PC)
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/patches/gcc/3.4.6/71_all_sh-pr16665-fix.patch	Wed Aug 15 21:23:08 2007 +0000
    10.3 @@ -0,0 +1,44 @@
    10.4 +diff -durN gcc-3.4.6.orig/gcc/config/sh/sh.c gcc-3.4.6/gcc/config/sh/sh.c
    10.5 +--- gcc-3.4.6.orig/gcc/config/sh/sh.c	2004-09-03 08:51:30.000000000 +0200
    10.6 ++++ gcc-3.4.6/gcc/config/sh/sh.c	2007-08-15 23:01:48.000000000 +0200
    10.7 +@@ -9107,6 +9107,15 @@
    10.8 +     }
    10.9 +   this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
   10.10 + 
   10.11 ++  /* In PIC case, we set PIC register to compute the target address.  We
   10.12 ++     can use a scratch register to save and restore the original value  
   10.13 ++     except for SHcompact.  For SHcompact, use stack.  */
   10.14 ++  if (flag_pic && TARGET_SHCOMPACT)
   10.15 ++    {
   10.16 ++      push (PIC_OFFSET_TABLE_REGNUM);
   10.17 ++      emit_insn (gen_GOTaddr2picreg ());
   10.18 ++    }
   10.19 ++
   10.20 +   /* For SHcompact, we only have r0 for a scratch register: r1 is the
   10.21 +      static chain pointer (even if you can't have nested virtual functions
   10.22 +      right now, someone might implement them sometime), and the rest of the
   10.23 +@@ -9189,8 +9198,24 @@
   10.24 +       assemble_external (function);
   10.25 +       TREE_USED (function) = 1;
   10.26 +     }
   10.27 ++  /* We can use scratch1 to save and restore the original value of
   10.28 ++     PIC register except for SHcompact.  */
   10.29 ++  if (flag_pic && ! TARGET_SHCOMPACT)
   10.30 ++    {
   10.31 ++      emit_move_insn (scratch1,
   10.32 ++		      gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
   10.33 ++      emit_insn (gen_GOTaddr2picreg ());
   10.34 ++    }
   10.35 +   funexp = XEXP (DECL_RTL (function), 0);
   10.36 +   emit_move_insn (scratch2, funexp);
   10.37 ++  if (flag_pic)
   10.38 ++    {
   10.39 ++      if (! TARGET_SHCOMPACT)
   10.40 ++	emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
   10.41 ++			scratch1);
   10.42 ++      else
   10.43 ++	pop (PIC_OFFSET_TABLE_REGNUM);
   10.44 ++    }
   10.45 +   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
   10.46 +   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
   10.47 +   SIBLING_CALL_P (sibcall) = 1;
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/patches/gcc/3.4.6/72_all_sh-no-reorder-blocks.patch	Wed Aug 15 21:23:08 2007 +0000
    11.3 @@ -0,0 +1,14 @@
    11.4 +diff -durN gcc-3.4.6.orig/gcc/config/sh/sh.h gcc-3.4.6/gcc/config/sh/sh.h
    11.5 +--- gcc-3.4.6.orig/gcc/config/sh/sh.h	2006-01-12 02:20:32.000000000 +0100
    11.6 ++++ gcc-3.4.6/gcc/config/sh/sh.h	2007-08-15 23:03:09.000000000 +0200
    11.7 +@@ -422,6 +422,10 @@
    11.8 + do {									\
    11.9 +   if (LEVEL)								\
   11.10 +     flag_omit_frame_pointer = -1;					\
   11.11 ++  if (LEVEL <= 2)							\
   11.12 ++    {									\
   11.13 ++      flag_reorder_blocks = 0;						\
   11.14 ++    }									\
   11.15 +   if (SIZE)								\
   11.16 +     target_flags |= SPACE_BIT;						\
   11.17 +   if (TARGET_SHMEDIA && LEVEL > 1)					\
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/patches/gcc/3.4.6/73_all_sh-pr20617.patch	Wed Aug 15 21:23:08 2007 +0000
    12.3 @@ -0,0 +1,24 @@
    12.4 +diff -durN gcc-3.4.6.orig/gcc/config/sh/lib1funcs.asm gcc-3.4.6/gcc/config/sh/lib1funcs.asm
    12.5 +--- gcc-3.4.6.orig/gcc/config/sh/lib1funcs.asm	2003-08-12 03:25:07.000000000 +0200
    12.6 ++++ gcc-3.4.6/gcc/config/sh/lib1funcs.asm	2007-08-15 23:04:26.000000000 +0200
    12.7 +@@ -37,9 +37,19 @@
    12.8 +    ELF local label prefixes by J"orn Rennecke
    12.9 +    amylaar@cygnus.com  */
   12.10 + 
   12.11 ++#define ALIAS(X,Y)	.global GLOBAL(X); .set GLOBAL(X),GLOBAL(Y)
   12.12 ++
   12.13 + #ifdef __ELF__
   12.14 + #define LOCAL(X)	.L_##X
   12.15 +-#define FUNC(X)		.type X,@function
   12.16 ++
   12.17 ++#if 1 /* ??? The export list mechanism is broken, everything that is not
   12.18 ++	 hidden is exported.  */
   12.19 ++#undef FUNC
   12.20 ++#define FUNC(X)		.type X,@function; .hidden X
   12.21 ++#undef ALIAS
   12.22 ++#define ALIAS(X,Y)	.global GLOBAL(X); .set GLOBAL(X),GLOBAL(Y); .hidden GLOBAL(X)
   12.23 ++#endif
   12.24 ++
   12.25 + #define ENDFUNC0(X)	.Lfe_##X: .size X,.Lfe_##X-X
   12.26 + #define ENDFUNC(X)	ENDFUNC0(X)
   12.27 + #else
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/patches/gcc/3.4.6/800-arm-bigendian.patch	Wed Aug 15 21:23:08 2007 +0000
    13.3 @@ -0,0 +1,65 @@
    13.4 +diff -durN gcc-3.4.6.orig/gcc/config/arm/linux-elf.h gcc-3.4.6/gcc/config/arm/linux-elf.h
    13.5 +--- gcc-3.4.6.orig/gcc/config/arm/linux-elf.h	2007-08-15 22:51:01.000000000 +0200
    13.6 ++++ gcc-3.4.6/gcc/config/arm/linux-elf.h	2007-08-15 23:05:42.000000000 +0200
    13.7 +@@ -30,17 +30,34 @@
    13.8 + /* Do not assume anything about header files.  */
    13.9 + #define NO_IMPLICIT_EXTERN_C
   13.10 + 
   13.11 ++/*
   13.12 ++ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
   13.13 ++ * (big endian) configurations.
   13.14 ++ */
   13.15 ++#if TARGET_BIG_ENDIAN_DEFAULT
   13.16 ++#define TARGET_ENDIAN_DEFAULT ARM_FLAG_BIG_END
   13.17 ++#define TARGET_ENDIAN_OPTION "mbig-endian"
   13.18 ++#define TARGET_LINKER_EMULATION "armelfb_linux"
   13.19 ++#else
   13.20 ++#define TARGET_ENDIAN_DEFAULT 0
   13.21 ++#define TARGET_ENDIAN_OPTION "mlittle-endian"
   13.22 ++#define TARGET_LINKER_EMULATION "armelf_linux"
   13.23 ++#endif
   13.24 ++
   13.25 + /* Default is to use APCS-32 mode.  */
   13.26 + #undef  TARGET_DEFAULT
   13.27 +-#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
   13.28 ++#define TARGET_DEFAULT \
   13.29 ++		( ARM_FLAG_APCS_32 | \
   13.30 ++		  ARM_FLAG_MMU_TRAPS | \
   13.31 ++		  TARGET_ENDIAN_DEFAULT )
   13.32 + 
   13.33 + #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
   13.34 + 
   13.35 +-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
   13.36 ++#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
   13.37 + 
   13.38 + #undef  MULTILIB_DEFAULTS
   13.39 + #define MULTILIB_DEFAULTS \
   13.40 +-	{ "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
   13.41 ++	{ "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mapcs-32", "mno-thumb-interwork" }
   13.42 + 
   13.43 + #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
   13.44 + 
   13.45 +@@ -94,7 +111,7 @@
   13.46 +    %{rdynamic:-export-dynamic} \
   13.47 +    %{!dynamic-linker:-dynamic-linker " ELF_DYNAMIC_LINKER "} \
   13.48 +    -X \
   13.49 +-   %{mbig-endian:-EB}" \
   13.50 ++   %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
   13.51 +    SUBTARGET_EXTRA_LINK_SPEC
   13.52 + 
   13.53 + #define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS()
   13.54 +diff -durN gcc-3.4.6.orig/gcc/config.gcc gcc-3.4.6/gcc/config.gcc
   13.55 +--- gcc-3.4.6.orig/gcc/config.gcc	2007-08-15 22:51:01.000000000 +0200
   13.56 ++++ gcc-3.4.6/gcc/config.gcc	2007-08-15 23:05:42.000000000 +0200
   13.57 +@@ -678,6 +678,11 @@
   13.58 + 	;;
   13.59 + arm*-*-linux*)			# ARM GNU/Linux with ELF
   13.60 + 	tm_file="dbxelf.h elfos.h linux.h arm/elf.h  arm/linux-gas.h arm/linux-elf.h arm/aout.h arm/arm.h"
   13.61 ++	case $target in
   13.62 ++	arm*b-*)
   13.63 ++		tm_defines="TARGET_BIG_ENDIAN_DEFAULT=1 $tm_defines"
   13.64 ++		;;
   13.65 ++	esac
   13.66 + 	tmake_file="t-slibgcc-elf-ver t-linux arm/t-linux"
   13.67 + 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
   13.68 + 	gnu_ld=yes
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/patches/gcc/3.4.6/800-powerpc-libc_stack_end-uclibc.patch	Wed Aug 15 21:23:08 2007 +0000
    14.3 @@ -0,0 +1,16 @@
    14.4 +diff -durN gcc-3.4.6.orig/gcc/config/rs6000/linux-unwind.h gcc-3.4.6/gcc/config/rs6000/linux-unwind.h
    14.5 +--- gcc-3.4.6.orig/gcc/config/rs6000/linux-unwind.h	2005-03-17 11:41:18.000000000 +0100
    14.6 ++++ gcc-3.4.6/gcc/config/rs6000/linux-unwind.h	2007-08-15 23:07:00.000000000 +0200
    14.7 +@@ -32,6 +32,7 @@
    14.8 +    these structs elsewhere;  Many fields are missing, particularly
    14.9 +    from the end of the structures.  */
   14.10 + 
   14.11 ++#ifndef inhibit_libc
   14.12 + struct gcc_vregs
   14.13 + {
   14.14 +   __attribute__ ((vector_size (16))) int vr[32];
   14.15 +@@ -320,3 +321,4 @@
   14.16 + 									\
   14.17 +     goto SUCCESS;							\
   14.18 +   } while (0)
   14.19 ++#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/patches/gcc/3.4.6/810-mips-xgot.patch	Wed Aug 15 21:23:08 2007 +0000
    15.3 @@ -0,0 +1,7 @@
    15.4 +diff -durN gcc-3.4.6.orig/gcc/config/mips/t-linux gcc-3.4.6/gcc/config/mips/t-linux
    15.5 +--- gcc-3.4.6.orig/gcc/config/mips/t-linux	1970-01-01 01:00:00.000000000 +0100
    15.6 ++++ gcc-3.4.6/gcc/config/mips/t-linux	2007-08-15 23:08:15.000000000 +0200
    15.7 +@@ -0,0 +1,3 @@
    15.8 ++# Compile crtbegin/end with xgot so it works for both
    15.9 ++# normal and large GOTs.
   15.10 ++CRTSTUFF_T_CFLAGS = -mxgot
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/patches/gcc/3.4.6/900-nios2.patch	Wed Aug 15 21:23:08 2007 +0000
    16.3 @@ -0,0 +1,10231 @@
    16.4 +diff -durN gcc-3.4.6.orig/gcc/combine.c gcc-3.4.6/gcc/combine.c
    16.5 +--- gcc-3.4.6.orig/gcc/combine.c	2005-08-08 20:41:04.000000000 +0200
    16.6 ++++ gcc-3.4.6/gcc/combine.c	2007-08-15 23:09:36.000000000 +0200
    16.7 +@@ -4381,6 +4381,14 @@
    16.8 + 					 mode);
    16.9 + 	    }
   16.10 + 
   16.11 ++#ifndef __nios2__
   16.12 ++/* This screws up Nios II in this test case:
   16.13 ++
   16.14 ++if (x & 1)
   16.15 ++  return 2;
   16.16 ++else
   16.17 ++  return 3;
   16.18 ++*/
   16.19 + 	  else if (STORE_FLAG_VALUE == 1
   16.20 + 		   && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
   16.21 + 		   && op1 == const0_rtx
   16.22 +@@ -4392,6 +4400,7 @@
   16.23 + 				 gen_lowpart_for_combine (mode, op0),
   16.24 + 				 const1_rtx);
   16.25 + 	    }
   16.26 ++#endif
   16.27 + 
   16.28 + 	  else if (STORE_FLAG_VALUE == 1
   16.29 + 		   && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
   16.30 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/crti.asm gcc-3.4.6/gcc/config/nios2/crti.asm
   16.31 +--- gcc-3.4.6.orig/gcc/config/nios2/crti.asm	1970-01-01 01:00:00.000000000 +0100
   16.32 ++++ gcc-3.4.6/gcc/config/nios2/crti.asm	2007-08-15 23:09:36.000000000 +0200
   16.33 +@@ -0,0 +1,88 @@
   16.34 ++/*
   16.35 ++  Copyright (C) 2003 
   16.36 ++ by Jonah Graham (jgraham@altera.com)
   16.37 ++
   16.38 ++This file is free software; you can redistribute it and/or modify it
   16.39 ++under the terms of the GNU General Public License as published by the
   16.40 ++Free Software Foundation; either version 2, or (at your option) any
   16.41 ++later version.
   16.42 ++
   16.43 ++In addition to the permissions in the GNU General Public License, the
   16.44 ++Free Software Foundation gives you unlimited permission to link the
   16.45 ++compiled version of this file with other programs, and to distribute
   16.46 ++those programs without any restriction coming from the use of this
   16.47 ++file.  (The General Public License restrictions do apply in other
   16.48 ++respects; for example, they cover modification of the file, and
   16.49 ++distribution when not linked into another program.)
   16.50 ++
   16.51 ++This file is distributed in the hope that it will be useful, but
   16.52 ++WITHOUT ANY WARRANTY; without even the implied warranty of
   16.53 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.54 ++General Public License for more details.
   16.55 ++
   16.56 ++You should have received a copy of the GNU General Public License
   16.57 ++along with this program; see the file COPYING.  If not, write to
   16.58 ++the Free Software Foundation, 59 Temple Place - Suite 330,
   16.59 ++Boston, MA 02111-1307, USA.
   16.60 ++
   16.61 ++   As a special exception, if you link this library with files
   16.62 ++   compiled with GCC to produce an executable, this does not cause
   16.63 ++   the resulting executable to be covered by the GNU General Public License.
   16.64 ++   This exception does not however invalidate any other reasons why
   16.65 ++   the executable file might be covered by the GNU General Public License.
   16.66 ++
   16.67 ++
   16.68 ++This file just make a stack frame for the contents of the .fini and
   16.69 ++.init sections.  Users may put any desired instructions in those
   16.70 ++sections.
   16.71 ++
   16.72 ++
   16.73 ++While technically any code can be put in the init and fini sections
   16.74 ++most stuff will not work other than stuff which obeys the call frame
   16.75 ++and ABI. All the call-preserved registers are saved, the call clobbered
   16.76 ++registers should have been saved by the code calling init and fini.
   16.77 ++
   16.78 ++See crtstuff.c for an example of code that inserts itself in the 
   16.79 ++init and fini sections. 
   16.80 ++
   16.81 ++See crt0.s for the code that calls init and fini.
   16.82 ++*/
   16.83 ++
   16.84 ++	.file	"crti.asm"
   16.85 ++
   16.86 ++	.section	".init"
   16.87 ++	.align 2
   16.88 ++	.global	_init
   16.89 ++_init:
   16.90 ++	addi	sp, sp, -48
   16.91 ++	stw	ra, 44(sp)
   16.92 ++	stw	r23, 40(sp)
   16.93 ++	stw	r22, 36(sp)
   16.94 ++	stw	r21, 32(sp)
   16.95 ++	stw	r20, 28(sp)
   16.96 ++	stw	r19, 24(sp)
   16.97 ++	stw	r18, 20(sp)
   16.98 ++	stw	r17, 16(sp)
   16.99 ++	stw	r16, 12(sp)
  16.100 ++	stw	fp, 8(sp)
  16.101 ++	mov	fp, sp
  16.102 ++	
  16.103 ++	
  16.104 ++	.section	".fini"
  16.105 ++	.align	2
  16.106 ++	.global	_fini
  16.107 ++_fini:
  16.108 ++	addi	sp, sp, -48
  16.109 ++	stw	ra, 44(sp)
  16.110 ++	stw	r23, 40(sp)
  16.111 ++	stw	r22, 36(sp)
  16.112 ++	stw	r21, 32(sp)
  16.113 ++	stw	r20, 28(sp)
  16.114 ++	stw	r19, 24(sp)
  16.115 ++	stw	r18, 20(sp)
  16.116 ++	stw	r17, 16(sp)
  16.117 ++	stw	r16, 12(sp)
  16.118 ++	stw	fp, 8(sp)
  16.119 ++	mov	fp, sp
  16.120 ++	
  16.121 ++
  16.122 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/crtn.asm gcc-3.4.6/gcc/config/nios2/crtn.asm
  16.123 +--- gcc-3.4.6.orig/gcc/config/nios2/crtn.asm	1970-01-01 01:00:00.000000000 +0100
  16.124 ++++ gcc-3.4.6/gcc/config/nios2/crtn.asm	2007-08-15 23:09:36.000000000 +0200
  16.125 +@@ -0,0 +1,70 @@
  16.126 ++/*
  16.127 ++  Copyright (C) 2003 
  16.128 ++ by Jonah Graham (jgraham@altera.com)
  16.129 ++
  16.130 ++This file is free software; you can redistribute it and/or modify it
  16.131 ++under the terms of the GNU General Public License as published by the
  16.132 ++Free Software Foundation; either version 2, or (at your option) any
  16.133 ++later version.
  16.134 ++
  16.135 ++In addition to the permissions in the GNU General Public License, the
  16.136 ++Free Software Foundation gives you unlimited permission to link the
  16.137 ++compiled version of this file with other programs, and to distribute
  16.138 ++those programs without any restriction coming from the use of this
  16.139 ++file.  (The General Public License restrictions do apply in other
  16.140 ++respects; for example, they cover modification of the file, and
  16.141 ++distribution when not linked into another program.)
  16.142 ++
  16.143 ++This file is distributed in the hope that it will be useful, but
  16.144 ++WITHOUT ANY WARRANTY; without even the implied warranty of
  16.145 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.146 ++General Public License for more details.
  16.147 ++
  16.148 ++You should have received a copy of the GNU General Public License
  16.149 ++along with this program; see the file COPYING.  If not, write to
  16.150 ++the Free Software Foundation, 59 Temple Place - Suite 330,
  16.151 ++Boston, MA 02111-1307, USA.
  16.152 ++
  16.153 ++   As a special exception, if you link this library with files
  16.154 ++   compiled with GCC to produce an executable, this does not cause
  16.155 ++   the resulting executable to be covered by the GNU General Public License.
  16.156 ++   This exception does not however invalidate any other reasons why
  16.157 ++   the executable file might be covered by the GNU General Public License.
  16.158 ++
  16.159 ++
  16.160 ++This file just makes sure that the .fini and .init sections do in
  16.161 ++fact return.  Users may put any desired instructions in those sections.
  16.162 ++This file is the last thing linked into any executable.
  16.163 ++*/	
  16.164 ++	.file	"crtn.asm"
  16.165 ++
  16.166 ++
  16.167 ++
  16.168 ++	.section	".init"
  16.169 ++	ldw	ra, 44(sp)
  16.170 ++	ldw	r23, 40(sp)
  16.171 ++	ldw	r22, 36(sp)
  16.172 ++	ldw	r21, 32(sp)
  16.173 ++	ldw	r20, 28(sp)
  16.174 ++	ldw	r19, 24(sp)
  16.175 ++	ldw	r18, 20(sp)
  16.176 ++	ldw	r17, 16(sp)
  16.177 ++	ldw	r16, 12(sp)
  16.178 ++	ldw	fp, 8(sp)
  16.179 ++	addi	sp, sp, -48
  16.180 ++	ret
  16.181 ++	
  16.182 ++	.section	".fini"
  16.183 ++	ldw	ra, 44(sp)
  16.184 ++	ldw	r23, 40(sp)
  16.185 ++	ldw	r22, 36(sp)
  16.186 ++	ldw	r21, 32(sp)
  16.187 ++	ldw	r20, 28(sp)
  16.188 ++	ldw	r19, 24(sp)
  16.189 ++	ldw	r18, 20(sp)
  16.190 ++	ldw	r17, 16(sp)
  16.191 ++	ldw	r16, 12(sp)
  16.192 ++	ldw	fp, 8(sp)
  16.193 ++	addi	sp, sp, -48
  16.194 ++	ret
  16.195 ++	
  16.196 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod.c gcc-3.4.6/gcc/config/nios2/lib2-divmod.c
  16.197 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod.c	1970-01-01 01:00:00.000000000 +0100
  16.198 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divmod.c	2007-08-15 23:09:36.000000000 +0200
  16.199 +@@ -0,0 +1,126 @@
  16.200 ++
  16.201 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
  16.202 ++   supposedly valid even though this is a "target" file.  */
  16.203 ++#include "auto-host.h"
  16.204 ++
  16.205 ++
  16.206 ++#include "tconfig.h"
  16.207 ++#include "tsystem.h"
  16.208 ++#include "coretypes.h"
  16.209 ++#include "tm.h"
  16.210 ++
  16.211 ++
  16.212 ++/* Don't use `fancy_abort' here even if config.h says to use it.  */
  16.213 ++#ifdef abort
  16.214 ++#undef abort
  16.215 ++#endif
  16.216 ++
  16.217 ++
  16.218 ++#ifdef HAVE_GAS_HIDDEN
  16.219 ++#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
  16.220 ++#else
  16.221 ++#define ATTRIBUTE_HIDDEN
  16.222 ++#endif
  16.223 ++
  16.224 ++#include "libgcc2.h"
  16.225 ++
  16.226 ++extern SItype __modsi3 (SItype, SItype);
  16.227 ++extern SItype __divsi3 (SItype, SItype);
  16.228 ++extern SItype __umodsi3 (SItype, SItype);
  16.229 ++extern SItype __udivsi3 (SItype, SItype);
  16.230 ++
  16.231 ++static USItype udivmodsi4(USItype, USItype, word_type);
  16.232 ++
  16.233 ++/* 16-bit SI divide and modulo as used in NIOS */
  16.234 ++
  16.235 ++
  16.236 ++static USItype
  16.237 ++udivmodsi4(USItype num, USItype den, word_type modwanted)
  16.238 ++{
  16.239 ++  USItype bit = 1;
  16.240 ++  USItype res = 0;
  16.241 ++
  16.242 ++  while (den < num && bit && !(den & (1L<<31)))
  16.243 ++    {
  16.244 ++      den <<=1;
  16.245 ++      bit <<=1;
  16.246 ++    }
  16.247 ++  while (bit)
  16.248 ++    {
  16.249 ++      if (num >= den)
  16.250 ++	{
  16.251 ++	  num -= den;
  16.252 ++	  res |= bit;
  16.253 ++	}
  16.254 ++      bit >>=1;
  16.255 ++      den >>=1;
  16.256 ++    }
  16.257 ++  if (modwanted) return num;
  16.258 ++  return res;
  16.259 ++}
  16.260 ++
  16.261 ++
  16.262 ++SItype
  16.263 ++__divsi3 (SItype a, SItype b)
  16.264 ++{
  16.265 ++  word_type neg = 0;
  16.266 ++  SItype res;
  16.267 ++
  16.268 ++  if (a < 0)
  16.269 ++    {
  16.270 ++      a = -a;
  16.271 ++      neg = !neg;
  16.272 ++    }
  16.273 ++
  16.274 ++  if (b < 0)
  16.275 ++    {
  16.276 ++      b = -b;
  16.277 ++      neg = !neg;
  16.278 ++    }
  16.279 ++
  16.280 ++  res = udivmodsi4 (a, b, 0);
  16.281 ++
  16.282 ++  if (neg)
  16.283 ++    res = -res;
  16.284 ++
  16.285 ++  return res;
  16.286 ++}
  16.287 ++
  16.288 ++
  16.289 ++SItype
  16.290 ++__modsi3 (SItype a, SItype b)
  16.291 ++{
  16.292 ++  word_type neg = 0;
  16.293 ++  SItype res;
  16.294 ++
  16.295 ++  if (a < 0)
  16.296 ++    {
  16.297 ++      a = -a;
  16.298 ++      neg = 1;
  16.299 ++    }
  16.300 ++
  16.301 ++  if (b < 0)
  16.302 ++    b = -b;
  16.303 ++
  16.304 ++  res = udivmodsi4 (a, b, 1);
  16.305 ++
  16.306 ++  if (neg)
  16.307 ++    res = -res;
  16.308 ++
  16.309 ++  return res;
  16.310 ++}
  16.311 ++
  16.312 ++
  16.313 ++SItype
  16.314 ++__udivsi3 (SItype a, SItype b)
  16.315 ++{
  16.316 ++  return udivmodsi4 (a, b, 0);
  16.317 ++}
  16.318 ++
  16.319 ++
  16.320 ++SItype
  16.321 ++__umodsi3 (SItype a, SItype b)
  16.322 ++{
  16.323 ++  return udivmodsi4 (a, b, 1);
  16.324 ++}
  16.325 ++
  16.326 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod-hi.c gcc-3.4.6/gcc/config/nios2/lib2-divmod-hi.c
  16.327 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod-hi.c	1970-01-01 01:00:00.000000000 +0100
  16.328 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divmod-hi.c	2007-08-15 23:09:36.000000000 +0200
  16.329 +@@ -0,0 +1,123 @@
  16.330 ++
  16.331 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
  16.332 ++   supposedly valid even though this is a "target" file.  */
  16.333 ++#include "auto-host.h"
  16.334 ++
  16.335 ++
  16.336 ++#include "tconfig.h"
  16.337 ++#include "tsystem.h"
  16.338 ++#include "coretypes.h"
  16.339 ++#include "tm.h"
  16.340 ++
  16.341 ++
  16.342 ++/* Don't use `fancy_abort' here even if config.h says to use it.  */
  16.343 ++#ifdef abort
  16.344 ++#undef abort
  16.345 ++#endif
  16.346 ++
  16.347 ++
  16.348 ++#ifdef HAVE_GAS_HIDDEN
  16.349 ++#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
  16.350 ++#else
  16.351 ++#define ATTRIBUTE_HIDDEN
  16.352 ++#endif
  16.353 ++
  16.354 ++#include "libgcc2.h"
  16.355 ++
  16.356 ++extern HItype __modhi3 (HItype, HItype);
  16.357 ++extern HItype __divhi3 (HItype, HItype);
  16.358 ++extern HItype __umodhi3 (HItype, HItype);
  16.359 ++extern HItype __udivhi3 (HItype, HItype);
  16.360 ++
  16.361 ++static UHItype udivmodhi4(UHItype, UHItype, word_type);
  16.362 ++
  16.363 ++static UHItype
  16.364 ++udivmodhi4(UHItype num, UHItype den, word_type modwanted)
  16.365 ++{
  16.366 ++  UHItype bit = 1;
  16.367 ++  UHItype res = 0;
  16.368 ++
  16.369 ++  while (den < num && bit && !(den & (1L<<15)))
  16.370 ++    {
  16.371 ++      den <<=1;
  16.372 ++      bit <<=1;
  16.373 ++    }
  16.374 ++  while (bit)
  16.375 ++    {
  16.376 ++      if (num >= den)
  16.377 ++	{
  16.378 ++	  num -= den;
  16.379 ++	  res |= bit;
  16.380 ++	}
  16.381 ++      bit >>=1;
  16.382 ++      den >>=1;
  16.383 ++    }
  16.384 ++  if (modwanted) return num;
  16.385 ++  return res;
  16.386 ++}
  16.387 ++
  16.388 ++
  16.389 ++HItype
  16.390 ++__divhi3 (HItype a, HItype b)
  16.391 ++{
  16.392 ++  word_type neg = 0;
  16.393 ++  HItype res;
  16.394 ++
  16.395 ++  if (a < 0)
  16.396 ++    {
  16.397 ++      a = -a;
  16.398 ++      neg = !neg;
  16.399 ++    }
  16.400 ++
  16.401 ++  if (b < 0)
  16.402 ++    {
  16.403 ++      b = -b;
  16.404 ++      neg = !neg;
  16.405 ++    }
  16.406 ++
  16.407 ++  res = udivmodhi4 (a, b, 0);
  16.408 ++
  16.409 ++  if (neg)
  16.410 ++    res = -res;
  16.411 ++
  16.412 ++  return res;
  16.413 ++}
  16.414 ++
  16.415 ++
  16.416 ++HItype
  16.417 ++__modhi3 (HItype a, HItype b)
  16.418 ++{
  16.419 ++  word_type neg = 0;
  16.420 ++  HItype res;
  16.421 ++
  16.422 ++  if (a < 0)
  16.423 ++    {
  16.424 ++      a = -a;
  16.425 ++      neg = 1;
  16.426 ++    }
  16.427 ++
  16.428 ++  if (b < 0)
  16.429 ++    b = -b;
  16.430 ++
  16.431 ++  res = udivmodhi4 (a, b, 1);
  16.432 ++
  16.433 ++  if (neg)
  16.434 ++    res = -res;
  16.435 ++
  16.436 ++  return res;
  16.437 ++}
  16.438 ++
  16.439 ++
  16.440 ++HItype
  16.441 ++__udivhi3 (HItype a, HItype b)
  16.442 ++{
  16.443 ++  return udivmodhi4 (a, b, 0);
  16.444 ++}
  16.445 ++
  16.446 ++
  16.447 ++HItype
  16.448 ++__umodhi3 (HItype a, HItype b)
  16.449 ++{
  16.450 ++  return udivmodhi4 (a, b, 1);
  16.451 ++}
  16.452 ++
  16.453 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-divtable.c gcc-3.4.6/gcc/config/nios2/lib2-divtable.c
  16.454 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divtable.c	1970-01-01 01:00:00.000000000 +0100
  16.455 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divtable.c	2007-08-15 23:09:36.000000000 +0200
  16.456 +@@ -0,0 +1,46 @@
  16.457 ++
  16.458 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
  16.459 ++   supposedly valid even though this is a "target" file.  */
  16.460 ++#include "auto-host.h"
  16.461 ++
  16.462 ++
  16.463 ++#include "tconfig.h"
  16.464 ++#include "tsystem.h"
  16.465 ++#include "coretypes.h"
  16.466 ++#include "tm.h"
  16.467 ++
  16.468 ++
  16.469 ++/* Don't use `fancy_abort' here even if config.h says to use it.  */
  16.470 ++#ifdef abort
  16.471 ++#undef abort
  16.472 ++#endif
  16.473 ++
  16.474 ++
  16.475 ++#ifdef HAVE_GAS_HIDDEN
  16.476 ++#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
  16.477 ++#else
  16.478 ++#define ATTRIBUTE_HIDDEN
  16.479 ++#endif
  16.480 ++
  16.481 ++#include "libgcc2.h"
  16.482 ++
  16.483 ++UQItype __divsi3_table[] =
  16.484 ++{
  16.485 ++  0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7, 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
  16.486 ++  0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
  16.487 ++  0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7, 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
  16.488 ++  0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7, 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
  16.489 ++  0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7, 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
  16.490 ++  0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7, 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
  16.491 ++  0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7, 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
  16.492 ++  0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7, 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
  16.493 ++  0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7, 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
  16.494 ++  0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7, 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
  16.495 ++  0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7, 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
  16.496 ++  0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7, 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
  16.497 ++  0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7, 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
  16.498 ++  0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7, 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
  16.499 ++  0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7, 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
  16.500 ++  0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7, 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
  16.501 ++};
  16.502 ++
  16.503 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-mul.c gcc-3.4.6/gcc/config/nios2/lib2-mul.c
  16.504 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-mul.c	1970-01-01 01:00:00.000000000 +0100
  16.505 ++++ gcc-3.4.6/gcc/config/nios2/lib2-mul.c	2007-08-15 23:09:36.000000000 +0200
  16.506 +@@ -0,0 +1,103 @@
  16.507 ++/* while we are debugging (ie compile outside of gcc build) 
  16.508 ++   disable gcc specific headers */
  16.509 ++#ifndef DEBUG_MULSI3
  16.510 ++
  16.511 ++
  16.512 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
  16.513 ++   supposedly valid even though this is a "target" file.  */
  16.514 ++#include "auto-host.h"
  16.515 ++
  16.516 ++
  16.517 ++#include "tconfig.h"
  16.518 ++#include "tsystem.h"
  16.519 ++#include "coretypes.h"
  16.520 ++#include "tm.h"
  16.521 ++
  16.522 ++
  16.523 ++/* Don't use `fancy_abort' here even if config.h says to use it.  */
  16.524 ++#ifdef abort
  16.525 ++#undef abort
  16.526 ++#endif
  16.527 ++
  16.528 ++
  16.529 ++#ifdef HAVE_GAS_HIDDEN
  16.530 ++#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
  16.531 ++#else
  16.532 ++#define ATTRIBUTE_HIDDEN
  16.533 ++#endif
  16.534 ++
  16.535 ++#include "libgcc2.h"
  16.536 ++
  16.537 ++#else
  16.538 ++#define SItype int
  16.539 ++#define USItype unsigned int
  16.540 ++#endif
  16.541 ++
  16.542 ++
  16.543 ++extern SItype __mulsi3 (SItype, SItype);
  16.544 ++
  16.545 ++SItype
  16.546 ++__mulsi3 (SItype a, SItype b)
  16.547 ++{
  16.548 ++  SItype res = 0;
  16.549 ++  USItype cnt = a;
  16.550 ++  
  16.551 ++  while (cnt)
  16.552 ++    {
  16.553 ++      if (cnt & 1)
  16.554 ++        {
  16.555 ++	  res += b;	  
  16.556 ++	}
  16.557 ++      b <<= 1;
  16.558 ++      cnt >>= 1;
  16.559 ++    }
  16.560 ++    
  16.561 ++  return res;
  16.562 ++}
  16.563 ++/*
  16.564 ++TODO: Choose best alternative implementation.
  16.565 ++
  16.566 ++SItype
  16.567 ++__divsi3 (SItype a, SItype b)
  16.568 ++{
  16.569 ++  SItype res = 0;
  16.570 ++  USItype cnt = 0;
  16.571 ++  
  16.572 ++  while (cnt < 32)
  16.573 ++    {
  16.574 ++      if (a & (1L << cnt))
  16.575 ++        {
  16.576 ++	  res += b;	  
  16.577 ++	}
  16.578 ++      b <<= 1;
  16.579 ++      cnt++;
  16.580 ++    }
  16.581 ++    
  16.582 ++  return res;
  16.583 ++}
  16.584 ++*/
  16.585 ++
  16.586 ++
  16.587 ++#ifdef DEBUG_MULSI3
  16.588 ++
  16.589 ++int
  16.590 ++main ()
  16.591 ++{
  16.592 ++  int i, j;
  16.593 ++  int error = 0;
  16.594 ++  
  16.595 ++  for (i = -1000; i < 1000; i++)
  16.596 ++    for (j = -1000; j < 1000; j++)
  16.597 ++      {
  16.598 ++	int expect = i * j;
  16.599 ++	int actual = A__divsi3 (i, j);
  16.600 ++	if (expect != actual)
  16.601 ++	  {
  16.602 ++	    printf ("error: %d * %d = %d not %d\n", i, j, expect, actual);
  16.603 ++	    error = 1;
  16.604 ++	  }
  16.605 ++      }
  16.606 ++
  16.607 ++  return error;
  16.608 ++}
  16.609 ++#endif
  16.610 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.c gcc-3.4.6/gcc/config/nios2/nios2.c
  16.611 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.c	1970-01-01 01:00:00.000000000 +0100
  16.612 ++++ gcc-3.4.6/gcc/config/nios2/nios2.c	2007-08-15 23:09:36.000000000 +0200
  16.613 +@@ -0,0 +1,2853 @@
  16.614 ++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
  16.615 ++   Copyright (C) 2003 Altera
  16.616 ++   Contributed by Jonah Graham (jgraham@altera.com).
  16.617 ++
  16.618 ++This file is part of GNU CC.
  16.619 ++
  16.620 ++GNU CC is free software; you can redistribute it and/or modify
  16.621 ++it under the terms of the GNU General Public License as published by
  16.622 ++the Free Software Foundation; either version 2, or (at your option)
  16.623 ++any later version.
  16.624 ++
  16.625 ++GNU CC is distributed in the hope that it will be useful,
  16.626 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.627 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.628 ++GNU General Public License for more details.
  16.629 ++
  16.630 ++You should have received a copy of the GNU General Public License
  16.631 ++along with GNU CC; see the file COPYING.  If not, write to
  16.632 ++the Free Software Foundation, 59 Temple Place - Suite 330,
  16.633 ++Boston, MA 02111-1307, USA.  */
  16.634 ++
  16.635 ++
  16.636 ++#include <stdio.h>
  16.637 ++#include "config.h"
  16.638 ++#include "system.h"
  16.639 ++#include "coretypes.h"
  16.640 ++#include "tm.h"
  16.641 ++#include "rtl.h"
  16.642 ++#include "tree.h"
  16.643 ++#include "tm_p.h"
  16.644 ++#include "regs.h"
  16.645 ++#include "hard-reg-set.h"
  16.646 ++#include "real.h"
  16.647 ++#include "insn-config.h"
  16.648 ++#include "conditions.h"
  16.649 ++#include "output.h"
  16.650 ++#include "insn-attr.h"
  16.651 ++#include "flags.h"
  16.652 ++#include "recog.h"
  16.653 ++#include "expr.h"
  16.654 ++#include "toplev.h"
  16.655 ++#include "basic-block.h"
  16.656 ++#include "function.h"
  16.657 ++#include "ggc.h"
  16.658 ++#include "reload.h"
  16.659 ++#include "debug.h"
  16.660 ++#include "optabs.h"
  16.661 ++#include "target.h"
  16.662 ++#include "target-def.h"
  16.663 ++
  16.664 ++/* local prototypes */
  16.665 ++static bool nios2_rtx_costs (rtx, int, int, int *);
  16.666 ++
  16.667 ++static void nios2_asm_function_prologue (FILE *, HOST_WIDE_INT);
  16.668 ++static int nios2_use_dfa_pipeline_interface (void);
  16.669 ++static int nios2_issue_rate (void);
  16.670 ++static struct machine_function *nios2_init_machine_status (void);
  16.671 ++static bool nios2_in_small_data_p (tree);
  16.672 ++static rtx save_reg (int, HOST_WIDE_INT, rtx);
  16.673 ++static rtx restore_reg (int, HOST_WIDE_INT);
  16.674 ++static unsigned int nios2_section_type_flags (tree, const char *, int);
  16.675 ++static void nios2_init_builtins (void);
  16.676 ++static rtx nios2_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
  16.677 ++static bool nios2_function_ok_for_sibcall (tree, tree);
  16.678 ++static void nios2_encode_section_info (tree, rtx, int);
  16.679 ++
  16.680 ++/* Initialize the GCC target structure.  */
  16.681 ++#undef TARGET_ASM_FUNCTION_PROLOGUE
  16.682 ++#define TARGET_ASM_FUNCTION_PROLOGUE nios2_asm_function_prologue
  16.683 ++
  16.684 ++#undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
  16.685 ++#define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE \
  16.686 ++ nios2_use_dfa_pipeline_interface
  16.687 ++#undef TARGET_SCHED_ISSUE_RATE
  16.688 ++#define TARGET_SCHED_ISSUE_RATE nios2_issue_rate
  16.689 ++#undef TARGET_IN_SMALL_DATA_P
  16.690 ++#define TARGET_IN_SMALL_DATA_P nios2_in_small_data_p
  16.691 ++#undef  TARGET_ENCODE_SECTION_INFO
  16.692 ++#define TARGET_ENCODE_SECTION_INFO nios2_encode_section_info
  16.693 ++#undef  TARGET_SECTION_TYPE_FLAGS
  16.694 ++#define TARGET_SECTION_TYPE_FLAGS  nios2_section_type_flags
  16.695 ++
  16.696 ++#undef TARGET_INIT_BUILTINS
  16.697 ++#define TARGET_INIT_BUILTINS nios2_init_builtins
  16.698 ++#undef TARGET_EXPAND_BUILTIN
  16.699 ++#define TARGET_EXPAND_BUILTIN nios2_expand_builtin
  16.700 ++
  16.701 ++#undef TARGET_FUNCTION_OK_FOR_SIBCALL
  16.702 ++#define TARGET_FUNCTION_OK_FOR_SIBCALL nios2_function_ok_for_sibcall
  16.703 ++
  16.704 ++#undef TARGET_RTX_COSTS
  16.705 ++#define TARGET_RTX_COSTS nios2_rtx_costs
  16.706 ++
  16.707 ++
  16.708 ++struct gcc_target targetm = TARGET_INITIALIZER;
  16.709 ++
  16.710 ++
  16.711 ++
  16.712 ++/* Threshold for data being put into the small data/bss area, instead
  16.713 ++   of the normal data area (references to the small data/bss area take
  16.714 ++   1 instruction, and use the global pointer, references to the normal
  16.715 ++   data area takes 2 instructions).  */
  16.716 ++unsigned HOST_WIDE_INT nios2_section_threshold = NIOS2_DEFAULT_GVALUE;
  16.717 ++
  16.718 ++
  16.719 ++/* Structure to be filled in by compute_frame_size with register
  16.720 ++   save masks, and offsets for the current function.  */
  16.721 ++
  16.722 ++struct nios2_frame_info
  16.723 ++GTY (())
  16.724 ++{
  16.725 ++  long total_size;		/* # bytes that the entire frame takes up */
  16.726 ++  long var_size;		/* # bytes that variables take up */
  16.727 ++  long args_size;		/* # bytes that outgoing arguments take up */
  16.728 ++  int save_reg_size;		/* # bytes needed to store gp regs */
  16.729 ++  int save_reg_rounded;		/* # bytes needed to store gp regs */
  16.730 ++  long save_regs_offset;	/* offset from new sp to store gp registers */
  16.731 ++  int initialized;		/* != 0 if frame size already calculated */
  16.732 ++  int num_regs;			/* number of gp registers saved */
  16.733 ++};
  16.734 ++
  16.735 ++struct machine_function
  16.736 ++GTY (())
  16.737 ++{
  16.738 ++
  16.739 ++  /* Current frame information, calculated by compute_frame_size.  */
  16.740 ++  struct nios2_frame_info frame;
  16.741 ++};
  16.742 ++
  16.743 ++
  16.744 ++/***************************************
  16.745 ++ * Section encodings
  16.746 ++ ***************************************/
  16.747 ++
  16.748 ++
  16.749 ++
  16.750 ++
  16.751 ++
  16.752 ++/***************************************
  16.753 ++ * Stack Layout and Calling Conventions
  16.754 ++ ***************************************/
  16.755 ++
  16.756 ++
  16.757 ++#define TOO_BIG_OFFSET(X) ((X) > ((1 << 15) - 1))
  16.758 ++#define TEMP_REG_NUM 8
  16.759 ++
  16.760 ++static void
  16.761 ++nios2_asm_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
  16.762 ++{
  16.763 ++  if (flag_verbose_asm || flag_debug_asm)
  16.764 ++    {
  16.765 ++      compute_frame_size ();
  16.766 ++      dump_frame_size (file);
  16.767 ++    }
  16.768 ++}
  16.769 ++
  16.770 ++static rtx
  16.771 ++save_reg (int regno, HOST_WIDE_INT offset, rtx cfa_store_reg)
  16.772 ++{
  16.773 ++  rtx insn, stack_slot;
  16.774 ++
  16.775 ++  stack_slot = gen_rtx_PLUS (SImode,
  16.776 ++			     cfa_store_reg,
  16.777 ++			     GEN_INT (offset));
  16.778 ++
  16.779 ++  insn = emit_insn (gen_rtx_SET (SImode,
  16.780 ++				 gen_rtx_MEM (SImode, stack_slot),
  16.781 ++				 gen_rtx_REG (SImode, regno)));
  16.782 ++
  16.783 ++  RTX_FRAME_RELATED_P (insn) = 1;
  16.784 ++
  16.785 ++  return insn;
  16.786 ++}
  16.787 ++
  16.788 ++static rtx
  16.789 ++restore_reg (int regno, HOST_WIDE_INT offset)
  16.790 ++{
  16.791 ++  rtx insn, stack_slot;
  16.792 ++
  16.793 ++  if (TOO_BIG_OFFSET (offset))
  16.794 ++    {
  16.795 ++      stack_slot = gen_rtx_REG (SImode, TEMP_REG_NUM);
  16.796 ++      insn = emit_insn (gen_rtx_SET (SImode,
  16.797 ++				     stack_slot,
  16.798 ++				     GEN_INT (offset)));
  16.799 ++
  16.800 ++      insn = emit_insn (gen_rtx_SET (SImode,
  16.801 ++				     stack_slot,
  16.802 ++                                     gen_rtx_PLUS (SImode,
  16.803 ++				                   stack_slot,
  16.804 ++				                   stack_pointer_rtx)));
  16.805 ++    }
  16.806 ++  else
  16.807 ++    {
  16.808 ++      stack_slot = gen_rtx_PLUS (SImode,
  16.809 ++			         stack_pointer_rtx,
  16.810 ++				 GEN_INT (offset));
  16.811 ++    }
  16.812 ++
  16.813 ++  stack_slot = gen_rtx_MEM (SImode, stack_slot);
  16.814 ++
  16.815 ++  insn = emit_move_insn (gen_rtx_REG (SImode, regno), stack_slot);
  16.816 ++
  16.817 ++  return insn;
  16.818 ++}
  16.819 ++
  16.820 ++
  16.821 ++/* There are two possible paths for prologue expansion,
  16.822 ++- the first is if the total frame size is < 2^15-1. In that
  16.823 ++case all the immediates will fit into the 16-bit immediate
  16.824 ++fields.
  16.825 ++- the second is when the frame size is too big, in that
  16.826 ++case an additional temporary register is used, first 
  16.827 ++as a cfa_temp to offset the sp, second as the cfa_store
  16.828 ++register.
  16.829 ++
  16.830 ++See the comment above dwarf2out_frame_debug_expr in 
  16.831 ++dwarf2out.c for more explanation of the "rules."
  16.832 ++
  16.833 ++
  16.834 ++Case 1:
  16.835 ++Rule #  Example Insn                       Effect
  16.836 ++2  	addi	sp, sp, -total_frame_size  cfa.reg=sp, cfa.offset=total_frame_size
  16.837 ++                                           cfa_store.reg=sp, cfa_store.offset=total_frame_size
  16.838 ++12  	stw	ra, offset(sp)		   
  16.839 ++12  	stw	r16, offset(sp)
  16.840 ++1  	mov	fp, sp
  16.841 ++  
  16.842 ++Case 2: 
  16.843 ++Rule #  Example Insn                       Effect
  16.844 ++6 	movi	r8, total_frame_size       cfa_temp.reg=r8, cfa_temp.offset=total_frame_size
  16.845 ++2  	sub	sp, sp, r8                 cfa.reg=sp, cfa.offset=total_frame_size
  16.846 ++                                           cfa_store.reg=sp, cfa_store.offset=total_frame_size
  16.847 ++5   	add	r8, r8, sp                 cfa_store.reg=r8, cfa_store.offset=0
  16.848 ++12  	stw	ra, offset(r8)
  16.849 ++12  	stw	r16, offset(r8)
  16.850 ++1  	mov	fp, sp
  16.851 ++
  16.852 ++*/
  16.853 ++
  16.854 ++void
  16.855 ++expand_prologue ()
  16.856 ++{
  16.857 ++  int i;
  16.858 ++  HOST_WIDE_INT total_frame_size;
  16.859 ++  int cfa_store_offset;
  16.860 ++  rtx insn;
  16.861 ++  rtx cfa_store_reg = 0;
  16.862 ++
  16.863 ++  total_frame_size = compute_frame_size ();
  16.864 ++
  16.865 ++  if (total_frame_size)
  16.866 ++    {
  16.867 ++
  16.868 ++      if (TOO_BIG_OFFSET (total_frame_size)) 
  16.869 ++	{
  16.870 ++	    /* cfa_temp and cfa_store_reg are the same register,
  16.871 ++	       cfa_store_reg overwrites cfa_temp */
  16.872 ++	    cfa_store_reg = gen_rtx_REG (SImode, TEMP_REG_NUM);
  16.873 ++	    insn = emit_insn (gen_rtx_SET (SImode,
  16.874 ++					   cfa_store_reg,
  16.875 ++					   GEN_INT (total_frame_size)));
  16.876 ++
  16.877 ++	    RTX_FRAME_RELATED_P (insn) = 1;
  16.878 ++
  16.879 ++
  16.880 ++	    insn = gen_rtx_SET (SImode,
  16.881 ++				stack_pointer_rtx,
  16.882 ++				gen_rtx_MINUS (SImode,
  16.883 ++					       stack_pointer_rtx,
  16.884 ++					       cfa_store_reg));
  16.885 ++
  16.886 ++	    insn = emit_insn (insn);
  16.887 ++	    RTX_FRAME_RELATED_P (insn) = 1;
  16.888 ++
  16.889 ++
  16.890 ++	    /* if there are no registers to save, I don't need to
  16.891 ++	       create a cfa_store */
  16.892 ++	    if (cfun->machine->frame.save_reg_size) 
  16.893 ++	      {
  16.894 ++		insn = gen_rtx_SET (SImode,
  16.895 ++				    cfa_store_reg,
  16.896 ++				    gen_rtx_PLUS (SImode,
  16.897 ++						  cfa_store_reg,
  16.898 ++						  stack_pointer_rtx));
  16.899 ++
  16.900 ++		insn = emit_insn (insn);
  16.901 ++		RTX_FRAME_RELATED_P (insn) = 1;
  16.902 ++	      }
  16.903 ++
  16.904 ++	    cfa_store_offset 
  16.905 ++	      = total_frame_size 
  16.906 ++		- (cfun->machine->frame.save_regs_offset
  16.907 ++		   + cfun->machine->frame.save_reg_rounded);
  16.908 ++	}
  16.909 ++      else
  16.910 ++	{
  16.911 ++	    insn = gen_rtx_SET (SImode,
  16.912 ++				stack_pointer_rtx,
  16.913 ++				gen_rtx_PLUS (SImode,
  16.914 ++					      stack_pointer_rtx,
  16.915 ++					      GEN_INT (-total_frame_size)));
  16.916 ++	    insn = emit_insn (insn);
  16.917 ++	    RTX_FRAME_RELATED_P (insn) = 1;
  16.918 ++
  16.919 ++	    cfa_store_reg = stack_pointer_rtx;
  16.920 ++	    cfa_store_offset 
  16.921 ++	      = cfun->machine->frame.save_regs_offset
  16.922 ++		+ cfun->machine->frame.save_reg_rounded;
  16.923 ++	}
  16.924 ++    }
  16.925 ++
  16.926 ++  if (MUST_SAVE_REGISTER (RA_REGNO))
  16.927 ++    {
  16.928 ++      cfa_store_offset -= 4;
  16.929 ++      save_reg (RA_REGNO, cfa_store_offset, cfa_store_reg);
  16.930 ++    }
  16.931 ++  if (MUST_SAVE_REGISTER (FP_REGNO))
  16.932 ++    {
  16.933 ++      cfa_store_offset -= 4;
  16.934 ++      save_reg (FP_REGNO, cfa_store_offset, cfa_store_reg);
  16.935 ++    }
  16.936 ++
  16.937 ++  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  16.938 ++    {
  16.939 ++      if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
  16.940 ++	{
  16.941 ++	  cfa_store_offset -= 4;
  16.942 ++	  save_reg (i, cfa_store_offset, cfa_store_reg);
  16.943 ++	}
  16.944 ++    }
  16.945 ++
  16.946 ++  if (frame_pointer_needed)
  16.947 ++    {
  16.948 ++      insn = emit_insn (gen_rtx_SET (SImode,
  16.949 ++				     gen_rtx_REG (SImode, FP_REGNO),
  16.950 ++				     gen_rtx_REG (SImode, SP_REGNO)));
  16.951 ++
  16.952 ++      RTX_FRAME_RELATED_P (insn) = 1;
  16.953 ++    }
  16.954 ++
  16.955 ++  /* If we are profiling, make sure no instructions are scheduled before
  16.956 ++     the call to mcount.  */
  16.957 ++  if (current_function_profile)
  16.958 ++    emit_insn (gen_blockage ());
  16.959 ++}
  16.960 ++
  16.961 ++void
  16.962 ++expand_epilogue (bool sibcall_p)
  16.963 ++{
  16.964 ++  rtx insn;
  16.965 ++  int i;
  16.966 ++  HOST_WIDE_INT total_frame_size;
  16.967 ++  int register_store_offset;
  16.968 ++
  16.969 ++  total_frame_size = compute_frame_size ();
  16.970 ++
  16.971 ++  if (!sibcall_p && nios2_can_use_return_insn ())
  16.972 ++    {
  16.973 ++      insn = emit_jump_insn (gen_return ());
  16.974 ++      return;
  16.975 ++    }
  16.976 ++
  16.977 ++  emit_insn (gen_blockage ());
  16.978 ++
  16.979 ++  register_store_offset =
  16.980 ++    cfun->machine->frame.save_regs_offset +
  16.981 ++    cfun->machine->frame.save_reg_rounded;
  16.982 ++
  16.983 ++  if (MUST_SAVE_REGISTER (RA_REGNO))
  16.984 ++    {
  16.985 ++      register_store_offset -= 4;
  16.986 ++      restore_reg (RA_REGNO, register_store_offset);
  16.987 ++    }
  16.988 ++
  16.989 ++  if (MUST_SAVE_REGISTER (FP_REGNO))
  16.990 ++    {
  16.991 ++      register_store_offset -= 4;
  16.992 ++      restore_reg (FP_REGNO, register_store_offset);
  16.993 ++    }
  16.994 ++
  16.995 ++  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  16.996 ++    {
  16.997 ++      if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
  16.998 ++	{
  16.999 ++	  register_store_offset -= 4;
 16.1000 ++	  restore_reg (i, register_store_offset);
 16.1001 ++	}
 16.1002 ++    }
 16.1003 ++
 16.1004 ++  if (total_frame_size)
 16.1005 ++    {
 16.1006 ++      rtx sp_adjust;
 16.1007 ++
 16.1008 ++      if (TOO_BIG_OFFSET (total_frame_size))
 16.1009 ++        {
 16.1010 ++	  sp_adjust = gen_rtx_REG (SImode, TEMP_REG_NUM);
 16.1011 ++	  insn = emit_insn (gen_rtx_SET (SImode,
 16.1012 ++					 sp_adjust,
 16.1013 ++					 GEN_INT (total_frame_size)));
 16.1014 ++
 16.1015 ++      	}
 16.1016 ++      else
 16.1017 ++        {
 16.1018 ++	  sp_adjust = GEN_INT (total_frame_size);
 16.1019 ++	}
 16.1020 ++
 16.1021 ++      insn = gen_rtx_SET (SImode,
 16.1022 ++			  stack_pointer_rtx,
 16.1023 ++			  gen_rtx_PLUS (SImode,
 16.1024 ++					stack_pointer_rtx,
 16.1025 ++					sp_adjust));
 16.1026 ++      insn = emit_insn (insn);
 16.1027 ++    }
 16.1028 ++
 16.1029 ++
 16.1030 ++  if (!sibcall_p)
 16.1031 ++    {
 16.1032 ++      insn = emit_jump_insn (gen_return_from_epilogue (gen_rtx (REG, Pmode,
 16.1033 ++								RA_REGNO)));
 16.1034 ++    }
 16.1035 ++}
 16.1036 ++
 16.1037 ++
 16.1038 ++bool
 16.1039 ++nios2_function_ok_for_sibcall (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
 16.1040 ++{
 16.1041 ++  return true;
 16.1042 ++}
 16.1043 ++
 16.1044 ++
 16.1045 ++
 16.1046 ++
 16.1047 ++
 16.1048 ++/* ----------------------- *
 16.1049 ++ * Profiling
 16.1050 ++ * ----------------------- */
 16.1051 ++
 16.1052 ++void
 16.1053 ++function_profiler (FILE *file, int labelno)
 16.1054 ++{
 16.1055 ++  fprintf (file, "\t%s mcount begin, label: .LP%d\n", 
 16.1056 ++           ASM_COMMENT_START, labelno);
 16.1057 ++  fprintf (file, "\tnextpc\tr8\n");
 16.1058 ++  fprintf (file, "\tmov\tr9, ra\n");
 16.1059 ++  fprintf (file, "\tmovhi\tr10, %%hiadj(.LP%d)\n", labelno);
 16.1060 ++  fprintf (file, "\taddi\tr10, r10, %%lo(.LP%d)\n", labelno);
 16.1061 ++  fprintf (file, "\tcall\tmcount\n");
 16.1062 ++  fprintf (file, "\tmov\tra, r9\n");
 16.1063 ++  fprintf (file, "\t%s mcount end\n", ASM_COMMENT_START);
 16.1064 ++}
 16.1065 ++
 16.1066 ++
 16.1067 ++/***************************************
 16.1068 ++ * Stack Layout
 16.1069 ++ ***************************************/
 16.1070 ++
 16.1071 ++
 16.1072 ++void
 16.1073 ++dump_frame_size (FILE *file)
 16.1074 ++{
 16.1075 ++  fprintf (file, "\t%s Current Frame Info\n", ASM_COMMENT_START);
 16.1076 ++
 16.1077 ++  fprintf (file, "\t%s total_size = %ld\n", ASM_COMMENT_START,
 16.1078 ++	   cfun->machine->frame.total_size);
 16.1079 ++  fprintf (file, "\t%s var_size = %ld\n", ASM_COMMENT_START,
 16.1080 ++	   cfun->machine->frame.var_size);
 16.1081 ++  fprintf (file, "\t%s args_size = %ld\n", ASM_COMMENT_START,
 16.1082 ++	   cfun->machine->frame.args_size);
 16.1083 ++  fprintf (file, "\t%s save_reg_size = %d\n", ASM_COMMENT_START,
 16.1084 ++	   cfun->machine->frame.save_reg_size);
 16.1085 ++  fprintf (file, "\t%s save_reg_rounded = %d\n", ASM_COMMENT_START,
 16.1086 ++	   cfun->machine->frame.save_reg_rounded);
 16.1087 ++  fprintf (file, "\t%s initialized = %d\n", ASM_COMMENT_START,
 16.1088 ++	   cfun->machine->frame.initialized);
 16.1089 ++  fprintf (file, "\t%s num_regs = %d\n", ASM_COMMENT_START,
 16.1090 ++	   cfun->machine->frame.num_regs);
 16.1091 ++  fprintf (file, "\t%s save_regs_offset = %ld\n", ASM_COMMENT_START,
 16.1092 ++	   cfun->machine->frame.save_regs_offset);
 16.1093 ++  fprintf (file, "\t%s current_function_is_leaf = %d\n", ASM_COMMENT_START,
 16.1094 ++	   current_function_is_leaf);
 16.1095 ++  fprintf (file, "\t%s frame_pointer_needed = %d\n", ASM_COMMENT_START,
 16.1096 ++	   frame_pointer_needed);
 16.1097 ++  fprintf (file, "\t%s pretend_args_size = %d\n", ASM_COMMENT_START,
 16.1098 ++	   current_function_pretend_args_size);
 16.1099 ++
 16.1100 ++}
 16.1101 ++
 16.1102 ++
 16.1103 ++/* Return the bytes needed to compute the frame pointer from the current
 16.1104 ++   stack pointer.
 16.1105 ++*/
 16.1106 ++
 16.1107 ++HOST_WIDE_INT
 16.1108 ++compute_frame_size ()
 16.1109 ++{
 16.1110 ++  unsigned int regno;
 16.1111 ++  HOST_WIDE_INT var_size;	/* # of var. bytes allocated */
 16.1112 ++  HOST_WIDE_INT total_size;	/* # bytes that the entire frame takes up */
 16.1113 ++  HOST_WIDE_INT save_reg_size;	/* # bytes needed to store callee save regs */
 16.1114 ++  HOST_WIDE_INT save_reg_rounded;	
 16.1115 ++    /* # bytes needed to store callee save regs (rounded) */
 16.1116 ++  HOST_WIDE_INT out_args_size;	/* # bytes needed for outgoing args */
 16.1117 ++
 16.1118 ++  save_reg_size = 0;
 16.1119 ++  var_size = STACK_ALIGN (get_frame_size ());
 16.1120 ++  out_args_size = STACK_ALIGN (current_function_outgoing_args_size);
 16.1121 ++
 16.1122 ++  total_size = var_size + out_args_size;
 16.1123 ++
 16.1124 ++  /* Calculate space needed for gp registers.  */
 16.1125 ++  for (regno = 0; regno <= FIRST_PSEUDO_REGISTER; regno++)
 16.1126 ++    {
 16.1127 ++      if (MUST_SAVE_REGISTER (regno))
 16.1128 ++	{
 16.1129 ++	  save_reg_size += 4;
 16.1130 ++	}
 16.1131 ++    }
 16.1132 ++
 16.1133 ++  save_reg_rounded = STACK_ALIGN (save_reg_size);
 16.1134 ++  total_size += save_reg_rounded;
 16.1135 ++
 16.1136 ++  total_size += STACK_ALIGN (current_function_pretend_args_size);
 16.1137 ++
 16.1138 ++  /* Save other computed information.  */
 16.1139 ++  cfun->machine->frame.total_size = total_size;
 16.1140 ++  cfun->machine->frame.var_size = var_size;
 16.1141 ++  cfun->machine->frame.args_size = current_function_outgoing_args_size;
 16.1142 ++  cfun->machine->frame.save_reg_size = save_reg_size;
 16.1143 ++  cfun->machine->frame.save_reg_rounded = save_reg_rounded;
 16.1144 ++  cfun->machine->frame.initialized = reload_completed;
 16.1145 ++  cfun->machine->frame.num_regs = save_reg_size / UNITS_PER_WORD;
 16.1146 ++
 16.1147 ++  cfun->machine->frame.save_regs_offset
 16.1148 ++    = save_reg_rounded ? current_function_outgoing_args_size + var_size : 0;
 16.1149 ++
 16.1150 ++  return total_size;
 16.1151 ++}
 16.1152 ++
 16.1153 ++
 16.1154 ++int
 16.1155 ++nios2_initial_elimination_offset (int from, int to ATTRIBUTE_UNUSED)
 16.1156 ++{
 16.1157 ++  int offset;
 16.1158 ++
 16.1159 ++  /* Set OFFSET to the offset from the stack pointer.  */
 16.1160 ++  switch (from)
 16.1161 ++    {
 16.1162 ++    case FRAME_POINTER_REGNUM:
 16.1163 ++      offset = 0;
 16.1164 ++      break;
 16.1165 ++
 16.1166 ++    case ARG_POINTER_REGNUM:
 16.1167 ++      compute_frame_size ();
 16.1168 ++      offset = cfun->machine->frame.total_size;
 16.1169 ++      offset -= current_function_pretend_args_size;
 16.1170 ++      break;
 16.1171 ++
 16.1172 ++    case RETURN_ADDRESS_POINTER_REGNUM:
 16.1173 ++      compute_frame_size ();
 16.1174 ++      /* since the return address is always the first of the
 16.1175 ++         saved registers, return the offset to the beginning
 16.1176 ++         of the saved registers block */
 16.1177 ++      offset = cfun->machine->frame.save_regs_offset;
 16.1178 ++      break;
 16.1179 ++
 16.1180 ++    default:
 16.1181 ++      abort ();
 16.1182 ++    }
 16.1183 ++
 16.1184 ++  return offset;
 16.1185 ++}
 16.1186 ++
 16.1187 ++/* Return nonzero if this function is known to have a null epilogue.
 16.1188 ++   This allows the optimizer to omit jumps to jumps if no stack
 16.1189 ++   was created.  */
 16.1190 ++int
 16.1191 ++nios2_can_use_return_insn ()
 16.1192 ++{
 16.1193 ++  if (!reload_completed)
 16.1194 ++    return 0;
 16.1195 ++
 16.1196 ++  if (regs_ever_live[RA_REGNO] || current_function_profile)
 16.1197 ++    return 0;
 16.1198 ++
 16.1199 ++  if (cfun->machine->frame.initialized)
 16.1200 ++    return cfun->machine->frame.total_size == 0;
 16.1201 ++
 16.1202 ++  return compute_frame_size () == 0;
 16.1203 ++}
 16.1204 ++
 16.1205 ++
 16.1206 ++
 16.1207 ++
 16.1208 ++
 16.1209 ++/***************************************
 16.1210 ++ *
 16.1211 ++ ***************************************/
 16.1212 ++
 16.1213 ++const char *nios2_sys_nosys_string;    /* for -msys=nosys */
 16.1214 ++const char *nios2_sys_lib_string;    /* for -msys-lib= */
 16.1215 ++const char *nios2_sys_crt0_string;    /* for -msys-crt0= */
 16.1216 ++
 16.1217 ++void
 16.1218 ++override_options ()
 16.1219 ++{
 16.1220 ++  /* Function to allocate machine-dependent function status.  */
 16.1221 ++  init_machine_status = &nios2_init_machine_status;
 16.1222 ++
 16.1223 ++  nios2_section_threshold 
 16.1224 ++    = g_switch_set ? g_switch_value : NIOS2_DEFAULT_GVALUE;
 16.1225 ++
 16.1226 ++  if (nios2_sys_nosys_string && *nios2_sys_nosys_string)
 16.1227 ++    {
 16.1228 ++      error ("invalid option '-msys=nosys%s'", nios2_sys_nosys_string);
 16.1229 ++    }
 16.1230 ++
 16.1231 ++  /* If we don't have mul, we don't have mulx either! */
 16.1232 ++  if (!TARGET_HAS_MUL && TARGET_HAS_MULX) 
 16.1233 ++    {
 16.1234 ++      target_flags &= ~HAS_MULX_FLAG;
 16.1235 ++    }
 16.1236 ++
 16.1237 ++}
 16.1238 ++
 16.1239 ++void
 16.1240 ++optimization_options (int level, int size)
 16.1241 ++{
 16.1242 ++  if (level || size)
 16.1243 ++    {
 16.1244 ++      target_flags |= INLINE_MEMCPY_FLAG;
 16.1245 ++    }
 16.1246 ++
 16.1247 ++  if (level >= 3 && !size)
 16.1248 ++    {
 16.1249 ++      target_flags |= FAST_SW_DIV_FLAG;
 16.1250 ++    }
 16.1251 ++}
 16.1252 ++
 16.1253 ++/* Allocate a chunk of memory for per-function machine-dependent data.  */
 16.1254 ++static struct machine_function *
 16.1255 ++nios2_init_machine_status ()
 16.1256 ++{
 16.1257 ++  return ((struct machine_function *)
 16.1258 ++	  ggc_alloc_cleared (sizeof (struct machine_function)));
 16.1259 ++}
 16.1260 ++
 16.1261 ++
 16.1262 ++
 16.1263 ++/*****************
 16.1264 ++ * Describing Relative Costs of Operations
 16.1265 ++ *****************/
 16.1266 ++
 16.1267 ++/* Compute a (partial) cost for rtx X.  Return true if the complete
 16.1268 ++   cost has been computed, and false if subexpressions should be
 16.1269 ++   scanned.  In either case, *TOTAL contains the cost result.  */
 16.1270 ++
 16.1271 ++
 16.1272 ++
 16.1273 ++static bool
 16.1274 ++nios2_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
 16.1275 ++{
 16.1276 ++  switch (code)
 16.1277 ++    {
 16.1278 ++      case CONST_INT:
 16.1279 ++	if (INTVAL (x) == 0)
 16.1280 ++	  {
 16.1281 ++	    *total = COSTS_N_INSNS (0);
 16.1282 ++	    return true;
 16.1283 ++	  }
 16.1284 ++	else if (SMALL_INT (INTVAL (x))
 16.1285 ++		|| SMALL_INT_UNSIGNED (INTVAL (x))
 16.1286 ++		|| UPPER16_INT (INTVAL (x)))
 16.1287 ++	  {
 16.1288 ++	    *total = COSTS_N_INSNS (2);
 16.1289 ++	    return true;
 16.1290 ++	  }
 16.1291 ++	else
 16.1292 ++	  {
 16.1293 ++	    *total = COSTS_N_INSNS (4);
 16.1294 ++	    return true;
 16.1295 ++	  }
 16.1296 ++
 16.1297 ++      case LABEL_REF:
 16.1298 ++      case SYMBOL_REF:
 16.1299 ++	/* ??? gp relative stuff will fit in here */
 16.1300 ++	/* fall through */
 16.1301 ++      case CONST:
 16.1302 ++      case CONST_DOUBLE:
 16.1303 ++	{
 16.1304 ++	  *total = COSTS_N_INSNS (4);
 16.1305 ++	  return true;
 16.1306 ++	}
 16.1307 ++
 16.1308 ++      case MULT:
 16.1309 ++	{
 16.1310 ++	  *total = COSTS_N_INSNS (1);
 16.1311 ++	  return false;
 16.1312 ++	}
 16.1313 ++      case SIGN_EXTEND:
 16.1314 ++	{
 16.1315 ++	  *total = COSTS_N_INSNS (3);
 16.1316 ++	  return false;
 16.1317 ++	}
 16.1318 ++      case ZERO_EXTEND:
 16.1319 ++	{
 16.1320 ++	  *total = COSTS_N_INSNS (1);
 16.1321 ++	  return false;
 16.1322 ++	}
 16.1323 ++
 16.1324 ++    default:
 16.1325 ++      return false;
 16.1326 ++    }
 16.1327 ++}
 16.1328 ++
 16.1329 ++
 16.1330 ++/***************************************
 16.1331 ++ * INSTRUCTION SUPPORT
 16.1332 ++ *
 16.1333 ++ * These functions are used within the Machine Description to
 16.1334 ++ * handle common or complicated output and expansions from
 16.1335 ++ * instructions.
 16.1336 ++ ***************************************/
 16.1337 ++
 16.1338 ++int
 16.1339 ++nios2_emit_move_sequence (rtx *operands, enum machine_mode mode)
 16.1340 ++{
 16.1341 ++  rtx to = operands[0];
 16.1342 ++  rtx from = operands[1];
 16.1343 ++
 16.1344 ++  if (!register_operand (to, mode) && !reg_or_0_operand (from, mode))
 16.1345 ++    {
 16.1346 ++      if (no_new_pseudos)
 16.1347 ++	internal_error ("Trying to force_reg no_new_pseudos == 1");
 16.1348 ++      from = copy_to_mode_reg (mode, from);
 16.1349 ++    }
 16.1350 ++
 16.1351 ++  operands[0] = to;
 16.1352 ++  operands[1] = from;
 16.1353 ++  return 0;
 16.1354 ++}
 16.1355 ++
 16.1356 ++/* Divide Support */
 16.1357 ++
 16.1358 ++/*
 16.1359 ++  If -O3 is used, we want to output a table lookup for
 16.1360 ++  divides between small numbers (both num and den >= 0
 16.1361 ++  and < 0x10). The overhead of this method in the worse
 16.1362 ++  case is 40 bytes in the text section (10 insns) and
 16.1363 ++  256 bytes in the data section. Additional divides do
 16.1364 ++  not incur additional penalties in the data section.
 16.1365 ++
 16.1366 ++  Code speed is improved for small divides by about 5x
 16.1367 ++  when using this method in the worse case (~9 cycles
 16.1368 ++  vs ~45). And in the worse case divides not within the
 16.1369 ++  table are penalized by about 10% (~5 cycles vs ~45).
 16.1370 ++  However in the typical case the penalty is not as bad
 16.1371 ++  because doing the long divide in only 45 cycles is
 16.1372 ++  quite optimistic.
 16.1373 ++
 16.1374 ++  ??? It would be nice to have some benchmarks other
 16.1375 ++  than Dhrystone to back this up.
 16.1376 ++
 16.1377 ++  This bit of expansion is to create this instruction
 16.1378 ++  sequence as rtl.
 16.1379 ++	or	$8, $4, $5
 16.1380 ++	slli	$9, $4, 4
 16.1381 ++	cmpgeui	$3, $8, 16
 16.1382 ++	beq	$3, $0, .L3
 16.1383 ++	or	$10, $9, $5
 16.1384 ++	add	$12, $11, divide_table
 16.1385 ++	ldbu	$2, 0($12)
 16.1386 ++	br	.L1
 16.1387 ++.L3:
 16.1388 ++	call	slow_div
 16.1389 ++.L1:
 16.1390 ++#	continue here with result in $2
 16.1391 ++
 16.1392 ++  ??? Ideally I would like the emit libcall block to contain
 16.1393 ++  all of this code, but I don't know how to do that. What it
 16.1394 ++  means is that if the divide can be eliminated, it may not
 16.1395 ++  completely disappear.
 16.1396 ++
 16.1397 ++  ??? The __divsi3_table label should ideally be moved out
 16.1398 ++  of this block and into a global. If it is placed into the
 16.1399 ++  sdata section we can save even more cycles by doing things
 16.1400 ++  gp relative.
 16.1401 ++*/
 16.1402 ++int
 16.1403 ++nios2_emit_expensive_div (rtx *operands, enum machine_mode mode)
 16.1404 ++{
 16.1405 ++  rtx or_result, shift_left_result;
 16.1406 ++  rtx lookup_value;
 16.1407 ++  rtx lab1, lab3;
 16.1408 ++  rtx insns;
 16.1409 ++  rtx libfunc;
 16.1410 ++  rtx final_result;
 16.1411 ++  rtx tmp;
 16.1412 ++
 16.1413 ++  /* it may look a little generic, but only SImode
 16.1414 ++     is supported for now */
 16.1415 ++  if (mode != SImode)
 16.1416 ++    abort ();
 16.1417 ++
 16.1418 ++  libfunc = sdiv_optab->handlers[(int) SImode].libfunc;
 16.1419 ++
 16.1420 ++
 16.1421 ++
 16.1422 ++  lab1 = gen_label_rtx ();
 16.1423 ++  lab3 = gen_label_rtx ();
 16.1424 ++
 16.1425 ++  or_result = expand_simple_binop (SImode, IOR,
 16.1426 ++				   operands[1], operands[2],
 16.1427 ++				   0, 0, OPTAB_LIB_WIDEN);
 16.1428 ++
 16.1429 ++  emit_cmp_and_jump_insns (or_result, GEN_INT (15), GTU, 0,
 16.1430 ++			   GET_MODE (or_result), 0, lab3);
 16.1431 ++  JUMP_LABEL (get_last_insn ()) = lab3;
 16.1432 ++
 16.1433 ++  shift_left_result = expand_simple_binop (SImode, ASHIFT,
 16.1434 ++					   operands[1], GEN_INT (4),
 16.1435 ++					   0, 0, OPTAB_LIB_WIDEN);
 16.1436 ++
 16.1437 ++  lookup_value = expand_simple_binop (SImode, IOR,
 16.1438 ++				      shift_left_result, operands[2],
 16.1439 ++				      0, 0, OPTAB_LIB_WIDEN);
 16.1440 ++
 16.1441 ++  convert_move (operands[0],
 16.1442 ++		gen_rtx (MEM, QImode,
 16.1443 ++			 gen_rtx (PLUS, SImode,
 16.1444 ++				  lookup_value,
 16.1445 ++				  gen_rtx_SYMBOL_REF (SImode, "__divsi3_table"))),
 16.1446 ++		1);
 16.1447 ++
 16.1448 ++
 16.1449 ++  tmp = emit_jump_insn (gen_jump (lab1));
 16.1450 ++  JUMP_LABEL (tmp) = lab1;
 16.1451 ++  emit_barrier ();
 16.1452 ++
 16.1453 ++  emit_label (lab3);
 16.1454 ++  LABEL_NUSES (lab3) = 1;
 16.1455 ++
 16.1456 ++  start_sequence ();
 16.1457 ++  final_result = emit_library_call_value (libfunc, NULL_RTX,
 16.1458 ++					  LCT_CONST, SImode, 2,
 16.1459 ++					  operands[1], SImode,
 16.1460 ++					  operands[2], SImode);
 16.1461 ++
 16.1462 ++
 16.1463 ++  insns = get_insns ();
 16.1464 ++  end_sequence ();
 16.1465 ++  emit_libcall_block (insns, operands[0], final_result,
 16.1466 ++		      gen_rtx (DIV, SImode, operands[1], operands[2]));
 16.1467 ++
 16.1468 ++  emit_label (lab1);
 16.1469 ++  LABEL_NUSES (lab1) = 1;
 16.1470 ++  return 1;
 16.1471 ++}
 16.1472 ++
 16.1473 ++/* Branches/Compares */
 16.1474 ++
 16.1475 ++/* the way of handling branches/compares
 16.1476 ++   in gcc is heavily borrowed from MIPS */
 16.1477 ++
 16.1478 ++enum internal_test
 16.1479 ++{
 16.1480 ++  ITEST_EQ,
 16.1481 ++  ITEST_NE,
 16.1482 ++  ITEST_GT,
 16.1483 ++  ITEST_GE,
 16.1484 ++  ITEST_LT,
 16.1485 ++  ITEST_LE,
 16.1486 ++  ITEST_GTU,
 16.1487 ++  ITEST_GEU,
 16.1488 ++  ITEST_LTU,
 16.1489 ++  ITEST_LEU,
 16.1490 ++  ITEST_MAX
 16.1491 ++};
 16.1492 ++
 16.1493 ++static enum internal_test map_test_to_internal_test (enum rtx_code);
 16.1494 ++
 16.1495 ++/* Cached operands, and operator to compare for use in set/branch/trap
 16.1496 ++   on condition codes.  */
 16.1497 ++rtx branch_cmp[2];
 16.1498 ++enum cmp_type branch_type;
 16.1499 ++
 16.1500 ++/* Make normal rtx_code into something we can index from an array */
 16.1501 ++
 16.1502 ++static enum internal_test
 16.1503 ++map_test_to_internal_test (enum rtx_code test_code)
 16.1504 ++{
 16.1505 ++  enum internal_test test = ITEST_MAX;
 16.1506 ++
 16.1507 ++  switch (test_code)
 16.1508 ++    {
 16.1509 ++    case EQ:
 16.1510 ++      test = ITEST_EQ;
 16.1511 ++      break;
 16.1512 ++    case NE:
 16.1513 ++      test = ITEST_NE;
 16.1514 ++      break;
 16.1515 ++    case GT:
 16.1516 ++      test = ITEST_GT;
 16.1517 ++      break;
 16.1518 ++    case GE:
 16.1519 ++      test = ITEST_GE;
 16.1520 ++      break;
 16.1521 ++    case LT:
 16.1522 ++      test = ITEST_LT;
 16.1523 ++      break;
 16.1524 ++    case LE:
 16.1525 ++      test = ITEST_LE;
 16.1526 ++      break;
 16.1527 ++    case GTU:
 16.1528 ++      test = ITEST_GTU;
 16.1529 ++      break;
 16.1530 ++    case GEU:
 16.1531 ++      test = ITEST_GEU;
 16.1532 ++      break;
 16.1533 ++    case LTU:
 16.1534 ++      test = ITEST_LTU;
 16.1535 ++      break;
 16.1536 ++    case LEU:
 16.1537 ++      test = ITEST_LEU;
 16.1538 ++      break;
 16.1539 ++    default:
 16.1540 ++      break;
 16.1541 ++    }
 16.1542 ++
 16.1543 ++  return test;
 16.1544 ++}
 16.1545 ++
 16.1546 ++/* Generate the code to compare (and possibly branch) two integer values
 16.1547 ++   TEST_CODE is the comparison code we are trying to emulate 
 16.1548 ++     (or implement directly)
 16.1549 ++   RESULT is where to store the result of the comparison, 
 16.1550 ++     or null to emit a branch
 16.1551 ++   CMP0 CMP1 are the two comparison operands
 16.1552 ++   DESTINATION is the destination of the branch, or null to only compare
 16.1553 ++   */
 16.1554 ++
 16.1555 ++void
 16.1556 ++gen_int_relational (enum rtx_code test_code, /* relational test (EQ, etc) */
 16.1557 ++		    rtx result,		/* result to store comp. or 0 if branch */
 16.1558 ++		    rtx cmp0,		/* first operand to compare */
 16.1559 ++		    rtx cmp1,		/* second operand to compare */
 16.1560 ++		    rtx destination)	/* destination of the branch, or 0 if compare */
 16.1561 ++{
 16.1562 ++  struct cmp_info
 16.1563 ++  {
 16.1564 ++    /* for register (or 0) compares */
 16.1565 ++    enum rtx_code test_code_reg;	/* code to use in instruction (LT vs. LTU) */
 16.1566 ++    int reverse_regs;		/* reverse registers in test */
 16.1567 ++
 16.1568 ++    /* for immediate compares */
 16.1569 ++    enum rtx_code test_code_const;	
 16.1570 ++         /* code to use in instruction (LT vs. LTU) */
 16.1571 ++    int const_low;		/* low bound of constant we can accept */
 16.1572 ++    int const_high;		/* high bound of constant we can accept */
 16.1573 ++    int const_add;		/* constant to add */
 16.1574 ++
 16.1575 ++    /* generic info */
 16.1576 ++    int unsignedp;		/* != 0 for unsigned comparisons.  */
 16.1577 ++  };
 16.1578 ++
 16.1579 ++  static const struct cmp_info info[(int) ITEST_MAX] = {
 16.1580 ++
 16.1581 ++    {EQ, 0, EQ, -32768, 32767, 0, 0}, /* EQ  */
 16.1582 ++    {NE, 0, NE, -32768, 32767, 0, 0}, /* NE  */
 16.1583 ++
 16.1584 ++    {LT, 1, GE, -32769, 32766, 1, 0}, /* GT  */
 16.1585 ++    {GE, 0, GE, -32768, 32767, 0, 0}, /* GE  */
 16.1586 ++    {LT, 0, LT, -32768, 32767, 0, 0}, /* LT  */
 16.1587 ++    {GE, 1, LT, -32769, 32766, 1, 0}, /* LE  */
 16.1588 ++
 16.1589 ++    {LTU, 1, GEU, 0, 65534, 1, 0}, /* GTU */
 16.1590 ++    {GEU, 0, GEU, 0, 65535, 0, 0}, /* GEU */
 16.1591 ++    {LTU, 0, LTU, 0, 65535, 0, 0}, /* LTU */
 16.1592 ++    {GEU, 1, LTU, 0, 65534, 1, 0}, /* LEU */
 16.1593 ++  };
 16.1594 ++
 16.1595 ++  enum internal_test test;
 16.1596 ++  enum machine_mode mode;
 16.1597 ++  const struct cmp_info *p_info;
 16.1598 ++  int branch_p;
 16.1599 ++
 16.1600 ++
 16.1601 ++
 16.1602 ++
 16.1603 ++  test = map_test_to_internal_test (test_code);
 16.1604 ++  if (test == ITEST_MAX)
 16.1605 ++    abort ();
 16.1606 ++
 16.1607 ++  p_info = &info[(int) test];
 16.1608 ++
 16.1609 ++  mode = GET_MODE (cmp0);
 16.1610 ++  if (mode == VOIDmode)
 16.1611 ++    mode = GET_MODE (cmp1);
 16.1612 ++
 16.1613 ++  branch_p = (destination != 0);
 16.1614 ++
 16.1615 ++  /* We can't, under any circumstances, have const_ints in cmp0
 16.1616 ++     ??? Actually we could have const0 */
 16.1617 ++  if (GET_CODE (cmp0) == CONST_INT)
 16.1618 ++    cmp0 = force_reg (mode, cmp0);
 16.1619 ++
 16.1620 ++  /* if the comparison is against an int not in legal range
 16.1621 ++     move it into a register */
 16.1622 ++  if (GET_CODE (cmp1) == CONST_INT)
 16.1623 ++    {
 16.1624 ++      HOST_WIDE_INT value = INTVAL (cmp1);
 16.1625 ++
 16.1626 ++      if (value < p_info->const_low || value > p_info->const_high)
 16.1627 ++	cmp1 = force_reg (mode, cmp1);
 16.1628 ++    }
 16.1629 ++
 16.1630 ++  /* Comparison to constants, may involve adding 1 to change a GT into GE.
 16.1631 ++     Comparison between two registers, may involve switching operands.  */
 16.1632 ++  if (GET_CODE (cmp1) == CONST_INT)
 16.1633 ++    {
 16.1634 ++      if (p_info->const_add != 0)
 16.1635 ++	{
 16.1636 ++	  HOST_WIDE_INT new = INTVAL (cmp1) + p_info->const_add;
 16.1637 ++
 16.1638 ++	  /* If modification of cmp1 caused overflow,
 16.1639 ++	     we would get the wrong answer if we follow the usual path;
 16.1640 ++	     thus, x > 0xffffffffU would turn into x > 0U.  */
 16.1641 ++	  if ((p_info->unsignedp
 16.1642 ++	       ? (unsigned HOST_WIDE_INT) new >
 16.1643 ++	       (unsigned HOST_WIDE_INT) INTVAL (cmp1)
 16.1644 ++	       : new > INTVAL (cmp1)) != (p_info->const_add > 0))
 16.1645 ++	    {
 16.1646 ++	      /* ??? This case can never happen with the current numbers,
 16.1647 ++	         but I am paranoid and would rather an abort than
 16.1648 ++	         a bug I will never find */
 16.1649 ++	      abort ();
 16.1650 ++	    }
 16.1651 ++	  else
 16.1652 ++	    cmp1 = GEN_INT (new);
 16.1653 ++	}
 16.1654 ++    }
 16.1655 ++
 16.1656 ++  else if (p_info->reverse_regs)
 16.1657 ++    {
 16.1658 ++      rtx temp = cmp0;
 16.1659 ++      cmp0 = cmp1;
 16.1660 ++      cmp1 = temp;
 16.1661 ++    }
 16.1662 ++
 16.1663 ++
 16.1664 ++
 16.1665 ++  if (branch_p)
 16.1666 ++    {
 16.1667 ++      if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
 16.1668 ++	{
 16.1669 ++	  rtx insn;
 16.1670 ++	  rtx cond = gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1);
 16.1671 ++	  rtx label = gen_rtx_LABEL_REF (VOIDmode, destination);
 16.1672 ++
 16.1673 ++	  insn = gen_rtx_SET (VOIDmode, pc_rtx,
 16.1674 ++			      gen_rtx_IF_THEN_ELSE (VOIDmode,
 16.1675 ++						    cond, label, pc_rtx));
 16.1676 ++	  emit_jump_insn (insn);
 16.1677 ++	}
 16.1678 ++      else
 16.1679 ++	{
 16.1680 ++	  rtx cond, label;
 16.1681 ++
 16.1682 ++	  result = gen_reg_rtx (mode);
 16.1683 ++
 16.1684 ++	  emit_move_insn (result,
 16.1685 ++			  gen_rtx (p_info->test_code_const, mode, cmp0,
 16.1686 ++				   cmp1));
 16.1687 ++
 16.1688 ++	  cond = gen_rtx (NE, mode, result, const0_rtx);
 16.1689 ++	  label = gen_rtx_LABEL_REF (VOIDmode, destination);
 16.1690 ++
 16.1691 ++	  emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
 16.1692 ++				       gen_rtx_IF_THEN_ELSE (VOIDmode,
 16.1693 ++							     cond,
 16.1694 ++							     label, pc_rtx)));
 16.1695 ++	}
 16.1696 ++    }
 16.1697 ++  else
 16.1698 ++    {
 16.1699 ++      if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
 16.1700 ++	{
 16.1701 ++	  emit_move_insn (result,
 16.1702 ++			  gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1));
 16.1703 ++	}
 16.1704 ++      else
 16.1705 ++	{
 16.1706 ++	  emit_move_insn (result,
 16.1707 ++			  gen_rtx (p_info->test_code_const, mode, cmp0,
 16.1708 ++				   cmp1));
 16.1709 ++	}
 16.1710 ++    }
 16.1711 ++
 16.1712 ++}
 16.1713 ++
 16.1714 ++
 16.1715 ++/* ??? For now conditional moves are only supported
 16.1716 ++   when the mode of the operands being compared are
 16.1717 ++   the same as the ones being moved */
 16.1718 ++
 16.1719 ++void
 16.1720 ++gen_conditional_move (rtx *operands, enum machine_mode mode)
 16.1721 ++{
 16.1722 ++  rtx insn, cond;
 16.1723 ++  rtx cmp_reg = gen_reg_rtx (mode);
 16.1724 ++  enum rtx_code cmp_code = GET_CODE (operands[1]);
 16.1725 ++  enum rtx_code move_code = EQ;
 16.1726 ++
 16.1727 ++  /* emit a comparison if it is not "simple".
 16.1728 ++     Simple comparisons are X eq 0 and X ne 0 */
 16.1729 ++  if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[1] == const0_rtx)
 16.1730 ++    {
 16.1731 ++      cmp_reg = branch_cmp[0];
 16.1732 ++      move_code = cmp_code;
 16.1733 ++    }
 16.1734 ++  else if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[0] == const0_rtx)
 16.1735 ++    {
 16.1736 ++      cmp_reg = branch_cmp[1];
 16.1737 ++      move_code = cmp_code == EQ ? NE : EQ;
 16.1738 ++    }
 16.1739 ++  else
 16.1740 ++    gen_int_relational (cmp_code, cmp_reg, branch_cmp[0], branch_cmp[1],
 16.1741 ++			NULL_RTX);
 16.1742 ++
 16.1743 ++  cond = gen_rtx (move_code, VOIDmode, cmp_reg, CONST0_RTX (mode));
 16.1744 ++  insn = gen_rtx_SET (mode, operands[0],
 16.1745 ++		      gen_rtx_IF_THEN_ELSE (mode,
 16.1746 ++					    cond, operands[2], operands[3]));
 16.1747 ++  emit_insn (insn);
 16.1748 ++}
 16.1749 ++
 16.1750 ++/*******************
 16.1751 ++ * Addressing Modes
 16.1752 ++ *******************/
 16.1753 ++
 16.1754 ++int
 16.1755 ++nios2_legitimate_address (rtx operand, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.1756 ++                          int strict)
 16.1757 ++{
 16.1758 ++  int ret_val = 0;
 16.1759 ++
 16.1760 ++  switch (GET_CODE (operand))
 16.1761 ++    {
 16.1762 ++      /* direct.  */
 16.1763 ++    case SYMBOL_REF:
 16.1764 ++      if (SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (operand))
 16.1765 ++        {
 16.1766 ++          ret_val = 1;
 16.1767 ++          break;
 16.1768 ++	}
 16.1769 ++      /* else, fall through */
 16.1770 ++    case LABEL_REF:
 16.1771 ++    case CONST_INT:
 16.1772 ++    case CONST:
 16.1773 ++    case CONST_DOUBLE:
 16.1774 ++      /* ??? In here I need to add gp addressing */
 16.1775 ++      ret_val = 0;
 16.1776 ++
 16.1777 ++      break;
 16.1778 ++
 16.1779 ++      /* Register indirect.  */
 16.1780 ++    case REG:
 16.1781 ++      ret_val = REG_OK_FOR_BASE_P2 (operand, strict);
 16.1782 ++      break;
 16.1783 ++
 16.1784 ++      /* Register indirect with displacement */
 16.1785 ++    case PLUS:
 16.1786 ++      {
 16.1787 ++	rtx op0 = XEXP (operand, 0);
 16.1788 ++	rtx op1 = XEXP (operand, 1);
 16.1789 ++
 16.1790 ++	if (REG_P (op0) && REG_P (op1))
 16.1791 ++	  ret_val = 0;
 16.1792 ++	else if (REG_P (op0) && CONSTANT_P (op1))
 16.1793 ++	  ret_val = REG_OK_FOR_BASE_P2 (op0, strict)
 16.1794 ++	    && SMALL_INT (INTVAL (op1));
 16.1795 ++	else if (REG_P (op1) && CONSTANT_P (op0))
 16.1796 ++	  ret_val = REG_OK_FOR_BASE_P2 (op1, strict)
 16.1797 ++	    && SMALL_INT (INTVAL (op0));
 16.1798 ++	else
 16.1799 ++	  ret_val = 0;
 16.1800 ++      }
 16.1801 ++      break;
 16.1802 ++
 16.1803 ++    default:
 16.1804 ++      ret_val = 0;
 16.1805 ++      break;
 16.1806 ++    }
 16.1807 ++
 16.1808 ++  return ret_val;
 16.1809 ++}
 16.1810 ++
 16.1811 ++/* Return true if EXP should be placed in the small data section.  */
 16.1812 ++
 16.1813 ++static bool
 16.1814 ++nios2_in_small_data_p (tree exp)
 16.1815 ++{
 16.1816 ++  /* We want to merge strings, so we never consider them small data.  */
 16.1817 ++  if (TREE_CODE (exp) == STRING_CST)
 16.1818 ++    return false;
 16.1819 ++
 16.1820 ++  if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
 16.1821 ++    {
 16.1822 ++      const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
 16.1823 ++      /* ??? these string names need moving into 
 16.1824 ++         an array in some header file */
 16.1825 ++      if (nios2_section_threshold > 0
 16.1826 ++          && (strcmp (section, ".sbss") == 0
 16.1827 ++	      || strncmp (section, ".sbss.", 6) == 0
 16.1828 ++	      || strcmp (section, ".sdata") == 0
 16.1829 ++	      || strncmp (section, ".sdata.", 7) == 0))
 16.1830 ++	return true;
 16.1831 ++    }
 16.1832 ++  else if (TREE_CODE (exp) == VAR_DECL)
 16.1833 ++    {
 16.1834 ++      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
 16.1835 ++
 16.1836 ++      /* If this is an incomplete type with size 0, then we can't put it
 16.1837 ++         in sdata because it might be too big when completed.  */
 16.1838 ++      if (size > 0 && size <= nios2_section_threshold)
 16.1839 ++	return true;
 16.1840 ++    }
 16.1841 ++
 16.1842 ++  return false;
 16.1843 ++}
 16.1844 ++
 16.1845 ++static void
 16.1846 ++nios2_encode_section_info (tree decl, rtx rtl, int first)
 16.1847 ++{
 16.1848 ++
 16.1849 ++  rtx symbol;
 16.1850 ++  int flags;
 16.1851 ++
 16.1852 ++  default_encode_section_info (decl, rtl, first);
 16.1853 ++  
 16.1854 ++  /* Careful not to prod global register variables.  */
 16.1855 ++  if (GET_CODE (rtl) != MEM)
 16.1856 ++    return;
 16.1857 ++  symbol = XEXP (rtl, 0);
 16.1858 ++  if (GET_CODE (symbol) != SYMBOL_REF)
 16.1859 ++    return;
 16.1860 ++
 16.1861 ++  flags = SYMBOL_REF_FLAGS (symbol);
 16.1862 ++    
 16.1863 ++  /* We don't want weak variables to be addressed with gp in case they end up with
 16.1864 ++     value 0 which is not within 2^15 of $gp */
 16.1865 ++  if (DECL_P (decl) && DECL_WEAK (decl))
 16.1866 ++    flags |= SYMBOL_FLAG_WEAK_DECL;
 16.1867 ++
 16.1868 ++  SYMBOL_REF_FLAGS (symbol) = flags;
 16.1869 ++}
 16.1870 ++
 16.1871 ++
 16.1872 ++static unsigned int
 16.1873 ++nios2_section_type_flags (tree decl, const char *name, int reloc)
 16.1874 ++{
 16.1875 ++  unsigned int flags;
 16.1876 ++
 16.1877 ++  flags = default_section_type_flags (decl, name, reloc);
 16.1878 ++
 16.1879 ++  /* ??? these string names need moving into an array in some header file */
 16.1880 ++  if (strcmp (name, ".sbss") == 0
 16.1881 ++      || strncmp (name, ".sbss.", 6) == 0
 16.1882 ++      || strcmp (name, ".sdata") == 0
 16.1883 ++      || strncmp (name, ".sdata.", 7) == 0)
 16.1884 ++    flags |= SECTION_SMALL;
 16.1885 ++
 16.1886 ++  return flags;
 16.1887 ++}
 16.1888 ++
 16.1889 ++
 16.1890 ++
 16.1891 ++
 16.1892 ++/*****************************************
 16.1893 ++ * Defining the Output Assembler Language
 16.1894 ++ *****************************************/
 16.1895 ++
 16.1896 ++/* -------------- *
 16.1897 ++ * Output of Data
 16.1898 ++ * -------------- */
 16.1899 ++
 16.1900 ++
 16.1901 ++/* -------------------------------- *
 16.1902 ++ * Output of Assembler Instructions
 16.1903 ++ * -------------------------------- */
 16.1904 ++
 16.1905 ++
 16.1906 ++/* print the operand OP to file stream
 16.1907 ++   FILE modified by LETTER. LETTER
 16.1908 ++   can be one of:
 16.1909 ++     i: print "i" if OP is an immediate, except 0
 16.1910 ++     o: print "io" if OP is volatile
 16.1911 ++
 16.1912 ++     z: for const0_rtx print $0 instead of 0
 16.1913 ++     H: for %hiadj
 16.1914 ++     L: for %lo
 16.1915 ++     U: for upper half of 32 bit value
 16.1916 ++ */
 16.1917 ++
 16.1918 ++void
 16.1919 ++nios2_print_operand (FILE *file, rtx op, int letter)
 16.1920 ++{
 16.1921 ++
 16.1922 ++  switch (letter)
 16.1923 ++    {
 16.1924 ++    case 'i':
 16.1925 ++      if (CONSTANT_P (op) && (op != const0_rtx))
 16.1926 ++	fprintf (file, "i");
 16.1927 ++      return;
 16.1928 ++
 16.1929 ++    case 'o':
 16.1930 ++      if (GET_CODE (op) == MEM
 16.1931 ++          && ((MEM_VOLATILE_P (op) && !TARGET_CACHE_VOLATILE)
 16.1932 ++              || TARGET_BYPASS_CACHE))
 16.1933 ++	fprintf (file, "io");
 16.1934 ++      return;
 16.1935 ++
 16.1936 ++    default:
 16.1937 ++      break;
 16.1938 ++    }
 16.1939 ++
 16.1940 ++  if (comparison_operator (op, VOIDmode))
 16.1941 ++    {
 16.1942 ++      if (letter == 0)
 16.1943 ++	{
 16.1944 ++	  fprintf (file, "%s", GET_RTX_NAME (GET_CODE (op)));
 16.1945 ++	  return;
 16.1946 ++	}
 16.1947 ++    }
 16.1948 ++
 16.1949 ++
 16.1950 ++  switch (GET_CODE (op))
 16.1951 ++    {
 16.1952 ++    case REG:
 16.1953 ++      if (letter == 0 || letter == 'z')
 16.1954 ++	{
 16.1955 ++	  fprintf (file, "%s", reg_names[REGNO (op)]);
 16.1956 ++	  return;
 16.1957 ++	}
 16.1958 ++
 16.1959 ++    case CONST_INT:
 16.1960 ++      if (INTVAL (op) == 0 && letter == 'z')
 16.1961 ++	{
 16.1962 ++	  fprintf (file, "zero");
 16.1963 ++	  return;
 16.1964 ++	}
 16.1965 ++      else if (letter == 'U')
 16.1966 ++	{
 16.1967 ++	  HOST_WIDE_INT val = INTVAL (op);
 16.1968 ++	  rtx new_op;
 16.1969 ++	  val = (val / 65536) & 0xFFFF;
 16.1970 ++	  new_op = GEN_INT (val);
 16.1971 ++	  output_addr_const (file, new_op);
 16.1972 ++	  return;
 16.1973 ++	}
 16.1974 ++
 16.1975 ++      /* else, fall through */
 16.1976 ++    case CONST:
 16.1977 ++    case LABEL_REF:
 16.1978 ++    case SYMBOL_REF:
 16.1979 ++    case CONST_DOUBLE:
 16.1980 ++      if (letter == 0 || letter == 'z')
 16.1981 ++	{
 16.1982 ++	  output_addr_const (file, op);
 16.1983 ++	  return;
 16.1984 ++	}
 16.1985 ++      else if (letter == 'H')
 16.1986 ++	{
 16.1987 ++	  fprintf (file, "%%hiadj(");
 16.1988 ++	  output_addr_const (file, op);
 16.1989 ++	  fprintf (file, ")");
 16.1990 ++	  return;
 16.1991 ++	}
 16.1992 ++      else if (letter == 'L')
 16.1993 ++	{
 16.1994 ++	  fprintf (file, "%%lo(");
 16.1995 ++	  output_addr_const (file, op);
 16.1996 ++	  fprintf (file, ")");
 16.1997 ++	  return;
 16.1998 ++	}
 16.1999 ++
 16.2000 ++
 16.2001 ++    case SUBREG:
 16.2002 ++    case MEM:
 16.2003 ++      if (letter == 0)
 16.2004 ++	{
 16.2005 ++	  output_address (op);
 16.2006 ++	  return;
 16.2007 ++	}
 16.2008 ++
 16.2009 ++    case CODE_LABEL:
 16.2010 ++      if (letter == 0)
 16.2011 ++	{
 16.2012 ++	  output_addr_const (file, op);
 16.2013 ++	  return;
 16.2014 ++	}
 16.2015 ++
 16.2016 ++    default:
 16.2017 ++      break;
 16.2018 ++    }
 16.2019 ++
 16.2020 ++  fprintf (stderr, "Missing way to print (%c) ", letter);
 16.2021 ++  debug_rtx (op);
 16.2022 ++  abort ();
 16.2023 ++}
 16.2024 ++
 16.2025 ++static int gprel_constant (rtx);
 16.2026 ++
 16.2027 ++static int
 16.2028 ++gprel_constant (rtx op)
 16.2029 ++{
 16.2030 ++  if (GET_CODE (op) == SYMBOL_REF
 16.2031 ++      && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (op))
 16.2032 ++    {
 16.2033 ++      return 1;
 16.2034 ++    }
 16.2035 ++  else if (GET_CODE (op) == CONST
 16.2036 ++           && GET_CODE (XEXP (op, 0)) == PLUS)
 16.2037 ++    {
 16.2038 ++      return gprel_constant (XEXP (XEXP (op, 0), 0));
 16.2039 ++    }
 16.2040 ++  else
 16.2041 ++    {
 16.2042 ++      return 0;
 16.2043 ++    }
 16.2044 ++}
 16.2045 ++
 16.2046 ++void
 16.2047 ++nios2_print_operand_address (FILE *file, rtx op)
 16.2048 ++{
 16.2049 ++  switch (GET_CODE (op))
 16.2050 ++    {
 16.2051 ++    case CONST:
 16.2052 ++    case CONST_INT:
 16.2053 ++    case LABEL_REF:
 16.2054 ++    case CONST_DOUBLE:
 16.2055 ++    case SYMBOL_REF:
 16.2056 ++      if (gprel_constant (op))
 16.2057 ++        {
 16.2058 ++          fprintf (file, "%%gprel(");
 16.2059 ++          output_addr_const (file, op);
 16.2060 ++          fprintf (file, ")(%s)", reg_names[GP_REGNO]);
 16.2061 ++          return;
 16.2062 ++        }
 16.2063 ++
 16.2064 ++      break;
 16.2065 ++
 16.2066 ++    case PLUS:
 16.2067 ++      {
 16.2068 ++	rtx op0 = XEXP (op, 0);
 16.2069 ++	rtx op1 = XEXP (op, 1);
 16.2070 ++
 16.2071 ++	if (REG_P (op0) && CONSTANT_P (op1))
 16.2072 ++	  {
 16.2073 ++	    output_addr_const (file, op1);
 16.2074 ++	    fprintf (file, "(%s)", reg_names[REGNO (op0)]);
 16.2075 ++	    return;
 16.2076 ++	  }
 16.2077 ++	else if (REG_P (op1) && CONSTANT_P (op0))
 16.2078 ++	  {
 16.2079 ++	    output_addr_const (file, op0);
 16.2080 ++	    fprintf (file, "(%s)", reg_names[REGNO (op1)]);
 16.2081 ++	    return;
 16.2082 ++	  }
 16.2083 ++      }
 16.2084 ++      break;
 16.2085 ++
 16.2086 ++    case REG:
 16.2087 ++      fprintf (file, "0(%s)", reg_names[REGNO (op)]);
 16.2088 ++      return;
 16.2089 ++
 16.2090 ++    case MEM:
 16.2091 ++      {
 16.2092 ++	rtx base = XEXP (op, 0);
 16.2093 ++	PRINT_OPERAND_ADDRESS (file, base);
 16.2094 ++	return;
 16.2095 ++      }
 16.2096 ++    default:
 16.2097 ++      break;
 16.2098 ++    }
 16.2099 ++
 16.2100 ++  fprintf (stderr, "Missing way to print address\n");
 16.2101 ++  debug_rtx (op);
 16.2102 ++  abort ();
 16.2103 ++}
 16.2104 ++
 16.2105 ++
 16.2106 ++
 16.2107 ++
 16.2108 ++
 16.2109 ++/****************************
 16.2110 ++ * Predicates
 16.2111 ++ ****************************/
 16.2112 ++
 16.2113 ++int
 16.2114 ++arith_operand (rtx op, enum machine_mode mode)
 16.2115 ++{
 16.2116 ++  if (GET_CODE (op) == CONST_INT && SMALL_INT (INTVAL (op)))
 16.2117 ++    return 1;
 16.2118 ++
 16.2119 ++  return register_operand (op, mode);
 16.2120 ++}
 16.2121 ++
 16.2122 ++int
 16.2123 ++uns_arith_operand (rtx op, enum machine_mode mode)
 16.2124 ++{
 16.2125 ++  if (GET_CODE (op) == CONST_INT && SMALL_INT_UNSIGNED (INTVAL (op)))
 16.2126 ++    return 1;
 16.2127 ++
 16.2128 ++  return register_operand (op, mode);
 16.2129 ++}
 16.2130 ++
 16.2131 ++int
 16.2132 ++logical_operand (rtx op, enum machine_mode mode)
 16.2133 ++{
 16.2134 ++  if (GET_CODE (op) == CONST_INT
 16.2135 ++      && (SMALL_INT_UNSIGNED (INTVAL (op)) || UPPER16_INT (INTVAL (op))))
 16.2136 ++    return 1;
 16.2137 ++
 16.2138 ++  return register_operand (op, mode);
 16.2139 ++}
 16.2140 ++
 16.2141 ++int
 16.2142 ++shift_operand (rtx op, enum machine_mode mode)
 16.2143 ++{
 16.2144 ++  if (GET_CODE (op) == CONST_INT && SHIFT_INT (INTVAL (op)))
 16.2145 ++    return 1;
 16.2146 ++
 16.2147 ++  return register_operand (op, mode);
 16.2148 ++}
 16.2149 ++
 16.2150 ++int
 16.2151 ++rdwrctl_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
 16.2152 ++{
 16.2153 ++  return GET_CODE (op) == CONST_INT && RDWRCTL_INT (INTVAL (op));
 16.2154 ++}
 16.2155 ++
 16.2156 ++/* Return truth value of whether OP is a register or the constant 0. */
 16.2157 ++
 16.2158 ++int
 16.2159 ++reg_or_0_operand (rtx op, enum machine_mode mode)
 16.2160 ++{
 16.2161 ++  switch (GET_CODE (op))
 16.2162 ++    {
 16.2163 ++    case CONST_INT:
 16.2164 ++      return INTVAL (op) == 0;
 16.2165 ++
 16.2166 ++    case CONST_DOUBLE:
 16.2167 ++      return op == CONST0_RTX (mode);
 16.2168 ++
 16.2169 ++    default:
 16.2170 ++      break;
 16.2171 ++    }
 16.2172 ++
 16.2173 ++  return register_operand (op, mode);
 16.2174 ++}
 16.2175 ++
 16.2176 ++
 16.2177 ++int
 16.2178 ++equality_op (rtx op, enum machine_mode mode)
 16.2179 ++{
 16.2180 ++  if (mode != GET_MODE (op))
 16.2181 ++    return 0;
 16.2182 ++
 16.2183 ++  return GET_CODE (op) == EQ || GET_CODE (op) == NE;
 16.2184 ++}
 16.2185 ++
 16.2186 ++int
 16.2187 ++custom_insn_opcode (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
 16.2188 ++{
 16.2189 ++  return GET_CODE (op) == CONST_INT && CUSTOM_INSN_OPCODE (INTVAL (op));
 16.2190 ++}
 16.2191 ++
 16.2192 ++
 16.2193 ++
 16.2194 ++
 16.2195 ++
 16.2196 ++
 16.2197 ++
 16.2198 ++/*****************************************************************************
 16.2199 ++**
 16.2200 ++** instruction scheduler
 16.2201 ++**
 16.2202 ++*****************************************************************************/
 16.2203 ++static int
 16.2204 ++nios2_use_dfa_pipeline_interface ()
 16.2205 ++{
 16.2206 ++  return 1;
 16.2207 ++}
 16.2208 ++
 16.2209 ++
 16.2210 ++static int
 16.2211 ++nios2_issue_rate ()
 16.2212 ++{
 16.2213 ++#ifdef MAX_DFA_ISSUE_RATE
 16.2214 ++  return MAX_DFA_ISSUE_RATE;
 16.2215 ++#else
 16.2216 ++  return 1;
 16.2217 ++#endif
 16.2218 ++}
 16.2219 ++
 16.2220 ++
 16.2221 ++const char *
 16.2222 ++asm_output_opcode (FILE *file ATTRIBUTE_UNUSED, 
 16.2223 ++                   const char *ptr ATTRIBUTE_UNUSED)
 16.2224 ++{
 16.2225 ++  const char *p;
 16.2226 ++
 16.2227 ++  p = ptr;
 16.2228 ++  return ptr;
 16.2229 ++}
 16.2230 ++
 16.2231 ++
 16.2232 ++
 16.2233 ++/*****************************************************************************
 16.2234 ++**
 16.2235 ++** function arguments
 16.2236 ++**
 16.2237 ++*****************************************************************************/
 16.2238 ++
 16.2239 ++void
 16.2240 ++init_cumulative_args (CUMULATIVE_ARGS *cum, 
 16.2241 ++                      tree fntype ATTRIBUTE_UNUSED, 
 16.2242 ++                      rtx libname ATTRIBUTE_UNUSED, 
 16.2243 ++                      tree fndecl ATTRIBUTE_UNUSED, 
 16.2244 ++                      int n_named_args ATTRIBUTE_UNUSED)
 16.2245 ++{
 16.2246 ++  cum->regs_used = 0;
 16.2247 ++}
 16.2248 ++
 16.2249 ++
 16.2250 ++/* Update the data in CUM to advance over an argument
 16.2251 ++   of mode MODE and data type TYPE.
 16.2252 ++   (TYPE is null for libcalls where that information may not be available.)  */
 16.2253 ++
 16.2254 ++void
 16.2255 ++function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, 
 16.2256 ++                      tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
 16.2257 ++{
 16.2258 ++  HOST_WIDE_INT param_size;
 16.2259 ++
 16.2260 ++  if (mode == BLKmode)
 16.2261 ++    {
 16.2262 ++      param_size = int_size_in_bytes (type);
 16.2263 ++      if (param_size < 0)
 16.2264 ++	internal_error
 16.2265 ++	  ("Do not know how to handle large structs or variable length types");
 16.2266 ++    }
 16.2267 ++  else
 16.2268 ++    {
 16.2269 ++      param_size = GET_MODE_SIZE (mode);
 16.2270 ++    }
 16.2271 ++
 16.2272 ++  /* convert to words (round up) */
 16.2273 ++  param_size = (3 + param_size) / 4;
 16.2274 ++
 16.2275 ++  if (cum->regs_used + param_size > NUM_ARG_REGS)
 16.2276 ++    {
 16.2277 ++      cum->regs_used = NUM_ARG_REGS;
 16.2278 ++    }
 16.2279 ++  else
 16.2280 ++    {
 16.2281 ++      cum->regs_used += param_size;
 16.2282 ++    }
 16.2283 ++
 16.2284 ++  return;
 16.2285 ++}
 16.2286 ++
 16.2287 ++/* Define where to put the arguments to a function.  Value is zero to
 16.2288 ++   push the argument on the stack, or a hard register in which to
 16.2289 ++   store the argument.
 16.2290 ++
 16.2291 ++   MODE is the argument's machine mode.
 16.2292 ++   TYPE is the data type of the argument (as a tree).
 16.2293 ++   This is null for libcalls where that information may
 16.2294 ++   not be available.
 16.2295 ++   CUM is a variable of type CUMULATIVE_ARGS which gives info about
 16.2296 ++   the preceding args and about the function being called.
 16.2297 ++   NAMED is nonzero if this argument is a named parameter
 16.2298 ++   (otherwise it is an extra parameter matching an ellipsis).  */
 16.2299 ++rtx
 16.2300 ++function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode, 
 16.2301 ++              tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
 16.2302 ++{
 16.2303 ++  rtx return_rtx = NULL_RTX;
 16.2304 ++
 16.2305 ++  if (cum->regs_used < NUM_ARG_REGS)
 16.2306 ++    {
 16.2307 ++      return_rtx = gen_rtx_REG (mode, FIRST_ARG_REGNO + cum->regs_used);
 16.2308 ++    }
 16.2309 ++
 16.2310 ++  return return_rtx;
 16.2311 ++}
 16.2312 ++
 16.2313 ++int
 16.2314 ++function_arg_partial_nregs (const CUMULATIVE_ARGS *cum,
 16.2315 ++                            enum machine_mode mode, tree type, 
 16.2316 ++                            int named ATTRIBUTE_UNUSED)
 16.2317 ++{
 16.2318 ++  HOST_WIDE_INT param_size;
 16.2319 ++
 16.2320 ++  if (mode == BLKmode)
 16.2321 ++    {
 16.2322 ++      param_size = int_size_in_bytes (type);
 16.2323 ++      if (param_size < 0)
 16.2324 ++	internal_error
 16.2325 ++	  ("Do not know how to handle large structs or variable length types");
 16.2326 ++    }
 16.2327 ++  else
 16.2328 ++    {
 16.2329 ++      param_size = GET_MODE_SIZE (mode);
 16.2330 ++    }
 16.2331 ++
 16.2332 ++  /* convert to words (round up) */
 16.2333 ++  param_size = (3 + param_size) / 4;
 16.2334 ++
 16.2335 ++  if (cum->regs_used < NUM_ARG_REGS
 16.2336 ++      && cum->regs_used + param_size > NUM_ARG_REGS)
 16.2337 ++    {
 16.2338 ++      return NUM_ARG_REGS - cum->regs_used;
 16.2339 ++    }
 16.2340 ++  else
 16.2341 ++    {
 16.2342 ++      return 0;
 16.2343 ++    }
 16.2344 ++}
 16.2345 ++
 16.2346 ++
 16.2347 ++int
 16.2348 ++nios2_return_in_memory (tree type)
 16.2349 ++{
 16.2350 ++  int res = ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
 16.2351 ++  	     || (int_size_in_bytes (type) == -1));
 16.2352 ++
 16.2353 ++  return res;
 16.2354 ++}
 16.2355 ++
 16.2356 ++/* ??? It may be possible to eliminate the copyback and implement
 16.2357 ++       my own va_arg type, but that is more work for now. */
 16.2358 ++int
 16.2359 ++nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *cum, 
 16.2360 ++                              enum machine_mode mode, tree type, 
 16.2361 ++                              int no_rtl)
 16.2362 ++{
 16.2363 ++  CUMULATIVE_ARGS local_cum;
 16.2364 ++  int regs_to_push;
 16.2365 ++
 16.2366 ++  local_cum = *cum;
 16.2367 ++  FUNCTION_ARG_ADVANCE (local_cum, mode, type, 1);
 16.2368 ++
 16.2369 ++  regs_to_push = NUM_ARG_REGS - local_cum.regs_used;
 16.2370 ++
 16.2371 ++  if (!no_rtl)
 16.2372 ++    {
 16.2373 ++      if (regs_to_push > 0)
 16.2374 ++	{
 16.2375 ++	  rtx ptr, mem;
 16.2376 ++
 16.2377 ++	  ptr = virtual_incoming_args_rtx;
 16.2378 ++	  mem = gen_rtx_MEM (BLKmode, ptr);
 16.2379 ++
 16.2380 ++	  /* va_arg is an array access in this case, which causes
 16.2381 ++	     it to get MEM_IN_STRUCT_P set.  We must set it here
 16.2382 ++	     so that the insn scheduler won't assume that these
 16.2383 ++	     stores can't possibly overlap with the va_arg loads.  */
 16.2384 ++	  MEM_SET_IN_STRUCT_P (mem, 1);
 16.2385 ++
 16.2386 ++	  emit_insn (gen_blockage ());
 16.2387 ++	  move_block_from_reg (local_cum.regs_used + FIRST_ARG_REGNO, mem,
 16.2388 ++			       regs_to_push);
 16.2389 ++	  emit_insn (gen_blockage ());
 16.2390 ++	}
 16.2391 ++    }
 16.2392 ++
 16.2393 ++  return regs_to_push * UNITS_PER_WORD;
 16.2394 ++
 16.2395 ++}
 16.2396 ++
 16.2397 ++
 16.2398 ++
 16.2399 ++/*****************************************************************************
 16.2400 ++**
 16.2401 ++** builtins
 16.2402 ++**
 16.2403 ++** This method for handling builtins is from CSP where _many_ more types of
 16.2404 ++** expanders have already been written. Check there first before writing
 16.2405 ++** new ones.
 16.2406 ++**
 16.2407 ++*****************************************************************************/
 16.2408 ++
 16.2409 ++enum nios2_builtins
 16.2410 ++{
 16.2411 ++  NIOS2_BUILTIN_LDBIO,
 16.2412 ++  NIOS2_BUILTIN_LDBUIO,
 16.2413 ++  NIOS2_BUILTIN_LDHIO,
 16.2414 ++  NIOS2_BUILTIN_LDHUIO,
 16.2415 ++  NIOS2_BUILTIN_LDWIO,
 16.2416 ++  NIOS2_BUILTIN_STBIO,
 16.2417 ++  NIOS2_BUILTIN_STHIO,
 16.2418 ++  NIOS2_BUILTIN_STWIO,
 16.2419 ++  NIOS2_BUILTIN_SYNC,
 16.2420 ++  NIOS2_BUILTIN_RDCTL,
 16.2421 ++  NIOS2_BUILTIN_WRCTL,
 16.2422 ++
 16.2423 ++  NIOS2_BUILTIN_CUSTOM_N,
 16.2424 ++  NIOS2_BUILTIN_CUSTOM_NI,
 16.2425 ++  NIOS2_BUILTIN_CUSTOM_NF,
 16.2426 ++  NIOS2_BUILTIN_CUSTOM_NP,
 16.2427 ++  NIOS2_BUILTIN_CUSTOM_NII,
 16.2428 ++  NIOS2_BUILTIN_CUSTOM_NIF,
 16.2429 ++  NIOS2_BUILTIN_CUSTOM_NIP,
 16.2430 ++  NIOS2_BUILTIN_CUSTOM_NFI,
 16.2431 ++  NIOS2_BUILTIN_CUSTOM_NFF,
 16.2432 ++  NIOS2_BUILTIN_CUSTOM_NFP,
 16.2433 ++  NIOS2_BUILTIN_CUSTOM_NPI,
 16.2434 ++  NIOS2_BUILTIN_CUSTOM_NPF,
 16.2435 ++  NIOS2_BUILTIN_CUSTOM_NPP,
 16.2436 ++  NIOS2_BUILTIN_CUSTOM_IN,
 16.2437 ++  NIOS2_BUILTIN_CUSTOM_INI,
 16.2438 ++  NIOS2_BUILTIN_CUSTOM_INF,
 16.2439 ++  NIOS2_BUILTIN_CUSTOM_INP,
 16.2440 ++  NIOS2_BUILTIN_CUSTOM_INII,
 16.2441 ++  NIOS2_BUILTIN_CUSTOM_INIF,
 16.2442 ++  NIOS2_BUILTIN_CUSTOM_INIP,
 16.2443 ++  NIOS2_BUILTIN_CUSTOM_INFI,
 16.2444 ++  NIOS2_BUILTIN_CUSTOM_INFF,
 16.2445 ++  NIOS2_BUILTIN_CUSTOM_INFP,
 16.2446 ++  NIOS2_BUILTIN_CUSTOM_INPI,
 16.2447 ++  NIOS2_BUILTIN_CUSTOM_INPF,
 16.2448 ++  NIOS2_BUILTIN_CUSTOM_INPP,
 16.2449 ++  NIOS2_BUILTIN_CUSTOM_FN,
 16.2450 ++  NIOS2_BUILTIN_CUSTOM_FNI,
 16.2451 ++  NIOS2_BUILTIN_CUSTOM_FNF,
 16.2452 ++  NIOS2_BUILTIN_CUSTOM_FNP,
 16.2453 ++  NIOS2_BUILTIN_CUSTOM_FNII,
 16.2454 ++  NIOS2_BUILTIN_CUSTOM_FNIF,
 16.2455 ++  NIOS2_BUILTIN_CUSTOM_FNIP,
 16.2456 ++  NIOS2_BUILTIN_CUSTOM_FNFI,
 16.2457 ++  NIOS2_BUILTIN_CUSTOM_FNFF,
 16.2458 ++  NIOS2_BUILTIN_CUSTOM_FNFP,
 16.2459 ++  NIOS2_BUILTIN_CUSTOM_FNPI,
 16.2460 ++  NIOS2_BUILTIN_CUSTOM_FNPF,
 16.2461 ++  NIOS2_BUILTIN_CUSTOM_FNPP,
 16.2462 ++  NIOS2_BUILTIN_CUSTOM_PN,
 16.2463 ++  NIOS2_BUILTIN_CUSTOM_PNI,
 16.2464 ++  NIOS2_BUILTIN_CUSTOM_PNF,
 16.2465 ++  NIOS2_BUILTIN_CUSTOM_PNP,
 16.2466 ++  NIOS2_BUILTIN_CUSTOM_PNII,
 16.2467 ++  NIOS2_BUILTIN_CUSTOM_PNIF,
 16.2468 ++  NIOS2_BUILTIN_CUSTOM_PNIP,
 16.2469 ++  NIOS2_BUILTIN_CUSTOM_PNFI,
 16.2470 ++  NIOS2_BUILTIN_CUSTOM_PNFF,
 16.2471 ++  NIOS2_BUILTIN_CUSTOM_PNFP,
 16.2472 ++  NIOS2_BUILTIN_CUSTOM_PNPI,
 16.2473 ++  NIOS2_BUILTIN_CUSTOM_PNPF,
 16.2474 ++  NIOS2_BUILTIN_CUSTOM_PNPP,
 16.2475 ++
 16.2476 ++
 16.2477 ++  LIM_NIOS2_BUILTINS
 16.2478 ++};
 16.2479 ++
 16.2480 ++struct builtin_description
 16.2481 ++{
 16.2482 ++    const enum insn_code icode;
 16.2483 ++    const char *const name;
 16.2484 ++    const enum nios2_builtins code;
 16.2485 ++    const tree *type;
 16.2486 ++    rtx (* expander) PARAMS ((const struct builtin_description *,
 16.2487 ++                              tree, rtx, rtx, enum machine_mode, int));
 16.2488 ++};
 16.2489 ++
 16.2490 ++static rtx nios2_expand_STXIO (const struct builtin_description *, 
 16.2491 ++                               tree, rtx, rtx, enum machine_mode, int);
 16.2492 ++static rtx nios2_expand_LDXIO (const struct builtin_description *, 
 16.2493 ++                               tree, rtx, rtx, enum machine_mode, int);
 16.2494 ++static rtx nios2_expand_sync (const struct builtin_description *, 
 16.2495 ++                              tree, rtx, rtx, enum machine_mode, int);
 16.2496 ++static rtx nios2_expand_rdctl (const struct builtin_description *, 
 16.2497 ++                               tree, rtx, rtx, enum machine_mode, int);
 16.2498 ++static rtx nios2_expand_wrctl (const struct builtin_description *, 
 16.2499 ++                               tree, rtx, rtx, enum machine_mode, int);
 16.2500 ++
 16.2501 ++static rtx nios2_expand_custom_n (const struct builtin_description *, 
 16.2502 ++                                  tree, rtx, rtx, enum machine_mode, int);
 16.2503 ++static rtx nios2_expand_custom_Xn (const struct builtin_description *, 
 16.2504 ++                                   tree, rtx, rtx, enum machine_mode, int);
 16.2505 ++static rtx nios2_expand_custom_nX (const struct builtin_description *, 
 16.2506 ++                                   tree, rtx, rtx, enum machine_mode, int);
 16.2507 ++static rtx nios2_expand_custom_XnX (const struct builtin_description *, 
 16.2508 ++                                    tree, rtx, rtx, enum machine_mode, int);
 16.2509 ++static rtx nios2_expand_custom_nXX (const struct builtin_description *, 
 16.2510 ++                                    tree, rtx, rtx, enum machine_mode, int);
 16.2511 ++static rtx nios2_expand_custom_XnXX (const struct builtin_description *, 
 16.2512 ++                                     tree, rtx, rtx, enum machine_mode, int);
 16.2513 ++
 16.2514 ++static tree endlink;
 16.2515 ++
 16.2516 ++/* int fn (volatile const void *)
 16.2517 ++ */
 16.2518 ++static tree int_ftype_volatile_const_void_p;
 16.2519 ++
 16.2520 ++/* int fn (int)
 16.2521 ++ */
 16.2522 ++static tree int_ftype_int;
 16.2523 ++
 16.2524 ++/* void fn (int, int)
 16.2525 ++ */
 16.2526 ++static tree void_ftype_int_int;
 16.2527 ++
 16.2528 ++/* void fn (volatile void *, int)
 16.2529 ++ */
 16.2530 ++static tree void_ftype_volatile_void_p_int;
 16.2531 ++
 16.2532 ++/* void fn (void)
 16.2533 ++ */
 16.2534 ++static tree void_ftype_void;
 16.2535 ++
 16.2536 ++static tree custom_n;
 16.2537 ++static tree custom_ni;
 16.2538 ++static tree custom_nf;
 16.2539 ++static tree custom_np;
 16.2540 ++static tree custom_nii;
 16.2541 ++static tree custom_nif;
 16.2542 ++static tree custom_nip;
 16.2543 ++static tree custom_nfi;
 16.2544 ++static tree custom_nff;
 16.2545 ++static tree custom_nfp;
 16.2546 ++static tree custom_npi;
 16.2547 ++static tree custom_npf;
 16.2548 ++static tree custom_npp;
 16.2549 ++static tree custom_in;
 16.2550 ++static tree custom_ini;
 16.2551 ++static tree custom_inf;
 16.2552 ++static tree custom_inp;
 16.2553 ++static tree custom_inii;
 16.2554 ++static tree custom_inif;
 16.2555 ++static tree custom_inip;
 16.2556 ++static tree custom_infi;
 16.2557 ++static tree custom_inff;
 16.2558 ++static tree custom_infp;
 16.2559 ++static tree custom_inpi;
 16.2560 ++static tree custom_inpf;
 16.2561 ++static tree custom_inpp;
 16.2562 ++static tree custom_fn;
 16.2563 ++static tree custom_fni;
 16.2564 ++static tree custom_fnf;
 16.2565 ++static tree custom_fnp;
 16.2566 ++static tree custom_fnii;
 16.2567 ++static tree custom_fnif;
 16.2568 ++static tree custom_fnip;
 16.2569 ++static tree custom_fnfi;
 16.2570 ++static tree custom_fnff;
 16.2571 ++static tree custom_fnfp;
 16.2572 ++static tree custom_fnpi;
 16.2573 ++static tree custom_fnpf;
 16.2574 ++static tree custom_fnpp;
 16.2575 ++static tree custom_pn;
 16.2576 ++static tree custom_pni;
 16.2577 ++static tree custom_pnf;
 16.2578 ++static tree custom_pnp;
 16.2579 ++static tree custom_pnii;
 16.2580 ++static tree custom_pnif;
 16.2581 ++static tree custom_pnip;
 16.2582 ++static tree custom_pnfi;
 16.2583 ++static tree custom_pnff;
 16.2584 ++static tree custom_pnfp;
 16.2585 ++static tree custom_pnpi;
 16.2586 ++static tree custom_pnpf;
 16.2587 ++static tree custom_pnpp;
 16.2588 ++
 16.2589 ++
 16.2590 ++static const struct builtin_description bdesc[] = {
 16.2591 ++    {CODE_FOR_ldbio, "__builtin_ldbio", NIOS2_BUILTIN_LDBIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
 16.2592 ++    {CODE_FOR_ldbuio, "__builtin_ldbuio", NIOS2_BUILTIN_LDBUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
 16.2593 ++    {CODE_FOR_ldhio, "__builtin_ldhio", NIOS2_BUILTIN_LDHIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
 16.2594 ++    {CODE_FOR_ldhuio, "__builtin_ldhuio", NIOS2_BUILTIN_LDHUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
 16.2595 ++    {CODE_FOR_ldwio, "__builtin_ldwio", NIOS2_BUILTIN_LDWIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
 16.2596 ++
 16.2597 ++    {CODE_FOR_stbio, "__builtin_stbio", NIOS2_BUILTIN_STBIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
 16.2598 ++    {CODE_FOR_sthio, "__builtin_sthio", NIOS2_BUILTIN_STHIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
 16.2599 ++    {CODE_FOR_stwio, "__builtin_stwio", NIOS2_BUILTIN_STWIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
 16.2600 ++
 16.2601 ++    {CODE_FOR_sync, "__builtin_sync", NIOS2_BUILTIN_SYNC, &void_ftype_void, nios2_expand_sync},
 16.2602 ++    {CODE_FOR_rdctl, "__builtin_rdctl", NIOS2_BUILTIN_RDCTL, &int_ftype_int, nios2_expand_rdctl},
 16.2603 ++    {CODE_FOR_wrctl, "__builtin_wrctl", NIOS2_BUILTIN_WRCTL, &void_ftype_int_int, nios2_expand_wrctl},
 16.2604 ++
 16.2605 ++    {CODE_FOR_custom_n, "__builtin_custom_n", NIOS2_BUILTIN_CUSTOM_N, &custom_n, nios2_expand_custom_n},
 16.2606 ++    {CODE_FOR_custom_ni, "__builtin_custom_ni", NIOS2_BUILTIN_CUSTOM_NI, &custom_ni, nios2_expand_custom_nX},
 16.2607 ++    {CODE_FOR_custom_nf, "__builtin_custom_nf", NIOS2_BUILTIN_CUSTOM_NF, &custom_nf, nios2_expand_custom_nX},
 16.2608 ++    {CODE_FOR_custom_np, "__builtin_custom_np", NIOS2_BUILTIN_CUSTOM_NP, &custom_np, nios2_expand_custom_nX},
 16.2609 ++    {CODE_FOR_custom_nii, "__builtin_custom_nii", NIOS2_BUILTIN_CUSTOM_NII, &custom_nii, nios2_expand_custom_nXX},
 16.2610 ++    {CODE_FOR_custom_nif, "__builtin_custom_nif", NIOS2_BUILTIN_CUSTOM_NIF, &custom_nif, nios2_expand_custom_nXX},
 16.2611 ++    {CODE_FOR_custom_nip, "__builtin_custom_nip", NIOS2_BUILTIN_CUSTOM_NIP, &custom_nip, nios2_expand_custom_nXX},
 16.2612 ++    {CODE_FOR_custom_nfi, "__builtin_custom_nfi", NIOS2_BUILTIN_CUSTOM_NFI, &custom_nfi, nios2_expand_custom_nXX},
 16.2613 ++    {CODE_FOR_custom_nff, "__builtin_custom_nff", NIOS2_BUILTIN_CUSTOM_NFF, &custom_nff, nios2_expand_custom_nXX},
 16.2614 ++    {CODE_FOR_custom_nfp, "__builtin_custom_nfp", NIOS2_BUILTIN_CUSTOM_NFP, &custom_nfp, nios2_expand_custom_nXX},
 16.2615 ++    {CODE_FOR_custom_npi, "__builtin_custom_npi", NIOS2_BUILTIN_CUSTOM_NPI, &custom_npi, nios2_expand_custom_nXX},
 16.2616 ++    {CODE_FOR_custom_npf, "__builtin_custom_npf", NIOS2_BUILTIN_CUSTOM_NPF, &custom_npf, nios2_expand_custom_nXX},
 16.2617 ++    {CODE_FOR_custom_npp, "__builtin_custom_npp", NIOS2_BUILTIN_CUSTOM_NPP, &custom_npp, nios2_expand_custom_nXX},
 16.2618 ++    {CODE_FOR_custom_in, "__builtin_custom_in", NIOS2_BUILTIN_CUSTOM_IN, &custom_in, nios2_expand_custom_Xn},
 16.2619 ++    {CODE_FOR_custom_ini, "__builtin_custom_ini", NIOS2_BUILTIN_CUSTOM_INI, &custom_ini, nios2_expand_custom_XnX},
 16.2620 ++    {CODE_FOR_custom_inf, "__builtin_custom_inf", NIOS2_BUILTIN_CUSTOM_INF, &custom_inf, nios2_expand_custom_XnX},
 16.2621 ++    {CODE_FOR_custom_inp, "__builtin_custom_inp", NIOS2_BUILTIN_CUSTOM_INP, &custom_inp, nios2_expand_custom_XnX},
 16.2622 ++    {CODE_FOR_custom_inii, "__builtin_custom_inii", NIOS2_BUILTIN_CUSTOM_INII, &custom_inii, nios2_expand_custom_XnXX},
 16.2623 ++    {CODE_FOR_custom_inif, "__builtin_custom_inif", NIOS2_BUILTIN_CUSTOM_INIF, &custom_inif, nios2_expand_custom_XnXX},
 16.2624 ++    {CODE_FOR_custom_inip, "__builtin_custom_inip", NIOS2_BUILTIN_CUSTOM_INIP, &custom_inip, nios2_expand_custom_XnXX},
 16.2625 ++    {CODE_FOR_custom_infi, "__builtin_custom_infi", NIOS2_BUILTIN_CUSTOM_INFI, &custom_infi, nios2_expand_custom_XnXX},
 16.2626 ++    {CODE_FOR_custom_inff, "__builtin_custom_inff", NIOS2_BUILTIN_CUSTOM_INFF, &custom_inff, nios2_expand_custom_XnXX},
 16.2627 ++    {CODE_FOR_custom_infp, "__builtin_custom_infp", NIOS2_BUILTIN_CUSTOM_INFP, &custom_infp, nios2_expand_custom_XnXX},
 16.2628 ++    {CODE_FOR_custom_inpi, "__builtin_custom_inpi", NIOS2_BUILTIN_CUSTOM_INPI, &custom_inpi, nios2_expand_custom_XnXX},
 16.2629 ++    {CODE_FOR_custom_inpf, "__builtin_custom_inpf", NIOS2_BUILTIN_CUSTOM_INPF, &custom_inpf, nios2_expand_custom_XnXX},
 16.2630 ++    {CODE_FOR_custom_inpp, "__builtin_custom_inpp", NIOS2_BUILTIN_CUSTOM_INPP, &custom_inpp, nios2_expand_custom_XnXX},
 16.2631 ++    {CODE_FOR_custom_fn, "__builtin_custom_fn", NIOS2_BUILTIN_CUSTOM_FN, &custom_fn, nios2_expand_custom_Xn},
 16.2632 ++    {CODE_FOR_custom_fni, "__builtin_custom_fni", NIOS2_BUILTIN_CUSTOM_FNI, &custom_fni, nios2_expand_custom_XnX},
 16.2633 ++    {CODE_FOR_custom_fnf, "__builtin_custom_fnf", NIOS2_BUILTIN_CUSTOM_FNF, &custom_fnf, nios2_expand_custom_XnX},
 16.2634 ++    {CODE_FOR_custom_fnp, "__builtin_custom_fnp", NIOS2_BUILTIN_CUSTOM_FNP, &custom_fnp, nios2_expand_custom_XnX},
 16.2635 ++    {CODE_FOR_custom_fnii, "__builtin_custom_fnii", NIOS2_BUILTIN_CUSTOM_FNII, &custom_fnii, nios2_expand_custom_XnXX},
 16.2636 ++    {CODE_FOR_custom_fnif, "__builtin_custom_fnif", NIOS2_BUILTIN_CUSTOM_FNIF, &custom_fnif, nios2_expand_custom_XnXX},
 16.2637 ++    {CODE_FOR_custom_fnip, "__builtin_custom_fnip", NIOS2_BUILTIN_CUSTOM_FNIP, &custom_fnip, nios2_expand_custom_XnXX},
 16.2638 ++    {CODE_FOR_custom_fnfi, "__builtin_custom_fnfi", NIOS2_BUILTIN_CUSTOM_FNFI, &custom_fnfi, nios2_expand_custom_XnXX},
 16.2639 ++    {CODE_FOR_custom_fnff, "__builtin_custom_fnff", NIOS2_BUILTIN_CUSTOM_FNFF, &custom_fnff, nios2_expand_custom_XnXX},
 16.2640 ++    {CODE_FOR_custom_fnfp, "__builtin_custom_fnfp", NIOS2_BUILTIN_CUSTOM_FNFP, &custom_fnfp, nios2_expand_custom_XnXX},
 16.2641 ++    {CODE_FOR_custom_fnpi, "__builtin_custom_fnpi", NIOS2_BUILTIN_CUSTOM_FNPI, &custom_fnpi, nios2_expand_custom_XnXX},
 16.2642 ++    {CODE_FOR_custom_fnpf, "__builtin_custom_fnpf", NIOS2_BUILTIN_CUSTOM_FNPF, &custom_fnpf, nios2_expand_custom_XnXX},
 16.2643 ++    {CODE_FOR_custom_fnpp, "__builtin_custom_fnpp", NIOS2_BUILTIN_CUSTOM_FNPP, &custom_fnpp, nios2_expand_custom_XnXX},
 16.2644 ++    {CODE_FOR_custom_pn, "__builtin_custom_pn", NIOS2_BUILTIN_CUSTOM_PN, &custom_pn, nios2_expand_custom_Xn},
 16.2645 ++    {CODE_FOR_custom_pni, "__builtin_custom_pni", NIOS2_BUILTIN_CUSTOM_PNI, &custom_pni, nios2_expand_custom_XnX},
 16.2646 ++    {CODE_FOR_custom_pnf, "__builtin_custom_pnf", NIOS2_BUILTIN_CUSTOM_PNF, &custom_pnf, nios2_expand_custom_XnX},
 16.2647 ++    {CODE_FOR_custom_pnp, "__builtin_custom_pnp", NIOS2_BUILTIN_CUSTOM_PNP, &custom_pnp, nios2_expand_custom_XnX},
 16.2648 ++    {CODE_FOR_custom_pnii, "__builtin_custom_pnii", NIOS2_BUILTIN_CUSTOM_PNII, &custom_pnii, nios2_expand_custom_XnXX},
 16.2649 ++    {CODE_FOR_custom_pnif, "__builtin_custom_pnif", NIOS2_BUILTIN_CUSTOM_PNIF, &custom_pnif, nios2_expand_custom_XnXX},
 16.2650 ++    {CODE_FOR_custom_pnip, "__builtin_custom_pnip", NIOS2_BUILTIN_CUSTOM_PNIP, &custom_pnip, nios2_expand_custom_XnXX},
 16.2651 ++    {CODE_FOR_custom_pnfi, "__builtin_custom_pnfi", NIOS2_BUILTIN_CUSTOM_PNFI, &custom_pnfi, nios2_expand_custom_XnXX},
 16.2652 ++    {CODE_FOR_custom_pnff, "__builtin_custom_pnff", NIOS2_BUILTIN_CUSTOM_PNFF, &custom_pnff, nios2_expand_custom_XnXX},
 16.2653 ++    {CODE_FOR_custom_pnfp, "__builtin_custom_pnfp", NIOS2_BUILTIN_CUSTOM_PNFP, &custom_pnfp, nios2_expand_custom_XnXX},
 16.2654 ++    {CODE_FOR_custom_pnpi, "__builtin_custom_pnpi", NIOS2_BUILTIN_CUSTOM_PNPI, &custom_pnpi, nios2_expand_custom_XnXX},
 16.2655 ++    {CODE_FOR_custom_pnpf, "__builtin_custom_pnpf", NIOS2_BUILTIN_CUSTOM_PNPF, &custom_pnpf, nios2_expand_custom_XnXX},
 16.2656 ++    {CODE_FOR_custom_pnpp, "__builtin_custom_pnpp", NIOS2_BUILTIN_CUSTOM_PNPP, &custom_pnpp, nios2_expand_custom_XnXX},
 16.2657 ++
 16.2658 ++
 16.2659 ++    {0, 0, 0, 0, 0},
 16.2660 ++};
 16.2661 ++
 16.2662 ++/* This does not have a closing bracket on purpose (see use) */
 16.2663 ++#define def_param(TYPE) \
 16.2664 ++  tree_cons (NULL_TREE, TYPE,
 16.2665 ++
 16.2666 ++static void
 16.2667 ++nios2_init_builtins ()
 16.2668 ++{
 16.2669 ++  const struct builtin_description *d;
 16.2670 ++
 16.2671 ++
 16.2672 ++  endlink = void_list_node;
 16.2673 ++
 16.2674 ++  /* Special indenting here because one of the brackets is in def_param */
 16.2675 ++  /* *INDENT-OFF* */
 16.2676 ++
 16.2677 ++  /* int fn (volatile const void *)
 16.2678 ++   */
 16.2679 ++  int_ftype_volatile_const_void_p
 16.2680 ++    = build_function_type (integer_type_node,
 16.2681 ++			   def_param (build_qualified_type (ptr_type_node,
 16.2682 ++			                                    TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
 16.2683 ++			   endlink));
 16.2684 ++
 16.2685 ++
 16.2686 ++  /* void fn (volatile void *, int)
 16.2687 ++   */
 16.2688 ++  void_ftype_volatile_void_p_int
 16.2689 ++    = build_function_type (void_type_node,
 16.2690 ++			   def_param (build_qualified_type (ptr_type_node,
 16.2691 ++			                                    TYPE_QUAL_VOLATILE))
 16.2692 ++			   def_param (integer_type_node)
 16.2693 ++			   endlink)));
 16.2694 ++
 16.2695 ++  /* void fn (void)
 16.2696 ++   */
 16.2697 ++  void_ftype_void
 16.2698 ++      = build_function_type (void_type_node,
 16.2699 ++                             endlink);
 16.2700 ++
 16.2701 ++  /* int fn (int)
 16.2702 ++   */
 16.2703 ++  int_ftype_int
 16.2704 ++      = build_function_type (integer_type_node,
 16.2705 ++                             def_param (integer_type_node)
 16.2706 ++                             endlink));
 16.2707 ++
 16.2708 ++  /* void fn (int, int)
 16.2709 ++   */
 16.2710 ++  void_ftype_int_int
 16.2711 ++      = build_function_type (void_type_node,
 16.2712 ++                             def_param (integer_type_node)
 16.2713 ++                             def_param (integer_type_node)
 16.2714 ++                             endlink)));
 16.2715 ++
 16.2716 ++
 16.2717 ++#define CUSTOM_NUM def_param (integer_type_node)
 16.2718 ++
 16.2719 ++  custom_n
 16.2720 ++      = build_function_type (void_type_node,
 16.2721 ++  			     CUSTOM_NUM
 16.2722 ++  			     endlink));
 16.2723 ++  custom_ni
 16.2724 ++      = build_function_type (void_type_node,
 16.2725 ++  			     CUSTOM_NUM
 16.2726 ++  			     def_param (integer_type_node)
 16.2727 ++  			     endlink)));
 16.2728 ++  custom_nf
 16.2729 ++      = build_function_type (void_type_node,
 16.2730 ++  			     CUSTOM_NUM
 16.2731 ++  			     def_param (float_type_node)
 16.2732 ++  			     endlink)));
 16.2733 ++  custom_np
 16.2734 ++      = build_function_type (void_type_node,
 16.2735 ++  			     CUSTOM_NUM
 16.2736 ++  			     def_param (ptr_type_node)
 16.2737 ++  			     endlink)));
 16.2738 ++  custom_nii
 16.2739 ++      = build_function_type (void_type_node,
 16.2740 ++  			     CUSTOM_NUM
 16.2741 ++  			     def_param (integer_type_node)
 16.2742 ++  			     def_param (integer_type_node)
 16.2743 ++  			     endlink))));
 16.2744 ++  custom_nif
 16.2745 ++      = build_function_type (void_type_node,
 16.2746 ++  			     CUSTOM_NUM
 16.2747 ++  			     def_param (integer_type_node)
 16.2748 ++  			     def_param (float_type_node)
 16.2749 ++  			     endlink))));
 16.2750 ++  custom_nip
 16.2751 ++      = build_function_type (void_type_node,
 16.2752 ++  			     CUSTOM_NUM
 16.2753 ++  			     def_param (integer_type_node)
 16.2754 ++  			     def_param (ptr_type_node)
 16.2755 ++  			     endlink))));
 16.2756 ++  custom_nfi
 16.2757 ++      = build_function_type (void_type_node,
 16.2758 ++  			     CUSTOM_NUM
 16.2759 ++  			     def_param (float_type_node)
 16.2760 ++  			     def_param (integer_type_node)
 16.2761 ++  			     endlink))));
 16.2762 ++  custom_nff
 16.2763 ++      = build_function_type (void_type_node,
 16.2764 ++  			     CUSTOM_NUM
 16.2765 ++  			     def_param (float_type_node)
 16.2766 ++  			     def_param (float_type_node)
 16.2767 ++  			     endlink))));
 16.2768 ++  custom_nfp
 16.2769 ++      = build_function_type (void_type_node,
 16.2770 ++  			     CUSTOM_NUM
 16.2771 ++  			     def_param (float_type_node)
 16.2772 ++  			     def_param (ptr_type_node)
 16.2773 ++  			     endlink))));
 16.2774 ++  custom_npi
 16.2775 ++      = build_function_type (void_type_node,
 16.2776 ++  			     CUSTOM_NUM
 16.2777 ++  			     def_param (ptr_type_node)
 16.2778 ++  			     def_param (integer_type_node)
 16.2779 ++  			     endlink))));
 16.2780 ++  custom_npf
 16.2781 ++      = build_function_type (void_type_node,
 16.2782 ++  			     CUSTOM_NUM
 16.2783 ++  			     def_param (ptr_type_node)
 16.2784 ++  			     def_param (float_type_node)
 16.2785 ++  			     endlink))));
 16.2786 ++  custom_npp
 16.2787 ++      = build_function_type (void_type_node,
 16.2788 ++  			     CUSTOM_NUM
 16.2789 ++  			     def_param (ptr_type_node)
 16.2790 ++  			     def_param (ptr_type_node)
 16.2791 ++  			     endlink))));
 16.2792 ++
 16.2793 ++  custom_in
 16.2794 ++      = build_function_type (integer_type_node,
 16.2795 ++  			     CUSTOM_NUM
 16.2796 ++  			     endlink));
 16.2797 ++  custom_ini
 16.2798 ++      = build_function_type (integer_type_node,
 16.2799 ++  			     CUSTOM_NUM
 16.2800 ++  			     def_param (integer_type_node)
 16.2801 ++  			     endlink)));
 16.2802 ++  custom_inf
 16.2803 ++      = build_function_type (integer_type_node,
 16.2804 ++  			     CUSTOM_NUM
 16.2805 ++  			     def_param (float_type_node)
 16.2806 ++  			     endlink)));
 16.2807 ++  custom_inp
 16.2808 ++      = build_function_type (integer_type_node,
 16.2809 ++  			     CUSTOM_NUM
 16.2810 ++  			     def_param (ptr_type_node)
 16.2811 ++  			     endlink)));
 16.2812 ++  custom_inii
 16.2813 ++      = build_function_type (integer_type_node,
 16.2814 ++  			     CUSTOM_NUM
 16.2815 ++  			     def_param (integer_type_node)
 16.2816 ++  			     def_param (integer_type_node)
 16.2817 ++  			     endlink))));
 16.2818 ++  custom_inif
 16.2819 ++      = build_function_type (integer_type_node,
 16.2820 ++  			     CUSTOM_NUM
 16.2821 ++  			     def_param (integer_type_node)
 16.2822 ++  			     def_param (float_type_node)
 16.2823 ++  			     endlink))));
 16.2824 ++  custom_inip
 16.2825 ++      = build_function_type (integer_type_node,
 16.2826 ++  			     CUSTOM_NUM
 16.2827 ++  			     def_param (integer_type_node)
 16.2828 ++  			     def_param (ptr_type_node)
 16.2829 ++  			     endlink))));
 16.2830 ++  custom_infi
 16.2831 ++      = build_function_type (integer_type_node,
 16.2832 ++  			     CUSTOM_NUM
 16.2833 ++  			     def_param (float_type_node)
 16.2834 ++  			     def_param (integer_type_node)
 16.2835 ++  			     endlink))));
 16.2836 ++  custom_inff
 16.2837 ++      = build_function_type (integer_type_node,
 16.2838 ++  			     CUSTOM_NUM
 16.2839 ++  			     def_param (float_type_node)
 16.2840 ++  			     def_param (float_type_node)
 16.2841 ++  			     endlink))));
 16.2842 ++  custom_infp
 16.2843 ++      = build_function_type (integer_type_node,
 16.2844 ++  			     CUSTOM_NUM
 16.2845 ++  			     def_param (float_type_node)
 16.2846 ++  			     def_param (ptr_type_node)
 16.2847 ++  			     endlink))));
 16.2848 ++  custom_inpi
 16.2849 ++      = build_function_type (integer_type_node,
 16.2850 ++  			     CUSTOM_NUM
 16.2851 ++  			     def_param (ptr_type_node)
 16.2852 ++  			     def_param (integer_type_node)
 16.2853 ++  			     endlink))));
 16.2854 ++  custom_inpf
 16.2855 ++      = build_function_type (integer_type_node,
 16.2856 ++  			     CUSTOM_NUM
 16.2857 ++  			     def_param (ptr_type_node)
 16.2858 ++  			     def_param (float_type_node)
 16.2859 ++  			     endlink))));
 16.2860 ++  custom_inpp
 16.2861 ++      = build_function_type (integer_type_node,
 16.2862 ++  			     CUSTOM_NUM
 16.2863 ++  			     def_param (ptr_type_node)
 16.2864 ++  			     def_param (ptr_type_node)
 16.2865 ++  			     endlink))));
 16.2866 ++
 16.2867 ++  custom_fn
 16.2868 ++      = build_function_type (float_type_node,
 16.2869 ++  			     CUSTOM_NUM
 16.2870 ++  			     endlink));
 16.2871 ++  custom_fni
 16.2872 ++      = build_function_type (float_type_node,
 16.2873 ++  			     CUSTOM_NUM
 16.2874 ++  			     def_param (integer_type_node)
 16.2875 ++  			     endlink)));
 16.2876 ++  custom_fnf
 16.2877 ++      = build_function_type (float_type_node,
 16.2878 ++  			     CUSTOM_NUM
 16.2879 ++  			     def_param (float_type_node)
 16.2880 ++  			     endlink)));
 16.2881 ++  custom_fnp
 16.2882 ++      = build_function_type (float_type_node,
 16.2883 ++  			     CUSTOM_NUM
 16.2884 ++  			     def_param (ptr_type_node)
 16.2885 ++  			     endlink)));
 16.2886 ++  custom_fnii
 16.2887 ++      = build_function_type (float_type_node,
 16.2888 ++  			     CUSTOM_NUM
 16.2889 ++  			     def_param (integer_type_node)
 16.2890 ++  			     def_param (integer_type_node)
 16.2891 ++  			     endlink))));
 16.2892 ++  custom_fnif
 16.2893 ++      = build_function_type (float_type_node,
 16.2894 ++  			     CUSTOM_NUM
 16.2895 ++  			     def_param (integer_type_node)
 16.2896 ++  			     def_param (float_type_node)
 16.2897 ++  			     endlink))));
 16.2898 ++  custom_fnip
 16.2899 ++      = build_function_type (float_type_node,
 16.2900 ++  			     CUSTOM_NUM
 16.2901 ++  			     def_param (integer_type_node)
 16.2902 ++  			     def_param (ptr_type_node)
 16.2903 ++  			     endlink))));
 16.2904 ++  custom_fnfi
 16.2905 ++      = build_function_type (float_type_node,
 16.2906 ++  			     CUSTOM_NUM
 16.2907 ++  			     def_param (float_type_node)
 16.2908 ++  			     def_param (integer_type_node)
 16.2909 ++  			     endlink))));
 16.2910 ++  custom_fnff
 16.2911 ++      = build_function_type (float_type_node,
 16.2912 ++  			     CUSTOM_NUM
 16.2913 ++  			     def_param (float_type_node)
 16.2914 ++  			     def_param (float_type_node)
 16.2915 ++  			     endlink))));
 16.2916 ++  custom_fnfp
 16.2917 ++      = build_function_type (float_type_node,
 16.2918 ++  			     CUSTOM_NUM
 16.2919 ++  			     def_param (float_type_node)
 16.2920 ++  			     def_param (ptr_type_node)
 16.2921 ++  			     endlink))));
 16.2922 ++  custom_fnpi
 16.2923 ++      = build_function_type (float_type_node,
 16.2924 ++  			     CUSTOM_NUM
 16.2925 ++  			     def_param (ptr_type_node)
 16.2926 ++  			     def_param (integer_type_node)
 16.2927 ++  			     endlink))));
 16.2928 ++  custom_fnpf
 16.2929 ++      = build_function_type (float_type_node,
 16.2930 ++  			     CUSTOM_NUM
 16.2931 ++  			     def_param (ptr_type_node)
 16.2932 ++  			     def_param (float_type_node)
 16.2933 ++  			     endlink))));
 16.2934 ++  custom_fnpp
 16.2935 ++      = build_function_type (float_type_node,
 16.2936 ++  			     CUSTOM_NUM
 16.2937 ++  			     def_param (ptr_type_node)
 16.2938 ++  			     def_param (ptr_type_node)
 16.2939 ++  			     endlink))));
 16.2940 ++
 16.2941 ++
 16.2942 ++  custom_pn
 16.2943 ++      = build_function_type (ptr_type_node,
 16.2944 ++  			     CUSTOM_NUM
 16.2945 ++  			     endlink));
 16.2946 ++  custom_pni
 16.2947 ++      = build_function_type (ptr_type_node,
 16.2948 ++  			     CUSTOM_NUM
 16.2949 ++  			     def_param (integer_type_node)
 16.2950 ++  			     endlink)));
 16.2951 ++  custom_pnf
 16.2952 ++      = build_function_type (ptr_type_node,
 16.2953 ++  			     CUSTOM_NUM
 16.2954 ++  			     def_param (float_type_node)
 16.2955 ++  			     endlink)));
 16.2956 ++  custom_pnp
 16.2957 ++      = build_function_type (ptr_type_node,
 16.2958 ++  			     CUSTOM_NUM
 16.2959 ++  			     def_param (ptr_type_node)
 16.2960 ++  			     endlink)));
 16.2961 ++  custom_pnii
 16.2962 ++      = build_function_type (ptr_type_node,
 16.2963 ++  			     CUSTOM_NUM
 16.2964 ++  			     def_param (integer_type_node)
 16.2965 ++  			     def_param (integer_type_node)
 16.2966 ++  			     endlink))));
 16.2967 ++  custom_pnif
 16.2968 ++      = build_function_type (ptr_type_node,
 16.2969 ++  			     CUSTOM_NUM
 16.2970 ++  			     def_param (integer_type_node)
 16.2971 ++  			     def_param (float_type_node)
 16.2972 ++  			     endlink))));
 16.2973 ++  custom_pnip
 16.2974 ++      = build_function_type (ptr_type_node,
 16.2975 ++  			     CUSTOM_NUM
 16.2976 ++  			     def_param (integer_type_node)
 16.2977 ++  			     def_param (ptr_type_node)
 16.2978 ++  			     endlink))));
 16.2979 ++  custom_pnfi
 16.2980 ++      = build_function_type (ptr_type_node,
 16.2981 ++  			     CUSTOM_NUM
 16.2982 ++  			     def_param (float_type_node)
 16.2983 ++  			     def_param (integer_type_node)
 16.2984 ++  			     endlink))));
 16.2985 ++  custom_pnff
 16.2986 ++      = build_function_type (ptr_type_node,
 16.2987 ++  			     CUSTOM_NUM
 16.2988 ++  			     def_param (float_type_node)
 16.2989 ++  			     def_param (float_type_node)
 16.2990 ++  			     endlink))));
 16.2991 ++  custom_pnfp
 16.2992 ++      = build_function_type (ptr_type_node,
 16.2993 ++  			     CUSTOM_NUM
 16.2994 ++  			     def_param (float_type_node)
 16.2995 ++  			     def_param (ptr_type_node)
 16.2996 ++  			     endlink))));
 16.2997 ++  custom_pnpi
 16.2998 ++      = build_function_type (ptr_type_node,
 16.2999 ++  			     CUSTOM_NUM
 16.3000 ++  			     def_param (ptr_type_node)
 16.3001 ++  			     def_param (integer_type_node)
 16.3002 ++  			     endlink))));
 16.3003 ++  custom_pnpf
 16.3004 ++      = build_function_type (ptr_type_node,
 16.3005 ++  			     CUSTOM_NUM
 16.3006 ++  			     def_param (ptr_type_node)
 16.3007 ++  			     def_param (float_type_node)
 16.3008 ++  			     endlink))));
 16.3009 ++  custom_pnpp
 16.3010 ++      = build_function_type (ptr_type_node,
 16.3011 ++  			     CUSTOM_NUM
 16.3012 ++  			     def_param (ptr_type_node)
 16.3013 ++  			     def_param (ptr_type_node)
 16.3014 ++  			     endlink))));
 16.3015 ++
 16.3016 ++
 16.3017 ++
 16.3018 ++  /* *INDENT-ON* */
 16.3019 ++
 16.3020 ++
 16.3021 ++  for (d = bdesc; d->name; d++)
 16.3022 ++    {
 16.3023 ++      builtin_function (d->name, *d->type, d->code,
 16.3024 ++			BUILT_IN_MD, NULL, NULL);
 16.3025 ++    }
 16.3026 ++}
 16.3027 ++
 16.3028 ++/* Expand an expression EXP that calls a built-in function,
 16.3029 ++   with result going to TARGET if that's convenient
 16.3030 ++   (and in mode MODE if that's convenient).
 16.3031 ++   SUBTARGET may be used as the target for computing one of EXP's operands.
 16.3032 ++   IGNORE is nonzero if the value is to be ignored.  */
 16.3033 ++
 16.3034 ++static rtx
 16.3035 ++nios2_expand_builtin (tree exp, rtx target, rtx subtarget, 
 16.3036 ++                      enum machine_mode mode, int ignore)
 16.3037 ++{
 16.3038 ++  const struct builtin_description *d;
 16.3039 ++  tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
 16.3040 ++  unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
 16.3041 ++
 16.3042 ++  for (d = bdesc; d->name; d++)
 16.3043 ++    if (d->code == fcode)
 16.3044 ++      return (d->expander) (d, exp, target, subtarget, mode, ignore);
 16.3045 ++
 16.3046 ++  /* we should have seen one of the functins we registered */
 16.3047 ++  abort ();
 16.3048 ++}
 16.3049 ++
 16.3050 ++static rtx nios2_create_target (const struct builtin_description *, rtx);
 16.3051 ++
 16.3052 ++
 16.3053 ++static rtx
 16.3054 ++nios2_create_target (const struct builtin_description *d, rtx target)
 16.3055 ++{
 16.3056 ++  if (!target
 16.3057 ++      || !(*insn_data[d->icode].operand[0].predicate) (target,
 16.3058 ++                                                       insn_data[d->icode].operand[0].mode))
 16.3059 ++    {
 16.3060 ++      target = gen_reg_rtx (insn_data[d->icode].operand[0].mode);
 16.3061 ++    }
 16.3062 ++
 16.3063 ++  return target;
 16.3064 ++}
 16.3065 ++
 16.3066 ++
 16.3067 ++static rtx nios2_extract_opcode (const struct builtin_description *, int, tree);
 16.3068 ++static rtx nios2_extract_operand (const struct builtin_description *, int, int, tree);
 16.3069 ++
 16.3070 ++static rtx
 16.3071 ++nios2_extract_opcode (const struct builtin_description *d, int op, tree arglist)
 16.3072 ++{
 16.3073 ++  enum machine_mode mode = insn_data[d->icode].operand[op].mode;
 16.3074 ++  tree arg = TREE_VALUE (arglist);
 16.3075 ++  rtx opcode = expand_expr (arg, NULL_RTX, mode, 0);
 16.3076 ++  opcode = protect_from_queue (opcode, 0);
 16.3077 ++
 16.3078 ++  if (!(*insn_data[d->icode].operand[op].predicate) (opcode, mode))
 16.3079 ++    error ("Custom instruction opcode must be compile time constant in the range 0-255 for %s", d->name);
 16.3080 ++
 16.3081 ++  return opcode;
 16.3082 ++}
 16.3083 ++
 16.3084 ++static rtx
 16.3085 ++nios2_extract_operand (const struct builtin_description *d, int op, int argnum, tree arglist)
 16.3086 ++{
 16.3087 ++  enum machine_mode mode = insn_data[d->icode].operand[op].mode;
 16.3088 ++  tree arg = TREE_VALUE (arglist);
 16.3089 ++  rtx operand = expand_expr (arg, NULL_RTX, mode, 0);
 16.3090 ++  operand = protect_from_queue (operand, 0);
 16.3091 ++
 16.3092 ++  if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
 16.3093 ++    operand = copy_to_mode_reg (mode, operand);
 16.3094 ++
 16.3095 ++  /* ??? Better errors would be nice */
 16.3096 ++  if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
 16.3097 ++    error ("Invalid argument %d to %s", argnum, d->name);
 16.3098 ++
 16.3099 ++  return operand;
 16.3100 ++}
 16.3101 ++
 16.3102 ++
 16.3103 ++static rtx
 16.3104 ++nios2_expand_custom_n (const struct builtin_description *d, tree exp, 
 16.3105 ++                       rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED, 
 16.3106 ++                       enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
 16.3107 ++{
 16.3108 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3109 ++  rtx pat;
 16.3110 ++  rtx opcode;
 16.3111 ++
 16.3112 ++  /* custom_n should have exactly one operand */
 16.3113 ++  if (insn_data[d->icode].n_operands != 1)
 16.3114 ++    abort ();
 16.3115 ++
 16.3116 ++  opcode = nios2_extract_opcode (d, 0, arglist);
 16.3117 ++
 16.3118 ++  pat = GEN_FCN (d->icode) (opcode);
 16.3119 ++  if (!pat)
 16.3120 ++    return 0;
 16.3121 ++  emit_insn (pat);
 16.3122 ++  return 0;
 16.3123 ++}
 16.3124 ++
 16.3125 ++static rtx
 16.3126 ++nios2_expand_custom_Xn (const struct builtin_description *d, tree exp, 
 16.3127 ++                        rtx target, rtx subtarget ATTRIBUTE_UNUSED, 
 16.3128 ++                        enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3129 ++                        int ignore ATTRIBUTE_UNUSED)
 16.3130 ++{
 16.3131 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3132 ++  rtx pat;
 16.3133 ++  rtx opcode;
 16.3134 ++
 16.3135 ++  /* custom_Xn should have exactly two operands */
 16.3136 ++  if (insn_data[d->icode].n_operands != 2)
 16.3137 ++    abort ();
 16.3138 ++
 16.3139 ++  target = nios2_create_target (d, target);
 16.3140 ++  opcode = nios2_extract_opcode (d, 1, arglist);
 16.3141 ++
 16.3142 ++  pat = GEN_FCN (d->icode) (target, opcode);
 16.3143 ++  if (!pat)
 16.3144 ++    return 0;
 16.3145 ++  emit_insn (pat);
 16.3146 ++  return target;
 16.3147 ++}
 16.3148 ++
 16.3149 ++static rtx
 16.3150 ++nios2_expand_custom_nX (const struct builtin_description *d, tree exp, 
 16.3151 ++                        rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED, 
 16.3152 ++                        enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
 16.3153 ++{
 16.3154 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3155 ++  rtx pat;
 16.3156 ++  rtx opcode;
 16.3157 ++  rtx operands[1];
 16.3158 ++  int i;
 16.3159 ++
 16.3160 ++
 16.3161 ++  /* custom_nX should have exactly two operands */
 16.3162 ++  if (insn_data[d->icode].n_operands != 2)
 16.3163 ++    abort ();
 16.3164 ++
 16.3165 ++  opcode = nios2_extract_opcode (d, 0, arglist);
 16.3166 ++  for (i = 0; i < 1; i++)
 16.3167 ++    {
 16.3168 ++      arglist = TREE_CHAIN (arglist);
 16.3169 ++      operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
 16.3170 ++    }
 16.3171 ++
 16.3172 ++  pat = GEN_FCN (d->icode) (opcode, operands[0]);
 16.3173 ++  if (!pat)
 16.3174 ++    return 0;
 16.3175 ++  emit_insn (pat);
 16.3176 ++  return 0;
 16.3177 ++}
 16.3178 ++
 16.3179 ++static rtx
 16.3180 ++nios2_expand_custom_XnX (const struct builtin_description *d, tree exp, rtx target, 
 16.3181 ++                         rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3182 ++                         int ignore ATTRIBUTE_UNUSED)
 16.3183 ++{
 16.3184 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3185 ++  rtx pat;
 16.3186 ++  rtx opcode;
 16.3187 ++  rtx operands[1];
 16.3188 ++  int i;
 16.3189 ++
 16.3190 ++  /* custom_Xn should have exactly three operands */
 16.3191 ++  if (insn_data[d->icode].n_operands != 3)
 16.3192 ++    abort ();
 16.3193 ++
 16.3194 ++  target = nios2_create_target (d, target);
 16.3195 ++  opcode = nios2_extract_opcode (d, 1, arglist);
 16.3196 ++
 16.3197 ++  for (i = 0; i < 1; i++)
 16.3198 ++    {
 16.3199 ++      arglist = TREE_CHAIN (arglist);
 16.3200 ++      operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
 16.3201 ++    }
 16.3202 ++
 16.3203 ++  pat = GEN_FCN (d->icode) (target, opcode, operands[0]);
 16.3204 ++
 16.3205 ++  if (!pat)
 16.3206 ++    return 0;
 16.3207 ++  emit_insn (pat);
 16.3208 ++  return target;
 16.3209 ++}
 16.3210 ++
 16.3211 ++static rtx
 16.3212 ++nios2_expand_custom_nXX (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED, 
 16.3213 ++                         rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3214 ++                         int ignore ATTRIBUTE_UNUSED)
 16.3215 ++{
 16.3216 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3217 ++  rtx pat;
 16.3218 ++  rtx opcode;
 16.3219 ++  rtx operands[2];
 16.3220 ++  int i;
 16.3221 ++
 16.3222 ++
 16.3223 ++  /* custom_nX should have exactly three operands */
 16.3224 ++  if (insn_data[d->icode].n_operands != 3)
 16.3225 ++    abort ();
 16.3226 ++
 16.3227 ++  opcode = nios2_extract_opcode (d, 0, arglist);
 16.3228 ++  for (i = 0; i < 2; i++)
 16.3229 ++    {
 16.3230 ++      arglist = TREE_CHAIN (arglist);
 16.3231 ++      operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
 16.3232 ++    }
 16.3233 ++
 16.3234 ++  pat = GEN_FCN (d->icode) (opcode, operands[0], operands[1]);
 16.3235 ++  if (!pat)
 16.3236 ++    return 0;
 16.3237 ++  emit_insn (pat);
 16.3238 ++  return 0;
 16.3239 ++}
 16.3240 ++
 16.3241 ++static rtx
 16.3242 ++nios2_expand_custom_XnXX (const struct builtin_description *d, tree exp, rtx target, 
 16.3243 ++                          rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3244 ++                          int ignore ATTRIBUTE_UNUSED)
 16.3245 ++{
 16.3246 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3247 ++  rtx pat;
 16.3248 ++  rtx opcode;
 16.3249 ++  rtx operands[2];
 16.3250 ++  int i;
 16.3251 ++
 16.3252 ++
 16.3253 ++  /* custom_XnX should have exactly four operands */
 16.3254 ++  if (insn_data[d->icode].n_operands != 4)
 16.3255 ++    abort ();
 16.3256 ++
 16.3257 ++  target = nios2_create_target (d, target);
 16.3258 ++  opcode = nios2_extract_opcode (d, 1, arglist);
 16.3259 ++  for (i = 0; i < 2; i++)
 16.3260 ++    {
 16.3261 ++      arglist = TREE_CHAIN (arglist);
 16.3262 ++      operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
 16.3263 ++    }
 16.3264 ++
 16.3265 ++  pat = GEN_FCN (d->icode) (target, opcode, operands[0], operands[1]);
 16.3266 ++
 16.3267 ++  if (!pat)
 16.3268 ++    return 0;
 16.3269 ++  emit_insn (pat);
 16.3270 ++  return target;
 16.3271 ++}
 16.3272 ++
 16.3273 ++
 16.3274 ++
 16.3275 ++static rtx
 16.3276 ++nios2_expand_STXIO (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED, 
 16.3277 ++                    rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3278 ++                    int ignore ATTRIBUTE_UNUSED)
 16.3279 ++{
 16.3280 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3281 ++  rtx pat;
 16.3282 ++  rtx store_dest, store_val;
 16.3283 ++  enum insn_code icode = d->icode;
 16.3284 ++
 16.3285 ++  /* stores should have exactly two operands */
 16.3286 ++  if (insn_data[icode].n_operands != 2)
 16.3287 ++    abort ();
 16.3288 ++
 16.3289 ++  /* process the destination of the store */
 16.3290 ++  {
 16.3291 ++    enum machine_mode mode = insn_data[icode].operand[0].mode;
 16.3292 ++    tree arg = TREE_VALUE (arglist);
 16.3293 ++    store_dest = expand_expr (arg, NULL_RTX, VOIDmode, 0);
 16.3294 ++    store_dest = protect_from_queue (store_dest, 0);
 16.3295 ++
 16.3296 ++    store_dest = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, store_dest));
 16.3297 ++
 16.3298 ++    /* ??? Better errors would be nice */
 16.3299 ++    if (!(*insn_data[icode].operand[0].predicate) (store_dest, mode))
 16.3300 ++      error ("Invalid argument 1 to %s", d->name);
 16.3301 ++  }
 16.3302 ++
 16.3303 ++
 16.3304 ++  /* process the value to store */
 16.3305 ++  {
 16.3306 ++    enum machine_mode mode = insn_data[icode].operand[1].mode;
 16.3307 ++    tree arg = TREE_VALUE (TREE_CHAIN (arglist));
 16.3308 ++    store_val = expand_expr (arg, NULL_RTX, mode, 0);
 16.3309 ++    store_val = protect_from_queue (store_val, 0);
 16.3310 ++
 16.3311 ++    if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
 16.3312 ++      store_val = copy_to_mode_reg (mode, store_val);
 16.3313 ++
 16.3314 ++    /* ??? Better errors would be nice */
 16.3315 ++    if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
 16.3316 ++      error ("Invalid argument 2 to %s", d->name);
 16.3317 ++  }
 16.3318 ++
 16.3319 ++  pat = GEN_FCN (d->icode) (store_dest, store_val);
 16.3320 ++  if (!pat)
 16.3321 ++    return 0;
 16.3322 ++  emit_insn (pat);
 16.3323 ++  return 0;
 16.3324 ++}
 16.3325 ++
 16.3326 ++
 16.3327 ++static rtx
 16.3328 ++nios2_expand_LDXIO (const struct builtin_description * d, tree exp, rtx target, 
 16.3329 ++                    rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3330 ++                    int ignore ATTRIBUTE_UNUSED)
 16.3331 ++{
 16.3332 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3333 ++  rtx pat;
 16.3334 ++  rtx ld_src;
 16.3335 ++  enum insn_code icode = d->icode;
 16.3336 ++
 16.3337 ++  /* loads should have exactly two operands */
 16.3338 ++  if (insn_data[icode].n_operands != 2)
 16.3339 ++    abort ();
 16.3340 ++
 16.3341 ++  target = nios2_create_target (d, target);
 16.3342 ++
 16.3343 ++  {
 16.3344 ++    enum machine_mode mode = insn_data[icode].operand[1].mode;
 16.3345 ++    tree arg = TREE_VALUE (arglist);
 16.3346 ++    ld_src = expand_expr (arg, NULL_RTX, VOIDmode, 0);
 16.3347 ++    ld_src = protect_from_queue (ld_src, 0);
 16.3348 ++
 16.3349 ++    ld_src = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, ld_src));
 16.3350 ++
 16.3351 ++    /* ??? Better errors would be nice */
 16.3352 ++    if (!(*insn_data[icode].operand[1].predicate) (ld_src, mode))
 16.3353 ++      {
 16.3354 ++        error ("Invalid argument 1 to %s", d->name);
 16.3355 ++      }
 16.3356 ++  }
 16.3357 ++
 16.3358 ++  pat = GEN_FCN (d->icode) (target, ld_src);
 16.3359 ++  if (!pat)
 16.3360 ++    return 0;
 16.3361 ++  emit_insn (pat);
 16.3362 ++  return target;
 16.3363 ++}
 16.3364 ++
 16.3365 ++
 16.3366 ++static rtx
 16.3367 ++nios2_expand_sync (const struct builtin_description * d ATTRIBUTE_UNUSED, 
 16.3368 ++                   tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED, 
 16.3369 ++                   rtx subtarget ATTRIBUTE_UNUSED, 
 16.3370 ++                   enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3371 ++                   int ignore ATTRIBUTE_UNUSED)
 16.3372 ++{
 16.3373 ++  emit_insn (gen_sync ());
 16.3374 ++  return 0;
 16.3375 ++}
 16.3376 ++
 16.3377 ++static rtx
 16.3378 ++nios2_expand_rdctl (const struct builtin_description * d ATTRIBUTE_UNUSED, 
 16.3379 ++                   tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED, 
 16.3380 ++                   rtx subtarget ATTRIBUTE_UNUSED, 
 16.3381 ++                   enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3382 ++                   int ignore ATTRIBUTE_UNUSED)
 16.3383 ++{
 16.3384 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3385 ++  rtx pat;
 16.3386 ++  rtx rdctl_reg;
 16.3387 ++  enum insn_code icode = d->icode;
 16.3388 ++
 16.3389 ++  /* rdctl should have exactly two operands */
 16.3390 ++  if (insn_data[icode].n_operands != 2)
 16.3391 ++    abort ();
 16.3392 ++
 16.3393 ++  target = nios2_create_target (d, target);
 16.3394 ++
 16.3395 ++  {
 16.3396 ++    enum machine_mode mode = insn_data[icode].operand[1].mode;
 16.3397 ++    tree arg = TREE_VALUE (arglist);
 16.3398 ++    rdctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
 16.3399 ++    rdctl_reg = protect_from_queue (rdctl_reg, 0);
 16.3400 ++
 16.3401 ++    if (!(*insn_data[icode].operand[1].predicate) (rdctl_reg, mode))
 16.3402 ++      {
 16.3403 ++        error ("Control register number must be in range 0-31 for %s", d->name);
 16.3404 ++      }
 16.3405 ++  }
 16.3406 ++
 16.3407 ++  pat = GEN_FCN (d->icode) (target, rdctl_reg);
 16.3408 ++  if (!pat)
 16.3409 ++    return 0;
 16.3410 ++  emit_insn (pat);
 16.3411 ++  return target;
 16.3412 ++}
 16.3413 ++
 16.3414 ++static rtx
 16.3415 ++nios2_expand_wrctl (const struct builtin_description * d ATTRIBUTE_UNUSED, 
 16.3416 ++                   tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED, 
 16.3417 ++                   rtx subtarget ATTRIBUTE_UNUSED, 
 16.3418 ++                   enum machine_mode mode ATTRIBUTE_UNUSED, 
 16.3419 ++                   int ignore ATTRIBUTE_UNUSED)
 16.3420 ++{
 16.3421 ++  tree arglist = TREE_OPERAND (exp, 1);
 16.3422 ++  rtx pat;
 16.3423 ++  rtx wrctl_reg, store_val;
 16.3424 ++  enum insn_code icode = d->icode;
 16.3425 ++
 16.3426 ++  /* stores should have exactly two operands */
 16.3427 ++  if (insn_data[icode].n_operands != 2)
 16.3428 ++    abort ();
 16.3429 ++
 16.3430 ++  /* process the destination of the store */
 16.3431 ++  {
 16.3432 ++    enum machine_mode mode = insn_data[icode].operand[0].mode;
 16.3433 ++    tree arg = TREE_VALUE (arglist);
 16.3434 ++    wrctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
 16.3435 ++    wrctl_reg = protect_from_queue (wrctl_reg, 0);
 16.3436 ++
 16.3437 ++    if (!(*insn_data[icode].operand[0].predicate) (wrctl_reg, mode))
 16.3438 ++      error ("Control register number must be in range 0-31 for %s", d->name);
 16.3439 ++  }
 16.3440 ++
 16.3441 ++
 16.3442 ++  /* process the value to store */
 16.3443 ++  {
 16.3444 ++    enum machine_mode mode = insn_data[icode].operand[1].mode;
 16.3445 ++    tree arg = TREE_VALUE (TREE_CHAIN (arglist));
 16.3446 ++    store_val = expand_expr (arg, NULL_RTX, mode, 0);
 16.3447 ++    store_val = protect_from_queue (store_val, 0);
 16.3448 ++
 16.3449 ++    if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
 16.3450 ++      store_val = copy_to_mode_reg (mode, store_val);
 16.3451 ++
 16.3452 ++    /* ??? Better errors would be nice */
 16.3453 ++    if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
 16.3454 ++      error ("Invalid argument 2 to %s", d->name);
 16.3455 ++  }
 16.3456 ++
 16.3457 ++  pat = GEN_FCN (d->icode) (wrctl_reg, store_val);
 16.3458 ++  if (!pat)
 16.3459 ++    return 0;
 16.3460 ++  emit_insn (pat);
 16.3461 ++  return 0;
 16.3462 ++}
 16.3463 ++
 16.3464 ++
 16.3465 ++#include "gt-nios2.h"
 16.3466 ++
 16.3467 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2-dp-bit.c gcc-3.4.6/gcc/config/nios2/nios2-dp-bit.c
 16.3468 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-dp-bit.c	1970-01-01 01:00:00.000000000 +0100
 16.3469 ++++ gcc-3.4.6/gcc/config/nios2/nios2-dp-bit.c	2007-08-15 23:09:36.000000000 +0200
 16.3470 +@@ -0,0 +1,1652 @@
 16.3471 ++
 16.3472 ++/* This is a software floating point library which can be used
 16.3473 ++   for targets without hardware floating point. 
 16.3474 ++   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
 16.3475 ++   Free Software Foundation, Inc.
 16.3476 ++
 16.3477 ++This file is free software; you can redistribute it and/or modify it
 16.3478 ++under the terms of the GNU General Public License as published by the
 16.3479 ++Free Software Foundation; either version 2, or (at your option) any
 16.3480 ++later version.
 16.3481 ++
 16.3482 ++In addition to the permissions in the GNU General Public License, the
 16.3483 ++Free Software Foundation gives you unlimited permission to link the
 16.3484 ++compiled version of this file with other programs, and to distribute
 16.3485 ++those programs without any restriction coming from the use of this
 16.3486 ++file.  (The General Public License restrictions do apply in other
 16.3487 ++respects; for example, they cover modification of the file, and
 16.3488 ++distribution when not linked into another program.)
 16.3489 ++
 16.3490 ++This file is distributed in the hope that it will be useful, but
 16.3491 ++WITHOUT ANY WARRANTY; without even the implied warranty of
 16.3492 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16.3493 ++General Public License for more details.
 16.3494 ++
 16.3495 ++You should have received a copy of the GNU General Public License
 16.3496 ++along with this program; see the file COPYING.  If not, write to
 16.3497 ++the Free Software Foundation, 59 Temple Place - Suite 330,
 16.3498 ++Boston, MA 02111-1307, USA.  */
 16.3499 ++
 16.3500 ++/* As a special exception, if you link this library with other files,
 16.3501 ++   some of which are compiled with GCC, to produce an executable,
 16.3502 ++   this library does not by itself cause the resulting executable
 16.3503 ++   to be covered by the GNU General Public License.
 16.3504 ++   This exception does not however invalidate any other reasons why
 16.3505 ++   the executable file might be covered by the GNU General Public License.  */
 16.3506 ++
 16.3507 ++/* This implements IEEE 754 format arithmetic, but does not provide a
 16.3508 ++   mechanism for setting the rounding mode, or for generating or handling
 16.3509 ++   exceptions.
 16.3510 ++
 16.3511 ++   The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
 16.3512 ++   Wilson, all of Cygnus Support.  */
 16.3513 ++
 16.3514 ++/* The intended way to use this file is to make two copies, add `#define FLOAT'
 16.3515 ++   to one copy, then compile both copies and add them to libgcc.a.  */
 16.3516 ++
 16.3517 ++#include "tconfig.h"
 16.3518 ++#include "coretypes.h"
 16.3519 ++#include "tm.h"
 16.3520 ++#include "config/fp-bit.h"
 16.3521 ++
 16.3522 ++/* The following macros can be defined to change the behavior of this file:
 16.3523 ++   FLOAT: Implement a `float', aka SFmode, fp library.  If this is not
 16.3524 ++     defined, then this file implements a `double', aka DFmode, fp library.
 16.3525 ++   FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
 16.3526 ++     don't include float->double conversion which requires the double library.
 16.3527 ++     This is useful only for machines which can't support doubles, e.g. some
 16.3528 ++     8-bit processors.
 16.3529 ++   CMPtype: Specify the type that floating point compares should return.
 16.3530 ++     This defaults to SItype, aka int.
 16.3531 ++   US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
 16.3532 ++     US Software goFast library.
 16.3533 ++   _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
 16.3534 ++     two integers to the FLO_union_type.
 16.3535 ++   NO_DENORMALS: Disable handling of denormals.
 16.3536 ++   NO_NANS: Disable nan and infinity handling
 16.3537 ++   SMALL_MACHINE: Useful when operations on QIs and HIs are faster
 16.3538 ++     than on an SI */
 16.3539 ++
 16.3540 ++/* We don't currently support extended floats (long doubles) on machines
 16.3541 ++   without hardware to deal with them.
 16.3542 ++
 16.3543 ++   These stubs are just to keep the linker from complaining about unresolved
 16.3544 ++   references which can be pulled in from libio & libstdc++, even if the
 16.3545 ++   user isn't using long doubles.  However, they may generate an unresolved
 16.3546 ++   external to abort if abort is not used by the function, and the stubs
 16.3547 ++   are referenced from within libc, since libgcc goes before and after the
 16.3548 ++   system library.  */
 16.3549 ++
 16.3550 ++#ifdef DECLARE_LIBRARY_RENAMES
 16.3551 ++  DECLARE_LIBRARY_RENAMES
 16.3552 ++#endif
 16.3553 ++
 16.3554 ++#ifdef EXTENDED_FLOAT_STUBS
 16.3555 ++extern void abort (void);
 16.3556 ++void __extendsfxf2 (void) { abort(); }
 16.3557 ++void __extenddfxf2 (void) { abort(); }
 16.3558 ++void __truncxfdf2 (void) { abort(); }
 16.3559 ++void __truncxfsf2 (void) { abort(); }
 16.3560 ++void __fixxfsi (void) { abort(); }
 16.3561 ++void __floatsixf (void) { abort(); }
 16.3562 ++void __addxf3 (void) { abort(); }
 16.3563 ++void __subxf3 (void) { abort(); }
 16.3564 ++void __mulxf3 (void) { abort(); }
 16.3565 ++void __divxf3 (void) { abort(); }
 16.3566 ++void __negxf2 (void) { abort(); }
 16.3567 ++void __eqxf2 (void) { abort(); }
 16.3568 ++void __nexf2 (void) { abort(); }
 16.3569 ++void __gtxf2 (void) { abort(); }
 16.3570 ++void __gexf2 (void) { abort(); }
 16.3571 ++void __lexf2 (void) { abort(); }
 16.3572 ++void __ltxf2 (void) { abort(); }
 16.3573 ++
 16.3574 ++void __extendsftf2 (void) { abort(); }
 16.3575 ++void __extenddftf2 (void) { abort(); }
 16.3576 ++void __trunctfdf2 (void) { abort(); }
 16.3577 ++void __trunctfsf2 (void) { abort(); }
 16.3578 ++void __fixtfsi (void) { abort(); }
 16.3579 ++void __floatsitf (void) { abort(); }
 16.3580 ++void __addtf3 (void) { abort(); }
 16.3581 ++void __subtf3 (void) { abort(); }
 16.3582 ++void __multf3 (void) { abort(); }
 16.3583 ++void __divtf3 (void) { abort(); }
 16.3584 ++void __negtf2 (void) { abort(); }
 16.3585 ++void __eqtf2 (void) { abort(); }
 16.3586 ++void __netf2 (void) { abort(); }
 16.3587 ++void __gttf2 (void) { abort(); }
 16.3588 ++void __getf2 (void) { abort(); }
 16.3589 ++void __letf2 (void) { abort(); }
 16.3590 ++void __lttf2 (void) { abort(); }
 16.3591 ++#else	/* !EXTENDED_FLOAT_STUBS, rest of file */
 16.3592 ++
 16.3593 ++/* IEEE "special" number predicates */
 16.3594 ++
 16.3595 ++#ifdef NO_NANS
 16.3596 ++
 16.3597 ++#define nan() 0
 16.3598 ++#define isnan(x) 0
 16.3599 ++#define isinf(x) 0
 16.3600 ++#else
 16.3601 ++
 16.3602 ++#if   defined L_thenan_sf
 16.3603 ++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.3604 ++#elif defined L_thenan_df
 16.3605 ++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.3606 ++#elif defined L_thenan_tf
 16.3607 ++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.3608 ++#elif defined TFLOAT
 16.3609 ++extern const fp_number_type __thenan_tf;
 16.3610 ++#elif defined FLOAT
 16.3611 ++extern const fp_number_type __thenan_sf;
 16.3612 ++#else
 16.3613 ++extern const fp_number_type __thenan_df;
 16.3614 ++#endif
 16.3615 ++
 16.3616 ++INLINE
 16.3617 ++static fp_number_type *
 16.3618 ++nan (void)
 16.3619 ++{
 16.3620 ++  /* Discard the const qualifier...  */
 16.3621 ++#ifdef TFLOAT
 16.3622 ++  return (fp_number_type *) (& __thenan_tf);
 16.3623 ++#elif defined FLOAT  
 16.3624 ++  return (fp_number_type *) (& __thenan_sf);
 16.3625 ++#else
 16.3626 ++  return (fp_number_type *) (& __thenan_df);
 16.3627 ++#endif
 16.3628 ++}
 16.3629 ++
 16.3630 ++INLINE
 16.3631 ++static int
 16.3632 ++isnan ( fp_number_type *  x)
 16.3633 ++{
 16.3634 ++  return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
 16.3635 ++}
 16.3636 ++
 16.3637 ++INLINE
 16.3638 ++static int
 16.3639 ++isinf ( fp_number_type *  x)
 16.3640 ++{
 16.3641 ++  return x->class == CLASS_INFINITY;
 16.3642 ++}
 16.3643 ++
 16.3644 ++#endif /* NO_NANS */
 16.3645 ++
 16.3646 ++INLINE
 16.3647 ++static int
 16.3648 ++iszero ( fp_number_type *  x)
 16.3649 ++{
 16.3650 ++  return x->class == CLASS_ZERO;
 16.3651 ++}
 16.3652 ++
 16.3653 ++INLINE 
 16.3654 ++static void
 16.3655 ++flip_sign ( fp_number_type *  x)
 16.3656 ++{
 16.3657 ++  x->sign = !x->sign;
 16.3658 ++}
 16.3659 ++
 16.3660 ++extern FLO_type pack_d ( fp_number_type * );
 16.3661 ++
 16.3662 ++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
 16.3663 ++FLO_type
 16.3664 ++pack_d ( fp_number_type *  src)
 16.3665 ++{
 16.3666 ++  FLO_union_type dst;
 16.3667 ++  fractype fraction = src->fraction.ll;	/* wasn't unsigned before? */
 16.3668 ++  int sign = src->sign;
 16.3669 ++  int exp = 0;
 16.3670 ++
 16.3671 ++  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
 16.3672 ++    {
 16.3673 ++      /* We can't represent these values accurately.  By using the
 16.3674 ++	 largest possible magnitude, we guarantee that the conversion
 16.3675 ++	 of infinity is at least as big as any finite number.  */
 16.3676 ++      exp = EXPMAX;
 16.3677 ++      fraction = ((fractype) 1 << FRACBITS) - 1;
 16.3678 ++    }
 16.3679 ++  else if (isnan (src))
 16.3680 ++    {
 16.3681 ++      exp = EXPMAX;
 16.3682 ++      if (src->class == CLASS_QNAN || 1)
 16.3683 ++	{
 16.3684 ++#ifdef QUIET_NAN_NEGATED
 16.3685 ++	  fraction |= QUIET_NAN - 1;
 16.3686 ++#else
 16.3687 ++	  fraction |= QUIET_NAN;
 16.3688 ++#endif
 16.3689 ++	}
 16.3690 ++    }
 16.3691 ++  else if (isinf (src))
 16.3692 ++    {
 16.3693 ++      exp = EXPMAX;
 16.3694 ++      fraction = 0;
 16.3695 ++    }
 16.3696 ++  else if (iszero (src))
 16.3697 ++    {
 16.3698 ++      exp = 0;
 16.3699 ++      fraction = 0;
 16.3700 ++    }
 16.3701 ++  else if (fraction == 0)
 16.3702 ++    {
 16.3703 ++      exp = 0;
 16.3704 ++    }
 16.3705 ++  else
 16.3706 ++    {
 16.3707 ++      if (src->normal_exp < NORMAL_EXPMIN)
 16.3708 ++	{
 16.3709 ++#ifdef NO_DENORMALS
 16.3710 ++	  /* Go straight to a zero representation if denormals are not
 16.3711 ++ 	     supported.  The denormal handling would be harmless but
 16.3712 ++ 	     isn't unnecessary.  */
 16.3713 ++	  exp = 0;
 16.3714 ++	  fraction = 0;
 16.3715 ++#else /* NO_DENORMALS */
 16.3716 ++	  /* This number's exponent is too low to fit into the bits
 16.3717 ++	     available in the number, so we'll store 0 in the exponent and
 16.3718 ++	     shift the fraction to the right to make up for it.  */
 16.3719 ++
 16.3720 ++	  int shift = NORMAL_EXPMIN - src->normal_exp;
 16.3721 ++
 16.3722 ++	  exp = 0;
 16.3723 ++
 16.3724 ++	  if (shift > FRAC_NBITS - NGARDS)
 16.3725 ++	    {
 16.3726 ++	      /* No point shifting, since it's more that 64 out.  */
 16.3727 ++	      fraction = 0;
 16.3728 ++	    }
 16.3729 ++	  else
 16.3730 ++	    {
 16.3731 ++	      int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
 16.3732 ++	      fraction = (fraction >> shift) | lowbit;
 16.3733 ++	    }
 16.3734 ++	  if ((fraction & GARDMASK) == GARDMSB)
 16.3735 ++	    {
 16.3736 ++	      if ((fraction & (1 << NGARDS)))
 16.3737 ++		fraction += GARDROUND + 1;
 16.3738 ++	    }
 16.3739 ++	  else
 16.3740 ++	    {
 16.3741 ++	      /* Add to the guards to round up.  */
 16.3742 ++	      fraction += GARDROUND;
 16.3743 ++	    }
 16.3744 ++	  /* Perhaps the rounding means we now need to change the
 16.3745 ++             exponent, because the fraction is no longer denormal.  */
 16.3746 ++	  if (fraction >= IMPLICIT_1)
 16.3747 ++	    {
 16.3748 ++	      exp += 1;
 16.3749 ++	    }
 16.3750 ++	  fraction >>= NGARDS;
 16.3751 ++#endif /* NO_DENORMALS */
 16.3752 ++	}
 16.3753 ++      else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
 16.3754 ++	       && src->normal_exp > EXPBIAS)
 16.3755 ++	{
 16.3756 ++	  exp = EXPMAX;
 16.3757 ++	  fraction = 0;
 16.3758 ++	}
 16.3759 ++      else
 16.3760 ++	{
 16.3761 ++	  exp = src->normal_exp + EXPBIAS;
 16.3762 ++	  if (!ROUND_TOWARDS_ZERO)
 16.3763 ++	    {
 16.3764 ++	      /* IF the gard bits are the all zero, but the first, then we're
 16.3765 ++		 half way between two numbers, choose the one which makes the
 16.3766 ++		 lsb of the answer 0.  */
 16.3767 ++	      if ((fraction & GARDMASK) == GARDMSB)
 16.3768 ++		{
 16.3769 ++		  if (fraction & (1 << NGARDS))
 16.3770 ++		    fraction += GARDROUND + 1;
 16.3771 ++		}
 16.3772 ++	      else
 16.3773 ++		{
 16.3774 ++		  /* Add a one to the guards to round up */
 16.3775 ++		  fraction += GARDROUND;
 16.3776 ++		}
 16.3777 ++	      if (fraction >= IMPLICIT_2)
 16.3778 ++		{
 16.3779 ++		  fraction >>= 1;
 16.3780 ++		  exp += 1;
 16.3781 ++		}
 16.3782 ++	    }
 16.3783 ++	  fraction >>= NGARDS;
 16.3784 ++
 16.3785 ++	  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
 16.3786 ++	    {
 16.3787 ++	      /* Saturate on overflow.  */
 16.3788 ++	      exp = EXPMAX;
 16.3789 ++	      fraction = ((fractype) 1 << FRACBITS) - 1;
 16.3790 ++	    }
 16.3791 ++	}
 16.3792 ++    }
 16.3793 ++
 16.3794 ++  /* We previously used bitfields to store the number, but this doesn't
 16.3795 ++     handle little/big endian systems conveniently, so use shifts and
 16.3796 ++     masks */
 16.3797 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
 16.3798 ++  dst.bits.fraction = fraction;
 16.3799 ++  dst.bits.exp = exp;
 16.3800 ++  dst.bits.sign = sign;
 16.3801 ++#else
 16.3802 ++# if defined TFLOAT && defined HALFFRACBITS
 16.3803 ++ {
 16.3804 ++   halffractype high, low, unity;
 16.3805 ++   int lowsign, lowexp;
 16.3806 ++
 16.3807 ++   unity = (halffractype) 1 << HALFFRACBITS;
 16.3808 ++
 16.3809 ++   /* Set HIGH to the high double's significand, masking out the implicit 1.
 16.3810 ++      Set LOW to the low double's full significand.  */
 16.3811 ++   high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
 16.3812 ++   low = fraction & (unity * 2 - 1);
 16.3813 ++
 16.3814 ++   /* Get the initial sign and exponent of the low double.  */
 16.3815 ++   lowexp = exp - HALFFRACBITS - 1;
 16.3816 ++   lowsign = sign;
 16.3817 ++
 16.3818 ++   /* HIGH should be rounded like a normal double, making |LOW| <=
 16.3819 ++      0.5 ULP of HIGH.  Assume round-to-nearest.  */
 16.3820 ++   if (exp < EXPMAX)
 16.3821 ++     if (low > unity || (low == unity && (high & 1) == 1))
 16.3822 ++       {
 16.3823 ++	 /* Round HIGH up and adjust LOW to match.  */
 16.3824 ++	 high++;
 16.3825 ++	 if (high == unity)
 16.3826 ++	   {
 16.3827 ++	     /* May make it infinite, but that's OK.  */
 16.3828 ++	     high = 0;
 16.3829 ++	     exp++;
 16.3830 ++	   }
 16.3831 ++	 low = unity * 2 - low;
 16.3832 ++	 lowsign ^= 1;
 16.3833 ++       }
 16.3834 ++
 16.3835 ++   high |= (halffractype) exp << HALFFRACBITS;
 16.3836 ++   high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
 16.3837 ++
 16.3838 ++   if (exp == EXPMAX || exp == 0 || low == 0)
 16.3839 ++     low = 0;
 16.3840 ++   else
 16.3841 ++     {
 16.3842 ++       while (lowexp > 0 && low < unity)
 16.3843 ++	 {
 16.3844 ++	   low <<= 1;
 16.3845 ++	   lowexp--;
 16.3846 ++	 }
 16.3847 ++
 16.3848 ++       if (lowexp <= 0)
 16.3849 ++	 {
 16.3850 ++	   halffractype roundmsb, round;
 16.3851 ++	   int shift;
 16.3852 ++
 16.3853 ++	   shift = 1 - lowexp;
 16.3854 ++	   roundmsb = (1 << (shift - 1));
 16.3855 ++	   round = low & ((roundmsb << 1) - 1);
 16.3856 ++
 16.3857 ++	   low >>= shift;
 16.3858 ++	   lowexp = 0;
 16.3859 ++
 16.3860 ++	   if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
 16.3861 ++	     {
 16.3862 ++	       low++;
 16.3863 ++	       if (low == unity)
 16.3864 ++		 /* LOW rounds up to the smallest normal number.  */
 16.3865 ++		 lowexp++;
 16.3866 ++	     }
 16.3867 ++	 }
 16.3868 ++
 16.3869 ++       low &= unity - 1;
 16.3870 ++       low |= (halffractype) lowexp << HALFFRACBITS;
 16.3871 ++       low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
 16.3872 ++     }
 16.3873 ++   dst.value_raw = ((fractype) high << HALFSHIFT) | low;
 16.3874 ++ }
 16.3875 ++# else
 16.3876 ++  dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
 16.3877 ++  dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
 16.3878 ++  dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
 16.3879 ++# endif
 16.3880 ++#endif
 16.3881 ++
 16.3882 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
 16.3883 ++#ifdef TFLOAT
 16.3884 ++  {
 16.3885 ++    qrtrfractype tmp1 = dst.words[0];
 16.3886 ++    qrtrfractype tmp2 = dst.words[1];
 16.3887 ++    dst.words[0] = dst.words[3];
 16.3888 ++    dst.words[1] = dst.words[2];
 16.3889 ++    dst.words[2] = tmp2;
 16.3890 ++    dst.words[3] = tmp1;
 16.3891 ++  }
 16.3892 ++#else
 16.3893 ++  {
 16.3894 ++    halffractype tmp = dst.words[0];
 16.3895 ++    dst.words[0] = dst.words[1];
 16.3896 ++    dst.words[1] = tmp;
 16.3897 ++  }
 16.3898 ++#endif
 16.3899 ++#endif
 16.3900 ++
 16.3901 ++  return dst.value;
 16.3902 ++}
 16.3903 ++#endif
 16.3904 ++
 16.3905 ++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
 16.3906 ++void
 16.3907 ++unpack_d (FLO_union_type * src, fp_number_type * dst)
 16.3908 ++{
 16.3909 ++  /* We previously used bitfields to store the number, but this doesn't
 16.3910 ++     handle little/big endian systems conveniently, so use shifts and
 16.3911 ++     masks */
 16.3912 ++  fractype fraction;
 16.3913 ++  int exp;
 16.3914 ++  int sign;
 16.3915 ++
 16.3916 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
 16.3917 ++  FLO_union_type swapped;
 16.3918 ++
 16.3919 ++#ifdef TFLOAT
 16.3920 ++  swapped.words[0] = src->words[3];
 16.3921 ++  swapped.words[1] = src->words[2];
 16.3922 ++  swapped.words[2] = src->words[1];
 16.3923 ++  swapped.words[3] = src->words[0];
 16.3924 ++#else
 16.3925 ++  swapped.words[0] = src->words[1];
 16.3926 ++  swapped.words[1] = src->words[0];
 16.3927 ++#endif
 16.3928 ++  src = &swapped;
 16.3929 ++#endif
 16.3930 ++  
 16.3931 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
 16.3932 ++  fraction = src->bits.fraction;
 16.3933 ++  exp = src->bits.exp;
 16.3934 ++  sign = src->bits.sign;
 16.3935 ++#else
 16.3936 ++# if defined TFLOAT && defined HALFFRACBITS
 16.3937 ++ {
 16.3938 ++   halffractype high, low;
 16.3939 ++   
 16.3940 ++   high = src->value_raw >> HALFSHIFT;
 16.3941 ++   low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
 16.3942 ++
 16.3943 ++   fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
 16.3944 ++   fraction <<= FRACBITS - HALFFRACBITS;
 16.3945 ++   exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
 16.3946 ++   sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
 16.3947 ++
 16.3948 ++   if (exp != EXPMAX && exp != 0 && low != 0)
 16.3949 ++     {
 16.3950 ++       int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
 16.3951 ++       int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
 16.3952 ++       int shift;
 16.3953 ++       fractype xlow;
 16.3954 ++
 16.3955 ++       xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
 16.3956 ++       if (lowexp)
 16.3957 ++	 xlow |= (((halffractype)1) << HALFFRACBITS);
 16.3958 ++       else
 16.3959 ++	 lowexp = 1;
 16.3960 ++       shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
 16.3961 ++       if (shift > 0)
 16.3962 ++	 xlow <<= shift;
 16.3963 ++       else if (shift < 0)
 16.3964 ++	 xlow >>= -shift;
 16.3965 ++       if (sign == lowsign)
 16.3966 ++	 fraction += xlow;
 16.3967 ++       else if (fraction >= xlow)
 16.3968 ++	 fraction -= xlow;
 16.3969 ++       else
 16.3970 ++	 {
 16.3971 ++	   /* The high part is a power of two but the full number is lower.
 16.3972 ++	      This code will leave the implicit 1 in FRACTION, but we'd
 16.3973 ++	      have added that below anyway.  */
 16.3974 ++	   fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
 16.3975 ++	   exp--;
 16.3976 ++	 }
 16.3977 ++     }
 16.3978 ++ }
 16.3979 ++# else
 16.3980 ++  fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
 16.3981 ++  exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
 16.3982 ++  sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
 16.3983 ++# endif
 16.3984 ++#endif
 16.3985 ++
 16.3986 ++  dst->sign = sign;
 16.3987 ++  if (exp == 0)
 16.3988 ++    {
 16.3989 ++      /* Hmm.  Looks like 0 */
 16.3990 ++      if (fraction == 0
 16.3991 ++#ifdef NO_DENORMALS
 16.3992 ++	  || 1
 16.3993 ++#endif
 16.3994 ++	  )
 16.3995 ++	{
 16.3996 ++	  /* tastes like zero */
 16.3997 ++	  dst->class = CLASS_ZERO;
 16.3998 ++	}
 16.3999 ++      else
 16.4000 ++	{
 16.4001 ++	  /* Zero exponent with nonzero fraction - it's denormalized,
 16.4002 ++	     so there isn't a leading implicit one - we'll shift it so
 16.4003 ++	     it gets one.  */
 16.4004 ++	  dst->normal_exp = exp - EXPBIAS + 1;
 16.4005 ++	  fraction <<= NGARDS;
 16.4006 ++
 16.4007 ++	  dst->class = CLASS_NUMBER;
 16.4008 ++#if 1
 16.4009 ++	  while (fraction < IMPLICIT_1)
 16.4010 ++	    {
 16.4011 ++	      fraction <<= 1;
 16.4012 ++	      dst->normal_exp--;
 16.4013 ++	    }
 16.4014 ++#endif
 16.4015 ++	  dst->fraction.ll = fraction;
 16.4016 ++	}
 16.4017 ++    }
 16.4018 ++  else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
 16.4019 ++    {
 16.4020 ++      /* Huge exponent*/
 16.4021 ++      if (fraction == 0)
 16.4022 ++	{
 16.4023 ++	  /* Attached to a zero fraction - means infinity */
 16.4024 ++	  dst->class = CLASS_INFINITY;
 16.4025 ++	}
 16.4026 ++      else
 16.4027 ++	{
 16.4028 ++	  /* Nonzero fraction, means nan */
 16.4029 ++#ifdef QUIET_NAN_NEGATED
 16.4030 ++	  if ((fraction & QUIET_NAN) == 0)
 16.4031 ++#else
 16.4032 ++	  if (fraction & QUIET_NAN)
 16.4033 ++#endif
 16.4034 ++	    {
 16.4035 ++	      dst->class = CLASS_QNAN;
 16.4036 ++	    }
 16.4037 ++	  else
 16.4038 ++	    {
 16.4039 ++	      dst->class = CLASS_SNAN;
 16.4040 ++	    }
 16.4041 ++	  /* Keep the fraction part as the nan number */
 16.4042 ++	  dst->fraction.ll = fraction;
 16.4043 ++	}
 16.4044 ++    }
 16.4045 ++  else
 16.4046 ++    {
 16.4047 ++      /* Nothing strange about this number */
 16.4048 ++      dst->normal_exp = exp - EXPBIAS;
 16.4049 ++      dst->class = CLASS_NUMBER;
 16.4050 ++      dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
 16.4051 ++    }
 16.4052 ++}
 16.4053 ++#endif /* L_unpack_df || L_unpack_sf */
 16.4054 ++
 16.4055 ++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
 16.4056 ++static fp_number_type *
 16.4057 ++_fpadd_parts (fp_number_type * a,
 16.4058 ++	      fp_number_type * b,
 16.4059 ++	      fp_number_type * tmp)
 16.4060 ++{
 16.4061 ++  intfrac tfraction;
 16.4062 ++
 16.4063 ++  /* Put commonly used fields in local variables.  */
 16.4064 ++  int a_normal_exp;
 16.4065 ++  int b_normal_exp;
 16.4066 ++  fractype a_fraction;
 16.4067 ++  fractype b_fraction;
 16.4068 ++
 16.4069 ++  if (isnan (a))
 16.4070 ++    {
 16.4071 ++      return a;
 16.4072 ++    }
 16.4073 ++  if (isnan (b))
 16.4074 ++    {
 16.4075 ++      return b;
 16.4076 ++    }
 16.4077 ++  if (isinf (a))
 16.4078 ++    {
 16.4079 ++      /* Adding infinities with opposite signs yields a NaN.  */
 16.4080 ++      if (isinf (b) && a->sign != b->sign)
 16.4081 ++	return nan ();
 16.4082 ++      return a;
 16.4083 ++    }
 16.4084 ++  if (isinf (b))
 16.4085 ++    {
 16.4086 ++      return b;
 16.4087 ++    }
 16.4088 ++  if (iszero (b))
 16.4089 ++    {
 16.4090 ++      if (iszero (a))
 16.4091 ++	{
 16.4092 ++	  *tmp = *a;
 16.4093 ++	  tmp->sign = a->sign & b->sign;
 16.4094 ++	  return tmp;
 16.4095 ++	}
 16.4096 ++      return a;
 16.4097 ++    }
 16.4098 ++  if (iszero (a))
 16.4099 ++    {
 16.4100 ++      return b;
 16.4101 ++    }
 16.4102 ++
 16.4103 ++  /* Got two numbers. shift the smaller and increment the exponent till
 16.4104 ++     they're the same */
 16.4105 ++  {
 16.4106 ++    int diff;
 16.4107 ++
 16.4108 ++    a_normal_exp = a->normal_exp;
 16.4109 ++    b_normal_exp = b->normal_exp;
 16.4110 ++    a_fraction = a->fraction.ll;
 16.4111 ++    b_fraction = b->fraction.ll;
 16.4112 ++
 16.4113 ++    diff = a_normal_exp - b_normal_exp;
 16.4114 ++
 16.4115 ++    if (diff < 0)
 16.4116 ++      diff = -diff;
 16.4117 ++    if (diff < FRAC_NBITS)
 16.4118 ++      {
 16.4119 ++	/* ??? This does shifts one bit at a time.  Optimize.  */
 16.4120 ++	while (a_normal_exp > b_normal_exp)
 16.4121 ++	  {
 16.4122 ++	    b_normal_exp++;
 16.4123 ++	    LSHIFT (b_fraction);
 16.4124 ++	  }
 16.4125 ++	while (b_normal_exp > a_normal_exp)
 16.4126 ++	  {
 16.4127 ++	    a_normal_exp++;
 16.4128 ++	    LSHIFT (a_fraction);
 16.4129 ++	  }
 16.4130 ++      }
 16.4131 ++    else
 16.4132 ++      {
 16.4133 ++	/* Somethings's up.. choose the biggest */
 16.4134 ++	if (a_normal_exp > b_normal_exp)
 16.4135 ++	  {
 16.4136 ++	    b_normal_exp = a_normal_exp;
 16.4137 ++	    b_fraction = 0;
 16.4138 ++	  }
 16.4139 ++	else
 16.4140 ++	  {
 16.4141 ++	    a_normal_exp = b_normal_exp;
 16.4142 ++	    a_fraction = 0;
 16.4143 ++	  }
 16.4144 ++      }
 16.4145 ++  }
 16.4146 ++
 16.4147 ++  if (a->sign != b->sign)
 16.4148 ++    {
 16.4149 ++      if (a->sign)
 16.4150 ++	{
 16.4151 ++	  tfraction = -a_fraction + b_fraction;
 16.4152 ++	}
 16.4153 ++      else
 16.4154 ++	{
 16.4155 ++	  tfraction = a_fraction - b_fraction;
 16.4156 ++	}
 16.4157 ++      if (tfraction >= 0)
 16.4158 ++	{
 16.4159 ++	  tmp->sign = 0;
 16.4160 ++	  tmp->normal_exp = a_normal_exp;
 16.4161 ++	  tmp->fraction.ll = tfraction;
 16.4162 ++	}
 16.4163 ++      else
 16.4164 ++	{
 16.4165 ++	  tmp->sign = 1;
 16.4166 ++	  tmp->normal_exp = a_normal_exp;
 16.4167 ++	  tmp->fraction.ll = -tfraction;
 16.4168 ++	}
 16.4169 ++      /* and renormalize it */
 16.4170 ++
 16.4171 ++      while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
 16.4172 ++	{
 16.4173 ++	  tmp->fraction.ll <<= 1;
 16.4174 ++	  tmp->normal_exp--;
 16.4175 ++	}
 16.4176 ++    }
 16.4177 ++  else
 16.4178 ++    {
 16.4179 ++      tmp->sign = a->sign;
 16.4180 ++      tmp->normal_exp = a_normal_exp;
 16.4181 ++      tmp->fraction.ll = a_fraction + b_fraction;
 16.4182 ++    }
 16.4183 ++  tmp->class = CLASS_NUMBER;
 16.4184 ++  /* Now the fraction is added, we have to shift down to renormalize the
 16.4185 ++     number */
 16.4186 ++
 16.4187 ++  if (tmp->fraction.ll >= IMPLICIT_2)
 16.4188 ++    {
 16.4189 ++      LSHIFT (tmp->fraction.ll);
 16.4190 ++      tmp->normal_exp++;
 16.4191 ++    }
 16.4192 ++  return tmp;
 16.4193 ++
 16.4194 ++}
 16.4195 ++
 16.4196 ++FLO_type
 16.4197 ++add (FLO_type arg_a, FLO_type arg_b)
 16.4198 ++{
 16.4199 ++  fp_number_type a;
 16.4200 ++  fp_number_type b;
 16.4201 ++  fp_number_type tmp;
 16.4202 ++  fp_number_type *res;
 16.4203 ++  FLO_union_type au, bu;
 16.4204 ++
 16.4205 ++  au.value = arg_a;
 16.4206 ++  bu.value = arg_b;
 16.4207 ++
 16.4208 ++  unpack_d (&au, &a);
 16.4209 ++  unpack_d (&bu, &b);
 16.4210 ++
 16.4211 ++  res = _fpadd_parts (&a, &b, &tmp);
 16.4212 ++
 16.4213 ++  return pack_d (res);
 16.4214 ++}
 16.4215 ++
 16.4216 ++FLO_type
 16.4217 ++sub (FLO_type arg_a, FLO_type arg_b)
 16.4218 ++{
 16.4219 ++  fp_number_type a;
 16.4220 ++  fp_number_type b;
 16.4221 ++  fp_number_type tmp;
 16.4222 ++  fp_number_type *res;
 16.4223 ++  FLO_union_type au, bu;
 16.4224 ++
 16.4225 ++  au.value = arg_a;
 16.4226 ++  bu.value = arg_b;
 16.4227 ++
 16.4228 ++  unpack_d (&au, &a);
 16.4229 ++  unpack_d (&bu, &b);
 16.4230 ++
 16.4231 ++  b.sign ^= 1;
 16.4232 ++
 16.4233 ++  res = _fpadd_parts (&a, &b, &tmp);
 16.4234 ++
 16.4235 ++  return pack_d (res);
 16.4236 ++}
 16.4237 ++#endif /* L_addsub_sf || L_addsub_df */
 16.4238 ++
 16.4239 ++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
 16.4240 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
 16.4241 ++_fpmul_parts ( fp_number_type *  a,
 16.4242 ++	       fp_number_type *  b,
 16.4243 ++	       fp_number_type * tmp)
 16.4244 ++{
 16.4245 ++  fractype low = 0;
 16.4246 ++  fractype high = 0;
 16.4247 ++
 16.4248 ++  if (isnan (a))
 16.4249 ++    {
 16.4250 ++      a->sign = a->sign != b->sign;
 16.4251 ++      return a;
 16.4252 ++    }
 16.4253 ++  if (isnan (b))
 16.4254 ++    {
 16.4255 ++      b->sign = a->sign != b->sign;
 16.4256 ++      return b;
 16.4257 ++    }
 16.4258 ++  if (isinf (a))
 16.4259 ++    {
 16.4260 ++      if (iszero (b))
 16.4261 ++	return nan ();
 16.4262 ++      a->sign = a->sign != b->sign;
 16.4263 ++      return a;
 16.4264 ++    }
 16.4265 ++  if (isinf (b))
 16.4266 ++    {
 16.4267 ++      if (iszero (a))
 16.4268 ++	{
 16.4269 ++	  return nan ();
 16.4270 ++	}
 16.4271 ++      b->sign = a->sign != b->sign;
 16.4272 ++      return b;
 16.4273 ++    }
 16.4274 ++  if (iszero (a))
 16.4275 ++    {
 16.4276 ++      a->sign = a->sign != b->sign;
 16.4277 ++      return a;
 16.4278 ++    }
 16.4279 ++  if (iszero (b))
 16.4280 ++    {
 16.4281 ++      b->sign = a->sign != b->sign;
 16.4282 ++      return b;
 16.4283 ++    }
 16.4284 ++
 16.4285 ++  /* Calculate the mantissa by multiplying both numbers to get a
 16.4286 ++     twice-as-wide number.  */
 16.4287 ++  {
 16.4288 ++#if defined(NO_DI_MODE) || defined(TFLOAT)
 16.4289 ++    {
 16.4290 ++      fractype x = a->fraction.ll;
 16.4291 ++      fractype ylow = b->fraction.ll;
 16.4292 ++      fractype yhigh = 0;
 16.4293 ++      int bit;
 16.4294 ++
 16.4295 ++      /* ??? This does multiplies one bit at a time.  Optimize.  */
 16.4296 ++      for (bit = 0; bit < FRAC_NBITS; bit++)
 16.4297 ++	{
 16.4298 ++	  int carry;
 16.4299 ++
 16.4300 ++	  if (x & 1)
 16.4301 ++	    {
 16.4302 ++	      carry = (low += ylow) < ylow;
 16.4303 ++	      high += yhigh + carry;
 16.4304 ++	    }
 16.4305 ++	  yhigh <<= 1;
 16.4306 ++	  if (ylow & FRACHIGH)
 16.4307 ++	    {
 16.4308 ++	      yhigh |= 1;
 16.4309 ++	    }
 16.4310 ++	  ylow <<= 1;
 16.4311 ++	  x >>= 1;
 16.4312 ++	}
 16.4313 ++    }
 16.4314 ++#elif defined(FLOAT) 
 16.4315 ++    /* Multiplying two USIs to get a UDI, we're safe.  */
 16.4316 ++    {
 16.4317 ++      UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
 16.4318 ++      
 16.4319 ++      high = answer >> BITS_PER_SI;
 16.4320 ++      low = answer;
 16.4321 ++    }
 16.4322 ++#else
 16.4323 ++    /* fractype is DImode, but we need the result to be twice as wide.
 16.4324 ++       Assuming a widening multiply from DImode to TImode is not
 16.4325 ++       available, build one by hand.  */
 16.4326 ++    {
 16.4327 ++      USItype nl = a->fraction.ll;
 16.4328 ++      USItype nh = a->fraction.ll >> BITS_PER_SI;
 16.4329 ++      USItype ml = b->fraction.ll;
 16.4330 ++      USItype mh = b->fraction.ll >> BITS_PER_SI;
 16.4331 ++      UDItype pp_ll = (UDItype) ml * nl;
 16.4332 ++      UDItype pp_hl = (UDItype) mh * nl;
 16.4333 ++      UDItype pp_lh = (UDItype) ml * nh;
 16.4334 ++      UDItype pp_hh = (UDItype) mh * nh;
 16.4335 ++      UDItype res2 = 0;
 16.4336 ++      UDItype res0 = 0;
 16.4337 ++      UDItype ps_hh__ = pp_hl + pp_lh;
 16.4338 ++      if (ps_hh__ < pp_hl)
 16.4339 ++	res2 += (UDItype)1 << BITS_PER_SI;
 16.4340 ++      pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
 16.4341 ++      res0 = pp_ll + pp_hl;
 16.4342 ++      if (res0 < pp_ll)
 16.4343 ++	res2++;
 16.4344 ++      res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
 16.4345 ++      high = res2;
 16.4346 ++      low = res0;
 16.4347 ++    }
 16.4348 ++#endif
 16.4349 ++  }
 16.4350 ++
 16.4351 ++  tmp->normal_exp = a->normal_exp + b->normal_exp
 16.4352 ++    + FRAC_NBITS - (FRACBITS + NGARDS);
 16.4353 ++  tmp->sign = a->sign != b->sign;
 16.4354 ++  while (high >= IMPLICIT_2)
 16.4355 ++    {
 16.4356 ++      tmp->normal_exp++;
 16.4357 ++      if (high & 1)
 16.4358 ++	{
 16.4359 ++	  low >>= 1;
 16.4360 ++	  low |= FRACHIGH;
 16.4361 ++	}
 16.4362 ++      high >>= 1;
 16.4363 ++    }
 16.4364 ++  while (high < IMPLICIT_1)
 16.4365 ++    {
 16.4366 ++      tmp->normal_exp--;
 16.4367 ++
 16.4368 ++      high <<= 1;
 16.4369 ++      if (low & FRACHIGH)
 16.4370 ++	high |= 1;
 16.4371 ++      low <<= 1;
 16.4372 ++    }
 16.4373 ++  /* rounding is tricky. if we only round if it won't make us round later.  */
 16.4374 ++#if 0
 16.4375 ++  if (low & FRACHIGH2)
 16.4376 ++    {
 16.4377 ++      if (((high & GARDMASK) != GARDMSB)
 16.4378 ++	  && (((high + 1) & GARDMASK) == GARDMSB))
 16.4379 ++	{
 16.4380 ++	  /* don't round, it gets done again later.  */
 16.4381 ++	}
 16.4382 ++      else
 16.4383 ++	{
 16.4384 ++	  high++;
 16.4385 ++	}
 16.4386 ++    }
 16.4387 ++#endif
 16.4388 ++  if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
 16.4389 ++    {
 16.4390 ++      if (high & (1 << NGARDS))
 16.4391 ++	{
 16.4392 ++	  /* half way, so round to even */
 16.4393 ++	  high += GARDROUND + 1;
 16.4394 ++	}
 16.4395 ++      else if (low)
 16.4396 ++	{
 16.4397 ++	  /* but we really weren't half way */
 16.4398 ++	  high += GARDROUND + 1;
 16.4399 ++	}
 16.4400 ++    }
 16.4401 ++  tmp->fraction.ll = high;
 16.4402 ++  tmp->class = CLASS_NUMBER;
 16.4403 ++  return tmp;
 16.4404 ++}
 16.4405 ++
 16.4406 ++FLO_type
 16.4407 ++multiply (FLO_type arg_a, FLO_type arg_b)
 16.4408 ++{
 16.4409 ++  fp_number_type a;
 16.4410 ++  fp_number_type b;
 16.4411 ++  fp_number_type tmp;
 16.4412 ++  fp_number_type *res;
 16.4413 ++  FLO_union_type au, bu;
 16.4414 ++
 16.4415 ++  au.value = arg_a;
 16.4416 ++  bu.value = arg_b;
 16.4417 ++
 16.4418 ++  unpack_d (&au, &a);
 16.4419 ++  unpack_d (&bu, &b);
 16.4420 ++
 16.4421 ++  res = _fpmul_parts (&a, &b, &tmp);
 16.4422 ++
 16.4423 ++  return pack_d (res);
 16.4424 ++}
 16.4425 ++#endif /* L_mul_sf || L_mul_df */
 16.4426 ++
 16.4427 ++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
 16.4428 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
 16.4429 ++_fpdiv_parts (fp_number_type * a,
 16.4430 ++	      fp_number_type * b)
 16.4431 ++{
 16.4432 ++  fractype bit;
 16.4433 ++  fractype numerator;
 16.4434 ++  fractype denominator;
 16.4435 ++  fractype quotient;
 16.4436 ++
 16.4437 ++  if (isnan (a))
 16.4438 ++    {
 16.4439 ++      return a;
 16.4440 ++    }
 16.4441 ++  if (isnan (b))
 16.4442 ++    {
 16.4443 ++      return b;
 16.4444 ++    }
 16.4445 ++
 16.4446 ++  a->sign = a->sign ^ b->sign;
 16.4447 ++
 16.4448 ++  if (isinf (a) || iszero (a))
 16.4449 ++    {
 16.4450 ++      if (a->class == b->class)
 16.4451 ++	return nan ();
 16.4452 ++      return a;
 16.4453 ++    }
 16.4454 ++
 16.4455 ++  if (isinf (b))
 16.4456 ++    {
 16.4457 ++      a->fraction.ll = 0;
 16.4458 ++      a->normal_exp = 0;
 16.4459 ++      return a;
 16.4460 ++    }
 16.4461 ++  if (iszero (b))
 16.4462 ++    {
 16.4463 ++      a->class = CLASS_INFINITY;
 16.4464 ++      return a;
 16.4465 ++    }
 16.4466 ++
 16.4467 ++  /* Calculate the mantissa by multiplying both 64bit numbers to get a
 16.4468 ++     128 bit number */
 16.4469 ++  {
 16.4470 ++    /* quotient =
 16.4471 ++       ( numerator / denominator) * 2^(numerator exponent -  denominator exponent)
 16.4472 ++     */
 16.4473 ++
 16.4474 ++    a->normal_exp = a->normal_exp - b->normal_exp;
 16.4475 ++    numerator = a->fraction.ll;
 16.4476 ++    denominator = b->fraction.ll;
 16.4477 ++
 16.4478 ++    if (numerator < denominator)
 16.4479 ++      {
 16.4480 ++	/* Fraction will be less than 1.0 */
 16.4481 ++	numerator *= 2;
 16.4482 ++	a->normal_exp--;
 16.4483 ++      }
 16.4484 ++    bit = IMPLICIT_1;
 16.4485 ++    quotient = 0;
 16.4486 ++    /* ??? Does divide one bit at a time.  Optimize.  */
 16.4487 ++    while (bit)
 16.4488 ++      {
 16.4489 ++	if (numerator >= denominator)
 16.4490 ++	  {
 16.4491 ++	    quotient |= bit;
 16.4492 ++	    numerator -= denominator;
 16.4493 ++	  }
 16.4494 ++	bit >>= 1;
 16.4495 ++	numerator *= 2;
 16.4496 ++      }
 16.4497 ++
 16.4498 ++    if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
 16.4499 ++      {
 16.4500 ++	if (quotient & (1 << NGARDS))
 16.4501 ++	  {
 16.4502 ++	    /* half way, so round to even */
 16.4503 ++	    quotient += GARDROUND + 1;
 16.4504 ++	  }
 16.4505 ++	else if (numerator)
 16.4506 ++	  {
 16.4507 ++	    /* but we really weren't half way, more bits exist */
 16.4508 ++	    quotient += GARDROUND + 1;
 16.4509 ++	  }
 16.4510 ++      }
 16.4511 ++
 16.4512 ++    a->fraction.ll = quotient;
 16.4513 ++    return (a);
 16.4514 ++  }
 16.4515 ++}
 16.4516 ++
 16.4517 ++FLO_type
 16.4518 ++divide (FLO_type arg_a, FLO_type arg_b)
 16.4519 ++{
 16.4520 ++  fp_number_type a;
 16.4521 ++  fp_number_type b;
 16.4522 ++  fp_number_type *res;
 16.4523 ++  FLO_union_type au, bu;
 16.4524 ++
 16.4525 ++  au.value = arg_a;
 16.4526 ++  bu.value = arg_b;
 16.4527 ++
 16.4528 ++  unpack_d (&au, &a);
 16.4529 ++  unpack_d (&bu, &b);
 16.4530 ++
 16.4531 ++  res = _fpdiv_parts (&a, &b);
 16.4532 ++
 16.4533 ++  return pack_d (res);
 16.4534 ++}
 16.4535 ++#endif /* L_div_sf || L_div_df */
 16.4536 ++
 16.4537 ++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
 16.4538 ++    || defined(L_fpcmp_parts_tf)
 16.4539 ++/* according to the demo, fpcmp returns a comparison with 0... thus
 16.4540 ++   a<b -> -1
 16.4541 ++   a==b -> 0
 16.4542 ++   a>b -> +1
 16.4543 ++ */
 16.4544 ++
 16.4545 ++int
 16.4546 ++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
 16.4547 ++{
 16.4548 ++#if 0
 16.4549 ++  /* either nan -> unordered. Must be checked outside of this routine.  */
 16.4550 ++  if (isnan (a) && isnan (b))
 16.4551 ++    {
 16.4552 ++      return 1;			/* still unordered! */
 16.4553 ++    }
 16.4554 ++#endif
 16.4555 ++
 16.4556 ++  if (isnan (a) || isnan (b))
 16.4557 ++    {
 16.4558 ++      return 1;			/* how to indicate unordered compare? */
 16.4559 ++    }
 16.4560 ++  if (isinf (a) && isinf (b))
 16.4561 ++    {
 16.4562 ++      /* +inf > -inf, but +inf != +inf */
 16.4563 ++      /* b    \a| +inf(0)| -inf(1)
 16.4564 ++       ______\+--------+--------
 16.4565 ++       +inf(0)| a==b(0)| a<b(-1)
 16.4566 ++       -------+--------+--------
 16.4567 ++       -inf(1)| a>b(1) | a==b(0)
 16.4568 ++       -------+--------+--------
 16.4569 ++       So since unordered must be nonzero, just line up the columns...
 16.4570 ++       */
 16.4571 ++      return b->sign - a->sign;
 16.4572 ++    }
 16.4573 ++  /* but not both...  */
 16.4574 ++  if (isinf (a))
 16.4575 ++    {
 16.4576 ++      return a->sign ? -1 : 1;
 16.4577 ++    }
 16.4578 ++  if (isinf (b))
 16.4579 ++    {
 16.4580 ++      return b->sign ? 1 : -1;
 16.4581 ++    }
 16.4582 ++  if (iszero (a) && iszero (b))
 16.4583 ++    {
 16.4584 ++      return 0;
 16.4585 ++    }
 16.4586 ++  if (iszero (a))
 16.4587 ++    {
 16.4588 ++      return b->sign ? 1 : -1;
 16.4589 ++    }
 16.4590 ++  if (iszero (b))
 16.4591 ++    {
 16.4592 ++      return a->sign ? -1 : 1;
 16.4593 ++    }
 16.4594 ++  /* now both are "normal".  */
 16.4595 ++  if (a->sign != b->sign)
 16.4596 ++    {
 16.4597 ++      /* opposite signs */
 16.4598 ++      return a->sign ? -1 : 1;
 16.4599 ++    }
 16.4600 ++  /* same sign; exponents? */
 16.4601 ++  if (a->normal_exp > b->normal_exp)
 16.4602 ++    {
 16.4603 ++      return a->sign ? -1 : 1;
 16.4604 ++    }
 16.4605 ++  if (a->normal_exp < b->normal_exp)
 16.4606 ++    {
 16.4607 ++      return a->sign ? 1 : -1;
 16.4608 ++    }
 16.4609 ++  /* same exponents; check size.  */
 16.4610 ++  if (a->fraction.ll > b->fraction.ll)
 16.4611 ++    {
 16.4612 ++      return a->sign ? -1 : 1;
 16.4613 ++    }
 16.4614 ++  if (a->fraction.ll < b->fraction.ll)
 16.4615 ++    {
 16.4616 ++      return a->sign ? 1 : -1;
 16.4617 ++    }
 16.4618 ++  /* after all that, they're equal.  */
 16.4619 ++  return 0;
 16.4620 ++}
 16.4621 ++#endif
 16.4622 ++
 16.4623 ++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
 16.4624 ++CMPtype
 16.4625 ++compare (FLO_type arg_a, FLO_type arg_b)
 16.4626 ++{
 16.4627 ++  fp_number_type a;
 16.4628 ++  fp_number_type b;
 16.4629 ++  FLO_union_type au, bu;
 16.4630 ++
 16.4631 ++  au.value = arg_a;
 16.4632 ++  bu.value = arg_b;
 16.4633 ++
 16.4634 ++  unpack_d (&au, &a);
 16.4635 ++  unpack_d (&bu, &b);
 16.4636 ++
 16.4637 ++  return __fpcmp_parts (&a, &b);
 16.4638 ++}
 16.4639 ++#endif /* L_compare_sf || L_compare_df */
 16.4640 ++
 16.4641 ++#ifndef US_SOFTWARE_GOFAST
 16.4642 ++
 16.4643 ++/* These should be optimized for their specific tasks someday.  */
 16.4644 ++
 16.4645 ++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
 16.4646 ++CMPtype
 16.4647 ++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4648 ++{
 16.4649 ++  fp_number_type a;
 16.4650 ++  fp_number_type b;
 16.4651 ++  FLO_union_type au, bu;
 16.4652 ++
 16.4653 ++  au.value = arg_a;
 16.4654 ++  bu.value = arg_b;
 16.4655 ++
 16.4656 ++  unpack_d (&au, &a);
 16.4657 ++  unpack_d (&bu, &b);
 16.4658 ++
 16.4659 ++  if (isnan (&a) || isnan (&b))
 16.4660 ++    return 1;			/* false, truth == 0 */
 16.4661 ++
 16.4662 ++  return __fpcmp_parts (&a, &b) ;
 16.4663 ++}
 16.4664 ++#endif /* L_eq_sf || L_eq_df */
 16.4665 ++
 16.4666 ++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
 16.4667 ++CMPtype
 16.4668 ++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4669 ++{
 16.4670 ++  fp_number_type a;
 16.4671 ++  fp_number_type b;
 16.4672 ++  FLO_union_type au, bu;
 16.4673 ++
 16.4674 ++  au.value = arg_a;
 16.4675 ++  bu.value = arg_b;
 16.4676 ++
 16.4677 ++  unpack_d (&au, &a);
 16.4678 ++  unpack_d (&bu, &b);
 16.4679 ++
 16.4680 ++  if (isnan (&a) || isnan (&b))
 16.4681 ++    return 1;			/* true, truth != 0 */
 16.4682 ++
 16.4683 ++  return  __fpcmp_parts (&a, &b) ;
 16.4684 ++}
 16.4685 ++#endif /* L_ne_sf || L_ne_df */
 16.4686 ++
 16.4687 ++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
 16.4688 ++CMPtype
 16.4689 ++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4690 ++{
 16.4691 ++  fp_number_type a;
 16.4692 ++  fp_number_type b;
 16.4693 ++  FLO_union_type au, bu;
 16.4694 ++
 16.4695 ++  au.value = arg_a;
 16.4696 ++  bu.value = arg_b;
 16.4697 ++
 16.4698 ++  unpack_d (&au, &a);
 16.4699 ++  unpack_d (&bu, &b);
 16.4700 ++
 16.4701 ++  if (isnan (&a) || isnan (&b))
 16.4702 ++    return -1;			/* false, truth > 0 */
 16.4703 ++
 16.4704 ++  return __fpcmp_parts (&a, &b);
 16.4705 ++}
 16.4706 ++#endif /* L_gt_sf || L_gt_df */
 16.4707 ++
 16.4708 ++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
 16.4709 ++CMPtype
 16.4710 ++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4711 ++{
 16.4712 ++  fp_number_type a;
 16.4713 ++  fp_number_type b;
 16.4714 ++  FLO_union_type au, bu;
 16.4715 ++
 16.4716 ++  au.value = arg_a;
 16.4717 ++  bu.value = arg_b;
 16.4718 ++
 16.4719 ++  unpack_d (&au, &a);
 16.4720 ++  unpack_d (&bu, &b);
 16.4721 ++
 16.4722 ++  if (isnan (&a) || isnan (&b))
 16.4723 ++    return -1;			/* false, truth >= 0 */
 16.4724 ++  return __fpcmp_parts (&a, &b) ;
 16.4725 ++}
 16.4726 ++#endif /* L_ge_sf || L_ge_df */
 16.4727 ++
 16.4728 ++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
 16.4729 ++CMPtype
 16.4730 ++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4731 ++{
 16.4732 ++  fp_number_type a;
 16.4733 ++  fp_number_type b;
 16.4734 ++  FLO_union_type au, bu;
 16.4735 ++
 16.4736 ++  au.value = arg_a;
 16.4737 ++  bu.value = arg_b;
 16.4738 ++
 16.4739 ++  unpack_d (&au, &a);
 16.4740 ++  unpack_d (&bu, &b);
 16.4741 ++
 16.4742 ++  if (isnan (&a) || isnan (&b))
 16.4743 ++    return 1;			/* false, truth < 0 */
 16.4744 ++
 16.4745 ++  return __fpcmp_parts (&a, &b);
 16.4746 ++}
 16.4747 ++#endif /* L_lt_sf || L_lt_df */
 16.4748 ++
 16.4749 ++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
 16.4750 ++CMPtype
 16.4751 ++_le_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4752 ++{
 16.4753 ++  fp_number_type a;
 16.4754 ++  fp_number_type b;
 16.4755 ++  FLO_union_type au, bu;
 16.4756 ++
 16.4757 ++  au.value = arg_a;
 16.4758 ++  bu.value = arg_b;
 16.4759 ++
 16.4760 ++  unpack_d (&au, &a);
 16.4761 ++  unpack_d (&bu, &b);
 16.4762 ++
 16.4763 ++  if (isnan (&a) || isnan (&b))
 16.4764 ++    return 1;			/* false, truth <= 0 */
 16.4765 ++
 16.4766 ++  return __fpcmp_parts (&a, &b) ;
 16.4767 ++}
 16.4768 ++#endif /* L_le_sf || L_le_df */
 16.4769 ++
 16.4770 ++#endif /* ! US_SOFTWARE_GOFAST */
 16.4771 ++
 16.4772 ++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
 16.4773 ++CMPtype
 16.4774 ++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
 16.4775 ++{
 16.4776 ++  fp_number_type a;
 16.4777 ++  fp_number_type b;
 16.4778 ++  FLO_union_type au, bu;
 16.4779 ++
 16.4780 ++  au.value = arg_a;
 16.4781 ++  bu.value = arg_b;
 16.4782 ++
 16.4783 ++  unpack_d (&au, &a);
 16.4784 ++  unpack_d (&bu, &b);
 16.4785 ++
 16.4786 ++  return (isnan (&a) || isnan (&b));
 16.4787 ++}
 16.4788 ++#endif /* L_unord_sf || L_unord_df */
 16.4789 ++
 16.4790 ++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
 16.4791 ++FLO_type
 16.4792 ++si_to_float (SItype arg_a)
 16.4793 ++{
 16.4794 ++  fp_number_type in;
 16.4795 ++
 16.4796 ++  in.class = CLASS_NUMBER;
 16.4797 ++  in.sign = arg_a < 0;
 16.4798 ++  if (!arg_a)
 16.4799 ++    {
 16.4800 ++      in.class = CLASS_ZERO;
 16.4801 ++    }
 16.4802 ++  else
 16.4803 ++    {
 16.4804 ++      in.normal_exp = FRACBITS + NGARDS;
 16.4805 ++      if (in.sign) 
 16.4806 ++	{
 16.4807 ++	  /* Special case for minint, since there is no +ve integer
 16.4808 ++	     representation for it */
 16.4809 ++	  if (arg_a == (- MAX_SI_INT - 1))
 16.4810 ++	    {
 16.4811 ++	      return (FLO_type)(- MAX_SI_INT - 1);
 16.4812 ++	    }
 16.4813 ++	  in.fraction.ll = (-arg_a);
 16.4814 ++	}
 16.4815 ++      else
 16.4816 ++	in.fraction.ll = arg_a;
 16.4817 ++
 16.4818 ++      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
 16.4819 ++	{
 16.4820 ++	  in.fraction.ll <<= 1;
 16.4821 ++	  in.normal_exp -= 1;
 16.4822 ++	}
 16.4823 ++    }
 16.4824 ++  return pack_d (&in);
 16.4825 ++}
 16.4826 ++#endif /* L_si_to_sf || L_si_to_df */
 16.4827 ++
 16.4828 ++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
 16.4829 ++FLO_type
 16.4830 ++usi_to_float (USItype arg_a)
 16.4831 ++{
 16.4832 ++  fp_number_type in;
 16.4833 ++
 16.4834 ++  in.sign = 0;
 16.4835 ++  if (!arg_a)
 16.4836 ++    {
 16.4837 ++      in.class = CLASS_ZERO;
 16.4838 ++    }
 16.4839 ++  else
 16.4840 ++    {
 16.4841 ++      in.class = CLASS_NUMBER;
 16.4842 ++      in.normal_exp = FRACBITS + NGARDS;
 16.4843 ++      in.fraction.ll = arg_a;
 16.4844 ++
 16.4845 ++      while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
 16.4846 ++        {
 16.4847 ++          in.fraction.ll >>= 1;
 16.4848 ++          in.normal_exp += 1;
 16.4849 ++        }
 16.4850 ++      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
 16.4851 ++	{
 16.4852 ++	  in.fraction.ll <<= 1;
 16.4853 ++	  in.normal_exp -= 1;
 16.4854 ++	}
 16.4855 ++    }
 16.4856 ++  return pack_d (&in);
 16.4857 ++}
 16.4858 ++#endif
 16.4859 ++
 16.4860 ++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
 16.4861 ++SItype
 16.4862 ++float_to_si (FLO_type arg_a)
 16.4863 ++{
 16.4864 ++  fp_number_type a;
 16.4865 ++  SItype tmp;
 16.4866 ++  FLO_union_type au;
 16.4867 ++
 16.4868 ++  au.value = arg_a;
 16.4869 ++  unpack_d (&au, &a);
 16.4870 ++
 16.4871 ++  if (iszero (&a))
 16.4872 ++    return 0;
 16.4873 ++  if (isnan (&a))
 16.4874 ++    return 0;
 16.4875 ++  /* get reasonable MAX_SI_INT...  */
 16.4876 ++  if (isinf (&a))
 16.4877 ++    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
 16.4878 ++  /* it is a number, but a small one */
 16.4879 ++  if (a.normal_exp < 0)
 16.4880 ++    return 0;
 16.4881 ++  if (a.normal_exp > BITS_PER_SI - 2)
 16.4882 ++    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
 16.4883 ++  tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
 16.4884 ++  return a.sign ? (-tmp) : (tmp);
 16.4885 ++}
 16.4886 ++#endif /* L_sf_to_si || L_df_to_si */
 16.4887 ++
 16.4888 ++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
 16.4889 ++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
 16.4890 ++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
 16.4891 ++   we also define them for GOFAST because the ones in libgcc2.c have the
 16.4892 ++   wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
 16.4893 ++   out of libgcc2.c.  We can't define these here if not GOFAST because then
 16.4894 ++   there'd be duplicate copies.  */
 16.4895 ++
 16.4896 ++USItype
 16.4897 ++float_to_usi (FLO_type arg_a)
 16.4898 ++{
 16.4899 ++  fp_number_type a;
 16.4900 ++  FLO_union_type au;
 16.4901 ++
 16.4902 ++  au.value = arg_a;
 16.4903 ++  unpack_d (&au, &a);
 16.4904 ++
 16.4905 ++  if (iszero (&a))
 16.4906 ++    return 0;
 16.4907 ++  if (isnan (&a))
 16.4908 ++    return 0;
 16.4909 ++  /* it is a negative number */
 16.4910 ++  if (a.sign)
 16.4911 ++    return 0;
 16.4912 ++  /* get reasonable MAX_USI_INT...  */
 16.4913 ++  if (isinf (&a))
 16.4914 ++    return MAX_USI_INT;
 16.4915 ++  /* it is a number, but a small one */
 16.4916 ++  if (a.normal_exp < 0)
 16.4917 ++    return 0;
 16.4918 ++  if (a.normal_exp > BITS_PER_SI - 1)
 16.4919 ++    return MAX_USI_INT;
 16.4920 ++  else if (a.normal_exp > (FRACBITS + NGARDS))
 16.4921 ++    return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
 16.4922 ++  else
 16.4923 ++    return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
 16.4924 ++}
 16.4925 ++#endif /* US_SOFTWARE_GOFAST */
 16.4926 ++#endif /* L_sf_to_usi || L_df_to_usi */
 16.4927 ++
 16.4928 ++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
 16.4929 ++FLO_type
 16.4930 ++negate (FLO_type arg_a)
 16.4931 ++{
 16.4932 ++  fp_number_type a;
 16.4933 ++  FLO_union_type au;
 16.4934 ++
 16.4935 ++  au.value = arg_a;
 16.4936 ++  unpack_d (&au, &a);
 16.4937 ++
 16.4938 ++  flip_sign (&a);
 16.4939 ++  return pack_d (&a);
 16.4940 ++}
 16.4941 ++#endif /* L_negate_sf || L_negate_df */
 16.4942 ++
 16.4943 ++#ifdef FLOAT
 16.4944 ++
 16.4945 ++#if defined(L_make_sf)
 16.4946 ++SFtype
 16.4947 ++__make_fp(fp_class_type class,
 16.4948 ++	     unsigned int sign,
 16.4949 ++	     int exp, 
 16.4950 ++	     USItype frac)
 16.4951 ++{
 16.4952 ++  fp_number_type in;
 16.4953 ++
 16.4954 ++  in.class = class;
 16.4955 ++  in.sign = sign;
 16.4956 ++  in.normal_exp = exp;
 16.4957 ++  in.fraction.ll = frac;
 16.4958 ++  return pack_d (&in);
 16.4959 ++}
 16.4960 ++#endif /* L_make_sf */
 16.4961 ++
 16.4962 ++#ifndef FLOAT_ONLY
 16.4963 ++
 16.4964 ++/* This enables one to build an fp library that supports float but not double.
 16.4965 ++   Otherwise, we would get an undefined reference to __make_dp.
 16.4966 ++   This is needed for some 8-bit ports that can't handle well values that
 16.4967 ++   are 8-bytes in size, so we just don't support double for them at all.  */
 16.4968 ++
 16.4969 ++#if defined(L_sf_to_df)
 16.4970 ++DFtype
 16.4971 ++sf_to_df (SFtype arg_a)
 16.4972 ++{
 16.4973 ++  fp_number_type in;
 16.4974 ++  FLO_union_type au;
 16.4975 ++
 16.4976 ++  au.value = arg_a;
 16.4977 ++  unpack_d (&au, &in);
 16.4978 ++
 16.4979 ++  return __make_dp (in.class, in.sign, in.normal_exp,
 16.4980 ++		    ((UDItype) in.fraction.ll) << F_D_BITOFF);
 16.4981 ++}
 16.4982 ++#endif /* L_sf_to_df */
 16.4983 ++
 16.4984 ++#if defined(L_sf_to_tf) && defined(TMODES)
 16.4985 ++TFtype
 16.4986 ++sf_to_tf (SFtype arg_a)
 16.4987 ++{
 16.4988 ++  fp_number_type in;
 16.4989 ++  FLO_union_type au;
 16.4990 ++
 16.4991 ++  au.value = arg_a;
 16.4992 ++  unpack_d (&au, &in);
 16.4993 ++
 16.4994 ++  return __make_tp (in.class, in.sign, in.normal_exp,
 16.4995 ++		    ((UTItype) in.fraction.ll) << F_T_BITOFF);
 16.4996 ++}
 16.4997 ++#endif /* L_sf_to_df */
 16.4998 ++
 16.4999 ++#endif /* ! FLOAT_ONLY */
 16.5000 ++#endif /* FLOAT */
 16.5001 ++
 16.5002 ++#ifndef FLOAT
 16.5003 ++
 16.5004 ++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
 16.5005 ++
 16.5006 ++#if defined(L_make_df)
 16.5007 ++DFtype
 16.5008 ++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
 16.5009 ++{
 16.5010 ++  fp_number_type in;
 16.5011 ++
 16.5012 ++  in.class = class;
 16.5013 ++  in.sign = sign;
 16.5014 ++  in.normal_exp = exp;
 16.5015 ++  in.fraction.ll = frac;
 16.5016 ++  return pack_d (&in);
 16.5017 ++}
 16.5018 ++#endif /* L_make_df */
 16.5019 ++
 16.5020 ++#if defined(L_df_to_sf)
 16.5021 ++SFtype
 16.5022 ++df_to_sf (DFtype arg_a)
 16.5023 ++{
 16.5024 ++  fp_number_type in;
 16.5025 ++  USItype sffrac;
 16.5026 ++  FLO_union_type au;
 16.5027 ++
 16.5028 ++  au.value = arg_a;
 16.5029 ++  unpack_d (&au, &in);
 16.5030 ++
 16.5031 ++  sffrac = in.fraction.ll >> F_D_BITOFF;
 16.5032 ++
 16.5033 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.5034 ++     zero bits.  */
 16.5035 ++  if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
 16.5036 ++    sffrac |= 1;
 16.5037 ++
 16.5038 ++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
 16.5039 ++}
 16.5040 ++#endif /* L_df_to_sf */
 16.5041 ++
 16.5042 ++#if defined(L_df_to_tf) && defined(TMODES) \
 16.5043 ++    && !defined(FLOAT) && !defined(TFLOAT)
 16.5044 ++TFtype
 16.5045 ++df_to_tf (DFtype arg_a)
 16.5046 ++{
 16.5047 ++  fp_number_type in;
 16.5048 ++  FLO_union_type au;
 16.5049 ++
 16.5050 ++  au.value = arg_a;
 16.5051 ++  unpack_d (&au, &in);
 16.5052 ++
 16.5053 ++  return __make_tp (in.class, in.sign, in.normal_exp,
 16.5054 ++		    ((UTItype) in.fraction.ll) << D_T_BITOFF);
 16.5055 ++}
 16.5056 ++#endif /* L_sf_to_df */
 16.5057 ++
 16.5058 ++#ifdef TFLOAT
 16.5059 ++#if defined(L_make_tf)
 16.5060 ++TFtype
 16.5061 ++__make_tp(fp_class_type class,
 16.5062 ++	     unsigned int sign,
 16.5063 ++	     int exp, 
 16.5064 ++	     UTItype frac)
 16.5065 ++{
 16.5066 ++  fp_number_type in;
 16.5067 ++
 16.5068 ++  in.class = class;
 16.5069 ++  in.sign = sign;
 16.5070 ++  in.normal_exp = exp;
 16.5071 ++  in.fraction.ll = frac;
 16.5072 ++  return pack_d (&in);
 16.5073 ++}
 16.5074 ++#endif /* L_make_tf */
 16.5075 ++
 16.5076 ++#if defined(L_tf_to_df)
 16.5077 ++DFtype
 16.5078 ++tf_to_df (TFtype arg_a)
 16.5079 ++{
 16.5080 ++  fp_number_type in;
 16.5081 ++  UDItype sffrac;
 16.5082 ++  FLO_union_type au;
 16.5083 ++
 16.5084 ++  au.value = arg_a;
 16.5085 ++  unpack_d (&au, &in);
 16.5086 ++
 16.5087 ++  sffrac = in.fraction.ll >> D_T_BITOFF;
 16.5088 ++
 16.5089 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.5090 ++     zero bits.  */
 16.5091 ++  if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
 16.5092 ++    sffrac |= 1;
 16.5093 ++
 16.5094 ++  return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
 16.5095 ++}
 16.5096 ++#endif /* L_tf_to_df */
 16.5097 ++
 16.5098 ++#if defined(L_tf_to_sf)
 16.5099 ++SFtype
 16.5100 ++tf_to_sf (TFtype arg_a)
 16.5101 ++{
 16.5102 ++  fp_number_type in;
 16.5103 ++  USItype sffrac;
 16.5104 ++  FLO_union_type au;
 16.5105 ++
 16.5106 ++  au.value = arg_a;
 16.5107 ++  unpack_d (&au, &in);
 16.5108 ++
 16.5109 ++  sffrac = in.fraction.ll >> F_T_BITOFF;
 16.5110 ++
 16.5111 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.5112 ++     zero bits.  */
 16.5113 ++  if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
 16.5114 ++    sffrac |= 1;
 16.5115 ++
 16.5116 ++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
 16.5117 ++}
 16.5118 ++#endif /* L_tf_to_sf */
 16.5119 ++#endif /* TFLOAT */
 16.5120 ++
 16.5121 ++#endif /* ! FLOAT */
 16.5122 ++#endif /* !EXTENDED_FLOAT_STUBS */
 16.5123 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2-fp-bit.c gcc-3.4.6/gcc/config/nios2/nios2-fp-bit.c
 16.5124 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-fp-bit.c	1970-01-01 01:00:00.000000000 +0100
 16.5125 ++++ gcc-3.4.6/gcc/config/nios2/nios2-fp-bit.c	2007-08-15 23:09:36.000000000 +0200
 16.5126 +@@ -0,0 +1,1652 @@
 16.5127 ++#define FLOAT
 16.5128 ++/* This is a software floating point library which can be used
 16.5129 ++   for targets without hardware floating point. 
 16.5130 ++   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
 16.5131 ++   Free Software Foundation, Inc.
 16.5132 ++
 16.5133 ++This file is free software; you can redistribute it and/or modify it
 16.5134 ++under the terms of the GNU General Public License as published by the
 16.5135 ++Free Software Foundation; either version 2, or (at your option) any
 16.5136 ++later version.
 16.5137 ++
 16.5138 ++In addition to the permissions in the GNU General Public License, the
 16.5139 ++Free Software Foundation gives you unlimited permission to link the
 16.5140 ++compiled version of this file with other programs, and to distribute
 16.5141 ++those programs without any restriction coming from the use of this
 16.5142 ++file.  (The General Public License restrictions do apply in other
 16.5143 ++respects; for example, they cover modification of the file, and
 16.5144 ++distribution when not linked into another program.)
 16.5145 ++
 16.5146 ++This file is distributed in the hope that it will be useful, but
 16.5147 ++WITHOUT ANY WARRANTY; without even the implied warranty of
 16.5148 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16.5149 ++General Public License for more details.
 16.5150 ++
 16.5151 ++You should have received a copy of the GNU General Public License
 16.5152 ++along with this program; see the file COPYING.  If not, write to
 16.5153 ++the Free Software Foundation, 59 Temple Place - Suite 330,
 16.5154 ++Boston, MA 02111-1307, USA.  */
 16.5155 ++
 16.5156 ++/* As a special exception, if you link this library with other files,
 16.5157 ++   some of which are compiled with GCC, to produce an executable,
 16.5158 ++   this library does not by itself cause the resulting executable
 16.5159 ++   to be covered by the GNU General Public License.
 16.5160 ++   This exception does not however invalidate any other reasons why
 16.5161 ++   the executable file might be covered by the GNU General Public License.  */
 16.5162 ++
 16.5163 ++/* This implements IEEE 754 format arithmetic, but does not provide a
 16.5164 ++   mechanism for setting the rounding mode, or for generating or handling
 16.5165 ++   exceptions.
 16.5166 ++
 16.5167 ++   The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
 16.5168 ++   Wilson, all of Cygnus Support.  */
 16.5169 ++
 16.5170 ++/* The intended way to use this file is to make two copies, add `#define FLOAT'
 16.5171 ++   to one copy, then compile both copies and add them to libgcc.a.  */
 16.5172 ++
 16.5173 ++#include "tconfig.h"
 16.5174 ++#include "coretypes.h"
 16.5175 ++#include "tm.h"
 16.5176 ++#include "config/fp-bit.h"
 16.5177 ++
 16.5178 ++/* The following macros can be defined to change the behavior of this file:
 16.5179 ++   FLOAT: Implement a `float', aka SFmode, fp library.  If this is not
 16.5180 ++     defined, then this file implements a `double', aka DFmode, fp library.
 16.5181 ++   FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
 16.5182 ++     don't include float->double conversion which requires the double library.
 16.5183 ++     This is useful only for machines which can't support doubles, e.g. some
 16.5184 ++     8-bit processors.
 16.5185 ++   CMPtype: Specify the type that floating point compares should return.
 16.5186 ++     This defaults to SItype, aka int.
 16.5187 ++   US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
 16.5188 ++     US Software goFast library.
 16.5189 ++   _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
 16.5190 ++     two integers to the FLO_union_type.
 16.5191 ++   NO_DENORMALS: Disable handling of denormals.
 16.5192 ++   NO_NANS: Disable nan and infinity handling
 16.5193 ++   SMALL_MACHINE: Useful when operations on QIs and HIs are faster
 16.5194 ++     than on an SI */
 16.5195 ++
 16.5196 ++/* We don't currently support extended floats (long doubles) on machines
 16.5197 ++   without hardware to deal with them.
 16.5198 ++
 16.5199 ++   These stubs are just to keep the linker from complaining about unresolved
 16.5200 ++   references which can be pulled in from libio & libstdc++, even if the
 16.5201 ++   user isn't using long doubles.  However, they may generate an unresolved
 16.5202 ++   external to abort if abort is not used by the function, and the stubs
 16.5203 ++   are referenced from within libc, since libgcc goes before and after the
 16.5204 ++   system library.  */
 16.5205 ++
 16.5206 ++#ifdef DECLARE_LIBRARY_RENAMES
 16.5207 ++  DECLARE_LIBRARY_RENAMES
 16.5208 ++#endif
 16.5209 ++
 16.5210 ++#ifdef EXTENDED_FLOAT_STUBS
 16.5211 ++extern void abort (void);
 16.5212 ++void __extendsfxf2 (void) { abort(); }
 16.5213 ++void __extenddfxf2 (void) { abort(); }
 16.5214 ++void __truncxfdf2 (void) { abort(); }
 16.5215 ++void __truncxfsf2 (void) { abort(); }
 16.5216 ++void __fixxfsi (void) { abort(); }
 16.5217 ++void __floatsixf (void) { abort(); }
 16.5218 ++void __addxf3 (void) { abort(); }
 16.5219 ++void __subxf3 (void) { abort(); }
 16.5220 ++void __mulxf3 (void) { abort(); }
 16.5221 ++void __divxf3 (void) { abort(); }
 16.5222 ++void __negxf2 (void) { abort(); }
 16.5223 ++void __eqxf2 (void) { abort(); }
 16.5224 ++void __nexf2 (void) { abort(); }
 16.5225 ++void __gtxf2 (void) { abort(); }
 16.5226 ++void __gexf2 (void) { abort(); }
 16.5227 ++void __lexf2 (void) { abort(); }
 16.5228 ++void __ltxf2 (void) { abort(); }
 16.5229 ++
 16.5230 ++void __extendsftf2 (void) { abort(); }
 16.5231 ++void __extenddftf2 (void) { abort(); }
 16.5232 ++void __trunctfdf2 (void) { abort(); }
 16.5233 ++void __trunctfsf2 (void) { abort(); }
 16.5234 ++void __fixtfsi (void) { abort(); }
 16.5235 ++void __floatsitf (void) { abort(); }
 16.5236 ++void __addtf3 (void) { abort(); }
 16.5237 ++void __subtf3 (void) { abort(); }
 16.5238 ++void __multf3 (void) { abort(); }
 16.5239 ++void __divtf3 (void) { abort(); }
 16.5240 ++void __negtf2 (void) { abort(); }
 16.5241 ++void __eqtf2 (void) { abort(); }
 16.5242 ++void __netf2 (void) { abort(); }
 16.5243 ++void __gttf2 (void) { abort(); }
 16.5244 ++void __getf2 (void) { abort(); }
 16.5245 ++void __letf2 (void) { abort(); }
 16.5246 ++void __lttf2 (void) { abort(); }
 16.5247 ++#else	/* !EXTENDED_FLOAT_STUBS, rest of file */
 16.5248 ++
 16.5249 ++/* IEEE "special" number predicates */
 16.5250 ++
 16.5251 ++#ifdef NO_NANS
 16.5252 ++
 16.5253 ++#define nan() 0
 16.5254 ++#define isnan(x) 0
 16.5255 ++#define isinf(x) 0
 16.5256 ++#else
 16.5257 ++
 16.5258 ++#if   defined L_thenan_sf
 16.5259 ++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.5260 ++#elif defined L_thenan_df
 16.5261 ++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.5262 ++#elif defined L_thenan_tf
 16.5263 ++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
 16.5264 ++#elif defined TFLOAT
 16.5265 ++extern const fp_number_type __thenan_tf;
 16.5266 ++#elif defined FLOAT
 16.5267 ++extern const fp_number_type __thenan_sf;
 16.5268 ++#else
 16.5269 ++extern const fp_number_type __thenan_df;
 16.5270 ++#endif
 16.5271 ++
 16.5272 ++INLINE
 16.5273 ++static fp_number_type *
 16.5274 ++nan (void)
 16.5275 ++{
 16.5276 ++  /* Discard the const qualifier...  */
 16.5277 ++#ifdef TFLOAT
 16.5278 ++  return (fp_number_type *) (& __thenan_tf);
 16.5279 ++#elif defined FLOAT  
 16.5280 ++  return (fp_number_type *) (& __thenan_sf);
 16.5281 ++#else
 16.5282 ++  return (fp_number_type *) (& __thenan_df);
 16.5283 ++#endif
 16.5284 ++}
 16.5285 ++
 16.5286 ++INLINE
 16.5287 ++static int
 16.5288 ++isnan ( fp_number_type *  x)
 16.5289 ++{
 16.5290 ++  return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
 16.5291 ++}
 16.5292 ++
 16.5293 ++INLINE
 16.5294 ++static int
 16.5295 ++isinf ( fp_number_type *  x)
 16.5296 ++{
 16.5297 ++  return x->class == CLASS_INFINITY;
 16.5298 ++}
 16.5299 ++
 16.5300 ++#endif /* NO_NANS */
 16.5301 ++
 16.5302 ++INLINE
 16.5303 ++static int
 16.5304 ++iszero ( fp_number_type *  x)
 16.5305 ++{
 16.5306 ++  return x->class == CLASS_ZERO;
 16.5307 ++}
 16.5308 ++
 16.5309 ++INLINE 
 16.5310 ++static void
 16.5311 ++flip_sign ( fp_number_type *  x)
 16.5312 ++{
 16.5313 ++  x->sign = !x->sign;
 16.5314 ++}
 16.5315 ++
 16.5316 ++extern FLO_type pack_d ( fp_number_type * );
 16.5317 ++
 16.5318 ++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
 16.5319 ++FLO_type
 16.5320 ++pack_d ( fp_number_type *  src)
 16.5321 ++{
 16.5322 ++  FLO_union_type dst;
 16.5323 ++  fractype fraction = src->fraction.ll;	/* wasn't unsigned before? */
 16.5324 ++  int sign = src->sign;
 16.5325 ++  int exp = 0;
 16.5326 ++
 16.5327 ++  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
 16.5328 ++    {
 16.5329 ++      /* We can't represent these values accurately.  By using the
 16.5330 ++	 largest possible magnitude, we guarantee that the conversion
 16.5331 ++	 of infinity is at least as big as any finite number.  */
 16.5332 ++      exp = EXPMAX;
 16.5333 ++      fraction = ((fractype) 1 << FRACBITS) - 1;
 16.5334 ++    }
 16.5335 ++  else if (isnan (src))
 16.5336 ++    {
 16.5337 ++      exp = EXPMAX;
 16.5338 ++      if (src->class == CLASS_QNAN || 1)
 16.5339 ++	{
 16.5340 ++#ifdef QUIET_NAN_NEGATED
 16.5341 ++	  fraction |= QUIET_NAN - 1;
 16.5342 ++#else
 16.5343 ++	  fraction |= QUIET_NAN;
 16.5344 ++#endif
 16.5345 ++	}
 16.5346 ++    }
 16.5347 ++  else if (isinf (src))
 16.5348 ++    {
 16.5349 ++      exp = EXPMAX;
 16.5350 ++      fraction = 0;
 16.5351 ++    }
 16.5352 ++  else if (iszero (src))
 16.5353 ++    {
 16.5354 ++      exp = 0;
 16.5355 ++      fraction = 0;
 16.5356 ++    }
 16.5357 ++  else if (fraction == 0)
 16.5358 ++    {
 16.5359 ++      exp = 0;
 16.5360 ++    }
 16.5361 ++  else
 16.5362 ++    {
 16.5363 ++      if (src->normal_exp < NORMAL_EXPMIN)
 16.5364 ++	{
 16.5365 ++#ifdef NO_DENORMALS
 16.5366 ++	  /* Go straight to a zero representation if denormals are not
 16.5367 ++ 	     supported.  The denormal handling would be harmless but
 16.5368 ++ 	     isn't unnecessary.  */
 16.5369 ++	  exp = 0;
 16.5370 ++	  fraction = 0;
 16.5371 ++#else /* NO_DENORMALS */
 16.5372 ++	  /* This number's exponent is too low to fit into the bits
 16.5373 ++	     available in the number, so we'll store 0 in the exponent and
 16.5374 ++	     shift the fraction to the right to make up for it.  */
 16.5375 ++
 16.5376 ++	  int shift = NORMAL_EXPMIN - src->normal_exp;
 16.5377 ++
 16.5378 ++	  exp = 0;
 16.5379 ++
 16.5380 ++	  if (shift > FRAC_NBITS - NGARDS)
 16.5381 ++	    {
 16.5382 ++	      /* No point shifting, since it's more that 64 out.  */
 16.5383 ++	      fraction = 0;
 16.5384 ++	    }
 16.5385 ++	  else
 16.5386 ++	    {
 16.5387 ++	      int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
 16.5388 ++	      fraction = (fraction >> shift) | lowbit;
 16.5389 ++	    }
 16.5390 ++	  if ((fraction & GARDMASK) == GARDMSB)
 16.5391 ++	    {
 16.5392 ++	      if ((fraction & (1 << NGARDS)))
 16.5393 ++		fraction += GARDROUND + 1;
 16.5394 ++	    }
 16.5395 ++	  else
 16.5396 ++	    {
 16.5397 ++	      /* Add to the guards to round up.  */
 16.5398 ++	      fraction += GARDROUND;
 16.5399 ++	    }
 16.5400 ++	  /* Perhaps the rounding means we now need to change the
 16.5401 ++             exponent, because the fraction is no longer denormal.  */
 16.5402 ++	  if (fraction >= IMPLICIT_1)
 16.5403 ++	    {
 16.5404 ++	      exp += 1;
 16.5405 ++	    }
 16.5406 ++	  fraction >>= NGARDS;
 16.5407 ++#endif /* NO_DENORMALS */
 16.5408 ++	}
 16.5409 ++      else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
 16.5410 ++	       && src->normal_exp > EXPBIAS)
 16.5411 ++	{
 16.5412 ++	  exp = EXPMAX;
 16.5413 ++	  fraction = 0;
 16.5414 ++	}
 16.5415 ++      else
 16.5416 ++	{
 16.5417 ++	  exp = src->normal_exp + EXPBIAS;
 16.5418 ++	  if (!ROUND_TOWARDS_ZERO)
 16.5419 ++	    {
 16.5420 ++	      /* IF the gard bits are the all zero, but the first, then we're
 16.5421 ++		 half way between two numbers, choose the one which makes the
 16.5422 ++		 lsb of the answer 0.  */
 16.5423 ++	      if ((fraction & GARDMASK) == GARDMSB)
 16.5424 ++		{
 16.5425 ++		  if (fraction & (1 << NGARDS))
 16.5426 ++		    fraction += GARDROUND + 1;
 16.5427 ++		}
 16.5428 ++	      else
 16.5429 ++		{
 16.5430 ++		  /* Add a one to the guards to round up */
 16.5431 ++		  fraction += GARDROUND;
 16.5432 ++		}
 16.5433 ++	      if (fraction >= IMPLICIT_2)
 16.5434 ++		{
 16.5435 ++		  fraction >>= 1;
 16.5436 ++		  exp += 1;
 16.5437 ++		}
 16.5438 ++	    }
 16.5439 ++	  fraction >>= NGARDS;
 16.5440 ++
 16.5441 ++	  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
 16.5442 ++	    {
 16.5443 ++	      /* Saturate on overflow.  */
 16.5444 ++	      exp = EXPMAX;
 16.5445 ++	      fraction = ((fractype) 1 << FRACBITS) - 1;
 16.5446 ++	    }
 16.5447 ++	}
 16.5448 ++    }
 16.5449 ++
 16.5450 ++  /* We previously used bitfields to store the number, but this doesn't
 16.5451 ++     handle little/big endian systems conveniently, so use shifts and
 16.5452 ++     masks */
 16.5453 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
 16.5454 ++  dst.bits.fraction = fraction;
 16.5455 ++  dst.bits.exp = exp;
 16.5456 ++  dst.bits.sign = sign;
 16.5457 ++#else
 16.5458 ++# if defined TFLOAT && defined HALFFRACBITS
 16.5459 ++ {
 16.5460 ++   halffractype high, low, unity;
 16.5461 ++   int lowsign, lowexp;
 16.5462 ++
 16.5463 ++   unity = (halffractype) 1 << HALFFRACBITS;
 16.5464 ++
 16.5465 ++   /* Set HIGH to the high double's significand, masking out the implicit 1.
 16.5466 ++      Set LOW to the low double's full significand.  */
 16.5467 ++   high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
 16.5468 ++   low = fraction & (unity * 2 - 1);
 16.5469 ++
 16.5470 ++   /* Get the initial sign and exponent of the low double.  */
 16.5471 ++   lowexp = exp - HALFFRACBITS - 1;
 16.5472 ++   lowsign = sign;
 16.5473 ++
 16.5474 ++   /* HIGH should be rounded like a normal double, making |LOW| <=
 16.5475 ++      0.5 ULP of HIGH.  Assume round-to-nearest.  */
 16.5476 ++   if (exp < EXPMAX)
 16.5477 ++     if (low > unity || (low == unity && (high & 1) == 1))
 16.5478 ++       {
 16.5479 ++	 /* Round HIGH up and adjust LOW to match.  */
 16.5480 ++	 high++;
 16.5481 ++	 if (high == unity)
 16.5482 ++	   {
 16.5483 ++	     /* May make it infinite, but that's OK.  */
 16.5484 ++	     high = 0;
 16.5485 ++	     exp++;
 16.5486 ++	   }
 16.5487 ++	 low = unity * 2 - low;
 16.5488 ++	 lowsign ^= 1;
 16.5489 ++       }
 16.5490 ++
 16.5491 ++   high |= (halffractype) exp << HALFFRACBITS;
 16.5492 ++   high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
 16.5493 ++
 16.5494 ++   if (exp == EXPMAX || exp == 0 || low == 0)
 16.5495 ++     low = 0;
 16.5496 ++   else
 16.5497 ++     {
 16.5498 ++       while (lowexp > 0 && low < unity)
 16.5499 ++	 {
 16.5500 ++	   low <<= 1;
 16.5501 ++	   lowexp--;
 16.5502 ++	 }
 16.5503 ++
 16.5504 ++       if (lowexp <= 0)
 16.5505 ++	 {
 16.5506 ++	   halffractype roundmsb, round;
 16.5507 ++	   int shift;
 16.5508 ++
 16.5509 ++	   shift = 1 - lowexp;
 16.5510 ++	   roundmsb = (1 << (shift - 1));
 16.5511 ++	   round = low & ((roundmsb << 1) - 1);
 16.5512 ++
 16.5513 ++	   low >>= shift;
 16.5514 ++	   lowexp = 0;
 16.5515 ++
 16.5516 ++	   if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
 16.5517 ++	     {
 16.5518 ++	       low++;
 16.5519 ++	       if (low == unity)
 16.5520 ++		 /* LOW rounds up to the smallest normal number.  */
 16.5521 ++		 lowexp++;
 16.5522 ++	     }
 16.5523 ++	 }
 16.5524 ++
 16.5525 ++       low &= unity - 1;
 16.5526 ++       low |= (halffractype) lowexp << HALFFRACBITS;
 16.5527 ++       low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
 16.5528 ++     }
 16.5529 ++   dst.value_raw = ((fractype) high << HALFSHIFT) | low;
 16.5530 ++ }
 16.5531 ++# else
 16.5532 ++  dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
 16.5533 ++  dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
 16.5534 ++  dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
 16.5535 ++# endif
 16.5536 ++#endif
 16.5537 ++
 16.5538 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
 16.5539 ++#ifdef TFLOAT
 16.5540 ++  {
 16.5541 ++    qrtrfractype tmp1 = dst.words[0];
 16.5542 ++    qrtrfractype tmp2 = dst.words[1];
 16.5543 ++    dst.words[0] = dst.words[3];
 16.5544 ++    dst.words[1] = dst.words[2];
 16.5545 ++    dst.words[2] = tmp2;
 16.5546 ++    dst.words[3] = tmp1;
 16.5547 ++  }
 16.5548 ++#else
 16.5549 ++  {
 16.5550 ++    halffractype tmp = dst.words[0];
 16.5551 ++    dst.words[0] = dst.words[1];
 16.5552 ++    dst.words[1] = tmp;
 16.5553 ++  }
 16.5554 ++#endif
 16.5555 ++#endif
 16.5556 ++
 16.5557 ++  return dst.value;
 16.5558 ++}
 16.5559 ++#endif
 16.5560 ++
 16.5561 ++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
 16.5562 ++void
 16.5563 ++unpack_d (FLO_union_type * src, fp_number_type * dst)
 16.5564 ++{
 16.5565 ++  /* We previously used bitfields to store the number, but this doesn't
 16.5566 ++     handle little/big endian systems conveniently, so use shifts and
 16.5567 ++     masks */
 16.5568 ++  fractype fraction;
 16.5569 ++  int exp;
 16.5570 ++  int sign;
 16.5571 ++
 16.5572 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
 16.5573 ++  FLO_union_type swapped;
 16.5574 ++
 16.5575 ++#ifdef TFLOAT
 16.5576 ++  swapped.words[0] = src->words[3];
 16.5577 ++  swapped.words[1] = src->words[2];
 16.5578 ++  swapped.words[2] = src->words[1];
 16.5579 ++  swapped.words[3] = src->words[0];
 16.5580 ++#else
 16.5581 ++  swapped.words[0] = src->words[1];
 16.5582 ++  swapped.words[1] = src->words[0];
 16.5583 ++#endif
 16.5584 ++  src = &swapped;
 16.5585 ++#endif
 16.5586 ++  
 16.5587 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
 16.5588 ++  fraction = src->bits.fraction;
 16.5589 ++  exp = src->bits.exp;
 16.5590 ++  sign = src->bits.sign;
 16.5591 ++#else
 16.5592 ++# if defined TFLOAT && defined HALFFRACBITS
 16.5593 ++ {
 16.5594 ++   halffractype high, low;
 16.5595 ++   
 16.5596 ++   high = src->value_raw >> HALFSHIFT;
 16.5597 ++   low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
 16.5598 ++
 16.5599 ++   fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
 16.5600 ++   fraction <<= FRACBITS - HALFFRACBITS;
 16.5601 ++   exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
 16.5602 ++   sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
 16.5603 ++
 16.5604 ++   if (exp != EXPMAX && exp != 0 && low != 0)
 16.5605 ++     {
 16.5606 ++       int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
 16.5607 ++       int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
 16.5608 ++       int shift;
 16.5609 ++       fractype xlow;
 16.5610 ++
 16.5611 ++       xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
 16.5612 ++       if (lowexp)
 16.5613 ++	 xlow |= (((halffractype)1) << HALFFRACBITS);
 16.5614 ++       else
 16.5615 ++	 lowexp = 1;
 16.5616 ++       shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
 16.5617 ++       if (shift > 0)
 16.5618 ++	 xlow <<= shift;
 16.5619 ++       else if (shift < 0)
 16.5620 ++	 xlow >>= -shift;
 16.5621 ++       if (sign == lowsign)
 16.5622 ++	 fraction += xlow;
 16.5623 ++       else if (fraction >= xlow)
 16.5624 ++	 fraction -= xlow;
 16.5625 ++       else
 16.5626 ++	 {
 16.5627 ++	   /* The high part is a power of two but the full number is lower.
 16.5628 ++	      This code will leave the implicit 1 in FRACTION, but we'd
 16.5629 ++	      have added that below anyway.  */
 16.5630 ++	   fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
 16.5631 ++	   exp--;
 16.5632 ++	 }
 16.5633 ++     }
 16.5634 ++ }
 16.5635 ++# else
 16.5636 ++  fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
 16.5637 ++  exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
 16.5638 ++  sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
 16.5639 ++# endif
 16.5640 ++#endif
 16.5641 ++
 16.5642 ++  dst->sign = sign;
 16.5643 ++  if (exp == 0)
 16.5644 ++    {
 16.5645 ++      /* Hmm.  Looks like 0 */
 16.5646 ++      if (fraction == 0
 16.5647 ++#ifdef NO_DENORMALS
 16.5648 ++	  || 1
 16.5649 ++#endif
 16.5650 ++	  )
 16.5651 ++	{
 16.5652 ++	  /* tastes like zero */
 16.5653 ++	  dst->class = CLASS_ZERO;
 16.5654 ++	}
 16.5655 ++      else
 16.5656 ++	{
 16.5657 ++	  /* Zero exponent with nonzero fraction - it's denormalized,
 16.5658 ++	     so there isn't a leading implicit one - we'll shift it so
 16.5659 ++	     it gets one.  */
 16.5660 ++	  dst->normal_exp = exp - EXPBIAS + 1;
 16.5661 ++	  fraction <<= NGARDS;
 16.5662 ++
 16.5663 ++	  dst->class = CLASS_NUMBER;
 16.5664 ++#if 1
 16.5665 ++	  while (fraction < IMPLICIT_1)
 16.5666 ++	    {
 16.5667 ++	      fraction <<= 1;
 16.5668 ++	      dst->normal_exp--;
 16.5669 ++	    }
 16.5670 ++#endif
 16.5671 ++	  dst->fraction.ll = fraction;
 16.5672 ++	}
 16.5673 ++    }
 16.5674 ++  else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
 16.5675 ++    {
 16.5676 ++      /* Huge exponent*/
 16.5677 ++      if (fraction == 0)
 16.5678 ++	{
 16.5679 ++	  /* Attached to a zero fraction - means infinity */
 16.5680 ++	  dst->class = CLASS_INFINITY;
 16.5681 ++	}
 16.5682 ++      else
 16.5683 ++	{
 16.5684 ++	  /* Nonzero fraction, means nan */
 16.5685 ++#ifdef QUIET_NAN_NEGATED
 16.5686 ++	  if ((fraction & QUIET_NAN) == 0)
 16.5687 ++#else
 16.5688 ++	  if (fraction & QUIET_NAN)
 16.5689 ++#endif
 16.5690 ++	    {
 16.5691 ++	      dst->class = CLASS_QNAN;
 16.5692 ++	    }
 16.5693 ++	  else
 16.5694 ++	    {
 16.5695 ++	      dst->class = CLASS_SNAN;
 16.5696 ++	    }
 16.5697 ++	  /* Keep the fraction part as the nan number */
 16.5698 ++	  dst->fraction.ll = fraction;
 16.5699 ++	}
 16.5700 ++    }
 16.5701 ++  else
 16.5702 ++    {
 16.5703 ++      /* Nothing strange about this number */
 16.5704 ++      dst->normal_exp = exp - EXPBIAS;
 16.5705 ++      dst->class = CLASS_NUMBER;
 16.5706 ++      dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
 16.5707 ++    }
 16.5708 ++}
 16.5709 ++#endif /* L_unpack_df || L_unpack_sf */
 16.5710 ++
 16.5711 ++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
 16.5712 ++static fp_number_type *
 16.5713 ++_fpadd_parts (fp_number_type * a,
 16.5714 ++	      fp_number_type * b,
 16.5715 ++	      fp_number_type * tmp)
 16.5716 ++{
 16.5717 ++  intfrac tfraction;
 16.5718 ++
 16.5719 ++  /* Put commonly used fields in local variables.  */
 16.5720 ++  int a_normal_exp;
 16.5721 ++  int b_normal_exp;
 16.5722 ++  fractype a_fraction;
 16.5723 ++  fractype b_fraction;
 16.5724 ++
 16.5725 ++  if (isnan (a))
 16.5726 ++    {
 16.5727 ++      return a;
 16.5728 ++    }
 16.5729 ++  if (isnan (b))
 16.5730 ++    {
 16.5731 ++      return b;
 16.5732 ++    }
 16.5733 ++  if (isinf (a))
 16.5734 ++    {
 16.5735 ++      /* Adding infinities with opposite signs yields a NaN.  */
 16.5736 ++      if (isinf (b) && a->sign != b->sign)
 16.5737 ++	return nan ();
 16.5738 ++      return a;
 16.5739 ++    }
 16.5740 ++  if (isinf (b))
 16.5741 ++    {
 16.5742 ++      return b;
 16.5743 ++    }
 16.5744 ++  if (iszero (b))
 16.5745 ++    {
 16.5746 ++      if (iszero (a))
 16.5747 ++	{
 16.5748 ++	  *tmp = *a;
 16.5749 ++	  tmp->sign = a->sign & b->sign;
 16.5750 ++	  return tmp;
 16.5751 ++	}
 16.5752 ++      return a;
 16.5753 ++    }
 16.5754 ++  if (iszero (a))
 16.5755 ++    {
 16.5756 ++      return b;
 16.5757 ++    }
 16.5758 ++
 16.5759 ++  /* Got two numbers. shift the smaller and increment the exponent till
 16.5760 ++     they're the same */
 16.5761 ++  {
 16.5762 ++    int diff;
 16.5763 ++
 16.5764 ++    a_normal_exp = a->normal_exp;
 16.5765 ++    b_normal_exp = b->normal_exp;
 16.5766 ++    a_fraction = a->fraction.ll;
 16.5767 ++    b_fraction = b->fraction.ll;
 16.5768 ++
 16.5769 ++    diff = a_normal_exp - b_normal_exp;
 16.5770 ++
 16.5771 ++    if (diff < 0)
 16.5772 ++      diff = -diff;
 16.5773 ++    if (diff < FRAC_NBITS)
 16.5774 ++      {
 16.5775 ++	/* ??? This does shifts one bit at a time.  Optimize.  */
 16.5776 ++	while (a_normal_exp > b_normal_exp)
 16.5777 ++	  {
 16.5778 ++	    b_normal_exp++;
 16.5779 ++	    LSHIFT (b_fraction);
 16.5780 ++	  }
 16.5781 ++	while (b_normal_exp > a_normal_exp)
 16.5782 ++	  {
 16.5783 ++	    a_normal_exp++;
 16.5784 ++	    LSHIFT (a_fraction);
 16.5785 ++	  }
 16.5786 ++      }
 16.5787 ++    else
 16.5788 ++      {
 16.5789 ++	/* Somethings's up.. choose the biggest */
 16.5790 ++	if (a_normal_exp > b_normal_exp)
 16.5791 ++	  {
 16.5792 ++	    b_normal_exp = a_normal_exp;
 16.5793 ++	    b_fraction = 0;
 16.5794 ++	  }
 16.5795 ++	else
 16.5796 ++	  {
 16.5797 ++	    a_normal_exp = b_normal_exp;
 16.5798 ++	    a_fraction = 0;
 16.5799 ++	  }
 16.5800 ++      }
 16.5801 ++  }
 16.5802 ++
 16.5803 ++  if (a->sign != b->sign)
 16.5804 ++    {
 16.5805 ++      if (a->sign)
 16.5806 ++	{
 16.5807 ++	  tfraction = -a_fraction + b_fraction;
 16.5808 ++	}
 16.5809 ++      else
 16.5810 ++	{
 16.5811 ++	  tfraction = a_fraction - b_fraction;
 16.5812 ++	}
 16.5813 ++      if (tfraction >= 0)
 16.5814 ++	{
 16.5815 ++	  tmp->sign = 0;
 16.5816 ++	  tmp->normal_exp = a_normal_exp;
 16.5817 ++	  tmp->fraction.ll = tfraction;
 16.5818 ++	}
 16.5819 ++      else
 16.5820 ++	{
 16.5821 ++	  tmp->sign = 1;
 16.5822 ++	  tmp->normal_exp = a_normal_exp;
 16.5823 ++	  tmp->fraction.ll = -tfraction;
 16.5824 ++	}
 16.5825 ++      /* and renormalize it */
 16.5826 ++
 16.5827 ++      while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
 16.5828 ++	{
 16.5829 ++	  tmp->fraction.ll <<= 1;
 16.5830 ++	  tmp->normal_exp--;
 16.5831 ++	}
 16.5832 ++    }
 16.5833 ++  else
 16.5834 ++    {
 16.5835 ++      tmp->sign = a->sign;
 16.5836 ++      tmp->normal_exp = a_normal_exp;
 16.5837 ++      tmp->fraction.ll = a_fraction + b_fraction;
 16.5838 ++    }
 16.5839 ++  tmp->class = CLASS_NUMBER;
 16.5840 ++  /* Now the fraction is added, we have to shift down to renormalize the
 16.5841 ++     number */
 16.5842 ++
 16.5843 ++  if (tmp->fraction.ll >= IMPLICIT_2)
 16.5844 ++    {
 16.5845 ++      LSHIFT (tmp->fraction.ll);
 16.5846 ++      tmp->normal_exp++;
 16.5847 ++    }
 16.5848 ++  return tmp;
 16.5849 ++
 16.5850 ++}
 16.5851 ++
 16.5852 ++FLO_type
 16.5853 ++add (FLO_type arg_a, FLO_type arg_b)
 16.5854 ++{
 16.5855 ++  fp_number_type a;
 16.5856 ++  fp_number_type b;
 16.5857 ++  fp_number_type tmp;
 16.5858 ++  fp_number_type *res;
 16.5859 ++  FLO_union_type au, bu;
 16.5860 ++
 16.5861 ++  au.value = arg_a;
 16.5862 ++  bu.value = arg_b;
 16.5863 ++
 16.5864 ++  unpack_d (&au, &a);
 16.5865 ++  unpack_d (&bu, &b);
 16.5866 ++
 16.5867 ++  res = _fpadd_parts (&a, &b, &tmp);
 16.5868 ++
 16.5869 ++  return pack_d (res);
 16.5870 ++}
 16.5871 ++
 16.5872 ++FLO_type
 16.5873 ++sub (FLO_type arg_a, FLO_type arg_b)
 16.5874 ++{
 16.5875 ++  fp_number_type a;
 16.5876 ++  fp_number_type b;
 16.5877 ++  fp_number_type tmp;
 16.5878 ++  fp_number_type *res;
 16.5879 ++  FLO_union_type au, bu;
 16.5880 ++
 16.5881 ++  au.value = arg_a;
 16.5882 ++  bu.value = arg_b;
 16.5883 ++
 16.5884 ++  unpack_d (&au, &a);
 16.5885 ++  unpack_d (&bu, &b);
 16.5886 ++
 16.5887 ++  b.sign ^= 1;
 16.5888 ++
 16.5889 ++  res = _fpadd_parts (&a, &b, &tmp);
 16.5890 ++
 16.5891 ++  return pack_d (res);
 16.5892 ++}
 16.5893 ++#endif /* L_addsub_sf || L_addsub_df */
 16.5894 ++
 16.5895 ++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
 16.5896 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
 16.5897 ++_fpmul_parts ( fp_number_type *  a,
 16.5898 ++	       fp_number_type *  b,
 16.5899 ++	       fp_number_type * tmp)
 16.5900 ++{
 16.5901 ++  fractype low = 0;
 16.5902 ++  fractype high = 0;
 16.5903 ++
 16.5904 ++  if (isnan (a))
 16.5905 ++    {
 16.5906 ++      a->sign = a->sign != b->sign;
 16.5907 ++      return a;
 16.5908 ++    }
 16.5909 ++  if (isnan (b))
 16.5910 ++    {
 16.5911 ++      b->sign = a->sign != b->sign;
 16.5912 ++      return b;
 16.5913 ++    }
 16.5914 ++  if (isinf (a))
 16.5915 ++    {
 16.5916 ++      if (iszero (b))
 16.5917 ++	return nan ();
 16.5918 ++      a->sign = a->sign != b->sign;
 16.5919 ++      return a;
 16.5920 ++    }
 16.5921 ++  if (isinf (b))
 16.5922 ++    {
 16.5923 ++      if (iszero (a))
 16.5924 ++	{
 16.5925 ++	  return nan ();
 16.5926 ++	}
 16.5927 ++      b->sign = a->sign != b->sign;
 16.5928 ++      return b;
 16.5929 ++    }
 16.5930 ++  if (iszero (a))
 16.5931 ++    {
 16.5932 ++      a->sign = a->sign != b->sign;
 16.5933 ++      return a;
 16.5934 ++    }
 16.5935 ++  if (iszero (b))
 16.5936 ++    {
 16.5937 ++      b->sign = a->sign != b->sign;
 16.5938 ++      return b;
 16.5939 ++    }
 16.5940 ++
 16.5941 ++  /* Calculate the mantissa by multiplying both numbers to get a
 16.5942 ++     twice-as-wide number.  */
 16.5943 ++  {
 16.5944 ++#if defined(NO_DI_MODE) || defined(TFLOAT)
 16.5945 ++    {
 16.5946 ++      fractype x = a->fraction.ll;
 16.5947 ++      fractype ylow = b->fraction.ll;
 16.5948 ++      fractype yhigh = 0;
 16.5949 ++      int bit;
 16.5950 ++
 16.5951 ++      /* ??? This does multiplies one bit at a time.  Optimize.  */
 16.5952 ++      for (bit = 0; bit < FRAC_NBITS; bit++)
 16.5953 ++	{
 16.5954 ++	  int carry;
 16.5955 ++
 16.5956 ++	  if (x & 1)
 16.5957 ++	    {
 16.5958 ++	      carry = (low += ylow) < ylow;
 16.5959 ++	      high += yhigh + carry;
 16.5960 ++	    }
 16.5961 ++	  yhigh <<= 1;
 16.5962 ++	  if (ylow & FRACHIGH)
 16.5963 ++	    {
 16.5964 ++	      yhigh |= 1;
 16.5965 ++	    }
 16.5966 ++	  ylow <<= 1;
 16.5967 ++	  x >>= 1;
 16.5968 ++	}
 16.5969 ++    }
 16.5970 ++#elif defined(FLOAT) 
 16.5971 ++    /* Multiplying two USIs to get a UDI, we're safe.  */
 16.5972 ++    {
 16.5973 ++      UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
 16.5974 ++      
 16.5975 ++      high = answer >> BITS_PER_SI;
 16.5976 ++      low = answer;
 16.5977 ++    }
 16.5978 ++#else
 16.5979 ++    /* fractype is DImode, but we need the result to be twice as wide.
 16.5980 ++       Assuming a widening multiply from DImode to TImode is not
 16.5981 ++       available, build one by hand.  */
 16.5982 ++    {
 16.5983 ++      USItype nl = a->fraction.ll;
 16.5984 ++      USItype nh = a->fraction.ll >> BITS_PER_SI;
 16.5985 ++      USItype ml = b->fraction.ll;
 16.5986 ++      USItype mh = b->fraction.ll >> BITS_PER_SI;
 16.5987 ++      UDItype pp_ll = (UDItype) ml * nl;
 16.5988 ++      UDItype pp_hl = (UDItype) mh * nl;
 16.5989 ++      UDItype pp_lh = (UDItype) ml * nh;
 16.5990 ++      UDItype pp_hh = (UDItype) mh * nh;
 16.5991 ++      UDItype res2 = 0;
 16.5992 ++      UDItype res0 = 0;
 16.5993 ++      UDItype ps_hh__ = pp_hl + pp_lh;
 16.5994 ++      if (ps_hh__ < pp_hl)
 16.5995 ++	res2 += (UDItype)1 << BITS_PER_SI;
 16.5996 ++      pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
 16.5997 ++      res0 = pp_ll + pp_hl;
 16.5998 ++      if (res0 < pp_ll)
 16.5999 ++	res2++;
 16.6000 ++      res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
 16.6001 ++      high = res2;
 16.6002 ++      low = res0;
 16.6003 ++    }
 16.6004 ++#endif
 16.6005 ++  }
 16.6006 ++
 16.6007 ++  tmp->normal_exp = a->normal_exp + b->normal_exp
 16.6008 ++    + FRAC_NBITS - (FRACBITS + NGARDS);
 16.6009 ++  tmp->sign = a->sign != b->sign;
 16.6010 ++  while (high >= IMPLICIT_2)
 16.6011 ++    {
 16.6012 ++      tmp->normal_exp++;
 16.6013 ++      if (high & 1)
 16.6014 ++	{
 16.6015 ++	  low >>= 1;
 16.6016 ++	  low |= FRACHIGH;
 16.6017 ++	}
 16.6018 ++      high >>= 1;
 16.6019 ++    }
 16.6020 ++  while (high < IMPLICIT_1)
 16.6021 ++    {
 16.6022 ++      tmp->normal_exp--;
 16.6023 ++
 16.6024 ++      high <<= 1;
 16.6025 ++      if (low & FRACHIGH)
 16.6026 ++	high |= 1;
 16.6027 ++      low <<= 1;
 16.6028 ++    }
 16.6029 ++  /* rounding is tricky. if we only round if it won't make us round later.  */
 16.6030 ++#if 0
 16.6031 ++  if (low & FRACHIGH2)
 16.6032 ++    {
 16.6033 ++      if (((high & GARDMASK) != GARDMSB)
 16.6034 ++	  && (((high + 1) & GARDMASK) == GARDMSB))
 16.6035 ++	{
 16.6036 ++	  /* don't round, it gets done again later.  */
 16.6037 ++	}
 16.6038 ++      else
 16.6039 ++	{
 16.6040 ++	  high++;
 16.6041 ++	}
 16.6042 ++    }
 16.6043 ++#endif
 16.6044 ++  if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
 16.6045 ++    {
 16.6046 ++      if (high & (1 << NGARDS))
 16.6047 ++	{
 16.6048 ++	  /* half way, so round to even */
 16.6049 ++	  high += GARDROUND + 1;
 16.6050 ++	}
 16.6051 ++      else if (low)
 16.6052 ++	{
 16.6053 ++	  /* but we really weren't half way */
 16.6054 ++	  high += GARDROUND + 1;
 16.6055 ++	}
 16.6056 ++    }
 16.6057 ++  tmp->fraction.ll = high;
 16.6058 ++  tmp->class = CLASS_NUMBER;
 16.6059 ++  return tmp;
 16.6060 ++}
 16.6061 ++
 16.6062 ++FLO_type
 16.6063 ++multiply (FLO_type arg_a, FLO_type arg_b)
 16.6064 ++{
 16.6065 ++  fp_number_type a;
 16.6066 ++  fp_number_type b;
 16.6067 ++  fp_number_type tmp;
 16.6068 ++  fp_number_type *res;
 16.6069 ++  FLO_union_type au, bu;
 16.6070 ++
 16.6071 ++  au.value = arg_a;
 16.6072 ++  bu.value = arg_b;
 16.6073 ++
 16.6074 ++  unpack_d (&au, &a);
 16.6075 ++  unpack_d (&bu, &b);
 16.6076 ++
 16.6077 ++  res = _fpmul_parts (&a, &b, &tmp);
 16.6078 ++
 16.6079 ++  return pack_d (res);
 16.6080 ++}
 16.6081 ++#endif /* L_mul_sf || L_mul_df */
 16.6082 ++
 16.6083 ++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
 16.6084 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
 16.6085 ++_fpdiv_parts (fp_number_type * a,
 16.6086 ++	      fp_number_type * b)
 16.6087 ++{
 16.6088 ++  fractype bit;
 16.6089 ++  fractype numerator;
 16.6090 ++  fractype denominator;
 16.6091 ++  fractype quotient;
 16.6092 ++
 16.6093 ++  if (isnan (a))
 16.6094 ++    {
 16.6095 ++      return a;
 16.6096 ++    }
 16.6097 ++  if (isnan (b))
 16.6098 ++    {
 16.6099 ++      return b;
 16.6100 ++    }
 16.6101 ++
 16.6102 ++  a->sign = a->sign ^ b->sign;
 16.6103 ++
 16.6104 ++  if (isinf (a) || iszero (a))
 16.6105 ++    {
 16.6106 ++      if (a->class == b->class)
 16.6107 ++	return nan ();
 16.6108 ++      return a;
 16.6109 ++    }
 16.6110 ++
 16.6111 ++  if (isinf (b))
 16.6112 ++    {
 16.6113 ++      a->fraction.ll = 0;
 16.6114 ++      a->normal_exp = 0;
 16.6115 ++      return a;
 16.6116 ++    }
 16.6117 ++  if (iszero (b))
 16.6118 ++    {
 16.6119 ++      a->class = CLASS_INFINITY;
 16.6120 ++      return a;
 16.6121 ++    }
 16.6122 ++
 16.6123 ++  /* Calculate the mantissa by multiplying both 64bit numbers to get a
 16.6124 ++     128 bit number */
 16.6125 ++  {
 16.6126 ++    /* quotient =
 16.6127 ++       ( numerator / denominator) * 2^(numerator exponent -  denominator exponent)
 16.6128 ++     */
 16.6129 ++
 16.6130 ++    a->normal_exp = a->normal_exp - b->normal_exp;
 16.6131 ++    numerator = a->fraction.ll;
 16.6132 ++    denominator = b->fraction.ll;
 16.6133 ++
 16.6134 ++    if (numerator < denominator)
 16.6135 ++      {
 16.6136 ++	/* Fraction will be less than 1.0 */
 16.6137 ++	numerator *= 2;
 16.6138 ++	a->normal_exp--;
 16.6139 ++      }
 16.6140 ++    bit = IMPLICIT_1;
 16.6141 ++    quotient = 0;
 16.6142 ++    /* ??? Does divide one bit at a time.  Optimize.  */
 16.6143 ++    while (bit)
 16.6144 ++      {
 16.6145 ++	if (numerator >= denominator)
 16.6146 ++	  {
 16.6147 ++	    quotient |= bit;
 16.6148 ++	    numerator -= denominator;
 16.6149 ++	  }
 16.6150 ++	bit >>= 1;
 16.6151 ++	numerator *= 2;
 16.6152 ++      }
 16.6153 ++
 16.6154 ++    if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
 16.6155 ++      {
 16.6156 ++	if (quotient & (1 << NGARDS))
 16.6157 ++	  {
 16.6158 ++	    /* half way, so round to even */
 16.6159 ++	    quotient += GARDROUND + 1;
 16.6160 ++	  }
 16.6161 ++	else if (numerator)
 16.6162 ++	  {
 16.6163 ++	    /* but we really weren't half way, more bits exist */
 16.6164 ++	    quotient += GARDROUND + 1;
 16.6165 ++	  }
 16.6166 ++      }
 16.6167 ++
 16.6168 ++    a->fraction.ll = quotient;
 16.6169 ++    return (a);
 16.6170 ++  }
 16.6171 ++}
 16.6172 ++
 16.6173 ++FLO_type
 16.6174 ++divide (FLO_type arg_a, FLO_type arg_b)
 16.6175 ++{
 16.6176 ++  fp_number_type a;
 16.6177 ++  fp_number_type b;
 16.6178 ++  fp_number_type *res;
 16.6179 ++  FLO_union_type au, bu;
 16.6180 ++
 16.6181 ++  au.value = arg_a;
 16.6182 ++  bu.value = arg_b;
 16.6183 ++
 16.6184 ++  unpack_d (&au, &a);
 16.6185 ++  unpack_d (&bu, &b);
 16.6186 ++
 16.6187 ++  res = _fpdiv_parts (&a, &b);
 16.6188 ++
 16.6189 ++  return pack_d (res);
 16.6190 ++}
 16.6191 ++#endif /* L_div_sf || L_div_df */
 16.6192 ++
 16.6193 ++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
 16.6194 ++    || defined(L_fpcmp_parts_tf)
 16.6195 ++/* according to the demo, fpcmp returns a comparison with 0... thus
 16.6196 ++   a<b -> -1
 16.6197 ++   a==b -> 0
 16.6198 ++   a>b -> +1
 16.6199 ++ */
 16.6200 ++
 16.6201 ++int
 16.6202 ++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
 16.6203 ++{
 16.6204 ++#if 0
 16.6205 ++  /* either nan -> unordered. Must be checked outside of this routine.  */
 16.6206 ++  if (isnan (a) && isnan (b))
 16.6207 ++    {
 16.6208 ++      return 1;			/* still unordered! */
 16.6209 ++    }
 16.6210 ++#endif
 16.6211 ++
 16.6212 ++  if (isnan (a) || isnan (b))
 16.6213 ++    {
 16.6214 ++      return 1;			/* how to indicate unordered compare? */
 16.6215 ++    }
 16.6216 ++  if (isinf (a) && isinf (b))
 16.6217 ++    {
 16.6218 ++      /* +inf > -inf, but +inf != +inf */
 16.6219 ++      /* b    \a| +inf(0)| -inf(1)
 16.6220 ++       ______\+--------+--------
 16.6221 ++       +inf(0)| a==b(0)| a<b(-1)
 16.6222 ++       -------+--------+--------
 16.6223 ++       -inf(1)| a>b(1) | a==b(0)
 16.6224 ++       -------+--------+--------
 16.6225 ++       So since unordered must be nonzero, just line up the columns...
 16.6226 ++       */
 16.6227 ++      return b->sign - a->sign;
 16.6228 ++    }
 16.6229 ++  /* but not both...  */
 16.6230 ++  if (isinf (a))
 16.6231 ++    {
 16.6232 ++      return a->sign ? -1 : 1;
 16.6233 ++    }
 16.6234 ++  if (isinf (b))
 16.6235 ++    {
 16.6236 ++      return b->sign ? 1 : -1;
 16.6237 ++    }
 16.6238 ++  if (iszero (a) && iszero (b))
 16.6239 ++    {
 16.6240 ++      return 0;
 16.6241 ++    }
 16.6242 ++  if (iszero (a))
 16.6243 ++    {
 16.6244 ++      return b->sign ? 1 : -1;
 16.6245 ++    }
 16.6246 ++  if (iszero (b))
 16.6247 ++    {
 16.6248 ++      return a->sign ? -1 : 1;
 16.6249 ++    }
 16.6250 ++  /* now both are "normal".  */
 16.6251 ++  if (a->sign != b->sign)
 16.6252 ++    {
 16.6253 ++      /* opposite signs */
 16.6254 ++      return a->sign ? -1 : 1;
 16.6255 ++    }
 16.6256 ++  /* same sign; exponents? */
 16.6257 ++  if (a->normal_exp > b->normal_exp)
 16.6258 ++    {
 16.6259 ++      return a->sign ? -1 : 1;
 16.6260 ++    }
 16.6261 ++  if (a->normal_exp < b->normal_exp)
 16.6262 ++    {
 16.6263 ++      return a->sign ? 1 : -1;
 16.6264 ++    }
 16.6265 ++  /* same exponents; check size.  */
 16.6266 ++  if (a->fraction.ll > b->fraction.ll)
 16.6267 ++    {
 16.6268 ++      return a->sign ? -1 : 1;
 16.6269 ++    }
 16.6270 ++  if (a->fraction.ll < b->fraction.ll)
 16.6271 ++    {
 16.6272 ++      return a->sign ? 1 : -1;
 16.6273 ++    }
 16.6274 ++  /* after all that, they're equal.  */
 16.6275 ++  return 0;
 16.6276 ++}
 16.6277 ++#endif
 16.6278 ++
 16.6279 ++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
 16.6280 ++CMPtype
 16.6281 ++compare (FLO_type arg_a, FLO_type arg_b)
 16.6282 ++{
 16.6283 ++  fp_number_type a;
 16.6284 ++  fp_number_type b;
 16.6285 ++  FLO_union_type au, bu;
 16.6286 ++
 16.6287 ++  au.value = arg_a;
 16.6288 ++  bu.value = arg_b;
 16.6289 ++
 16.6290 ++  unpack_d (&au, &a);
 16.6291 ++  unpack_d (&bu, &b);
 16.6292 ++
 16.6293 ++  return __fpcmp_parts (&a, &b);
 16.6294 ++}
 16.6295 ++#endif /* L_compare_sf || L_compare_df */
 16.6296 ++
 16.6297 ++#ifndef US_SOFTWARE_GOFAST
 16.6298 ++
 16.6299 ++/* These should be optimized for their specific tasks someday.  */
 16.6300 ++
 16.6301 ++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
 16.6302 ++CMPtype
 16.6303 ++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6304 ++{
 16.6305 ++  fp_number_type a;
 16.6306 ++  fp_number_type b;
 16.6307 ++  FLO_union_type au, bu;
 16.6308 ++
 16.6309 ++  au.value = arg_a;
 16.6310 ++  bu.value = arg_b;
 16.6311 ++
 16.6312 ++  unpack_d (&au, &a);
 16.6313 ++  unpack_d (&bu, &b);
 16.6314 ++
 16.6315 ++  if (isnan (&a) || isnan (&b))
 16.6316 ++    return 1;			/* false, truth == 0 */
 16.6317 ++
 16.6318 ++  return __fpcmp_parts (&a, &b) ;
 16.6319 ++}
 16.6320 ++#endif /* L_eq_sf || L_eq_df */
 16.6321 ++
 16.6322 ++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
 16.6323 ++CMPtype
 16.6324 ++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6325 ++{
 16.6326 ++  fp_number_type a;
 16.6327 ++  fp_number_type b;
 16.6328 ++  FLO_union_type au, bu;
 16.6329 ++
 16.6330 ++  au.value = arg_a;
 16.6331 ++  bu.value = arg_b;
 16.6332 ++
 16.6333 ++  unpack_d (&au, &a);
 16.6334 ++  unpack_d (&bu, &b);
 16.6335 ++
 16.6336 ++  if (isnan (&a) || isnan (&b))
 16.6337 ++    return 1;			/* true, truth != 0 */
 16.6338 ++
 16.6339 ++  return  __fpcmp_parts (&a, &b) ;
 16.6340 ++}
 16.6341 ++#endif /* L_ne_sf || L_ne_df */
 16.6342 ++
 16.6343 ++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
 16.6344 ++CMPtype
 16.6345 ++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6346 ++{
 16.6347 ++  fp_number_type a;
 16.6348 ++  fp_number_type b;
 16.6349 ++  FLO_union_type au, bu;
 16.6350 ++
 16.6351 ++  au.value = arg_a;
 16.6352 ++  bu.value = arg_b;
 16.6353 ++
 16.6354 ++  unpack_d (&au, &a);
 16.6355 ++  unpack_d (&bu, &b);
 16.6356 ++
 16.6357 ++  if (isnan (&a) || isnan (&b))
 16.6358 ++    return -1;			/* false, truth > 0 */
 16.6359 ++
 16.6360 ++  return __fpcmp_parts (&a, &b);
 16.6361 ++}
 16.6362 ++#endif /* L_gt_sf || L_gt_df */
 16.6363 ++
 16.6364 ++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
 16.6365 ++CMPtype
 16.6366 ++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6367 ++{
 16.6368 ++  fp_number_type a;
 16.6369 ++  fp_number_type b;
 16.6370 ++  FLO_union_type au, bu;
 16.6371 ++
 16.6372 ++  au.value = arg_a;
 16.6373 ++  bu.value = arg_b;
 16.6374 ++
 16.6375 ++  unpack_d (&au, &a);
 16.6376 ++  unpack_d (&bu, &b);
 16.6377 ++
 16.6378 ++  if (isnan (&a) || isnan (&b))
 16.6379 ++    return -1;			/* false, truth >= 0 */
 16.6380 ++  return __fpcmp_parts (&a, &b) ;
 16.6381 ++}
 16.6382 ++#endif /* L_ge_sf || L_ge_df */
 16.6383 ++
 16.6384 ++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
 16.6385 ++CMPtype
 16.6386 ++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6387 ++{
 16.6388 ++  fp_number_type a;
 16.6389 ++  fp_number_type b;
 16.6390 ++  FLO_union_type au, bu;
 16.6391 ++
 16.6392 ++  au.value = arg_a;
 16.6393 ++  bu.value = arg_b;
 16.6394 ++
 16.6395 ++  unpack_d (&au, &a);
 16.6396 ++  unpack_d (&bu, &b);
 16.6397 ++
 16.6398 ++  if (isnan (&a) || isnan (&b))
 16.6399 ++    return 1;			/* false, truth < 0 */
 16.6400 ++
 16.6401 ++  return __fpcmp_parts (&a, &b);
 16.6402 ++}
 16.6403 ++#endif /* L_lt_sf || L_lt_df */
 16.6404 ++
 16.6405 ++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
 16.6406 ++CMPtype
 16.6407 ++_le_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6408 ++{
 16.6409 ++  fp_number_type a;
 16.6410 ++  fp_number_type b;
 16.6411 ++  FLO_union_type au, bu;
 16.6412 ++
 16.6413 ++  au.value = arg_a;
 16.6414 ++  bu.value = arg_b;
 16.6415 ++
 16.6416 ++  unpack_d (&au, &a);
 16.6417 ++  unpack_d (&bu, &b);
 16.6418 ++
 16.6419 ++  if (isnan (&a) || isnan (&b))
 16.6420 ++    return 1;			/* false, truth <= 0 */
 16.6421 ++
 16.6422 ++  return __fpcmp_parts (&a, &b) ;
 16.6423 ++}
 16.6424 ++#endif /* L_le_sf || L_le_df */
 16.6425 ++
 16.6426 ++#endif /* ! US_SOFTWARE_GOFAST */
 16.6427 ++
 16.6428 ++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
 16.6429 ++CMPtype
 16.6430 ++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
 16.6431 ++{
 16.6432 ++  fp_number_type a;
 16.6433 ++  fp_number_type b;
 16.6434 ++  FLO_union_type au, bu;
 16.6435 ++
 16.6436 ++  au.value = arg_a;
 16.6437 ++  bu.value = arg_b;
 16.6438 ++
 16.6439 ++  unpack_d (&au, &a);
 16.6440 ++  unpack_d (&bu, &b);
 16.6441 ++
 16.6442 ++  return (isnan (&a) || isnan (&b));
 16.6443 ++}
 16.6444 ++#endif /* L_unord_sf || L_unord_df */
 16.6445 ++
 16.6446 ++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
 16.6447 ++FLO_type
 16.6448 ++si_to_float (SItype arg_a)
 16.6449 ++{
 16.6450 ++  fp_number_type in;
 16.6451 ++
 16.6452 ++  in.class = CLASS_NUMBER;
 16.6453 ++  in.sign = arg_a < 0;
 16.6454 ++  if (!arg_a)
 16.6455 ++    {
 16.6456 ++      in.class = CLASS_ZERO;
 16.6457 ++    }
 16.6458 ++  else
 16.6459 ++    {
 16.6460 ++      in.normal_exp = FRACBITS + NGARDS;
 16.6461 ++      if (in.sign) 
 16.6462 ++	{
 16.6463 ++	  /* Special case for minint, since there is no +ve integer
 16.6464 ++	     representation for it */
 16.6465 ++	  if (arg_a == (- MAX_SI_INT - 1))
 16.6466 ++	    {
 16.6467 ++	      return (FLO_type)(- MAX_SI_INT - 1);
 16.6468 ++	    }
 16.6469 ++	  in.fraction.ll = (-arg_a);
 16.6470 ++	}
 16.6471 ++      else
 16.6472 ++	in.fraction.ll = arg_a;
 16.6473 ++
 16.6474 ++      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
 16.6475 ++	{
 16.6476 ++	  in.fraction.ll <<= 1;
 16.6477 ++	  in.normal_exp -= 1;
 16.6478 ++	}
 16.6479 ++    }
 16.6480 ++  return pack_d (&in);
 16.6481 ++}
 16.6482 ++#endif /* L_si_to_sf || L_si_to_df */
 16.6483 ++
 16.6484 ++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
 16.6485 ++FLO_type
 16.6486 ++usi_to_float (USItype arg_a)
 16.6487 ++{
 16.6488 ++  fp_number_type in;
 16.6489 ++
 16.6490 ++  in.sign = 0;
 16.6491 ++  if (!arg_a)
 16.6492 ++    {
 16.6493 ++      in.class = CLASS_ZERO;
 16.6494 ++    }
 16.6495 ++  else
 16.6496 ++    {
 16.6497 ++      in.class = CLASS_NUMBER;
 16.6498 ++      in.normal_exp = FRACBITS + NGARDS;
 16.6499 ++      in.fraction.ll = arg_a;
 16.6500 ++
 16.6501 ++      while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
 16.6502 ++        {
 16.6503 ++          in.fraction.ll >>= 1;
 16.6504 ++          in.normal_exp += 1;
 16.6505 ++        }
 16.6506 ++      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
 16.6507 ++	{
 16.6508 ++	  in.fraction.ll <<= 1;
 16.6509 ++	  in.normal_exp -= 1;
 16.6510 ++	}
 16.6511 ++    }
 16.6512 ++  return pack_d (&in);
 16.6513 ++}
 16.6514 ++#endif
 16.6515 ++
 16.6516 ++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
 16.6517 ++SItype
 16.6518 ++float_to_si (FLO_type arg_a)
 16.6519 ++{
 16.6520 ++  fp_number_type a;
 16.6521 ++  SItype tmp;
 16.6522 ++  FLO_union_type au;
 16.6523 ++
 16.6524 ++  au.value = arg_a;
 16.6525 ++  unpack_d (&au, &a);
 16.6526 ++
 16.6527 ++  if (iszero (&a))
 16.6528 ++    return 0;
 16.6529 ++  if (isnan (&a))
 16.6530 ++    return 0;
 16.6531 ++  /* get reasonable MAX_SI_INT...  */
 16.6532 ++  if (isinf (&a))
 16.6533 ++    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
 16.6534 ++  /* it is a number, but a small one */
 16.6535 ++  if (a.normal_exp < 0)
 16.6536 ++    return 0;
 16.6537 ++  if (a.normal_exp > BITS_PER_SI - 2)
 16.6538 ++    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
 16.6539 ++  tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
 16.6540 ++  return a.sign ? (-tmp) : (tmp);
 16.6541 ++}
 16.6542 ++#endif /* L_sf_to_si || L_df_to_si */
 16.6543 ++
 16.6544 ++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
 16.6545 ++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
 16.6546 ++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
 16.6547 ++   we also define them for GOFAST because the ones in libgcc2.c have the
 16.6548 ++   wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
 16.6549 ++   out of libgcc2.c.  We can't define these here if not GOFAST because then
 16.6550 ++   there'd be duplicate copies.  */
 16.6551 ++
 16.6552 ++USItype
 16.6553 ++float_to_usi (FLO_type arg_a)
 16.6554 ++{
 16.6555 ++  fp_number_type a;
 16.6556 ++  FLO_union_type au;
 16.6557 ++
 16.6558 ++  au.value = arg_a;
 16.6559 ++  unpack_d (&au, &a);
 16.6560 ++
 16.6561 ++  if (iszero (&a))
 16.6562 ++    return 0;
 16.6563 ++  if (isnan (&a))
 16.6564 ++    return 0;
 16.6565 ++  /* it is a negative number */
 16.6566 ++  if (a.sign)
 16.6567 ++    return 0;
 16.6568 ++  /* get reasonable MAX_USI_INT...  */
 16.6569 ++  if (isinf (&a))
 16.6570 ++    return MAX_USI_INT;
 16.6571 ++  /* it is a number, but a small one */
 16.6572 ++  if (a.normal_exp < 0)
 16.6573 ++    return 0;
 16.6574 ++  if (a.normal_exp > BITS_PER_SI - 1)
 16.6575 ++    return MAX_USI_INT;
 16.6576 ++  else if (a.normal_exp > (FRACBITS + NGARDS))
 16.6577 ++    return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
 16.6578 ++  else
 16.6579 ++    return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
 16.6580 ++}
 16.6581 ++#endif /* US_SOFTWARE_GOFAST */
 16.6582 ++#endif /* L_sf_to_usi || L_df_to_usi */
 16.6583 ++
 16.6584 ++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
 16.6585 ++FLO_type
 16.6586 ++negate (FLO_type arg_a)
 16.6587 ++{
 16.6588 ++  fp_number_type a;
 16.6589 ++  FLO_union_type au;
 16.6590 ++
 16.6591 ++  au.value = arg_a;
 16.6592 ++  unpack_d (&au, &a);
 16.6593 ++
 16.6594 ++  flip_sign (&a);
 16.6595 ++  return pack_d (&a);
 16.6596 ++}
 16.6597 ++#endif /* L_negate_sf || L_negate_df */
 16.6598 ++
 16.6599 ++#ifdef FLOAT
 16.6600 ++
 16.6601 ++#if defined(L_make_sf)
 16.6602 ++SFtype
 16.6603 ++__make_fp(fp_class_type class,
 16.6604 ++	     unsigned int sign,
 16.6605 ++	     int exp, 
 16.6606 ++	     USItype frac)
 16.6607 ++{
 16.6608 ++  fp_number_type in;
 16.6609 ++
 16.6610 ++  in.class = class;
 16.6611 ++  in.sign = sign;
 16.6612 ++  in.normal_exp = exp;
 16.6613 ++  in.fraction.ll = frac;
 16.6614 ++  return pack_d (&in);
 16.6615 ++}
 16.6616 ++#endif /* L_make_sf */
 16.6617 ++
 16.6618 ++#ifndef FLOAT_ONLY
 16.6619 ++
 16.6620 ++/* This enables one to build an fp library that supports float but not double.
 16.6621 ++   Otherwise, we would get an undefined reference to __make_dp.
 16.6622 ++   This is needed for some 8-bit ports that can't handle well values that
 16.6623 ++   are 8-bytes in size, so we just don't support double for them at all.  */
 16.6624 ++
 16.6625 ++#if defined(L_sf_to_df)
 16.6626 ++DFtype
 16.6627 ++sf_to_df (SFtype arg_a)
 16.6628 ++{
 16.6629 ++  fp_number_type in;
 16.6630 ++  FLO_union_type au;
 16.6631 ++
 16.6632 ++  au.value = arg_a;
 16.6633 ++  unpack_d (&au, &in);
 16.6634 ++
 16.6635 ++  return __make_dp (in.class, in.sign, in.normal_exp,
 16.6636 ++		    ((UDItype) in.fraction.ll) << F_D_BITOFF);
 16.6637 ++}
 16.6638 ++#endif /* L_sf_to_df */
 16.6639 ++
 16.6640 ++#if defined(L_sf_to_tf) && defined(TMODES)
 16.6641 ++TFtype
 16.6642 ++sf_to_tf (SFtype arg_a)
 16.6643 ++{
 16.6644 ++  fp_number_type in;
 16.6645 ++  FLO_union_type au;
 16.6646 ++
 16.6647 ++  au.value = arg_a;
 16.6648 ++  unpack_d (&au, &in);
 16.6649 ++
 16.6650 ++  return __make_tp (in.class, in.sign, in.normal_exp,
 16.6651 ++		    ((UTItype) in.fraction.ll) << F_T_BITOFF);
 16.6652 ++}
 16.6653 ++#endif /* L_sf_to_df */
 16.6654 ++
 16.6655 ++#endif /* ! FLOAT_ONLY */
 16.6656 ++#endif /* FLOAT */
 16.6657 ++
 16.6658 ++#ifndef FLOAT
 16.6659 ++
 16.6660 ++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
 16.6661 ++
 16.6662 ++#if defined(L_make_df)
 16.6663 ++DFtype
 16.6664 ++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
 16.6665 ++{
 16.6666 ++  fp_number_type in;
 16.6667 ++
 16.6668 ++  in.class = class;
 16.6669 ++  in.sign = sign;
 16.6670 ++  in.normal_exp = exp;
 16.6671 ++  in.fraction.ll = frac;
 16.6672 ++  return pack_d (&in);
 16.6673 ++}
 16.6674 ++#endif /* L_make_df */
 16.6675 ++
 16.6676 ++#if defined(L_df_to_sf)
 16.6677 ++SFtype
 16.6678 ++df_to_sf (DFtype arg_a)
 16.6679 ++{
 16.6680 ++  fp_number_type in;
 16.6681 ++  USItype sffrac;
 16.6682 ++  FLO_union_type au;
 16.6683 ++
 16.6684 ++  au.value = arg_a;
 16.6685 ++  unpack_d (&au, &in);
 16.6686 ++
 16.6687 ++  sffrac = in.fraction.ll >> F_D_BITOFF;
 16.6688 ++
 16.6689 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.6690 ++     zero bits.  */
 16.6691 ++  if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
 16.6692 ++    sffrac |= 1;
 16.6693 ++
 16.6694 ++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
 16.6695 ++}
 16.6696 ++#endif /* L_df_to_sf */
 16.6697 ++
 16.6698 ++#if defined(L_df_to_tf) && defined(TMODES) \
 16.6699 ++    && !defined(FLOAT) && !defined(TFLOAT)
 16.6700 ++TFtype
 16.6701 ++df_to_tf (DFtype arg_a)
 16.6702 ++{
 16.6703 ++  fp_number_type in;
 16.6704 ++  FLO_union_type au;
 16.6705 ++
 16.6706 ++  au.value = arg_a;
 16.6707 ++  unpack_d (&au, &in);
 16.6708 ++
 16.6709 ++  return __make_tp (in.class, in.sign, in.normal_exp,
 16.6710 ++		    ((UTItype) in.fraction.ll) << D_T_BITOFF);
 16.6711 ++}
 16.6712 ++#endif /* L_sf_to_df */
 16.6713 ++
 16.6714 ++#ifdef TFLOAT
 16.6715 ++#if defined(L_make_tf)
 16.6716 ++TFtype
 16.6717 ++__make_tp(fp_class_type class,
 16.6718 ++	     unsigned int sign,
 16.6719 ++	     int exp, 
 16.6720 ++	     UTItype frac)
 16.6721 ++{
 16.6722 ++  fp_number_type in;
 16.6723 ++
 16.6724 ++  in.class = class;
 16.6725 ++  in.sign = sign;
 16.6726 ++  in.normal_exp = exp;
 16.6727 ++  in.fraction.ll = frac;
 16.6728 ++  return pack_d (&in);
 16.6729 ++}
 16.6730 ++#endif /* L_make_tf */
 16.6731 ++
 16.6732 ++#if defined(L_tf_to_df)
 16.6733 ++DFtype
 16.6734 ++tf_to_df (TFtype arg_a)
 16.6735 ++{
 16.6736 ++  fp_number_type in;
 16.6737 ++  UDItype sffrac;
 16.6738 ++  FLO_union_type au;
 16.6739 ++
 16.6740 ++  au.value = arg_a;
 16.6741 ++  unpack_d (&au, &in);
 16.6742 ++
 16.6743 ++  sffrac = in.fraction.ll >> D_T_BITOFF;
 16.6744 ++
 16.6745 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.6746 ++     zero bits.  */
 16.6747 ++  if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
 16.6748 ++    sffrac |= 1;
 16.6749 ++
 16.6750 ++  return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
 16.6751 ++}
 16.6752 ++#endif /* L_tf_to_df */
 16.6753 ++
 16.6754 ++#if defined(L_tf_to_sf)
 16.6755 ++SFtype
 16.6756 ++tf_to_sf (TFtype arg_a)
 16.6757 ++{
 16.6758 ++  fp_number_type in;
 16.6759 ++  USItype sffrac;
 16.6760 ++  FLO_union_type au;
 16.6761 ++
 16.6762 ++  au.value = arg_a;
 16.6763 ++  unpack_d (&au, &in);
 16.6764 ++
 16.6765 ++  sffrac = in.fraction.ll >> F_T_BITOFF;
 16.6766 ++
 16.6767 ++  /* We set the lowest guard bit in SFFRAC if we discarded any non
 16.6768 ++     zero bits.  */
 16.6769 ++  if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
 16.6770 ++    sffrac |= 1;
 16.6771 ++
 16.6772 ++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
 16.6773 ++}
 16.6774 ++#endif /* L_tf_to_sf */
 16.6775 ++#endif /* TFLOAT */
 16.6776 ++
 16.6777 ++#endif /* ! FLOAT */
 16.6778 ++#endif /* !EXTENDED_FLOAT_STUBS */
 16.6779 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.h gcc-3.4.6/gcc/config/nios2/nios2.h
 16.6780 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.h	1970-01-01 01:00:00.000000000 +0100
 16.6781 ++++ gcc-3.4.6/gcc/config/nios2/nios2.h	2007-08-15 23:09:36.000000000 +0200
 16.6782 +@@ -0,0 +1,824 @@
 16.6783 ++/* Definitions of target machine for Altera NIOS 2G NIOS2 version.
 16.6784 ++   Copyright (C) 2003 Altera 
 16.6785 ++   Contributed by Jonah Graham (jgraham@altera.com).
 16.6786 ++
 16.6787 ++This file is part of GNU CC.
 16.6788 ++
 16.6789 ++GNU CC is free software; you can redistribute it and/or modify
 16.6790 ++it under the terms of the GNU General Public License as published by
 16.6791 ++the Free Software Foundation; either version 2, or (at your option)
 16.6792 ++any later version.
 16.6793 ++
 16.6794 ++GNU CC is distributed in the hope that it will be useful,
 16.6795 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
 16.6796 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16.6797 ++GNU General Public License for more details.
 16.6798 ++
 16.6799 ++You should have received a copy of the GNU General Public License
 16.6800 ++along with GNU CC; see the file COPYING.  If not, write to
 16.6801 ++the Free Software Foundation, 59 Temple Place - Suite 330,
 16.6802 ++Boston, MA 02111-1307, USA.  */
 16.6803 ++
 16.6804 ++
 16.6805 ++
 16.6806 ++#define TARGET_CPU_CPP_BUILTINS()		\
 16.6807 ++  do						\
 16.6808 ++    {						\
 16.6809 ++      builtin_define_std ("NIOS2");		\
 16.6810 ++      builtin_define_std ("nios2");		\
 16.6811 ++      builtin_define ("_GNU_SOURCE");		\
 16.6812 ++    }						\
 16.6813 ++  while (0)
 16.6814 ++#define TARGET_VERSION fprintf (stderr, " (Altera Nios II)")
 16.6815 ++
 16.6816 ++
 16.6817 ++
 16.6818 ++
 16.6819 ++
 16.6820 ++/*********************************
 16.6821 ++ * Run-time Target Specification
 16.6822 ++ *********************************/
 16.6823 ++
 16.6824 ++#define HAS_DIV_FLAG 0x0001
 16.6825 ++#define HAS_MUL_FLAG 0x0002
 16.6826 ++#define HAS_MULX_FLAG 0x0004
 16.6827 ++#define FAST_SW_DIV_FLAG 0x0008
 16.6828 ++#define INLINE_MEMCPY_FLAG 0x00010
 16.6829 ++#define CACHE_VOLATILE_FLAG 0x0020
 16.6830 ++#define BYPASS_CACHE_FLAG 0x0040
 16.6831 ++
 16.6832 ++extern int target_flags;
 16.6833 ++#define TARGET_HAS_DIV (target_flags & HAS_DIV_FLAG)
 16.6834 ++#define TARGET_HAS_MUL (target_flags & HAS_MUL_FLAG)
 16.6835 ++#define TARGET_HAS_MULX (target_flags & HAS_MULX_FLAG)
 16.6836 ++#define TARGET_FAST_SW_DIV (target_flags & FAST_SW_DIV_FLAG)
 16.6837 ++#define TARGET_INLINE_MEMCPY (target_flags & INLINE_MEMCPY_FLAG)
 16.6838 ++#define TARGET_CACHE_VOLATILE (target_flags & CACHE_VOLATILE_FLAG)
 16.6839 ++#define TARGET_BYPASS_CACHE (target_flags & BYPASS_CACHE_FLAG)
 16.6840 ++
 16.6841 ++#define TARGET_SWITCHES					\
 16.6842 ++{							\
 16.6843 ++    { "hw-div", HAS_DIV_FLAG,				\
 16.6844 ++      N_("Enable DIV, DIVU") },				\
 16.6845 ++    { "no-hw-div", -HAS_DIV_FLAG,			\
 16.6846 ++      N_("Disable DIV, DIVU (default)") },		\
 16.6847 ++    { "hw-mul", HAS_MUL_FLAG,				\
 16.6848 ++      N_("Enable MUL instructions (default)") },				\
 16.6849 ++    { "hw-mulx", HAS_MULX_FLAG,				\
 16.6850 ++      N_("Enable MULX instructions, assume fast shifter") },				\
 16.6851 ++    { "no-hw-mul", -HAS_MUL_FLAG,			\
 16.6852 ++      N_("Disable MUL instructions") },		\
 16.6853 ++    { "no-hw-mulx", -HAS_MULX_FLAG,			\
 16.6854 ++      N_("Disable MULX instructions, assume slow shifter (default and implied by -mno-hw-mul)") },		\
 16.6855 ++    { "fast-sw-div", FAST_SW_DIV_FLAG,				\
 16.6856 ++      N_("Use table based fast divide (default at -O3)") },				\
 16.6857 ++    { "no-fast-sw-div", -FAST_SW_DIV_FLAG,			\
 16.6858 ++      N_("Don't use table based fast divide ever") },		\
 16.6859 ++    { "inline-memcpy", INLINE_MEMCPY_FLAG,				\
 16.6860 ++      N_("Inline small memcpy (default when optimizing)") },				\
 16.6861 ++    { "no-inline-memcpy", -INLINE_MEMCPY_FLAG,			\
 16.6862 ++      N_("Don't Inline small memcpy") },		\
 16.6863 ++    { "cache-volatile", CACHE_VOLATILE_FLAG,				\
 16.6864 ++      N_("Volatile accesses use non-io variants of instructions (default)") },				\
 16.6865 ++    { "no-cache-volatile", -CACHE_VOLATILE_FLAG,			\
 16.6866 ++      N_("Volatile accesses use io variants of instructions") },		\
 16.6867 ++    { "bypass-cache", BYPASS_CACHE_FLAG,				\
 16.6868 ++      N_("All ld/st instructins use io variants") },				\
 16.6869 ++    { "no-bypass-cache", -BYPASS_CACHE_FLAG,			\
 16.6870 ++      N_("All ld/st instructins do not use io variants (default)") },		\
 16.6871 ++    { "smallc", 0,			\
 16.6872 ++      N_("Link with a limited version of the C library") },		\
 16.6873 ++    { "ctors-in-init", 0,			\
 16.6874 ++      "" /* undocumented: N_("Link with static constructors and destructors in init") */ },		\
 16.6875 ++    { "", TARGET_DEFAULT, 0 }				\
 16.6876 ++}
 16.6877 ++
 16.6878 ++
 16.6879 ++extern const char *nios2_sys_nosys_string;    /* for -msys=nosys */
 16.6880 ++extern const char *nios2_sys_lib_string;    /* for -msys-lib= */
 16.6881 ++extern const char *nios2_sys_crt0_string;    /* for -msys-crt0= */
 16.6882 ++
 16.6883 ++#define TARGET_OPTIONS					\
 16.6884 ++{							\
 16.6885 ++  { "sys=nosys",    &nios2_sys_nosys_string,		\
 16.6886 ++      N_("Use stub versions of OS library calls (default)"), 0},	\
 16.6887 ++  { "sys-lib=",    &nios2_sys_lib_string,		\
 16.6888 ++      N_("Name of System Library to link against. (Converted to a -l option)"), 0},	\
 16.6889 ++  { "sys-crt0=",    &nios2_sys_crt0_string,		\
 16.6890 ++      N_("Name of the startfile. (default is a crt0 for the ISS only)"), 0},	\
 16.6891 ++}
 16.6892 ++
 16.6893 ++
 16.6894 ++/* Default target_flags if no switches specified.  */
 16.6895 ++#ifndef TARGET_DEFAULT
 16.6896 ++# define TARGET_DEFAULT (HAS_MUL_FLAG | CACHE_VOLATILE_FLAG)
 16.6897 ++#endif
 16.6898 ++
 16.6899 ++/* Switch  Recognition by gcc.c.  Add -G xx support */
 16.6900 ++#undef  SWITCH_TAKES_ARG
 16.6901 ++#define SWITCH_TAKES_ARG(CHAR)						\
 16.6902 ++  (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
 16.6903 ++
 16.6904 ++#define OVERRIDE_OPTIONS override_options ()
 16.6905 ++#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) optimization_options (LEVEL, SIZE)
 16.6906 ++#define CAN_DEBUG_WITHOUT_FP
 16.6907 ++ 
 16.6908 ++#define CC1_SPEC "\
 16.6909 ++%{G*}"
 16.6910 ++
 16.6911 ++#undef LIB_SPEC
 16.6912 ++#define LIB_SPEC \
 16.6913 ++"--start-group %{msmallc: -lsmallc} %{!msmallc: -lc} -lgcc \
 16.6914 ++ %{msys-lib=*: -l%*} \
 16.6915 ++ %{!msys-lib=*: -lc } \
 16.6916 ++ --end-group \
 16.6917 ++ %{msys-lib=: %eYou need a library name for -msys-lib=} \
 16.6918 ++"
 16.6919 ++
 16.6920 ++
 16.6921 ++#undef STARTFILE_SPEC 
 16.6922 ++#define STARTFILE_SPEC  \
 16.6923 ++"%{msys-crt0=*: %*} %{!msys-crt0=*: crt1%O%s} \
 16.6924 ++ %{msys-crt0=: %eYou need a C startup file for -msys-crt0=} \
 16.6925 ++ %{mctors-in-init: crti%O%s crtbegin%O%s} \
 16.6926 ++"
 16.6927 ++
 16.6928 ++#undef ENDFILE_SPEC 
 16.6929 ++#define ENDFILE_SPEC \
 16.6930 ++ "%{mctors-in-init: crtend%O%s crtn%O%s}"
 16.6931 ++
 16.6932 ++
 16.6933 ++/***********************
 16.6934 ++ * Storage Layout
 16.6935 ++ ***********************/
 16.6936 ++
 16.6937 ++#define DEFAULT_SIGNED_CHAR 1
 16.6938 ++#define BITS_BIG_ENDIAN 0
 16.6939 ++#define BYTES_BIG_ENDIAN 0
 16.6940 ++#define WORDS_BIG_ENDIAN 0
 16.6941 ++#define BITS_PER_UNIT 8
 16.6942 ++#define BITS_PER_WORD 32
 16.6943 ++#define UNITS_PER_WORD 4
 16.6944 ++#define POINTER_SIZE 32
 16.6945 ++#define BIGGEST_ALIGNMENT 32
 16.6946 ++#define STRICT_ALIGNMENT 1
 16.6947 ++#define FUNCTION_BOUNDARY 32
 16.6948 ++#define PARM_BOUNDARY 32
 16.6949 ++#define STACK_BOUNDARY 32
 16.6950 ++#define PREFERRED_STACK_BOUNDARY 32
 16.6951 ++#define MAX_FIXED_MODE_SIZE 64
 16.6952 ++
 16.6953 ++#define CONSTANT_ALIGNMENT(EXP, ALIGN)				\
 16.6954 ++  ((TREE_CODE (EXP) == STRING_CST) 				\
 16.6955 ++   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
 16.6956 ++
 16.6957 ++
 16.6958 ++/**********************
 16.6959 ++ * Layout of Source Language Data Types
 16.6960 ++ **********************/
 16.6961 ++
 16.6962 ++#define INT_TYPE_SIZE 32
 16.6963 ++#define SHORT_TYPE_SIZE 16
 16.6964 ++#define LONG_TYPE_SIZE 32
 16.6965 ++#define LONG_LONG_TYPE_SIZE 64
 16.6966 ++#define FLOAT_TYPE_SIZE 32
 16.6967 ++#define DOUBLE_TYPE_SIZE 64
 16.6968 ++#define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
 16.6969 ++
 16.6970 ++
 16.6971 ++/*************************
 16.6972 ++ * Condition Code Status
 16.6973 ++ ************************/
 16.6974 ++
 16.6975 ++/* comparison type */
 16.6976 ++/* ??? currently only CMP_SI is used */
 16.6977 ++enum cmp_type {
 16.6978 ++  CMP_SI,				/* compare four byte integers */
 16.6979 ++  CMP_DI,				/* compare eight byte integers */
 16.6980 ++  CMP_SF,				/* compare single precision floats */
 16.6981 ++  CMP_DF,				/* compare double precision floats */
 16.6982 ++  CMP_MAX				/* max comparison type */
 16.6983 ++};
 16.6984 ++
 16.6985 ++extern GTY(()) rtx branch_cmp[2];	/* operands for compare */
 16.6986 ++extern enum cmp_type branch_type;	/* what type of branch to use */
 16.6987 ++
 16.6988 ++/**********************
 16.6989 ++ * Register Usage
 16.6990 ++ **********************/
 16.6991 ++
 16.6992 ++/* ---------------------------------- *
 16.6993 ++ * Basic Characteristics of Registers
 16.6994 ++ * ---------------------------------- */
 16.6995 ++
 16.6996 ++/*
 16.6997 ++Register Number
 16.6998 ++      Register Name
 16.6999 ++          Alternate Name
 16.7000 ++                Purpose
 16.7001 ++0     r0  zero  always zero
 16.7002 ++1     r1  at    Assembler Temporary
 16.7003 ++2-3   r2-r3     Return Location
 16.7004 ++4-7   r4-r7     Register Arguments
 16.7005 ++8-15  r8-r15    Caller Saved Registers
 16.7006 ++16-22 r16-r22   Callee Saved Registers
 16.7007 ++23    r23 sc    Static Chain (Callee Saved)
 16.7008 ++                ??? Does $sc want to be caller or callee 
 16.7009 ++                saved. If caller, 15, else 23. 
 16.7010 ++24    r24       Exception Temporary
 16.7011 ++25    r25       Breakpoint Temporary
 16.7012 ++26    r26 gp    Global Pointer
 16.7013 ++27    r27 sp    Stack Pointer
 16.7014 ++28    r28 fp    Frame Pointer
 16.7015 ++29    r29 ea    Exception Return Address
 16.7016 ++30    r30 ba    Breakpoint Return Address
 16.7017 ++31    r31 ra    Return Address
 16.7018 ++
 16.7019 ++32    ctl0 status
 16.7020 ++33    ctl1 estatus STATUS saved by exception ? 	
 16.7021 ++34    ctl2 bstatus STATUS saved by break ? 	
 16.7022 ++35    ctl3 ipri    Interrupt Priority Mask ?	
 16.7023 ++36    ctl4 ecause  Exception Cause ? 	
 16.7024 ++
 16.7025 ++37         pc   Not an actual register	
 16.7026 ++
 16.7027 ++38    rap      Return address pointer, this does not
 16.7028 ++                   actually exist and will be eliminated
 16.7029 ++
 16.7030 ++39    fake_fp  Fake Frame Pointer which will always be eliminated.
 16.7031 ++40    fake_ap  Fake Argument Pointer which will always be eliminated.
 16.7032 ++
 16.7033 ++41             First Pseudo Register
 16.7034 ++
 16.7035 ++
 16.7036 ++The definitions for all the hard register numbers
 16.7037 ++are located in nios2.md.
 16.7038 ++*/
 16.7039 ++
 16.7040 ++#define FIRST_PSEUDO_REGISTER 41
 16.7041 ++#define NUM_ARG_REGS (LAST_ARG_REGNO - FIRST_ARG_REGNO + 1)
 16.7042 ++
 16.7043 ++
 16.7044 ++
 16.7045 ++/* also see CONDITIONAL_REGISTER_USAGE */
 16.7046 ++#define FIXED_REGISTERS			     \
 16.7047 ++    {					     \
 16.7048 ++/*        +0  1  2  3  4  5  6  7  8  9 */   \
 16.7049 ++/*   0 */  1, 1, 0, 0, 0, 0, 0, 0, 0, 0,     \
 16.7050 ++/*  10 */  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     \
 16.7051 ++/*  20 */  0, 0, 0, 0, 1, 1, 1, 1, 0, 1,     \
 16.7052 ++/*  30 */  1, 0, 1, 1, 1, 1, 1, 1, 1, 1,     \
 16.7053 ++/*  40 */  1,                                \
 16.7054 ++    }
 16.7055 ++
 16.7056 ++/* call used is the same as caller saved
 16.7057 ++   + fixed regs + args + ret vals */
 16.7058 ++#define CALL_USED_REGISTERS		     \
 16.7059 ++    { 					     \
 16.7060 ++/*        +0  1  2  3  4  5  6  7  8  9 */   \
 16.7061 ++/*   0 */  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     \
 16.7062 ++/*  10 */  1, 1, 1, 1, 1, 1, 0, 0, 0, 0,     \
 16.7063 ++/*  20 */  0, 0, 0, 0, 1, 1, 1, 1, 0, 1,     \
 16.7064 ++/*  30 */  1, 0, 1, 1, 1, 1, 1, 1, 1, 1,     \
 16.7065 ++/*  40 */  1,                                \
 16.7066 ++    }
 16.7067 ++
 16.7068 ++#define HARD_REGNO_NREGS(REGNO, MODE)            \
 16.7069 ++   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1)  \
 16.7070 ++    / UNITS_PER_WORD)
 16.7071 ++
 16.7072 ++/* --------------------------- *
 16.7073 ++ * How Values Fit in Registers
 16.7074 ++ * --------------------------- */
 16.7075 ++
 16.7076 ++#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
 16.7077 ++
 16.7078 ++#define MODES_TIEABLE_P(MODE1, MODE2) 1
 16.7079 ++
 16.7080 ++
 16.7081 ++/*************************
 16.7082 ++ * Register Classes
 16.7083 ++ *************************/
 16.7084 ++
 16.7085 ++enum reg_class
 16.7086 ++{
 16.7087 ++    NO_REGS,
 16.7088 ++    ALL_REGS,
 16.7089 ++    LIM_REG_CLASSES
 16.7090 ++};
 16.7091 ++
 16.7092 ++#define N_REG_CLASSES (int) LIM_REG_CLASSES
 16.7093 ++
 16.7094 ++#define REG_CLASS_NAMES   \
 16.7095 ++    {"NO_REGS",           \
 16.7096 ++     "ALL_REGS"}
 16.7097 ++
 16.7098 ++#define GENERAL_REGS ALL_REGS
 16.7099 ++
 16.7100 ++#define REG_CLASS_CONTENTS   \
 16.7101 ++/* NO_REGS  */       {{ 0, 0},     \
 16.7102 ++/* ALL_REGS */        {~0,~0}}    \
 16.7103 ++
 16.7104 ++#define REGNO_REG_CLASS(REGNO) ALL_REGS
 16.7105 ++
 16.7106 ++#define BASE_REG_CLASS ALL_REGS
 16.7107 ++#define INDEX_REG_CLASS ALL_REGS
 16.7108 ++
 16.7109 ++/* only one reg class, 'r', is handled automatically */
 16.7110 ++#define REG_CLASS_FROM_LETTER(CHAR) NO_REGS
 16.7111 ++
 16.7112 ++#define REGNO_OK_FOR_BASE_P2(REGNO, STRICT) \
 16.7113 ++    ((STRICT) \
 16.7114 ++     ? (REGNO) < FIRST_PSEUDO_REGISTER \
 16.7115 ++     : (REGNO) < FIRST_PSEUDO_REGISTER || (reg_renumber && reg_renumber[REGNO] < FIRST_PSEUDO_REGISTER))
 16.7116 ++
 16.7117 ++#define REGNO_OK_FOR_INDEX_P2(REGNO, STRICT) \
 16.7118 ++    (REGNO_OK_FOR_BASE_P2 (REGNO, STRICT))
 16.7119 ++
 16.7120 ++#define REGNO_OK_FOR_BASE_P(REGNO) \
 16.7121 ++    (REGNO_OK_FOR_BASE_P2 (REGNO, 1))
 16.7122 ++
 16.7123 ++#define REGNO_OK_FOR_INDEX_P(REGNO) \
 16.7124 ++    (REGNO_OK_FOR_INDEX_P2 (REGNO, 1))
 16.7125 ++
 16.7126 ++#define REG_OK_FOR_BASE_P2(X, STRICT)                                   \
 16.7127 ++    (STRICT                                                             \
 16.7128 ++     ? REGNO_OK_FOR_BASE_P2 (REGNO (X), 1)                              \
 16.7129 ++     : REGNO_OK_FOR_BASE_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
 16.7130 ++
 16.7131 ++#define REG_OK_FOR_INDEX_P2(X, STRICT)                                  \
 16.7132 ++    (STRICT                                                             \
 16.7133 ++     ? REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1)                             \
 16.7134 ++     : REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
 16.7135 ++
 16.7136 ++#define CLASS_MAX_NREGS(CLASS, MODE)             \
 16.7137 ++   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1)  \
 16.7138 ++    / UNITS_PER_WORD)
 16.7139 ++
 16.7140 ++
 16.7141 ++#define SMALL_INT(X) ((unsigned HOST_WIDE_INT) ((X) + 0x8000) < 0x10000)
 16.7142 ++#define SMALL_INT_UNSIGNED(X) ((unsigned HOST_WIDE_INT) (X) < 0x10000)
 16.7143 ++#define UPPER16_INT(X) (((X) & 0xffff) == 0)
 16.7144 ++#define SHIFT_INT(X) ((X) >= 0 && (X) <= 31)
 16.7145 ++#define RDWRCTL_INT(X) ((X) >= 0 && (X) <= 31)
 16.7146 ++#define CUSTOM_INSN_OPCODE(X) ((X) >= 0 && (X) <= 255)
 16.7147 ++
 16.7148 ++#define CONST_OK_FOR_LETTER_P(VALUE, C)			\
 16.7149 ++ (							\
 16.7150 ++  (C) == 'I' ? SMALL_INT (VALUE) :			\
 16.7151 ++  (C) == 'J' ? SMALL_INT_UNSIGNED (VALUE) :		\
 16.7152 ++  (C) == 'K' ? UPPER16_INT (VALUE) :         		\
 16.7153 ++  (C) == 'L' ? SHIFT_INT (VALUE) :			\
 16.7154 ++  (C) == 'M' ? (VALUE) == 0 :				\
 16.7155 ++  (C) == 'N' ? CUSTOM_INSN_OPCODE (VALUE) :		\
 16.7156 ++  (C) == 'O' ? RDWRCTL_INT (VALUE) :			\
 16.7157 ++  0)
 16.7158 ++
 16.7159 ++#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
 16.7160 ++
 16.7161 ++#define PREFERRED_RELOAD_CLASS(X, CLASS) \
 16.7162 ++    ((CLASS) == NO_REGS ? GENERAL_REGS : (CLASS))
 16.7163 ++
 16.7164 ++/* 'S' matches immediates which are in small data 
 16.7165 ++   and therefore can be added to gp to create a 
 16.7166 ++   32-bit value. */
 16.7167 ++#define EXTRA_CONSTRAINT(VALUE, C)		\
 16.7168 ++  ((C) == 'S' 					\
 16.7169 ++   && (GET_CODE (VALUE) == SYMBOL_REF)   	\
 16.7170 ++   && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (VALUE))
 16.7171 ++
 16.7172 ++
 16.7173 ++
 16.7174 ++
 16.7175 ++/* Say that the epilogue uses the return address register.  Note that
 16.7176 ++   in the case of sibcalls, the values "used by the epilogue" are
 16.7177 ++   considered live at the start of the called function.  */
 16.7178 ++#define EPILOGUE_USES(REGNO) ((REGNO) == RA_REGNO)
 16.7179 ++
 16.7180 ++
 16.7181 ++#define DEFAULT_MAIN_RETURN  c_expand_return (integer_zero_node)
 16.7182 ++
 16.7183 ++/**********************************
 16.7184 ++ * Trampolines for Nested Functions
 16.7185 ++ ***********************************/
 16.7186 ++
 16.7187 ++#define TRAMPOLINE_TEMPLATE(FILE) \
 16.7188 ++    error ("trampolines not yet implemented")
 16.7189 ++#define TRAMPOLINE_SIZE 20
 16.7190 ++#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
 16.7191 ++    error ("trampolines not yet implemented")
 16.7192 ++
 16.7193 ++/***************************
 16.7194 ++ * Stack Layout and Calling Conventions
 16.7195 ++ ***************************/
 16.7196 ++
 16.7197 ++/* ------------------ *
 16.7198 ++ * Basic Stack Layout
 16.7199 ++ * ------------------ */
 16.7200 ++
 16.7201 ++/* The downward variants are used by the compiler,
 16.7202 ++   the upward ones serve as documentation */
 16.7203 ++#define STACK_GROWS_DOWNWARD
 16.7204 ++#define FRAME_GROWS_UPWARD
 16.7205 ++#define ARGS_GROW_UPWARD
 16.7206 ++
 16.7207 ++#define STARTING_FRAME_OFFSET current_function_outgoing_args_size
 16.7208 ++#define FIRST_PARM_OFFSET(FUNDECL) 0
 16.7209 ++
 16.7210 ++/* Before the prologue, RA lives in r31.  */
 16.7211 ++#define INCOMING_RETURN_ADDR_RTX  gen_rtx_REG (VOIDmode, RA_REGNO)
 16.7212 ++
 16.7213 ++/* -------------------------------------- *
 16.7214 ++ * Registers That Address the Stack Frame
 16.7215 ++ * -------------------------------------- */
 16.7216 ++
 16.7217 ++#define STACK_POINTER_REGNUM SP_REGNO
 16.7218 ++#define STATIC_CHAIN_REGNUM SC_REGNO
 16.7219 ++#define PC_REGNUM PC_REGNO
 16.7220 ++#define DWARF_FRAME_RETURN_COLUMN RA_REGNO
 16.7221 ++
 16.7222 ++/* Base register for access to local variables of the function.  We
 16.7223 ++   pretend that the frame pointer is a non-existent hard register, and 
 16.7224 ++   then eliminate it to HARD_FRAME_POINTER_REGNUM. */
 16.7225 ++#define FRAME_POINTER_REGNUM FAKE_FP_REGNO
 16.7226 ++
 16.7227 ++#define HARD_FRAME_POINTER_REGNUM FP_REGNO
 16.7228 ++#define RETURN_ADDRESS_POINTER_REGNUM RAP_REGNO
 16.7229 ++/* the argumnet pointer needs to always be eliminated
 16.7230 ++   so it is set to a fake hard register. */
 16.7231 ++#define ARG_POINTER_REGNUM FAKE_AP_REGNO
 16.7232 ++
 16.7233 ++/* ----------------------------------------- *
 16.7234 ++ * Eliminating Frame Pointer and Arg Pointer
 16.7235 ++ * ----------------------------------------- */
 16.7236 ++
 16.7237 ++#define FRAME_POINTER_REQUIRED 0
 16.7238 ++
 16.7239 ++#define ELIMINABLE_REGS							\
 16.7240 ++{{ ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM},				\
 16.7241 ++ { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM},			\
 16.7242 ++ { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM},		\
 16.7243 ++ { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},		\
 16.7244 ++ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},				\
 16.7245 ++ { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
 16.7246 ++
 16.7247 ++#define CAN_ELIMINATE(FROM, TO)	1
 16.7248 ++
 16.7249 ++#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
 16.7250 ++	(OFFSET) = nios2_initial_elimination_offset ((FROM), (TO))
 16.7251 ++
 16.7252 ++#define MUST_SAVE_REGISTER(regno) \
 16.7253 ++ ((regs_ever_live[regno] && !call_used_regs[regno])			\
 16.7254 ++  || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)	\
 16.7255 ++  || (regno == RA_REGNO && regs_ever_live[RA_REGNO]))
 16.7256 ++
 16.7257 ++/* Treat LOC as a byte offset from the stack pointer and round it up
 16.7258 ++   to the next fully-aligned offset.  */
 16.7259 ++#define STACK_ALIGN(LOC)						\
 16.7260 ++  (((LOC) + ((PREFERRED_STACK_BOUNDARY / 8) - 1)) & ~((PREFERRED_STACK_BOUNDARY / 8) - 1))
 16.7261 ++
 16.7262 ++
 16.7263 ++/* ------------------------------ *
 16.7264 ++ * Passing Arguments in Registers
 16.7265 ++ * ------------------------------ */
 16.7266 ++
 16.7267 ++/* see nios2.c */
 16.7268 ++#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
 16.7269 ++  (function_arg (&CUM, MODE, TYPE, NAMED))
 16.7270 ++
 16.7271 ++#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
 16.7272 ++  (function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED))
 16.7273 ++
 16.7274 ++#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) 0
 16.7275 ++
 16.7276 ++#define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 0
 16.7277 ++
 16.7278 ++typedef struct nios2_args
 16.7279 ++{
 16.7280 ++    int regs_used;
 16.7281 ++} CUMULATIVE_ARGS;
 16.7282 ++
 16.7283 ++/* This is to initialize the above unused CUM data type */
 16.7284 ++#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
 16.7285 ++    (init_cumulative_args (&CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS))
 16.7286 ++
 16.7287 ++#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
 16.7288 ++    (function_arg_advance (&CUM, MODE, TYPE, NAMED))
 16.7289 ++
 16.7290 ++#define FUNCTION_ARG_REGNO_P(REGNO) \
 16.7291 ++    ((REGNO) >= FIRST_ARG_REGNO && (REGNO) <= LAST_ARG_REGNO)
 16.7292 ++
 16.7293 ++#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)   \
 16.7294 ++  {								    \
 16.7295 ++    int pret_size = nios2_setup_incoming_varargs (&(CUM), (MODE),	    \
 16.7296 ++						(TYPE), (NO_RTL));  \
 16.7297 ++    if (pret_size)						    \
 16.7298 ++      (PRETEND_SIZE) = pret_size;				    \
 16.7299 ++  }
 16.7300 ++
 16.7301 ++/* ----------------------------- *
 16.7302 ++ * Generating Code for Profiling
 16.7303 ++ * ----------------------------- */
 16.7304 ++
 16.7305 ++#define PROFILE_BEFORE_PROLOGUE
 16.7306 ++
 16.7307 ++#define FUNCTION_PROFILER(FILE, LABELNO) \
 16.7308 ++  function_profiler ((FILE), (LABELNO))
 16.7309 ++
 16.7310 ++/* --------------------------------------- *
 16.7311 ++ * Passing Function Arguments on the Stack
 16.7312 ++ * --------------------------------------- */
 16.7313 ++
 16.7314 ++#define PROMOTE_PROTOTYPES 1
 16.7315 ++
 16.7316 ++#define PUSH_ARGS 0
 16.7317 ++#define ACCUMULATE_OUTGOING_ARGS 1
 16.7318 ++
 16.7319 ++#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACKSIZE) 0
 16.7320 ++
 16.7321 ++/* --------------------------------------- *
 16.7322 ++ * How Scalar Function Values Are Returned
 16.7323 ++ * --------------------------------------- */
 16.7324 ++
 16.7325 ++#define FUNCTION_VALUE(VALTYPE, FUNC) \
 16.7326 ++    gen_rtx(REG, TYPE_MODE(VALTYPE), FIRST_RETVAL_REGNO)
 16.7327 ++
 16.7328 ++#define LIBCALL_VALUE(MODE) \
 16.7329 ++    gen_rtx(REG, MODE, FIRST_RETVAL_REGNO)
 16.7330 ++
 16.7331 ++#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == FIRST_RETVAL_REGNO)
 16.7332 ++
 16.7333 ++/* ----------------------------- *
 16.7334 ++ * How Large Values Are Returned
 16.7335 ++ * ----------------------------- */
 16.7336 ++
 16.7337 ++
 16.7338 ++#define RETURN_IN_MEMORY(TYPE)	\
 16.7339 ++  nios2_return_in_memory (TYPE)
 16.7340 ++
 16.7341 ++
 16.7342 ++#define STRUCT_VALUE 0
 16.7343 ++
 16.7344 ++#define DEFAULT_PCC_STRUCT_RETURN 0
 16.7345 ++
 16.7346 ++/*******************
 16.7347 ++ * Addressing Modes
 16.7348 ++ *******************/
 16.7349 ++
 16.7350 ++
 16.7351 ++#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
 16.7352 ++
 16.7353 ++#define CONSTANT_ADDRESS_P(X) (CONSTANT_P (X))
 16.7354 ++
 16.7355 ++#define MAX_REGS_PER_ADDRESS 1
 16.7356 ++
 16.7357 ++/* Go to ADDR if X is a valid address.  */
 16.7358 ++#ifndef REG_OK_STRICT
 16.7359 ++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)        \
 16.7360 ++    {                                                  \
 16.7361 ++        if (nios2_legitimate_address ((X), (MODE), 0))  \
 16.7362 ++            goto ADDR;                                 \
 16.7363 ++    }
 16.7364 ++#else
 16.7365 ++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)        \
 16.7366 ++    {                                                  \
 16.7367 ++        if (nios2_legitimate_address ((X), (MODE), 1))  \
 16.7368 ++            goto ADDR;                                 \
 16.7369 ++    }
 16.7370 ++#endif
 16.7371 ++
 16.7372 ++#ifndef REG_OK_STRICT
 16.7373 ++#define REG_OK_FOR_BASE_P(X)   REGNO_OK_FOR_BASE_P2 (REGNO (X), 0)
 16.7374 ++#define REG_OK_FOR_INDEX_P(X)  REGNO_OK_FOR_INDEX_P2 (REGNO (X), 0)
 16.7375 ++#else
 16.7376 ++#define REG_OK_FOR_BASE_P(X)   REGNO_OK_FOR_BASE_P2 (REGNO (X), 1)
 16.7377 ++#define REG_OK_FOR_INDEX_P(X)  REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1)
 16.7378 ++#endif
 16.7379 ++
 16.7380 ++#define LEGITIMATE_CONSTANT_P(X) 1
 16.7381 ++
 16.7382 ++/* Nios II has no mode dependent addresses.  */
 16.7383 ++#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
 16.7384 ++
 16.7385 ++/* Set if this has a weak declaration  */
 16.7386 ++#define SYMBOL_FLAG_WEAK_DECL	(1 << SYMBOL_FLAG_MACH_DEP_SHIFT)
 16.7387 ++#define SYMBOL_REF_WEAK_DECL_P(RTX) \
 16.7388 ++  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_WEAK_DECL) != 0)
 16.7389 ++
 16.7390 ++
 16.7391 ++/* true if a symbol is both small and not weak. In this case, gp
 16.7392 ++   relative access can be used */
 16.7393 ++#define SYMBOL_REF_IN_NIOS2_SMALL_DATA_P(RTX) \
 16.7394 ++   (SYMBOL_REF_SMALL_P(RTX) && !SYMBOL_REF_WEAK_DECL_P(RTX))
 16.7395 ++
 16.7396 ++/*****************
 16.7397 ++ * Describing Relative Costs of Operations
 16.7398 ++ *****************/
 16.7399 ++
 16.7400 ++#define SLOW_BYTE_ACCESS 1
 16.7401 ++
 16.7402 ++/* It is as good to call a constant function address as to call an address
 16.7403 ++   kept in a register.
 16.7404 ++   ??? Not true anymore really. Now that call cannot address full range
 16.7405 ++   of memory callr may need to be used */
 16.7406 ++
 16.7407 ++#define NO_FUNCTION_CSE
 16.7408 ++#define NO_RECURSIVE_FUNCTION_CSE
 16.7409 ++
 16.7410 ++
 16.7411 ++
 16.7412 ++/*****************************************
 16.7413 ++ * Defining the Output Assembler Language
 16.7414 ++ *****************************************/
 16.7415 ++
 16.7416 ++/* ------------------------------------------ *
 16.7417 ++ * The Overall Framework of an Assembler File
 16.7418 ++ * ------------------------------------------ */
 16.7419 ++
 16.7420 ++#define ASM_APP_ON "#APP\n"
 16.7421 ++#define ASM_APP_OFF "#NO_APP\n"
 16.7422 ++
 16.7423 ++#define ASM_COMMENT_START "# "
 16.7424 ++
 16.7425 ++/* ------------------------------- *
 16.7426 ++ * Output and Generation of Labels
 16.7427 ++ * ------------------------------- */
 16.7428 ++
 16.7429 ++#define GLOBAL_ASM_OP "\t.global\t"
 16.7430 ++
 16.7431 ++
 16.7432 ++/* -------------- *
 16.7433 ++ * Output of Data
 16.7434 ++ * -------------- */
 16.7435 ++
 16.7436 ++#define DWARF2_UNWIND_INFO 0
 16.7437 ++
 16.7438 ++
 16.7439 ++/* -------------------------------- *
 16.7440 ++ * Assembler Commands for Alignment
 16.7441 ++ * -------------------------------- */
 16.7442 ++
 16.7443 ++#define ASM_OUTPUT_ALIGN(FILE, LOG) \
 16.7444 ++  do { \
 16.7445 ++    fprintf ((FILE), "%s%d\n", ALIGN_ASM_OP, (LOG)); \
 16.7446 ++  } while (0)
 16.7447 ++
 16.7448 ++
 16.7449 ++/* -------------------------------- *
 16.7450 ++ * Output of Assembler Instructions
 16.7451 ++ * -------------------------------- */
 16.7452 ++
 16.7453 ++#define REGISTER_NAMES \
 16.7454 ++{ \
 16.7455 ++    "zero", \
 16.7456 ++    "at", \
 16.7457 ++    "r2", \
 16.7458 ++    "r3", \
 16.7459 ++    "r4", \
 16.7460 ++    "r5", \
 16.7461 ++    "r6", \
 16.7462 ++    "r7", \
 16.7463 ++    "r8", \
 16.7464 ++    "r9", \
 16.7465 ++    "r10", \
 16.7466 ++    "r11", \
 16.7467 ++    "r12", \
 16.7468 ++    "r13", \
 16.7469 ++    "r14", \
 16.7470 ++    "r15", \
 16.7471 ++    "r16", \
 16.7472 ++    "r17", \
 16.7473 ++    "r18", \
 16.7474 ++    "r19", \
 16.7475 ++    "r20", \
 16.7476 ++    "r21", \
 16.7477 ++    "r22", \
 16.7478 ++    "r23", \
 16.7479 ++    "r24", \
 16.7480 ++    "r25", \
 16.7481 ++    "gp", \
 16.7482 ++    "sp", \
 16.7483 ++    "fp", \
 16.7484 ++    "ta", \
 16.7485 ++    "ba", \
 16.7486 ++    "ra", \
 16.7487 ++    "status", \
 16.7488 ++    "estatus", \
 16.7489 ++    "bstatus", \
 16.7490 ++    "ipri", \
 16.7491 ++    "ecause", \
 16.7492 ++    "pc", \
 16.7493 ++    "rap", \
 16.7494 ++    "fake_fp", \
 16.7495 ++    "fake_ap", \
 16.7496 ++}
 16.7497 ++
 16.7498 ++#define ASM_OUTPUT_OPCODE(STREAM, PTR)\
 16.7499 ++   (PTR) = asm_output_opcode (STREAM, PTR)
 16.7500 ++
 16.7501 ++#define PRINT_OPERAND(STREAM, X, CODE) \
 16.7502 ++    nios2_print_operand (STREAM, X, CODE)
 16.7503 ++
 16.7504 ++#define PRINT_OPERAND_ADDRESS(STREAM, X) \
 16.7505 ++    nios2_print_operand_address (STREAM, X)
 16.7506 ++
 16.7507 ++#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
 16.7508 ++do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \
 16.7509 ++     fprintf (FILE, ".L%u\n", (unsigned) (VALUE));               \
 16.7510 ++   } while (0)
 16.7511 ++
 16.7512 ++
 16.7513 ++/* ------------ *
 16.7514 ++ * Label Output
 16.7515 ++ * ------------ */
 16.7516 ++
 16.7517 ++
 16.7518 ++/* ---------------------------------------------------- *
 16.7519 ++ * Dividing the Output into Sections (Texts, Data, ...)
 16.7520 ++ * ---------------------------------------------------- */
 16.7521 ++
 16.7522 ++/* Output before read-only data.  */
 16.7523 ++#define TEXT_SECTION_ASM_OP ("\t.section\t.text")
 16.7524 ++
 16.7525 ++/* Output before writable data.  */
 16.7526 ++#define DATA_SECTION_ASM_OP ("\t.section\t.data")
 16.7527 ++
 16.7528 ++
 16.7529 ++/* Default the definition of "small data" to 8 bytes. */
 16.7530 ++/* ??? How come I can't use HOST_WIDE_INT here? */
 16.7531 ++extern unsigned long nios2_section_threshold;
 16.7532 ++#define NIOS2_DEFAULT_GVALUE 8
 16.7533 ++
 16.7534 ++
 16.7535 ++
 16.7536 ++/* This says how to output assembler code to declare an
 16.7537 ++   uninitialized external linkage data object.  Under SVR4,
 16.7538 ++   the linker seems to want the alignment of data objects
 16.7539 ++   to depend on their types.  We do exactly that here.  */
 16.7540 ++
 16.7541 ++#undef COMMON_ASM_OP
 16.7542 ++#define COMMON_ASM_OP	"\t.comm\t"
 16.7543 ++
 16.7544 ++#undef  ASM_OUTPUT_ALIGNED_COMMON
 16.7545 ++#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
 16.7546 ++do 									\
 16.7547 ++{									\
 16.7548 ++  if ((SIZE) <= nios2_section_threshold)				\
 16.7549 ++    {									\
 16.7550 ++      named_section (0, ".sbss", 0);					\
 16.7551 ++      (*targetm.asm_out.globalize_label) (FILE, NAME);			\
 16.7552 ++      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");			\
 16.7553 ++      if (!flag_inhibit_size_directive)					\
 16.7554 ++	ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE);			\
 16.7555 ++      ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT));	\
 16.7556 ++      ASM_OUTPUT_LABEL(FILE, NAME);					\
 16.7557 ++      ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1);			\
 16.7558 ++    }									\
 16.7559 ++  else									\
 16.7560 ++    {									\
 16.7561 ++      fprintf ((FILE), "%s", COMMON_ASM_OP);				\
 16.7562 ++      assemble_name ((FILE), (NAME));					\
 16.7563 ++      fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);	\
 16.7564 ++    }									\
 16.7565 ++}									\
 16.7566 ++while (0)
 16.7567 ++
 16.7568 ++
 16.7569 ++/* This says how to output assembler code to declare an
 16.7570 ++   uninitialized internal linkage data object.  Under SVR4,
 16.7571 ++   the linker seems to want the alignment of data objects
 16.7572 ++   to depend on their types.  We do exactly that here.  */
 16.7573 ++
 16.7574 ++#undef  ASM_OUTPUT_ALIGNED_LOCAL
 16.7575 ++#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
 16.7576 ++do {									\
 16.7577 ++  if ((SIZE) <= nios2_section_threshold)				\
 16.7578 ++    named_section (0, ".sbss", 0);					\
 16.7579 ++  else									\
 16.7580 ++    named_section (0, ".bss", 0);					\
 16.7581 ++  ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");			\
 16.7582 ++  if (!flag_inhibit_size_directive)					\
 16.7583 ++    ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE);			\
 16.7584 ++  ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT));	\
 16.7585 ++  ASM_OUTPUT_LABEL(FILE, NAME);						\
 16.7586 ++  ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1);				\
 16.7587 ++} while (0)
 16.7588 ++
 16.7589 ++
 16.7590 ++
 16.7591 ++/***************************
 16.7592 ++ * Miscellaneous Parameters
 16.7593 ++ ***************************/
 16.7594 ++
 16.7595 ++#define MOVE_MAX 4
 16.7596 ++
 16.7597 ++#define Pmode SImode
 16.7598 ++#define FUNCTION_MODE QImode
 16.7599 ++
 16.7600 ++#define CASE_VECTOR_MODE Pmode
 16.7601 ++
 16.7602 ++#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
 16.7603 ++
 16.7604 ++#define LOAD_EXTEND_OP(MODE) (ZERO_EXTEND)
 16.7605 ++
 16.7606 ++#define WORD_REGISTER_OPERATIONS
 16.7607 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.md gcc-3.4.6/gcc/config/nios2/nios2.md
 16.7608 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.md	1970-01-01 01:00:00.000000000 +0100
 16.7609 ++++ gcc-3.4.6/gcc/config/nios2/nios2.md	2007-08-15 23:09:36.000000000 +0200
 16.7610 +@@ -0,0 +1,2078 @@
 16.7611 ++;; Machine Description for Altera NIOS 2G NIOS2 version.
 16.7612 ++;;    Copyright (C) 2003 Altera 
 16.7613 ++;;    Contributed by Jonah Graham (jgraham@altera.com).
 16.7614 ++;; 
 16.7615 ++;; This file is part of GNU CC.
 16.7616 ++;; 
 16.7617 ++;; GNU CC is free software; you can redistribute it and/or modify
 16.7618 ++;; it under the terms of the GNU General Public License as published by
 16.7619 ++;; the Free Software Foundation; either version 2, or (at your option)
 16.7620 ++;; any later version.
 16.7621 ++;; 
 16.7622 ++;; GNU CC is distributed in the hope that it will be useful,
 16.7623 ++;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 16.7624 ++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16.7625 ++;; GNU General Public License for more details.
 16.7626 ++;; 
 16.7627 ++;; You should have received a copy of the GNU General Public License
 16.7628 ++;; along with GNU CC; see the file COPYING.  If not, write to
 16.7629 ++;; the Free Software Foundation, 59 Temple Place - Suite 330,
 16.7630 ++;; Boston, MA 02111-1307, USA.  */
 16.7631 ++
 16.7632 ++
 16.7633 ++
 16.7634 ++;*****************************************************************************
 16.7635 ++;*
 16.7636 ++;* constants
 16.7637 ++;*
 16.7638 ++;*****************************************************************************
 16.7639 ++(define_constants [
 16.7640 ++  (GP_REGNO 26)
 16.7641 ++  (SP_REGNO 27)
 16.7642 ++  (FP_REGNO 28)
 16.7643 ++  (RA_REGNO 31)
 16.7644 ++  (RAP_REGNO 38)
 16.7645 ++  (FIRST_RETVAL_REGNO 2)
 16.7646 ++  (LAST_RETVAL_REGNO 3)
 16.7647 ++  (FIRST_ARG_REGNO 4)
 16.7648 ++  (LAST_ARG_REGNO 7)
 16.7649 ++  (SC_REGNO 23)
 16.7650 ++  (PC_REGNO 37)
 16.7651 ++  (FAKE_FP_REGNO 39)
 16.7652 ++  (FAKE_AP_REGNO 40)
 16.7653 ++
 16.7654 ++
 16.7655 ++  (UNSPEC_BLOCKAGE 0)
 16.7656 ++  (UNSPEC_LDBIO 1)
 16.7657 ++  (UNSPEC_LDBUIO 2)
 16.7658 ++  (UNSPEC_LDHIO 3)
 16.7659 ++  (UNSPEC_LDHUIO 4)
 16.7660 ++  (UNSPEC_LDWIO 5)
 16.7661 ++  (UNSPEC_STBIO 6)
 16.7662 ++  (UNSPEC_STHIO 7)
 16.7663 ++  (UNSPEC_STWIO 8)
 16.7664 ++  (UNSPEC_SYNC 9)
 16.7665 ++  (UNSPEC_WRCTL 10)
 16.7666 ++  (UNSPEC_RDCTL 11)
 16.7667 ++  
 16.7668 ++])
 16.7669 ++
 16.7670 ++
 16.7671 ++
 16.7672 ++;*****************************************************************************
 16.7673 ++;*
 16.7674 ++;* instruction scheduler
 16.7675 ++;*
 16.7676 ++;*****************************************************************************
 16.7677 ++
 16.7678 ++; No schedule info is currently available, using an assumption that no
 16.7679 ++; instruction can use the results of the previous instruction without
 16.7680 ++; incuring a stall.
 16.7681 ++
 16.7682 ++; length of an instruction (in bytes)
 16.7683 ++(define_attr "length" "" (const_int 4))
 16.7684 ++(define_attr "type" "unknown,complex,control,alu,cond_alu,st,ld,shift,mul,div,custom" (const_string "complex"))
 16.7685 ++
 16.7686 ++(define_asm_attributes
 16.7687 ++ [(set_attr "length" "4")
 16.7688 ++  (set_attr "type" "complex")])
 16.7689 ++
 16.7690 ++(define_automaton "nios2")
 16.7691 ++(automata_option "v")
 16.7692 ++;(automata_option "no-minimization")
 16.7693 ++(automata_option "ndfa")
 16.7694 ++
 16.7695 ++; The nios2 pipeline is fairly straightforward for the fast model.
 16.7696 ++; Every alu operation is pipelined so that an instruction can
 16.7697 ++; be issued every cycle. However, there are still potential
 16.7698 ++; stalls which this description tries to deal with.
 16.7699 ++
 16.7700 ++(define_cpu_unit "cpu" "nios2")
 16.7701 ++
 16.7702 ++(define_insn_reservation "complex" 1
 16.7703 ++  (eq_attr "type" "complex")
 16.7704 ++  "cpu")
 16.7705 ++
 16.7706 ++(define_insn_reservation "control" 1
 16.7707 ++  (eq_attr "type" "control")
 16.7708 ++  "cpu")
 16.7709 ++
 16.7710 ++(define_insn_reservation "alu" 1
 16.7711 ++  (eq_attr "type" "alu")
 16.7712 ++  "cpu")
 16.7713 ++
 16.7714 ++(define_insn_reservation "cond_alu" 1
 16.7715 ++  (eq_attr "type" "cond_alu")
 16.7716 ++  "cpu")
 16.7717 ++
 16.7718 ++(define_insn_reservation "st" 1
 16.7719 ++  (eq_attr "type" "st")
 16.7720 ++  "cpu")
 16.7721 ++  
 16.7722 ++(define_insn_reservation "custom" 1
 16.7723 ++  (eq_attr "type" "custom")
 16.7724 ++  "cpu")
 16.7725 ++
 16.7726 ++; shifts, muls and lds have three cycle latency
 16.7727 ++(define_insn_reservation "ld" 3
 16.7728 ++  (eq_attr "type" "ld")
 16.7729 ++  "cpu")
 16.7730 ++
 16.7731 ++(define_insn_reservation "shift" 3
 16.7732 ++  (eq_attr "type" "shift")
 16.7733 ++  "cpu")
 16.7734 ++
 16.7735 ++(define_insn_reservation "mul" 3
 16.7736 ++  (eq_attr "type" "mul")
 16.7737 ++  "cpu")
 16.7738 ++
 16.7739 ++(define_insn_reservation "div" 1
 16.7740 ++  (eq_attr "type" "div")
 16.7741 ++  "cpu")
 16.7742 ++
 16.7743 ++
 16.7744 ++;*****************************************************************************
 16.7745 ++;*
 16.7746 ++;* MOV Instructions
 16.7747 ++;*
 16.7748 ++;*****************************************************************************
 16.7749 ++
 16.7750 ++(define_expand "movqi"
 16.7751 ++  [(set (match_operand:QI 0 "nonimmediate_operand" "")
 16.7752 ++        (match_operand:QI 1 "general_operand" ""))]
 16.7753 ++  ""
 16.7754 ++{
 16.7755 ++  if (nios2_emit_move_sequence (operands, QImode))
 16.7756 ++    DONE;
 16.7757 ++})
 16.7758 ++
 16.7759 ++(define_insn "movqi_internal"
 16.7760 ++  [(set (match_operand:QI 0 "nonimmediate_operand" "=m, r,r, r")
 16.7761 ++        (match_operand:QI 1 "general_operand"       "rM,m,rM,I"))]
 16.7762 ++  "(register_operand (operands[0], QImode)
 16.7763 ++    || register_operand (operands[1], QImode)
 16.7764 ++    || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
 16.7765 ++  "@
 16.7766 ++    stb%o0\\t%z1, %0
 16.7767 ++    ldbu%o1\\t%0, %1
 16.7768 ++    mov\\t%0, %z1
 16.7769 ++    movi\\t%0, %1"
 16.7770 ++  [(set_attr "type" "st,ld,alu,alu")])
 16.7771 ++
 16.7772 ++(define_insn "ldbio"
 16.7773 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7774 ++	(unspec_volatile:SI [(const_int 0)] UNSPEC_LDBIO))
 16.7775 ++   (use (match_operand:SI 1 "memory_operand" "m"))]
 16.7776 ++  ""
 16.7777 ++  "ldbio\\t%0, %1"
 16.7778 ++  [(set_attr "type" "ld")])
 16.7779 ++
 16.7780 ++(define_insn "ldbuio"
 16.7781 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7782 ++	(unspec_volatile:SI [(const_int 0)] UNSPEC_LDBUIO))
 16.7783 ++   (use (match_operand:SI 1 "memory_operand" "m"))]
 16.7784 ++  ""
 16.7785 ++  "ldbuio\\t%0, %1"
 16.7786 ++  [(set_attr "type" "ld")])
 16.7787 ++
 16.7788 ++(define_insn "stbio"
 16.7789 ++  [(set (match_operand:SI 0 "memory_operand" "=m")
 16.7790 ++	(match_operand:SI 1 "register_operand"   "r"))
 16.7791 ++   (unspec_volatile:SI [(const_int 0)] UNSPEC_STBIO)]
 16.7792 ++  ""
 16.7793 ++  "stbio\\t%z1, %0"
 16.7794 ++  [(set_attr "type" "st")])
 16.7795 ++
 16.7796 ++
 16.7797 ++(define_expand "movhi"
 16.7798 ++  [(set (match_operand:HI 0 "nonimmediate_operand" "")
 16.7799 ++        (match_operand:HI 1 "general_operand" ""))]
 16.7800 ++  ""
 16.7801 ++{
 16.7802 ++  if (nios2_emit_move_sequence (operands, HImode))
 16.7803 ++    DONE;
 16.7804 ++})
 16.7805 ++
 16.7806 ++(define_insn "movhi_internal"
 16.7807 ++  [(set (match_operand:HI 0 "nonimmediate_operand" "=m, r,r, r,r")
 16.7808 ++        (match_operand:HI 1 "general_operand"       "rM,m,rM,I,J"))]
 16.7809 ++  "(register_operand (operands[0], HImode)
 16.7810 ++    || register_operand (operands[1], HImode)
 16.7811 ++    || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
 16.7812 ++  "@
 16.7813 ++    sth%o0\\t%z1, %0
 16.7814 ++    ldhu%o1\\t%0, %1
 16.7815 ++    mov\\t%0, %z1
 16.7816 ++    movi\\t%0, %1
 16.7817 ++    movui\\t%0, %1"
 16.7818 ++  [(set_attr "type" "st,ld,alu,alu,alu")])
 16.7819 ++
 16.7820 ++(define_insn "ldhio"
 16.7821 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7822 ++	(unspec_volatile:SI [(const_int 0)] UNSPEC_LDHIO))
 16.7823 ++   (use (match_operand:SI 1 "memory_operand" "m"))]
 16.7824 ++  ""
 16.7825 ++  "ldhio\\t%0, %1"
 16.7826 ++  [(set_attr "type" "ld")])
 16.7827 ++
 16.7828 ++(define_insn "ldhuio"
 16.7829 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7830 ++	(unspec_volatile:SI [(const_int 0)] UNSPEC_LDHUIO))
 16.7831 ++   (use (match_operand:SI 1 "memory_operand" "m"))]
 16.7832 ++  ""
 16.7833 ++  "ldhuio\\t%0, %1"
 16.7834 ++  [(set_attr "type" "ld")])
 16.7835 ++
 16.7836 ++(define_insn "sthio"
 16.7837 ++  [(set (match_operand:SI 0 "memory_operand" "=m")
 16.7838 ++	(match_operand:SI 1 "register_operand"   "r"))
 16.7839 ++   (unspec_volatile:SI [(const_int 0)] UNSPEC_STHIO)]
 16.7840 ++  ""
 16.7841 ++  "sthio\\t%z1, %0"
 16.7842 ++  [(set_attr "type" "st")])
 16.7843 ++
 16.7844 ++(define_expand "movsi"
 16.7845 ++  [(set (match_operand:SI 0 "nonimmediate_operand" "")
 16.7846 ++        (match_operand:SI 1 "general_operand" ""))]
 16.7847 ++  ""
 16.7848 ++{
 16.7849 ++  if (nios2_emit_move_sequence (operands, SImode))
 16.7850 ++    DONE;
 16.7851 ++})
 16.7852 ++
 16.7853 ++(define_insn "movsi_internal"
 16.7854 ++  [(set (match_operand:SI 0 "nonimmediate_operand" "=m, r,r, r,r,r,r")
 16.7855 ++        (match_operand:SI 1 "general_operand"       "rM,m,rM,I,J,S,i"))]
 16.7856 ++  "(register_operand (operands[0], SImode)
 16.7857 ++    || register_operand (operands[1], SImode)
 16.7858 ++    || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
 16.7859 ++  "@
 16.7860 ++    stw%o0\\t%z1, %0
 16.7861 ++    ldw%o1\\t%0, %1
 16.7862 ++    mov\\t%0, %z1
 16.7863 ++    movi\\t%0, %1
 16.7864 ++    movui\\t%0, %1
 16.7865 ++    addi\\t%0, gp, %%gprel(%1)
 16.7866 ++    movhi\\t%0, %H1\;addi\\t%0, %0, %L1"
 16.7867 ++  [(set_attr "type" "st,ld,alu,alu,alu,alu,alu")])
 16.7868 ++
 16.7869 ++(define_insn "ldwio"
 16.7870 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7871 ++	(unspec_volatile:SI [(const_int 0)] UNSPEC_LDWIO))
 16.7872 ++   (use (match_operand:SI 1 "memory_operand" "m"))]
 16.7873 ++  ""
 16.7874 ++  "ldwio\\t%0, %1"
 16.7875 ++  [(set_attr "type" "ld")])
 16.7876 ++
 16.7877 ++(define_insn "stwio"
 16.7878 ++  [(set (match_operand:SI 0 "memory_operand" "=m")
 16.7879 ++	(match_operand:SI 1 "register_operand"   "r"))
 16.7880 ++   (unspec_volatile:SI [(const_int 0)] UNSPEC_STWIO)]
 16.7881 ++  ""
 16.7882 ++  "stwio\\t%z1, %0"
 16.7883 ++  [(set_attr "type" "st")])
 16.7884 ++
 16.7885 ++
 16.7886 ++
 16.7887 ++;*****************************************************************************
 16.7888 ++;*
 16.7889 ++;* zero extension
 16.7890 ++;*
 16.7891 ++;*****************************************************************************
 16.7892 ++
 16.7893 ++
 16.7894 ++(define_insn "zero_extendhisi2"
 16.7895 ++  [(set (match_operand:SI 0 "register_operand" "=r,r")
 16.7896 ++	(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
 16.7897 ++  ""
 16.7898 ++  "@
 16.7899 ++    andi\\t%0, %1, 0xffff
 16.7900 ++    ldhu%o1\\t%0, %1"
 16.7901 ++  [(set_attr "type"	"alu,ld")])
 16.7902 ++
 16.7903 ++(define_insn "zero_extendqihi2"
 16.7904 ++  [(set (match_operand:HI 0 "register_operand" "=r,r")
 16.7905 ++	(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
 16.7906 ++  ""
 16.7907 ++  "@
 16.7908 ++    andi\\t%0, %1, 0xff
 16.7909 ++    ldbu%o1\\t%0, %1"
 16.7910 ++  [(set_attr "type"	"alu,ld")])
 16.7911 ++
 16.7912 ++(define_insn "zero_extendqisi2"
 16.7913 ++  [(set (match_operand:SI 0 "register_operand" "=r,r")
 16.7914 ++	(zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
 16.7915 ++  ""
 16.7916 ++  "@
 16.7917 ++    andi\\t%0, %1, 0xff
 16.7918 ++    ldbu%o1\\t%0, %1"
 16.7919 ++  [(set_attr "type"	"alu,ld")])
 16.7920 ++
 16.7921 ++
 16.7922 ++
 16.7923 ++;*****************************************************************************
 16.7924 ++;*
 16.7925 ++;* sign extension
 16.7926 ++;*
 16.7927 ++;*****************************************************************************
 16.7928 ++
 16.7929 ++(define_expand "extendhisi2"
 16.7930 ++  [(set (match_operand:SI 0 "register_operand" "")
 16.7931 ++	(sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
 16.7932 ++  ""
 16.7933 ++{
 16.7934 ++  if (optimize && GET_CODE (operands[1]) == MEM)
 16.7935 ++    operands[1] = force_not_mem (operands[1]);
 16.7936 ++
 16.7937 ++  if (GET_CODE (operands[1]) != MEM)
 16.7938 ++    {
 16.7939 ++      rtx op1   = gen_lowpart (SImode, operands[1]);
 16.7940 ++      rtx temp  = gen_reg_rtx (SImode);
 16.7941 ++      rtx shift = GEN_INT (16);
 16.7942 ++
 16.7943 ++      emit_insn (gen_ashlsi3 (temp, op1, shift));
 16.7944 ++      emit_insn (gen_ashrsi3 (operands[0], temp, shift));
 16.7945 ++      DONE;
 16.7946 ++    }
 16.7947 ++})
 16.7948 ++
 16.7949 ++(define_insn "extendhisi2_internal"
 16.7950 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.7951 ++	(sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
 16.7952 ++  ""
 16.7953 ++  "ldh%o1\\t%0, %1"
 16.7954 ++  [(set_attr "type"	"ld")])
 16.7955 ++
 16.7956 ++(define_expand "extendqihi2"
 16.7957 ++  [(set (match_operand:HI 0 "register_operand" "")
 16.7958 ++	(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
 16.7959 ++  ""
 16.7960 ++{
 16.7961 ++  if (optimize && GET_CODE (operands[1]) == MEM)
 16.7962 ++    operands[1] = force_not_mem (operands[1]);
 16.7963 ++
 16.7964 ++  if (GET_CODE (operands[1]) != MEM)
 16.7965 ++    {
 16.7966 ++      rtx op0   = gen_lowpart (SImode, operands[0]);
 16.7967 ++      rtx op1   = gen_lowpart (SImode, operands[1]);
 16.7968 ++      rtx temp  = gen_reg_rtx (SImode);
 16.7969 ++      rtx shift = GEN_INT (24);
 16.7970 ++
 16.7971 ++      emit_insn (gen_ashlsi3 (temp, op1, shift));
 16.7972 ++      emit_insn (gen_ashrsi3 (op0, temp, shift));
 16.7973 ++      DONE;
 16.7974 ++    }
 16.7975 ++})
 16.7976 ++
 16.7977 ++(define_insn "extendqihi2_internal"
 16.7978 ++  [(set (match_operand:HI 0 "register_operand" "=r")
 16.7979 ++	(sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
 16.7980 ++  ""
 16.7981 ++  "ldb%o1\\t%0, %1"
 16.7982 ++  [(set_attr "type"	"ld")])
 16.7983 ++
 16.7984 ++
 16.7985 ++(define_expand "extendqisi2"
 16.7986 ++  [(set (match_operand:SI 0 "register_operand" "")
 16.7987 ++	(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
 16.7988 ++  ""
 16.7989 ++{
 16.7990 ++  if (optimize && GET_CODE (operands[1]) == MEM)
 16.7991 ++    operands[1] = force_not_mem (operands[1]);
 16.7992 ++
 16.7993 ++  if (GET_CODE (operands[1]) != MEM)
 16.7994 ++    {
 16.7995 ++      rtx op1   = gen_lowpart (SImode, operands[1]);
 16.7996 ++      rtx temp  = gen_reg_rtx (SImode);
 16.7997 ++      rtx shift = GEN_INT (24);
 16.7998 ++
 16.7999 ++      emit_insn (gen_ashlsi3 (temp, op1, shift));
 16.8000 ++      emit_insn (gen_ashrsi3 (operands[0], temp, shift));
 16.8001 ++      DONE;
 16.8002 ++    }
 16.8003 ++})
 16.8004 ++
 16.8005 ++(define_insn "extendqisi2_insn"
 16.8006 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8007 ++	(sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
 16.8008 ++  ""
 16.8009 ++  "ldb%o1\\t%0, %1"
 16.8010 ++  [(set_attr "type"	"ld")])
 16.8011 ++
 16.8012 ++
 16.8013 ++
 16.8014 ++;*****************************************************************************
 16.8015 ++;*
 16.8016 ++;* Arithmetic Operations
 16.8017 ++;*
 16.8018 ++;*****************************************************************************
 16.8019 ++
 16.8020 ++(define_insn "addsi3"
 16.8021 ++  [(set (match_operand:SI 0 "register_operand"          "=r,r")
 16.8022 ++        (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
 16.8023 ++                 (match_operand:SI 2 "arith_operand"     "r,I")))]
 16.8024 ++  ""
 16.8025 ++  "add%i2\\t%0, %1, %z2"
 16.8026 ++  [(set_attr "type" "alu")])
 16.8027 ++
 16.8028 ++(define_insn "subsi3"
 16.8029 ++  [(set (match_operand:SI 0 "register_operand"           "=r")
 16.8030 ++        (minus:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8031 ++                  (match_operand:SI 2 "register_operand"  "r")))]
 16.8032 ++  ""
 16.8033 ++  "sub\\t%0, %z1, %2"
 16.8034 ++  [(set_attr "type" "alu")])
 16.8035 ++
 16.8036 ++(define_insn "mulsi3"
 16.8037 ++  [(set (match_operand:SI 0 "register_operand"            "=r,r")
 16.8038 ++        (mult:SI (match_operand:SI 1 "register_operand"    "r,r")
 16.8039 ++                 (match_operand:SI 2 "arith_operand"       "r,I")))]
 16.8040 ++  "TARGET_HAS_MUL"
 16.8041 ++  "mul%i2\\t%0, %1, %z2"
 16.8042 ++  [(set_attr "type" "mul")])
 16.8043 ++
 16.8044 ++(define_expand "divsi3"
 16.8045 ++  [(set (match_operand:SI 0 "register_operand"            "=r")
 16.8046 ++        (div:SI (match_operand:SI 1 "register_operand"     "r")
 16.8047 ++                (match_operand:SI 2 "register_operand"     "r")))]
 16.8048 ++  ""
 16.8049 ++{
 16.8050 ++  if (!TARGET_HAS_DIV)
 16.8051 ++    {
 16.8052 ++      if (!TARGET_FAST_SW_DIV)
 16.8053 ++	FAIL;
 16.8054 ++      else
 16.8055 ++        {
 16.8056 ++	  if (nios2_emit_expensive_div (operands, SImode))
 16.8057 ++	    DONE;
 16.8058 ++	}
 16.8059 ++    }
 16.8060 ++})
 16.8061 ++
 16.8062 ++(define_insn "divsi3_insn"
 16.8063 ++  [(set (match_operand:SI 0 "register_operand"            "=r")
 16.8064 ++        (div:SI (match_operand:SI 1 "register_operand"     "r")
 16.8065 ++                (match_operand:SI 2 "register_operand"     "r")))]
 16.8066 ++  "TARGET_HAS_DIV"
 16.8067 ++  "div\\t%0, %1, %2"
 16.8068 ++  [(set_attr "type" "div")])
 16.8069 ++
 16.8070 ++(define_insn "udivsi3"
 16.8071 ++  [(set (match_operand:SI 0 "register_operand"            "=r")
 16.8072 ++        (udiv:SI (match_operand:SI 1 "register_operand"     "r")
 16.8073 ++                (match_operand:SI 2 "register_operand"     "r")))]
 16.8074 ++  "TARGET_HAS_DIV"
 16.8075 ++  "divu\\t%0, %1, %2"
 16.8076 ++  [(set_attr "type" "div")])
 16.8077 ++
 16.8078 ++(define_insn "smulsi3_highpart"
 16.8079 ++  [(set (match_operand:SI 0 "register_operand"                            "=r")
 16.8080 ++	(truncate:SI
 16.8081 ++	 (lshiftrt:DI
 16.8082 ++	  (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand"  "r"))
 16.8083 ++		   (sign_extend:DI (match_operand:SI 2 "register_operand"  "r")))
 16.8084 ++	  (const_int 32))))]
 16.8085 ++  "TARGET_HAS_MULX"
 16.8086 ++  "mulxss\\t%0, %1, %2"
 16.8087 ++  [(set_attr "type" "mul")])
 16.8088 ++
 16.8089 ++(define_insn "umulsi3_highpart"
 16.8090 ++  [(set (match_operand:SI 0 "register_operand"                            "=r")
 16.8091 ++	(truncate:SI
 16.8092 ++	 (lshiftrt:DI
 16.8093 ++	  (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand"  "r"))
 16.8094 ++		   (zero_extend:DI (match_operand:SI 2 "register_operand"  "r")))
 16.8095 ++	  (const_int 32))))]
 16.8096 ++  "TARGET_HAS_MULX"
 16.8097 ++  "mulxuu\\t%0, %1, %2"
 16.8098 ++  [(set_attr "type" "mul")])
 16.8099 ++
 16.8100 ++
 16.8101 ++(define_expand "mulsidi3"
 16.8102 ++    [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
 16.8103 ++	  (mult:SI (match_operand:SI 1 "register_operand" "")
 16.8104 ++		   (match_operand:SI 2 "register_operand" "")))
 16.8105 ++     (set (subreg:SI (match_dup 0) 4)
 16.8106 ++	  (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
 16.8107 ++					     (sign_extend:DI (match_dup 2)))
 16.8108 ++				    (const_int 32))))]
 16.8109 ++  "TARGET_HAS_MULX"
 16.8110 ++  "")
 16.8111 ++
 16.8112 ++(define_expand "umulsidi3"
 16.8113 ++    [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
 16.8114 ++	  (mult:SI (match_operand:SI 1 "register_operand" "")
 16.8115 ++		   (match_operand:SI 2 "register_operand" "")))
 16.8116 ++     (set (subreg:SI (match_dup 0) 4)
 16.8117 ++	  (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
 16.8118 ++					     (zero_extend:DI (match_dup 2)))
 16.8119 ++				    (const_int 32))))]
 16.8120 ++  "TARGET_HAS_MULX"
 16.8121 ++  "")
 16.8122 ++
 16.8123 ++
 16.8124 ++
 16.8125 ++;*****************************************************************************
 16.8126 ++;*
 16.8127 ++;* Negate and ones complement
 16.8128 ++;*
 16.8129 ++;*****************************************************************************
 16.8130 ++
 16.8131 ++(define_insn "negsi2"
 16.8132 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8133 ++	(neg:SI (match_operand:SI 1 "register_operand" "r")))]
 16.8134 ++  ""
 16.8135 ++{
 16.8136 ++  operands[2] = const0_rtx;
 16.8137 ++  return "sub\\t%0, %z2, %1";
 16.8138 ++}
 16.8139 ++  [(set_attr "type" "alu")])
 16.8140 ++
 16.8141 ++(define_insn "one_cmplsi2"
 16.8142 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8143 ++	(not:SI (match_operand:SI 1 "register_operand" "r")))]
 16.8144 ++  ""
 16.8145 ++{
 16.8146 ++  operands[2] = const0_rtx;
 16.8147 ++  return "nor\\t%0, %z2, %1";
 16.8148 ++}
 16.8149 ++  [(set_attr "type" "alu")])
 16.8150 ++
 16.8151 ++
 16.8152 ++
 16.8153 ++; Logical Operantions
 16.8154 ++
 16.8155 ++(define_insn "andsi3"
 16.8156 ++  [(set (match_operand:SI 0 "register_operand"         "=r, r,r")
 16.8157 ++        (and:SI (match_operand:SI 1 "register_operand" "%r, r,r")
 16.8158 ++                (match_operand:SI 2 "logical_operand"   "rM,J,K")))]
 16.8159 ++  ""
 16.8160 ++  "@
 16.8161 ++    and\\t%0, %1, %z2
 16.8162 ++    and%i2\\t%0, %1, %2
 16.8163 ++    andh%i2\\t%0, %1, %U2"
 16.8164 ++  [(set_attr "type" "alu")])
 16.8165 ++
 16.8166 ++(define_insn "iorsi3"
 16.8167 ++  [(set (match_operand:SI 0 "register_operand"          "=r, r,r")
 16.8168 ++        (ior:SI (match_operand:SI 1 "register_operand"  "%r, r,r")
 16.8169 ++                (match_operand:SI 2 "logical_operand"    "rM,J,K")))]
 16.8170 ++  ""
 16.8171 ++  "@
 16.8172 ++    or\\t%0, %1, %z2
 16.8173 ++    or%i2\\t%0, %1, %2
 16.8174 ++    orh%i2\\t%0, %1, %U2"
 16.8175 ++  [(set_attr "type" "alu")])
 16.8176 ++
 16.8177 ++(define_insn "*norsi3"
 16.8178 ++  [(set (match_operand:SI 0 "register_operand"                  "=r")
 16.8179 ++        (and:SI (not:SI (match_operand:SI 1 "register_operand"  "%r"))
 16.8180 ++                (not:SI (match_operand:SI 2 "reg_or_0_operand"   "rM"))))]
 16.8181 ++  ""
 16.8182 ++  "nor\\t%0, %1, %z2"
 16.8183 ++  [(set_attr "type" "alu")])
 16.8184 ++
 16.8185 ++(define_insn "xorsi3"
 16.8186 ++  [(set (match_operand:SI 0 "register_operand"          "=r, r,r")
 16.8187 ++        (xor:SI (match_operand:SI 1 "register_operand"  "%r, r,r")
 16.8188 ++                (match_operand:SI 2 "logical_operand"    "rM,J,K")))]
 16.8189 ++  ""
 16.8190 ++  "@
 16.8191 ++    xor\\t%0, %1, %z2
 16.8192 ++    xor%i2\\t%0, %1, %2
 16.8193 ++    xorh%i2\\t%0, %1, %U2"
 16.8194 ++  [(set_attr "type" "alu")])
 16.8195 ++
 16.8196 ++
 16.8197 ++
 16.8198 ++;*****************************************************************************
 16.8199 ++;*
 16.8200 ++;* Shifts
 16.8201 ++;*
 16.8202 ++;*****************************************************************************
 16.8203 ++
 16.8204 ++(define_insn "ashlsi3"
 16.8205 ++  [(set (match_operand:SI 0 "register_operand"           "=r,r")
 16.8206 ++	(ashift:SI (match_operand:SI 1 "register_operand" "r,r")
 16.8207 ++		   (match_operand:SI 2 "shift_operand"    "r,L")))]
 16.8208 ++  ""
 16.8209 ++  "sll%i2\\t%0, %1, %z2"
 16.8210 ++  [(set_attr "type" "shift")])
 16.8211 ++
 16.8212 ++(define_insn "ashrsi3"
 16.8213 ++  [(set (match_operand:SI 0 "register_operand"             "=r,r")
 16.8214 ++	(ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
 16.8215 ++		     (match_operand:SI 2 "shift_operand"    "r,L")))]
 16.8216 ++  ""
 16.8217 ++  "sra%i2\\t%0, %1, %z2"
 16.8218 ++  [(set_attr "type" "shift")])
 16.8219 ++
 16.8220 ++(define_insn "lshrsi3"
 16.8221 ++  [(set (match_operand:SI 0 "register_operand"             "=r,r")
 16.8222 ++	(lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
 16.8223 ++		     (match_operand:SI 2 "shift_operand"    "r,L")))]
 16.8224 ++  ""
 16.8225 ++  "srl%i2\\t%0, %1, %z2"
 16.8226 ++  [(set_attr "type" "shift")])
 16.8227 ++
 16.8228 ++(define_insn "rotlsi3"
 16.8229 ++  [(set (match_operand:SI 0 "register_operand"           "=r,r")
 16.8230 ++	(rotate:SI (match_operand:SI 1 "register_operand" "r,r")
 16.8231 ++		   (match_operand:SI 2 "shift_operand"    "r,L")))]
 16.8232 ++  ""
 16.8233 ++  "rol%i2\\t%0, %1, %z2"
 16.8234 ++  [(set_attr "type" "shift")])
 16.8235 ++
 16.8236 ++(define_insn "rotrsi3"
 16.8237 ++  [(set (match_operand:SI 0 "register_operand"             "=r,r")
 16.8238 ++	(rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
 16.8239 ++		     (match_operand:SI 2 "register_operand" "r,r")))]
 16.8240 ++  ""
 16.8241 ++  "ror\\t%0, %1, %2"
 16.8242 ++  [(set_attr "type" "shift")])
 16.8243 ++
 16.8244 ++(define_insn "*shift_mul_constants"
 16.8245 ++  [(set (match_operand:SI 0 "register_operand"                     "=r")
 16.8246 ++	(ashift:SI (mult:SI (match_operand:SI 1 "register_operand"  "r")
 16.8247 ++		            (match_operand:SI 2 "const_int_operand" "I"))
 16.8248 ++		   (match_operand:SI 3          "const_int_operand" "I")))]
 16.8249 ++  "TARGET_HAS_MUL && SMALL_INT (INTVAL (operands[2]) << INTVAL (operands[3]))"
 16.8250 ++{
 16.8251 ++  HOST_WIDE_INT mul = INTVAL (operands[2]) << INTVAL (operands[3]);
 16.8252 ++  rtx ops[3];
 16.8253 ++  
 16.8254 ++  ops[0] = operands[0];
 16.8255 ++  ops[1] = operands[1];
 16.8256 ++  ops[2] = GEN_INT (mul);
 16.8257 ++  
 16.8258 ++  output_asm_insn ("muli\t%0, %1, %2", ops);
 16.8259 ++  return "";
 16.8260 ++}
 16.8261 ++  [(set_attr "type" "mul")])
 16.8262 ++
 16.8263 ++
 16.8264 ++
 16.8265 ++
 16.8266 ++;*****************************************************************************
 16.8267 ++;*
 16.8268 ++;* Prologue, Epilogue and Return
 16.8269 ++;*
 16.8270 ++;*****************************************************************************
 16.8271 ++
 16.8272 ++(define_expand "prologue"
 16.8273 ++  [(const_int 1)]
 16.8274 ++  ""
 16.8275 ++{
 16.8276 ++  expand_prologue ();
 16.8277 ++  DONE;
 16.8278 ++})
 16.8279 ++
 16.8280 ++(define_expand "epilogue"
 16.8281 ++  [(return)]
 16.8282 ++  ""
 16.8283 ++{
 16.8284 ++  expand_epilogue (false);
 16.8285 ++  DONE;
 16.8286 ++})
 16.8287 ++
 16.8288 ++(define_expand "sibcall_epilogue"
 16.8289 ++  [(return)]
 16.8290 ++  ""
 16.8291 ++{
 16.8292 ++  expand_epilogue (true);
 16.8293 ++  DONE;
 16.8294 ++})
 16.8295 ++
 16.8296 ++(define_insn "return"
 16.8297 ++  [(return)]
 16.8298 ++  "reload_completed && nios2_can_use_return_insn ()"
 16.8299 ++  "ret\\t"
 16.8300 ++)
 16.8301 ++
 16.8302 ++(define_insn "return_from_epilogue"
 16.8303 ++  [(use (match_operand 0 "pmode_register_operand" ""))
 16.8304 ++   (return)]
 16.8305 ++  "reload_completed"
 16.8306 ++  "ret\\t"
 16.8307 ++)
 16.8308 ++
 16.8309 ++;; Block any insns from being moved before this point, since the
 16.8310 ++;; profiling call to mcount can use various registers that aren't
 16.8311 ++;; saved or used to pass arguments.
 16.8312 ++
 16.8313 ++(define_insn "blockage"
 16.8314 ++  [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
 16.8315 ++  ""
 16.8316 ++  ""
 16.8317 ++  [(set_attr "type" "unknown")
 16.8318 ++   (set_attr "length" "0")])
 16.8319 ++
 16.8320 ++
 16.8321 ++
 16.8322 ++;*****************************************************************************
 16.8323 ++;*
 16.8324 ++;* Jumps and Calls
 16.8325 ++;*
 16.8326 ++;*****************************************************************************
 16.8327 ++
 16.8328 ++(define_insn "indirect_jump"
 16.8329 ++  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
 16.8330 ++  ""
 16.8331 ++  "jmp\\t%0"
 16.8332 ++  [(set_attr "type" "control")])
 16.8333 ++
 16.8334 ++(define_insn "jump"
 16.8335 ++  [(set (pc)
 16.8336 ++        (label_ref (match_operand 0 "" "")))]
 16.8337 ++  ""
 16.8338 ++  "br\\t%0"
 16.8339 ++  [(set_attr "type" "control")])
 16.8340 ++
 16.8341 ++
 16.8342 ++(define_insn "indirect_call"
 16.8343 ++  [(call (mem:QI (match_operand:SI 0 "register_operand" "r"))
 16.8344 ++         (match_operand 1 "" ""))
 16.8345 ++   (clobber (reg:SI RA_REGNO))]
 16.8346 ++  ""
 16.8347 ++  "callr\\t%0"
 16.8348 ++  [(set_attr "type" "control")])
 16.8349 ++
 16.8350 ++(define_insn "indirect_call_value"
 16.8351 ++  [(set (match_operand 0 "" "")
 16.8352 ++        (call (mem:QI (match_operand:SI 1 "register_operand" "r"))
 16.8353 ++              (match_operand 2 "" "")))
 16.8354 ++   (clobber (reg:SI RA_REGNO))]
 16.8355 ++  ""
 16.8356 ++  "callr\\t%1"
 16.8357 ++)
 16.8358 ++
 16.8359 ++(define_expand "call"
 16.8360 ++  [(parallel [(call (match_operand 0 "" "")
 16.8361 ++                    (match_operand 1 "" ""))
 16.8362 ++              (clobber (reg:SI RA_REGNO))])]
 16.8363 ++  ""
 16.8364 ++  "")
 16.8365 ++
 16.8366 ++(define_expand "call_value"
 16.8367 ++  [(parallel [(set (match_operand 0 "" "")
 16.8368 ++                   (call (match_operand 1 "" "")
 16.8369 ++                         (match_operand 2 "" "")))
 16.8370 ++              (clobber (reg:SI RA_REGNO))])]
 16.8371 ++  ""
 16.8372 ++  "")
 16.8373 ++
 16.8374 ++(define_insn "*call"
 16.8375 ++  [(call (mem:QI (match_operand:SI 0 "immediate_operand" "i"))
 16.8376 ++         (match_operand 1 "" ""))
 16.8377 ++   (clobber (match_operand:SI 2 "register_operand" "=r"))]
 16.8378 ++  ""
 16.8379 ++  "call\\t%0"
 16.8380 ++  [(set_attr "type" "control")])
 16.8381 ++
 16.8382 ++(define_insn "*call_value"
 16.8383 ++  [(set (match_operand 0 "" "")
 16.8384 ++        (call (mem:QI (match_operand:SI 1 "immediate_operand" "i"))
 16.8385 ++              (match_operand 2 "" "")))
 16.8386 ++   (clobber (match_operand:SI 3 "register_operand" "=r"))]
 16.8387 ++  ""
 16.8388 ++  "call\\t%1"
 16.8389 ++  [(set_attr "type" "control")])
 16.8390 ++
 16.8391 ++(define_expand "sibcall"
 16.8392 ++  [(parallel [(call (match_operand 0 "" "")
 16.8393 ++		    (match_operand 1 "" ""))
 16.8394 ++	      (return)
 16.8395 ++	      (use (match_operand 2 "" ""))])]
 16.8396 ++  ""
 16.8397 ++  {
 16.8398 ++    XEXP (operands[0], 0) = copy_to_mode_reg (SImode, XEXP (operands[0], 0));
 16.8399 ++
 16.8400 ++    if (operands[2] == NULL_RTX)
 16.8401 ++      operands[2] = const0_rtx;
 16.8402 ++  }
 16.8403 ++)
 16.8404 ++
 16.8405 ++(define_expand "sibcall_value"
 16.8406 ++  [(parallel [(set (match_operand 0 "" "")
 16.8407 ++		   (call (match_operand 1 "" "")
 16.8408 ++			 (match_operand 2 "" "")))
 16.8409 ++	      (return)
 16.8410 ++	      (use (match_operand 3 "" ""))])]
 16.8411 ++  ""
 16.8412 ++  {
 16.8413 ++    XEXP (operands[1], 0) = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
 16.8414 ++
 16.8415 ++    if (operands[3] == NULL_RTX)
 16.8416 ++      operands[3] = const0_rtx;
 16.8417 ++  }
 16.8418 ++)
 16.8419 ++
 16.8420 ++(define_insn "sibcall_insn"
 16.8421 ++ [(call (mem:QI (match_operand:SI 0 "register_operand" "r"))
 16.8422 ++	(match_operand 1 "" ""))
 16.8423 ++  (return)
 16.8424 ++  (use (match_operand 2 "" ""))]
 16.8425 ++  ""
 16.8426 ++  "jmp\\t%0"
 16.8427 ++)
 16.8428 ++
 16.8429 ++(define_insn "sibcall_value_insn"
 16.8430 ++ [(set (match_operand 0 "register_operand" "")
 16.8431 ++       (call (mem:QI (match_operand:SI 1 "register_operand" "r"))
 16.8432 ++	     (match_operand 2 "" "")))
 16.8433 ++  (return)
 16.8434 ++  (use (match_operand 3 "" ""))]
 16.8435 ++  ""
 16.8436 ++  "jmp\\t%1"
 16.8437 ++)
 16.8438 ++
 16.8439 ++
 16.8440 ++
 16.8441 ++
 16.8442 ++(define_expand "tablejump"
 16.8443 ++  [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
 16.8444 ++              (use (label_ref (match_operand 1 "" "")))])]
 16.8445 ++  ""
 16.8446 ++  ""
 16.8447 ++)
 16.8448 ++
 16.8449 ++(define_insn "*tablejump"
 16.8450 ++  [(set (pc)
 16.8451 ++	(match_operand:SI 0 "register_operand" "r"))
 16.8452 ++   (use (label_ref (match_operand 1 "" "")))]
 16.8453 ++  ""
 16.8454 ++  "jmp\\t%0"
 16.8455 ++  [(set_attr "type" "control")])
 16.8456 ++
 16.8457 ++
 16.8458 ++
 16.8459 ++;*****************************************************************************
 16.8460 ++;*
 16.8461 ++;* Comparisons
 16.8462 ++;*
 16.8463 ++;*****************************************************************************
 16.8464 ++;; Flow here is rather complex (based on MIPS):
 16.8465 ++;;
 16.8466 ++;;  1)	The cmp{si,di,sf,df} routine is called.  It deposits the
 16.8467 ++;;	arguments into the branch_cmp array, and the type into
 16.8468 ++;;	branch_type.  No RTL is generated.
 16.8469 ++;;
 16.8470 ++;;  2)	The appropriate branch define_expand is called, which then
 16.8471 ++;;	creates the appropriate RTL for the comparison and branch.
 16.8472 ++;;	Different CC modes are used, based on what type of branch is
 16.8473 ++;;	done, so that we can constrain things appropriately.  There
 16.8474 ++;;	are assumptions in the rest of GCC that break if we fold the
 16.8475 ++;;	operands into the branchs for integer operations, and use cc0
 16.8476 ++;;	for floating point, so we use the fp status register instead.
 16.8477 ++;;	If needed, an appropriate temporary is created to hold the
 16.8478 ++;;	of the integer compare.
 16.8479 ++
 16.8480 ++(define_expand "cmpsi"
 16.8481 ++  [(set (cc0)
 16.8482 ++	(compare:CC (match_operand:SI 0 "register_operand" "")
 16.8483 ++		    (match_operand:SI 1 "arith_operand" "")))]
 16.8484 ++  ""
 16.8485 ++{
 16.8486 ++  branch_cmp[0] = operands[0];
 16.8487 ++  branch_cmp[1] = operands[1];
 16.8488 ++  branch_type = CMP_SI;
 16.8489 ++  DONE;
 16.8490 ++})
 16.8491 ++
 16.8492 ++(define_expand "tstsi"
 16.8493 ++  [(set (cc0)
 16.8494 ++	(match_operand:SI 0 "register_operand" ""))]
 16.8495 ++  ""
 16.8496 ++{
 16.8497 ++  branch_cmp[0] = operands[0];
 16.8498 ++  branch_cmp[1] = const0_rtx;
 16.8499 ++  branch_type = CMP_SI;
 16.8500 ++  DONE;
 16.8501 ++})
 16.8502 ++
 16.8503 ++
 16.8504 ++;*****************************************************************************
 16.8505 ++;*
 16.8506 ++;* setting a register from a comparison
 16.8507 ++;*
 16.8508 ++;*****************************************************************************
 16.8509 ++
 16.8510 ++(define_expand "seq"
 16.8511 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8512 ++	(eq:SI (match_dup 1)
 16.8513 ++	       (match_dup 2)))]
 16.8514 ++  ""
 16.8515 ++{
 16.8516 ++  if (branch_type != CMP_SI)
 16.8517 ++    FAIL;
 16.8518 ++
 16.8519 ++  /* set up operands from compare.  */
 16.8520 ++  operands[1] = branch_cmp[0];
 16.8521 ++  operands[2] = branch_cmp[1];
 16.8522 ++
 16.8523 ++  gen_int_relational (EQ, operands[0], operands[1], operands[2], NULL_RTX);
 16.8524 ++  DONE;
 16.8525 ++})
 16.8526 ++
 16.8527 ++
 16.8528 ++(define_insn "*seq"
 16.8529 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8530 ++	(eq:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
 16.8531 ++	       (match_operand:SI 2 "arith_operand"     "rI")))]
 16.8532 ++  ""
 16.8533 ++  "cmpeq%i2\\t%0, %z1, %z2"
 16.8534 ++  [(set_attr "type" "alu")])
 16.8535 ++
 16.8536 ++
 16.8537 ++(define_expand "sne"
 16.8538 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8539 ++	(ne:SI (match_dup 1)
 16.8540 ++	       (match_dup 2)))]
 16.8541 ++  ""
 16.8542 ++{
 16.8543 ++  if (branch_type != CMP_SI)
 16.8544 ++    FAIL;
 16.8545 ++
 16.8546 ++  /* set up operands from compare.  */
 16.8547 ++  operands[1] = branch_cmp[0];
 16.8548 ++  operands[2] = branch_cmp[1];
 16.8549 ++
 16.8550 ++  gen_int_relational (NE, operands[0], operands[1], operands[2], NULL_RTX);
 16.8551 ++  DONE;
 16.8552 ++})
 16.8553 ++
 16.8554 ++
 16.8555 ++(define_insn "*sne"
 16.8556 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8557 ++	(ne:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
 16.8558 ++	       (match_operand:SI 2 "arith_operand"     "rI")))]
 16.8559 ++  ""
 16.8560 ++  "cmpne%i2\\t%0, %z1, %z2"
 16.8561 ++  [(set_attr "type" "alu")])
 16.8562 ++
 16.8563 ++
 16.8564 ++(define_expand "sgt"
 16.8565 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8566 ++	(gt:SI (match_dup 1)
 16.8567 ++	       (match_dup 2)))]
 16.8568 ++  ""
 16.8569 ++{
 16.8570 ++  if (branch_type != CMP_SI)
 16.8571 ++    FAIL;
 16.8572 ++
 16.8573 ++  /* set up operands from compare.  */
 16.8574 ++  operands[1] = branch_cmp[0];
 16.8575 ++  operands[2] = branch_cmp[1];
 16.8576 ++
 16.8577 ++  gen_int_relational (GT, operands[0], operands[1], operands[2], NULL_RTX);
 16.8578 ++  DONE;
 16.8579 ++})
 16.8580 ++
 16.8581 ++
 16.8582 ++(define_insn "*sgt"
 16.8583 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8584 ++	(gt:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8585 ++	       (match_operand:SI 2 "reg_or_0_operand"  "rM")))]
 16.8586 ++  ""
 16.8587 ++  "cmplt\\t%0, %z2, %z1"
 16.8588 ++  [(set_attr "type" "alu")])
 16.8589 ++
 16.8590 ++
 16.8591 ++(define_expand "sge"
 16.8592 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8593 ++	(ge:SI (match_dup 1)
 16.8594 ++	       (match_dup 2)))]
 16.8595 ++  ""
 16.8596 ++{
 16.8597 ++  if (branch_type != CMP_SI)
 16.8598 ++    FAIL;
 16.8599 ++
 16.8600 ++  /* set up operands from compare.  */
 16.8601 ++  operands[1] = branch_cmp[0];
 16.8602 ++  operands[2] = branch_cmp[1];
 16.8603 ++
 16.8604 ++  gen_int_relational (GE, operands[0], operands[1], operands[2], NULL_RTX);
 16.8605 ++  DONE;
 16.8606 ++})
 16.8607 ++
 16.8608 ++
 16.8609 ++(define_insn "*sge"
 16.8610 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8611 ++	(ge:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8612 ++	       (match_operand:SI 2 "arith_operand"     "rI")))]
 16.8613 ++  ""
 16.8614 ++  "cmpge%i2\\t%0, %z1, %z2"
 16.8615 ++  [(set_attr "type" "alu")])
 16.8616 ++
 16.8617 ++(define_expand "sle"
 16.8618 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8619 ++	(le:SI (match_dup 1)
 16.8620 ++	       (match_dup 2)))]
 16.8621 ++  ""
 16.8622 ++{
 16.8623 ++  if (branch_type != CMP_SI)
 16.8624 ++    FAIL;
 16.8625 ++
 16.8626 ++  /* set up operands from compare.  */
 16.8627 ++  operands[1] = branch_cmp[0];
 16.8628 ++  operands[2] = branch_cmp[1];
 16.8629 ++
 16.8630 ++  gen_int_relational (LE, operands[0], operands[1], operands[2], NULL_RTX);
 16.8631 ++  DONE;
 16.8632 ++})
 16.8633 ++
 16.8634 ++
 16.8635 ++(define_insn "*sle"
 16.8636 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8637 ++	(le:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8638 ++	       (match_operand:SI 2 "reg_or_0_operand"  "rM")))]
 16.8639 ++  ""
 16.8640 ++  "cmpge\\t%0, %z2, %z1"
 16.8641 ++  [(set_attr "type" "alu")])
 16.8642 ++
 16.8643 ++
 16.8644 ++(define_expand "slt"
 16.8645 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8646 ++	(lt:SI (match_dup 1)
 16.8647 ++	       (match_dup 2)))]
 16.8648 ++  ""
 16.8649 ++{
 16.8650 ++  if (branch_type != CMP_SI)
 16.8651 ++    FAIL;
 16.8652 ++
 16.8653 ++  /* set up operands from compare.  */
 16.8654 ++  operands[1] = branch_cmp[0];
 16.8655 ++  operands[2] = branch_cmp[1];
 16.8656 ++
 16.8657 ++  gen_int_relational (LT, operands[0], operands[1], operands[2], NULL_RTX);
 16.8658 ++  DONE;
 16.8659 ++})
 16.8660 ++
 16.8661 ++
 16.8662 ++(define_insn "*slt"
 16.8663 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8664 ++	(lt:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8665 ++	       (match_operand:SI 2 "arith_operand"     "rI")))]
 16.8666 ++  ""
 16.8667 ++  "cmplt%i2\\t%0, %z1, %z2"
 16.8668 ++  [(set_attr "type" "alu")])
 16.8669 ++
 16.8670 ++
 16.8671 ++(define_expand "sgtu"
 16.8672 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8673 ++	(gtu:SI (match_dup 1)
 16.8674 ++	        (match_dup 2)))]
 16.8675 ++  ""
 16.8676 ++{
 16.8677 ++  if (branch_type != CMP_SI)
 16.8678 ++    FAIL;
 16.8679 ++
 16.8680 ++  /* set up operands from compare.  */
 16.8681 ++  operands[1] = branch_cmp[0];
 16.8682 ++  operands[2] = branch_cmp[1];
 16.8683 ++
 16.8684 ++  gen_int_relational (GTU, operands[0], operands[1], operands[2], NULL_RTX);
 16.8685 ++  DONE;
 16.8686 ++})
 16.8687 ++
 16.8688 ++
 16.8689 ++(define_insn "*sgtu"
 16.8690 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8691 ++	(gtu:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8692 ++	        (match_operand:SI 2 "reg_or_0_operand"  "rM")))]
 16.8693 ++  ""
 16.8694 ++  "cmpltu\\t%0, %z2, %z1"
 16.8695 ++  [(set_attr "type" "alu")])
 16.8696 ++
 16.8697 ++
 16.8698 ++(define_expand "sgeu"
 16.8699 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8700 ++	(geu:SI (match_dup 1)
 16.8701 ++	        (match_dup 2)))]
 16.8702 ++  ""
 16.8703 ++{
 16.8704 ++  if (branch_type != CMP_SI)
 16.8705 ++    FAIL;
 16.8706 ++
 16.8707 ++  /* set up operands from compare.  */
 16.8708 ++  operands[1] = branch_cmp[0];
 16.8709 ++  operands[2] = branch_cmp[1];
 16.8710 ++
 16.8711 ++  gen_int_relational (GEU, operands[0], operands[1], operands[2], NULL_RTX);
 16.8712 ++  DONE;
 16.8713 ++})
 16.8714 ++
 16.8715 ++
 16.8716 ++(define_insn "*sgeu"
 16.8717 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8718 ++	(geu:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8719 ++	        (match_operand:SI 2 "uns_arith_operand"     "rJ")))]
 16.8720 ++  ""
 16.8721 ++  "cmpgeu%i2\\t%0, %z1, %z2"
 16.8722 ++  [(set_attr "type" "alu")])
 16.8723 ++
 16.8724 ++(define_expand "sleu"
 16.8725 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8726 ++	(leu:SI (match_dup 1)
 16.8727 ++	        (match_dup 2)))]
 16.8728 ++  ""
 16.8729 ++{
 16.8730 ++  if (branch_type != CMP_SI)
 16.8731 ++    FAIL;
 16.8732 ++
 16.8733 ++  /* set up operands from compare.  */
 16.8734 ++  operands[1] = branch_cmp[0];
 16.8735 ++  operands[2] = branch_cmp[1];
 16.8736 ++
 16.8737 ++  gen_int_relational (LEU, operands[0], operands[1], operands[2], NULL_RTX);
 16.8738 ++  DONE;
 16.8739 ++})
 16.8740 ++
 16.8741 ++
 16.8742 ++(define_insn "*sleu"
 16.8743 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8744 ++	(leu:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8745 ++	        (match_operand:SI 2 "reg_or_0_operand"  "rM")))]
 16.8746 ++  ""
 16.8747 ++  "cmpgeu\\t%0, %z2, %z1"
 16.8748 ++  [(set_attr "type" "alu")])
 16.8749 ++
 16.8750 ++
 16.8751 ++(define_expand "sltu"
 16.8752 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.8753 ++	(ltu:SI (match_dup 1)
 16.8754 ++	        (match_dup 2)))]
 16.8755 ++  ""
 16.8756 ++{
 16.8757 ++  if (branch_type != CMP_SI)
 16.8758 ++    FAIL;
 16.8759 ++
 16.8760 ++  /* set up operands from compare.  */
 16.8761 ++  operands[1] = branch_cmp[0];
 16.8762 ++  operands[2] = branch_cmp[1];
 16.8763 ++
 16.8764 ++  gen_int_relational (LTU, operands[0], operands[1], operands[2], NULL_RTX);
 16.8765 ++  DONE;
 16.8766 ++})
 16.8767 ++
 16.8768 ++
 16.8769 ++(define_insn "*sltu"
 16.8770 ++  [(set (match_operand:SI 0 "register_operand"        "=r")
 16.8771 ++	(ltu:SI (match_operand:SI 1 "reg_or_0_operand"  "rM")
 16.8772 ++	        (match_operand:SI 2 "uns_arith_operand"     "rJ")))]
 16.8773 ++  ""
 16.8774 ++  "cmpltu%i2\\t%0, %z1, %z2"
 16.8775 ++  [(set_attr "type" "alu")])
 16.8776 ++
 16.8777 ++
 16.8778 ++
 16.8779 ++
 16.8780 ++;*****************************************************************************
 16.8781 ++;*
 16.8782 ++;* branches
 16.8783 ++;*
 16.8784 ++;*****************************************************************************
 16.8785 ++
 16.8786 ++(define_insn "*cbranch"
 16.8787 ++  [(set (pc)
 16.8788 ++	(if_then_else
 16.8789 ++         (match_operator:SI 0 "comparison_operator"
 16.8790 ++			    [(match_operand:SI 2 "reg_or_0_operand" "rM")
 16.8791 ++			     (match_operand:SI 3 "reg_or_0_operand" "rM")])
 16.8792 ++        (label_ref (match_operand 1 "" ""))
 16.8793 ++        (pc)))]
 16.8794 ++  ""
 16.8795 ++  "b%0\\t%z2, %z3, %l1"
 16.8796 ++  [(set_attr "type" "control")])
 16.8797 ++
 16.8798 ++
 16.8799 ++(define_expand "beq"
 16.8800 ++  [(set (pc)
 16.8801 ++	(if_then_else (eq:CC (cc0)
 16.8802 ++			     (const_int 0))
 16.8803 ++		      (label_ref (match_operand 0 "" ""))
 16.8804 ++		      (pc)))]
 16.8805 ++  ""
 16.8806 ++{
 16.8807 ++  gen_int_relational (EQ, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8808 ++  DONE;
 16.8809 ++})
 16.8810 ++
 16.8811 ++
 16.8812 ++(define_expand "bne"
 16.8813 ++  [(set (pc)
 16.8814 ++	(if_then_else (ne:CC (cc0)
 16.8815 ++			     (const_int 0))
 16.8816 ++		      (label_ref (match_operand 0 "" ""))
 16.8817 ++		      (pc)))]
 16.8818 ++  ""
 16.8819 ++{
 16.8820 ++  gen_int_relational (NE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8821 ++  DONE;
 16.8822 ++})
 16.8823 ++
 16.8824 ++
 16.8825 ++(define_expand "bgt"
 16.8826 ++  [(set (pc)
 16.8827 ++	(if_then_else (gt:CC (cc0)
 16.8828 ++			     (const_int 0))
 16.8829 ++		      (label_ref (match_operand 0 "" ""))
 16.8830 ++		      (pc)))]
 16.8831 ++  ""
 16.8832 ++{
 16.8833 ++  gen_int_relational (GT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8834 ++  DONE;
 16.8835 ++})
 16.8836 ++
 16.8837 ++(define_expand "bge"
 16.8838 ++  [(set (pc)
 16.8839 ++	(if_then_else (ge:CC (cc0)
 16.8840 ++			     (const_int 0))
 16.8841 ++		      (label_ref (match_operand 0 "" ""))
 16.8842 ++		      (pc)))]
 16.8843 ++  ""
 16.8844 ++{
 16.8845 ++  gen_int_relational (GE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8846 ++  DONE;
 16.8847 ++})
 16.8848 ++
 16.8849 ++(define_expand "ble"
 16.8850 ++  [(set (pc)
 16.8851 ++	(if_then_else (le:CC (cc0)
 16.8852 ++			     (const_int 0))
 16.8853 ++		      (label_ref (match_operand 0 "" ""))
 16.8854 ++		      (pc)))]
 16.8855 ++  ""
 16.8856 ++{
 16.8857 ++  gen_int_relational (LE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8858 ++  DONE;
 16.8859 ++})
 16.8860 ++
 16.8861 ++(define_expand "blt"
 16.8862 ++  [(set (pc)
 16.8863 ++	(if_then_else (lt:CC (cc0)
 16.8864 ++			     (const_int 0))
 16.8865 ++		      (label_ref (match_operand 0 "" ""))
 16.8866 ++		      (pc)))]
 16.8867 ++  ""
 16.8868 ++{
 16.8869 ++  gen_int_relational (LT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8870 ++  DONE;
 16.8871 ++})
 16.8872 ++
 16.8873 ++
 16.8874 ++(define_expand "bgtu"
 16.8875 ++  [(set (pc)
 16.8876 ++	(if_then_else (gtu:CC (cc0)
 16.8877 ++		 	      (const_int 0))
 16.8878 ++		      (label_ref (match_operand 0 "" ""))
 16.8879 ++		      (pc)))]
 16.8880 ++  ""
 16.8881 ++{
 16.8882 ++  gen_int_relational (GTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8883 ++  DONE;
 16.8884 ++})
 16.8885 ++
 16.8886 ++(define_expand "bgeu"
 16.8887 ++  [(set (pc)
 16.8888 ++	(if_then_else (geu:CC (cc0)
 16.8889 ++			      (const_int 0))
 16.8890 ++		      (label_ref (match_operand 0 "" ""))
 16.8891 ++		      (pc)))]
 16.8892 ++  ""
 16.8893 ++{
 16.8894 ++  gen_int_relational (GEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8895 ++  DONE;
 16.8896 ++})
 16.8897 ++
 16.8898 ++(define_expand "bleu"
 16.8899 ++  [(set (pc)
 16.8900 ++	(if_then_else (leu:CC (cc0)
 16.8901 ++			      (const_int 0))
 16.8902 ++		      (label_ref (match_operand 0 "" ""))
 16.8903 ++		      (pc)))]
 16.8904 ++  ""
 16.8905 ++{
 16.8906 ++  gen_int_relational (LEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8907 ++  DONE;
 16.8908 ++})
 16.8909 ++
 16.8910 ++(define_expand "bltu"
 16.8911 ++  [(set (pc)
 16.8912 ++	(if_then_else (ltu:CC (cc0)
 16.8913 ++			      (const_int 0))
 16.8914 ++		      (label_ref (match_operand 0 "" ""))
 16.8915 ++		      (pc)))]
 16.8916 ++  ""
 16.8917 ++{
 16.8918 ++  gen_int_relational (LTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
 16.8919 ++  DONE;
 16.8920 ++})
 16.8921 ++
 16.8922 ++
 16.8923 ++;*****************************************************************************
 16.8924 ++;*
 16.8925 ++;* String and Block Operations
 16.8926 ++;*
 16.8927 ++;*****************************************************************************
 16.8928 ++
 16.8929 ++; ??? This is all really a hack to get Dhrystone to work as fast as possible
 16.8930 ++;     things to be fixed:
 16.8931 ++;        * let the compiler core handle all of this, for that to work the extra
 16.8932 ++;          aliasing needs to be addressed.
 16.8933 ++;        * we use three temporary registers for loading and storing to ensure no
 16.8934 ++;          ld use stalls, this is excessive, because after the first ld/st only
 16.8935 ++;          two are needed. Only two would be needed all the way through if 
 16.8936 ++;          we could schedule with other code. Consider:
 16.8937 ++;           1  ld $1, 0($src)
 16.8938 ++;           2  ld $2, 4($src)
 16.8939 ++;           3  ld $3, 8($src)
 16.8940 ++;           4  st $1, 0($dest)
 16.8941 ++;           5  ld $1, 12($src)
 16.8942 ++;           6  st $2, 4($src)
 16.8943 ++;           7  etc.
 16.8944 ++;          The first store has to wait until 4. If it does not there will be one
 16.8945 ++;          cycle of stalling. However, if any other instruction could be placed
 16.8946 ++;          between 1 and 4, $3 would not be needed.
 16.8947 ++;        * In small we probably don't want to ever do this ourself because there
 16.8948 ++;          is no ld use stall.
 16.8949 ++
 16.8950 ++(define_expand "movstrsi"
 16.8951 ++  [(parallel [(set (match_operand:BLK 0 "general_operand"  "")
 16.8952 ++		   (match_operand:BLK 1 "general_operand"  ""))
 16.8953 ++	      (use (match_operand:SI 2 "const_int_operand" ""))
 16.8954 ++	      (use (match_operand:SI 3 "const_int_operand" ""))
 16.8955 ++	      (clobber (match_scratch:SI 4                "=&r"))
 16.8956 ++	      (clobber (match_scratch:SI 5                "=&r"))
 16.8957 ++	      (clobber (match_scratch:SI 6                "=&r"))])]
 16.8958 ++  "TARGET_INLINE_MEMCPY"
 16.8959 ++{
 16.8960 ++  rtx ld_addr_reg, st_addr_reg;
 16.8961 ++
 16.8962 ++  /* If the predicate for op2 fails in expr.c:emit_block_move_via_movstr 
 16.8963 ++     it trys to copy to a register, but does not re-try the predicate.
 16.8964 ++     ??? Intead of fixing expr.c, I fix it here. */
 16.8965 ++  if (!const_int_operand (operands[2], SImode))
 16.8966 ++    FAIL;
 16.8967 ++
 16.8968 ++  /* ??? there are some magic numbers which need to be sorted out here.
 16.8969 ++         the basis for them is not increasing code size hugely or going
 16.8970 ++         out of range of offset addressing */
 16.8971 ++  if (INTVAL (operands[3]) < 4)
 16.8972 ++    FAIL;
 16.8973 ++  if (!optimize
 16.8974 ++      || (optimize_size && INTVAL (operands[2]) > 12)
 16.8975 ++      || (optimize < 3 && INTVAL (operands[2]) > 100)
 16.8976 ++      || INTVAL (operands[2]) > 200)
 16.8977 ++    FAIL;
 16.8978 ++
 16.8979 ++  st_addr_reg
 16.8980 ++    = replace_equiv_address (operands[0],
 16.8981 ++			     copy_to_mode_reg (Pmode, XEXP (operands[0], 0)));
 16.8982 ++  ld_addr_reg
 16.8983 ++    = replace_equiv_address (operands[1],
 16.8984 ++			     copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
 16.8985 ++  emit_insn (gen_movstrsi_internal (st_addr_reg, ld_addr_reg,
 16.8986 ++				    operands[2], operands[3]));
 16.8987 ++
 16.8988 ++  DONE;
 16.8989 ++})
 16.8990 ++
 16.8991 ++
 16.8992 ++(define_insn "movstrsi_internal"
 16.8993 ++  [(set (match_operand:BLK 0 "memory_operand"   "=o")
 16.8994 ++	(match_operand:BLK 1 "memory_operand"    "o"))
 16.8995 ++   (use (match_operand:SI 2 "const_int_operand"  "i"))
 16.8996 ++   (use (match_operand:SI 3 "const_int_operand"  "i"))
 16.8997 ++   (clobber (match_scratch:SI 4                "=&r"))
 16.8998 ++   (clobber (match_scratch:SI 5                "=&r"))
 16.8999 ++   (clobber (match_scratch:SI 6                "=&r"))]
 16.9000 ++  "TARGET_INLINE_MEMCPY"
 16.9001 ++{
 16.9002 ++  int ld_offset = INTVAL (operands[2]);
 16.9003 ++  int ld_len = INTVAL (operands[2]);
 16.9004 ++  int ld_reg = 0;
 16.9005 ++  rtx ld_addr_reg = XEXP (operands[1], 0);
 16.9006 ++  int st_offset = INTVAL (operands[2]);
 16.9007 ++  int st_len = INTVAL (operands[2]);
 16.9008 ++  int st_reg = 0;
 16.9009 ++  rtx st_addr_reg = XEXP (operands[0], 0);
 16.9010 ++  int delay_count = 0;
 16.9011 ++  
 16.9012 ++  /* ops[0] is the address used by the insn
 16.9013 ++     ops[1] is the register being loaded or stored */
 16.9014 ++  rtx ops[2];
 16.9015 ++  
 16.9016 ++  if (INTVAL (operands[3]) < 4)
 16.9017 ++    abort ();
 16.9018 ++  
 16.9019 ++  while (ld_offset >= 4)
 16.9020 ++    {
 16.9021 ++      /* if the load use delay has been met, I can start
 16.9022 ++         storing */
 16.9023 ++      if (delay_count >= 3)
 16.9024 ++        {
 16.9025 ++	  ops[0] = gen_rtx (MEM, SImode, 
 16.9026 ++			    plus_constant (st_addr_reg, st_len - st_offset));
 16.9027 ++	  ops[1] = operands[st_reg + 4];			 
 16.9028 ++	  output_asm_insn ("stw\t%1, %0", ops);
 16.9029 ++	  
 16.9030 ++	  st_reg = (st_reg + 1) % 3;
 16.9031 ++	  st_offset -= 4;
 16.9032 ++        }
 16.9033 ++    
 16.9034 ++      ops[0] = gen_rtx (MEM, SImode, 
 16.9035 ++			plus_constant (ld_addr_reg, ld_len - ld_offset));
 16.9036 ++      ops[1] = operands[ld_reg + 4];			 
 16.9037 ++      output_asm_insn ("ldw\t%1, %0", ops);
 16.9038 ++      
 16.9039 ++      ld_reg = (ld_reg + 1) % 3;
 16.9040 ++      ld_offset -= 4;
 16.9041 ++      delay_count++;
 16.9042 ++    }
 16.9043 ++  
 16.9044 ++  if (ld_offset >= 2)
 16.9045 ++    {
 16.9046 ++      /* if the load use delay has been met, I can start
 16.9047 ++         storing */
 16.9048 ++      if (delay_count >= 3)
 16.9049 ++        {
 16.9050 ++	  ops[0] = gen_rtx (MEM, SImode, 
 16.9051 ++			    plus_constant (st_addr_reg, st_len - st_offset));
 16.9052 ++	  ops[1] = operands[st_reg + 4];			 
 16.9053 ++	  output_asm_insn ("stw\t%1, %0", ops);
 16.9054 ++	  
 16.9055 ++	  st_reg = (st_reg + 1) % 3;
 16.9056 ++	  st_offset -= 4;
 16.9057 ++        }
 16.9058 ++    
 16.9059 ++      ops[0] = gen_rtx (MEM, HImode, 
 16.9060 ++			plus_constant (ld_addr_reg, ld_len - ld_offset));
 16.9061 ++      ops[1] = operands[ld_reg + 4];			 
 16.9062 ++      output_asm_insn ("ldh\t%1, %0", ops);
 16.9063 ++      
 16.9064 ++      ld_reg = (ld_reg + 1) % 3;
 16.9065 ++      ld_offset -= 2;
 16.9066 ++      delay_count++;
 16.9067 ++    }
 16.9068 ++  
 16.9069 ++  if (ld_offset >= 1)
 16.9070 ++    {
 16.9071 ++      /* if the load use delay has been met, I can start
 16.9072 ++         storing */
 16.9073 ++      if (delay_count >= 3)
 16.9074 ++        {
 16.9075 ++	  ops[0] = gen_rtx (MEM, SImode, 
 16.9076 ++			    plus_constant (st_addr_reg, st_len - st_offset));
 16.9077 ++	  ops[1] = operands[st_reg + 4];			 
 16.9078 ++	  output_asm_insn ("stw\t%1, %0", ops);
 16.9079 ++	  
 16.9080 ++	  st_reg = (st_reg + 1) % 3;
 16.9081 ++	  st_offset -= 4;
 16.9082 ++        }
 16.9083 ++    
 16.9084 ++      ops[0] = gen_rtx (MEM, QImode, 
 16.9085 ++			plus_constant (ld_addr_reg, ld_len - ld_offset));
 16.9086 ++      ops[1] = operands[ld_reg + 4];			 
 16.9087 ++      output_asm_insn ("ldb\t%1, %0", ops);
 16.9088 ++      
 16.9089 ++      ld_reg = (ld_reg + 1) % 3;
 16.9090 ++      ld_offset -= 1;
 16.9091 ++      delay_count++;
 16.9092 ++    }
 16.9093 ++
 16.9094 ++    while (st_offset >= 4)
 16.9095 ++      {
 16.9096 ++	ops[0] = gen_rtx (MEM, SImode, 
 16.9097 ++			  plus_constant (st_addr_reg, st_len - st_offset));
 16.9098 ++	ops[1] = operands[st_reg + 4];			 
 16.9099 ++	output_asm_insn ("stw\t%1, %0", ops);
 16.9100 ++
 16.9101 ++	st_reg = (st_reg + 1) % 3;
 16.9102 ++	st_offset -= 4;
 16.9103 ++      }
 16.9104 ++  
 16.9105 ++    while (st_offset >= 2)
 16.9106 ++      {
 16.9107 ++	ops[0] = gen_rtx (MEM, HImode, 
 16.9108 ++			  plus_constant (st_addr_reg, st_len - st_offset));
 16.9109 ++	ops[1] = operands[st_reg + 4];			 
 16.9110 ++	output_asm_insn ("sth\t%1, %0", ops);
 16.9111 ++
 16.9112 ++	st_reg = (st_reg + 1) % 3;
 16.9113 ++	st_offset -= 2;
 16.9114 ++      }
 16.9115 ++  
 16.9116 ++    while (st_offset >= 1)
 16.9117 ++      {
 16.9118 ++	ops[0] = gen_rtx (MEM, QImode, 
 16.9119 ++			  plus_constant (st_addr_reg, st_len - st_offset));
 16.9120 ++	ops[1] = operands[st_reg + 4];			 
 16.9121 ++	output_asm_insn ("stb\t%1, %0", ops);
 16.9122 ++
 16.9123 ++	st_reg = (st_reg + 1) % 3;
 16.9124 ++	st_offset -= 1;
 16.9125 ++      }
 16.9126 ++  
 16.9127 ++  return "";
 16.9128 ++}
 16.9129 ++; ??? lengths are not being used yet, but I will probably forget
 16.9130 ++; to update this once I am using lengths, so set it to something
 16.9131 ++; definetely big enough to cover it. 400 allows for 200 bytes
 16.9132 ++; of motion.
 16.9133 ++  [(set_attr "length" "400")])
 16.9134 ++
 16.9135 ++
 16.9136 ++
 16.9137 ++;*****************************************************************************
 16.9138 ++;*
 16.9139 ++;* Custom instructions
 16.9140 ++;*
 16.9141 ++;*****************************************************************************
 16.9142 ++
 16.9143 ++(define_constants [
 16.9144 ++  (CUSTOM_N 100)
 16.9145 ++  (CUSTOM_NI 101)
 16.9146 ++  (CUSTOM_NF 102)
 16.9147 ++  (CUSTOM_NP 103)
 16.9148 ++  (CUSTOM_NII 104)
 16.9149 ++  (CUSTOM_NIF 105)
 16.9150 ++  (CUSTOM_NIP 106)
 16.9151 ++  (CUSTOM_NFI 107)
 16.9152 ++  (CUSTOM_NFF 108)
 16.9153 ++  (CUSTOM_NFP 109)
 16.9154 ++  (CUSTOM_NPI 110)
 16.9155 ++  (CUSTOM_NPF 111)
 16.9156 ++  (CUSTOM_NPP 112)
 16.9157 ++  (CUSTOM_IN 113)
 16.9158 ++  (CUSTOM_INI 114)
 16.9159 ++  (CUSTOM_INF 115)
 16.9160 ++  (CUSTOM_INP 116)
 16.9161 ++  (CUSTOM_INII 117)
 16.9162 ++  (CUSTOM_INIF 118)
 16.9163 ++  (CUSTOM_INIP 119)
 16.9164 ++  (CUSTOM_INFI 120)
 16.9165 ++  (CUSTOM_INFF 121)
 16.9166 ++  (CUSTOM_INFP 122)
 16.9167 ++  (CUSTOM_INPI 123)
 16.9168 ++  (CUSTOM_INPF 124)
 16.9169 ++  (CUSTOM_INPP 125)
 16.9170 ++  (CUSTOM_FN 126)
 16.9171 ++  (CUSTOM_FNI 127)
 16.9172 ++  (CUSTOM_FNF 128)
 16.9173 ++  (CUSTOM_FNP 129)
 16.9174 ++  (CUSTOM_FNII 130)
 16.9175 ++  (CUSTOM_FNIF 131)
 16.9176 ++  (CUSTOM_FNIP 132)
 16.9177 ++  (CUSTOM_FNFI 133)
 16.9178 ++  (CUSTOM_FNFF 134)
 16.9179 ++  (CUSTOM_FNFP 135)
 16.9180 ++  (CUSTOM_FNPI 136)
 16.9181 ++  (CUSTOM_FNPF 137)
 16.9182 ++  (CUSTOM_FNPP 138)
 16.9183 ++  (CUSTOM_PN 139)
 16.9184 ++  (CUSTOM_PNI 140)
 16.9185 ++  (CUSTOM_PNF 141)
 16.9186 ++  (CUSTOM_PNP 142)
 16.9187 ++  (CUSTOM_PNII 143)
 16.9188 ++  (CUSTOM_PNIF 144)
 16.9189 ++  (CUSTOM_PNIP 145)
 16.9190 ++  (CUSTOM_PNFI 146)
 16.9191 ++  (CUSTOM_PNFF 147)
 16.9192 ++  (CUSTOM_PNFP 148)
 16.9193 ++  (CUSTOM_PNPI 149)
 16.9194 ++  (CUSTOM_PNPF 150)
 16.9195 ++  (CUSTOM_PNPP 151)
 16.9196 ++])
 16.9197 ++
 16.9198 ++
 16.9199 ++(define_insn "custom_n"
 16.9200 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")] CUSTOM_N)]
 16.9201 ++  ""
 16.9202 ++  "custom\\t%0, zero, zero, zero"
 16.9203 ++  [(set_attr "type" "custom")])
 16.9204 ++
 16.9205 ++(define_insn "custom_ni"
 16.9206 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9207 ++                     (match_operand:SI 1 "register_operand"   "r")] CUSTOM_NI)]
 16.9208 ++  ""
 16.9209 ++  "custom\\t%0, zero, %1, zero"
 16.9210 ++  [(set_attr "type" "custom")])
 16.9211 ++
 16.9212 ++(define_insn "custom_nf"
 16.9213 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9214 ++                     (match_operand:SF 1 "register_operand"   "r")] CUSTOM_NF)]
 16.9215 ++  ""
 16.9216 ++  "custom\\t%0, zero, %1, zero"
 16.9217 ++  [(set_attr "type" "custom")])
 16.9218 ++
 16.9219 ++(define_insn "custom_np"
 16.9220 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9221 ++                     (match_operand:SI 1 "register_operand"   "r")] CUSTOM_NP)]
 16.9222 ++  ""
 16.9223 ++  "custom\\t%0, zero, %1, zero"
 16.9224 ++  [(set_attr "type" "custom")])
 16.9225 ++
 16.9226 ++(define_insn "custom_nii"
 16.9227 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9228 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9229 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NII)]
 16.9230 ++  ""
 16.9231 ++  "custom\\t%0, zero, %1, %2"
 16.9232 ++  [(set_attr "type" "custom")])
 16.9233 ++
 16.9234 ++(define_insn "custom_nif"
 16.9235 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9236 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9237 ++                     (match_operand:SF 2 "register_operand"   "r")] CUSTOM_NIF)]
 16.9238 ++  ""
 16.9239 ++  "custom\\t%0, zero, %1, %2"
 16.9240 ++  [(set_attr "type" "custom")])
 16.9241 ++
 16.9242 ++(define_insn "custom_nip"
 16.9243 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9244 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9245 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NIP)]
 16.9246 ++  ""
 16.9247 ++  "custom\\t%0, zero, %1, %2"
 16.9248 ++  [(set_attr "type" "custom")])
 16.9249 ++
 16.9250 ++(define_insn "custom_nfi"
 16.9251 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9252 ++                     (match_operand:SF 1 "register_operand"   "r")
 16.9253 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NFI)]
 16.9254 ++  ""
 16.9255 ++  "custom\\t%0, zero, %1, %2"
 16.9256 ++  [(set_attr "type" "custom")])
 16.9257 ++
 16.9258 ++(define_insn "custom_nff"
 16.9259 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9260 ++                     (match_operand:SF 1 "register_operand"   "r")
 16.9261 ++                     (match_operand:SF 2 "register_operand"   "r")] CUSTOM_NFF)]
 16.9262 ++  ""
 16.9263 ++  "custom\\t%0, zero, %1, %2"
 16.9264 ++  [(set_attr "type" "custom")])
 16.9265 ++
 16.9266 ++(define_insn "custom_nfp"
 16.9267 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9268 ++                     (match_operand:SF 1 "register_operand"   "r")
 16.9269 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NFP)]
 16.9270 ++  ""
 16.9271 ++  "custom\\t%0, zero, %1, %2"
 16.9272 ++  [(set_attr "type" "custom")])
 16.9273 ++
 16.9274 ++(define_insn "custom_npi"
 16.9275 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9276 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9277 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NPI)]
 16.9278 ++  ""
 16.9279 ++  "custom\\t%0, zero, %1, %2"
 16.9280 ++  [(set_attr "type" "custom")])
 16.9281 ++
 16.9282 ++(define_insn "custom_npf"
 16.9283 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9284 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9285 ++                     (match_operand:SF 2 "register_operand"   "r")] CUSTOM_NPF)]
 16.9286 ++  ""
 16.9287 ++  "custom\\t%0, zero, %1, %2"
 16.9288 ++  [(set_attr "type" "custom")])
 16.9289 ++
 16.9290 ++(define_insn "custom_npp"
 16.9291 ++  [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
 16.9292 ++                     (match_operand:SI 1 "register_operand"   "r")
 16.9293 ++                     (match_operand:SI 2 "register_operand"   "r")] CUSTOM_NPP)]
 16.9294 ++  ""
 16.9295 ++  "custom\\t%0, zero, %1, %2"
 16.9296 ++  [(set_attr "type" "custom")])
 16.9297 ++
 16.9298 ++
 16.9299 ++
 16.9300 ++(define_insn "custom_in"
 16.9301 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9302 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_IN))]
 16.9303 ++  ""
 16.9304 ++  "custom\\t%1, %0, zero, zero"
 16.9305 ++  [(set_attr "type" "custom")])
 16.9306 ++
 16.9307 ++(define_insn "custom_ini"
 16.9308 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9309 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9310 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_INI))]
 16.9311 ++  ""
 16.9312 ++  "custom\\t%1, %0, %2, zero"
 16.9313 ++  [(set_attr "type" "custom")])
 16.9314 ++
 16.9315 ++(define_insn "custom_inf"
 16.9316 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9317 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9318 ++                          (match_operand:SF 2 "register_operand"   "r")] CUSTOM_INF))]
 16.9319 ++  ""
 16.9320 ++  "custom\\t%1, %0, %2, zero"
 16.9321 ++  [(set_attr "type" "custom")])
 16.9322 ++
 16.9323 ++(define_insn "custom_inp"
 16.9324 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9325 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9326 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_INP))]
 16.9327 ++  ""
 16.9328 ++  "custom\\t%1, %0, %2, zero"
 16.9329 ++  [(set_attr "type" "custom")])
 16.9330 ++
 16.9331 ++(define_insn "custom_inii"
 16.9332 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9333 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9334 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9335 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INII))]
 16.9336 ++  ""
 16.9337 ++  "custom\\t%1, %0, %2, %3"
 16.9338 ++  [(set_attr "type" "custom")])
 16.9339 ++
 16.9340 ++(define_insn "custom_inif"
 16.9341 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9342 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9343 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9344 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_INIF))]
 16.9345 ++  ""
 16.9346 ++  "custom\\t%1, %0, %2, %3"
 16.9347 ++  [(set_attr "type" "custom")])
 16.9348 ++
 16.9349 ++(define_insn "custom_inip"
 16.9350 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9351 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9352 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9353 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INIP))]
 16.9354 ++  ""
 16.9355 ++  "custom\\t%1, %0, %2, %3"
 16.9356 ++  [(set_attr "type" "custom")])
 16.9357 ++
 16.9358 ++(define_insn "custom_infi"
 16.9359 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9360 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9361 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9362 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INFI))]
 16.9363 ++  ""
 16.9364 ++  "custom\\t%1, %0, %2, %3"
 16.9365 ++  [(set_attr "type" "custom")])
 16.9366 ++
 16.9367 ++(define_insn "custom_inff"
 16.9368 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9369 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9370 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9371 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_INFF))]
 16.9372 ++  ""
 16.9373 ++  "custom\\t%1, %0, %2, %3"
 16.9374 ++  [(set_attr "type" "custom")])
 16.9375 ++
 16.9376 ++(define_insn "custom_infp"
 16.9377 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9378 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9379 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9380 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INFP))]
 16.9381 ++  ""
 16.9382 ++  "custom\\t%1, %0, %2, %3"
 16.9383 ++  [(set_attr "type" "custom")])
 16.9384 ++
 16.9385 ++(define_insn "custom_inpi"
 16.9386 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9387 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9388 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9389 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INPI))]
 16.9390 ++  ""
 16.9391 ++  "custom\\t%1, %0, %2, %3"
 16.9392 ++  [(set_attr "type" "custom")])
 16.9393 ++
 16.9394 ++(define_insn "custom_inpf"
 16.9395 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9396 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9397 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9398 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_INPF))]
 16.9399 ++  ""
 16.9400 ++  "custom\\t%1, %0, %2, %3"
 16.9401 ++  [(set_attr "type" "custom")])
 16.9402 ++
 16.9403 ++(define_insn "custom_inpp"
 16.9404 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9405 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9406 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9407 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_INPP))]
 16.9408 ++  ""
 16.9409 ++  "custom\\t%1, %0, %2, %3"
 16.9410 ++  [(set_attr "type" "custom")])
 16.9411 ++
 16.9412 ++
 16.9413 ++
 16.9414 ++
 16.9415 ++
 16.9416 ++(define_insn "custom_fn"
 16.9417 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9418 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_FN))]
 16.9419 ++  ""
 16.9420 ++  "custom\\t%1, %0, zero, zero"
 16.9421 ++  [(set_attr "type" "custom")])
 16.9422 ++
 16.9423 ++(define_insn "custom_fni"
 16.9424 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9425 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9426 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_FNI))]
 16.9427 ++  ""
 16.9428 ++  "custom\\t%1, %0, %2, zero"
 16.9429 ++  [(set_attr "type" "custom")])
 16.9430 ++
 16.9431 ++(define_insn "custom_fnf"
 16.9432 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9433 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9434 ++                          (match_operand:SF 2 "register_operand"   "r")] CUSTOM_FNF))]
 16.9435 ++  ""
 16.9436 ++  "custom\\t%1, %0, %2, zero"
 16.9437 ++  [(set_attr "type" "custom")])
 16.9438 ++
 16.9439 ++(define_insn "custom_fnp"
 16.9440 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9441 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9442 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_FNP))]
 16.9443 ++  ""
 16.9444 ++  "custom\\t%1, %0, %2, zero"
 16.9445 ++  [(set_attr "type" "custom")])
 16.9446 ++
 16.9447 ++(define_insn "custom_fnii"
 16.9448 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9449 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9450 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9451 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNII))]
 16.9452 ++  ""
 16.9453 ++  "custom\\t%1, %0, %2, %3"
 16.9454 ++  [(set_attr "type" "custom")])
 16.9455 ++
 16.9456 ++(define_insn "custom_fnif"
 16.9457 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9458 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9459 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9460 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_FNIF))]
 16.9461 ++  ""
 16.9462 ++  "custom\\t%1, %0, %2, %3"
 16.9463 ++  [(set_attr "type" "custom")])
 16.9464 ++
 16.9465 ++(define_insn "custom_fnip"
 16.9466 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9467 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9468 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9469 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNIP))]
 16.9470 ++  ""
 16.9471 ++  "custom\\t%1, %0, %2, %3"
 16.9472 ++  [(set_attr "type" "custom")])
 16.9473 ++
 16.9474 ++(define_insn "custom_fnfi"
 16.9475 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9476 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9477 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9478 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNFI))]
 16.9479 ++  ""
 16.9480 ++  "custom\\t%1, %0, %2, %3"
 16.9481 ++  [(set_attr "type" "custom")])
 16.9482 ++
 16.9483 ++(define_insn "custom_fnff"
 16.9484 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9485 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9486 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9487 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_FNFF))]
 16.9488 ++  ""
 16.9489 ++  "custom\\t%1, %0, %2, %3"
 16.9490 ++  [(set_attr "type" "custom")])
 16.9491 ++
 16.9492 ++(define_insn "custom_fnfp"
 16.9493 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9494 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9495 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9496 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNFP))]
 16.9497 ++  ""
 16.9498 ++  "custom\\t%1, %0, %2, %3"
 16.9499 ++  [(set_attr "type" "custom")])
 16.9500 ++
 16.9501 ++(define_insn "custom_fnpi"
 16.9502 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9503 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9504 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9505 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNPI))]
 16.9506 ++  ""
 16.9507 ++  "custom\\t%1, %0, %2, %3"
 16.9508 ++  [(set_attr "type" "custom")])
 16.9509 ++
 16.9510 ++(define_insn "custom_fnpf"
 16.9511 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9512 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9513 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9514 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_FNPF))]
 16.9515 ++  ""
 16.9516 ++  "custom\\t%1, %0, %2, %3"
 16.9517 ++  [(set_attr "type" "custom")])
 16.9518 ++
 16.9519 ++(define_insn "custom_fnpp"
 16.9520 ++  [(set (match_operand:SF 0 "register_operand"   "=r")
 16.9521 ++        (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9522 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9523 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_FNPP))]
 16.9524 ++  ""
 16.9525 ++  "custom\\t%1, %0, %2, %3"
 16.9526 ++  [(set_attr "type" "custom")])
 16.9527 ++
 16.9528 ++
 16.9529 ++
 16.9530 ++(define_insn "custom_pn"
 16.9531 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9532 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_PN))]
 16.9533 ++  ""
 16.9534 ++  "custom\\t%1, %0, zero, zero"
 16.9535 ++  [(set_attr "type" "custom")])
 16.9536 ++
 16.9537 ++(define_insn "custom_pni"
 16.9538 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9539 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9540 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_PNI))]
 16.9541 ++  ""
 16.9542 ++  "custom\\t%1, %0, %2, zero"
 16.9543 ++  [(set_attr "type" "custom")])
 16.9544 ++
 16.9545 ++(define_insn "custom_pnf"
 16.9546 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9547 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9548 ++                          (match_operand:SF 2 "register_operand"   "r")] CUSTOM_PNF))]
 16.9549 ++  ""
 16.9550 ++  "custom\\t%1, %0, %2, zero"
 16.9551 ++  [(set_attr "type" "custom")])
 16.9552 ++
 16.9553 ++(define_insn "custom_pnp"
 16.9554 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9555 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9556 ++                          (match_operand:SI 2 "register_operand"   "r")] CUSTOM_PNP))]
 16.9557 ++  ""
 16.9558 ++  "custom\\t%1, %0, %2, zero"
 16.9559 ++  [(set_attr "type" "custom")])
 16.9560 ++
 16.9561 ++(define_insn "custom_pnii"
 16.9562 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9563 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9564 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9565 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNII))]
 16.9566 ++  ""
 16.9567 ++  "custom\\t%1, %0, %2, %3"
 16.9568 ++  [(set_attr "type" "custom")])
 16.9569 ++
 16.9570 ++(define_insn "custom_pnif"
 16.9571 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9572 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9573 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9574 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_PNIF))]
 16.9575 ++  ""
 16.9576 ++  "custom\\t%1, %0, %2, %3"
 16.9577 ++  [(set_attr "type" "custom")])
 16.9578 ++
 16.9579 ++(define_insn "custom_pnip"
 16.9580 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9581 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9582 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9583 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNIP))]
 16.9584 ++  ""
 16.9585 ++  "custom\\t%1, %0, %2, %3"
 16.9586 ++  [(set_attr "type" "custom")])
 16.9587 ++
 16.9588 ++(define_insn "custom_pnfi"
 16.9589 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9590 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9591 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9592 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNFI))]
 16.9593 ++  ""
 16.9594 ++  "custom\\t%1, %0, %2, %3"
 16.9595 ++  [(set_attr "type" "custom")])
 16.9596 ++
 16.9597 ++(define_insn "custom_pnff"
 16.9598 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9599 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9600 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9601 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_PNFF))]
 16.9602 ++  ""
 16.9603 ++  "custom\\t%1, %0, %2, %3"
 16.9604 ++  [(set_attr "type" "custom")])
 16.9605 ++
 16.9606 ++(define_insn "custom_pnfp"
 16.9607 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9608 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9609 ++                          (match_operand:SF 2 "register_operand"   "r")
 16.9610 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNFP))]
 16.9611 ++  ""
 16.9612 ++  "custom\\t%1, %0, %2, %3"
 16.9613 ++  [(set_attr "type" "custom")])
 16.9614 ++
 16.9615 ++(define_insn "custom_pnpi"
 16.9616 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9617 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9618 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9619 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNPI))]
 16.9620 ++  ""
 16.9621 ++  "custom\\t%1, %0, %2, %3"
 16.9622 ++  [(set_attr "type" "custom")])
 16.9623 ++
 16.9624 ++(define_insn "custom_pnpf"
 16.9625 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9626 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9627 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9628 ++                          (match_operand:SF 3 "register_operand"   "r")] CUSTOM_PNPF))]
 16.9629 ++  ""
 16.9630 ++  "custom\\t%1, %0, %2, %3"
 16.9631 ++  [(set_attr "type" "custom")])
 16.9632 ++
 16.9633 ++(define_insn "custom_pnpp"
 16.9634 ++  [(set (match_operand:SI 0 "register_operand"   "=r")
 16.9635 ++        (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
 16.9636 ++                          (match_operand:SI 2 "register_operand"   "r")
 16.9637 ++                          (match_operand:SI 3 "register_operand"   "r")] CUSTOM_PNPP))]
 16.9638 ++  ""
 16.9639 ++  "custom\\t%1, %0, %2, %3"
 16.9640 ++  [(set_attr "type" "custom")])
 16.9641 ++
 16.9642 ++
 16.9643 ++
 16.9644 ++
 16.9645 ++
 16.9646 ++
 16.9647 ++;*****************************************************************************
 16.9648 ++;*
 16.9649 ++;* Misc
 16.9650 ++;*
 16.9651 ++;*****************************************************************************
 16.9652 ++
 16.9653 ++(define_insn "nop"
 16.9654 ++  [(const_int 0)]
 16.9655 ++  ""
 16.9656 ++  "nop\\t"
 16.9657 ++  [(set_attr "type" "alu")])
 16.9658 ++
 16.9659 ++(define_insn "sync"
 16.9660 ++  [(unspec_volatile [(const_int 0)] UNSPEC_SYNC)]
 16.9661 ++  ""
 16.9662 ++  "sync\\t"
 16.9663 ++  [(set_attr "type" "control")])
 16.9664 ++
 16.9665 ++
 16.9666 ++(define_insn "rdctl"
 16.9667 ++  [(set (match_operand:SI 0 "register_operand" "=r")
 16.9668 ++	(unspec_volatile:SI [(match_operand:SI 1 "rdwrctl_operand" "O")] UNSPEC_RDCTL))]
 16.9669 ++  ""
 16.9670 ++  "rdctl\\t%0, ctl%1"
 16.9671 ++  [(set_attr "type" "control")])
 16.9672 ++
 16.9673 ++(define_insn "wrctl"
 16.9674 ++  [(unspec_volatile:SI [(match_operand:SI 0 "rdwrctl_operand"  "O")
 16.9675 ++                        (match_operand:SI 1 "register_operand" "r")] UNSPEC_WRCTL)]
 16.9676 ++  ""
 16.9677 ++  "wrctl\\tctl%0, %1"
 16.9678 ++  [(set_attr "type" "control")])
 16.9679 ++
 16.9680 ++
 16.9681 ++
 16.9682 ++;*****************************************************************************
 16.9683 ++;*
 16.9684 ++;* Peepholes
 16.9685 ++;*
 16.9686 ++;*****************************************************************************
 16.9687 ++
 16.9688 ++
 16.9689 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2-protos.h gcc-3.4.6/gcc/config/nios2/nios2-protos.h
 16.9690 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-protos.h	1970-01-01 01:00:00.000000000 +0100
 16.9691 ++++ gcc-3.4.6/gcc/config/nios2/nios2-protos.h	2007-08-15 23:09:36.000000000 +0200
 16.9692 +@@ -0,0 +1,70 @@
 16.9693 ++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
 16.9694 ++   Copyright (C) 2003 Altera 
 16.9695 ++   Contributed by Jonah Graham (jgraham@altera.com).
 16.9696 ++
 16.9697 ++This file is part of GNU CC.
 16.9698 ++
 16.9699 ++GNU CC is free software; you can redistribute it and/or modify
 16.9700 ++it under the terms of the GNU General Public License as published by
 16.9701 ++the Free Software Foundation; either version 2, or (at your option)
 16.9702 ++any later version.
 16.9703 ++
 16.9704 ++GNU CC is distributed in the hope that it will be useful,
 16.9705 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
 16.9706 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16.9707 ++GNU General Public License for more details.
 16.9708 ++
 16.9709 ++You should have received a copy of the GNU General Public License
 16.9710 ++along with GNU CC; see the file COPYING.  If not, write to
 16.9711 ++the Free Software Foundation, 59 Temple Place - Suite 330,
 16.9712 ++Boston, MA 02111-1307, USA.  */
 16.9713 ++
 16.9714 ++extern void dump_frame_size (FILE *);
 16.9715 ++extern HOST_WIDE_INT compute_frame_size (void);
 16.9716 ++extern int nios2_initial_elimination_offset (int, int);
 16.9717 ++extern void override_options (void);
 16.9718 ++extern void optimization_options (int, int);
 16.9719 ++extern int nios2_can_use_return_insn (void);
 16.9720 ++extern void expand_prologue (void);
 16.9721 ++extern void expand_epilogue (bool);
 16.9722 ++extern void function_profiler (FILE *, int);
 16.9723 ++
 16.9724 ++
 16.9725 ++#ifdef RTX_CODE
 16.9726 ++extern int nios2_legitimate_address (rtx, enum machine_mode, int);
 16.9727 ++extern void nios2_print_operand (FILE *, rtx, int);
 16.9728 ++extern void nios2_print_operand_address (FILE *, rtx);
 16.9729 ++
 16.9730 ++extern int nios2_emit_move_sequence (rtx *, enum machine_mode);
 16.9731 ++extern int nios2_emit_expensive_div (rtx *, enum machine_mode);
 16.9732 ++
 16.9733 ++extern void gen_int_relational (enum rtx_code, rtx, rtx, rtx, rtx);
 16.9734 ++extern void gen_conditional_move (rtx *, enum machine_mode);
 16.9735 ++extern const char *asm_output_opcode (FILE *, const char *);
 16.9736 ++
 16.9737 ++/* predicates */
 16.9738 ++extern int arith_operand (rtx, enum machine_mode);
 16.9739 ++extern int uns_arith_operand (rtx, enum machine_mode);
 16.9740 ++extern int logical_operand (rtx, enum machine_mode);
 16.9741 ++extern int shift_operand (rtx, enum machine_mode);
 16.9742 ++extern int reg_or_0_operand (rtx, enum machine_mode);
 16.9743 ++extern int equality_op (rtx, enum machine_mode);
 16.9744 ++extern int custom_insn_opcode (rtx, enum machine_mode);
 16.9745 ++extern int rdwrctl_operand (rtx, enum machine_mode);
 16.9746 ++
 16.9747 ++# ifdef HAVE_MACHINE_MODES
 16.9748 ++#  if defined TREE_CODE
 16.9749 ++extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 16.9750 ++extern rtx function_arg (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 16.9751 ++extern int function_arg_partial_nregs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 16.9752 ++extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int);
 16.9753 ++extern int nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 16.9754 ++
 16.9755 ++#  endif /* TREE_CODE */
 16.9756 ++# endif	/* HAVE_MACHINE_MODES */
 16.9757 ++#endif
 16.9758 ++
 16.9759 ++#ifdef TREE_CODE
 16.9760 ++extern int nios2_return_in_memory (tree);
 16.9761 ++
 16.9762 ++#endif /* TREE_CODE */
 16.9763 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/t-nios2 gcc-3.4.6/gcc/config/nios2/t-nios2
 16.9764 +--- gcc-3.4.6.orig/gcc/config/nios2/t-nios2	1970-01-01 01:00:00.000000000 +0100
 16.9765 ++++ gcc-3.4.6/gcc/config/nios2/t-nios2	2007-08-15 23:09:36.000000000 +0200
 16.9766 +@@ -0,0 +1,123 @@
 16.9767 ++##
 16.9768 ++## Compiler flags to use when compiling libgcc2.c.
 16.9769 ++##
 16.9770 ++## LIB2FUNCS_EXTRA
 16.9771 ++## A list of source file names to be compiled or assembled and inserted into libgcc.a.
 16.9772 ++
 16.9773 ++LIB2FUNCS_EXTRA=$(srcdir)/config/nios2/lib2-divmod.c \
 16.9774 ++  $(srcdir)/config/nios2/lib2-divmod-hi.c \
 16.9775 ++  $(srcdir)/config/nios2/lib2-divtable.c \
 16.9776 ++  $(srcdir)/config/nios2/lib2-mul.c
 16.9777 ++
 16.9778 ++##
 16.9779 ++## Floating Point Emulation
 16.9780 ++## To have GCC include software floating point libraries in libgcc.a define FPBIT
 16.9781 ++## and DPBIT along with a few rules as follows:
 16.9782 ++##
 16.9783 ++## # We want fine grained libraries, so use the new code
 16.9784 ++## # to build the floating point emulation libraries.
 16.9785 ++FPBIT=$(srcdir)/config/nios2/nios2-fp-bit.c
 16.9786 ++DPBIT=$(srcdir)/config/nios2/nios2-dp-bit.c
 16.9787 ++
 16.9788 ++TARGET_LIBGCC2_CFLAGS = -O2
 16.9789 ++
 16.9790 ++# FLOAT_ONLY - no doubles
 16.9791 ++# SMALL_MACHINE - QI/HI is faster than SI
 16.9792 ++#     Actually SMALL_MACHINE uses chars and shorts instead of ints
 16.9793 ++#     since ints (16-bit ones as they are today) are at least as fast
 16.9794 ++#     as chars and shorts, don't define SMALL_MACHINE
 16.9795 ++# CMPtype - type returned by FP compare, i.e. INT (hard coded in fp-bit - see code )
 16.9796 ++
 16.9797 ++$(FPBIT): $(srcdir)/config/fp-bit.c Makefile
 16.9798 ++	echo '#define FLOAT'          >  ${FPBIT}
 16.9799 ++	cat $(srcdir)/config/fp-bit.c >> ${FPBIT}
 16.9800 ++
 16.9801 ++$(DPBIT): $(srcdir)/config/fp-bit.c Makefile
 16.9802 ++	echo ''          >  ${DPBIT}
 16.9803 ++	cat $(srcdir)/config/fp-bit.c >> ${DPBIT}
 16.9804 ++
 16.9805 ++EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o 
 16.9806 ++
 16.9807 ++# Assemble startup files. 
 16.9808 ++$(T)crti.o: $(srcdir)/config/nios2/crti.asm $(GCC_PASSES) 
 16.9809 ++	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
 16.9810 ++	-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/nios2/crti.asm 
 16.9811 ++
 16.9812 ++$(T)crtn.o: $(srcdir)/config/nios2/crtn.asm $(GCC_PASSES) 
 16.9813 ++	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
 16.9814 ++	-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/nios2/crtn.asm 
 16.9815 ++
 16.9816 ++
 16.9817 ++## You may need to provide additional #defines at the beginning of
 16.9818 ++## fp-bit.c and dp-bit.c to control target endianness and other options
 16.9819 ++##
 16.9820 ++## CRTSTUFF_T_CFLAGS
 16.9821 ++## Special flags used when compiling crtstuff.c.  See Initialization.
 16.9822 ++##
 16.9823 ++## CRTSTUFF_T_CFLAGS_S
 16.9824 ++## Special flags used when compiling crtstuff.c for shared linking.  Used
 16.9825 ++## if you use crtbeginS.o and crtendS.o in EXTRA-PARTS. See Initialization.
 16.9826 ++##
 16.9827 ++## MULTILIB_OPTIONS
 16.9828 ++## For some targets, invoking GCC in different ways produces objects that
 16.9829 ++## can not be linked together.  For example, for some targets GCC produces
 16.9830 ++## both big and little endian code.  For these targets, you must arrange
 16.9831 ++## for multiple versions of libgcc.a to be compiled, one for each set of
 16.9832 ++## incompatible options.  When GCC invokes the linker, it arranges to link
 16.9833 ++## in the right version of libgcc.a, based on the command line options
 16.9834 ++## used.
 16.9835 ++## The MULTILIB_OPTIONS macro lists the set of options for which special
 16.9836 ++## versions of libgcc.a must be built.  Write options that are mutually
 16.9837 ++## incompatible side by side, separated by a slash.  Write options that may
 16.9838 ++## be used together separated by a space.  The build procedure will build
 16.9839 ++## all combinations of compatible options.
 16.9840 ++##
 16.9841 ++## For example, if you set MULTILIB_OPTIONS to m68000/m68020 msoft-float,
 16.9842 ++## Makefile will build special versions of libgcc.a using the following
 16.9843 ++## sets of options: -m68000, -m68020, -msoft-float, -m68000 -msoft-float,
 16.9844 ++## and -m68020 -msoft-float.
 16.9845 ++
 16.9846 ++MULTILIB_OPTIONS = mno-hw-mul mhw-mulx
 16.9847 ++
 16.9848 ++## MULTILIB_DIRNAMES
 16.9849 ++## If MULTILIB_OPTIONS is used, this variable specifies the directory names
 16.9850 ++## that should be used to hold the various libraries.  Write one element in
 16.9851 ++## MULTILIB_DIRNAMES for each element in MULTILIB_OPTIONS. If
 16.9852 ++## MULTILIB_DIRNAMES is not used, the default value will be
 16.9853 ++## MULTILIB_OPTIONS, with all slashes treated as spaces.
 16.9854 ++## For example, if MULTILIB_OPTIONS is set to m68000/m68020 msoft-float,
 16.9855 ++## then the default value of MULTILIB_DIRNAMES is m68000 m68020
 16.9856 ++## msoft-float.  You may specify a different value if you desire a
 16.9857 ++## different set of directory names.
 16.9858 ++
 16.9859 ++# MULTILIB_DIRNAMES =
 16.9860 ++
 16.9861 ++## MULTILIB_MATCHES
 16.9862 ++## Sometimes the same option may be written in two different ways.  If an
 16.9863 ++## option is listed in MULTILIB_OPTIONS, GCC needs to know about any
 16.9864 ++## synonyms.  In that case, set MULTILIB_MATCHES to a list of items of the
 16.9865 ++## form option=option to describe all relevant synonyms.  For example,
 16.9866 ++## m68000=mc68000 m68020=mc68020.
 16.9867 ++##
 16.9868 ++## MULTILIB_EXCEPTIONS
 16.9869 ++## Sometimes when there are multiple sets of MULTILIB_OPTIONS being
 16.9870 ++## specified, there are combinations that should not be built.  In that
 16.9871 ++## case, set MULTILIB_EXCEPTIONS to be all of the switch exceptions in
 16.9872 ++## shell case syntax that should not be built.
 16.9873 ++## For example, in the PowerPC embedded ABI support, it is not desirable to
 16.9874 ++## build libraries compiled with the -mcall-aix option and either of the
 16.9875 ++## -fleading-underscore or -mlittle options at the same time.  Therefore
 16.9876 ++## MULTILIB_EXCEPTIONS is set to
 16.9877 ++##
 16.9878 ++## *mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*
 16.9879 ++##
 16.9880 ++
 16.9881 ++MULTILIB_EXCEPTIONS = *mno-hw-mul/*mhw-mulx*
 16.9882 ++
 16.9883 ++##
 16.9884 ++## MULTILIB_EXTRA_OPTS Sometimes it is desirable that when building
 16.9885 ++## multiple versions of libgcc.a certain options should always be passed on
 16.9886 ++## to the compiler.  In that case, set MULTILIB_EXTRA_OPTS to be the list
 16.9887 ++## of options to be used for all builds.
 16.9888 ++##
 16.9889 ++
 16.9890 +diff -durN gcc-3.4.6.orig/gcc/config.gcc gcc-3.4.6/gcc/config.gcc
 16.9891 +--- gcc-3.4.6.orig/gcc/config.gcc	2007-08-15 23:07:00.000000000 +0200
 16.9892 ++++ gcc-3.4.6/gcc/config.gcc	2007-08-15 23:09:36.000000000 +0200
 16.9893 +@@ -1342,6 +1342,10 @@
 16.9894 + 		thread_file='posix'
 16.9895 + 	fi
 16.9896 + 	;;
 16.9897 ++# JBG
 16.9898 ++nios2-*-* | nios2-*-*)
 16.9899 ++	tm_file="elfos.h ${tm_file}"
 16.9900 ++	;;
 16.9901 + # m68hc11 and m68hc12 share the same machine description.
 16.9902 + m68hc11-*-*|m6811-*-*)
 16.9903 + 	tm_file="dbxelf.h elfos.h m68hc11/m68hc11.h"
 16.9904 +diff -durN gcc-3.4.6.orig/gcc/cse.c gcc-3.4.6/gcc/cse.c
 16.9905 +--- gcc-3.4.6.orig/gcc/cse.c	2005-12-31 01:39:42.000000000 +0100
 16.9906 ++++ gcc-3.4.6/gcc/cse.c	2007-08-15 23:09:36.000000000 +0200
 16.9907 +@@ -3134,6 +3134,10 @@
 16.9908 + #ifdef FLOAT_STORE_FLAG_VALUE
 16.9909 + 	  REAL_VALUE_TYPE fsfv;
 16.9910 + #endif
 16.9911 ++#ifdef __nios2__
 16.9912 ++	  if (p->is_const)
 16.9913 ++	    break;
 16.9914 ++#endif
 16.9915 + 
 16.9916 + 	  /* If the entry isn't valid, skip it.  */
 16.9917 + 	  if (! exp_equiv_p (p->exp, p->exp, 1, 0))
 16.9918 +diff -durN gcc-3.4.6.orig/gcc/doc/extend.texi gcc-3.4.6/gcc/doc/extend.texi
 16.9919 +--- gcc-3.4.6.orig/gcc/doc/extend.texi	2005-02-26 23:17:26.000000000 +0100
 16.9920 ++++ gcc-3.4.6/gcc/doc/extend.texi	2007-08-15 23:09:36.000000000 +0200
 16.9921 +@@ -5638,12 +5638,118 @@
 16.9922 + instructions, but allow the compiler to schedule those calls.
 16.9923 + 
 16.9924 + @menu
 16.9925 ++* Altera Nios II Built-in Functions::
 16.9926 + * Alpha Built-in Functions::
 16.9927 + * ARM Built-in Functions::
 16.9928 + * X86 Built-in Functions::
 16.9929 + * PowerPC AltiVec Built-in Functions::
 16.9930 + @end menu
 16.9931 + 
 16.9932 ++@node Altera Nios II Built-in Functions
 16.9933 ++@subsection Altera Nios II Built-in Functions
 16.9934 ++
 16.9935 ++These built-in functions are available for the Altera Nios II
 16.9936 ++family of processors.
 16.9937 ++
 16.9938 ++The following built-in functions are always available.  They
 16.9939 ++all generate the machine instruction that is part of the name.
 16.9940 ++
 16.9941 ++@example
 16.9942 ++int __builtin_ldbio (volatile const void *)
 16.9943 ++int __builtin_ldbuio (volatile const void *)
 16.9944 ++int __builtin_ldhio (volatile const void *)
 16.9945 ++int __builtin_ldhuio (volatile const void *)
 16.9946 ++int __builtin_ldwio (volatile const void *)
 16.9947 ++void __builtin_stbio (volatile void *, int)
 16.9948 ++void __builtin_sthio (volatile void *, int)
 16.9949 ++void __builtin_stwio (volatile void *, int)
 16.9950 ++void __builtin_sync (void)
 16.9951 ++int __builtin_rdctl (int) 
 16.9952 ++void __builtin_wrctl (int, int)
 16.9953 ++@end example
 16.9954 ++
 16.9955 ++The following built-in functions are always available.  They
 16.9956 ++all generate a Nios II Custom Instruction. The name of the 
 16.9957 ++function represents the types that the function takes and 
 16.9958 ++returns. The letter before the @code{n} is the return type
 16.9959 ++or void if absent. The @code{n} represnts the first parameter
 16.9960 ++to all the custom instructions, the custom instruction number.
 16.9961 ++The two letters after the @code{n} represent the up to two 
 16.9962 ++parameters to the function.
 16.9963 ++
 16.9964 ++The letters reprsent the following data types:
 16.9965 ++@table @code
 16.9966 ++@item <no letter>
 16.9967 ++@code{void} for return type and no parameter for parameter types.
 16.9968 ++
 16.9969 ++@item i
 16.9970 ++@code{int} for return type and parameter type
 16.9971 ++
 16.9972 ++@item f
 16.9973 ++@code{float} for return type and parameter type
 16.9974 ++
 16.9975 ++@item p
 16.9976 ++@code{void *} for return type and parameter type
 16.9977 ++
 16.9978 ++@end table
 16.9979 ++
 16.9980 ++And the function names are:
 16.9981 ++@example
 16.9982 ++void __builtin_custom_n (void)
 16.9983 ++void __builtin_custom_ni (int)
 16.9984 ++void __builtin_custom_nf (float)
 16.9985 ++void __builtin_custom_np (void *)
 16.9986 ++void __builtin_custom_nii (int, int)
 16.9987 ++void __builtin_custom_nif (int, float)
 16.9988 ++void __builtin_custom_nip (int, void *)
 16.9989 ++void __builtin_custom_nfi (float, int)
 16.9990 ++void __builtin_custom_nff (float, float)
 16.9991 ++void __builtin_custom_nfp (float, void *)
 16.9992 ++void __builtin_custom_npi (void *, int)
 16.9993 ++void __builtin_custom_npf (void *, float)
 16.9994 ++void __builtin_custom_npp (void *, void *)
 16.9995 ++int __builtin_custom_in (void)
 16.9996 ++int __builtin_custom_ini (int)
 16.9997 ++int __builtin_custom_inf (float)
 16.9998 ++int __builtin_custom_inp (void *)
 16.9999 ++int __builtin_custom_inii (int, int)
16.10000 ++int __builtin_custom_inif (int, float)
16.10001 ++int __builtin_custom_inip (int, void *)
16.10002 ++int __builtin_custom_infi (float, int)
16.10003 ++int __builtin_custom_inff (float, float)
16.10004 ++int __builtin_custom_infp (float, void *)
16.10005 ++int __builtin_custom_inpi (void *, int)
16.10006 ++int __builtin_custom_inpf (void *, float)
16.10007 ++int __builtin_custom_inpp (void *, void *)
16.10008 ++float __builtin_custom_fn (void)
16.10009 ++float __builtin_custom_fni (int)
16.10010 ++float __builtin_custom_fnf (float)
16.10011 ++float __builtin_custom_fnp (void *)
16.10012 ++float __builtin_custom_fnii (int, int)
16.10013 ++float __builtin_custom_fnif (int, float)
16.10014 ++float __builtin_custom_fnip (int, void *)
16.10015 ++float __builtin_custom_fnfi (float, int)
16.10016 ++float __builtin_custom_fnff (float, float)
16.10017 ++float __builtin_custom_fnfp (float, void *)
16.10018 ++float __builtin_custom_fnpi (void *, int)
16.10019 ++float __builtin_custom_fnpf (void *, float)
16.10020 ++float __builtin_custom_fnpp (void *, void *)
16.10021 ++void * __builtin_custom_pn (void)
16.10022 ++void * __builtin_custom_pni (int)
16.10023 ++void * __builtin_custom_pnf (float)
16.10024 ++void * __builtin_custom_pnp (void *)
16.10025 ++void * __builtin_custom_pnii (int, int)
16.10026 ++void * __builtin_custom_pnif (int, float)
16.10027 ++void * __builtin_custom_pnip (int, void *)
16.10028 ++void * __builtin_custom_pnfi (float, int)
16.10029 ++void * __builtin_custom_pnff (float, float)
16.10030 ++void * __builtin_custom_pnfp (float, void *)
16.10031 ++void * __builtin_custom_pnpi (void *, int)
16.10032 ++void * __builtin_custom_pnpf (void *, float)
16.10033 ++void * __builtin_custom_pnpp (void *, void *)
16.10034 ++@end example
16.10035 ++
16.10036 ++
16.10037 + @node Alpha Built-in Functions
16.10038 + @subsection Alpha Built-in Functions
16.10039 + 
16.10040 +diff -durN gcc-3.4.6.orig/gcc/doc/invoke.texi gcc-3.4.6/gcc/doc/invoke.texi
16.10041 +--- gcc-3.4.6.orig/gcc/doc/invoke.texi	2005-10-08 02:22:20.000000000 +0200
16.10042 ++++ gcc-3.4.6/gcc/doc/invoke.texi	2007-08-15 23:09:36.000000000 +0200
16.10043 +@@ -337,6 +337,14 @@
16.10044 + @item Machine Dependent Options
16.10045 + @xref{Submodel Options,,Hardware Models and Configurations}.
16.10046 + 
16.10047 ++@emph{Altera Nios II Options}
16.10048 ++@gccoptlist{-msmallc -mno-bypass-cache -mbypass-cache @gol
16.10049 ++-mno-cache-volatile -mcache-volatile -mno-inline-memcpy @gol 
16.10050 ++-minline-memcpy -mno-fast-sw-div -mfast-sw-div @gol
16.10051 ++-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx @gol
16.10052 ++-mno-hw-div -mhw-div @gol
16.10053 ++-msys-crt0= -msys-lib= -msys=nosys }
16.10054 ++
16.10055 + @emph{M680x0 Options}
16.10056 + @gccoptlist{-m68000  -m68020  -m68020-40  -m68020-60  -m68030  -m68040 @gol
16.10057 + -m68060  -mcpu32  -m5200  -m68881  -mbitfield  -mc68000  -mc68020   @gol
16.10058 +@@ -5839,6 +5847,7 @@
16.10059 + that macro, which enables you to change the defaults.
16.10060 + 
16.10061 + @menu
16.10062 ++* Altera Nios II Options::
16.10063 + * M680x0 Options::
16.10064 + * M68hc1x Options::
16.10065 + * VAX Options::
16.10066 +@@ -5874,6 +5883,103 @@
16.10067 + * FRV Options::
16.10068 + @end menu
16.10069 + 
16.10070 ++
16.10071 ++@node Altera Nios II Options
16.10072 ++@subsection Altera Nios II Options
16.10073 ++@cindex Altera Nios II options
16.10074 ++
16.10075 ++These are the @samp{-m} options defined for the Altera Nios II 
16.10076 ++processor.
16.10077 ++
16.10078 ++@table @gcctabopt
16.10079 ++
16.10080 ++@item -msmallc
16.10081 ++@opindex msmallc
16.10082 ++
16.10083 ++Link with a limited version of the C library, -lsmallc. For more 
16.10084 ++information see the C Library Documentation.
16.10085 ++
16.10086 ++
16.10087 ++@item -mbypass-cache
16.10088 ++@itemx -mno-bypass-cache
16.10089 ++@opindex mno-bypass-cache
16.10090 ++@opindex mbypass-cache
16.10091 ++
16.10092 ++Force all load and store instructions to always bypass cache by 
16.10093 ++using io variants of the instructions. The default is to not
16.10094 ++bypass the cache.
16.10095 ++
16.10096 ++@item -mno-cache-volatile 
16.10097 ++@itemx -mcache-volatile       
16.10098 ++@opindex mcache-volatile 
16.10099 ++@opindex mno-cache-volatile
16.10100 ++
16.10101 ++Volatile memory access bypass the cache using the io variants of 
16.10102 ++the ld and st instructions. The default is to cache volatile 
16.10103 ++accesses. 
16.10104 ++
16.10105 ++-mno-cache-volatile is deprecated and will be deleted in a 
16.10106 ++future GCC release.
16.10107 ++
16.10108 ++
16.10109 ++@item -mno-inline-memcpy
16.10110 ++@itemx -minline-memcpy
16.10111 ++@opindex mno-inline-memcpy 
16.10112 ++@opindex minline-memcpy
16.10113 ++
16.10114 ++Do not inline memcpy. The default is to inline when -O is on.
16.10115 ++
16.10116 ++
16.10117 ++@item -mno-fast-sw-div
16.10118 ++@itemx -mfast-sw-div
16.10119 ++@opindex mno-fast-sw-div
16.10120 ++@opindex mfast-sw-div
16.10121 ++
16.10122 ++Do no use table based fast divide for small numbers. The default 
16.10123 ++is to use the fast divide at -O3 and above.
16.10124 ++
16.10125 ++
16.10126 ++@item -mno-hw-mul
16.10127 ++@itemx -mhw-mul
16.10128 ++@itemx -mno-hw-mulx
16.10129 ++@itemx -mhw-mulx
16.10130 ++@itemx -mno-hw-div
16.10131 ++@itemx -mhw-div
16.10132 ++@opindex mno-hw-mul
16.10133 ++@opindex mhw-mul
16.10134 ++@opindex mno-hw-mulx
16.10135 ++@opindex mhw-mulx
16.10136 ++@opindex mno-hw-div
16.10137 ++@opindex mhw-div
16.10138 ++
16.10139 ++Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of 
16.10140 ++instructions by the compiler. The default is to emit @code{mul}
16.10141 ++and not emit @code{div} and @code{mulx}.
16.10142 ++
16.10143 ++The different combinations of @code{mul} and @code{mulx} instructions 
16.10144 ++generate a different multilib options. 
16.10145 ++
16.10146 ++
16.10147 ++@item -msys-crt0=@var{startfile}
16.10148 ++@opindex msys-crt0
16.10149 ++
16.10150 ++@var{startfile} is the file name  of the startfile (crt0) to use 
16.10151 ++when linking. The default is crt0.o that comes with libgloss
16.10152 ++and is only suitable for use with the instruction set
16.10153 ++simulator.
16.10154 ++
16.10155 ++@item -msys-lib=@var{systemlib}
16.10156 ++@itemx -msys-lib=nosys
16.10157 ++@opindex msys-lib
16.10158 ++
16.10159 ++@var{systemlib} is the library name of the library which provides
16.10160 ++the system calls required by the C library, e.g. @code{read}, @code{write}
16.10161 ++etc. The default is to use nosys, this library provides
16.10162 ++stub implementations of the calls and is part of libgloss.
16.10163 ++
16.10164 ++@end table
16.10165 ++
16.10166 ++
16.10167 + @node M680x0 Options
16.10168 + @subsection M680x0 Options
16.10169 + @cindex M680x0 options
16.10170 +diff -durN gcc-3.4.6.orig/gcc/doc/md.texi gcc-3.4.6/gcc/doc/md.texi
16.10171 +--- gcc-3.4.6.orig/gcc/doc/md.texi	2004-11-13 23:31:42.000000000 +0100
16.10172 ++++ gcc-3.4.6/gcc/doc/md.texi	2007-08-15 23:09:36.000000000 +0200
16.10173 +@@ -1337,6 +1337,49 @@
16.10174 + available on some particular machines.
16.10175 + 
16.10176 + @table @emph
16.10177 ++
16.10178 ++@item Altera Nios II family---@file{nios2.h}
16.10179 ++@table @code
16.10180 ++
16.10181 ++@item I
16.10182 ++Integer that is valid as an immediate operand in an
16.10183 ++instruction taking a signed 16-bit number. Range
16.10184 ++@minus{}32768 to 32767.
16.10185 ++
16.10186 ++@item J
16.10187 ++Integer that is valid as an immediate operand in an
16.10188 ++instruction taking an unsigned 16-bit number. Range
16.10189 ++0 to 65535.
16.10190 ++
16.10191 ++@item K
16.10192 ++Integer that is valid as an immediate operand in an
16.10193 ++instruction taking only the upper 16-bits of a
16.10194 ++32-bit number. Range 32-bit numbers with the lower
16.10195 ++16-bits being 0.
16.10196 ++
16.10197 ++@item L
16.10198 ++Integer that is valid as an immediate operand for a 
16.10199 ++shift instruction. Range 0 to 31.
16.10200 ++
16.10201 ++
16.10202 ++@item M
16.10203 ++Integer that is valid as an immediate operand for
16.10204 ++only the value 0. Can be used in conjunction with
16.10205 ++the format modifier @code{z} to use @code{r0}
16.10206 ++instead of @code{0} in the assembly output.
16.10207 ++
16.10208 ++@item N
16.10209 ++Integer that is valid as an immediate operand for
16.10210 ++a custom instruction opcode. Range 0 to 255.
16.10211 ++
16.10212 ++@item S
16.10213 ++Matches immediates which are addresses in the small
16.10214 ++data section and therefore can be added to @code{gp}
16.10215 ++as a 16-bit immediate to re-create their 32-bit value.
16.10216 ++
16.10217 ++@end table
16.10218 ++
16.10219 ++
16.10220 + @item ARM family---@file{arm.h}
16.10221 + @table @code
16.10222 + @item f
16.10223 +diff -durN gcc-3.4.6.orig/gcc/Makefile.in gcc-3.4.6/gcc/Makefile.in
16.10224 +--- gcc-3.4.6.orig/gcc/Makefile.in	2005-02-24 10:26:59.000000000 +0100
16.10225 ++++ gcc-3.4.6/gcc/Makefile.in	2007-08-15 23:09:36.000000000 +0200
16.10226 +@@ -3094,7 +3094,7 @@
16.10227 + 	  $(INSTALL_DATA) $(srcdir)/README-fixinc \
16.10228 + 	    $(DESTDIR)$(itoolsdatadir)/include/README ; \
16.10229 + 	  $(INSTALL_SCRIPT) fixinc.sh $(DESTDIR)$(itoolsdir)/fixinc.sh ; \
16.10230 +-	  $(INSTALL_PROGRAM) fixinc/fixincl $(DESTDIR)$(itoolsdir)/fixincl ; \
16.10231 ++	  $(INSTALL_PROGRAM) fixinc/fixincl$(build_exeext) $(DESTDIR)$(itoolsdir)/fixincl$(build_exeext) ; \
16.10232 + 	  $(INSTALL_DATA) $(srcdir)/gsyslimits.h \
16.10233 + 	    $(DESTDIR)$(itoolsdatadir)/gsyslimits.h ; \
16.10234 + 	else :; fi
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/patches/gcc/3.4.6/arm-softfloat.patch	Wed Aug 15 21:23:08 2007 +0000
    17.3 @@ -0,0 +1,161 @@
    17.4 +diff -durN gcc-3.4.6.orig/gcc/config/arm/coff.h gcc-3.4.6/gcc/config/arm/coff.h
    17.5 +--- gcc-3.4.6.orig/gcc/config/arm/coff.h	2004-02-24 15:25:22.000000000 +0100
    17.6 ++++ gcc-3.4.6/gcc/config/arm/coff.h	2007-08-15 23:10:54.000000000 +0200
    17.7 +@@ -31,11 +31,16 @@
    17.8 + #define TARGET_VERSION fputs (" (ARM/coff)", stderr)
    17.9 + 
   17.10 + #undef  TARGET_DEFAULT
   17.11 +-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
   17.12 ++#define TARGET_DEFAULT		\
   17.13 ++	( ARM_FLAG_SOFT_FLOAT	\
   17.14 ++	| ARM_FLAG_VFP		\
   17.15 ++	| ARM_FLAG_APCS_32	\
   17.16 ++	| ARM_FLAG_APCS_FRAME	\
   17.17 ++	| ARM_FLAG_MMU_TRAPS )
   17.18 + 
   17.19 + #ifndef MULTILIB_DEFAULTS
   17.20 + #define MULTILIB_DEFAULTS \
   17.21 +-  { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
   17.22 ++  { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork" }
   17.23 + #endif
   17.24 + 
   17.25 + /* This is COFF, but prefer stabs.  */
   17.26 +diff -durN gcc-3.4.6.orig/gcc/config/arm/elf.h gcc-3.4.6/gcc/config/arm/elf.h
   17.27 +--- gcc-3.4.6.orig/gcc/config/arm/elf.h	2004-02-24 15:25:22.000000000 +0100
   17.28 ++++ gcc-3.4.6/gcc/config/arm/elf.h	2007-08-15 23:10:54.000000000 +0200
   17.29 +@@ -46,7 +46,9 @@
   17.30 + 
   17.31 + #ifndef SUBTARGET_ASM_FLOAT_SPEC
   17.32 + #define SUBTARGET_ASM_FLOAT_SPEC "\
   17.33 +-%{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
   17.34 ++%{mapcs-float:-mfloat} \
   17.35 ++%{mhard-float:-mfpu=fpa} \
   17.36 ++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
   17.37 + #endif
   17.38 + 
   17.39 + #ifndef ASM_SPEC
   17.40 +@@ -106,12 +108,17 @@
   17.41 + #endif
   17.42 + 
   17.43 + #ifndef TARGET_DEFAULT
   17.44 +-#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
   17.45 ++#define TARGET_DEFAULT		\
   17.46 ++	( ARM_FLAG_SOFT_FLOAT	\
   17.47 ++	| ARM_FLAG_VFP		\
   17.48 ++	| ARM_FLAG_APCS_32	\
   17.49 ++	| ARM_FLAG_APCS_FRAME	\
   17.50 ++	| ARM_FLAG_MMU_TRAPS )
   17.51 + #endif
   17.52 + 
   17.53 + #ifndef MULTILIB_DEFAULTS
   17.54 + #define MULTILIB_DEFAULTS \
   17.55 +-  { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
   17.56 ++  { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
   17.57 + #endif
   17.58 + 
   17.59 + #define TARGET_ASM_FILE_START_APP_OFF true
   17.60 +diff -durN gcc-3.4.6.orig/gcc/config/arm/linux-elf.h gcc-3.4.6/gcc/config/arm/linux-elf.h
   17.61 +--- gcc-3.4.6.orig/gcc/config/arm/linux-elf.h	2007-08-15 23:07:00.000000000 +0200
   17.62 ++++ gcc-3.4.6/gcc/config/arm/linux-elf.h	2007-08-15 23:10:54.000000000 +0200
   17.63 +@@ -44,12 +44,26 @@
   17.64 + #define TARGET_LINKER_EMULATION "armelf_linux"
   17.65 + #endif
   17.66 + 
   17.67 +-/* Default is to use APCS-32 mode.  */
   17.68 ++/*
   17.69 ++ * Default is to use APCS-32 mode with soft-vfp.
   17.70 ++ * The old Linux default for floats can be achieved with -mhard-float
   17.71 ++ * or with the configure --with-float=hard option.
   17.72 ++ * If -msoft-float or --with-float=soft is used then software float 
   17.73 ++ * support will be used just like the default but with the legacy
   17.74 ++ * big endian word ordering for double float representation instead.
   17.75 ++ */
   17.76 + #undef  TARGET_DEFAULT
   17.77 +-#define TARGET_DEFAULT \
   17.78 +-		( ARM_FLAG_APCS_32 | \
   17.79 +-		  ARM_FLAG_MMU_TRAPS | \
   17.80 +-		  TARGET_ENDIAN_DEFAULT )
   17.81 ++#define TARGET_DEFAULT		\
   17.82 ++	( ARM_FLAG_APCS_32	\
   17.83 ++	| ARM_FLAG_SOFT_FLOAT	\
   17.84 ++	| TARGET_ENDIAN_DEFAULT	\
   17.85 ++	| ARM_FLAG_VFP		\
   17.86 ++	| ARM_FLAG_MMU_TRAPS )
   17.87 ++
   17.88 ++#undef  SUBTARGET_EXTRA_ASM_SPEC
   17.89 ++#define SUBTARGET_EXTRA_ASM_SPEC "\
   17.90 ++%{mhard-float:-mfpu=fpa} \
   17.91 ++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
   17.92 + 
   17.93 + #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
   17.94 + 
   17.95 +@@ -57,7 +71,7 @@
   17.96 + 
   17.97 + #undef  MULTILIB_DEFAULTS
   17.98 + #define MULTILIB_DEFAULTS \
   17.99 +-	{ "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mapcs-32", "mno-thumb-interwork" }
  17.100 ++	{ "marm", TARGET_ENDIAN_OPTION, "mapcs-32", "mno-thumb-interwork" }
  17.101 + 
  17.102 + #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
  17.103 + 
  17.104 +@@ -72,7 +86,7 @@
  17.105 +    %{shared:-lc} \
  17.106 +    %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
  17.107 + 
  17.108 +-#define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
  17.109 ++#define LIBGCC_SPEC "-lgcc"
  17.110 + 
  17.111 + /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
  17.112 +    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
  17.113 +diff -durN gcc-3.4.6.orig/gcc/config/arm/t-linux gcc-3.4.6/gcc/config/arm/t-linux
  17.114 +--- gcc-3.4.6.orig/gcc/config/arm/t-linux	2003-09-20 23:09:07.000000000 +0200
  17.115 ++++ gcc-3.4.6/gcc/config/arm/t-linux	2007-08-15 23:10:54.000000000 +0200
  17.116 +@@ -4,7 +4,10 @@
  17.117 + LIBGCC2_DEBUG_CFLAGS = -g0
  17.118 + 
  17.119 + LIB1ASMSRC = arm/lib1funcs.asm
  17.120 +-LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
  17.121 ++LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
  17.122 ++	_negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
  17.123 ++	_truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
  17.124 ++	_fixsfsi _fixunssfsi
  17.125 + 
  17.126 + # MULTILIB_OPTIONS = mhard-float/msoft-float
  17.127 + # MULTILIB_DIRNAMES = hard-float soft-float
  17.128 +diff -durN gcc-3.4.6.orig/gcc/config/arm/unknown-elf.h gcc-3.4.6/gcc/config/arm/unknown-elf.h
  17.129 +--- gcc-3.4.6.orig/gcc/config/arm/unknown-elf.h	2004-02-24 15:25:22.000000000 +0100
  17.130 ++++ gcc-3.4.6/gcc/config/arm/unknown-elf.h	2007-08-15 23:10:54.000000000 +0200
  17.131 +@@ -30,7 +30,12 @@
  17.132 + 
  17.133 + /* Default to using APCS-32 and software floating point.  */
  17.134 + #ifndef TARGET_DEFAULT
  17.135 +-#define TARGET_DEFAULT	(ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
  17.136 ++#define TARGET_DEFAULT		\
  17.137 ++	( ARM_FLAG_SOFT_FLOAT	\
  17.138 ++	| ARM_FLAG_VFP		\
  17.139 ++	| ARM_FLAG_APCS_32	\
  17.140 ++	| ARM_FLAG_APCS_FRAME	\
  17.141 ++	| ARM_FLAG_MMU_TRAPS )
  17.142 + #endif
  17.143 + 
  17.144 + /* Now we define the strings used to build the spec file.  */
  17.145 +diff -durN gcc-3.4.6.orig/gcc/config/arm/xscale-elf.h gcc-3.4.6/gcc/config/arm/xscale-elf.h
  17.146 +--- gcc-3.4.6.orig/gcc/config/arm/xscale-elf.h	2003-07-02 01:26:43.000000000 +0200
  17.147 ++++ gcc-3.4.6/gcc/config/arm/xscale-elf.h	2007-08-15 23:10:54.000000000 +0200
  17.148 +@@ -49,11 +49,12 @@
  17.149 + 		     endian, regardless of the endian-ness of the memory
  17.150 + 		     system.  */
  17.151 + 		     
  17.152 +-#define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
  17.153 +-  %{mhard-float:-mfpu=fpa} \
  17.154 +-  %{!mhard-float: %{msoft-float:-mfpu=softfpa;:-mfpu=softvfp}}"
  17.155 ++#define SUBTARGET_EXTRA_ASM_SPEC "\
  17.156 ++%{!mcpu=*:-mcpu=xscale} \
  17.157 ++%{mhard-float:-mfpu=fpa} \
  17.158 ++%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
  17.159 + 
  17.160 + #ifndef MULTILIB_DEFAULTS
  17.161 + #define MULTILIB_DEFAULTS \
  17.162 +-  { "mlittle-endian", "mno-thumb-interwork", "marm", "msoft-float" }
  17.163 ++  { "mlittle-endian", "mno-thumb-interwork", "marm" }
  17.164 + #endif