1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/gcc/3.4.6/250-nios2.patch Thu Nov 17 01:14:12 2011 +0100
1.3 @@ -0,0 +1,10231 @@
1.4 +diff -durN gcc-3.4.6.orig/gcc/combine.c gcc-3.4.6/gcc/combine.c
1.5 +--- gcc-3.4.6.orig/gcc/combine.c 2005-08-08 20:41:04.000000000 +0200
1.6 ++++ gcc-3.4.6/gcc/combine.c 2007-08-15 23:09:36.000000000 +0200
1.7 +@@ -4381,6 +4381,14 @@
1.8 + mode);
1.9 + }
1.10 +
1.11 ++#ifndef __nios2__
1.12 ++/* This screws up Nios II in this test case:
1.13 ++
1.14 ++if (x & 1)
1.15 ++ return 2;
1.16 ++else
1.17 ++ return 3;
1.18 ++*/
1.19 + else if (STORE_FLAG_VALUE == 1
1.20 + && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
1.21 + && op1 == const0_rtx
1.22 +@@ -4392,6 +4400,7 @@
1.23 + gen_lowpart_for_combine (mode, op0),
1.24 + const1_rtx);
1.25 + }
1.26 ++#endif
1.27 +
1.28 + else if (STORE_FLAG_VALUE == 1
1.29 + && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
1.30 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/crti.asm gcc-3.4.6/gcc/config/nios2/crti.asm
1.31 +--- gcc-3.4.6.orig/gcc/config/nios2/crti.asm 1970-01-01 01:00:00.000000000 +0100
1.32 ++++ gcc-3.4.6/gcc/config/nios2/crti.asm 2007-08-15 23:09:36.000000000 +0200
1.33 +@@ -0,0 +1,88 @@
1.34 ++/*
1.35 ++ Copyright (C) 2003
1.36 ++ by Jonah Graham (jgraham@altera.com)
1.37 ++
1.38 ++This file is free software; you can redistribute it and/or modify it
1.39 ++under the terms of the GNU General Public License as published by the
1.40 ++Free Software Foundation; either version 2, or (at your option) any
1.41 ++later version.
1.42 ++
1.43 ++In addition to the permissions in the GNU General Public License, the
1.44 ++Free Software Foundation gives you unlimited permission to link the
1.45 ++compiled version of this file with other programs, and to distribute
1.46 ++those programs without any restriction coming from the use of this
1.47 ++file. (The General Public License restrictions do apply in other
1.48 ++respects; for example, they cover modification of the file, and
1.49 ++distribution when not linked into another program.)
1.50 ++
1.51 ++This file is distributed in the hope that it will be useful, but
1.52 ++WITHOUT ANY WARRANTY; without even the implied warranty of
1.53 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.54 ++General Public License for more details.
1.55 ++
1.56 ++You should have received a copy of the GNU General Public License
1.57 ++along with this program; see the file COPYING. If not, write to
1.58 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.59 ++Boston, MA 02111-1307, USA.
1.60 ++
1.61 ++ As a special exception, if you link this library with files
1.62 ++ compiled with GCC to produce an executable, this does not cause
1.63 ++ the resulting executable to be covered by the GNU General Public License.
1.64 ++ This exception does not however invalidate any other reasons why
1.65 ++ the executable file might be covered by the GNU General Public License.
1.66 ++
1.67 ++
1.68 ++This file just make a stack frame for the contents of the .fini and
1.69 ++.init sections. Users may put any desired instructions in those
1.70 ++sections.
1.71 ++
1.72 ++
1.73 ++While technically any code can be put in the init and fini sections
1.74 ++most stuff will not work other than stuff which obeys the call frame
1.75 ++and ABI. All the call-preserved registers are saved, the call clobbered
1.76 ++registers should have been saved by the code calling init and fini.
1.77 ++
1.78 ++See crtstuff.c for an example of code that inserts itself in the
1.79 ++init and fini sections.
1.80 ++
1.81 ++See crt0.s for the code that calls init and fini.
1.82 ++*/
1.83 ++
1.84 ++ .file "crti.asm"
1.85 ++
1.86 ++ .section ".init"
1.87 ++ .align 2
1.88 ++ .global _init
1.89 ++_init:
1.90 ++ addi sp, sp, -48
1.91 ++ stw ra, 44(sp)
1.92 ++ stw r23, 40(sp)
1.93 ++ stw r22, 36(sp)
1.94 ++ stw r21, 32(sp)
1.95 ++ stw r20, 28(sp)
1.96 ++ stw r19, 24(sp)
1.97 ++ stw r18, 20(sp)
1.98 ++ stw r17, 16(sp)
1.99 ++ stw r16, 12(sp)
1.100 ++ stw fp, 8(sp)
1.101 ++ mov fp, sp
1.102 ++
1.103 ++
1.104 ++ .section ".fini"
1.105 ++ .align 2
1.106 ++ .global _fini
1.107 ++_fini:
1.108 ++ addi sp, sp, -48
1.109 ++ stw ra, 44(sp)
1.110 ++ stw r23, 40(sp)
1.111 ++ stw r22, 36(sp)
1.112 ++ stw r21, 32(sp)
1.113 ++ stw r20, 28(sp)
1.114 ++ stw r19, 24(sp)
1.115 ++ stw r18, 20(sp)
1.116 ++ stw r17, 16(sp)
1.117 ++ stw r16, 12(sp)
1.118 ++ stw fp, 8(sp)
1.119 ++ mov fp, sp
1.120 ++
1.121 ++
1.122 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/crtn.asm gcc-3.4.6/gcc/config/nios2/crtn.asm
1.123 +--- gcc-3.4.6.orig/gcc/config/nios2/crtn.asm 1970-01-01 01:00:00.000000000 +0100
1.124 ++++ gcc-3.4.6/gcc/config/nios2/crtn.asm 2007-08-15 23:09:36.000000000 +0200
1.125 +@@ -0,0 +1,70 @@
1.126 ++/*
1.127 ++ Copyright (C) 2003
1.128 ++ by Jonah Graham (jgraham@altera.com)
1.129 ++
1.130 ++This file is free software; you can redistribute it and/or modify it
1.131 ++under the terms of the GNU General Public License as published by the
1.132 ++Free Software Foundation; either version 2, or (at your option) any
1.133 ++later version.
1.134 ++
1.135 ++In addition to the permissions in the GNU General Public License, the
1.136 ++Free Software Foundation gives you unlimited permission to link the
1.137 ++compiled version of this file with other programs, and to distribute
1.138 ++those programs without any restriction coming from the use of this
1.139 ++file. (The General Public License restrictions do apply in other
1.140 ++respects; for example, they cover modification of the file, and
1.141 ++distribution when not linked into another program.)
1.142 ++
1.143 ++This file is distributed in the hope that it will be useful, but
1.144 ++WITHOUT ANY WARRANTY; without even the implied warranty of
1.145 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.146 ++General Public License for more details.
1.147 ++
1.148 ++You should have received a copy of the GNU General Public License
1.149 ++along with this program; see the file COPYING. If not, write to
1.150 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.151 ++Boston, MA 02111-1307, USA.
1.152 ++
1.153 ++ As a special exception, if you link this library with files
1.154 ++ compiled with GCC to produce an executable, this does not cause
1.155 ++ the resulting executable to be covered by the GNU General Public License.
1.156 ++ This exception does not however invalidate any other reasons why
1.157 ++ the executable file might be covered by the GNU General Public License.
1.158 ++
1.159 ++
1.160 ++This file just makes sure that the .fini and .init sections do in
1.161 ++fact return. Users may put any desired instructions in those sections.
1.162 ++This file is the last thing linked into any executable.
1.163 ++*/
1.164 ++ .file "crtn.asm"
1.165 ++
1.166 ++
1.167 ++
1.168 ++ .section ".init"
1.169 ++ ldw ra, 44(sp)
1.170 ++ ldw r23, 40(sp)
1.171 ++ ldw r22, 36(sp)
1.172 ++ ldw r21, 32(sp)
1.173 ++ ldw r20, 28(sp)
1.174 ++ ldw r19, 24(sp)
1.175 ++ ldw r18, 20(sp)
1.176 ++ ldw r17, 16(sp)
1.177 ++ ldw r16, 12(sp)
1.178 ++ ldw fp, 8(sp)
1.179 ++ addi sp, sp, -48
1.180 ++ ret
1.181 ++
1.182 ++ .section ".fini"
1.183 ++ ldw ra, 44(sp)
1.184 ++ ldw r23, 40(sp)
1.185 ++ ldw r22, 36(sp)
1.186 ++ ldw r21, 32(sp)
1.187 ++ ldw r20, 28(sp)
1.188 ++ ldw r19, 24(sp)
1.189 ++ ldw r18, 20(sp)
1.190 ++ ldw r17, 16(sp)
1.191 ++ ldw r16, 12(sp)
1.192 ++ ldw fp, 8(sp)
1.193 ++ addi sp, sp, -48
1.194 ++ ret
1.195 ++
1.196 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod.c gcc-3.4.6/gcc/config/nios2/lib2-divmod.c
1.197 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod.c 1970-01-01 01:00:00.000000000 +0100
1.198 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divmod.c 2007-08-15 23:09:36.000000000 +0200
1.199 +@@ -0,0 +1,126 @@
1.200 ++
1.201 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
1.202 ++ supposedly valid even though this is a "target" file. */
1.203 ++#include "auto-host.h"
1.204 ++
1.205 ++
1.206 ++#include "tconfig.h"
1.207 ++#include "tsystem.h"
1.208 ++#include "coretypes.h"
1.209 ++#include "tm.h"
1.210 ++
1.211 ++
1.212 ++/* Don't use `fancy_abort' here even if config.h says to use it. */
1.213 ++#ifdef abort
1.214 ++#undef abort
1.215 ++#endif
1.216 ++
1.217 ++
1.218 ++#ifdef HAVE_GAS_HIDDEN
1.219 ++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
1.220 ++#else
1.221 ++#define ATTRIBUTE_HIDDEN
1.222 ++#endif
1.223 ++
1.224 ++#include "libgcc2.h"
1.225 ++
1.226 ++extern SItype __modsi3 (SItype, SItype);
1.227 ++extern SItype __divsi3 (SItype, SItype);
1.228 ++extern SItype __umodsi3 (SItype, SItype);
1.229 ++extern SItype __udivsi3 (SItype, SItype);
1.230 ++
1.231 ++static USItype udivmodsi4(USItype, USItype, word_type);
1.232 ++
1.233 ++/* 16-bit SI divide and modulo as used in NIOS */
1.234 ++
1.235 ++
1.236 ++static USItype
1.237 ++udivmodsi4(USItype num, USItype den, word_type modwanted)
1.238 ++{
1.239 ++ USItype bit = 1;
1.240 ++ USItype res = 0;
1.241 ++
1.242 ++ while (den < num && bit && !(den & (1L<<31)))
1.243 ++ {
1.244 ++ den <<=1;
1.245 ++ bit <<=1;
1.246 ++ }
1.247 ++ while (bit)
1.248 ++ {
1.249 ++ if (num >= den)
1.250 ++ {
1.251 ++ num -= den;
1.252 ++ res |= bit;
1.253 ++ }
1.254 ++ bit >>=1;
1.255 ++ den >>=1;
1.256 ++ }
1.257 ++ if (modwanted) return num;
1.258 ++ return res;
1.259 ++}
1.260 ++
1.261 ++
1.262 ++SItype
1.263 ++__divsi3 (SItype a, SItype b)
1.264 ++{
1.265 ++ word_type neg = 0;
1.266 ++ SItype res;
1.267 ++
1.268 ++ if (a < 0)
1.269 ++ {
1.270 ++ a = -a;
1.271 ++ neg = !neg;
1.272 ++ }
1.273 ++
1.274 ++ if (b < 0)
1.275 ++ {
1.276 ++ b = -b;
1.277 ++ neg = !neg;
1.278 ++ }
1.279 ++
1.280 ++ res = udivmodsi4 (a, b, 0);
1.281 ++
1.282 ++ if (neg)
1.283 ++ res = -res;
1.284 ++
1.285 ++ return res;
1.286 ++}
1.287 ++
1.288 ++
1.289 ++SItype
1.290 ++__modsi3 (SItype a, SItype b)
1.291 ++{
1.292 ++ word_type neg = 0;
1.293 ++ SItype res;
1.294 ++
1.295 ++ if (a < 0)
1.296 ++ {
1.297 ++ a = -a;
1.298 ++ neg = 1;
1.299 ++ }
1.300 ++
1.301 ++ if (b < 0)
1.302 ++ b = -b;
1.303 ++
1.304 ++ res = udivmodsi4 (a, b, 1);
1.305 ++
1.306 ++ if (neg)
1.307 ++ res = -res;
1.308 ++
1.309 ++ return res;
1.310 ++}
1.311 ++
1.312 ++
1.313 ++SItype
1.314 ++__udivsi3 (SItype a, SItype b)
1.315 ++{
1.316 ++ return udivmodsi4 (a, b, 0);
1.317 ++}
1.318 ++
1.319 ++
1.320 ++SItype
1.321 ++__umodsi3 (SItype a, SItype b)
1.322 ++{
1.323 ++ return udivmodsi4 (a, b, 1);
1.324 ++}
1.325 ++
1.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
1.327 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divmod-hi.c 1970-01-01 01:00:00.000000000 +0100
1.328 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divmod-hi.c 2007-08-15 23:09:36.000000000 +0200
1.329 +@@ -0,0 +1,123 @@
1.330 ++
1.331 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
1.332 ++ supposedly valid even though this is a "target" file. */
1.333 ++#include "auto-host.h"
1.334 ++
1.335 ++
1.336 ++#include "tconfig.h"
1.337 ++#include "tsystem.h"
1.338 ++#include "coretypes.h"
1.339 ++#include "tm.h"
1.340 ++
1.341 ++
1.342 ++/* Don't use `fancy_abort' here even if config.h says to use it. */
1.343 ++#ifdef abort
1.344 ++#undef abort
1.345 ++#endif
1.346 ++
1.347 ++
1.348 ++#ifdef HAVE_GAS_HIDDEN
1.349 ++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
1.350 ++#else
1.351 ++#define ATTRIBUTE_HIDDEN
1.352 ++#endif
1.353 ++
1.354 ++#include "libgcc2.h"
1.355 ++
1.356 ++extern HItype __modhi3 (HItype, HItype);
1.357 ++extern HItype __divhi3 (HItype, HItype);
1.358 ++extern HItype __umodhi3 (HItype, HItype);
1.359 ++extern HItype __udivhi3 (HItype, HItype);
1.360 ++
1.361 ++static UHItype udivmodhi4(UHItype, UHItype, word_type);
1.362 ++
1.363 ++static UHItype
1.364 ++udivmodhi4(UHItype num, UHItype den, word_type modwanted)
1.365 ++{
1.366 ++ UHItype bit = 1;
1.367 ++ UHItype res = 0;
1.368 ++
1.369 ++ while (den < num && bit && !(den & (1L<<15)))
1.370 ++ {
1.371 ++ den <<=1;
1.372 ++ bit <<=1;
1.373 ++ }
1.374 ++ while (bit)
1.375 ++ {
1.376 ++ if (num >= den)
1.377 ++ {
1.378 ++ num -= den;
1.379 ++ res |= bit;
1.380 ++ }
1.381 ++ bit >>=1;
1.382 ++ den >>=1;
1.383 ++ }
1.384 ++ if (modwanted) return num;
1.385 ++ return res;
1.386 ++}
1.387 ++
1.388 ++
1.389 ++HItype
1.390 ++__divhi3 (HItype a, HItype b)
1.391 ++{
1.392 ++ word_type neg = 0;
1.393 ++ HItype res;
1.394 ++
1.395 ++ if (a < 0)
1.396 ++ {
1.397 ++ a = -a;
1.398 ++ neg = !neg;
1.399 ++ }
1.400 ++
1.401 ++ if (b < 0)
1.402 ++ {
1.403 ++ b = -b;
1.404 ++ neg = !neg;
1.405 ++ }
1.406 ++
1.407 ++ res = udivmodhi4 (a, b, 0);
1.408 ++
1.409 ++ if (neg)
1.410 ++ res = -res;
1.411 ++
1.412 ++ return res;
1.413 ++}
1.414 ++
1.415 ++
1.416 ++HItype
1.417 ++__modhi3 (HItype a, HItype b)
1.418 ++{
1.419 ++ word_type neg = 0;
1.420 ++ HItype res;
1.421 ++
1.422 ++ if (a < 0)
1.423 ++ {
1.424 ++ a = -a;
1.425 ++ neg = 1;
1.426 ++ }
1.427 ++
1.428 ++ if (b < 0)
1.429 ++ b = -b;
1.430 ++
1.431 ++ res = udivmodhi4 (a, b, 1);
1.432 ++
1.433 ++ if (neg)
1.434 ++ res = -res;
1.435 ++
1.436 ++ return res;
1.437 ++}
1.438 ++
1.439 ++
1.440 ++HItype
1.441 ++__udivhi3 (HItype a, HItype b)
1.442 ++{
1.443 ++ return udivmodhi4 (a, b, 0);
1.444 ++}
1.445 ++
1.446 ++
1.447 ++HItype
1.448 ++__umodhi3 (HItype a, HItype b)
1.449 ++{
1.450 ++ return udivmodhi4 (a, b, 1);
1.451 ++}
1.452 ++
1.453 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-divtable.c gcc-3.4.6/gcc/config/nios2/lib2-divtable.c
1.454 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-divtable.c 1970-01-01 01:00:00.000000000 +0100
1.455 ++++ gcc-3.4.6/gcc/config/nios2/lib2-divtable.c 2007-08-15 23:09:36.000000000 +0200
1.456 +@@ -0,0 +1,46 @@
1.457 ++
1.458 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
1.459 ++ supposedly valid even though this is a "target" file. */
1.460 ++#include "auto-host.h"
1.461 ++
1.462 ++
1.463 ++#include "tconfig.h"
1.464 ++#include "tsystem.h"
1.465 ++#include "coretypes.h"
1.466 ++#include "tm.h"
1.467 ++
1.468 ++
1.469 ++/* Don't use `fancy_abort' here even if config.h says to use it. */
1.470 ++#ifdef abort
1.471 ++#undef abort
1.472 ++#endif
1.473 ++
1.474 ++
1.475 ++#ifdef HAVE_GAS_HIDDEN
1.476 ++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
1.477 ++#else
1.478 ++#define ATTRIBUTE_HIDDEN
1.479 ++#endif
1.480 ++
1.481 ++#include "libgcc2.h"
1.482 ++
1.483 ++UQItype __divsi3_table[] =
1.484 ++{
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.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,
1.501 ++};
1.502 ++
1.503 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/lib2-mul.c gcc-3.4.6/gcc/config/nios2/lib2-mul.c
1.504 +--- gcc-3.4.6.orig/gcc/config/nios2/lib2-mul.c 1970-01-01 01:00:00.000000000 +0100
1.505 ++++ gcc-3.4.6/gcc/config/nios2/lib2-mul.c 2007-08-15 23:09:36.000000000 +0200
1.506 +@@ -0,0 +1,103 @@
1.507 ++/* while we are debugging (ie compile outside of gcc build)
1.508 ++ disable gcc specific headers */
1.509 ++#ifndef DEBUG_MULSI3
1.510 ++
1.511 ++
1.512 ++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
1.513 ++ supposedly valid even though this is a "target" file. */
1.514 ++#include "auto-host.h"
1.515 ++
1.516 ++
1.517 ++#include "tconfig.h"
1.518 ++#include "tsystem.h"
1.519 ++#include "coretypes.h"
1.520 ++#include "tm.h"
1.521 ++
1.522 ++
1.523 ++/* Don't use `fancy_abort' here even if config.h says to use it. */
1.524 ++#ifdef abort
1.525 ++#undef abort
1.526 ++#endif
1.527 ++
1.528 ++
1.529 ++#ifdef HAVE_GAS_HIDDEN
1.530 ++#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
1.531 ++#else
1.532 ++#define ATTRIBUTE_HIDDEN
1.533 ++#endif
1.534 ++
1.535 ++#include "libgcc2.h"
1.536 ++
1.537 ++#else
1.538 ++#define SItype int
1.539 ++#define USItype unsigned int
1.540 ++#endif
1.541 ++
1.542 ++
1.543 ++extern SItype __mulsi3 (SItype, SItype);
1.544 ++
1.545 ++SItype
1.546 ++__mulsi3 (SItype a, SItype b)
1.547 ++{
1.548 ++ SItype res = 0;
1.549 ++ USItype cnt = a;
1.550 ++
1.551 ++ while (cnt)
1.552 ++ {
1.553 ++ if (cnt & 1)
1.554 ++ {
1.555 ++ res += b;
1.556 ++ }
1.557 ++ b <<= 1;
1.558 ++ cnt >>= 1;
1.559 ++ }
1.560 ++
1.561 ++ return res;
1.562 ++}
1.563 ++/*
1.564 ++TODO: Choose best alternative implementation.
1.565 ++
1.566 ++SItype
1.567 ++__divsi3 (SItype a, SItype b)
1.568 ++{
1.569 ++ SItype res = 0;
1.570 ++ USItype cnt = 0;
1.571 ++
1.572 ++ while (cnt < 32)
1.573 ++ {
1.574 ++ if (a & (1L << cnt))
1.575 ++ {
1.576 ++ res += b;
1.577 ++ }
1.578 ++ b <<= 1;
1.579 ++ cnt++;
1.580 ++ }
1.581 ++
1.582 ++ return res;
1.583 ++}
1.584 ++*/
1.585 ++
1.586 ++
1.587 ++#ifdef DEBUG_MULSI3
1.588 ++
1.589 ++int
1.590 ++main ()
1.591 ++{
1.592 ++ int i, j;
1.593 ++ int error = 0;
1.594 ++
1.595 ++ for (i = -1000; i < 1000; i++)
1.596 ++ for (j = -1000; j < 1000; j++)
1.597 ++ {
1.598 ++ int expect = i * j;
1.599 ++ int actual = A__divsi3 (i, j);
1.600 ++ if (expect != actual)
1.601 ++ {
1.602 ++ printf ("error: %d * %d = %d not %d\n", i, j, expect, actual);
1.603 ++ error = 1;
1.604 ++ }
1.605 ++ }
1.606 ++
1.607 ++ return error;
1.608 ++}
1.609 ++#endif
1.610 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.c gcc-3.4.6/gcc/config/nios2/nios2.c
1.611 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.c 1970-01-01 01:00:00.000000000 +0100
1.612 ++++ gcc-3.4.6/gcc/config/nios2/nios2.c 2007-08-15 23:09:36.000000000 +0200
1.613 +@@ -0,0 +1,2853 @@
1.614 ++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
1.615 ++ Copyright (C) 2003 Altera
1.616 ++ Contributed by Jonah Graham (jgraham@altera.com).
1.617 ++
1.618 ++This file is part of GNU CC.
1.619 ++
1.620 ++GNU CC is free software; you can redistribute it and/or modify
1.621 ++it under the terms of the GNU General Public License as published by
1.622 ++the Free Software Foundation; either version 2, or (at your option)
1.623 ++any later version.
1.624 ++
1.625 ++GNU CC is distributed in the hope that it will be useful,
1.626 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
1.627 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.628 ++GNU General Public License for more details.
1.629 ++
1.630 ++You should have received a copy of the GNU General Public License
1.631 ++along with GNU CC; see the file COPYING. If not, write to
1.632 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.633 ++Boston, MA 02111-1307, USA. */
1.634 ++
1.635 ++
1.636 ++#include <stdio.h>
1.637 ++#include "config.h"
1.638 ++#include "system.h"
1.639 ++#include "coretypes.h"
1.640 ++#include "tm.h"
1.641 ++#include "rtl.h"
1.642 ++#include "tree.h"
1.643 ++#include "tm_p.h"
1.644 ++#include "regs.h"
1.645 ++#include "hard-reg-set.h"
1.646 ++#include "real.h"
1.647 ++#include "insn-config.h"
1.648 ++#include "conditions.h"
1.649 ++#include "output.h"
1.650 ++#include "insn-attr.h"
1.651 ++#include "flags.h"
1.652 ++#include "recog.h"
1.653 ++#include "expr.h"
1.654 ++#include "toplev.h"
1.655 ++#include "basic-block.h"
1.656 ++#include "function.h"
1.657 ++#include "ggc.h"
1.658 ++#include "reload.h"
1.659 ++#include "debug.h"
1.660 ++#include "optabs.h"
1.661 ++#include "target.h"
1.662 ++#include "target-def.h"
1.663 ++
1.664 ++/* local prototypes */
1.665 ++static bool nios2_rtx_costs (rtx, int, int, int *);
1.666 ++
1.667 ++static void nios2_asm_function_prologue (FILE *, HOST_WIDE_INT);
1.668 ++static int nios2_use_dfa_pipeline_interface (void);
1.669 ++static int nios2_issue_rate (void);
1.670 ++static struct machine_function *nios2_init_machine_status (void);
1.671 ++static bool nios2_in_small_data_p (tree);
1.672 ++static rtx save_reg (int, HOST_WIDE_INT, rtx);
1.673 ++static rtx restore_reg (int, HOST_WIDE_INT);
1.674 ++static unsigned int nios2_section_type_flags (tree, const char *, int);
1.675 ++static void nios2_init_builtins (void);
1.676 ++static rtx nios2_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1.677 ++static bool nios2_function_ok_for_sibcall (tree, tree);
1.678 ++static void nios2_encode_section_info (tree, rtx, int);
1.679 ++
1.680 ++/* Initialize the GCC target structure. */
1.681 ++#undef TARGET_ASM_FUNCTION_PROLOGUE
1.682 ++#define TARGET_ASM_FUNCTION_PROLOGUE nios2_asm_function_prologue
1.683 ++
1.684 ++#undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
1.685 ++#define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE \
1.686 ++ nios2_use_dfa_pipeline_interface
1.687 ++#undef TARGET_SCHED_ISSUE_RATE
1.688 ++#define TARGET_SCHED_ISSUE_RATE nios2_issue_rate
1.689 ++#undef TARGET_IN_SMALL_DATA_P
1.690 ++#define TARGET_IN_SMALL_DATA_P nios2_in_small_data_p
1.691 ++#undef TARGET_ENCODE_SECTION_INFO
1.692 ++#define TARGET_ENCODE_SECTION_INFO nios2_encode_section_info
1.693 ++#undef TARGET_SECTION_TYPE_FLAGS
1.694 ++#define TARGET_SECTION_TYPE_FLAGS nios2_section_type_flags
1.695 ++
1.696 ++#undef TARGET_INIT_BUILTINS
1.697 ++#define TARGET_INIT_BUILTINS nios2_init_builtins
1.698 ++#undef TARGET_EXPAND_BUILTIN
1.699 ++#define TARGET_EXPAND_BUILTIN nios2_expand_builtin
1.700 ++
1.701 ++#undef TARGET_FUNCTION_OK_FOR_SIBCALL
1.702 ++#define TARGET_FUNCTION_OK_FOR_SIBCALL nios2_function_ok_for_sibcall
1.703 ++
1.704 ++#undef TARGET_RTX_COSTS
1.705 ++#define TARGET_RTX_COSTS nios2_rtx_costs
1.706 ++
1.707 ++
1.708 ++struct gcc_target targetm = TARGET_INITIALIZER;
1.709 ++
1.710 ++
1.711 ++
1.712 ++/* Threshold for data being put into the small data/bss area, instead
1.713 ++ of the normal data area (references to the small data/bss area take
1.714 ++ 1 instruction, and use the global pointer, references to the normal
1.715 ++ data area takes 2 instructions). */
1.716 ++unsigned HOST_WIDE_INT nios2_section_threshold = NIOS2_DEFAULT_GVALUE;
1.717 ++
1.718 ++
1.719 ++/* Structure to be filled in by compute_frame_size with register
1.720 ++ save masks, and offsets for the current function. */
1.721 ++
1.722 ++struct nios2_frame_info
1.723 ++GTY (())
1.724 ++{
1.725 ++ long total_size; /* # bytes that the entire frame takes up */
1.726 ++ long var_size; /* # bytes that variables take up */
1.727 ++ long args_size; /* # bytes that outgoing arguments take up */
1.728 ++ int save_reg_size; /* # bytes needed to store gp regs */
1.729 ++ int save_reg_rounded; /* # bytes needed to store gp regs */
1.730 ++ long save_regs_offset; /* offset from new sp to store gp registers */
1.731 ++ int initialized; /* != 0 if frame size already calculated */
1.732 ++ int num_regs; /* number of gp registers saved */
1.733 ++};
1.734 ++
1.735 ++struct machine_function
1.736 ++GTY (())
1.737 ++{
1.738 ++
1.739 ++ /* Current frame information, calculated by compute_frame_size. */
1.740 ++ struct nios2_frame_info frame;
1.741 ++};
1.742 ++
1.743 ++
1.744 ++/***************************************
1.745 ++ * Section encodings
1.746 ++ ***************************************/
1.747 ++
1.748 ++
1.749 ++
1.750 ++
1.751 ++
1.752 ++/***************************************
1.753 ++ * Stack Layout and Calling Conventions
1.754 ++ ***************************************/
1.755 ++
1.756 ++
1.757 ++#define TOO_BIG_OFFSET(X) ((X) > ((1 << 15) - 1))
1.758 ++#define TEMP_REG_NUM 8
1.759 ++
1.760 ++static void
1.761 ++nios2_asm_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
1.762 ++{
1.763 ++ if (flag_verbose_asm || flag_debug_asm)
1.764 ++ {
1.765 ++ compute_frame_size ();
1.766 ++ dump_frame_size (file);
1.767 ++ }
1.768 ++}
1.769 ++
1.770 ++static rtx
1.771 ++save_reg (int regno, HOST_WIDE_INT offset, rtx cfa_store_reg)
1.772 ++{
1.773 ++ rtx insn, stack_slot;
1.774 ++
1.775 ++ stack_slot = gen_rtx_PLUS (SImode,
1.776 ++ cfa_store_reg,
1.777 ++ GEN_INT (offset));
1.778 ++
1.779 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.780 ++ gen_rtx_MEM (SImode, stack_slot),
1.781 ++ gen_rtx_REG (SImode, regno)));
1.782 ++
1.783 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.784 ++
1.785 ++ return insn;
1.786 ++}
1.787 ++
1.788 ++static rtx
1.789 ++restore_reg (int regno, HOST_WIDE_INT offset)
1.790 ++{
1.791 ++ rtx insn, stack_slot;
1.792 ++
1.793 ++ if (TOO_BIG_OFFSET (offset))
1.794 ++ {
1.795 ++ stack_slot = gen_rtx_REG (SImode, TEMP_REG_NUM);
1.796 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.797 ++ stack_slot,
1.798 ++ GEN_INT (offset)));
1.799 ++
1.800 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.801 ++ stack_slot,
1.802 ++ gen_rtx_PLUS (SImode,
1.803 ++ stack_slot,
1.804 ++ stack_pointer_rtx)));
1.805 ++ }
1.806 ++ else
1.807 ++ {
1.808 ++ stack_slot = gen_rtx_PLUS (SImode,
1.809 ++ stack_pointer_rtx,
1.810 ++ GEN_INT (offset));
1.811 ++ }
1.812 ++
1.813 ++ stack_slot = gen_rtx_MEM (SImode, stack_slot);
1.814 ++
1.815 ++ insn = emit_move_insn (gen_rtx_REG (SImode, regno), stack_slot);
1.816 ++
1.817 ++ return insn;
1.818 ++}
1.819 ++
1.820 ++
1.821 ++/* There are two possible paths for prologue expansion,
1.822 ++- the first is if the total frame size is < 2^15-1. In that
1.823 ++case all the immediates will fit into the 16-bit immediate
1.824 ++fields.
1.825 ++- the second is when the frame size is too big, in that
1.826 ++case an additional temporary register is used, first
1.827 ++as a cfa_temp to offset the sp, second as the cfa_store
1.828 ++register.
1.829 ++
1.830 ++See the comment above dwarf2out_frame_debug_expr in
1.831 ++dwarf2out.c for more explanation of the "rules."
1.832 ++
1.833 ++
1.834 ++Case 1:
1.835 ++Rule # Example Insn Effect
1.836 ++2 addi sp, sp, -total_frame_size cfa.reg=sp, cfa.offset=total_frame_size
1.837 ++ cfa_store.reg=sp, cfa_store.offset=total_frame_size
1.838 ++12 stw ra, offset(sp)
1.839 ++12 stw r16, offset(sp)
1.840 ++1 mov fp, sp
1.841 ++
1.842 ++Case 2:
1.843 ++Rule # Example Insn Effect
1.844 ++6 movi r8, total_frame_size cfa_temp.reg=r8, cfa_temp.offset=total_frame_size
1.845 ++2 sub sp, sp, r8 cfa.reg=sp, cfa.offset=total_frame_size
1.846 ++ cfa_store.reg=sp, cfa_store.offset=total_frame_size
1.847 ++5 add r8, r8, sp cfa_store.reg=r8, cfa_store.offset=0
1.848 ++12 stw ra, offset(r8)
1.849 ++12 stw r16, offset(r8)
1.850 ++1 mov fp, sp
1.851 ++
1.852 ++*/
1.853 ++
1.854 ++void
1.855 ++expand_prologue ()
1.856 ++{
1.857 ++ int i;
1.858 ++ HOST_WIDE_INT total_frame_size;
1.859 ++ int cfa_store_offset;
1.860 ++ rtx insn;
1.861 ++ rtx cfa_store_reg = 0;
1.862 ++
1.863 ++ total_frame_size = compute_frame_size ();
1.864 ++
1.865 ++ if (total_frame_size)
1.866 ++ {
1.867 ++
1.868 ++ if (TOO_BIG_OFFSET (total_frame_size))
1.869 ++ {
1.870 ++ /* cfa_temp and cfa_store_reg are the same register,
1.871 ++ cfa_store_reg overwrites cfa_temp */
1.872 ++ cfa_store_reg = gen_rtx_REG (SImode, TEMP_REG_NUM);
1.873 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.874 ++ cfa_store_reg,
1.875 ++ GEN_INT (total_frame_size)));
1.876 ++
1.877 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.878 ++
1.879 ++
1.880 ++ insn = gen_rtx_SET (SImode,
1.881 ++ stack_pointer_rtx,
1.882 ++ gen_rtx_MINUS (SImode,
1.883 ++ stack_pointer_rtx,
1.884 ++ cfa_store_reg));
1.885 ++
1.886 ++ insn = emit_insn (insn);
1.887 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.888 ++
1.889 ++
1.890 ++ /* if there are no registers to save, I don't need to
1.891 ++ create a cfa_store */
1.892 ++ if (cfun->machine->frame.save_reg_size)
1.893 ++ {
1.894 ++ insn = gen_rtx_SET (SImode,
1.895 ++ cfa_store_reg,
1.896 ++ gen_rtx_PLUS (SImode,
1.897 ++ cfa_store_reg,
1.898 ++ stack_pointer_rtx));
1.899 ++
1.900 ++ insn = emit_insn (insn);
1.901 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.902 ++ }
1.903 ++
1.904 ++ cfa_store_offset
1.905 ++ = total_frame_size
1.906 ++ - (cfun->machine->frame.save_regs_offset
1.907 ++ + cfun->machine->frame.save_reg_rounded);
1.908 ++ }
1.909 ++ else
1.910 ++ {
1.911 ++ insn = gen_rtx_SET (SImode,
1.912 ++ stack_pointer_rtx,
1.913 ++ gen_rtx_PLUS (SImode,
1.914 ++ stack_pointer_rtx,
1.915 ++ GEN_INT (-total_frame_size)));
1.916 ++ insn = emit_insn (insn);
1.917 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.918 ++
1.919 ++ cfa_store_reg = stack_pointer_rtx;
1.920 ++ cfa_store_offset
1.921 ++ = cfun->machine->frame.save_regs_offset
1.922 ++ + cfun->machine->frame.save_reg_rounded;
1.923 ++ }
1.924 ++ }
1.925 ++
1.926 ++ if (MUST_SAVE_REGISTER (RA_REGNO))
1.927 ++ {
1.928 ++ cfa_store_offset -= 4;
1.929 ++ save_reg (RA_REGNO, cfa_store_offset, cfa_store_reg);
1.930 ++ }
1.931 ++ if (MUST_SAVE_REGISTER (FP_REGNO))
1.932 ++ {
1.933 ++ cfa_store_offset -= 4;
1.934 ++ save_reg (FP_REGNO, cfa_store_offset, cfa_store_reg);
1.935 ++ }
1.936 ++
1.937 ++ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1.938 ++ {
1.939 ++ if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
1.940 ++ {
1.941 ++ cfa_store_offset -= 4;
1.942 ++ save_reg (i, cfa_store_offset, cfa_store_reg);
1.943 ++ }
1.944 ++ }
1.945 ++
1.946 ++ if (frame_pointer_needed)
1.947 ++ {
1.948 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.949 ++ gen_rtx_REG (SImode, FP_REGNO),
1.950 ++ gen_rtx_REG (SImode, SP_REGNO)));
1.951 ++
1.952 ++ RTX_FRAME_RELATED_P (insn) = 1;
1.953 ++ }
1.954 ++
1.955 ++ /* If we are profiling, make sure no instructions are scheduled before
1.956 ++ the call to mcount. */
1.957 ++ if (current_function_profile)
1.958 ++ emit_insn (gen_blockage ());
1.959 ++}
1.960 ++
1.961 ++void
1.962 ++expand_epilogue (bool sibcall_p)
1.963 ++{
1.964 ++ rtx insn;
1.965 ++ int i;
1.966 ++ HOST_WIDE_INT total_frame_size;
1.967 ++ int register_store_offset;
1.968 ++
1.969 ++ total_frame_size = compute_frame_size ();
1.970 ++
1.971 ++ if (!sibcall_p && nios2_can_use_return_insn ())
1.972 ++ {
1.973 ++ insn = emit_jump_insn (gen_return ());
1.974 ++ return;
1.975 ++ }
1.976 ++
1.977 ++ emit_insn (gen_blockage ());
1.978 ++
1.979 ++ register_store_offset =
1.980 ++ cfun->machine->frame.save_regs_offset +
1.981 ++ cfun->machine->frame.save_reg_rounded;
1.982 ++
1.983 ++ if (MUST_SAVE_REGISTER (RA_REGNO))
1.984 ++ {
1.985 ++ register_store_offset -= 4;
1.986 ++ restore_reg (RA_REGNO, register_store_offset);
1.987 ++ }
1.988 ++
1.989 ++ if (MUST_SAVE_REGISTER (FP_REGNO))
1.990 ++ {
1.991 ++ register_store_offset -= 4;
1.992 ++ restore_reg (FP_REGNO, register_store_offset);
1.993 ++ }
1.994 ++
1.995 ++ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1.996 ++ {
1.997 ++ if (MUST_SAVE_REGISTER (i) && i != FP_REGNO && i != RA_REGNO)
1.998 ++ {
1.999 ++ register_store_offset -= 4;
1.1000 ++ restore_reg (i, register_store_offset);
1.1001 ++ }
1.1002 ++ }
1.1003 ++
1.1004 ++ if (total_frame_size)
1.1005 ++ {
1.1006 ++ rtx sp_adjust;
1.1007 ++
1.1008 ++ if (TOO_BIG_OFFSET (total_frame_size))
1.1009 ++ {
1.1010 ++ sp_adjust = gen_rtx_REG (SImode, TEMP_REG_NUM);
1.1011 ++ insn = emit_insn (gen_rtx_SET (SImode,
1.1012 ++ sp_adjust,
1.1013 ++ GEN_INT (total_frame_size)));
1.1014 ++
1.1015 ++ }
1.1016 ++ else
1.1017 ++ {
1.1018 ++ sp_adjust = GEN_INT (total_frame_size);
1.1019 ++ }
1.1020 ++
1.1021 ++ insn = gen_rtx_SET (SImode,
1.1022 ++ stack_pointer_rtx,
1.1023 ++ gen_rtx_PLUS (SImode,
1.1024 ++ stack_pointer_rtx,
1.1025 ++ sp_adjust));
1.1026 ++ insn = emit_insn (insn);
1.1027 ++ }
1.1028 ++
1.1029 ++
1.1030 ++ if (!sibcall_p)
1.1031 ++ {
1.1032 ++ insn = emit_jump_insn (gen_return_from_epilogue (gen_rtx (REG, Pmode,
1.1033 ++ RA_REGNO)));
1.1034 ++ }
1.1035 ++}
1.1036 ++
1.1037 ++
1.1038 ++bool
1.1039 ++nios2_function_ok_for_sibcall (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
1.1040 ++{
1.1041 ++ return true;
1.1042 ++}
1.1043 ++
1.1044 ++
1.1045 ++
1.1046 ++
1.1047 ++
1.1048 ++/* ----------------------- *
1.1049 ++ * Profiling
1.1050 ++ * ----------------------- */
1.1051 ++
1.1052 ++void
1.1053 ++function_profiler (FILE *file, int labelno)
1.1054 ++{
1.1055 ++ fprintf (file, "\t%s mcount begin, label: .LP%d\n",
1.1056 ++ ASM_COMMENT_START, labelno);
1.1057 ++ fprintf (file, "\tnextpc\tr8\n");
1.1058 ++ fprintf (file, "\tmov\tr9, ra\n");
1.1059 ++ fprintf (file, "\tmovhi\tr10, %%hiadj(.LP%d)\n", labelno);
1.1060 ++ fprintf (file, "\taddi\tr10, r10, %%lo(.LP%d)\n", labelno);
1.1061 ++ fprintf (file, "\tcall\tmcount\n");
1.1062 ++ fprintf (file, "\tmov\tra, r9\n");
1.1063 ++ fprintf (file, "\t%s mcount end\n", ASM_COMMENT_START);
1.1064 ++}
1.1065 ++
1.1066 ++
1.1067 ++/***************************************
1.1068 ++ * Stack Layout
1.1069 ++ ***************************************/
1.1070 ++
1.1071 ++
1.1072 ++void
1.1073 ++dump_frame_size (FILE *file)
1.1074 ++{
1.1075 ++ fprintf (file, "\t%s Current Frame Info\n", ASM_COMMENT_START);
1.1076 ++
1.1077 ++ fprintf (file, "\t%s total_size = %ld\n", ASM_COMMENT_START,
1.1078 ++ cfun->machine->frame.total_size);
1.1079 ++ fprintf (file, "\t%s var_size = %ld\n", ASM_COMMENT_START,
1.1080 ++ cfun->machine->frame.var_size);
1.1081 ++ fprintf (file, "\t%s args_size = %ld\n", ASM_COMMENT_START,
1.1082 ++ cfun->machine->frame.args_size);
1.1083 ++ fprintf (file, "\t%s save_reg_size = %d\n", ASM_COMMENT_START,
1.1084 ++ cfun->machine->frame.save_reg_size);
1.1085 ++ fprintf (file, "\t%s save_reg_rounded = %d\n", ASM_COMMENT_START,
1.1086 ++ cfun->machine->frame.save_reg_rounded);
1.1087 ++ fprintf (file, "\t%s initialized = %d\n", ASM_COMMENT_START,
1.1088 ++ cfun->machine->frame.initialized);
1.1089 ++ fprintf (file, "\t%s num_regs = %d\n", ASM_COMMENT_START,
1.1090 ++ cfun->machine->frame.num_regs);
1.1091 ++ fprintf (file, "\t%s save_regs_offset = %ld\n", ASM_COMMENT_START,
1.1092 ++ cfun->machine->frame.save_regs_offset);
1.1093 ++ fprintf (file, "\t%s current_function_is_leaf = %d\n", ASM_COMMENT_START,
1.1094 ++ current_function_is_leaf);
1.1095 ++ fprintf (file, "\t%s frame_pointer_needed = %d\n", ASM_COMMENT_START,
1.1096 ++ frame_pointer_needed);
1.1097 ++ fprintf (file, "\t%s pretend_args_size = %d\n", ASM_COMMENT_START,
1.1098 ++ current_function_pretend_args_size);
1.1099 ++
1.1100 ++}
1.1101 ++
1.1102 ++
1.1103 ++/* Return the bytes needed to compute the frame pointer from the current
1.1104 ++ stack pointer.
1.1105 ++*/
1.1106 ++
1.1107 ++HOST_WIDE_INT
1.1108 ++compute_frame_size ()
1.1109 ++{
1.1110 ++ unsigned int regno;
1.1111 ++ HOST_WIDE_INT var_size; /* # of var. bytes allocated */
1.1112 ++ HOST_WIDE_INT total_size; /* # bytes that the entire frame takes up */
1.1113 ++ HOST_WIDE_INT save_reg_size; /* # bytes needed to store callee save regs */
1.1114 ++ HOST_WIDE_INT save_reg_rounded;
1.1115 ++ /* # bytes needed to store callee save regs (rounded) */
1.1116 ++ HOST_WIDE_INT out_args_size; /* # bytes needed for outgoing args */
1.1117 ++
1.1118 ++ save_reg_size = 0;
1.1119 ++ var_size = STACK_ALIGN (get_frame_size ());
1.1120 ++ out_args_size = STACK_ALIGN (current_function_outgoing_args_size);
1.1121 ++
1.1122 ++ total_size = var_size + out_args_size;
1.1123 ++
1.1124 ++ /* Calculate space needed for gp registers. */
1.1125 ++ for (regno = 0; regno <= FIRST_PSEUDO_REGISTER; regno++)
1.1126 ++ {
1.1127 ++ if (MUST_SAVE_REGISTER (regno))
1.1128 ++ {
1.1129 ++ save_reg_size += 4;
1.1130 ++ }
1.1131 ++ }
1.1132 ++
1.1133 ++ save_reg_rounded = STACK_ALIGN (save_reg_size);
1.1134 ++ total_size += save_reg_rounded;
1.1135 ++
1.1136 ++ total_size += STACK_ALIGN (current_function_pretend_args_size);
1.1137 ++
1.1138 ++ /* Save other computed information. */
1.1139 ++ cfun->machine->frame.total_size = total_size;
1.1140 ++ cfun->machine->frame.var_size = var_size;
1.1141 ++ cfun->machine->frame.args_size = current_function_outgoing_args_size;
1.1142 ++ cfun->machine->frame.save_reg_size = save_reg_size;
1.1143 ++ cfun->machine->frame.save_reg_rounded = save_reg_rounded;
1.1144 ++ cfun->machine->frame.initialized = reload_completed;
1.1145 ++ cfun->machine->frame.num_regs = save_reg_size / UNITS_PER_WORD;
1.1146 ++
1.1147 ++ cfun->machine->frame.save_regs_offset
1.1148 ++ = save_reg_rounded ? current_function_outgoing_args_size + var_size : 0;
1.1149 ++
1.1150 ++ return total_size;
1.1151 ++}
1.1152 ++
1.1153 ++
1.1154 ++int
1.1155 ++nios2_initial_elimination_offset (int from, int to ATTRIBUTE_UNUSED)
1.1156 ++{
1.1157 ++ int offset;
1.1158 ++
1.1159 ++ /* Set OFFSET to the offset from the stack pointer. */
1.1160 ++ switch (from)
1.1161 ++ {
1.1162 ++ case FRAME_POINTER_REGNUM:
1.1163 ++ offset = 0;
1.1164 ++ break;
1.1165 ++
1.1166 ++ case ARG_POINTER_REGNUM:
1.1167 ++ compute_frame_size ();
1.1168 ++ offset = cfun->machine->frame.total_size;
1.1169 ++ offset -= current_function_pretend_args_size;
1.1170 ++ break;
1.1171 ++
1.1172 ++ case RETURN_ADDRESS_POINTER_REGNUM:
1.1173 ++ compute_frame_size ();
1.1174 ++ /* since the return address is always the first of the
1.1175 ++ saved registers, return the offset to the beginning
1.1176 ++ of the saved registers block */
1.1177 ++ offset = cfun->machine->frame.save_regs_offset;
1.1178 ++ break;
1.1179 ++
1.1180 ++ default:
1.1181 ++ abort ();
1.1182 ++ }
1.1183 ++
1.1184 ++ return offset;
1.1185 ++}
1.1186 ++
1.1187 ++/* Return nonzero if this function is known to have a null epilogue.
1.1188 ++ This allows the optimizer to omit jumps to jumps if no stack
1.1189 ++ was created. */
1.1190 ++int
1.1191 ++nios2_can_use_return_insn ()
1.1192 ++{
1.1193 ++ if (!reload_completed)
1.1194 ++ return 0;
1.1195 ++
1.1196 ++ if (regs_ever_live[RA_REGNO] || current_function_profile)
1.1197 ++ return 0;
1.1198 ++
1.1199 ++ if (cfun->machine->frame.initialized)
1.1200 ++ return cfun->machine->frame.total_size == 0;
1.1201 ++
1.1202 ++ return compute_frame_size () == 0;
1.1203 ++}
1.1204 ++
1.1205 ++
1.1206 ++
1.1207 ++
1.1208 ++
1.1209 ++/***************************************
1.1210 ++ *
1.1211 ++ ***************************************/
1.1212 ++
1.1213 ++const char *nios2_sys_nosys_string; /* for -msys=nosys */
1.1214 ++const char *nios2_sys_lib_string; /* for -msys-lib= */
1.1215 ++const char *nios2_sys_crt0_string; /* for -msys-crt0= */
1.1216 ++
1.1217 ++void
1.1218 ++override_options ()
1.1219 ++{
1.1220 ++ /* Function to allocate machine-dependent function status. */
1.1221 ++ init_machine_status = &nios2_init_machine_status;
1.1222 ++
1.1223 ++ nios2_section_threshold
1.1224 ++ = g_switch_set ? g_switch_value : NIOS2_DEFAULT_GVALUE;
1.1225 ++
1.1226 ++ if (nios2_sys_nosys_string && *nios2_sys_nosys_string)
1.1227 ++ {
1.1228 ++ error ("invalid option '-msys=nosys%s'", nios2_sys_nosys_string);
1.1229 ++ }
1.1230 ++
1.1231 ++ /* If we don't have mul, we don't have mulx either! */
1.1232 ++ if (!TARGET_HAS_MUL && TARGET_HAS_MULX)
1.1233 ++ {
1.1234 ++ target_flags &= ~HAS_MULX_FLAG;
1.1235 ++ }
1.1236 ++
1.1237 ++}
1.1238 ++
1.1239 ++void
1.1240 ++optimization_options (int level, int size)
1.1241 ++{
1.1242 ++ if (level || size)
1.1243 ++ {
1.1244 ++ target_flags |= INLINE_MEMCPY_FLAG;
1.1245 ++ }
1.1246 ++
1.1247 ++ if (level >= 3 && !size)
1.1248 ++ {
1.1249 ++ target_flags |= FAST_SW_DIV_FLAG;
1.1250 ++ }
1.1251 ++}
1.1252 ++
1.1253 ++/* Allocate a chunk of memory for per-function machine-dependent data. */
1.1254 ++static struct machine_function *
1.1255 ++nios2_init_machine_status ()
1.1256 ++{
1.1257 ++ return ((struct machine_function *)
1.1258 ++ ggc_alloc_cleared (sizeof (struct machine_function)));
1.1259 ++}
1.1260 ++
1.1261 ++
1.1262 ++
1.1263 ++/*****************
1.1264 ++ * Describing Relative Costs of Operations
1.1265 ++ *****************/
1.1266 ++
1.1267 ++/* Compute a (partial) cost for rtx X. Return true if the complete
1.1268 ++ cost has been computed, and false if subexpressions should be
1.1269 ++ scanned. In either case, *TOTAL contains the cost result. */
1.1270 ++
1.1271 ++
1.1272 ++
1.1273 ++static bool
1.1274 ++nios2_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
1.1275 ++{
1.1276 ++ switch (code)
1.1277 ++ {
1.1278 ++ case CONST_INT:
1.1279 ++ if (INTVAL (x) == 0)
1.1280 ++ {
1.1281 ++ *total = COSTS_N_INSNS (0);
1.1282 ++ return true;
1.1283 ++ }
1.1284 ++ else if (SMALL_INT (INTVAL (x))
1.1285 ++ || SMALL_INT_UNSIGNED (INTVAL (x))
1.1286 ++ || UPPER16_INT (INTVAL (x)))
1.1287 ++ {
1.1288 ++ *total = COSTS_N_INSNS (2);
1.1289 ++ return true;
1.1290 ++ }
1.1291 ++ else
1.1292 ++ {
1.1293 ++ *total = COSTS_N_INSNS (4);
1.1294 ++ return true;
1.1295 ++ }
1.1296 ++
1.1297 ++ case LABEL_REF:
1.1298 ++ case SYMBOL_REF:
1.1299 ++ /* ??? gp relative stuff will fit in here */
1.1300 ++ /* fall through */
1.1301 ++ case CONST:
1.1302 ++ case CONST_DOUBLE:
1.1303 ++ {
1.1304 ++ *total = COSTS_N_INSNS (4);
1.1305 ++ return true;
1.1306 ++ }
1.1307 ++
1.1308 ++ case MULT:
1.1309 ++ {
1.1310 ++ *total = COSTS_N_INSNS (1);
1.1311 ++ return false;
1.1312 ++ }
1.1313 ++ case SIGN_EXTEND:
1.1314 ++ {
1.1315 ++ *total = COSTS_N_INSNS (3);
1.1316 ++ return false;
1.1317 ++ }
1.1318 ++ case ZERO_EXTEND:
1.1319 ++ {
1.1320 ++ *total = COSTS_N_INSNS (1);
1.1321 ++ return false;
1.1322 ++ }
1.1323 ++
1.1324 ++ default:
1.1325 ++ return false;
1.1326 ++ }
1.1327 ++}
1.1328 ++
1.1329 ++
1.1330 ++/***************************************
1.1331 ++ * INSTRUCTION SUPPORT
1.1332 ++ *
1.1333 ++ * These functions are used within the Machine Description to
1.1334 ++ * handle common or complicated output and expansions from
1.1335 ++ * instructions.
1.1336 ++ ***************************************/
1.1337 ++
1.1338 ++int
1.1339 ++nios2_emit_move_sequence (rtx *operands, enum machine_mode mode)
1.1340 ++{
1.1341 ++ rtx to = operands[0];
1.1342 ++ rtx from = operands[1];
1.1343 ++
1.1344 ++ if (!register_operand (to, mode) && !reg_or_0_operand (from, mode))
1.1345 ++ {
1.1346 ++ if (no_new_pseudos)
1.1347 ++ internal_error ("Trying to force_reg no_new_pseudos == 1");
1.1348 ++ from = copy_to_mode_reg (mode, from);
1.1349 ++ }
1.1350 ++
1.1351 ++ operands[0] = to;
1.1352 ++ operands[1] = from;
1.1353 ++ return 0;
1.1354 ++}
1.1355 ++
1.1356 ++/* Divide Support */
1.1357 ++
1.1358 ++/*
1.1359 ++ If -O3 is used, we want to output a table lookup for
1.1360 ++ divides between small numbers (both num and den >= 0
1.1361 ++ and < 0x10). The overhead of this method in the worse
1.1362 ++ case is 40 bytes in the text section (10 insns) and
1.1363 ++ 256 bytes in the data section. Additional divides do
1.1364 ++ not incur additional penalties in the data section.
1.1365 ++
1.1366 ++ Code speed is improved for small divides by about 5x
1.1367 ++ when using this method in the worse case (~9 cycles
1.1368 ++ vs ~45). And in the worse case divides not within the
1.1369 ++ table are penalized by about 10% (~5 cycles vs ~45).
1.1370 ++ However in the typical case the penalty is not as bad
1.1371 ++ because doing the long divide in only 45 cycles is
1.1372 ++ quite optimistic.
1.1373 ++
1.1374 ++ ??? It would be nice to have some benchmarks other
1.1375 ++ than Dhrystone to back this up.
1.1376 ++
1.1377 ++ This bit of expansion is to create this instruction
1.1378 ++ sequence as rtl.
1.1379 ++ or $8, $4, $5
1.1380 ++ slli $9, $4, 4
1.1381 ++ cmpgeui $3, $8, 16
1.1382 ++ beq $3, $0, .L3
1.1383 ++ or $10, $9, $5
1.1384 ++ add $12, $11, divide_table
1.1385 ++ ldbu $2, 0($12)
1.1386 ++ br .L1
1.1387 ++.L3:
1.1388 ++ call slow_div
1.1389 ++.L1:
1.1390 ++# continue here with result in $2
1.1391 ++
1.1392 ++ ??? Ideally I would like the emit libcall block to contain
1.1393 ++ all of this code, but I don't know how to do that. What it
1.1394 ++ means is that if the divide can be eliminated, it may not
1.1395 ++ completely disappear.
1.1396 ++
1.1397 ++ ??? The __divsi3_table label should ideally be moved out
1.1398 ++ of this block and into a global. If it is placed into the
1.1399 ++ sdata section we can save even more cycles by doing things
1.1400 ++ gp relative.
1.1401 ++*/
1.1402 ++int
1.1403 ++nios2_emit_expensive_div (rtx *operands, enum machine_mode mode)
1.1404 ++{
1.1405 ++ rtx or_result, shift_left_result;
1.1406 ++ rtx lookup_value;
1.1407 ++ rtx lab1, lab3;
1.1408 ++ rtx insns;
1.1409 ++ rtx libfunc;
1.1410 ++ rtx final_result;
1.1411 ++ rtx tmp;
1.1412 ++
1.1413 ++ /* it may look a little generic, but only SImode
1.1414 ++ is supported for now */
1.1415 ++ if (mode != SImode)
1.1416 ++ abort ();
1.1417 ++
1.1418 ++ libfunc = sdiv_optab->handlers[(int) SImode].libfunc;
1.1419 ++
1.1420 ++
1.1421 ++
1.1422 ++ lab1 = gen_label_rtx ();
1.1423 ++ lab3 = gen_label_rtx ();
1.1424 ++
1.1425 ++ or_result = expand_simple_binop (SImode, IOR,
1.1426 ++ operands[1], operands[2],
1.1427 ++ 0, 0, OPTAB_LIB_WIDEN);
1.1428 ++
1.1429 ++ emit_cmp_and_jump_insns (or_result, GEN_INT (15), GTU, 0,
1.1430 ++ GET_MODE (or_result), 0, lab3);
1.1431 ++ JUMP_LABEL (get_last_insn ()) = lab3;
1.1432 ++
1.1433 ++ shift_left_result = expand_simple_binop (SImode, ASHIFT,
1.1434 ++ operands[1], GEN_INT (4),
1.1435 ++ 0, 0, OPTAB_LIB_WIDEN);
1.1436 ++
1.1437 ++ lookup_value = expand_simple_binop (SImode, IOR,
1.1438 ++ shift_left_result, operands[2],
1.1439 ++ 0, 0, OPTAB_LIB_WIDEN);
1.1440 ++
1.1441 ++ convert_move (operands[0],
1.1442 ++ gen_rtx (MEM, QImode,
1.1443 ++ gen_rtx (PLUS, SImode,
1.1444 ++ lookup_value,
1.1445 ++ gen_rtx_SYMBOL_REF (SImode, "__divsi3_table"))),
1.1446 ++ 1);
1.1447 ++
1.1448 ++
1.1449 ++ tmp = emit_jump_insn (gen_jump (lab1));
1.1450 ++ JUMP_LABEL (tmp) = lab1;
1.1451 ++ emit_barrier ();
1.1452 ++
1.1453 ++ emit_label (lab3);
1.1454 ++ LABEL_NUSES (lab3) = 1;
1.1455 ++
1.1456 ++ start_sequence ();
1.1457 ++ final_result = emit_library_call_value (libfunc, NULL_RTX,
1.1458 ++ LCT_CONST, SImode, 2,
1.1459 ++ operands[1], SImode,
1.1460 ++ operands[2], SImode);
1.1461 ++
1.1462 ++
1.1463 ++ insns = get_insns ();
1.1464 ++ end_sequence ();
1.1465 ++ emit_libcall_block (insns, operands[0], final_result,
1.1466 ++ gen_rtx (DIV, SImode, operands[1], operands[2]));
1.1467 ++
1.1468 ++ emit_label (lab1);
1.1469 ++ LABEL_NUSES (lab1) = 1;
1.1470 ++ return 1;
1.1471 ++}
1.1472 ++
1.1473 ++/* Branches/Compares */
1.1474 ++
1.1475 ++/* the way of handling branches/compares
1.1476 ++ in gcc is heavily borrowed from MIPS */
1.1477 ++
1.1478 ++enum internal_test
1.1479 ++{
1.1480 ++ ITEST_EQ,
1.1481 ++ ITEST_NE,
1.1482 ++ ITEST_GT,
1.1483 ++ ITEST_GE,
1.1484 ++ ITEST_LT,
1.1485 ++ ITEST_LE,
1.1486 ++ ITEST_GTU,
1.1487 ++ ITEST_GEU,
1.1488 ++ ITEST_LTU,
1.1489 ++ ITEST_LEU,
1.1490 ++ ITEST_MAX
1.1491 ++};
1.1492 ++
1.1493 ++static enum internal_test map_test_to_internal_test (enum rtx_code);
1.1494 ++
1.1495 ++/* Cached operands, and operator to compare for use in set/branch/trap
1.1496 ++ on condition codes. */
1.1497 ++rtx branch_cmp[2];
1.1498 ++enum cmp_type branch_type;
1.1499 ++
1.1500 ++/* Make normal rtx_code into something we can index from an array */
1.1501 ++
1.1502 ++static enum internal_test
1.1503 ++map_test_to_internal_test (enum rtx_code test_code)
1.1504 ++{
1.1505 ++ enum internal_test test = ITEST_MAX;
1.1506 ++
1.1507 ++ switch (test_code)
1.1508 ++ {
1.1509 ++ case EQ:
1.1510 ++ test = ITEST_EQ;
1.1511 ++ break;
1.1512 ++ case NE:
1.1513 ++ test = ITEST_NE;
1.1514 ++ break;
1.1515 ++ case GT:
1.1516 ++ test = ITEST_GT;
1.1517 ++ break;
1.1518 ++ case GE:
1.1519 ++ test = ITEST_GE;
1.1520 ++ break;
1.1521 ++ case LT:
1.1522 ++ test = ITEST_LT;
1.1523 ++ break;
1.1524 ++ case LE:
1.1525 ++ test = ITEST_LE;
1.1526 ++ break;
1.1527 ++ case GTU:
1.1528 ++ test = ITEST_GTU;
1.1529 ++ break;
1.1530 ++ case GEU:
1.1531 ++ test = ITEST_GEU;
1.1532 ++ break;
1.1533 ++ case LTU:
1.1534 ++ test = ITEST_LTU;
1.1535 ++ break;
1.1536 ++ case LEU:
1.1537 ++ test = ITEST_LEU;
1.1538 ++ break;
1.1539 ++ default:
1.1540 ++ break;
1.1541 ++ }
1.1542 ++
1.1543 ++ return test;
1.1544 ++}
1.1545 ++
1.1546 ++/* Generate the code to compare (and possibly branch) two integer values
1.1547 ++ TEST_CODE is the comparison code we are trying to emulate
1.1548 ++ (or implement directly)
1.1549 ++ RESULT is where to store the result of the comparison,
1.1550 ++ or null to emit a branch
1.1551 ++ CMP0 CMP1 are the two comparison operands
1.1552 ++ DESTINATION is the destination of the branch, or null to only compare
1.1553 ++ */
1.1554 ++
1.1555 ++void
1.1556 ++gen_int_relational (enum rtx_code test_code, /* relational test (EQ, etc) */
1.1557 ++ rtx result, /* result to store comp. or 0 if branch */
1.1558 ++ rtx cmp0, /* first operand to compare */
1.1559 ++ rtx cmp1, /* second operand to compare */
1.1560 ++ rtx destination) /* destination of the branch, or 0 if compare */
1.1561 ++{
1.1562 ++ struct cmp_info
1.1563 ++ {
1.1564 ++ /* for register (or 0) compares */
1.1565 ++ enum rtx_code test_code_reg; /* code to use in instruction (LT vs. LTU) */
1.1566 ++ int reverse_regs; /* reverse registers in test */
1.1567 ++
1.1568 ++ /* for immediate compares */
1.1569 ++ enum rtx_code test_code_const;
1.1570 ++ /* code to use in instruction (LT vs. LTU) */
1.1571 ++ int const_low; /* low bound of constant we can accept */
1.1572 ++ int const_high; /* high bound of constant we can accept */
1.1573 ++ int const_add; /* constant to add */
1.1574 ++
1.1575 ++ /* generic info */
1.1576 ++ int unsignedp; /* != 0 for unsigned comparisons. */
1.1577 ++ };
1.1578 ++
1.1579 ++ static const struct cmp_info info[(int) ITEST_MAX] = {
1.1580 ++
1.1581 ++ {EQ, 0, EQ, -32768, 32767, 0, 0}, /* EQ */
1.1582 ++ {NE, 0, NE, -32768, 32767, 0, 0}, /* NE */
1.1583 ++
1.1584 ++ {LT, 1, GE, -32769, 32766, 1, 0}, /* GT */
1.1585 ++ {GE, 0, GE, -32768, 32767, 0, 0}, /* GE */
1.1586 ++ {LT, 0, LT, -32768, 32767, 0, 0}, /* LT */
1.1587 ++ {GE, 1, LT, -32769, 32766, 1, 0}, /* LE */
1.1588 ++
1.1589 ++ {LTU, 1, GEU, 0, 65534, 1, 0}, /* GTU */
1.1590 ++ {GEU, 0, GEU, 0, 65535, 0, 0}, /* GEU */
1.1591 ++ {LTU, 0, LTU, 0, 65535, 0, 0}, /* LTU */
1.1592 ++ {GEU, 1, LTU, 0, 65534, 1, 0}, /* LEU */
1.1593 ++ };
1.1594 ++
1.1595 ++ enum internal_test test;
1.1596 ++ enum machine_mode mode;
1.1597 ++ const struct cmp_info *p_info;
1.1598 ++ int branch_p;
1.1599 ++
1.1600 ++
1.1601 ++
1.1602 ++
1.1603 ++ test = map_test_to_internal_test (test_code);
1.1604 ++ if (test == ITEST_MAX)
1.1605 ++ abort ();
1.1606 ++
1.1607 ++ p_info = &info[(int) test];
1.1608 ++
1.1609 ++ mode = GET_MODE (cmp0);
1.1610 ++ if (mode == VOIDmode)
1.1611 ++ mode = GET_MODE (cmp1);
1.1612 ++
1.1613 ++ branch_p = (destination != 0);
1.1614 ++
1.1615 ++ /* We can't, under any circumstances, have const_ints in cmp0
1.1616 ++ ??? Actually we could have const0 */
1.1617 ++ if (GET_CODE (cmp0) == CONST_INT)
1.1618 ++ cmp0 = force_reg (mode, cmp0);
1.1619 ++
1.1620 ++ /* if the comparison is against an int not in legal range
1.1621 ++ move it into a register */
1.1622 ++ if (GET_CODE (cmp1) == CONST_INT)
1.1623 ++ {
1.1624 ++ HOST_WIDE_INT value = INTVAL (cmp1);
1.1625 ++
1.1626 ++ if (value < p_info->const_low || value > p_info->const_high)
1.1627 ++ cmp1 = force_reg (mode, cmp1);
1.1628 ++ }
1.1629 ++
1.1630 ++ /* Comparison to constants, may involve adding 1 to change a GT into GE.
1.1631 ++ Comparison between two registers, may involve switching operands. */
1.1632 ++ if (GET_CODE (cmp1) == CONST_INT)
1.1633 ++ {
1.1634 ++ if (p_info->const_add != 0)
1.1635 ++ {
1.1636 ++ HOST_WIDE_INT new = INTVAL (cmp1) + p_info->const_add;
1.1637 ++
1.1638 ++ /* If modification of cmp1 caused overflow,
1.1639 ++ we would get the wrong answer if we follow the usual path;
1.1640 ++ thus, x > 0xffffffffU would turn into x > 0U. */
1.1641 ++ if ((p_info->unsignedp
1.1642 ++ ? (unsigned HOST_WIDE_INT) new >
1.1643 ++ (unsigned HOST_WIDE_INT) INTVAL (cmp1)
1.1644 ++ : new > INTVAL (cmp1)) != (p_info->const_add > 0))
1.1645 ++ {
1.1646 ++ /* ??? This case can never happen with the current numbers,
1.1647 ++ but I am paranoid and would rather an abort than
1.1648 ++ a bug I will never find */
1.1649 ++ abort ();
1.1650 ++ }
1.1651 ++ else
1.1652 ++ cmp1 = GEN_INT (new);
1.1653 ++ }
1.1654 ++ }
1.1655 ++
1.1656 ++ else if (p_info->reverse_regs)
1.1657 ++ {
1.1658 ++ rtx temp = cmp0;
1.1659 ++ cmp0 = cmp1;
1.1660 ++ cmp1 = temp;
1.1661 ++ }
1.1662 ++
1.1663 ++
1.1664 ++
1.1665 ++ if (branch_p)
1.1666 ++ {
1.1667 ++ if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
1.1668 ++ {
1.1669 ++ rtx insn;
1.1670 ++ rtx cond = gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1);
1.1671 ++ rtx label = gen_rtx_LABEL_REF (VOIDmode, destination);
1.1672 ++
1.1673 ++ insn = gen_rtx_SET (VOIDmode, pc_rtx,
1.1674 ++ gen_rtx_IF_THEN_ELSE (VOIDmode,
1.1675 ++ cond, label, pc_rtx));
1.1676 ++ emit_jump_insn (insn);
1.1677 ++ }
1.1678 ++ else
1.1679 ++ {
1.1680 ++ rtx cond, label;
1.1681 ++
1.1682 ++ result = gen_reg_rtx (mode);
1.1683 ++
1.1684 ++ emit_move_insn (result,
1.1685 ++ gen_rtx (p_info->test_code_const, mode, cmp0,
1.1686 ++ cmp1));
1.1687 ++
1.1688 ++ cond = gen_rtx (NE, mode, result, const0_rtx);
1.1689 ++ label = gen_rtx_LABEL_REF (VOIDmode, destination);
1.1690 ++
1.1691 ++ emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
1.1692 ++ gen_rtx_IF_THEN_ELSE (VOIDmode,
1.1693 ++ cond,
1.1694 ++ label, pc_rtx)));
1.1695 ++ }
1.1696 ++ }
1.1697 ++ else
1.1698 ++ {
1.1699 ++ if (register_operand (cmp0, mode) && register_operand (cmp1, mode))
1.1700 ++ {
1.1701 ++ emit_move_insn (result,
1.1702 ++ gen_rtx (p_info->test_code_reg, mode, cmp0, cmp1));
1.1703 ++ }
1.1704 ++ else
1.1705 ++ {
1.1706 ++ emit_move_insn (result,
1.1707 ++ gen_rtx (p_info->test_code_const, mode, cmp0,
1.1708 ++ cmp1));
1.1709 ++ }
1.1710 ++ }
1.1711 ++
1.1712 ++}
1.1713 ++
1.1714 ++
1.1715 ++/* ??? For now conditional moves are only supported
1.1716 ++ when the mode of the operands being compared are
1.1717 ++ the same as the ones being moved */
1.1718 ++
1.1719 ++void
1.1720 ++gen_conditional_move (rtx *operands, enum machine_mode mode)
1.1721 ++{
1.1722 ++ rtx insn, cond;
1.1723 ++ rtx cmp_reg = gen_reg_rtx (mode);
1.1724 ++ enum rtx_code cmp_code = GET_CODE (operands[1]);
1.1725 ++ enum rtx_code move_code = EQ;
1.1726 ++
1.1727 ++ /* emit a comparison if it is not "simple".
1.1728 ++ Simple comparisons are X eq 0 and X ne 0 */
1.1729 ++ if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[1] == const0_rtx)
1.1730 ++ {
1.1731 ++ cmp_reg = branch_cmp[0];
1.1732 ++ move_code = cmp_code;
1.1733 ++ }
1.1734 ++ else if ((cmp_code == EQ || cmp_code == NE) && branch_cmp[0] == const0_rtx)
1.1735 ++ {
1.1736 ++ cmp_reg = branch_cmp[1];
1.1737 ++ move_code = cmp_code == EQ ? NE : EQ;
1.1738 ++ }
1.1739 ++ else
1.1740 ++ gen_int_relational (cmp_code, cmp_reg, branch_cmp[0], branch_cmp[1],
1.1741 ++ NULL_RTX);
1.1742 ++
1.1743 ++ cond = gen_rtx (move_code, VOIDmode, cmp_reg, CONST0_RTX (mode));
1.1744 ++ insn = gen_rtx_SET (mode, operands[0],
1.1745 ++ gen_rtx_IF_THEN_ELSE (mode,
1.1746 ++ cond, operands[2], operands[3]));
1.1747 ++ emit_insn (insn);
1.1748 ++}
1.1749 ++
1.1750 ++/*******************
1.1751 ++ * Addressing Modes
1.1752 ++ *******************/
1.1753 ++
1.1754 ++int
1.1755 ++nios2_legitimate_address (rtx operand, enum machine_mode mode ATTRIBUTE_UNUSED,
1.1756 ++ int strict)
1.1757 ++{
1.1758 ++ int ret_val = 0;
1.1759 ++
1.1760 ++ switch (GET_CODE (operand))
1.1761 ++ {
1.1762 ++ /* direct. */
1.1763 ++ case SYMBOL_REF:
1.1764 ++ if (SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (operand))
1.1765 ++ {
1.1766 ++ ret_val = 1;
1.1767 ++ break;
1.1768 ++ }
1.1769 ++ /* else, fall through */
1.1770 ++ case LABEL_REF:
1.1771 ++ case CONST_INT:
1.1772 ++ case CONST:
1.1773 ++ case CONST_DOUBLE:
1.1774 ++ /* ??? In here I need to add gp addressing */
1.1775 ++ ret_val = 0;
1.1776 ++
1.1777 ++ break;
1.1778 ++
1.1779 ++ /* Register indirect. */
1.1780 ++ case REG:
1.1781 ++ ret_val = REG_OK_FOR_BASE_P2 (operand, strict);
1.1782 ++ break;
1.1783 ++
1.1784 ++ /* Register indirect with displacement */
1.1785 ++ case PLUS:
1.1786 ++ {
1.1787 ++ rtx op0 = XEXP (operand, 0);
1.1788 ++ rtx op1 = XEXP (operand, 1);
1.1789 ++
1.1790 ++ if (REG_P (op0) && REG_P (op1))
1.1791 ++ ret_val = 0;
1.1792 ++ else if (REG_P (op0) && CONSTANT_P (op1))
1.1793 ++ ret_val = REG_OK_FOR_BASE_P2 (op0, strict)
1.1794 ++ && SMALL_INT (INTVAL (op1));
1.1795 ++ else if (REG_P (op1) && CONSTANT_P (op0))
1.1796 ++ ret_val = REG_OK_FOR_BASE_P2 (op1, strict)
1.1797 ++ && SMALL_INT (INTVAL (op0));
1.1798 ++ else
1.1799 ++ ret_val = 0;
1.1800 ++ }
1.1801 ++ break;
1.1802 ++
1.1803 ++ default:
1.1804 ++ ret_val = 0;
1.1805 ++ break;
1.1806 ++ }
1.1807 ++
1.1808 ++ return ret_val;
1.1809 ++}
1.1810 ++
1.1811 ++/* Return true if EXP should be placed in the small data section. */
1.1812 ++
1.1813 ++static bool
1.1814 ++nios2_in_small_data_p (tree exp)
1.1815 ++{
1.1816 ++ /* We want to merge strings, so we never consider them small data. */
1.1817 ++ if (TREE_CODE (exp) == STRING_CST)
1.1818 ++ return false;
1.1819 ++
1.1820 ++ if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
1.1821 ++ {
1.1822 ++ const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
1.1823 ++ /* ??? these string names need moving into
1.1824 ++ an array in some header file */
1.1825 ++ if (nios2_section_threshold > 0
1.1826 ++ && (strcmp (section, ".sbss") == 0
1.1827 ++ || strncmp (section, ".sbss.", 6) == 0
1.1828 ++ || strcmp (section, ".sdata") == 0
1.1829 ++ || strncmp (section, ".sdata.", 7) == 0))
1.1830 ++ return true;
1.1831 ++ }
1.1832 ++ else if (TREE_CODE (exp) == VAR_DECL)
1.1833 ++ {
1.1834 ++ HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
1.1835 ++
1.1836 ++ /* If this is an incomplete type with size 0, then we can't put it
1.1837 ++ in sdata because it might be too big when completed. */
1.1838 ++ if (size > 0 && size <= nios2_section_threshold)
1.1839 ++ return true;
1.1840 ++ }
1.1841 ++
1.1842 ++ return false;
1.1843 ++}
1.1844 ++
1.1845 ++static void
1.1846 ++nios2_encode_section_info (tree decl, rtx rtl, int first)
1.1847 ++{
1.1848 ++
1.1849 ++ rtx symbol;
1.1850 ++ int flags;
1.1851 ++
1.1852 ++ default_encode_section_info (decl, rtl, first);
1.1853 ++
1.1854 ++ /* Careful not to prod global register variables. */
1.1855 ++ if (GET_CODE (rtl) != MEM)
1.1856 ++ return;
1.1857 ++ symbol = XEXP (rtl, 0);
1.1858 ++ if (GET_CODE (symbol) != SYMBOL_REF)
1.1859 ++ return;
1.1860 ++
1.1861 ++ flags = SYMBOL_REF_FLAGS (symbol);
1.1862 ++
1.1863 ++ /* We don't want weak variables to be addressed with gp in case they end up with
1.1864 ++ value 0 which is not within 2^15 of $gp */
1.1865 ++ if (DECL_P (decl) && DECL_WEAK (decl))
1.1866 ++ flags |= SYMBOL_FLAG_WEAK_DECL;
1.1867 ++
1.1868 ++ SYMBOL_REF_FLAGS (symbol) = flags;
1.1869 ++}
1.1870 ++
1.1871 ++
1.1872 ++static unsigned int
1.1873 ++nios2_section_type_flags (tree decl, const char *name, int reloc)
1.1874 ++{
1.1875 ++ unsigned int flags;
1.1876 ++
1.1877 ++ flags = default_section_type_flags (decl, name, reloc);
1.1878 ++
1.1879 ++ /* ??? these string names need moving into an array in some header file */
1.1880 ++ if (strcmp (name, ".sbss") == 0
1.1881 ++ || strncmp (name, ".sbss.", 6) == 0
1.1882 ++ || strcmp (name, ".sdata") == 0
1.1883 ++ || strncmp (name, ".sdata.", 7) == 0)
1.1884 ++ flags |= SECTION_SMALL;
1.1885 ++
1.1886 ++ return flags;
1.1887 ++}
1.1888 ++
1.1889 ++
1.1890 ++
1.1891 ++
1.1892 ++/*****************************************
1.1893 ++ * Defining the Output Assembler Language
1.1894 ++ *****************************************/
1.1895 ++
1.1896 ++/* -------------- *
1.1897 ++ * Output of Data
1.1898 ++ * -------------- */
1.1899 ++
1.1900 ++
1.1901 ++/* -------------------------------- *
1.1902 ++ * Output of Assembler Instructions
1.1903 ++ * -------------------------------- */
1.1904 ++
1.1905 ++
1.1906 ++/* print the operand OP to file stream
1.1907 ++ FILE modified by LETTER. LETTER
1.1908 ++ can be one of:
1.1909 ++ i: print "i" if OP is an immediate, except 0
1.1910 ++ o: print "io" if OP is volatile
1.1911 ++
1.1912 ++ z: for const0_rtx print $0 instead of 0
1.1913 ++ H: for %hiadj
1.1914 ++ L: for %lo
1.1915 ++ U: for upper half of 32 bit value
1.1916 ++ */
1.1917 ++
1.1918 ++void
1.1919 ++nios2_print_operand (FILE *file, rtx op, int letter)
1.1920 ++{
1.1921 ++
1.1922 ++ switch (letter)
1.1923 ++ {
1.1924 ++ case 'i':
1.1925 ++ if (CONSTANT_P (op) && (op != const0_rtx))
1.1926 ++ fprintf (file, "i");
1.1927 ++ return;
1.1928 ++
1.1929 ++ case 'o':
1.1930 ++ if (GET_CODE (op) == MEM
1.1931 ++ && ((MEM_VOLATILE_P (op) && !TARGET_CACHE_VOLATILE)
1.1932 ++ || TARGET_BYPASS_CACHE))
1.1933 ++ fprintf (file, "io");
1.1934 ++ return;
1.1935 ++
1.1936 ++ default:
1.1937 ++ break;
1.1938 ++ }
1.1939 ++
1.1940 ++ if (comparison_operator (op, VOIDmode))
1.1941 ++ {
1.1942 ++ if (letter == 0)
1.1943 ++ {
1.1944 ++ fprintf (file, "%s", GET_RTX_NAME (GET_CODE (op)));
1.1945 ++ return;
1.1946 ++ }
1.1947 ++ }
1.1948 ++
1.1949 ++
1.1950 ++ switch (GET_CODE (op))
1.1951 ++ {
1.1952 ++ case REG:
1.1953 ++ if (letter == 0 || letter == 'z')
1.1954 ++ {
1.1955 ++ fprintf (file, "%s", reg_names[REGNO (op)]);
1.1956 ++ return;
1.1957 ++ }
1.1958 ++
1.1959 ++ case CONST_INT:
1.1960 ++ if (INTVAL (op) == 0 && letter == 'z')
1.1961 ++ {
1.1962 ++ fprintf (file, "zero");
1.1963 ++ return;
1.1964 ++ }
1.1965 ++ else if (letter == 'U')
1.1966 ++ {
1.1967 ++ HOST_WIDE_INT val = INTVAL (op);
1.1968 ++ rtx new_op;
1.1969 ++ val = (val / 65536) & 0xFFFF;
1.1970 ++ new_op = GEN_INT (val);
1.1971 ++ output_addr_const (file, new_op);
1.1972 ++ return;
1.1973 ++ }
1.1974 ++
1.1975 ++ /* else, fall through */
1.1976 ++ case CONST:
1.1977 ++ case LABEL_REF:
1.1978 ++ case SYMBOL_REF:
1.1979 ++ case CONST_DOUBLE:
1.1980 ++ if (letter == 0 || letter == 'z')
1.1981 ++ {
1.1982 ++ output_addr_const (file, op);
1.1983 ++ return;
1.1984 ++ }
1.1985 ++ else if (letter == 'H')
1.1986 ++ {
1.1987 ++ fprintf (file, "%%hiadj(");
1.1988 ++ output_addr_const (file, op);
1.1989 ++ fprintf (file, ")");
1.1990 ++ return;
1.1991 ++ }
1.1992 ++ else if (letter == 'L')
1.1993 ++ {
1.1994 ++ fprintf (file, "%%lo(");
1.1995 ++ output_addr_const (file, op);
1.1996 ++ fprintf (file, ")");
1.1997 ++ return;
1.1998 ++ }
1.1999 ++
1.2000 ++
1.2001 ++ case SUBREG:
1.2002 ++ case MEM:
1.2003 ++ if (letter == 0)
1.2004 ++ {
1.2005 ++ output_address (op);
1.2006 ++ return;
1.2007 ++ }
1.2008 ++
1.2009 ++ case CODE_LABEL:
1.2010 ++ if (letter == 0)
1.2011 ++ {
1.2012 ++ output_addr_const (file, op);
1.2013 ++ return;
1.2014 ++ }
1.2015 ++
1.2016 ++ default:
1.2017 ++ break;
1.2018 ++ }
1.2019 ++
1.2020 ++ fprintf (stderr, "Missing way to print (%c) ", letter);
1.2021 ++ debug_rtx (op);
1.2022 ++ abort ();
1.2023 ++}
1.2024 ++
1.2025 ++static int gprel_constant (rtx);
1.2026 ++
1.2027 ++static int
1.2028 ++gprel_constant (rtx op)
1.2029 ++{
1.2030 ++ if (GET_CODE (op) == SYMBOL_REF
1.2031 ++ && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (op))
1.2032 ++ {
1.2033 ++ return 1;
1.2034 ++ }
1.2035 ++ else if (GET_CODE (op) == CONST
1.2036 ++ && GET_CODE (XEXP (op, 0)) == PLUS)
1.2037 ++ {
1.2038 ++ return gprel_constant (XEXP (XEXP (op, 0), 0));
1.2039 ++ }
1.2040 ++ else
1.2041 ++ {
1.2042 ++ return 0;
1.2043 ++ }
1.2044 ++}
1.2045 ++
1.2046 ++void
1.2047 ++nios2_print_operand_address (FILE *file, rtx op)
1.2048 ++{
1.2049 ++ switch (GET_CODE (op))
1.2050 ++ {
1.2051 ++ case CONST:
1.2052 ++ case CONST_INT:
1.2053 ++ case LABEL_REF:
1.2054 ++ case CONST_DOUBLE:
1.2055 ++ case SYMBOL_REF:
1.2056 ++ if (gprel_constant (op))
1.2057 ++ {
1.2058 ++ fprintf (file, "%%gprel(");
1.2059 ++ output_addr_const (file, op);
1.2060 ++ fprintf (file, ")(%s)", reg_names[GP_REGNO]);
1.2061 ++ return;
1.2062 ++ }
1.2063 ++
1.2064 ++ break;
1.2065 ++
1.2066 ++ case PLUS:
1.2067 ++ {
1.2068 ++ rtx op0 = XEXP (op, 0);
1.2069 ++ rtx op1 = XEXP (op, 1);
1.2070 ++
1.2071 ++ if (REG_P (op0) && CONSTANT_P (op1))
1.2072 ++ {
1.2073 ++ output_addr_const (file, op1);
1.2074 ++ fprintf (file, "(%s)", reg_names[REGNO (op0)]);
1.2075 ++ return;
1.2076 ++ }
1.2077 ++ else if (REG_P (op1) && CONSTANT_P (op0))
1.2078 ++ {
1.2079 ++ output_addr_const (file, op0);
1.2080 ++ fprintf (file, "(%s)", reg_names[REGNO (op1)]);
1.2081 ++ return;
1.2082 ++ }
1.2083 ++ }
1.2084 ++ break;
1.2085 ++
1.2086 ++ case REG:
1.2087 ++ fprintf (file, "0(%s)", reg_names[REGNO (op)]);
1.2088 ++ return;
1.2089 ++
1.2090 ++ case MEM:
1.2091 ++ {
1.2092 ++ rtx base = XEXP (op, 0);
1.2093 ++ PRINT_OPERAND_ADDRESS (file, base);
1.2094 ++ return;
1.2095 ++ }
1.2096 ++ default:
1.2097 ++ break;
1.2098 ++ }
1.2099 ++
1.2100 ++ fprintf (stderr, "Missing way to print address\n");
1.2101 ++ debug_rtx (op);
1.2102 ++ abort ();
1.2103 ++}
1.2104 ++
1.2105 ++
1.2106 ++
1.2107 ++
1.2108 ++
1.2109 ++/****************************
1.2110 ++ * Predicates
1.2111 ++ ****************************/
1.2112 ++
1.2113 ++int
1.2114 ++arith_operand (rtx op, enum machine_mode mode)
1.2115 ++{
1.2116 ++ if (GET_CODE (op) == CONST_INT && SMALL_INT (INTVAL (op)))
1.2117 ++ return 1;
1.2118 ++
1.2119 ++ return register_operand (op, mode);
1.2120 ++}
1.2121 ++
1.2122 ++int
1.2123 ++uns_arith_operand (rtx op, enum machine_mode mode)
1.2124 ++{
1.2125 ++ if (GET_CODE (op) == CONST_INT && SMALL_INT_UNSIGNED (INTVAL (op)))
1.2126 ++ return 1;
1.2127 ++
1.2128 ++ return register_operand (op, mode);
1.2129 ++}
1.2130 ++
1.2131 ++int
1.2132 ++logical_operand (rtx op, enum machine_mode mode)
1.2133 ++{
1.2134 ++ if (GET_CODE (op) == CONST_INT
1.2135 ++ && (SMALL_INT_UNSIGNED (INTVAL (op)) || UPPER16_INT (INTVAL (op))))
1.2136 ++ return 1;
1.2137 ++
1.2138 ++ return register_operand (op, mode);
1.2139 ++}
1.2140 ++
1.2141 ++int
1.2142 ++shift_operand (rtx op, enum machine_mode mode)
1.2143 ++{
1.2144 ++ if (GET_CODE (op) == CONST_INT && SHIFT_INT (INTVAL (op)))
1.2145 ++ return 1;
1.2146 ++
1.2147 ++ return register_operand (op, mode);
1.2148 ++}
1.2149 ++
1.2150 ++int
1.2151 ++rdwrctl_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
1.2152 ++{
1.2153 ++ return GET_CODE (op) == CONST_INT && RDWRCTL_INT (INTVAL (op));
1.2154 ++}
1.2155 ++
1.2156 ++/* Return truth value of whether OP is a register or the constant 0. */
1.2157 ++
1.2158 ++int
1.2159 ++reg_or_0_operand (rtx op, enum machine_mode mode)
1.2160 ++{
1.2161 ++ switch (GET_CODE (op))
1.2162 ++ {
1.2163 ++ case CONST_INT:
1.2164 ++ return INTVAL (op) == 0;
1.2165 ++
1.2166 ++ case CONST_DOUBLE:
1.2167 ++ return op == CONST0_RTX (mode);
1.2168 ++
1.2169 ++ default:
1.2170 ++ break;
1.2171 ++ }
1.2172 ++
1.2173 ++ return register_operand (op, mode);
1.2174 ++}
1.2175 ++
1.2176 ++
1.2177 ++int
1.2178 ++equality_op (rtx op, enum machine_mode mode)
1.2179 ++{
1.2180 ++ if (mode != GET_MODE (op))
1.2181 ++ return 0;
1.2182 ++
1.2183 ++ return GET_CODE (op) == EQ || GET_CODE (op) == NE;
1.2184 ++}
1.2185 ++
1.2186 ++int
1.2187 ++custom_insn_opcode (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
1.2188 ++{
1.2189 ++ return GET_CODE (op) == CONST_INT && CUSTOM_INSN_OPCODE (INTVAL (op));
1.2190 ++}
1.2191 ++
1.2192 ++
1.2193 ++
1.2194 ++
1.2195 ++
1.2196 ++
1.2197 ++
1.2198 ++/*****************************************************************************
1.2199 ++**
1.2200 ++** instruction scheduler
1.2201 ++**
1.2202 ++*****************************************************************************/
1.2203 ++static int
1.2204 ++nios2_use_dfa_pipeline_interface ()
1.2205 ++{
1.2206 ++ return 1;
1.2207 ++}
1.2208 ++
1.2209 ++
1.2210 ++static int
1.2211 ++nios2_issue_rate ()
1.2212 ++{
1.2213 ++#ifdef MAX_DFA_ISSUE_RATE
1.2214 ++ return MAX_DFA_ISSUE_RATE;
1.2215 ++#else
1.2216 ++ return 1;
1.2217 ++#endif
1.2218 ++}
1.2219 ++
1.2220 ++
1.2221 ++const char *
1.2222 ++asm_output_opcode (FILE *file ATTRIBUTE_UNUSED,
1.2223 ++ const char *ptr ATTRIBUTE_UNUSED)
1.2224 ++{
1.2225 ++ const char *p;
1.2226 ++
1.2227 ++ p = ptr;
1.2228 ++ return ptr;
1.2229 ++}
1.2230 ++
1.2231 ++
1.2232 ++
1.2233 ++/*****************************************************************************
1.2234 ++**
1.2235 ++** function arguments
1.2236 ++**
1.2237 ++*****************************************************************************/
1.2238 ++
1.2239 ++void
1.2240 ++init_cumulative_args (CUMULATIVE_ARGS *cum,
1.2241 ++ tree fntype ATTRIBUTE_UNUSED,
1.2242 ++ rtx libname ATTRIBUTE_UNUSED,
1.2243 ++ tree fndecl ATTRIBUTE_UNUSED,
1.2244 ++ int n_named_args ATTRIBUTE_UNUSED)
1.2245 ++{
1.2246 ++ cum->regs_used = 0;
1.2247 ++}
1.2248 ++
1.2249 ++
1.2250 ++/* Update the data in CUM to advance over an argument
1.2251 ++ of mode MODE and data type TYPE.
1.2252 ++ (TYPE is null for libcalls where that information may not be available.) */
1.2253 ++
1.2254 ++void
1.2255 ++function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
1.2256 ++ tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
1.2257 ++{
1.2258 ++ HOST_WIDE_INT param_size;
1.2259 ++
1.2260 ++ if (mode == BLKmode)
1.2261 ++ {
1.2262 ++ param_size = int_size_in_bytes (type);
1.2263 ++ if (param_size < 0)
1.2264 ++ internal_error
1.2265 ++ ("Do not know how to handle large structs or variable length types");
1.2266 ++ }
1.2267 ++ else
1.2268 ++ {
1.2269 ++ param_size = GET_MODE_SIZE (mode);
1.2270 ++ }
1.2271 ++
1.2272 ++ /* convert to words (round up) */
1.2273 ++ param_size = (3 + param_size) / 4;
1.2274 ++
1.2275 ++ if (cum->regs_used + param_size > NUM_ARG_REGS)
1.2276 ++ {
1.2277 ++ cum->regs_used = NUM_ARG_REGS;
1.2278 ++ }
1.2279 ++ else
1.2280 ++ {
1.2281 ++ cum->regs_used += param_size;
1.2282 ++ }
1.2283 ++
1.2284 ++ return;
1.2285 ++}
1.2286 ++
1.2287 ++/* Define where to put the arguments to a function. Value is zero to
1.2288 ++ push the argument on the stack, or a hard register in which to
1.2289 ++ store the argument.
1.2290 ++
1.2291 ++ MODE is the argument's machine mode.
1.2292 ++ TYPE is the data type of the argument (as a tree).
1.2293 ++ This is null for libcalls where that information may
1.2294 ++ not be available.
1.2295 ++ CUM is a variable of type CUMULATIVE_ARGS which gives info about
1.2296 ++ the preceding args and about the function being called.
1.2297 ++ NAMED is nonzero if this argument is a named parameter
1.2298 ++ (otherwise it is an extra parameter matching an ellipsis). */
1.2299 ++rtx
1.2300 ++function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
1.2301 ++ tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED)
1.2302 ++{
1.2303 ++ rtx return_rtx = NULL_RTX;
1.2304 ++
1.2305 ++ if (cum->regs_used < NUM_ARG_REGS)
1.2306 ++ {
1.2307 ++ return_rtx = gen_rtx_REG (mode, FIRST_ARG_REGNO + cum->regs_used);
1.2308 ++ }
1.2309 ++
1.2310 ++ return return_rtx;
1.2311 ++}
1.2312 ++
1.2313 ++int
1.2314 ++function_arg_partial_nregs (const CUMULATIVE_ARGS *cum,
1.2315 ++ enum machine_mode mode, tree type,
1.2316 ++ int named ATTRIBUTE_UNUSED)
1.2317 ++{
1.2318 ++ HOST_WIDE_INT param_size;
1.2319 ++
1.2320 ++ if (mode == BLKmode)
1.2321 ++ {
1.2322 ++ param_size = int_size_in_bytes (type);
1.2323 ++ if (param_size < 0)
1.2324 ++ internal_error
1.2325 ++ ("Do not know how to handle large structs or variable length types");
1.2326 ++ }
1.2327 ++ else
1.2328 ++ {
1.2329 ++ param_size = GET_MODE_SIZE (mode);
1.2330 ++ }
1.2331 ++
1.2332 ++ /* convert to words (round up) */
1.2333 ++ param_size = (3 + param_size) / 4;
1.2334 ++
1.2335 ++ if (cum->regs_used < NUM_ARG_REGS
1.2336 ++ && cum->regs_used + param_size > NUM_ARG_REGS)
1.2337 ++ {
1.2338 ++ return NUM_ARG_REGS - cum->regs_used;
1.2339 ++ }
1.2340 ++ else
1.2341 ++ {
1.2342 ++ return 0;
1.2343 ++ }
1.2344 ++}
1.2345 ++
1.2346 ++
1.2347 ++int
1.2348 ++nios2_return_in_memory (tree type)
1.2349 ++{
1.2350 ++ int res = ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
1.2351 ++ || (int_size_in_bytes (type) == -1));
1.2352 ++
1.2353 ++ return res;
1.2354 ++}
1.2355 ++
1.2356 ++/* ??? It may be possible to eliminate the copyback and implement
1.2357 ++ my own va_arg type, but that is more work for now. */
1.2358 ++int
1.2359 ++nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *cum,
1.2360 ++ enum machine_mode mode, tree type,
1.2361 ++ int no_rtl)
1.2362 ++{
1.2363 ++ CUMULATIVE_ARGS local_cum;
1.2364 ++ int regs_to_push;
1.2365 ++
1.2366 ++ local_cum = *cum;
1.2367 ++ FUNCTION_ARG_ADVANCE (local_cum, mode, type, 1);
1.2368 ++
1.2369 ++ regs_to_push = NUM_ARG_REGS - local_cum.regs_used;
1.2370 ++
1.2371 ++ if (!no_rtl)
1.2372 ++ {
1.2373 ++ if (regs_to_push > 0)
1.2374 ++ {
1.2375 ++ rtx ptr, mem;
1.2376 ++
1.2377 ++ ptr = virtual_incoming_args_rtx;
1.2378 ++ mem = gen_rtx_MEM (BLKmode, ptr);
1.2379 ++
1.2380 ++ /* va_arg is an array access in this case, which causes
1.2381 ++ it to get MEM_IN_STRUCT_P set. We must set it here
1.2382 ++ so that the insn scheduler won't assume that these
1.2383 ++ stores can't possibly overlap with the va_arg loads. */
1.2384 ++ MEM_SET_IN_STRUCT_P (mem, 1);
1.2385 ++
1.2386 ++ emit_insn (gen_blockage ());
1.2387 ++ move_block_from_reg (local_cum.regs_used + FIRST_ARG_REGNO, mem,
1.2388 ++ regs_to_push);
1.2389 ++ emit_insn (gen_blockage ());
1.2390 ++ }
1.2391 ++ }
1.2392 ++
1.2393 ++ return regs_to_push * UNITS_PER_WORD;
1.2394 ++
1.2395 ++}
1.2396 ++
1.2397 ++
1.2398 ++
1.2399 ++/*****************************************************************************
1.2400 ++**
1.2401 ++** builtins
1.2402 ++**
1.2403 ++** This method for handling builtins is from CSP where _many_ more types of
1.2404 ++** expanders have already been written. Check there first before writing
1.2405 ++** new ones.
1.2406 ++**
1.2407 ++*****************************************************************************/
1.2408 ++
1.2409 ++enum nios2_builtins
1.2410 ++{
1.2411 ++ NIOS2_BUILTIN_LDBIO,
1.2412 ++ NIOS2_BUILTIN_LDBUIO,
1.2413 ++ NIOS2_BUILTIN_LDHIO,
1.2414 ++ NIOS2_BUILTIN_LDHUIO,
1.2415 ++ NIOS2_BUILTIN_LDWIO,
1.2416 ++ NIOS2_BUILTIN_STBIO,
1.2417 ++ NIOS2_BUILTIN_STHIO,
1.2418 ++ NIOS2_BUILTIN_STWIO,
1.2419 ++ NIOS2_BUILTIN_SYNC,
1.2420 ++ NIOS2_BUILTIN_RDCTL,
1.2421 ++ NIOS2_BUILTIN_WRCTL,
1.2422 ++
1.2423 ++ NIOS2_BUILTIN_CUSTOM_N,
1.2424 ++ NIOS2_BUILTIN_CUSTOM_NI,
1.2425 ++ NIOS2_BUILTIN_CUSTOM_NF,
1.2426 ++ NIOS2_BUILTIN_CUSTOM_NP,
1.2427 ++ NIOS2_BUILTIN_CUSTOM_NII,
1.2428 ++ NIOS2_BUILTIN_CUSTOM_NIF,
1.2429 ++ NIOS2_BUILTIN_CUSTOM_NIP,
1.2430 ++ NIOS2_BUILTIN_CUSTOM_NFI,
1.2431 ++ NIOS2_BUILTIN_CUSTOM_NFF,
1.2432 ++ NIOS2_BUILTIN_CUSTOM_NFP,
1.2433 ++ NIOS2_BUILTIN_CUSTOM_NPI,
1.2434 ++ NIOS2_BUILTIN_CUSTOM_NPF,
1.2435 ++ NIOS2_BUILTIN_CUSTOM_NPP,
1.2436 ++ NIOS2_BUILTIN_CUSTOM_IN,
1.2437 ++ NIOS2_BUILTIN_CUSTOM_INI,
1.2438 ++ NIOS2_BUILTIN_CUSTOM_INF,
1.2439 ++ NIOS2_BUILTIN_CUSTOM_INP,
1.2440 ++ NIOS2_BUILTIN_CUSTOM_INII,
1.2441 ++ NIOS2_BUILTIN_CUSTOM_INIF,
1.2442 ++ NIOS2_BUILTIN_CUSTOM_INIP,
1.2443 ++ NIOS2_BUILTIN_CUSTOM_INFI,
1.2444 ++ NIOS2_BUILTIN_CUSTOM_INFF,
1.2445 ++ NIOS2_BUILTIN_CUSTOM_INFP,
1.2446 ++ NIOS2_BUILTIN_CUSTOM_INPI,
1.2447 ++ NIOS2_BUILTIN_CUSTOM_INPF,
1.2448 ++ NIOS2_BUILTIN_CUSTOM_INPP,
1.2449 ++ NIOS2_BUILTIN_CUSTOM_FN,
1.2450 ++ NIOS2_BUILTIN_CUSTOM_FNI,
1.2451 ++ NIOS2_BUILTIN_CUSTOM_FNF,
1.2452 ++ NIOS2_BUILTIN_CUSTOM_FNP,
1.2453 ++ NIOS2_BUILTIN_CUSTOM_FNII,
1.2454 ++ NIOS2_BUILTIN_CUSTOM_FNIF,
1.2455 ++ NIOS2_BUILTIN_CUSTOM_FNIP,
1.2456 ++ NIOS2_BUILTIN_CUSTOM_FNFI,
1.2457 ++ NIOS2_BUILTIN_CUSTOM_FNFF,
1.2458 ++ NIOS2_BUILTIN_CUSTOM_FNFP,
1.2459 ++ NIOS2_BUILTIN_CUSTOM_FNPI,
1.2460 ++ NIOS2_BUILTIN_CUSTOM_FNPF,
1.2461 ++ NIOS2_BUILTIN_CUSTOM_FNPP,
1.2462 ++ NIOS2_BUILTIN_CUSTOM_PN,
1.2463 ++ NIOS2_BUILTIN_CUSTOM_PNI,
1.2464 ++ NIOS2_BUILTIN_CUSTOM_PNF,
1.2465 ++ NIOS2_BUILTIN_CUSTOM_PNP,
1.2466 ++ NIOS2_BUILTIN_CUSTOM_PNII,
1.2467 ++ NIOS2_BUILTIN_CUSTOM_PNIF,
1.2468 ++ NIOS2_BUILTIN_CUSTOM_PNIP,
1.2469 ++ NIOS2_BUILTIN_CUSTOM_PNFI,
1.2470 ++ NIOS2_BUILTIN_CUSTOM_PNFF,
1.2471 ++ NIOS2_BUILTIN_CUSTOM_PNFP,
1.2472 ++ NIOS2_BUILTIN_CUSTOM_PNPI,
1.2473 ++ NIOS2_BUILTIN_CUSTOM_PNPF,
1.2474 ++ NIOS2_BUILTIN_CUSTOM_PNPP,
1.2475 ++
1.2476 ++
1.2477 ++ LIM_NIOS2_BUILTINS
1.2478 ++};
1.2479 ++
1.2480 ++struct builtin_description
1.2481 ++{
1.2482 ++ const enum insn_code icode;
1.2483 ++ const char *const name;
1.2484 ++ const enum nios2_builtins code;
1.2485 ++ const tree *type;
1.2486 ++ rtx (* expander) PARAMS ((const struct builtin_description *,
1.2487 ++ tree, rtx, rtx, enum machine_mode, int));
1.2488 ++};
1.2489 ++
1.2490 ++static rtx nios2_expand_STXIO (const struct builtin_description *,
1.2491 ++ tree, rtx, rtx, enum machine_mode, int);
1.2492 ++static rtx nios2_expand_LDXIO (const struct builtin_description *,
1.2493 ++ tree, rtx, rtx, enum machine_mode, int);
1.2494 ++static rtx nios2_expand_sync (const struct builtin_description *,
1.2495 ++ tree, rtx, rtx, enum machine_mode, int);
1.2496 ++static rtx nios2_expand_rdctl (const struct builtin_description *,
1.2497 ++ tree, rtx, rtx, enum machine_mode, int);
1.2498 ++static rtx nios2_expand_wrctl (const struct builtin_description *,
1.2499 ++ tree, rtx, rtx, enum machine_mode, int);
1.2500 ++
1.2501 ++static rtx nios2_expand_custom_n (const struct builtin_description *,
1.2502 ++ tree, rtx, rtx, enum machine_mode, int);
1.2503 ++static rtx nios2_expand_custom_Xn (const struct builtin_description *,
1.2504 ++ tree, rtx, rtx, enum machine_mode, int);
1.2505 ++static rtx nios2_expand_custom_nX (const struct builtin_description *,
1.2506 ++ tree, rtx, rtx, enum machine_mode, int);
1.2507 ++static rtx nios2_expand_custom_XnX (const struct builtin_description *,
1.2508 ++ tree, rtx, rtx, enum machine_mode, int);
1.2509 ++static rtx nios2_expand_custom_nXX (const struct builtin_description *,
1.2510 ++ tree, rtx, rtx, enum machine_mode, int);
1.2511 ++static rtx nios2_expand_custom_XnXX (const struct builtin_description *,
1.2512 ++ tree, rtx, rtx, enum machine_mode, int);
1.2513 ++
1.2514 ++static tree endlink;
1.2515 ++
1.2516 ++/* int fn (volatile const void *)
1.2517 ++ */
1.2518 ++static tree int_ftype_volatile_const_void_p;
1.2519 ++
1.2520 ++/* int fn (int)
1.2521 ++ */
1.2522 ++static tree int_ftype_int;
1.2523 ++
1.2524 ++/* void fn (int, int)
1.2525 ++ */
1.2526 ++static tree void_ftype_int_int;
1.2527 ++
1.2528 ++/* void fn (volatile void *, int)
1.2529 ++ */
1.2530 ++static tree void_ftype_volatile_void_p_int;
1.2531 ++
1.2532 ++/* void fn (void)
1.2533 ++ */
1.2534 ++static tree void_ftype_void;
1.2535 ++
1.2536 ++static tree custom_n;
1.2537 ++static tree custom_ni;
1.2538 ++static tree custom_nf;
1.2539 ++static tree custom_np;
1.2540 ++static tree custom_nii;
1.2541 ++static tree custom_nif;
1.2542 ++static tree custom_nip;
1.2543 ++static tree custom_nfi;
1.2544 ++static tree custom_nff;
1.2545 ++static tree custom_nfp;
1.2546 ++static tree custom_npi;
1.2547 ++static tree custom_npf;
1.2548 ++static tree custom_npp;
1.2549 ++static tree custom_in;
1.2550 ++static tree custom_ini;
1.2551 ++static tree custom_inf;
1.2552 ++static tree custom_inp;
1.2553 ++static tree custom_inii;
1.2554 ++static tree custom_inif;
1.2555 ++static tree custom_inip;
1.2556 ++static tree custom_infi;
1.2557 ++static tree custom_inff;
1.2558 ++static tree custom_infp;
1.2559 ++static tree custom_inpi;
1.2560 ++static tree custom_inpf;
1.2561 ++static tree custom_inpp;
1.2562 ++static tree custom_fn;
1.2563 ++static tree custom_fni;
1.2564 ++static tree custom_fnf;
1.2565 ++static tree custom_fnp;
1.2566 ++static tree custom_fnii;
1.2567 ++static tree custom_fnif;
1.2568 ++static tree custom_fnip;
1.2569 ++static tree custom_fnfi;
1.2570 ++static tree custom_fnff;
1.2571 ++static tree custom_fnfp;
1.2572 ++static tree custom_fnpi;
1.2573 ++static tree custom_fnpf;
1.2574 ++static tree custom_fnpp;
1.2575 ++static tree custom_pn;
1.2576 ++static tree custom_pni;
1.2577 ++static tree custom_pnf;
1.2578 ++static tree custom_pnp;
1.2579 ++static tree custom_pnii;
1.2580 ++static tree custom_pnif;
1.2581 ++static tree custom_pnip;
1.2582 ++static tree custom_pnfi;
1.2583 ++static tree custom_pnff;
1.2584 ++static tree custom_pnfp;
1.2585 ++static tree custom_pnpi;
1.2586 ++static tree custom_pnpf;
1.2587 ++static tree custom_pnpp;
1.2588 ++
1.2589 ++
1.2590 ++static const struct builtin_description bdesc[] = {
1.2591 ++ {CODE_FOR_ldbio, "__builtin_ldbio", NIOS2_BUILTIN_LDBIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
1.2592 ++ {CODE_FOR_ldbuio, "__builtin_ldbuio", NIOS2_BUILTIN_LDBUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
1.2593 ++ {CODE_FOR_ldhio, "__builtin_ldhio", NIOS2_BUILTIN_LDHIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
1.2594 ++ {CODE_FOR_ldhuio, "__builtin_ldhuio", NIOS2_BUILTIN_LDHUIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
1.2595 ++ {CODE_FOR_ldwio, "__builtin_ldwio", NIOS2_BUILTIN_LDWIO, &int_ftype_volatile_const_void_p, nios2_expand_LDXIO},
1.2596 ++
1.2597 ++ {CODE_FOR_stbio, "__builtin_stbio", NIOS2_BUILTIN_STBIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
1.2598 ++ {CODE_FOR_sthio, "__builtin_sthio", NIOS2_BUILTIN_STHIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
1.2599 ++ {CODE_FOR_stwio, "__builtin_stwio", NIOS2_BUILTIN_STWIO, &void_ftype_volatile_void_p_int, nios2_expand_STXIO},
1.2600 ++
1.2601 ++ {CODE_FOR_sync, "__builtin_sync", NIOS2_BUILTIN_SYNC, &void_ftype_void, nios2_expand_sync},
1.2602 ++ {CODE_FOR_rdctl, "__builtin_rdctl", NIOS2_BUILTIN_RDCTL, &int_ftype_int, nios2_expand_rdctl},
1.2603 ++ {CODE_FOR_wrctl, "__builtin_wrctl", NIOS2_BUILTIN_WRCTL, &void_ftype_int_int, nios2_expand_wrctl},
1.2604 ++
1.2605 ++ {CODE_FOR_custom_n, "__builtin_custom_n", NIOS2_BUILTIN_CUSTOM_N, &custom_n, nios2_expand_custom_n},
1.2606 ++ {CODE_FOR_custom_ni, "__builtin_custom_ni", NIOS2_BUILTIN_CUSTOM_NI, &custom_ni, nios2_expand_custom_nX},
1.2607 ++ {CODE_FOR_custom_nf, "__builtin_custom_nf", NIOS2_BUILTIN_CUSTOM_NF, &custom_nf, nios2_expand_custom_nX},
1.2608 ++ {CODE_FOR_custom_np, "__builtin_custom_np", NIOS2_BUILTIN_CUSTOM_NP, &custom_np, nios2_expand_custom_nX},
1.2609 ++ {CODE_FOR_custom_nii, "__builtin_custom_nii", NIOS2_BUILTIN_CUSTOM_NII, &custom_nii, nios2_expand_custom_nXX},
1.2610 ++ {CODE_FOR_custom_nif, "__builtin_custom_nif", NIOS2_BUILTIN_CUSTOM_NIF, &custom_nif, nios2_expand_custom_nXX},
1.2611 ++ {CODE_FOR_custom_nip, "__builtin_custom_nip", NIOS2_BUILTIN_CUSTOM_NIP, &custom_nip, nios2_expand_custom_nXX},
1.2612 ++ {CODE_FOR_custom_nfi, "__builtin_custom_nfi", NIOS2_BUILTIN_CUSTOM_NFI, &custom_nfi, nios2_expand_custom_nXX},
1.2613 ++ {CODE_FOR_custom_nff, "__builtin_custom_nff", NIOS2_BUILTIN_CUSTOM_NFF, &custom_nff, nios2_expand_custom_nXX},
1.2614 ++ {CODE_FOR_custom_nfp, "__builtin_custom_nfp", NIOS2_BUILTIN_CUSTOM_NFP, &custom_nfp, nios2_expand_custom_nXX},
1.2615 ++ {CODE_FOR_custom_npi, "__builtin_custom_npi", NIOS2_BUILTIN_CUSTOM_NPI, &custom_npi, nios2_expand_custom_nXX},
1.2616 ++ {CODE_FOR_custom_npf, "__builtin_custom_npf", NIOS2_BUILTIN_CUSTOM_NPF, &custom_npf, nios2_expand_custom_nXX},
1.2617 ++ {CODE_FOR_custom_npp, "__builtin_custom_npp", NIOS2_BUILTIN_CUSTOM_NPP, &custom_npp, nios2_expand_custom_nXX},
1.2618 ++ {CODE_FOR_custom_in, "__builtin_custom_in", NIOS2_BUILTIN_CUSTOM_IN, &custom_in, nios2_expand_custom_Xn},
1.2619 ++ {CODE_FOR_custom_ini, "__builtin_custom_ini", NIOS2_BUILTIN_CUSTOM_INI, &custom_ini, nios2_expand_custom_XnX},
1.2620 ++ {CODE_FOR_custom_inf, "__builtin_custom_inf", NIOS2_BUILTIN_CUSTOM_INF, &custom_inf, nios2_expand_custom_XnX},
1.2621 ++ {CODE_FOR_custom_inp, "__builtin_custom_inp", NIOS2_BUILTIN_CUSTOM_INP, &custom_inp, nios2_expand_custom_XnX},
1.2622 ++ {CODE_FOR_custom_inii, "__builtin_custom_inii", NIOS2_BUILTIN_CUSTOM_INII, &custom_inii, nios2_expand_custom_XnXX},
1.2623 ++ {CODE_FOR_custom_inif, "__builtin_custom_inif", NIOS2_BUILTIN_CUSTOM_INIF, &custom_inif, nios2_expand_custom_XnXX},
1.2624 ++ {CODE_FOR_custom_inip, "__builtin_custom_inip", NIOS2_BUILTIN_CUSTOM_INIP, &custom_inip, nios2_expand_custom_XnXX},
1.2625 ++ {CODE_FOR_custom_infi, "__builtin_custom_infi", NIOS2_BUILTIN_CUSTOM_INFI, &custom_infi, nios2_expand_custom_XnXX},
1.2626 ++ {CODE_FOR_custom_inff, "__builtin_custom_inff", NIOS2_BUILTIN_CUSTOM_INFF, &custom_inff, nios2_expand_custom_XnXX},
1.2627 ++ {CODE_FOR_custom_infp, "__builtin_custom_infp", NIOS2_BUILTIN_CUSTOM_INFP, &custom_infp, nios2_expand_custom_XnXX},
1.2628 ++ {CODE_FOR_custom_inpi, "__builtin_custom_inpi", NIOS2_BUILTIN_CUSTOM_INPI, &custom_inpi, nios2_expand_custom_XnXX},
1.2629 ++ {CODE_FOR_custom_inpf, "__builtin_custom_inpf", NIOS2_BUILTIN_CUSTOM_INPF, &custom_inpf, nios2_expand_custom_XnXX},
1.2630 ++ {CODE_FOR_custom_inpp, "__builtin_custom_inpp", NIOS2_BUILTIN_CUSTOM_INPP, &custom_inpp, nios2_expand_custom_XnXX},
1.2631 ++ {CODE_FOR_custom_fn, "__builtin_custom_fn", NIOS2_BUILTIN_CUSTOM_FN, &custom_fn, nios2_expand_custom_Xn},
1.2632 ++ {CODE_FOR_custom_fni, "__builtin_custom_fni", NIOS2_BUILTIN_CUSTOM_FNI, &custom_fni, nios2_expand_custom_XnX},
1.2633 ++ {CODE_FOR_custom_fnf, "__builtin_custom_fnf", NIOS2_BUILTIN_CUSTOM_FNF, &custom_fnf, nios2_expand_custom_XnX},
1.2634 ++ {CODE_FOR_custom_fnp, "__builtin_custom_fnp", NIOS2_BUILTIN_CUSTOM_FNP, &custom_fnp, nios2_expand_custom_XnX},
1.2635 ++ {CODE_FOR_custom_fnii, "__builtin_custom_fnii", NIOS2_BUILTIN_CUSTOM_FNII, &custom_fnii, nios2_expand_custom_XnXX},
1.2636 ++ {CODE_FOR_custom_fnif, "__builtin_custom_fnif", NIOS2_BUILTIN_CUSTOM_FNIF, &custom_fnif, nios2_expand_custom_XnXX},
1.2637 ++ {CODE_FOR_custom_fnip, "__builtin_custom_fnip", NIOS2_BUILTIN_CUSTOM_FNIP, &custom_fnip, nios2_expand_custom_XnXX},
1.2638 ++ {CODE_FOR_custom_fnfi, "__builtin_custom_fnfi", NIOS2_BUILTIN_CUSTOM_FNFI, &custom_fnfi, nios2_expand_custom_XnXX},
1.2639 ++ {CODE_FOR_custom_fnff, "__builtin_custom_fnff", NIOS2_BUILTIN_CUSTOM_FNFF, &custom_fnff, nios2_expand_custom_XnXX},
1.2640 ++ {CODE_FOR_custom_fnfp, "__builtin_custom_fnfp", NIOS2_BUILTIN_CUSTOM_FNFP, &custom_fnfp, nios2_expand_custom_XnXX},
1.2641 ++ {CODE_FOR_custom_fnpi, "__builtin_custom_fnpi", NIOS2_BUILTIN_CUSTOM_FNPI, &custom_fnpi, nios2_expand_custom_XnXX},
1.2642 ++ {CODE_FOR_custom_fnpf, "__builtin_custom_fnpf", NIOS2_BUILTIN_CUSTOM_FNPF, &custom_fnpf, nios2_expand_custom_XnXX},
1.2643 ++ {CODE_FOR_custom_fnpp, "__builtin_custom_fnpp", NIOS2_BUILTIN_CUSTOM_FNPP, &custom_fnpp, nios2_expand_custom_XnXX},
1.2644 ++ {CODE_FOR_custom_pn, "__builtin_custom_pn", NIOS2_BUILTIN_CUSTOM_PN, &custom_pn, nios2_expand_custom_Xn},
1.2645 ++ {CODE_FOR_custom_pni, "__builtin_custom_pni", NIOS2_BUILTIN_CUSTOM_PNI, &custom_pni, nios2_expand_custom_XnX},
1.2646 ++ {CODE_FOR_custom_pnf, "__builtin_custom_pnf", NIOS2_BUILTIN_CUSTOM_PNF, &custom_pnf, nios2_expand_custom_XnX},
1.2647 ++ {CODE_FOR_custom_pnp, "__builtin_custom_pnp", NIOS2_BUILTIN_CUSTOM_PNP, &custom_pnp, nios2_expand_custom_XnX},
1.2648 ++ {CODE_FOR_custom_pnii, "__builtin_custom_pnii", NIOS2_BUILTIN_CUSTOM_PNII, &custom_pnii, nios2_expand_custom_XnXX},
1.2649 ++ {CODE_FOR_custom_pnif, "__builtin_custom_pnif", NIOS2_BUILTIN_CUSTOM_PNIF, &custom_pnif, nios2_expand_custom_XnXX},
1.2650 ++ {CODE_FOR_custom_pnip, "__builtin_custom_pnip", NIOS2_BUILTIN_CUSTOM_PNIP, &custom_pnip, nios2_expand_custom_XnXX},
1.2651 ++ {CODE_FOR_custom_pnfi, "__builtin_custom_pnfi", NIOS2_BUILTIN_CUSTOM_PNFI, &custom_pnfi, nios2_expand_custom_XnXX},
1.2652 ++ {CODE_FOR_custom_pnff, "__builtin_custom_pnff", NIOS2_BUILTIN_CUSTOM_PNFF, &custom_pnff, nios2_expand_custom_XnXX},
1.2653 ++ {CODE_FOR_custom_pnfp, "__builtin_custom_pnfp", NIOS2_BUILTIN_CUSTOM_PNFP, &custom_pnfp, nios2_expand_custom_XnXX},
1.2654 ++ {CODE_FOR_custom_pnpi, "__builtin_custom_pnpi", NIOS2_BUILTIN_CUSTOM_PNPI, &custom_pnpi, nios2_expand_custom_XnXX},
1.2655 ++ {CODE_FOR_custom_pnpf, "__builtin_custom_pnpf", NIOS2_BUILTIN_CUSTOM_PNPF, &custom_pnpf, nios2_expand_custom_XnXX},
1.2656 ++ {CODE_FOR_custom_pnpp, "__builtin_custom_pnpp", NIOS2_BUILTIN_CUSTOM_PNPP, &custom_pnpp, nios2_expand_custom_XnXX},
1.2657 ++
1.2658 ++
1.2659 ++ {0, 0, 0, 0, 0},
1.2660 ++};
1.2661 ++
1.2662 ++/* This does not have a closing bracket on purpose (see use) */
1.2663 ++#define def_param(TYPE) \
1.2664 ++ tree_cons (NULL_TREE, TYPE,
1.2665 ++
1.2666 ++static void
1.2667 ++nios2_init_builtins ()
1.2668 ++{
1.2669 ++ const struct builtin_description *d;
1.2670 ++
1.2671 ++
1.2672 ++ endlink = void_list_node;
1.2673 ++
1.2674 ++ /* Special indenting here because one of the brackets is in def_param */
1.2675 ++ /* *INDENT-OFF* */
1.2676 ++
1.2677 ++ /* int fn (volatile const void *)
1.2678 ++ */
1.2679 ++ int_ftype_volatile_const_void_p
1.2680 ++ = build_function_type (integer_type_node,
1.2681 ++ def_param (build_qualified_type (ptr_type_node,
1.2682 ++ TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
1.2683 ++ endlink));
1.2684 ++
1.2685 ++
1.2686 ++ /* void fn (volatile void *, int)
1.2687 ++ */
1.2688 ++ void_ftype_volatile_void_p_int
1.2689 ++ = build_function_type (void_type_node,
1.2690 ++ def_param (build_qualified_type (ptr_type_node,
1.2691 ++ TYPE_QUAL_VOLATILE))
1.2692 ++ def_param (integer_type_node)
1.2693 ++ endlink)));
1.2694 ++
1.2695 ++ /* void fn (void)
1.2696 ++ */
1.2697 ++ void_ftype_void
1.2698 ++ = build_function_type (void_type_node,
1.2699 ++ endlink);
1.2700 ++
1.2701 ++ /* int fn (int)
1.2702 ++ */
1.2703 ++ int_ftype_int
1.2704 ++ = build_function_type (integer_type_node,
1.2705 ++ def_param (integer_type_node)
1.2706 ++ endlink));
1.2707 ++
1.2708 ++ /* void fn (int, int)
1.2709 ++ */
1.2710 ++ void_ftype_int_int
1.2711 ++ = build_function_type (void_type_node,
1.2712 ++ def_param (integer_type_node)
1.2713 ++ def_param (integer_type_node)
1.2714 ++ endlink)));
1.2715 ++
1.2716 ++
1.2717 ++#define CUSTOM_NUM def_param (integer_type_node)
1.2718 ++
1.2719 ++ custom_n
1.2720 ++ = build_function_type (void_type_node,
1.2721 ++ CUSTOM_NUM
1.2722 ++ endlink));
1.2723 ++ custom_ni
1.2724 ++ = build_function_type (void_type_node,
1.2725 ++ CUSTOM_NUM
1.2726 ++ def_param (integer_type_node)
1.2727 ++ endlink)));
1.2728 ++ custom_nf
1.2729 ++ = build_function_type (void_type_node,
1.2730 ++ CUSTOM_NUM
1.2731 ++ def_param (float_type_node)
1.2732 ++ endlink)));
1.2733 ++ custom_np
1.2734 ++ = build_function_type (void_type_node,
1.2735 ++ CUSTOM_NUM
1.2736 ++ def_param (ptr_type_node)
1.2737 ++ endlink)));
1.2738 ++ custom_nii
1.2739 ++ = build_function_type (void_type_node,
1.2740 ++ CUSTOM_NUM
1.2741 ++ def_param (integer_type_node)
1.2742 ++ def_param (integer_type_node)
1.2743 ++ endlink))));
1.2744 ++ custom_nif
1.2745 ++ = build_function_type (void_type_node,
1.2746 ++ CUSTOM_NUM
1.2747 ++ def_param (integer_type_node)
1.2748 ++ def_param (float_type_node)
1.2749 ++ endlink))));
1.2750 ++ custom_nip
1.2751 ++ = build_function_type (void_type_node,
1.2752 ++ CUSTOM_NUM
1.2753 ++ def_param (integer_type_node)
1.2754 ++ def_param (ptr_type_node)
1.2755 ++ endlink))));
1.2756 ++ custom_nfi
1.2757 ++ = build_function_type (void_type_node,
1.2758 ++ CUSTOM_NUM
1.2759 ++ def_param (float_type_node)
1.2760 ++ def_param (integer_type_node)
1.2761 ++ endlink))));
1.2762 ++ custom_nff
1.2763 ++ = build_function_type (void_type_node,
1.2764 ++ CUSTOM_NUM
1.2765 ++ def_param (float_type_node)
1.2766 ++ def_param (float_type_node)
1.2767 ++ endlink))));
1.2768 ++ custom_nfp
1.2769 ++ = build_function_type (void_type_node,
1.2770 ++ CUSTOM_NUM
1.2771 ++ def_param (float_type_node)
1.2772 ++ def_param (ptr_type_node)
1.2773 ++ endlink))));
1.2774 ++ custom_npi
1.2775 ++ = build_function_type (void_type_node,
1.2776 ++ CUSTOM_NUM
1.2777 ++ def_param (ptr_type_node)
1.2778 ++ def_param (integer_type_node)
1.2779 ++ endlink))));
1.2780 ++ custom_npf
1.2781 ++ = build_function_type (void_type_node,
1.2782 ++ CUSTOM_NUM
1.2783 ++ def_param (ptr_type_node)
1.2784 ++ def_param (float_type_node)
1.2785 ++ endlink))));
1.2786 ++ custom_npp
1.2787 ++ = build_function_type (void_type_node,
1.2788 ++ CUSTOM_NUM
1.2789 ++ def_param (ptr_type_node)
1.2790 ++ def_param (ptr_type_node)
1.2791 ++ endlink))));
1.2792 ++
1.2793 ++ custom_in
1.2794 ++ = build_function_type (integer_type_node,
1.2795 ++ CUSTOM_NUM
1.2796 ++ endlink));
1.2797 ++ custom_ini
1.2798 ++ = build_function_type (integer_type_node,
1.2799 ++ CUSTOM_NUM
1.2800 ++ def_param (integer_type_node)
1.2801 ++ endlink)));
1.2802 ++ custom_inf
1.2803 ++ = build_function_type (integer_type_node,
1.2804 ++ CUSTOM_NUM
1.2805 ++ def_param (float_type_node)
1.2806 ++ endlink)));
1.2807 ++ custom_inp
1.2808 ++ = build_function_type (integer_type_node,
1.2809 ++ CUSTOM_NUM
1.2810 ++ def_param (ptr_type_node)
1.2811 ++ endlink)));
1.2812 ++ custom_inii
1.2813 ++ = build_function_type (integer_type_node,
1.2814 ++ CUSTOM_NUM
1.2815 ++ def_param (integer_type_node)
1.2816 ++ def_param (integer_type_node)
1.2817 ++ endlink))));
1.2818 ++ custom_inif
1.2819 ++ = build_function_type (integer_type_node,
1.2820 ++ CUSTOM_NUM
1.2821 ++ def_param (integer_type_node)
1.2822 ++ def_param (float_type_node)
1.2823 ++ endlink))));
1.2824 ++ custom_inip
1.2825 ++ = build_function_type (integer_type_node,
1.2826 ++ CUSTOM_NUM
1.2827 ++ def_param (integer_type_node)
1.2828 ++ def_param (ptr_type_node)
1.2829 ++ endlink))));
1.2830 ++ custom_infi
1.2831 ++ = build_function_type (integer_type_node,
1.2832 ++ CUSTOM_NUM
1.2833 ++ def_param (float_type_node)
1.2834 ++ def_param (integer_type_node)
1.2835 ++ endlink))));
1.2836 ++ custom_inff
1.2837 ++ = build_function_type (integer_type_node,
1.2838 ++ CUSTOM_NUM
1.2839 ++ def_param (float_type_node)
1.2840 ++ def_param (float_type_node)
1.2841 ++ endlink))));
1.2842 ++ custom_infp
1.2843 ++ = build_function_type (integer_type_node,
1.2844 ++ CUSTOM_NUM
1.2845 ++ def_param (float_type_node)
1.2846 ++ def_param (ptr_type_node)
1.2847 ++ endlink))));
1.2848 ++ custom_inpi
1.2849 ++ = build_function_type (integer_type_node,
1.2850 ++ CUSTOM_NUM
1.2851 ++ def_param (ptr_type_node)
1.2852 ++ def_param (integer_type_node)
1.2853 ++ endlink))));
1.2854 ++ custom_inpf
1.2855 ++ = build_function_type (integer_type_node,
1.2856 ++ CUSTOM_NUM
1.2857 ++ def_param (ptr_type_node)
1.2858 ++ def_param (float_type_node)
1.2859 ++ endlink))));
1.2860 ++ custom_inpp
1.2861 ++ = build_function_type (integer_type_node,
1.2862 ++ CUSTOM_NUM
1.2863 ++ def_param (ptr_type_node)
1.2864 ++ def_param (ptr_type_node)
1.2865 ++ endlink))));
1.2866 ++
1.2867 ++ custom_fn
1.2868 ++ = build_function_type (float_type_node,
1.2869 ++ CUSTOM_NUM
1.2870 ++ endlink));
1.2871 ++ custom_fni
1.2872 ++ = build_function_type (float_type_node,
1.2873 ++ CUSTOM_NUM
1.2874 ++ def_param (integer_type_node)
1.2875 ++ endlink)));
1.2876 ++ custom_fnf
1.2877 ++ = build_function_type (float_type_node,
1.2878 ++ CUSTOM_NUM
1.2879 ++ def_param (float_type_node)
1.2880 ++ endlink)));
1.2881 ++ custom_fnp
1.2882 ++ = build_function_type (float_type_node,
1.2883 ++ CUSTOM_NUM
1.2884 ++ def_param (ptr_type_node)
1.2885 ++ endlink)));
1.2886 ++ custom_fnii
1.2887 ++ = build_function_type (float_type_node,
1.2888 ++ CUSTOM_NUM
1.2889 ++ def_param (integer_type_node)
1.2890 ++ def_param (integer_type_node)
1.2891 ++ endlink))));
1.2892 ++ custom_fnif
1.2893 ++ = build_function_type (float_type_node,
1.2894 ++ CUSTOM_NUM
1.2895 ++ def_param (integer_type_node)
1.2896 ++ def_param (float_type_node)
1.2897 ++ endlink))));
1.2898 ++ custom_fnip
1.2899 ++ = build_function_type (float_type_node,
1.2900 ++ CUSTOM_NUM
1.2901 ++ def_param (integer_type_node)
1.2902 ++ def_param (ptr_type_node)
1.2903 ++ endlink))));
1.2904 ++ custom_fnfi
1.2905 ++ = build_function_type (float_type_node,
1.2906 ++ CUSTOM_NUM
1.2907 ++ def_param (float_type_node)
1.2908 ++ def_param (integer_type_node)
1.2909 ++ endlink))));
1.2910 ++ custom_fnff
1.2911 ++ = build_function_type (float_type_node,
1.2912 ++ CUSTOM_NUM
1.2913 ++ def_param (float_type_node)
1.2914 ++ def_param (float_type_node)
1.2915 ++ endlink))));
1.2916 ++ custom_fnfp
1.2917 ++ = build_function_type (float_type_node,
1.2918 ++ CUSTOM_NUM
1.2919 ++ def_param (float_type_node)
1.2920 ++ def_param (ptr_type_node)
1.2921 ++ endlink))));
1.2922 ++ custom_fnpi
1.2923 ++ = build_function_type (float_type_node,
1.2924 ++ CUSTOM_NUM
1.2925 ++ def_param (ptr_type_node)
1.2926 ++ def_param (integer_type_node)
1.2927 ++ endlink))));
1.2928 ++ custom_fnpf
1.2929 ++ = build_function_type (float_type_node,
1.2930 ++ CUSTOM_NUM
1.2931 ++ def_param (ptr_type_node)
1.2932 ++ def_param (float_type_node)
1.2933 ++ endlink))));
1.2934 ++ custom_fnpp
1.2935 ++ = build_function_type (float_type_node,
1.2936 ++ CUSTOM_NUM
1.2937 ++ def_param (ptr_type_node)
1.2938 ++ def_param (ptr_type_node)
1.2939 ++ endlink))));
1.2940 ++
1.2941 ++
1.2942 ++ custom_pn
1.2943 ++ = build_function_type (ptr_type_node,
1.2944 ++ CUSTOM_NUM
1.2945 ++ endlink));
1.2946 ++ custom_pni
1.2947 ++ = build_function_type (ptr_type_node,
1.2948 ++ CUSTOM_NUM
1.2949 ++ def_param (integer_type_node)
1.2950 ++ endlink)));
1.2951 ++ custom_pnf
1.2952 ++ = build_function_type (ptr_type_node,
1.2953 ++ CUSTOM_NUM
1.2954 ++ def_param (float_type_node)
1.2955 ++ endlink)));
1.2956 ++ custom_pnp
1.2957 ++ = build_function_type (ptr_type_node,
1.2958 ++ CUSTOM_NUM
1.2959 ++ def_param (ptr_type_node)
1.2960 ++ endlink)));
1.2961 ++ custom_pnii
1.2962 ++ = build_function_type (ptr_type_node,
1.2963 ++ CUSTOM_NUM
1.2964 ++ def_param (integer_type_node)
1.2965 ++ def_param (integer_type_node)
1.2966 ++ endlink))));
1.2967 ++ custom_pnif
1.2968 ++ = build_function_type (ptr_type_node,
1.2969 ++ CUSTOM_NUM
1.2970 ++ def_param (integer_type_node)
1.2971 ++ def_param (float_type_node)
1.2972 ++ endlink))));
1.2973 ++ custom_pnip
1.2974 ++ = build_function_type (ptr_type_node,
1.2975 ++ CUSTOM_NUM
1.2976 ++ def_param (integer_type_node)
1.2977 ++ def_param (ptr_type_node)
1.2978 ++ endlink))));
1.2979 ++ custom_pnfi
1.2980 ++ = build_function_type (ptr_type_node,
1.2981 ++ CUSTOM_NUM
1.2982 ++ def_param (float_type_node)
1.2983 ++ def_param (integer_type_node)
1.2984 ++ endlink))));
1.2985 ++ custom_pnff
1.2986 ++ = build_function_type (ptr_type_node,
1.2987 ++ CUSTOM_NUM
1.2988 ++ def_param (float_type_node)
1.2989 ++ def_param (float_type_node)
1.2990 ++ endlink))));
1.2991 ++ custom_pnfp
1.2992 ++ = build_function_type (ptr_type_node,
1.2993 ++ CUSTOM_NUM
1.2994 ++ def_param (float_type_node)
1.2995 ++ def_param (ptr_type_node)
1.2996 ++ endlink))));
1.2997 ++ custom_pnpi
1.2998 ++ = build_function_type (ptr_type_node,
1.2999 ++ CUSTOM_NUM
1.3000 ++ def_param (ptr_type_node)
1.3001 ++ def_param (integer_type_node)
1.3002 ++ endlink))));
1.3003 ++ custom_pnpf
1.3004 ++ = build_function_type (ptr_type_node,
1.3005 ++ CUSTOM_NUM
1.3006 ++ def_param (ptr_type_node)
1.3007 ++ def_param (float_type_node)
1.3008 ++ endlink))));
1.3009 ++ custom_pnpp
1.3010 ++ = build_function_type (ptr_type_node,
1.3011 ++ CUSTOM_NUM
1.3012 ++ def_param (ptr_type_node)
1.3013 ++ def_param (ptr_type_node)
1.3014 ++ endlink))));
1.3015 ++
1.3016 ++
1.3017 ++
1.3018 ++ /* *INDENT-ON* */
1.3019 ++
1.3020 ++
1.3021 ++ for (d = bdesc; d->name; d++)
1.3022 ++ {
1.3023 ++ builtin_function (d->name, *d->type, d->code,
1.3024 ++ BUILT_IN_MD, NULL, NULL);
1.3025 ++ }
1.3026 ++}
1.3027 ++
1.3028 ++/* Expand an expression EXP that calls a built-in function,
1.3029 ++ with result going to TARGET if that's convenient
1.3030 ++ (and in mode MODE if that's convenient).
1.3031 ++ SUBTARGET may be used as the target for computing one of EXP's operands.
1.3032 ++ IGNORE is nonzero if the value is to be ignored. */
1.3033 ++
1.3034 ++static rtx
1.3035 ++nios2_expand_builtin (tree exp, rtx target, rtx subtarget,
1.3036 ++ enum machine_mode mode, int ignore)
1.3037 ++{
1.3038 ++ const struct builtin_description *d;
1.3039 ++ tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
1.3040 ++ unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
1.3041 ++
1.3042 ++ for (d = bdesc; d->name; d++)
1.3043 ++ if (d->code == fcode)
1.3044 ++ return (d->expander) (d, exp, target, subtarget, mode, ignore);
1.3045 ++
1.3046 ++ /* we should have seen one of the functins we registered */
1.3047 ++ abort ();
1.3048 ++}
1.3049 ++
1.3050 ++static rtx nios2_create_target (const struct builtin_description *, rtx);
1.3051 ++
1.3052 ++
1.3053 ++static rtx
1.3054 ++nios2_create_target (const struct builtin_description *d, rtx target)
1.3055 ++{
1.3056 ++ if (!target
1.3057 ++ || !(*insn_data[d->icode].operand[0].predicate) (target,
1.3058 ++ insn_data[d->icode].operand[0].mode))
1.3059 ++ {
1.3060 ++ target = gen_reg_rtx (insn_data[d->icode].operand[0].mode);
1.3061 ++ }
1.3062 ++
1.3063 ++ return target;
1.3064 ++}
1.3065 ++
1.3066 ++
1.3067 ++static rtx nios2_extract_opcode (const struct builtin_description *, int, tree);
1.3068 ++static rtx nios2_extract_operand (const struct builtin_description *, int, int, tree);
1.3069 ++
1.3070 ++static rtx
1.3071 ++nios2_extract_opcode (const struct builtin_description *d, int op, tree arglist)
1.3072 ++{
1.3073 ++ enum machine_mode mode = insn_data[d->icode].operand[op].mode;
1.3074 ++ tree arg = TREE_VALUE (arglist);
1.3075 ++ rtx opcode = expand_expr (arg, NULL_RTX, mode, 0);
1.3076 ++ opcode = protect_from_queue (opcode, 0);
1.3077 ++
1.3078 ++ if (!(*insn_data[d->icode].operand[op].predicate) (opcode, mode))
1.3079 ++ error ("Custom instruction opcode must be compile time constant in the range 0-255 for %s", d->name);
1.3080 ++
1.3081 ++ return opcode;
1.3082 ++}
1.3083 ++
1.3084 ++static rtx
1.3085 ++nios2_extract_operand (const struct builtin_description *d, int op, int argnum, tree arglist)
1.3086 ++{
1.3087 ++ enum machine_mode mode = insn_data[d->icode].operand[op].mode;
1.3088 ++ tree arg = TREE_VALUE (arglist);
1.3089 ++ rtx operand = expand_expr (arg, NULL_RTX, mode, 0);
1.3090 ++ operand = protect_from_queue (operand, 0);
1.3091 ++
1.3092 ++ if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
1.3093 ++ operand = copy_to_mode_reg (mode, operand);
1.3094 ++
1.3095 ++ /* ??? Better errors would be nice */
1.3096 ++ if (!(*insn_data[d->icode].operand[op].predicate) (operand, mode))
1.3097 ++ error ("Invalid argument %d to %s", argnum, d->name);
1.3098 ++
1.3099 ++ return operand;
1.3100 ++}
1.3101 ++
1.3102 ++
1.3103 ++static rtx
1.3104 ++nios2_expand_custom_n (const struct builtin_description *d, tree exp,
1.3105 ++ rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED,
1.3106 ++ enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
1.3107 ++{
1.3108 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3109 ++ rtx pat;
1.3110 ++ rtx opcode;
1.3111 ++
1.3112 ++ /* custom_n should have exactly one operand */
1.3113 ++ if (insn_data[d->icode].n_operands != 1)
1.3114 ++ abort ();
1.3115 ++
1.3116 ++ opcode = nios2_extract_opcode (d, 0, arglist);
1.3117 ++
1.3118 ++ pat = GEN_FCN (d->icode) (opcode);
1.3119 ++ if (!pat)
1.3120 ++ return 0;
1.3121 ++ emit_insn (pat);
1.3122 ++ return 0;
1.3123 ++}
1.3124 ++
1.3125 ++static rtx
1.3126 ++nios2_expand_custom_Xn (const struct builtin_description *d, tree exp,
1.3127 ++ rtx target, rtx subtarget ATTRIBUTE_UNUSED,
1.3128 ++ enum machine_mode mode ATTRIBUTE_UNUSED,
1.3129 ++ int ignore ATTRIBUTE_UNUSED)
1.3130 ++{
1.3131 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3132 ++ rtx pat;
1.3133 ++ rtx opcode;
1.3134 ++
1.3135 ++ /* custom_Xn should have exactly two operands */
1.3136 ++ if (insn_data[d->icode].n_operands != 2)
1.3137 ++ abort ();
1.3138 ++
1.3139 ++ target = nios2_create_target (d, target);
1.3140 ++ opcode = nios2_extract_opcode (d, 1, arglist);
1.3141 ++
1.3142 ++ pat = GEN_FCN (d->icode) (target, opcode);
1.3143 ++ if (!pat)
1.3144 ++ return 0;
1.3145 ++ emit_insn (pat);
1.3146 ++ return target;
1.3147 ++}
1.3148 ++
1.3149 ++static rtx
1.3150 ++nios2_expand_custom_nX (const struct builtin_description *d, tree exp,
1.3151 ++ rtx target ATTRIBUTE_UNUSED, rtx subtarget ATTRIBUTE_UNUSED,
1.3152 ++ enum machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED)
1.3153 ++{
1.3154 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3155 ++ rtx pat;
1.3156 ++ rtx opcode;
1.3157 ++ rtx operands[1];
1.3158 ++ int i;
1.3159 ++
1.3160 ++
1.3161 ++ /* custom_nX should have exactly two operands */
1.3162 ++ if (insn_data[d->icode].n_operands != 2)
1.3163 ++ abort ();
1.3164 ++
1.3165 ++ opcode = nios2_extract_opcode (d, 0, arglist);
1.3166 ++ for (i = 0; i < 1; i++)
1.3167 ++ {
1.3168 ++ arglist = TREE_CHAIN (arglist);
1.3169 ++ operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
1.3170 ++ }
1.3171 ++
1.3172 ++ pat = GEN_FCN (d->icode) (opcode, operands[0]);
1.3173 ++ if (!pat)
1.3174 ++ return 0;
1.3175 ++ emit_insn (pat);
1.3176 ++ return 0;
1.3177 ++}
1.3178 ++
1.3179 ++static rtx
1.3180 ++nios2_expand_custom_XnX (const struct builtin_description *d, tree exp, rtx target,
1.3181 ++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
1.3182 ++ int ignore ATTRIBUTE_UNUSED)
1.3183 ++{
1.3184 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3185 ++ rtx pat;
1.3186 ++ rtx opcode;
1.3187 ++ rtx operands[1];
1.3188 ++ int i;
1.3189 ++
1.3190 ++ /* custom_Xn should have exactly three operands */
1.3191 ++ if (insn_data[d->icode].n_operands != 3)
1.3192 ++ abort ();
1.3193 ++
1.3194 ++ target = nios2_create_target (d, target);
1.3195 ++ opcode = nios2_extract_opcode (d, 1, arglist);
1.3196 ++
1.3197 ++ for (i = 0; i < 1; i++)
1.3198 ++ {
1.3199 ++ arglist = TREE_CHAIN (arglist);
1.3200 ++ operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
1.3201 ++ }
1.3202 ++
1.3203 ++ pat = GEN_FCN (d->icode) (target, opcode, operands[0]);
1.3204 ++
1.3205 ++ if (!pat)
1.3206 ++ return 0;
1.3207 ++ emit_insn (pat);
1.3208 ++ return target;
1.3209 ++}
1.3210 ++
1.3211 ++static rtx
1.3212 ++nios2_expand_custom_nXX (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED,
1.3213 ++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
1.3214 ++ int ignore ATTRIBUTE_UNUSED)
1.3215 ++{
1.3216 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3217 ++ rtx pat;
1.3218 ++ rtx opcode;
1.3219 ++ rtx operands[2];
1.3220 ++ int i;
1.3221 ++
1.3222 ++
1.3223 ++ /* custom_nX should have exactly three operands */
1.3224 ++ if (insn_data[d->icode].n_operands != 3)
1.3225 ++ abort ();
1.3226 ++
1.3227 ++ opcode = nios2_extract_opcode (d, 0, arglist);
1.3228 ++ for (i = 0; i < 2; i++)
1.3229 ++ {
1.3230 ++ arglist = TREE_CHAIN (arglist);
1.3231 ++ operands[i] = nios2_extract_operand (d, i + 1, i + 1, arglist);
1.3232 ++ }
1.3233 ++
1.3234 ++ pat = GEN_FCN (d->icode) (opcode, operands[0], operands[1]);
1.3235 ++ if (!pat)
1.3236 ++ return 0;
1.3237 ++ emit_insn (pat);
1.3238 ++ return 0;
1.3239 ++}
1.3240 ++
1.3241 ++static rtx
1.3242 ++nios2_expand_custom_XnXX (const struct builtin_description *d, tree exp, rtx target,
1.3243 ++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
1.3244 ++ int ignore ATTRIBUTE_UNUSED)
1.3245 ++{
1.3246 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3247 ++ rtx pat;
1.3248 ++ rtx opcode;
1.3249 ++ rtx operands[2];
1.3250 ++ int i;
1.3251 ++
1.3252 ++
1.3253 ++ /* custom_XnX should have exactly four operands */
1.3254 ++ if (insn_data[d->icode].n_operands != 4)
1.3255 ++ abort ();
1.3256 ++
1.3257 ++ target = nios2_create_target (d, target);
1.3258 ++ opcode = nios2_extract_opcode (d, 1, arglist);
1.3259 ++ for (i = 0; i < 2; i++)
1.3260 ++ {
1.3261 ++ arglist = TREE_CHAIN (arglist);
1.3262 ++ operands[i] = nios2_extract_operand (d, i + 2, i + 1, arglist);
1.3263 ++ }
1.3264 ++
1.3265 ++ pat = GEN_FCN (d->icode) (target, opcode, operands[0], operands[1]);
1.3266 ++
1.3267 ++ if (!pat)
1.3268 ++ return 0;
1.3269 ++ emit_insn (pat);
1.3270 ++ return target;
1.3271 ++}
1.3272 ++
1.3273 ++
1.3274 ++
1.3275 ++static rtx
1.3276 ++nios2_expand_STXIO (const struct builtin_description *d, tree exp, rtx target ATTRIBUTE_UNUSED,
1.3277 ++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
1.3278 ++ int ignore ATTRIBUTE_UNUSED)
1.3279 ++{
1.3280 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3281 ++ rtx pat;
1.3282 ++ rtx store_dest, store_val;
1.3283 ++ enum insn_code icode = d->icode;
1.3284 ++
1.3285 ++ /* stores should have exactly two operands */
1.3286 ++ if (insn_data[icode].n_operands != 2)
1.3287 ++ abort ();
1.3288 ++
1.3289 ++ /* process the destination of the store */
1.3290 ++ {
1.3291 ++ enum machine_mode mode = insn_data[icode].operand[0].mode;
1.3292 ++ tree arg = TREE_VALUE (arglist);
1.3293 ++ store_dest = expand_expr (arg, NULL_RTX, VOIDmode, 0);
1.3294 ++ store_dest = protect_from_queue (store_dest, 0);
1.3295 ++
1.3296 ++ store_dest = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, store_dest));
1.3297 ++
1.3298 ++ /* ??? Better errors would be nice */
1.3299 ++ if (!(*insn_data[icode].operand[0].predicate) (store_dest, mode))
1.3300 ++ error ("Invalid argument 1 to %s", d->name);
1.3301 ++ }
1.3302 ++
1.3303 ++
1.3304 ++ /* process the value to store */
1.3305 ++ {
1.3306 ++ enum machine_mode mode = insn_data[icode].operand[1].mode;
1.3307 ++ tree arg = TREE_VALUE (TREE_CHAIN (arglist));
1.3308 ++ store_val = expand_expr (arg, NULL_RTX, mode, 0);
1.3309 ++ store_val = protect_from_queue (store_val, 0);
1.3310 ++
1.3311 ++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
1.3312 ++ store_val = copy_to_mode_reg (mode, store_val);
1.3313 ++
1.3314 ++ /* ??? Better errors would be nice */
1.3315 ++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
1.3316 ++ error ("Invalid argument 2 to %s", d->name);
1.3317 ++ }
1.3318 ++
1.3319 ++ pat = GEN_FCN (d->icode) (store_dest, store_val);
1.3320 ++ if (!pat)
1.3321 ++ return 0;
1.3322 ++ emit_insn (pat);
1.3323 ++ return 0;
1.3324 ++}
1.3325 ++
1.3326 ++
1.3327 ++static rtx
1.3328 ++nios2_expand_LDXIO (const struct builtin_description * d, tree exp, rtx target,
1.3329 ++ rtx subtarget ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED,
1.3330 ++ int ignore ATTRIBUTE_UNUSED)
1.3331 ++{
1.3332 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3333 ++ rtx pat;
1.3334 ++ rtx ld_src;
1.3335 ++ enum insn_code icode = d->icode;
1.3336 ++
1.3337 ++ /* loads should have exactly two operands */
1.3338 ++ if (insn_data[icode].n_operands != 2)
1.3339 ++ abort ();
1.3340 ++
1.3341 ++ target = nios2_create_target (d, target);
1.3342 ++
1.3343 ++ {
1.3344 ++ enum machine_mode mode = insn_data[icode].operand[1].mode;
1.3345 ++ tree arg = TREE_VALUE (arglist);
1.3346 ++ ld_src = expand_expr (arg, NULL_RTX, VOIDmode, 0);
1.3347 ++ ld_src = protect_from_queue (ld_src, 0);
1.3348 ++
1.3349 ++ ld_src = gen_rtx_MEM (mode, copy_to_mode_reg (Pmode, ld_src));
1.3350 ++
1.3351 ++ /* ??? Better errors would be nice */
1.3352 ++ if (!(*insn_data[icode].operand[1].predicate) (ld_src, mode))
1.3353 ++ {
1.3354 ++ error ("Invalid argument 1 to %s", d->name);
1.3355 ++ }
1.3356 ++ }
1.3357 ++
1.3358 ++ pat = GEN_FCN (d->icode) (target, ld_src);
1.3359 ++ if (!pat)
1.3360 ++ return 0;
1.3361 ++ emit_insn (pat);
1.3362 ++ return target;
1.3363 ++}
1.3364 ++
1.3365 ++
1.3366 ++static rtx
1.3367 ++nios2_expand_sync (const struct builtin_description * d ATTRIBUTE_UNUSED,
1.3368 ++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
1.3369 ++ rtx subtarget ATTRIBUTE_UNUSED,
1.3370 ++ enum machine_mode mode ATTRIBUTE_UNUSED,
1.3371 ++ int ignore ATTRIBUTE_UNUSED)
1.3372 ++{
1.3373 ++ emit_insn (gen_sync ());
1.3374 ++ return 0;
1.3375 ++}
1.3376 ++
1.3377 ++static rtx
1.3378 ++nios2_expand_rdctl (const struct builtin_description * d ATTRIBUTE_UNUSED,
1.3379 ++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
1.3380 ++ rtx subtarget ATTRIBUTE_UNUSED,
1.3381 ++ enum machine_mode mode ATTRIBUTE_UNUSED,
1.3382 ++ int ignore ATTRIBUTE_UNUSED)
1.3383 ++{
1.3384 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3385 ++ rtx pat;
1.3386 ++ rtx rdctl_reg;
1.3387 ++ enum insn_code icode = d->icode;
1.3388 ++
1.3389 ++ /* rdctl should have exactly two operands */
1.3390 ++ if (insn_data[icode].n_operands != 2)
1.3391 ++ abort ();
1.3392 ++
1.3393 ++ target = nios2_create_target (d, target);
1.3394 ++
1.3395 ++ {
1.3396 ++ enum machine_mode mode = insn_data[icode].operand[1].mode;
1.3397 ++ tree arg = TREE_VALUE (arglist);
1.3398 ++ rdctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
1.3399 ++ rdctl_reg = protect_from_queue (rdctl_reg, 0);
1.3400 ++
1.3401 ++ if (!(*insn_data[icode].operand[1].predicate) (rdctl_reg, mode))
1.3402 ++ {
1.3403 ++ error ("Control register number must be in range 0-31 for %s", d->name);
1.3404 ++ }
1.3405 ++ }
1.3406 ++
1.3407 ++ pat = GEN_FCN (d->icode) (target, rdctl_reg);
1.3408 ++ if (!pat)
1.3409 ++ return 0;
1.3410 ++ emit_insn (pat);
1.3411 ++ return target;
1.3412 ++}
1.3413 ++
1.3414 ++static rtx
1.3415 ++nios2_expand_wrctl (const struct builtin_description * d ATTRIBUTE_UNUSED,
1.3416 ++ tree exp ATTRIBUTE_UNUSED, rtx target ATTRIBUTE_UNUSED,
1.3417 ++ rtx subtarget ATTRIBUTE_UNUSED,
1.3418 ++ enum machine_mode mode ATTRIBUTE_UNUSED,
1.3419 ++ int ignore ATTRIBUTE_UNUSED)
1.3420 ++{
1.3421 ++ tree arglist = TREE_OPERAND (exp, 1);
1.3422 ++ rtx pat;
1.3423 ++ rtx wrctl_reg, store_val;
1.3424 ++ enum insn_code icode = d->icode;
1.3425 ++
1.3426 ++ /* stores should have exactly two operands */
1.3427 ++ if (insn_data[icode].n_operands != 2)
1.3428 ++ abort ();
1.3429 ++
1.3430 ++ /* process the destination of the store */
1.3431 ++ {
1.3432 ++ enum machine_mode mode = insn_data[icode].operand[0].mode;
1.3433 ++ tree arg = TREE_VALUE (arglist);
1.3434 ++ wrctl_reg = expand_expr (arg, NULL_RTX, VOIDmode, 0);
1.3435 ++ wrctl_reg = protect_from_queue (wrctl_reg, 0);
1.3436 ++
1.3437 ++ if (!(*insn_data[icode].operand[0].predicate) (wrctl_reg, mode))
1.3438 ++ error ("Control register number must be in range 0-31 for %s", d->name);
1.3439 ++ }
1.3440 ++
1.3441 ++
1.3442 ++ /* process the value to store */
1.3443 ++ {
1.3444 ++ enum machine_mode mode = insn_data[icode].operand[1].mode;
1.3445 ++ tree arg = TREE_VALUE (TREE_CHAIN (arglist));
1.3446 ++ store_val = expand_expr (arg, NULL_RTX, mode, 0);
1.3447 ++ store_val = protect_from_queue (store_val, 0);
1.3448 ++
1.3449 ++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
1.3450 ++ store_val = copy_to_mode_reg (mode, store_val);
1.3451 ++
1.3452 ++ /* ??? Better errors would be nice */
1.3453 ++ if (!(*insn_data[icode].operand[1].predicate) (store_val, mode))
1.3454 ++ error ("Invalid argument 2 to %s", d->name);
1.3455 ++ }
1.3456 ++
1.3457 ++ pat = GEN_FCN (d->icode) (wrctl_reg, store_val);
1.3458 ++ if (!pat)
1.3459 ++ return 0;
1.3460 ++ emit_insn (pat);
1.3461 ++ return 0;
1.3462 ++}
1.3463 ++
1.3464 ++
1.3465 ++#include "gt-nios2.h"
1.3466 ++
1.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
1.3468 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-dp-bit.c 1970-01-01 01:00:00.000000000 +0100
1.3469 ++++ gcc-3.4.6/gcc/config/nios2/nios2-dp-bit.c 2007-08-15 23:09:36.000000000 +0200
1.3470 +@@ -0,0 +1,1652 @@
1.3471 ++
1.3472 ++/* This is a software floating point library which can be used
1.3473 ++ for targets without hardware floating point.
1.3474 ++ Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
1.3475 ++ Free Software Foundation, Inc.
1.3476 ++
1.3477 ++This file is free software; you can redistribute it and/or modify it
1.3478 ++under the terms of the GNU General Public License as published by the
1.3479 ++Free Software Foundation; either version 2, or (at your option) any
1.3480 ++later version.
1.3481 ++
1.3482 ++In addition to the permissions in the GNU General Public License, the
1.3483 ++Free Software Foundation gives you unlimited permission to link the
1.3484 ++compiled version of this file with other programs, and to distribute
1.3485 ++those programs without any restriction coming from the use of this
1.3486 ++file. (The General Public License restrictions do apply in other
1.3487 ++respects; for example, they cover modification of the file, and
1.3488 ++distribution when not linked into another program.)
1.3489 ++
1.3490 ++This file is distributed in the hope that it will be useful, but
1.3491 ++WITHOUT ANY WARRANTY; without even the implied warranty of
1.3492 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.3493 ++General Public License for more details.
1.3494 ++
1.3495 ++You should have received a copy of the GNU General Public License
1.3496 ++along with this program; see the file COPYING. If not, write to
1.3497 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.3498 ++Boston, MA 02111-1307, USA. */
1.3499 ++
1.3500 ++/* As a special exception, if you link this library with other files,
1.3501 ++ some of which are compiled with GCC, to produce an executable,
1.3502 ++ this library does not by itself cause the resulting executable
1.3503 ++ to be covered by the GNU General Public License.
1.3504 ++ This exception does not however invalidate any other reasons why
1.3505 ++ the executable file might be covered by the GNU General Public License. */
1.3506 ++
1.3507 ++/* This implements IEEE 754 format arithmetic, but does not provide a
1.3508 ++ mechanism for setting the rounding mode, or for generating or handling
1.3509 ++ exceptions.
1.3510 ++
1.3511 ++ The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
1.3512 ++ Wilson, all of Cygnus Support. */
1.3513 ++
1.3514 ++/* The intended way to use this file is to make two copies, add `#define FLOAT'
1.3515 ++ to one copy, then compile both copies and add them to libgcc.a. */
1.3516 ++
1.3517 ++#include "tconfig.h"
1.3518 ++#include "coretypes.h"
1.3519 ++#include "tm.h"
1.3520 ++#include "config/fp-bit.h"
1.3521 ++
1.3522 ++/* The following macros can be defined to change the behavior of this file:
1.3523 ++ FLOAT: Implement a `float', aka SFmode, fp library. If this is not
1.3524 ++ defined, then this file implements a `double', aka DFmode, fp library.
1.3525 ++ FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
1.3526 ++ don't include float->double conversion which requires the double library.
1.3527 ++ This is useful only for machines which can't support doubles, e.g. some
1.3528 ++ 8-bit processors.
1.3529 ++ CMPtype: Specify the type that floating point compares should return.
1.3530 ++ This defaults to SItype, aka int.
1.3531 ++ US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
1.3532 ++ US Software goFast library.
1.3533 ++ _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
1.3534 ++ two integers to the FLO_union_type.
1.3535 ++ NO_DENORMALS: Disable handling of denormals.
1.3536 ++ NO_NANS: Disable nan and infinity handling
1.3537 ++ SMALL_MACHINE: Useful when operations on QIs and HIs are faster
1.3538 ++ than on an SI */
1.3539 ++
1.3540 ++/* We don't currently support extended floats (long doubles) on machines
1.3541 ++ without hardware to deal with them.
1.3542 ++
1.3543 ++ These stubs are just to keep the linker from complaining about unresolved
1.3544 ++ references which can be pulled in from libio & libstdc++, even if the
1.3545 ++ user isn't using long doubles. However, they may generate an unresolved
1.3546 ++ external to abort if abort is not used by the function, and the stubs
1.3547 ++ are referenced from within libc, since libgcc goes before and after the
1.3548 ++ system library. */
1.3549 ++
1.3550 ++#ifdef DECLARE_LIBRARY_RENAMES
1.3551 ++ DECLARE_LIBRARY_RENAMES
1.3552 ++#endif
1.3553 ++
1.3554 ++#ifdef EXTENDED_FLOAT_STUBS
1.3555 ++extern void abort (void);
1.3556 ++void __extendsfxf2 (void) { abort(); }
1.3557 ++void __extenddfxf2 (void) { abort(); }
1.3558 ++void __truncxfdf2 (void) { abort(); }
1.3559 ++void __truncxfsf2 (void) { abort(); }
1.3560 ++void __fixxfsi (void) { abort(); }
1.3561 ++void __floatsixf (void) { abort(); }
1.3562 ++void __addxf3 (void) { abort(); }
1.3563 ++void __subxf3 (void) { abort(); }
1.3564 ++void __mulxf3 (void) { abort(); }
1.3565 ++void __divxf3 (void) { abort(); }
1.3566 ++void __negxf2 (void) { abort(); }
1.3567 ++void __eqxf2 (void) { abort(); }
1.3568 ++void __nexf2 (void) { abort(); }
1.3569 ++void __gtxf2 (void) { abort(); }
1.3570 ++void __gexf2 (void) { abort(); }
1.3571 ++void __lexf2 (void) { abort(); }
1.3572 ++void __ltxf2 (void) { abort(); }
1.3573 ++
1.3574 ++void __extendsftf2 (void) { abort(); }
1.3575 ++void __extenddftf2 (void) { abort(); }
1.3576 ++void __trunctfdf2 (void) { abort(); }
1.3577 ++void __trunctfsf2 (void) { abort(); }
1.3578 ++void __fixtfsi (void) { abort(); }
1.3579 ++void __floatsitf (void) { abort(); }
1.3580 ++void __addtf3 (void) { abort(); }
1.3581 ++void __subtf3 (void) { abort(); }
1.3582 ++void __multf3 (void) { abort(); }
1.3583 ++void __divtf3 (void) { abort(); }
1.3584 ++void __negtf2 (void) { abort(); }
1.3585 ++void __eqtf2 (void) { abort(); }
1.3586 ++void __netf2 (void) { abort(); }
1.3587 ++void __gttf2 (void) { abort(); }
1.3588 ++void __getf2 (void) { abort(); }
1.3589 ++void __letf2 (void) { abort(); }
1.3590 ++void __lttf2 (void) { abort(); }
1.3591 ++#else /* !EXTENDED_FLOAT_STUBS, rest of file */
1.3592 ++
1.3593 ++/* IEEE "special" number predicates */
1.3594 ++
1.3595 ++#ifdef NO_NANS
1.3596 ++
1.3597 ++#define nan() 0
1.3598 ++#define isnan(x) 0
1.3599 ++#define isinf(x) 0
1.3600 ++#else
1.3601 ++
1.3602 ++#if defined L_thenan_sf
1.3603 ++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.3604 ++#elif defined L_thenan_df
1.3605 ++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.3606 ++#elif defined L_thenan_tf
1.3607 ++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.3608 ++#elif defined TFLOAT
1.3609 ++extern const fp_number_type __thenan_tf;
1.3610 ++#elif defined FLOAT
1.3611 ++extern const fp_number_type __thenan_sf;
1.3612 ++#else
1.3613 ++extern const fp_number_type __thenan_df;
1.3614 ++#endif
1.3615 ++
1.3616 ++INLINE
1.3617 ++static fp_number_type *
1.3618 ++nan (void)
1.3619 ++{
1.3620 ++ /* Discard the const qualifier... */
1.3621 ++#ifdef TFLOAT
1.3622 ++ return (fp_number_type *) (& __thenan_tf);
1.3623 ++#elif defined FLOAT
1.3624 ++ return (fp_number_type *) (& __thenan_sf);
1.3625 ++#else
1.3626 ++ return (fp_number_type *) (& __thenan_df);
1.3627 ++#endif
1.3628 ++}
1.3629 ++
1.3630 ++INLINE
1.3631 ++static int
1.3632 ++isnan ( fp_number_type * x)
1.3633 ++{
1.3634 ++ return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
1.3635 ++}
1.3636 ++
1.3637 ++INLINE
1.3638 ++static int
1.3639 ++isinf ( fp_number_type * x)
1.3640 ++{
1.3641 ++ return x->class == CLASS_INFINITY;
1.3642 ++}
1.3643 ++
1.3644 ++#endif /* NO_NANS */
1.3645 ++
1.3646 ++INLINE
1.3647 ++static int
1.3648 ++iszero ( fp_number_type * x)
1.3649 ++{
1.3650 ++ return x->class == CLASS_ZERO;
1.3651 ++}
1.3652 ++
1.3653 ++INLINE
1.3654 ++static void
1.3655 ++flip_sign ( fp_number_type * x)
1.3656 ++{
1.3657 ++ x->sign = !x->sign;
1.3658 ++}
1.3659 ++
1.3660 ++extern FLO_type pack_d ( fp_number_type * );
1.3661 ++
1.3662 ++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
1.3663 ++FLO_type
1.3664 ++pack_d ( fp_number_type * src)
1.3665 ++{
1.3666 ++ FLO_union_type dst;
1.3667 ++ fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
1.3668 ++ int sign = src->sign;
1.3669 ++ int exp = 0;
1.3670 ++
1.3671 ++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
1.3672 ++ {
1.3673 ++ /* We can't represent these values accurately. By using the
1.3674 ++ largest possible magnitude, we guarantee that the conversion
1.3675 ++ of infinity is at least as big as any finite number. */
1.3676 ++ exp = EXPMAX;
1.3677 ++ fraction = ((fractype) 1 << FRACBITS) - 1;
1.3678 ++ }
1.3679 ++ else if (isnan (src))
1.3680 ++ {
1.3681 ++ exp = EXPMAX;
1.3682 ++ if (src->class == CLASS_QNAN || 1)
1.3683 ++ {
1.3684 ++#ifdef QUIET_NAN_NEGATED
1.3685 ++ fraction |= QUIET_NAN - 1;
1.3686 ++#else
1.3687 ++ fraction |= QUIET_NAN;
1.3688 ++#endif
1.3689 ++ }
1.3690 ++ }
1.3691 ++ else if (isinf (src))
1.3692 ++ {
1.3693 ++ exp = EXPMAX;
1.3694 ++ fraction = 0;
1.3695 ++ }
1.3696 ++ else if (iszero (src))
1.3697 ++ {
1.3698 ++ exp = 0;
1.3699 ++ fraction = 0;
1.3700 ++ }
1.3701 ++ else if (fraction == 0)
1.3702 ++ {
1.3703 ++ exp = 0;
1.3704 ++ }
1.3705 ++ else
1.3706 ++ {
1.3707 ++ if (src->normal_exp < NORMAL_EXPMIN)
1.3708 ++ {
1.3709 ++#ifdef NO_DENORMALS
1.3710 ++ /* Go straight to a zero representation if denormals are not
1.3711 ++ supported. The denormal handling would be harmless but
1.3712 ++ isn't unnecessary. */
1.3713 ++ exp = 0;
1.3714 ++ fraction = 0;
1.3715 ++#else /* NO_DENORMALS */
1.3716 ++ /* This number's exponent is too low to fit into the bits
1.3717 ++ available in the number, so we'll store 0 in the exponent and
1.3718 ++ shift the fraction to the right to make up for it. */
1.3719 ++
1.3720 ++ int shift = NORMAL_EXPMIN - src->normal_exp;
1.3721 ++
1.3722 ++ exp = 0;
1.3723 ++
1.3724 ++ if (shift > FRAC_NBITS - NGARDS)
1.3725 ++ {
1.3726 ++ /* No point shifting, since it's more that 64 out. */
1.3727 ++ fraction = 0;
1.3728 ++ }
1.3729 ++ else
1.3730 ++ {
1.3731 ++ int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
1.3732 ++ fraction = (fraction >> shift) | lowbit;
1.3733 ++ }
1.3734 ++ if ((fraction & GARDMASK) == GARDMSB)
1.3735 ++ {
1.3736 ++ if ((fraction & (1 << NGARDS)))
1.3737 ++ fraction += GARDROUND + 1;
1.3738 ++ }
1.3739 ++ else
1.3740 ++ {
1.3741 ++ /* Add to the guards to round up. */
1.3742 ++ fraction += GARDROUND;
1.3743 ++ }
1.3744 ++ /* Perhaps the rounding means we now need to change the
1.3745 ++ exponent, because the fraction is no longer denormal. */
1.3746 ++ if (fraction >= IMPLICIT_1)
1.3747 ++ {
1.3748 ++ exp += 1;
1.3749 ++ }
1.3750 ++ fraction >>= NGARDS;
1.3751 ++#endif /* NO_DENORMALS */
1.3752 ++ }
1.3753 ++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
1.3754 ++ && src->normal_exp > EXPBIAS)
1.3755 ++ {
1.3756 ++ exp = EXPMAX;
1.3757 ++ fraction = 0;
1.3758 ++ }
1.3759 ++ else
1.3760 ++ {
1.3761 ++ exp = src->normal_exp + EXPBIAS;
1.3762 ++ if (!ROUND_TOWARDS_ZERO)
1.3763 ++ {
1.3764 ++ /* IF the gard bits are the all zero, but the first, then we're
1.3765 ++ half way between two numbers, choose the one which makes the
1.3766 ++ lsb of the answer 0. */
1.3767 ++ if ((fraction & GARDMASK) == GARDMSB)
1.3768 ++ {
1.3769 ++ if (fraction & (1 << NGARDS))
1.3770 ++ fraction += GARDROUND + 1;
1.3771 ++ }
1.3772 ++ else
1.3773 ++ {
1.3774 ++ /* Add a one to the guards to round up */
1.3775 ++ fraction += GARDROUND;
1.3776 ++ }
1.3777 ++ if (fraction >= IMPLICIT_2)
1.3778 ++ {
1.3779 ++ fraction >>= 1;
1.3780 ++ exp += 1;
1.3781 ++ }
1.3782 ++ }
1.3783 ++ fraction >>= NGARDS;
1.3784 ++
1.3785 ++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
1.3786 ++ {
1.3787 ++ /* Saturate on overflow. */
1.3788 ++ exp = EXPMAX;
1.3789 ++ fraction = ((fractype) 1 << FRACBITS) - 1;
1.3790 ++ }
1.3791 ++ }
1.3792 ++ }
1.3793 ++
1.3794 ++ /* We previously used bitfields to store the number, but this doesn't
1.3795 ++ handle little/big endian systems conveniently, so use shifts and
1.3796 ++ masks */
1.3797 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
1.3798 ++ dst.bits.fraction = fraction;
1.3799 ++ dst.bits.exp = exp;
1.3800 ++ dst.bits.sign = sign;
1.3801 ++#else
1.3802 ++# if defined TFLOAT && defined HALFFRACBITS
1.3803 ++ {
1.3804 ++ halffractype high, low, unity;
1.3805 ++ int lowsign, lowexp;
1.3806 ++
1.3807 ++ unity = (halffractype) 1 << HALFFRACBITS;
1.3808 ++
1.3809 ++ /* Set HIGH to the high double's significand, masking out the implicit 1.
1.3810 ++ Set LOW to the low double's full significand. */
1.3811 ++ high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
1.3812 ++ low = fraction & (unity * 2 - 1);
1.3813 ++
1.3814 ++ /* Get the initial sign and exponent of the low double. */
1.3815 ++ lowexp = exp - HALFFRACBITS - 1;
1.3816 ++ lowsign = sign;
1.3817 ++
1.3818 ++ /* HIGH should be rounded like a normal double, making |LOW| <=
1.3819 ++ 0.5 ULP of HIGH. Assume round-to-nearest. */
1.3820 ++ if (exp < EXPMAX)
1.3821 ++ if (low > unity || (low == unity && (high & 1) == 1))
1.3822 ++ {
1.3823 ++ /* Round HIGH up and adjust LOW to match. */
1.3824 ++ high++;
1.3825 ++ if (high == unity)
1.3826 ++ {
1.3827 ++ /* May make it infinite, but that's OK. */
1.3828 ++ high = 0;
1.3829 ++ exp++;
1.3830 ++ }
1.3831 ++ low = unity * 2 - low;
1.3832 ++ lowsign ^= 1;
1.3833 ++ }
1.3834 ++
1.3835 ++ high |= (halffractype) exp << HALFFRACBITS;
1.3836 ++ high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
1.3837 ++
1.3838 ++ if (exp == EXPMAX || exp == 0 || low == 0)
1.3839 ++ low = 0;
1.3840 ++ else
1.3841 ++ {
1.3842 ++ while (lowexp > 0 && low < unity)
1.3843 ++ {
1.3844 ++ low <<= 1;
1.3845 ++ lowexp--;
1.3846 ++ }
1.3847 ++
1.3848 ++ if (lowexp <= 0)
1.3849 ++ {
1.3850 ++ halffractype roundmsb, round;
1.3851 ++ int shift;
1.3852 ++
1.3853 ++ shift = 1 - lowexp;
1.3854 ++ roundmsb = (1 << (shift - 1));
1.3855 ++ round = low & ((roundmsb << 1) - 1);
1.3856 ++
1.3857 ++ low >>= shift;
1.3858 ++ lowexp = 0;
1.3859 ++
1.3860 ++ if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
1.3861 ++ {
1.3862 ++ low++;
1.3863 ++ if (low == unity)
1.3864 ++ /* LOW rounds up to the smallest normal number. */
1.3865 ++ lowexp++;
1.3866 ++ }
1.3867 ++ }
1.3868 ++
1.3869 ++ low &= unity - 1;
1.3870 ++ low |= (halffractype) lowexp << HALFFRACBITS;
1.3871 ++ low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
1.3872 ++ }
1.3873 ++ dst.value_raw = ((fractype) high << HALFSHIFT) | low;
1.3874 ++ }
1.3875 ++# else
1.3876 ++ dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
1.3877 ++ dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
1.3878 ++ dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
1.3879 ++# endif
1.3880 ++#endif
1.3881 ++
1.3882 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
1.3883 ++#ifdef TFLOAT
1.3884 ++ {
1.3885 ++ qrtrfractype tmp1 = dst.words[0];
1.3886 ++ qrtrfractype tmp2 = dst.words[1];
1.3887 ++ dst.words[0] = dst.words[3];
1.3888 ++ dst.words[1] = dst.words[2];
1.3889 ++ dst.words[2] = tmp2;
1.3890 ++ dst.words[3] = tmp1;
1.3891 ++ }
1.3892 ++#else
1.3893 ++ {
1.3894 ++ halffractype tmp = dst.words[0];
1.3895 ++ dst.words[0] = dst.words[1];
1.3896 ++ dst.words[1] = tmp;
1.3897 ++ }
1.3898 ++#endif
1.3899 ++#endif
1.3900 ++
1.3901 ++ return dst.value;
1.3902 ++}
1.3903 ++#endif
1.3904 ++
1.3905 ++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
1.3906 ++void
1.3907 ++unpack_d (FLO_union_type * src, fp_number_type * dst)
1.3908 ++{
1.3909 ++ /* We previously used bitfields to store the number, but this doesn't
1.3910 ++ handle little/big endian systems conveniently, so use shifts and
1.3911 ++ masks */
1.3912 ++ fractype fraction;
1.3913 ++ int exp;
1.3914 ++ int sign;
1.3915 ++
1.3916 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
1.3917 ++ FLO_union_type swapped;
1.3918 ++
1.3919 ++#ifdef TFLOAT
1.3920 ++ swapped.words[0] = src->words[3];
1.3921 ++ swapped.words[1] = src->words[2];
1.3922 ++ swapped.words[2] = src->words[1];
1.3923 ++ swapped.words[3] = src->words[0];
1.3924 ++#else
1.3925 ++ swapped.words[0] = src->words[1];
1.3926 ++ swapped.words[1] = src->words[0];
1.3927 ++#endif
1.3928 ++ src = &swapped;
1.3929 ++#endif
1.3930 ++
1.3931 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
1.3932 ++ fraction = src->bits.fraction;
1.3933 ++ exp = src->bits.exp;
1.3934 ++ sign = src->bits.sign;
1.3935 ++#else
1.3936 ++# if defined TFLOAT && defined HALFFRACBITS
1.3937 ++ {
1.3938 ++ halffractype high, low;
1.3939 ++
1.3940 ++ high = src->value_raw >> HALFSHIFT;
1.3941 ++ low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
1.3942 ++
1.3943 ++ fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
1.3944 ++ fraction <<= FRACBITS - HALFFRACBITS;
1.3945 ++ exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1.3946 ++ sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
1.3947 ++
1.3948 ++ if (exp != EXPMAX && exp != 0 && low != 0)
1.3949 ++ {
1.3950 ++ int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1.3951 ++ int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
1.3952 ++ int shift;
1.3953 ++ fractype xlow;
1.3954 ++
1.3955 ++ xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
1.3956 ++ if (lowexp)
1.3957 ++ xlow |= (((halffractype)1) << HALFFRACBITS);
1.3958 ++ else
1.3959 ++ lowexp = 1;
1.3960 ++ shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
1.3961 ++ if (shift > 0)
1.3962 ++ xlow <<= shift;
1.3963 ++ else if (shift < 0)
1.3964 ++ xlow >>= -shift;
1.3965 ++ if (sign == lowsign)
1.3966 ++ fraction += xlow;
1.3967 ++ else if (fraction >= xlow)
1.3968 ++ fraction -= xlow;
1.3969 ++ else
1.3970 ++ {
1.3971 ++ /* The high part is a power of two but the full number is lower.
1.3972 ++ This code will leave the implicit 1 in FRACTION, but we'd
1.3973 ++ have added that below anyway. */
1.3974 ++ fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
1.3975 ++ exp--;
1.3976 ++ }
1.3977 ++ }
1.3978 ++ }
1.3979 ++# else
1.3980 ++ fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
1.3981 ++ exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
1.3982 ++ sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
1.3983 ++# endif
1.3984 ++#endif
1.3985 ++
1.3986 ++ dst->sign = sign;
1.3987 ++ if (exp == 0)
1.3988 ++ {
1.3989 ++ /* Hmm. Looks like 0 */
1.3990 ++ if (fraction == 0
1.3991 ++#ifdef NO_DENORMALS
1.3992 ++ || 1
1.3993 ++#endif
1.3994 ++ )
1.3995 ++ {
1.3996 ++ /* tastes like zero */
1.3997 ++ dst->class = CLASS_ZERO;
1.3998 ++ }
1.3999 ++ else
1.4000 ++ {
1.4001 ++ /* Zero exponent with nonzero fraction - it's denormalized,
1.4002 ++ so there isn't a leading implicit one - we'll shift it so
1.4003 ++ it gets one. */
1.4004 ++ dst->normal_exp = exp - EXPBIAS + 1;
1.4005 ++ fraction <<= NGARDS;
1.4006 ++
1.4007 ++ dst->class = CLASS_NUMBER;
1.4008 ++#if 1
1.4009 ++ while (fraction < IMPLICIT_1)
1.4010 ++ {
1.4011 ++ fraction <<= 1;
1.4012 ++ dst->normal_exp--;
1.4013 ++ }
1.4014 ++#endif
1.4015 ++ dst->fraction.ll = fraction;
1.4016 ++ }
1.4017 ++ }
1.4018 ++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
1.4019 ++ {
1.4020 ++ /* Huge exponent*/
1.4021 ++ if (fraction == 0)
1.4022 ++ {
1.4023 ++ /* Attached to a zero fraction - means infinity */
1.4024 ++ dst->class = CLASS_INFINITY;
1.4025 ++ }
1.4026 ++ else
1.4027 ++ {
1.4028 ++ /* Nonzero fraction, means nan */
1.4029 ++#ifdef QUIET_NAN_NEGATED
1.4030 ++ if ((fraction & QUIET_NAN) == 0)
1.4031 ++#else
1.4032 ++ if (fraction & QUIET_NAN)
1.4033 ++#endif
1.4034 ++ {
1.4035 ++ dst->class = CLASS_QNAN;
1.4036 ++ }
1.4037 ++ else
1.4038 ++ {
1.4039 ++ dst->class = CLASS_SNAN;
1.4040 ++ }
1.4041 ++ /* Keep the fraction part as the nan number */
1.4042 ++ dst->fraction.ll = fraction;
1.4043 ++ }
1.4044 ++ }
1.4045 ++ else
1.4046 ++ {
1.4047 ++ /* Nothing strange about this number */
1.4048 ++ dst->normal_exp = exp - EXPBIAS;
1.4049 ++ dst->class = CLASS_NUMBER;
1.4050 ++ dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
1.4051 ++ }
1.4052 ++}
1.4053 ++#endif /* L_unpack_df || L_unpack_sf */
1.4054 ++
1.4055 ++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
1.4056 ++static fp_number_type *
1.4057 ++_fpadd_parts (fp_number_type * a,
1.4058 ++ fp_number_type * b,
1.4059 ++ fp_number_type * tmp)
1.4060 ++{
1.4061 ++ intfrac tfraction;
1.4062 ++
1.4063 ++ /* Put commonly used fields in local variables. */
1.4064 ++ int a_normal_exp;
1.4065 ++ int b_normal_exp;
1.4066 ++ fractype a_fraction;
1.4067 ++ fractype b_fraction;
1.4068 ++
1.4069 ++ if (isnan (a))
1.4070 ++ {
1.4071 ++ return a;
1.4072 ++ }
1.4073 ++ if (isnan (b))
1.4074 ++ {
1.4075 ++ return b;
1.4076 ++ }
1.4077 ++ if (isinf (a))
1.4078 ++ {
1.4079 ++ /* Adding infinities with opposite signs yields a NaN. */
1.4080 ++ if (isinf (b) && a->sign != b->sign)
1.4081 ++ return nan ();
1.4082 ++ return a;
1.4083 ++ }
1.4084 ++ if (isinf (b))
1.4085 ++ {
1.4086 ++ return b;
1.4087 ++ }
1.4088 ++ if (iszero (b))
1.4089 ++ {
1.4090 ++ if (iszero (a))
1.4091 ++ {
1.4092 ++ *tmp = *a;
1.4093 ++ tmp->sign = a->sign & b->sign;
1.4094 ++ return tmp;
1.4095 ++ }
1.4096 ++ return a;
1.4097 ++ }
1.4098 ++ if (iszero (a))
1.4099 ++ {
1.4100 ++ return b;
1.4101 ++ }
1.4102 ++
1.4103 ++ /* Got two numbers. shift the smaller and increment the exponent till
1.4104 ++ they're the same */
1.4105 ++ {
1.4106 ++ int diff;
1.4107 ++
1.4108 ++ a_normal_exp = a->normal_exp;
1.4109 ++ b_normal_exp = b->normal_exp;
1.4110 ++ a_fraction = a->fraction.ll;
1.4111 ++ b_fraction = b->fraction.ll;
1.4112 ++
1.4113 ++ diff = a_normal_exp - b_normal_exp;
1.4114 ++
1.4115 ++ if (diff < 0)
1.4116 ++ diff = -diff;
1.4117 ++ if (diff < FRAC_NBITS)
1.4118 ++ {
1.4119 ++ /* ??? This does shifts one bit at a time. Optimize. */
1.4120 ++ while (a_normal_exp > b_normal_exp)
1.4121 ++ {
1.4122 ++ b_normal_exp++;
1.4123 ++ LSHIFT (b_fraction);
1.4124 ++ }
1.4125 ++ while (b_normal_exp > a_normal_exp)
1.4126 ++ {
1.4127 ++ a_normal_exp++;
1.4128 ++ LSHIFT (a_fraction);
1.4129 ++ }
1.4130 ++ }
1.4131 ++ else
1.4132 ++ {
1.4133 ++ /* Somethings's up.. choose the biggest */
1.4134 ++ if (a_normal_exp > b_normal_exp)
1.4135 ++ {
1.4136 ++ b_normal_exp = a_normal_exp;
1.4137 ++ b_fraction = 0;
1.4138 ++ }
1.4139 ++ else
1.4140 ++ {
1.4141 ++ a_normal_exp = b_normal_exp;
1.4142 ++ a_fraction = 0;
1.4143 ++ }
1.4144 ++ }
1.4145 ++ }
1.4146 ++
1.4147 ++ if (a->sign != b->sign)
1.4148 ++ {
1.4149 ++ if (a->sign)
1.4150 ++ {
1.4151 ++ tfraction = -a_fraction + b_fraction;
1.4152 ++ }
1.4153 ++ else
1.4154 ++ {
1.4155 ++ tfraction = a_fraction - b_fraction;
1.4156 ++ }
1.4157 ++ if (tfraction >= 0)
1.4158 ++ {
1.4159 ++ tmp->sign = 0;
1.4160 ++ tmp->normal_exp = a_normal_exp;
1.4161 ++ tmp->fraction.ll = tfraction;
1.4162 ++ }
1.4163 ++ else
1.4164 ++ {
1.4165 ++ tmp->sign = 1;
1.4166 ++ tmp->normal_exp = a_normal_exp;
1.4167 ++ tmp->fraction.ll = -tfraction;
1.4168 ++ }
1.4169 ++ /* and renormalize it */
1.4170 ++
1.4171 ++ while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
1.4172 ++ {
1.4173 ++ tmp->fraction.ll <<= 1;
1.4174 ++ tmp->normal_exp--;
1.4175 ++ }
1.4176 ++ }
1.4177 ++ else
1.4178 ++ {
1.4179 ++ tmp->sign = a->sign;
1.4180 ++ tmp->normal_exp = a_normal_exp;
1.4181 ++ tmp->fraction.ll = a_fraction + b_fraction;
1.4182 ++ }
1.4183 ++ tmp->class = CLASS_NUMBER;
1.4184 ++ /* Now the fraction is added, we have to shift down to renormalize the
1.4185 ++ number */
1.4186 ++
1.4187 ++ if (tmp->fraction.ll >= IMPLICIT_2)
1.4188 ++ {
1.4189 ++ LSHIFT (tmp->fraction.ll);
1.4190 ++ tmp->normal_exp++;
1.4191 ++ }
1.4192 ++ return tmp;
1.4193 ++
1.4194 ++}
1.4195 ++
1.4196 ++FLO_type
1.4197 ++add (FLO_type arg_a, FLO_type arg_b)
1.4198 ++{
1.4199 ++ fp_number_type a;
1.4200 ++ fp_number_type b;
1.4201 ++ fp_number_type tmp;
1.4202 ++ fp_number_type *res;
1.4203 ++ FLO_union_type au, bu;
1.4204 ++
1.4205 ++ au.value = arg_a;
1.4206 ++ bu.value = arg_b;
1.4207 ++
1.4208 ++ unpack_d (&au, &a);
1.4209 ++ unpack_d (&bu, &b);
1.4210 ++
1.4211 ++ res = _fpadd_parts (&a, &b, &tmp);
1.4212 ++
1.4213 ++ return pack_d (res);
1.4214 ++}
1.4215 ++
1.4216 ++FLO_type
1.4217 ++sub (FLO_type arg_a, FLO_type arg_b)
1.4218 ++{
1.4219 ++ fp_number_type a;
1.4220 ++ fp_number_type b;
1.4221 ++ fp_number_type tmp;
1.4222 ++ fp_number_type *res;
1.4223 ++ FLO_union_type au, bu;
1.4224 ++
1.4225 ++ au.value = arg_a;
1.4226 ++ bu.value = arg_b;
1.4227 ++
1.4228 ++ unpack_d (&au, &a);
1.4229 ++ unpack_d (&bu, &b);
1.4230 ++
1.4231 ++ b.sign ^= 1;
1.4232 ++
1.4233 ++ res = _fpadd_parts (&a, &b, &tmp);
1.4234 ++
1.4235 ++ return pack_d (res);
1.4236 ++}
1.4237 ++#endif /* L_addsub_sf || L_addsub_df */
1.4238 ++
1.4239 ++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
1.4240 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
1.4241 ++_fpmul_parts ( fp_number_type * a,
1.4242 ++ fp_number_type * b,
1.4243 ++ fp_number_type * tmp)
1.4244 ++{
1.4245 ++ fractype low = 0;
1.4246 ++ fractype high = 0;
1.4247 ++
1.4248 ++ if (isnan (a))
1.4249 ++ {
1.4250 ++ a->sign = a->sign != b->sign;
1.4251 ++ return a;
1.4252 ++ }
1.4253 ++ if (isnan (b))
1.4254 ++ {
1.4255 ++ b->sign = a->sign != b->sign;
1.4256 ++ return b;
1.4257 ++ }
1.4258 ++ if (isinf (a))
1.4259 ++ {
1.4260 ++ if (iszero (b))
1.4261 ++ return nan ();
1.4262 ++ a->sign = a->sign != b->sign;
1.4263 ++ return a;
1.4264 ++ }
1.4265 ++ if (isinf (b))
1.4266 ++ {
1.4267 ++ if (iszero (a))
1.4268 ++ {
1.4269 ++ return nan ();
1.4270 ++ }
1.4271 ++ b->sign = a->sign != b->sign;
1.4272 ++ return b;
1.4273 ++ }
1.4274 ++ if (iszero (a))
1.4275 ++ {
1.4276 ++ a->sign = a->sign != b->sign;
1.4277 ++ return a;
1.4278 ++ }
1.4279 ++ if (iszero (b))
1.4280 ++ {
1.4281 ++ b->sign = a->sign != b->sign;
1.4282 ++ return b;
1.4283 ++ }
1.4284 ++
1.4285 ++ /* Calculate the mantissa by multiplying both numbers to get a
1.4286 ++ twice-as-wide number. */
1.4287 ++ {
1.4288 ++#if defined(NO_DI_MODE) || defined(TFLOAT)
1.4289 ++ {
1.4290 ++ fractype x = a->fraction.ll;
1.4291 ++ fractype ylow = b->fraction.ll;
1.4292 ++ fractype yhigh = 0;
1.4293 ++ int bit;
1.4294 ++
1.4295 ++ /* ??? This does multiplies one bit at a time. Optimize. */
1.4296 ++ for (bit = 0; bit < FRAC_NBITS; bit++)
1.4297 ++ {
1.4298 ++ int carry;
1.4299 ++
1.4300 ++ if (x & 1)
1.4301 ++ {
1.4302 ++ carry = (low += ylow) < ylow;
1.4303 ++ high += yhigh + carry;
1.4304 ++ }
1.4305 ++ yhigh <<= 1;
1.4306 ++ if (ylow & FRACHIGH)
1.4307 ++ {
1.4308 ++ yhigh |= 1;
1.4309 ++ }
1.4310 ++ ylow <<= 1;
1.4311 ++ x >>= 1;
1.4312 ++ }
1.4313 ++ }
1.4314 ++#elif defined(FLOAT)
1.4315 ++ /* Multiplying two USIs to get a UDI, we're safe. */
1.4316 ++ {
1.4317 ++ UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
1.4318 ++
1.4319 ++ high = answer >> BITS_PER_SI;
1.4320 ++ low = answer;
1.4321 ++ }
1.4322 ++#else
1.4323 ++ /* fractype is DImode, but we need the result to be twice as wide.
1.4324 ++ Assuming a widening multiply from DImode to TImode is not
1.4325 ++ available, build one by hand. */
1.4326 ++ {
1.4327 ++ USItype nl = a->fraction.ll;
1.4328 ++ USItype nh = a->fraction.ll >> BITS_PER_SI;
1.4329 ++ USItype ml = b->fraction.ll;
1.4330 ++ USItype mh = b->fraction.ll >> BITS_PER_SI;
1.4331 ++ UDItype pp_ll = (UDItype) ml * nl;
1.4332 ++ UDItype pp_hl = (UDItype) mh * nl;
1.4333 ++ UDItype pp_lh = (UDItype) ml * nh;
1.4334 ++ UDItype pp_hh = (UDItype) mh * nh;
1.4335 ++ UDItype res2 = 0;
1.4336 ++ UDItype res0 = 0;
1.4337 ++ UDItype ps_hh__ = pp_hl + pp_lh;
1.4338 ++ if (ps_hh__ < pp_hl)
1.4339 ++ res2 += (UDItype)1 << BITS_PER_SI;
1.4340 ++ pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
1.4341 ++ res0 = pp_ll + pp_hl;
1.4342 ++ if (res0 < pp_ll)
1.4343 ++ res2++;
1.4344 ++ res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
1.4345 ++ high = res2;
1.4346 ++ low = res0;
1.4347 ++ }
1.4348 ++#endif
1.4349 ++ }
1.4350 ++
1.4351 ++ tmp->normal_exp = a->normal_exp + b->normal_exp
1.4352 ++ + FRAC_NBITS - (FRACBITS + NGARDS);
1.4353 ++ tmp->sign = a->sign != b->sign;
1.4354 ++ while (high >= IMPLICIT_2)
1.4355 ++ {
1.4356 ++ tmp->normal_exp++;
1.4357 ++ if (high & 1)
1.4358 ++ {
1.4359 ++ low >>= 1;
1.4360 ++ low |= FRACHIGH;
1.4361 ++ }
1.4362 ++ high >>= 1;
1.4363 ++ }
1.4364 ++ while (high < IMPLICIT_1)
1.4365 ++ {
1.4366 ++ tmp->normal_exp--;
1.4367 ++
1.4368 ++ high <<= 1;
1.4369 ++ if (low & FRACHIGH)
1.4370 ++ high |= 1;
1.4371 ++ low <<= 1;
1.4372 ++ }
1.4373 ++ /* rounding is tricky. if we only round if it won't make us round later. */
1.4374 ++#if 0
1.4375 ++ if (low & FRACHIGH2)
1.4376 ++ {
1.4377 ++ if (((high & GARDMASK) != GARDMSB)
1.4378 ++ && (((high + 1) & GARDMASK) == GARDMSB))
1.4379 ++ {
1.4380 ++ /* don't round, it gets done again later. */
1.4381 ++ }
1.4382 ++ else
1.4383 ++ {
1.4384 ++ high++;
1.4385 ++ }
1.4386 ++ }
1.4387 ++#endif
1.4388 ++ if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
1.4389 ++ {
1.4390 ++ if (high & (1 << NGARDS))
1.4391 ++ {
1.4392 ++ /* half way, so round to even */
1.4393 ++ high += GARDROUND + 1;
1.4394 ++ }
1.4395 ++ else if (low)
1.4396 ++ {
1.4397 ++ /* but we really weren't half way */
1.4398 ++ high += GARDROUND + 1;
1.4399 ++ }
1.4400 ++ }
1.4401 ++ tmp->fraction.ll = high;
1.4402 ++ tmp->class = CLASS_NUMBER;
1.4403 ++ return tmp;
1.4404 ++}
1.4405 ++
1.4406 ++FLO_type
1.4407 ++multiply (FLO_type arg_a, FLO_type arg_b)
1.4408 ++{
1.4409 ++ fp_number_type a;
1.4410 ++ fp_number_type b;
1.4411 ++ fp_number_type tmp;
1.4412 ++ fp_number_type *res;
1.4413 ++ FLO_union_type au, bu;
1.4414 ++
1.4415 ++ au.value = arg_a;
1.4416 ++ bu.value = arg_b;
1.4417 ++
1.4418 ++ unpack_d (&au, &a);
1.4419 ++ unpack_d (&bu, &b);
1.4420 ++
1.4421 ++ res = _fpmul_parts (&a, &b, &tmp);
1.4422 ++
1.4423 ++ return pack_d (res);
1.4424 ++}
1.4425 ++#endif /* L_mul_sf || L_mul_df */
1.4426 ++
1.4427 ++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
1.4428 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
1.4429 ++_fpdiv_parts (fp_number_type * a,
1.4430 ++ fp_number_type * b)
1.4431 ++{
1.4432 ++ fractype bit;
1.4433 ++ fractype numerator;
1.4434 ++ fractype denominator;
1.4435 ++ fractype quotient;
1.4436 ++
1.4437 ++ if (isnan (a))
1.4438 ++ {
1.4439 ++ return a;
1.4440 ++ }
1.4441 ++ if (isnan (b))
1.4442 ++ {
1.4443 ++ return b;
1.4444 ++ }
1.4445 ++
1.4446 ++ a->sign = a->sign ^ b->sign;
1.4447 ++
1.4448 ++ if (isinf (a) || iszero (a))
1.4449 ++ {
1.4450 ++ if (a->class == b->class)
1.4451 ++ return nan ();
1.4452 ++ return a;
1.4453 ++ }
1.4454 ++
1.4455 ++ if (isinf (b))
1.4456 ++ {
1.4457 ++ a->fraction.ll = 0;
1.4458 ++ a->normal_exp = 0;
1.4459 ++ return a;
1.4460 ++ }
1.4461 ++ if (iszero (b))
1.4462 ++ {
1.4463 ++ a->class = CLASS_INFINITY;
1.4464 ++ return a;
1.4465 ++ }
1.4466 ++
1.4467 ++ /* Calculate the mantissa by multiplying both 64bit numbers to get a
1.4468 ++ 128 bit number */
1.4469 ++ {
1.4470 ++ /* quotient =
1.4471 ++ ( numerator / denominator) * 2^(numerator exponent - denominator exponent)
1.4472 ++ */
1.4473 ++
1.4474 ++ a->normal_exp = a->normal_exp - b->normal_exp;
1.4475 ++ numerator = a->fraction.ll;
1.4476 ++ denominator = b->fraction.ll;
1.4477 ++
1.4478 ++ if (numerator < denominator)
1.4479 ++ {
1.4480 ++ /* Fraction will be less than 1.0 */
1.4481 ++ numerator *= 2;
1.4482 ++ a->normal_exp--;
1.4483 ++ }
1.4484 ++ bit = IMPLICIT_1;
1.4485 ++ quotient = 0;
1.4486 ++ /* ??? Does divide one bit at a time. Optimize. */
1.4487 ++ while (bit)
1.4488 ++ {
1.4489 ++ if (numerator >= denominator)
1.4490 ++ {
1.4491 ++ quotient |= bit;
1.4492 ++ numerator -= denominator;
1.4493 ++ }
1.4494 ++ bit >>= 1;
1.4495 ++ numerator *= 2;
1.4496 ++ }
1.4497 ++
1.4498 ++ if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
1.4499 ++ {
1.4500 ++ if (quotient & (1 << NGARDS))
1.4501 ++ {
1.4502 ++ /* half way, so round to even */
1.4503 ++ quotient += GARDROUND + 1;
1.4504 ++ }
1.4505 ++ else if (numerator)
1.4506 ++ {
1.4507 ++ /* but we really weren't half way, more bits exist */
1.4508 ++ quotient += GARDROUND + 1;
1.4509 ++ }
1.4510 ++ }
1.4511 ++
1.4512 ++ a->fraction.ll = quotient;
1.4513 ++ return (a);
1.4514 ++ }
1.4515 ++}
1.4516 ++
1.4517 ++FLO_type
1.4518 ++divide (FLO_type arg_a, FLO_type arg_b)
1.4519 ++{
1.4520 ++ fp_number_type a;
1.4521 ++ fp_number_type b;
1.4522 ++ fp_number_type *res;
1.4523 ++ FLO_union_type au, bu;
1.4524 ++
1.4525 ++ au.value = arg_a;
1.4526 ++ bu.value = arg_b;
1.4527 ++
1.4528 ++ unpack_d (&au, &a);
1.4529 ++ unpack_d (&bu, &b);
1.4530 ++
1.4531 ++ res = _fpdiv_parts (&a, &b);
1.4532 ++
1.4533 ++ return pack_d (res);
1.4534 ++}
1.4535 ++#endif /* L_div_sf || L_div_df */
1.4536 ++
1.4537 ++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
1.4538 ++ || defined(L_fpcmp_parts_tf)
1.4539 ++/* according to the demo, fpcmp returns a comparison with 0... thus
1.4540 ++ a<b -> -1
1.4541 ++ a==b -> 0
1.4542 ++ a>b -> +1
1.4543 ++ */
1.4544 ++
1.4545 ++int
1.4546 ++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
1.4547 ++{
1.4548 ++#if 0
1.4549 ++ /* either nan -> unordered. Must be checked outside of this routine. */
1.4550 ++ if (isnan (a) && isnan (b))
1.4551 ++ {
1.4552 ++ return 1; /* still unordered! */
1.4553 ++ }
1.4554 ++#endif
1.4555 ++
1.4556 ++ if (isnan (a) || isnan (b))
1.4557 ++ {
1.4558 ++ return 1; /* how to indicate unordered compare? */
1.4559 ++ }
1.4560 ++ if (isinf (a) && isinf (b))
1.4561 ++ {
1.4562 ++ /* +inf > -inf, but +inf != +inf */
1.4563 ++ /* b \a| +inf(0)| -inf(1)
1.4564 ++ ______\+--------+--------
1.4565 ++ +inf(0)| a==b(0)| a<b(-1)
1.4566 ++ -------+--------+--------
1.4567 ++ -inf(1)| a>b(1) | a==b(0)
1.4568 ++ -------+--------+--------
1.4569 ++ So since unordered must be nonzero, just line up the columns...
1.4570 ++ */
1.4571 ++ return b->sign - a->sign;
1.4572 ++ }
1.4573 ++ /* but not both... */
1.4574 ++ if (isinf (a))
1.4575 ++ {
1.4576 ++ return a->sign ? -1 : 1;
1.4577 ++ }
1.4578 ++ if (isinf (b))
1.4579 ++ {
1.4580 ++ return b->sign ? 1 : -1;
1.4581 ++ }
1.4582 ++ if (iszero (a) && iszero (b))
1.4583 ++ {
1.4584 ++ return 0;
1.4585 ++ }
1.4586 ++ if (iszero (a))
1.4587 ++ {
1.4588 ++ return b->sign ? 1 : -1;
1.4589 ++ }
1.4590 ++ if (iszero (b))
1.4591 ++ {
1.4592 ++ return a->sign ? -1 : 1;
1.4593 ++ }
1.4594 ++ /* now both are "normal". */
1.4595 ++ if (a->sign != b->sign)
1.4596 ++ {
1.4597 ++ /* opposite signs */
1.4598 ++ return a->sign ? -1 : 1;
1.4599 ++ }
1.4600 ++ /* same sign; exponents? */
1.4601 ++ if (a->normal_exp > b->normal_exp)
1.4602 ++ {
1.4603 ++ return a->sign ? -1 : 1;
1.4604 ++ }
1.4605 ++ if (a->normal_exp < b->normal_exp)
1.4606 ++ {
1.4607 ++ return a->sign ? 1 : -1;
1.4608 ++ }
1.4609 ++ /* same exponents; check size. */
1.4610 ++ if (a->fraction.ll > b->fraction.ll)
1.4611 ++ {
1.4612 ++ return a->sign ? -1 : 1;
1.4613 ++ }
1.4614 ++ if (a->fraction.ll < b->fraction.ll)
1.4615 ++ {
1.4616 ++ return a->sign ? 1 : -1;
1.4617 ++ }
1.4618 ++ /* after all that, they're equal. */
1.4619 ++ return 0;
1.4620 ++}
1.4621 ++#endif
1.4622 ++
1.4623 ++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
1.4624 ++CMPtype
1.4625 ++compare (FLO_type arg_a, FLO_type arg_b)
1.4626 ++{
1.4627 ++ fp_number_type a;
1.4628 ++ fp_number_type b;
1.4629 ++ FLO_union_type au, bu;
1.4630 ++
1.4631 ++ au.value = arg_a;
1.4632 ++ bu.value = arg_b;
1.4633 ++
1.4634 ++ unpack_d (&au, &a);
1.4635 ++ unpack_d (&bu, &b);
1.4636 ++
1.4637 ++ return __fpcmp_parts (&a, &b);
1.4638 ++}
1.4639 ++#endif /* L_compare_sf || L_compare_df */
1.4640 ++
1.4641 ++#ifndef US_SOFTWARE_GOFAST
1.4642 ++
1.4643 ++/* These should be optimized for their specific tasks someday. */
1.4644 ++
1.4645 ++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
1.4646 ++CMPtype
1.4647 ++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
1.4648 ++{
1.4649 ++ fp_number_type a;
1.4650 ++ fp_number_type b;
1.4651 ++ FLO_union_type au, bu;
1.4652 ++
1.4653 ++ au.value = arg_a;
1.4654 ++ bu.value = arg_b;
1.4655 ++
1.4656 ++ unpack_d (&au, &a);
1.4657 ++ unpack_d (&bu, &b);
1.4658 ++
1.4659 ++ if (isnan (&a) || isnan (&b))
1.4660 ++ return 1; /* false, truth == 0 */
1.4661 ++
1.4662 ++ return __fpcmp_parts (&a, &b) ;
1.4663 ++}
1.4664 ++#endif /* L_eq_sf || L_eq_df */
1.4665 ++
1.4666 ++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
1.4667 ++CMPtype
1.4668 ++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
1.4669 ++{
1.4670 ++ fp_number_type a;
1.4671 ++ fp_number_type b;
1.4672 ++ FLO_union_type au, bu;
1.4673 ++
1.4674 ++ au.value = arg_a;
1.4675 ++ bu.value = arg_b;
1.4676 ++
1.4677 ++ unpack_d (&au, &a);
1.4678 ++ unpack_d (&bu, &b);
1.4679 ++
1.4680 ++ if (isnan (&a) || isnan (&b))
1.4681 ++ return 1; /* true, truth != 0 */
1.4682 ++
1.4683 ++ return __fpcmp_parts (&a, &b) ;
1.4684 ++}
1.4685 ++#endif /* L_ne_sf || L_ne_df */
1.4686 ++
1.4687 ++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
1.4688 ++CMPtype
1.4689 ++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
1.4690 ++{
1.4691 ++ fp_number_type a;
1.4692 ++ fp_number_type b;
1.4693 ++ FLO_union_type au, bu;
1.4694 ++
1.4695 ++ au.value = arg_a;
1.4696 ++ bu.value = arg_b;
1.4697 ++
1.4698 ++ unpack_d (&au, &a);
1.4699 ++ unpack_d (&bu, &b);
1.4700 ++
1.4701 ++ if (isnan (&a) || isnan (&b))
1.4702 ++ return -1; /* false, truth > 0 */
1.4703 ++
1.4704 ++ return __fpcmp_parts (&a, &b);
1.4705 ++}
1.4706 ++#endif /* L_gt_sf || L_gt_df */
1.4707 ++
1.4708 ++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
1.4709 ++CMPtype
1.4710 ++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
1.4711 ++{
1.4712 ++ fp_number_type a;
1.4713 ++ fp_number_type b;
1.4714 ++ FLO_union_type au, bu;
1.4715 ++
1.4716 ++ au.value = arg_a;
1.4717 ++ bu.value = arg_b;
1.4718 ++
1.4719 ++ unpack_d (&au, &a);
1.4720 ++ unpack_d (&bu, &b);
1.4721 ++
1.4722 ++ if (isnan (&a) || isnan (&b))
1.4723 ++ return -1; /* false, truth >= 0 */
1.4724 ++ return __fpcmp_parts (&a, &b) ;
1.4725 ++}
1.4726 ++#endif /* L_ge_sf || L_ge_df */
1.4727 ++
1.4728 ++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
1.4729 ++CMPtype
1.4730 ++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
1.4731 ++{
1.4732 ++ fp_number_type a;
1.4733 ++ fp_number_type b;
1.4734 ++ FLO_union_type au, bu;
1.4735 ++
1.4736 ++ au.value = arg_a;
1.4737 ++ bu.value = arg_b;
1.4738 ++
1.4739 ++ unpack_d (&au, &a);
1.4740 ++ unpack_d (&bu, &b);
1.4741 ++
1.4742 ++ if (isnan (&a) || isnan (&b))
1.4743 ++ return 1; /* false, truth < 0 */
1.4744 ++
1.4745 ++ return __fpcmp_parts (&a, &b);
1.4746 ++}
1.4747 ++#endif /* L_lt_sf || L_lt_df */
1.4748 ++
1.4749 ++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
1.4750 ++CMPtype
1.4751 ++_le_f2 (FLO_type arg_a, FLO_type arg_b)
1.4752 ++{
1.4753 ++ fp_number_type a;
1.4754 ++ fp_number_type b;
1.4755 ++ FLO_union_type au, bu;
1.4756 ++
1.4757 ++ au.value = arg_a;
1.4758 ++ bu.value = arg_b;
1.4759 ++
1.4760 ++ unpack_d (&au, &a);
1.4761 ++ unpack_d (&bu, &b);
1.4762 ++
1.4763 ++ if (isnan (&a) || isnan (&b))
1.4764 ++ return 1; /* false, truth <= 0 */
1.4765 ++
1.4766 ++ return __fpcmp_parts (&a, &b) ;
1.4767 ++}
1.4768 ++#endif /* L_le_sf || L_le_df */
1.4769 ++
1.4770 ++#endif /* ! US_SOFTWARE_GOFAST */
1.4771 ++
1.4772 ++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
1.4773 ++CMPtype
1.4774 ++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
1.4775 ++{
1.4776 ++ fp_number_type a;
1.4777 ++ fp_number_type b;
1.4778 ++ FLO_union_type au, bu;
1.4779 ++
1.4780 ++ au.value = arg_a;
1.4781 ++ bu.value = arg_b;
1.4782 ++
1.4783 ++ unpack_d (&au, &a);
1.4784 ++ unpack_d (&bu, &b);
1.4785 ++
1.4786 ++ return (isnan (&a) || isnan (&b));
1.4787 ++}
1.4788 ++#endif /* L_unord_sf || L_unord_df */
1.4789 ++
1.4790 ++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
1.4791 ++FLO_type
1.4792 ++si_to_float (SItype arg_a)
1.4793 ++{
1.4794 ++ fp_number_type in;
1.4795 ++
1.4796 ++ in.class = CLASS_NUMBER;
1.4797 ++ in.sign = arg_a < 0;
1.4798 ++ if (!arg_a)
1.4799 ++ {
1.4800 ++ in.class = CLASS_ZERO;
1.4801 ++ }
1.4802 ++ else
1.4803 ++ {
1.4804 ++ in.normal_exp = FRACBITS + NGARDS;
1.4805 ++ if (in.sign)
1.4806 ++ {
1.4807 ++ /* Special case for minint, since there is no +ve integer
1.4808 ++ representation for it */
1.4809 ++ if (arg_a == (- MAX_SI_INT - 1))
1.4810 ++ {
1.4811 ++ return (FLO_type)(- MAX_SI_INT - 1);
1.4812 ++ }
1.4813 ++ in.fraction.ll = (-arg_a);
1.4814 ++ }
1.4815 ++ else
1.4816 ++ in.fraction.ll = arg_a;
1.4817 ++
1.4818 ++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1.4819 ++ {
1.4820 ++ in.fraction.ll <<= 1;
1.4821 ++ in.normal_exp -= 1;
1.4822 ++ }
1.4823 ++ }
1.4824 ++ return pack_d (&in);
1.4825 ++}
1.4826 ++#endif /* L_si_to_sf || L_si_to_df */
1.4827 ++
1.4828 ++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
1.4829 ++FLO_type
1.4830 ++usi_to_float (USItype arg_a)
1.4831 ++{
1.4832 ++ fp_number_type in;
1.4833 ++
1.4834 ++ in.sign = 0;
1.4835 ++ if (!arg_a)
1.4836 ++ {
1.4837 ++ in.class = CLASS_ZERO;
1.4838 ++ }
1.4839 ++ else
1.4840 ++ {
1.4841 ++ in.class = CLASS_NUMBER;
1.4842 ++ in.normal_exp = FRACBITS + NGARDS;
1.4843 ++ in.fraction.ll = arg_a;
1.4844 ++
1.4845 ++ while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
1.4846 ++ {
1.4847 ++ in.fraction.ll >>= 1;
1.4848 ++ in.normal_exp += 1;
1.4849 ++ }
1.4850 ++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1.4851 ++ {
1.4852 ++ in.fraction.ll <<= 1;
1.4853 ++ in.normal_exp -= 1;
1.4854 ++ }
1.4855 ++ }
1.4856 ++ return pack_d (&in);
1.4857 ++}
1.4858 ++#endif
1.4859 ++
1.4860 ++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
1.4861 ++SItype
1.4862 ++float_to_si (FLO_type arg_a)
1.4863 ++{
1.4864 ++ fp_number_type a;
1.4865 ++ SItype tmp;
1.4866 ++ FLO_union_type au;
1.4867 ++
1.4868 ++ au.value = arg_a;
1.4869 ++ unpack_d (&au, &a);
1.4870 ++
1.4871 ++ if (iszero (&a))
1.4872 ++ return 0;
1.4873 ++ if (isnan (&a))
1.4874 ++ return 0;
1.4875 ++ /* get reasonable MAX_SI_INT... */
1.4876 ++ if (isinf (&a))
1.4877 ++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1.4878 ++ /* it is a number, but a small one */
1.4879 ++ if (a.normal_exp < 0)
1.4880 ++ return 0;
1.4881 ++ if (a.normal_exp > BITS_PER_SI - 2)
1.4882 ++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1.4883 ++ tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
1.4884 ++ return a.sign ? (-tmp) : (tmp);
1.4885 ++}
1.4886 ++#endif /* L_sf_to_si || L_df_to_si */
1.4887 ++
1.4888 ++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
1.4889 ++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
1.4890 ++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
1.4891 ++ we also define them for GOFAST because the ones in libgcc2.c have the
1.4892 ++ wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
1.4893 ++ out of libgcc2.c. We can't define these here if not GOFAST because then
1.4894 ++ there'd be duplicate copies. */
1.4895 ++
1.4896 ++USItype
1.4897 ++float_to_usi (FLO_type arg_a)
1.4898 ++{
1.4899 ++ fp_number_type a;
1.4900 ++ FLO_union_type au;
1.4901 ++
1.4902 ++ au.value = arg_a;
1.4903 ++ unpack_d (&au, &a);
1.4904 ++
1.4905 ++ if (iszero (&a))
1.4906 ++ return 0;
1.4907 ++ if (isnan (&a))
1.4908 ++ return 0;
1.4909 ++ /* it is a negative number */
1.4910 ++ if (a.sign)
1.4911 ++ return 0;
1.4912 ++ /* get reasonable MAX_USI_INT... */
1.4913 ++ if (isinf (&a))
1.4914 ++ return MAX_USI_INT;
1.4915 ++ /* it is a number, but a small one */
1.4916 ++ if (a.normal_exp < 0)
1.4917 ++ return 0;
1.4918 ++ if (a.normal_exp > BITS_PER_SI - 1)
1.4919 ++ return MAX_USI_INT;
1.4920 ++ else if (a.normal_exp > (FRACBITS + NGARDS))
1.4921 ++ return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
1.4922 ++ else
1.4923 ++ return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
1.4924 ++}
1.4925 ++#endif /* US_SOFTWARE_GOFAST */
1.4926 ++#endif /* L_sf_to_usi || L_df_to_usi */
1.4927 ++
1.4928 ++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
1.4929 ++FLO_type
1.4930 ++negate (FLO_type arg_a)
1.4931 ++{
1.4932 ++ fp_number_type a;
1.4933 ++ FLO_union_type au;
1.4934 ++
1.4935 ++ au.value = arg_a;
1.4936 ++ unpack_d (&au, &a);
1.4937 ++
1.4938 ++ flip_sign (&a);
1.4939 ++ return pack_d (&a);
1.4940 ++}
1.4941 ++#endif /* L_negate_sf || L_negate_df */
1.4942 ++
1.4943 ++#ifdef FLOAT
1.4944 ++
1.4945 ++#if defined(L_make_sf)
1.4946 ++SFtype
1.4947 ++__make_fp(fp_class_type class,
1.4948 ++ unsigned int sign,
1.4949 ++ int exp,
1.4950 ++ USItype frac)
1.4951 ++{
1.4952 ++ fp_number_type in;
1.4953 ++
1.4954 ++ in.class = class;
1.4955 ++ in.sign = sign;
1.4956 ++ in.normal_exp = exp;
1.4957 ++ in.fraction.ll = frac;
1.4958 ++ return pack_d (&in);
1.4959 ++}
1.4960 ++#endif /* L_make_sf */
1.4961 ++
1.4962 ++#ifndef FLOAT_ONLY
1.4963 ++
1.4964 ++/* This enables one to build an fp library that supports float but not double.
1.4965 ++ Otherwise, we would get an undefined reference to __make_dp.
1.4966 ++ This is needed for some 8-bit ports that can't handle well values that
1.4967 ++ are 8-bytes in size, so we just don't support double for them at all. */
1.4968 ++
1.4969 ++#if defined(L_sf_to_df)
1.4970 ++DFtype
1.4971 ++sf_to_df (SFtype arg_a)
1.4972 ++{
1.4973 ++ fp_number_type in;
1.4974 ++ FLO_union_type au;
1.4975 ++
1.4976 ++ au.value = arg_a;
1.4977 ++ unpack_d (&au, &in);
1.4978 ++
1.4979 ++ return __make_dp (in.class, in.sign, in.normal_exp,
1.4980 ++ ((UDItype) in.fraction.ll) << F_D_BITOFF);
1.4981 ++}
1.4982 ++#endif /* L_sf_to_df */
1.4983 ++
1.4984 ++#if defined(L_sf_to_tf) && defined(TMODES)
1.4985 ++TFtype
1.4986 ++sf_to_tf (SFtype arg_a)
1.4987 ++{
1.4988 ++ fp_number_type in;
1.4989 ++ FLO_union_type au;
1.4990 ++
1.4991 ++ au.value = arg_a;
1.4992 ++ unpack_d (&au, &in);
1.4993 ++
1.4994 ++ return __make_tp (in.class, in.sign, in.normal_exp,
1.4995 ++ ((UTItype) in.fraction.ll) << F_T_BITOFF);
1.4996 ++}
1.4997 ++#endif /* L_sf_to_df */
1.4998 ++
1.4999 ++#endif /* ! FLOAT_ONLY */
1.5000 ++#endif /* FLOAT */
1.5001 ++
1.5002 ++#ifndef FLOAT
1.5003 ++
1.5004 ++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
1.5005 ++
1.5006 ++#if defined(L_make_df)
1.5007 ++DFtype
1.5008 ++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
1.5009 ++{
1.5010 ++ fp_number_type in;
1.5011 ++
1.5012 ++ in.class = class;
1.5013 ++ in.sign = sign;
1.5014 ++ in.normal_exp = exp;
1.5015 ++ in.fraction.ll = frac;
1.5016 ++ return pack_d (&in);
1.5017 ++}
1.5018 ++#endif /* L_make_df */
1.5019 ++
1.5020 ++#if defined(L_df_to_sf)
1.5021 ++SFtype
1.5022 ++df_to_sf (DFtype arg_a)
1.5023 ++{
1.5024 ++ fp_number_type in;
1.5025 ++ USItype sffrac;
1.5026 ++ FLO_union_type au;
1.5027 ++
1.5028 ++ au.value = arg_a;
1.5029 ++ unpack_d (&au, &in);
1.5030 ++
1.5031 ++ sffrac = in.fraction.ll >> F_D_BITOFF;
1.5032 ++
1.5033 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.5034 ++ zero bits. */
1.5035 ++ if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
1.5036 ++ sffrac |= 1;
1.5037 ++
1.5038 ++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
1.5039 ++}
1.5040 ++#endif /* L_df_to_sf */
1.5041 ++
1.5042 ++#if defined(L_df_to_tf) && defined(TMODES) \
1.5043 ++ && !defined(FLOAT) && !defined(TFLOAT)
1.5044 ++TFtype
1.5045 ++df_to_tf (DFtype arg_a)
1.5046 ++{
1.5047 ++ fp_number_type in;
1.5048 ++ FLO_union_type au;
1.5049 ++
1.5050 ++ au.value = arg_a;
1.5051 ++ unpack_d (&au, &in);
1.5052 ++
1.5053 ++ return __make_tp (in.class, in.sign, in.normal_exp,
1.5054 ++ ((UTItype) in.fraction.ll) << D_T_BITOFF);
1.5055 ++}
1.5056 ++#endif /* L_sf_to_df */
1.5057 ++
1.5058 ++#ifdef TFLOAT
1.5059 ++#if defined(L_make_tf)
1.5060 ++TFtype
1.5061 ++__make_tp(fp_class_type class,
1.5062 ++ unsigned int sign,
1.5063 ++ int exp,
1.5064 ++ UTItype frac)
1.5065 ++{
1.5066 ++ fp_number_type in;
1.5067 ++
1.5068 ++ in.class = class;
1.5069 ++ in.sign = sign;
1.5070 ++ in.normal_exp = exp;
1.5071 ++ in.fraction.ll = frac;
1.5072 ++ return pack_d (&in);
1.5073 ++}
1.5074 ++#endif /* L_make_tf */
1.5075 ++
1.5076 ++#if defined(L_tf_to_df)
1.5077 ++DFtype
1.5078 ++tf_to_df (TFtype arg_a)
1.5079 ++{
1.5080 ++ fp_number_type in;
1.5081 ++ UDItype sffrac;
1.5082 ++ FLO_union_type au;
1.5083 ++
1.5084 ++ au.value = arg_a;
1.5085 ++ unpack_d (&au, &in);
1.5086 ++
1.5087 ++ sffrac = in.fraction.ll >> D_T_BITOFF;
1.5088 ++
1.5089 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.5090 ++ zero bits. */
1.5091 ++ if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
1.5092 ++ sffrac |= 1;
1.5093 ++
1.5094 ++ return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
1.5095 ++}
1.5096 ++#endif /* L_tf_to_df */
1.5097 ++
1.5098 ++#if defined(L_tf_to_sf)
1.5099 ++SFtype
1.5100 ++tf_to_sf (TFtype arg_a)
1.5101 ++{
1.5102 ++ fp_number_type in;
1.5103 ++ USItype sffrac;
1.5104 ++ FLO_union_type au;
1.5105 ++
1.5106 ++ au.value = arg_a;
1.5107 ++ unpack_d (&au, &in);
1.5108 ++
1.5109 ++ sffrac = in.fraction.ll >> F_T_BITOFF;
1.5110 ++
1.5111 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.5112 ++ zero bits. */
1.5113 ++ if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
1.5114 ++ sffrac |= 1;
1.5115 ++
1.5116 ++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
1.5117 ++}
1.5118 ++#endif /* L_tf_to_sf */
1.5119 ++#endif /* TFLOAT */
1.5120 ++
1.5121 ++#endif /* ! FLOAT */
1.5122 ++#endif /* !EXTENDED_FLOAT_STUBS */
1.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
1.5124 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-fp-bit.c 1970-01-01 01:00:00.000000000 +0100
1.5125 ++++ gcc-3.4.6/gcc/config/nios2/nios2-fp-bit.c 2007-08-15 23:09:36.000000000 +0200
1.5126 +@@ -0,0 +1,1652 @@
1.5127 ++#define FLOAT
1.5128 ++/* This is a software floating point library which can be used
1.5129 ++ for targets without hardware floating point.
1.5130 ++ Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
1.5131 ++ Free Software Foundation, Inc.
1.5132 ++
1.5133 ++This file is free software; you can redistribute it and/or modify it
1.5134 ++under the terms of the GNU General Public License as published by the
1.5135 ++Free Software Foundation; either version 2, or (at your option) any
1.5136 ++later version.
1.5137 ++
1.5138 ++In addition to the permissions in the GNU General Public License, the
1.5139 ++Free Software Foundation gives you unlimited permission to link the
1.5140 ++compiled version of this file with other programs, and to distribute
1.5141 ++those programs without any restriction coming from the use of this
1.5142 ++file. (The General Public License restrictions do apply in other
1.5143 ++respects; for example, they cover modification of the file, and
1.5144 ++distribution when not linked into another program.)
1.5145 ++
1.5146 ++This file is distributed in the hope that it will be useful, but
1.5147 ++WITHOUT ANY WARRANTY; without even the implied warranty of
1.5148 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.5149 ++General Public License for more details.
1.5150 ++
1.5151 ++You should have received a copy of the GNU General Public License
1.5152 ++along with this program; see the file COPYING. If not, write to
1.5153 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.5154 ++Boston, MA 02111-1307, USA. */
1.5155 ++
1.5156 ++/* As a special exception, if you link this library with other files,
1.5157 ++ some of which are compiled with GCC, to produce an executable,
1.5158 ++ this library does not by itself cause the resulting executable
1.5159 ++ to be covered by the GNU General Public License.
1.5160 ++ This exception does not however invalidate any other reasons why
1.5161 ++ the executable file might be covered by the GNU General Public License. */
1.5162 ++
1.5163 ++/* This implements IEEE 754 format arithmetic, but does not provide a
1.5164 ++ mechanism for setting the rounding mode, or for generating or handling
1.5165 ++ exceptions.
1.5166 ++
1.5167 ++ The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
1.5168 ++ Wilson, all of Cygnus Support. */
1.5169 ++
1.5170 ++/* The intended way to use this file is to make two copies, add `#define FLOAT'
1.5171 ++ to one copy, then compile both copies and add them to libgcc.a. */
1.5172 ++
1.5173 ++#include "tconfig.h"
1.5174 ++#include "coretypes.h"
1.5175 ++#include "tm.h"
1.5176 ++#include "config/fp-bit.h"
1.5177 ++
1.5178 ++/* The following macros can be defined to change the behavior of this file:
1.5179 ++ FLOAT: Implement a `float', aka SFmode, fp library. If this is not
1.5180 ++ defined, then this file implements a `double', aka DFmode, fp library.
1.5181 ++ FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
1.5182 ++ don't include float->double conversion which requires the double library.
1.5183 ++ This is useful only for machines which can't support doubles, e.g. some
1.5184 ++ 8-bit processors.
1.5185 ++ CMPtype: Specify the type that floating point compares should return.
1.5186 ++ This defaults to SItype, aka int.
1.5187 ++ US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
1.5188 ++ US Software goFast library.
1.5189 ++ _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
1.5190 ++ two integers to the FLO_union_type.
1.5191 ++ NO_DENORMALS: Disable handling of denormals.
1.5192 ++ NO_NANS: Disable nan and infinity handling
1.5193 ++ SMALL_MACHINE: Useful when operations on QIs and HIs are faster
1.5194 ++ than on an SI */
1.5195 ++
1.5196 ++/* We don't currently support extended floats (long doubles) on machines
1.5197 ++ without hardware to deal with them.
1.5198 ++
1.5199 ++ These stubs are just to keep the linker from complaining about unresolved
1.5200 ++ references which can be pulled in from libio & libstdc++, even if the
1.5201 ++ user isn't using long doubles. However, they may generate an unresolved
1.5202 ++ external to abort if abort is not used by the function, and the stubs
1.5203 ++ are referenced from within libc, since libgcc goes before and after the
1.5204 ++ system library. */
1.5205 ++
1.5206 ++#ifdef DECLARE_LIBRARY_RENAMES
1.5207 ++ DECLARE_LIBRARY_RENAMES
1.5208 ++#endif
1.5209 ++
1.5210 ++#ifdef EXTENDED_FLOAT_STUBS
1.5211 ++extern void abort (void);
1.5212 ++void __extendsfxf2 (void) { abort(); }
1.5213 ++void __extenddfxf2 (void) { abort(); }
1.5214 ++void __truncxfdf2 (void) { abort(); }
1.5215 ++void __truncxfsf2 (void) { abort(); }
1.5216 ++void __fixxfsi (void) { abort(); }
1.5217 ++void __floatsixf (void) { abort(); }
1.5218 ++void __addxf3 (void) { abort(); }
1.5219 ++void __subxf3 (void) { abort(); }
1.5220 ++void __mulxf3 (void) { abort(); }
1.5221 ++void __divxf3 (void) { abort(); }
1.5222 ++void __negxf2 (void) { abort(); }
1.5223 ++void __eqxf2 (void) { abort(); }
1.5224 ++void __nexf2 (void) { abort(); }
1.5225 ++void __gtxf2 (void) { abort(); }
1.5226 ++void __gexf2 (void) { abort(); }
1.5227 ++void __lexf2 (void) { abort(); }
1.5228 ++void __ltxf2 (void) { abort(); }
1.5229 ++
1.5230 ++void __extendsftf2 (void) { abort(); }
1.5231 ++void __extenddftf2 (void) { abort(); }
1.5232 ++void __trunctfdf2 (void) { abort(); }
1.5233 ++void __trunctfsf2 (void) { abort(); }
1.5234 ++void __fixtfsi (void) { abort(); }
1.5235 ++void __floatsitf (void) { abort(); }
1.5236 ++void __addtf3 (void) { abort(); }
1.5237 ++void __subtf3 (void) { abort(); }
1.5238 ++void __multf3 (void) { abort(); }
1.5239 ++void __divtf3 (void) { abort(); }
1.5240 ++void __negtf2 (void) { abort(); }
1.5241 ++void __eqtf2 (void) { abort(); }
1.5242 ++void __netf2 (void) { abort(); }
1.5243 ++void __gttf2 (void) { abort(); }
1.5244 ++void __getf2 (void) { abort(); }
1.5245 ++void __letf2 (void) { abort(); }
1.5246 ++void __lttf2 (void) { abort(); }
1.5247 ++#else /* !EXTENDED_FLOAT_STUBS, rest of file */
1.5248 ++
1.5249 ++/* IEEE "special" number predicates */
1.5250 ++
1.5251 ++#ifdef NO_NANS
1.5252 ++
1.5253 ++#define nan() 0
1.5254 ++#define isnan(x) 0
1.5255 ++#define isinf(x) 0
1.5256 ++#else
1.5257 ++
1.5258 ++#if defined L_thenan_sf
1.5259 ++const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.5260 ++#elif defined L_thenan_df
1.5261 ++const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.5262 ++#elif defined L_thenan_tf
1.5263 ++const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
1.5264 ++#elif defined TFLOAT
1.5265 ++extern const fp_number_type __thenan_tf;
1.5266 ++#elif defined FLOAT
1.5267 ++extern const fp_number_type __thenan_sf;
1.5268 ++#else
1.5269 ++extern const fp_number_type __thenan_df;
1.5270 ++#endif
1.5271 ++
1.5272 ++INLINE
1.5273 ++static fp_number_type *
1.5274 ++nan (void)
1.5275 ++{
1.5276 ++ /* Discard the const qualifier... */
1.5277 ++#ifdef TFLOAT
1.5278 ++ return (fp_number_type *) (& __thenan_tf);
1.5279 ++#elif defined FLOAT
1.5280 ++ return (fp_number_type *) (& __thenan_sf);
1.5281 ++#else
1.5282 ++ return (fp_number_type *) (& __thenan_df);
1.5283 ++#endif
1.5284 ++}
1.5285 ++
1.5286 ++INLINE
1.5287 ++static int
1.5288 ++isnan ( fp_number_type * x)
1.5289 ++{
1.5290 ++ return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
1.5291 ++}
1.5292 ++
1.5293 ++INLINE
1.5294 ++static int
1.5295 ++isinf ( fp_number_type * x)
1.5296 ++{
1.5297 ++ return x->class == CLASS_INFINITY;
1.5298 ++}
1.5299 ++
1.5300 ++#endif /* NO_NANS */
1.5301 ++
1.5302 ++INLINE
1.5303 ++static int
1.5304 ++iszero ( fp_number_type * x)
1.5305 ++{
1.5306 ++ return x->class == CLASS_ZERO;
1.5307 ++}
1.5308 ++
1.5309 ++INLINE
1.5310 ++static void
1.5311 ++flip_sign ( fp_number_type * x)
1.5312 ++{
1.5313 ++ x->sign = !x->sign;
1.5314 ++}
1.5315 ++
1.5316 ++extern FLO_type pack_d ( fp_number_type * );
1.5317 ++
1.5318 ++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
1.5319 ++FLO_type
1.5320 ++pack_d ( fp_number_type * src)
1.5321 ++{
1.5322 ++ FLO_union_type dst;
1.5323 ++ fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
1.5324 ++ int sign = src->sign;
1.5325 ++ int exp = 0;
1.5326 ++
1.5327 ++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
1.5328 ++ {
1.5329 ++ /* We can't represent these values accurately. By using the
1.5330 ++ largest possible magnitude, we guarantee that the conversion
1.5331 ++ of infinity is at least as big as any finite number. */
1.5332 ++ exp = EXPMAX;
1.5333 ++ fraction = ((fractype) 1 << FRACBITS) - 1;
1.5334 ++ }
1.5335 ++ else if (isnan (src))
1.5336 ++ {
1.5337 ++ exp = EXPMAX;
1.5338 ++ if (src->class == CLASS_QNAN || 1)
1.5339 ++ {
1.5340 ++#ifdef QUIET_NAN_NEGATED
1.5341 ++ fraction |= QUIET_NAN - 1;
1.5342 ++#else
1.5343 ++ fraction |= QUIET_NAN;
1.5344 ++#endif
1.5345 ++ }
1.5346 ++ }
1.5347 ++ else if (isinf (src))
1.5348 ++ {
1.5349 ++ exp = EXPMAX;
1.5350 ++ fraction = 0;
1.5351 ++ }
1.5352 ++ else if (iszero (src))
1.5353 ++ {
1.5354 ++ exp = 0;
1.5355 ++ fraction = 0;
1.5356 ++ }
1.5357 ++ else if (fraction == 0)
1.5358 ++ {
1.5359 ++ exp = 0;
1.5360 ++ }
1.5361 ++ else
1.5362 ++ {
1.5363 ++ if (src->normal_exp < NORMAL_EXPMIN)
1.5364 ++ {
1.5365 ++#ifdef NO_DENORMALS
1.5366 ++ /* Go straight to a zero representation if denormals are not
1.5367 ++ supported. The denormal handling would be harmless but
1.5368 ++ isn't unnecessary. */
1.5369 ++ exp = 0;
1.5370 ++ fraction = 0;
1.5371 ++#else /* NO_DENORMALS */
1.5372 ++ /* This number's exponent is too low to fit into the bits
1.5373 ++ available in the number, so we'll store 0 in the exponent and
1.5374 ++ shift the fraction to the right to make up for it. */
1.5375 ++
1.5376 ++ int shift = NORMAL_EXPMIN - src->normal_exp;
1.5377 ++
1.5378 ++ exp = 0;
1.5379 ++
1.5380 ++ if (shift > FRAC_NBITS - NGARDS)
1.5381 ++ {
1.5382 ++ /* No point shifting, since it's more that 64 out. */
1.5383 ++ fraction = 0;
1.5384 ++ }
1.5385 ++ else
1.5386 ++ {
1.5387 ++ int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
1.5388 ++ fraction = (fraction >> shift) | lowbit;
1.5389 ++ }
1.5390 ++ if ((fraction & GARDMASK) == GARDMSB)
1.5391 ++ {
1.5392 ++ if ((fraction & (1 << NGARDS)))
1.5393 ++ fraction += GARDROUND + 1;
1.5394 ++ }
1.5395 ++ else
1.5396 ++ {
1.5397 ++ /* Add to the guards to round up. */
1.5398 ++ fraction += GARDROUND;
1.5399 ++ }
1.5400 ++ /* Perhaps the rounding means we now need to change the
1.5401 ++ exponent, because the fraction is no longer denormal. */
1.5402 ++ if (fraction >= IMPLICIT_1)
1.5403 ++ {
1.5404 ++ exp += 1;
1.5405 ++ }
1.5406 ++ fraction >>= NGARDS;
1.5407 ++#endif /* NO_DENORMALS */
1.5408 ++ }
1.5409 ++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
1.5410 ++ && src->normal_exp > EXPBIAS)
1.5411 ++ {
1.5412 ++ exp = EXPMAX;
1.5413 ++ fraction = 0;
1.5414 ++ }
1.5415 ++ else
1.5416 ++ {
1.5417 ++ exp = src->normal_exp + EXPBIAS;
1.5418 ++ if (!ROUND_TOWARDS_ZERO)
1.5419 ++ {
1.5420 ++ /* IF the gard bits are the all zero, but the first, then we're
1.5421 ++ half way between two numbers, choose the one which makes the
1.5422 ++ lsb of the answer 0. */
1.5423 ++ if ((fraction & GARDMASK) == GARDMSB)
1.5424 ++ {
1.5425 ++ if (fraction & (1 << NGARDS))
1.5426 ++ fraction += GARDROUND + 1;
1.5427 ++ }
1.5428 ++ else
1.5429 ++ {
1.5430 ++ /* Add a one to the guards to round up */
1.5431 ++ fraction += GARDROUND;
1.5432 ++ }
1.5433 ++ if (fraction >= IMPLICIT_2)
1.5434 ++ {
1.5435 ++ fraction >>= 1;
1.5436 ++ exp += 1;
1.5437 ++ }
1.5438 ++ }
1.5439 ++ fraction >>= NGARDS;
1.5440 ++
1.5441 ++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
1.5442 ++ {
1.5443 ++ /* Saturate on overflow. */
1.5444 ++ exp = EXPMAX;
1.5445 ++ fraction = ((fractype) 1 << FRACBITS) - 1;
1.5446 ++ }
1.5447 ++ }
1.5448 ++ }
1.5449 ++
1.5450 ++ /* We previously used bitfields to store the number, but this doesn't
1.5451 ++ handle little/big endian systems conveniently, so use shifts and
1.5452 ++ masks */
1.5453 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
1.5454 ++ dst.bits.fraction = fraction;
1.5455 ++ dst.bits.exp = exp;
1.5456 ++ dst.bits.sign = sign;
1.5457 ++#else
1.5458 ++# if defined TFLOAT && defined HALFFRACBITS
1.5459 ++ {
1.5460 ++ halffractype high, low, unity;
1.5461 ++ int lowsign, lowexp;
1.5462 ++
1.5463 ++ unity = (halffractype) 1 << HALFFRACBITS;
1.5464 ++
1.5465 ++ /* Set HIGH to the high double's significand, masking out the implicit 1.
1.5466 ++ Set LOW to the low double's full significand. */
1.5467 ++ high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
1.5468 ++ low = fraction & (unity * 2 - 1);
1.5469 ++
1.5470 ++ /* Get the initial sign and exponent of the low double. */
1.5471 ++ lowexp = exp - HALFFRACBITS - 1;
1.5472 ++ lowsign = sign;
1.5473 ++
1.5474 ++ /* HIGH should be rounded like a normal double, making |LOW| <=
1.5475 ++ 0.5 ULP of HIGH. Assume round-to-nearest. */
1.5476 ++ if (exp < EXPMAX)
1.5477 ++ if (low > unity || (low == unity && (high & 1) == 1))
1.5478 ++ {
1.5479 ++ /* Round HIGH up and adjust LOW to match. */
1.5480 ++ high++;
1.5481 ++ if (high == unity)
1.5482 ++ {
1.5483 ++ /* May make it infinite, but that's OK. */
1.5484 ++ high = 0;
1.5485 ++ exp++;
1.5486 ++ }
1.5487 ++ low = unity * 2 - low;
1.5488 ++ lowsign ^= 1;
1.5489 ++ }
1.5490 ++
1.5491 ++ high |= (halffractype) exp << HALFFRACBITS;
1.5492 ++ high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
1.5493 ++
1.5494 ++ if (exp == EXPMAX || exp == 0 || low == 0)
1.5495 ++ low = 0;
1.5496 ++ else
1.5497 ++ {
1.5498 ++ while (lowexp > 0 && low < unity)
1.5499 ++ {
1.5500 ++ low <<= 1;
1.5501 ++ lowexp--;
1.5502 ++ }
1.5503 ++
1.5504 ++ if (lowexp <= 0)
1.5505 ++ {
1.5506 ++ halffractype roundmsb, round;
1.5507 ++ int shift;
1.5508 ++
1.5509 ++ shift = 1 - lowexp;
1.5510 ++ roundmsb = (1 << (shift - 1));
1.5511 ++ round = low & ((roundmsb << 1) - 1);
1.5512 ++
1.5513 ++ low >>= shift;
1.5514 ++ lowexp = 0;
1.5515 ++
1.5516 ++ if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
1.5517 ++ {
1.5518 ++ low++;
1.5519 ++ if (low == unity)
1.5520 ++ /* LOW rounds up to the smallest normal number. */
1.5521 ++ lowexp++;
1.5522 ++ }
1.5523 ++ }
1.5524 ++
1.5525 ++ low &= unity - 1;
1.5526 ++ low |= (halffractype) lowexp << HALFFRACBITS;
1.5527 ++ low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
1.5528 ++ }
1.5529 ++ dst.value_raw = ((fractype) high << HALFSHIFT) | low;
1.5530 ++ }
1.5531 ++# else
1.5532 ++ dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
1.5533 ++ dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
1.5534 ++ dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
1.5535 ++# endif
1.5536 ++#endif
1.5537 ++
1.5538 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
1.5539 ++#ifdef TFLOAT
1.5540 ++ {
1.5541 ++ qrtrfractype tmp1 = dst.words[0];
1.5542 ++ qrtrfractype tmp2 = dst.words[1];
1.5543 ++ dst.words[0] = dst.words[3];
1.5544 ++ dst.words[1] = dst.words[2];
1.5545 ++ dst.words[2] = tmp2;
1.5546 ++ dst.words[3] = tmp1;
1.5547 ++ }
1.5548 ++#else
1.5549 ++ {
1.5550 ++ halffractype tmp = dst.words[0];
1.5551 ++ dst.words[0] = dst.words[1];
1.5552 ++ dst.words[1] = tmp;
1.5553 ++ }
1.5554 ++#endif
1.5555 ++#endif
1.5556 ++
1.5557 ++ return dst.value;
1.5558 ++}
1.5559 ++#endif
1.5560 ++
1.5561 ++#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
1.5562 ++void
1.5563 ++unpack_d (FLO_union_type * src, fp_number_type * dst)
1.5564 ++{
1.5565 ++ /* We previously used bitfields to store the number, but this doesn't
1.5566 ++ handle little/big endian systems conveniently, so use shifts and
1.5567 ++ masks */
1.5568 ++ fractype fraction;
1.5569 ++ int exp;
1.5570 ++ int sign;
1.5571 ++
1.5572 ++#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
1.5573 ++ FLO_union_type swapped;
1.5574 ++
1.5575 ++#ifdef TFLOAT
1.5576 ++ swapped.words[0] = src->words[3];
1.5577 ++ swapped.words[1] = src->words[2];
1.5578 ++ swapped.words[2] = src->words[1];
1.5579 ++ swapped.words[3] = src->words[0];
1.5580 ++#else
1.5581 ++ swapped.words[0] = src->words[1];
1.5582 ++ swapped.words[1] = src->words[0];
1.5583 ++#endif
1.5584 ++ src = &swapped;
1.5585 ++#endif
1.5586 ++
1.5587 ++#ifdef FLOAT_BIT_ORDER_MISMATCH
1.5588 ++ fraction = src->bits.fraction;
1.5589 ++ exp = src->bits.exp;
1.5590 ++ sign = src->bits.sign;
1.5591 ++#else
1.5592 ++# if defined TFLOAT && defined HALFFRACBITS
1.5593 ++ {
1.5594 ++ halffractype high, low;
1.5595 ++
1.5596 ++ high = src->value_raw >> HALFSHIFT;
1.5597 ++ low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
1.5598 ++
1.5599 ++ fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
1.5600 ++ fraction <<= FRACBITS - HALFFRACBITS;
1.5601 ++ exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1.5602 ++ sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
1.5603 ++
1.5604 ++ if (exp != EXPMAX && exp != 0 && low != 0)
1.5605 ++ {
1.5606 ++ int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1.5607 ++ int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
1.5608 ++ int shift;
1.5609 ++ fractype xlow;
1.5610 ++
1.5611 ++ xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
1.5612 ++ if (lowexp)
1.5613 ++ xlow |= (((halffractype)1) << HALFFRACBITS);
1.5614 ++ else
1.5615 ++ lowexp = 1;
1.5616 ++ shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
1.5617 ++ if (shift > 0)
1.5618 ++ xlow <<= shift;
1.5619 ++ else if (shift < 0)
1.5620 ++ xlow >>= -shift;
1.5621 ++ if (sign == lowsign)
1.5622 ++ fraction += xlow;
1.5623 ++ else if (fraction >= xlow)
1.5624 ++ fraction -= xlow;
1.5625 ++ else
1.5626 ++ {
1.5627 ++ /* The high part is a power of two but the full number is lower.
1.5628 ++ This code will leave the implicit 1 in FRACTION, but we'd
1.5629 ++ have added that below anyway. */
1.5630 ++ fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
1.5631 ++ exp--;
1.5632 ++ }
1.5633 ++ }
1.5634 ++ }
1.5635 ++# else
1.5636 ++ fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
1.5637 ++ exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
1.5638 ++ sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
1.5639 ++# endif
1.5640 ++#endif
1.5641 ++
1.5642 ++ dst->sign = sign;
1.5643 ++ if (exp == 0)
1.5644 ++ {
1.5645 ++ /* Hmm. Looks like 0 */
1.5646 ++ if (fraction == 0
1.5647 ++#ifdef NO_DENORMALS
1.5648 ++ || 1
1.5649 ++#endif
1.5650 ++ )
1.5651 ++ {
1.5652 ++ /* tastes like zero */
1.5653 ++ dst->class = CLASS_ZERO;
1.5654 ++ }
1.5655 ++ else
1.5656 ++ {
1.5657 ++ /* Zero exponent with nonzero fraction - it's denormalized,
1.5658 ++ so there isn't a leading implicit one - we'll shift it so
1.5659 ++ it gets one. */
1.5660 ++ dst->normal_exp = exp - EXPBIAS + 1;
1.5661 ++ fraction <<= NGARDS;
1.5662 ++
1.5663 ++ dst->class = CLASS_NUMBER;
1.5664 ++#if 1
1.5665 ++ while (fraction < IMPLICIT_1)
1.5666 ++ {
1.5667 ++ fraction <<= 1;
1.5668 ++ dst->normal_exp--;
1.5669 ++ }
1.5670 ++#endif
1.5671 ++ dst->fraction.ll = fraction;
1.5672 ++ }
1.5673 ++ }
1.5674 ++ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
1.5675 ++ {
1.5676 ++ /* Huge exponent*/
1.5677 ++ if (fraction == 0)
1.5678 ++ {
1.5679 ++ /* Attached to a zero fraction - means infinity */
1.5680 ++ dst->class = CLASS_INFINITY;
1.5681 ++ }
1.5682 ++ else
1.5683 ++ {
1.5684 ++ /* Nonzero fraction, means nan */
1.5685 ++#ifdef QUIET_NAN_NEGATED
1.5686 ++ if ((fraction & QUIET_NAN) == 0)
1.5687 ++#else
1.5688 ++ if (fraction & QUIET_NAN)
1.5689 ++#endif
1.5690 ++ {
1.5691 ++ dst->class = CLASS_QNAN;
1.5692 ++ }
1.5693 ++ else
1.5694 ++ {
1.5695 ++ dst->class = CLASS_SNAN;
1.5696 ++ }
1.5697 ++ /* Keep the fraction part as the nan number */
1.5698 ++ dst->fraction.ll = fraction;
1.5699 ++ }
1.5700 ++ }
1.5701 ++ else
1.5702 ++ {
1.5703 ++ /* Nothing strange about this number */
1.5704 ++ dst->normal_exp = exp - EXPBIAS;
1.5705 ++ dst->class = CLASS_NUMBER;
1.5706 ++ dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
1.5707 ++ }
1.5708 ++}
1.5709 ++#endif /* L_unpack_df || L_unpack_sf */
1.5710 ++
1.5711 ++#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
1.5712 ++static fp_number_type *
1.5713 ++_fpadd_parts (fp_number_type * a,
1.5714 ++ fp_number_type * b,
1.5715 ++ fp_number_type * tmp)
1.5716 ++{
1.5717 ++ intfrac tfraction;
1.5718 ++
1.5719 ++ /* Put commonly used fields in local variables. */
1.5720 ++ int a_normal_exp;
1.5721 ++ int b_normal_exp;
1.5722 ++ fractype a_fraction;
1.5723 ++ fractype b_fraction;
1.5724 ++
1.5725 ++ if (isnan (a))
1.5726 ++ {
1.5727 ++ return a;
1.5728 ++ }
1.5729 ++ if (isnan (b))
1.5730 ++ {
1.5731 ++ return b;
1.5732 ++ }
1.5733 ++ if (isinf (a))
1.5734 ++ {
1.5735 ++ /* Adding infinities with opposite signs yields a NaN. */
1.5736 ++ if (isinf (b) && a->sign != b->sign)
1.5737 ++ return nan ();
1.5738 ++ return a;
1.5739 ++ }
1.5740 ++ if (isinf (b))
1.5741 ++ {
1.5742 ++ return b;
1.5743 ++ }
1.5744 ++ if (iszero (b))
1.5745 ++ {
1.5746 ++ if (iszero (a))
1.5747 ++ {
1.5748 ++ *tmp = *a;
1.5749 ++ tmp->sign = a->sign & b->sign;
1.5750 ++ return tmp;
1.5751 ++ }
1.5752 ++ return a;
1.5753 ++ }
1.5754 ++ if (iszero (a))
1.5755 ++ {
1.5756 ++ return b;
1.5757 ++ }
1.5758 ++
1.5759 ++ /* Got two numbers. shift the smaller and increment the exponent till
1.5760 ++ they're the same */
1.5761 ++ {
1.5762 ++ int diff;
1.5763 ++
1.5764 ++ a_normal_exp = a->normal_exp;
1.5765 ++ b_normal_exp = b->normal_exp;
1.5766 ++ a_fraction = a->fraction.ll;
1.5767 ++ b_fraction = b->fraction.ll;
1.5768 ++
1.5769 ++ diff = a_normal_exp - b_normal_exp;
1.5770 ++
1.5771 ++ if (diff < 0)
1.5772 ++ diff = -diff;
1.5773 ++ if (diff < FRAC_NBITS)
1.5774 ++ {
1.5775 ++ /* ??? This does shifts one bit at a time. Optimize. */
1.5776 ++ while (a_normal_exp > b_normal_exp)
1.5777 ++ {
1.5778 ++ b_normal_exp++;
1.5779 ++ LSHIFT (b_fraction);
1.5780 ++ }
1.5781 ++ while (b_normal_exp > a_normal_exp)
1.5782 ++ {
1.5783 ++ a_normal_exp++;
1.5784 ++ LSHIFT (a_fraction);
1.5785 ++ }
1.5786 ++ }
1.5787 ++ else
1.5788 ++ {
1.5789 ++ /* Somethings's up.. choose the biggest */
1.5790 ++ if (a_normal_exp > b_normal_exp)
1.5791 ++ {
1.5792 ++ b_normal_exp = a_normal_exp;
1.5793 ++ b_fraction = 0;
1.5794 ++ }
1.5795 ++ else
1.5796 ++ {
1.5797 ++ a_normal_exp = b_normal_exp;
1.5798 ++ a_fraction = 0;
1.5799 ++ }
1.5800 ++ }
1.5801 ++ }
1.5802 ++
1.5803 ++ if (a->sign != b->sign)
1.5804 ++ {
1.5805 ++ if (a->sign)
1.5806 ++ {
1.5807 ++ tfraction = -a_fraction + b_fraction;
1.5808 ++ }
1.5809 ++ else
1.5810 ++ {
1.5811 ++ tfraction = a_fraction - b_fraction;
1.5812 ++ }
1.5813 ++ if (tfraction >= 0)
1.5814 ++ {
1.5815 ++ tmp->sign = 0;
1.5816 ++ tmp->normal_exp = a_normal_exp;
1.5817 ++ tmp->fraction.ll = tfraction;
1.5818 ++ }
1.5819 ++ else
1.5820 ++ {
1.5821 ++ tmp->sign = 1;
1.5822 ++ tmp->normal_exp = a_normal_exp;
1.5823 ++ tmp->fraction.ll = -tfraction;
1.5824 ++ }
1.5825 ++ /* and renormalize it */
1.5826 ++
1.5827 ++ while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
1.5828 ++ {
1.5829 ++ tmp->fraction.ll <<= 1;
1.5830 ++ tmp->normal_exp--;
1.5831 ++ }
1.5832 ++ }
1.5833 ++ else
1.5834 ++ {
1.5835 ++ tmp->sign = a->sign;
1.5836 ++ tmp->normal_exp = a_normal_exp;
1.5837 ++ tmp->fraction.ll = a_fraction + b_fraction;
1.5838 ++ }
1.5839 ++ tmp->class = CLASS_NUMBER;
1.5840 ++ /* Now the fraction is added, we have to shift down to renormalize the
1.5841 ++ number */
1.5842 ++
1.5843 ++ if (tmp->fraction.ll >= IMPLICIT_2)
1.5844 ++ {
1.5845 ++ LSHIFT (tmp->fraction.ll);
1.5846 ++ tmp->normal_exp++;
1.5847 ++ }
1.5848 ++ return tmp;
1.5849 ++
1.5850 ++}
1.5851 ++
1.5852 ++FLO_type
1.5853 ++add (FLO_type arg_a, FLO_type arg_b)
1.5854 ++{
1.5855 ++ fp_number_type a;
1.5856 ++ fp_number_type b;
1.5857 ++ fp_number_type tmp;
1.5858 ++ fp_number_type *res;
1.5859 ++ FLO_union_type au, bu;
1.5860 ++
1.5861 ++ au.value = arg_a;
1.5862 ++ bu.value = arg_b;
1.5863 ++
1.5864 ++ unpack_d (&au, &a);
1.5865 ++ unpack_d (&bu, &b);
1.5866 ++
1.5867 ++ res = _fpadd_parts (&a, &b, &tmp);
1.5868 ++
1.5869 ++ return pack_d (res);
1.5870 ++}
1.5871 ++
1.5872 ++FLO_type
1.5873 ++sub (FLO_type arg_a, FLO_type arg_b)
1.5874 ++{
1.5875 ++ fp_number_type a;
1.5876 ++ fp_number_type b;
1.5877 ++ fp_number_type tmp;
1.5878 ++ fp_number_type *res;
1.5879 ++ FLO_union_type au, bu;
1.5880 ++
1.5881 ++ au.value = arg_a;
1.5882 ++ bu.value = arg_b;
1.5883 ++
1.5884 ++ unpack_d (&au, &a);
1.5885 ++ unpack_d (&bu, &b);
1.5886 ++
1.5887 ++ b.sign ^= 1;
1.5888 ++
1.5889 ++ res = _fpadd_parts (&a, &b, &tmp);
1.5890 ++
1.5891 ++ return pack_d (res);
1.5892 ++}
1.5893 ++#endif /* L_addsub_sf || L_addsub_df */
1.5894 ++
1.5895 ++#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
1.5896 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
1.5897 ++_fpmul_parts ( fp_number_type * a,
1.5898 ++ fp_number_type * b,
1.5899 ++ fp_number_type * tmp)
1.5900 ++{
1.5901 ++ fractype low = 0;
1.5902 ++ fractype high = 0;
1.5903 ++
1.5904 ++ if (isnan (a))
1.5905 ++ {
1.5906 ++ a->sign = a->sign != b->sign;
1.5907 ++ return a;
1.5908 ++ }
1.5909 ++ if (isnan (b))
1.5910 ++ {
1.5911 ++ b->sign = a->sign != b->sign;
1.5912 ++ return b;
1.5913 ++ }
1.5914 ++ if (isinf (a))
1.5915 ++ {
1.5916 ++ if (iszero (b))
1.5917 ++ return nan ();
1.5918 ++ a->sign = a->sign != b->sign;
1.5919 ++ return a;
1.5920 ++ }
1.5921 ++ if (isinf (b))
1.5922 ++ {
1.5923 ++ if (iszero (a))
1.5924 ++ {
1.5925 ++ return nan ();
1.5926 ++ }
1.5927 ++ b->sign = a->sign != b->sign;
1.5928 ++ return b;
1.5929 ++ }
1.5930 ++ if (iszero (a))
1.5931 ++ {
1.5932 ++ a->sign = a->sign != b->sign;
1.5933 ++ return a;
1.5934 ++ }
1.5935 ++ if (iszero (b))
1.5936 ++ {
1.5937 ++ b->sign = a->sign != b->sign;
1.5938 ++ return b;
1.5939 ++ }
1.5940 ++
1.5941 ++ /* Calculate the mantissa by multiplying both numbers to get a
1.5942 ++ twice-as-wide number. */
1.5943 ++ {
1.5944 ++#if defined(NO_DI_MODE) || defined(TFLOAT)
1.5945 ++ {
1.5946 ++ fractype x = a->fraction.ll;
1.5947 ++ fractype ylow = b->fraction.ll;
1.5948 ++ fractype yhigh = 0;
1.5949 ++ int bit;
1.5950 ++
1.5951 ++ /* ??? This does multiplies one bit at a time. Optimize. */
1.5952 ++ for (bit = 0; bit < FRAC_NBITS; bit++)
1.5953 ++ {
1.5954 ++ int carry;
1.5955 ++
1.5956 ++ if (x & 1)
1.5957 ++ {
1.5958 ++ carry = (low += ylow) < ylow;
1.5959 ++ high += yhigh + carry;
1.5960 ++ }
1.5961 ++ yhigh <<= 1;
1.5962 ++ if (ylow & FRACHIGH)
1.5963 ++ {
1.5964 ++ yhigh |= 1;
1.5965 ++ }
1.5966 ++ ylow <<= 1;
1.5967 ++ x >>= 1;
1.5968 ++ }
1.5969 ++ }
1.5970 ++#elif defined(FLOAT)
1.5971 ++ /* Multiplying two USIs to get a UDI, we're safe. */
1.5972 ++ {
1.5973 ++ UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
1.5974 ++
1.5975 ++ high = answer >> BITS_PER_SI;
1.5976 ++ low = answer;
1.5977 ++ }
1.5978 ++#else
1.5979 ++ /* fractype is DImode, but we need the result to be twice as wide.
1.5980 ++ Assuming a widening multiply from DImode to TImode is not
1.5981 ++ available, build one by hand. */
1.5982 ++ {
1.5983 ++ USItype nl = a->fraction.ll;
1.5984 ++ USItype nh = a->fraction.ll >> BITS_PER_SI;
1.5985 ++ USItype ml = b->fraction.ll;
1.5986 ++ USItype mh = b->fraction.ll >> BITS_PER_SI;
1.5987 ++ UDItype pp_ll = (UDItype) ml * nl;
1.5988 ++ UDItype pp_hl = (UDItype) mh * nl;
1.5989 ++ UDItype pp_lh = (UDItype) ml * nh;
1.5990 ++ UDItype pp_hh = (UDItype) mh * nh;
1.5991 ++ UDItype res2 = 0;
1.5992 ++ UDItype res0 = 0;
1.5993 ++ UDItype ps_hh__ = pp_hl + pp_lh;
1.5994 ++ if (ps_hh__ < pp_hl)
1.5995 ++ res2 += (UDItype)1 << BITS_PER_SI;
1.5996 ++ pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
1.5997 ++ res0 = pp_ll + pp_hl;
1.5998 ++ if (res0 < pp_ll)
1.5999 ++ res2++;
1.6000 ++ res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
1.6001 ++ high = res2;
1.6002 ++ low = res0;
1.6003 ++ }
1.6004 ++#endif
1.6005 ++ }
1.6006 ++
1.6007 ++ tmp->normal_exp = a->normal_exp + b->normal_exp
1.6008 ++ + FRAC_NBITS - (FRACBITS + NGARDS);
1.6009 ++ tmp->sign = a->sign != b->sign;
1.6010 ++ while (high >= IMPLICIT_2)
1.6011 ++ {
1.6012 ++ tmp->normal_exp++;
1.6013 ++ if (high & 1)
1.6014 ++ {
1.6015 ++ low >>= 1;
1.6016 ++ low |= FRACHIGH;
1.6017 ++ }
1.6018 ++ high >>= 1;
1.6019 ++ }
1.6020 ++ while (high < IMPLICIT_1)
1.6021 ++ {
1.6022 ++ tmp->normal_exp--;
1.6023 ++
1.6024 ++ high <<= 1;
1.6025 ++ if (low & FRACHIGH)
1.6026 ++ high |= 1;
1.6027 ++ low <<= 1;
1.6028 ++ }
1.6029 ++ /* rounding is tricky. if we only round if it won't make us round later. */
1.6030 ++#if 0
1.6031 ++ if (low & FRACHIGH2)
1.6032 ++ {
1.6033 ++ if (((high & GARDMASK) != GARDMSB)
1.6034 ++ && (((high + 1) & GARDMASK) == GARDMSB))
1.6035 ++ {
1.6036 ++ /* don't round, it gets done again later. */
1.6037 ++ }
1.6038 ++ else
1.6039 ++ {
1.6040 ++ high++;
1.6041 ++ }
1.6042 ++ }
1.6043 ++#endif
1.6044 ++ if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
1.6045 ++ {
1.6046 ++ if (high & (1 << NGARDS))
1.6047 ++ {
1.6048 ++ /* half way, so round to even */
1.6049 ++ high += GARDROUND + 1;
1.6050 ++ }
1.6051 ++ else if (low)
1.6052 ++ {
1.6053 ++ /* but we really weren't half way */
1.6054 ++ high += GARDROUND + 1;
1.6055 ++ }
1.6056 ++ }
1.6057 ++ tmp->fraction.ll = high;
1.6058 ++ tmp->class = CLASS_NUMBER;
1.6059 ++ return tmp;
1.6060 ++}
1.6061 ++
1.6062 ++FLO_type
1.6063 ++multiply (FLO_type arg_a, FLO_type arg_b)
1.6064 ++{
1.6065 ++ fp_number_type a;
1.6066 ++ fp_number_type b;
1.6067 ++ fp_number_type tmp;
1.6068 ++ fp_number_type *res;
1.6069 ++ FLO_union_type au, bu;
1.6070 ++
1.6071 ++ au.value = arg_a;
1.6072 ++ bu.value = arg_b;
1.6073 ++
1.6074 ++ unpack_d (&au, &a);
1.6075 ++ unpack_d (&bu, &b);
1.6076 ++
1.6077 ++ res = _fpmul_parts (&a, &b, &tmp);
1.6078 ++
1.6079 ++ return pack_d (res);
1.6080 ++}
1.6081 ++#endif /* L_mul_sf || L_mul_df */
1.6082 ++
1.6083 ++#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
1.6084 ++static inline __attribute__ ((__always_inline__)) fp_number_type *
1.6085 ++_fpdiv_parts (fp_number_type * a,
1.6086 ++ fp_number_type * b)
1.6087 ++{
1.6088 ++ fractype bit;
1.6089 ++ fractype numerator;
1.6090 ++ fractype denominator;
1.6091 ++ fractype quotient;
1.6092 ++
1.6093 ++ if (isnan (a))
1.6094 ++ {
1.6095 ++ return a;
1.6096 ++ }
1.6097 ++ if (isnan (b))
1.6098 ++ {
1.6099 ++ return b;
1.6100 ++ }
1.6101 ++
1.6102 ++ a->sign = a->sign ^ b->sign;
1.6103 ++
1.6104 ++ if (isinf (a) || iszero (a))
1.6105 ++ {
1.6106 ++ if (a->class == b->class)
1.6107 ++ return nan ();
1.6108 ++ return a;
1.6109 ++ }
1.6110 ++
1.6111 ++ if (isinf (b))
1.6112 ++ {
1.6113 ++ a->fraction.ll = 0;
1.6114 ++ a->normal_exp = 0;
1.6115 ++ return a;
1.6116 ++ }
1.6117 ++ if (iszero (b))
1.6118 ++ {
1.6119 ++ a->class = CLASS_INFINITY;
1.6120 ++ return a;
1.6121 ++ }
1.6122 ++
1.6123 ++ /* Calculate the mantissa by multiplying both 64bit numbers to get a
1.6124 ++ 128 bit number */
1.6125 ++ {
1.6126 ++ /* quotient =
1.6127 ++ ( numerator / denominator) * 2^(numerator exponent - denominator exponent)
1.6128 ++ */
1.6129 ++
1.6130 ++ a->normal_exp = a->normal_exp - b->normal_exp;
1.6131 ++ numerator = a->fraction.ll;
1.6132 ++ denominator = b->fraction.ll;
1.6133 ++
1.6134 ++ if (numerator < denominator)
1.6135 ++ {
1.6136 ++ /* Fraction will be less than 1.0 */
1.6137 ++ numerator *= 2;
1.6138 ++ a->normal_exp--;
1.6139 ++ }
1.6140 ++ bit = IMPLICIT_1;
1.6141 ++ quotient = 0;
1.6142 ++ /* ??? Does divide one bit at a time. Optimize. */
1.6143 ++ while (bit)
1.6144 ++ {
1.6145 ++ if (numerator >= denominator)
1.6146 ++ {
1.6147 ++ quotient |= bit;
1.6148 ++ numerator -= denominator;
1.6149 ++ }
1.6150 ++ bit >>= 1;
1.6151 ++ numerator *= 2;
1.6152 ++ }
1.6153 ++
1.6154 ++ if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
1.6155 ++ {
1.6156 ++ if (quotient & (1 << NGARDS))
1.6157 ++ {
1.6158 ++ /* half way, so round to even */
1.6159 ++ quotient += GARDROUND + 1;
1.6160 ++ }
1.6161 ++ else if (numerator)
1.6162 ++ {
1.6163 ++ /* but we really weren't half way, more bits exist */
1.6164 ++ quotient += GARDROUND + 1;
1.6165 ++ }
1.6166 ++ }
1.6167 ++
1.6168 ++ a->fraction.ll = quotient;
1.6169 ++ return (a);
1.6170 ++ }
1.6171 ++}
1.6172 ++
1.6173 ++FLO_type
1.6174 ++divide (FLO_type arg_a, FLO_type arg_b)
1.6175 ++{
1.6176 ++ fp_number_type a;
1.6177 ++ fp_number_type b;
1.6178 ++ fp_number_type *res;
1.6179 ++ FLO_union_type au, bu;
1.6180 ++
1.6181 ++ au.value = arg_a;
1.6182 ++ bu.value = arg_b;
1.6183 ++
1.6184 ++ unpack_d (&au, &a);
1.6185 ++ unpack_d (&bu, &b);
1.6186 ++
1.6187 ++ res = _fpdiv_parts (&a, &b);
1.6188 ++
1.6189 ++ return pack_d (res);
1.6190 ++}
1.6191 ++#endif /* L_div_sf || L_div_df */
1.6192 ++
1.6193 ++#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
1.6194 ++ || defined(L_fpcmp_parts_tf)
1.6195 ++/* according to the demo, fpcmp returns a comparison with 0... thus
1.6196 ++ a<b -> -1
1.6197 ++ a==b -> 0
1.6198 ++ a>b -> +1
1.6199 ++ */
1.6200 ++
1.6201 ++int
1.6202 ++__fpcmp_parts (fp_number_type * a, fp_number_type * b)
1.6203 ++{
1.6204 ++#if 0
1.6205 ++ /* either nan -> unordered. Must be checked outside of this routine. */
1.6206 ++ if (isnan (a) && isnan (b))
1.6207 ++ {
1.6208 ++ return 1; /* still unordered! */
1.6209 ++ }
1.6210 ++#endif
1.6211 ++
1.6212 ++ if (isnan (a) || isnan (b))
1.6213 ++ {
1.6214 ++ return 1; /* how to indicate unordered compare? */
1.6215 ++ }
1.6216 ++ if (isinf (a) && isinf (b))
1.6217 ++ {
1.6218 ++ /* +inf > -inf, but +inf != +inf */
1.6219 ++ /* b \a| +inf(0)| -inf(1)
1.6220 ++ ______\+--------+--------
1.6221 ++ +inf(0)| a==b(0)| a<b(-1)
1.6222 ++ -------+--------+--------
1.6223 ++ -inf(1)| a>b(1) | a==b(0)
1.6224 ++ -------+--------+--------
1.6225 ++ So since unordered must be nonzero, just line up the columns...
1.6226 ++ */
1.6227 ++ return b->sign - a->sign;
1.6228 ++ }
1.6229 ++ /* but not both... */
1.6230 ++ if (isinf (a))
1.6231 ++ {
1.6232 ++ return a->sign ? -1 : 1;
1.6233 ++ }
1.6234 ++ if (isinf (b))
1.6235 ++ {
1.6236 ++ return b->sign ? 1 : -1;
1.6237 ++ }
1.6238 ++ if (iszero (a) && iszero (b))
1.6239 ++ {
1.6240 ++ return 0;
1.6241 ++ }
1.6242 ++ if (iszero (a))
1.6243 ++ {
1.6244 ++ return b->sign ? 1 : -1;
1.6245 ++ }
1.6246 ++ if (iszero (b))
1.6247 ++ {
1.6248 ++ return a->sign ? -1 : 1;
1.6249 ++ }
1.6250 ++ /* now both are "normal". */
1.6251 ++ if (a->sign != b->sign)
1.6252 ++ {
1.6253 ++ /* opposite signs */
1.6254 ++ return a->sign ? -1 : 1;
1.6255 ++ }
1.6256 ++ /* same sign; exponents? */
1.6257 ++ if (a->normal_exp > b->normal_exp)
1.6258 ++ {
1.6259 ++ return a->sign ? -1 : 1;
1.6260 ++ }
1.6261 ++ if (a->normal_exp < b->normal_exp)
1.6262 ++ {
1.6263 ++ return a->sign ? 1 : -1;
1.6264 ++ }
1.6265 ++ /* same exponents; check size. */
1.6266 ++ if (a->fraction.ll > b->fraction.ll)
1.6267 ++ {
1.6268 ++ return a->sign ? -1 : 1;
1.6269 ++ }
1.6270 ++ if (a->fraction.ll < b->fraction.ll)
1.6271 ++ {
1.6272 ++ return a->sign ? 1 : -1;
1.6273 ++ }
1.6274 ++ /* after all that, they're equal. */
1.6275 ++ return 0;
1.6276 ++}
1.6277 ++#endif
1.6278 ++
1.6279 ++#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
1.6280 ++CMPtype
1.6281 ++compare (FLO_type arg_a, FLO_type arg_b)
1.6282 ++{
1.6283 ++ fp_number_type a;
1.6284 ++ fp_number_type b;
1.6285 ++ FLO_union_type au, bu;
1.6286 ++
1.6287 ++ au.value = arg_a;
1.6288 ++ bu.value = arg_b;
1.6289 ++
1.6290 ++ unpack_d (&au, &a);
1.6291 ++ unpack_d (&bu, &b);
1.6292 ++
1.6293 ++ return __fpcmp_parts (&a, &b);
1.6294 ++}
1.6295 ++#endif /* L_compare_sf || L_compare_df */
1.6296 ++
1.6297 ++#ifndef US_SOFTWARE_GOFAST
1.6298 ++
1.6299 ++/* These should be optimized for their specific tasks someday. */
1.6300 ++
1.6301 ++#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
1.6302 ++CMPtype
1.6303 ++_eq_f2 (FLO_type arg_a, FLO_type arg_b)
1.6304 ++{
1.6305 ++ fp_number_type a;
1.6306 ++ fp_number_type b;
1.6307 ++ FLO_union_type au, bu;
1.6308 ++
1.6309 ++ au.value = arg_a;
1.6310 ++ bu.value = arg_b;
1.6311 ++
1.6312 ++ unpack_d (&au, &a);
1.6313 ++ unpack_d (&bu, &b);
1.6314 ++
1.6315 ++ if (isnan (&a) || isnan (&b))
1.6316 ++ return 1; /* false, truth == 0 */
1.6317 ++
1.6318 ++ return __fpcmp_parts (&a, &b) ;
1.6319 ++}
1.6320 ++#endif /* L_eq_sf || L_eq_df */
1.6321 ++
1.6322 ++#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
1.6323 ++CMPtype
1.6324 ++_ne_f2 (FLO_type arg_a, FLO_type arg_b)
1.6325 ++{
1.6326 ++ fp_number_type a;
1.6327 ++ fp_number_type b;
1.6328 ++ FLO_union_type au, bu;
1.6329 ++
1.6330 ++ au.value = arg_a;
1.6331 ++ bu.value = arg_b;
1.6332 ++
1.6333 ++ unpack_d (&au, &a);
1.6334 ++ unpack_d (&bu, &b);
1.6335 ++
1.6336 ++ if (isnan (&a) || isnan (&b))
1.6337 ++ return 1; /* true, truth != 0 */
1.6338 ++
1.6339 ++ return __fpcmp_parts (&a, &b) ;
1.6340 ++}
1.6341 ++#endif /* L_ne_sf || L_ne_df */
1.6342 ++
1.6343 ++#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
1.6344 ++CMPtype
1.6345 ++_gt_f2 (FLO_type arg_a, FLO_type arg_b)
1.6346 ++{
1.6347 ++ fp_number_type a;
1.6348 ++ fp_number_type b;
1.6349 ++ FLO_union_type au, bu;
1.6350 ++
1.6351 ++ au.value = arg_a;
1.6352 ++ bu.value = arg_b;
1.6353 ++
1.6354 ++ unpack_d (&au, &a);
1.6355 ++ unpack_d (&bu, &b);
1.6356 ++
1.6357 ++ if (isnan (&a) || isnan (&b))
1.6358 ++ return -1; /* false, truth > 0 */
1.6359 ++
1.6360 ++ return __fpcmp_parts (&a, &b);
1.6361 ++}
1.6362 ++#endif /* L_gt_sf || L_gt_df */
1.6363 ++
1.6364 ++#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
1.6365 ++CMPtype
1.6366 ++_ge_f2 (FLO_type arg_a, FLO_type arg_b)
1.6367 ++{
1.6368 ++ fp_number_type a;
1.6369 ++ fp_number_type b;
1.6370 ++ FLO_union_type au, bu;
1.6371 ++
1.6372 ++ au.value = arg_a;
1.6373 ++ bu.value = arg_b;
1.6374 ++
1.6375 ++ unpack_d (&au, &a);
1.6376 ++ unpack_d (&bu, &b);
1.6377 ++
1.6378 ++ if (isnan (&a) || isnan (&b))
1.6379 ++ return -1; /* false, truth >= 0 */
1.6380 ++ return __fpcmp_parts (&a, &b) ;
1.6381 ++}
1.6382 ++#endif /* L_ge_sf || L_ge_df */
1.6383 ++
1.6384 ++#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
1.6385 ++CMPtype
1.6386 ++_lt_f2 (FLO_type arg_a, FLO_type arg_b)
1.6387 ++{
1.6388 ++ fp_number_type a;
1.6389 ++ fp_number_type b;
1.6390 ++ FLO_union_type au, bu;
1.6391 ++
1.6392 ++ au.value = arg_a;
1.6393 ++ bu.value = arg_b;
1.6394 ++
1.6395 ++ unpack_d (&au, &a);
1.6396 ++ unpack_d (&bu, &b);
1.6397 ++
1.6398 ++ if (isnan (&a) || isnan (&b))
1.6399 ++ return 1; /* false, truth < 0 */
1.6400 ++
1.6401 ++ return __fpcmp_parts (&a, &b);
1.6402 ++}
1.6403 ++#endif /* L_lt_sf || L_lt_df */
1.6404 ++
1.6405 ++#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
1.6406 ++CMPtype
1.6407 ++_le_f2 (FLO_type arg_a, FLO_type arg_b)
1.6408 ++{
1.6409 ++ fp_number_type a;
1.6410 ++ fp_number_type b;
1.6411 ++ FLO_union_type au, bu;
1.6412 ++
1.6413 ++ au.value = arg_a;
1.6414 ++ bu.value = arg_b;
1.6415 ++
1.6416 ++ unpack_d (&au, &a);
1.6417 ++ unpack_d (&bu, &b);
1.6418 ++
1.6419 ++ if (isnan (&a) || isnan (&b))
1.6420 ++ return 1; /* false, truth <= 0 */
1.6421 ++
1.6422 ++ return __fpcmp_parts (&a, &b) ;
1.6423 ++}
1.6424 ++#endif /* L_le_sf || L_le_df */
1.6425 ++
1.6426 ++#endif /* ! US_SOFTWARE_GOFAST */
1.6427 ++
1.6428 ++#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
1.6429 ++CMPtype
1.6430 ++_unord_f2 (FLO_type arg_a, FLO_type arg_b)
1.6431 ++{
1.6432 ++ fp_number_type a;
1.6433 ++ fp_number_type b;
1.6434 ++ FLO_union_type au, bu;
1.6435 ++
1.6436 ++ au.value = arg_a;
1.6437 ++ bu.value = arg_b;
1.6438 ++
1.6439 ++ unpack_d (&au, &a);
1.6440 ++ unpack_d (&bu, &b);
1.6441 ++
1.6442 ++ return (isnan (&a) || isnan (&b));
1.6443 ++}
1.6444 ++#endif /* L_unord_sf || L_unord_df */
1.6445 ++
1.6446 ++#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
1.6447 ++FLO_type
1.6448 ++si_to_float (SItype arg_a)
1.6449 ++{
1.6450 ++ fp_number_type in;
1.6451 ++
1.6452 ++ in.class = CLASS_NUMBER;
1.6453 ++ in.sign = arg_a < 0;
1.6454 ++ if (!arg_a)
1.6455 ++ {
1.6456 ++ in.class = CLASS_ZERO;
1.6457 ++ }
1.6458 ++ else
1.6459 ++ {
1.6460 ++ in.normal_exp = FRACBITS + NGARDS;
1.6461 ++ if (in.sign)
1.6462 ++ {
1.6463 ++ /* Special case for minint, since there is no +ve integer
1.6464 ++ representation for it */
1.6465 ++ if (arg_a == (- MAX_SI_INT - 1))
1.6466 ++ {
1.6467 ++ return (FLO_type)(- MAX_SI_INT - 1);
1.6468 ++ }
1.6469 ++ in.fraction.ll = (-arg_a);
1.6470 ++ }
1.6471 ++ else
1.6472 ++ in.fraction.ll = arg_a;
1.6473 ++
1.6474 ++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1.6475 ++ {
1.6476 ++ in.fraction.ll <<= 1;
1.6477 ++ in.normal_exp -= 1;
1.6478 ++ }
1.6479 ++ }
1.6480 ++ return pack_d (&in);
1.6481 ++}
1.6482 ++#endif /* L_si_to_sf || L_si_to_df */
1.6483 ++
1.6484 ++#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
1.6485 ++FLO_type
1.6486 ++usi_to_float (USItype arg_a)
1.6487 ++{
1.6488 ++ fp_number_type in;
1.6489 ++
1.6490 ++ in.sign = 0;
1.6491 ++ if (!arg_a)
1.6492 ++ {
1.6493 ++ in.class = CLASS_ZERO;
1.6494 ++ }
1.6495 ++ else
1.6496 ++ {
1.6497 ++ in.class = CLASS_NUMBER;
1.6498 ++ in.normal_exp = FRACBITS + NGARDS;
1.6499 ++ in.fraction.ll = arg_a;
1.6500 ++
1.6501 ++ while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
1.6502 ++ {
1.6503 ++ in.fraction.ll >>= 1;
1.6504 ++ in.normal_exp += 1;
1.6505 ++ }
1.6506 ++ while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1.6507 ++ {
1.6508 ++ in.fraction.ll <<= 1;
1.6509 ++ in.normal_exp -= 1;
1.6510 ++ }
1.6511 ++ }
1.6512 ++ return pack_d (&in);
1.6513 ++}
1.6514 ++#endif
1.6515 ++
1.6516 ++#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
1.6517 ++SItype
1.6518 ++float_to_si (FLO_type arg_a)
1.6519 ++{
1.6520 ++ fp_number_type a;
1.6521 ++ SItype tmp;
1.6522 ++ FLO_union_type au;
1.6523 ++
1.6524 ++ au.value = arg_a;
1.6525 ++ unpack_d (&au, &a);
1.6526 ++
1.6527 ++ if (iszero (&a))
1.6528 ++ return 0;
1.6529 ++ if (isnan (&a))
1.6530 ++ return 0;
1.6531 ++ /* get reasonable MAX_SI_INT... */
1.6532 ++ if (isinf (&a))
1.6533 ++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1.6534 ++ /* it is a number, but a small one */
1.6535 ++ if (a.normal_exp < 0)
1.6536 ++ return 0;
1.6537 ++ if (a.normal_exp > BITS_PER_SI - 2)
1.6538 ++ return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1.6539 ++ tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
1.6540 ++ return a.sign ? (-tmp) : (tmp);
1.6541 ++}
1.6542 ++#endif /* L_sf_to_si || L_df_to_si */
1.6543 ++
1.6544 ++#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
1.6545 ++#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
1.6546 ++/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
1.6547 ++ we also define them for GOFAST because the ones in libgcc2.c have the
1.6548 ++ wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
1.6549 ++ out of libgcc2.c. We can't define these here if not GOFAST because then
1.6550 ++ there'd be duplicate copies. */
1.6551 ++
1.6552 ++USItype
1.6553 ++float_to_usi (FLO_type arg_a)
1.6554 ++{
1.6555 ++ fp_number_type a;
1.6556 ++ FLO_union_type au;
1.6557 ++
1.6558 ++ au.value = arg_a;
1.6559 ++ unpack_d (&au, &a);
1.6560 ++
1.6561 ++ if (iszero (&a))
1.6562 ++ return 0;
1.6563 ++ if (isnan (&a))
1.6564 ++ return 0;
1.6565 ++ /* it is a negative number */
1.6566 ++ if (a.sign)
1.6567 ++ return 0;
1.6568 ++ /* get reasonable MAX_USI_INT... */
1.6569 ++ if (isinf (&a))
1.6570 ++ return MAX_USI_INT;
1.6571 ++ /* it is a number, but a small one */
1.6572 ++ if (a.normal_exp < 0)
1.6573 ++ return 0;
1.6574 ++ if (a.normal_exp > BITS_PER_SI - 1)
1.6575 ++ return MAX_USI_INT;
1.6576 ++ else if (a.normal_exp > (FRACBITS + NGARDS))
1.6577 ++ return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
1.6578 ++ else
1.6579 ++ return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
1.6580 ++}
1.6581 ++#endif /* US_SOFTWARE_GOFAST */
1.6582 ++#endif /* L_sf_to_usi || L_df_to_usi */
1.6583 ++
1.6584 ++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
1.6585 ++FLO_type
1.6586 ++negate (FLO_type arg_a)
1.6587 ++{
1.6588 ++ fp_number_type a;
1.6589 ++ FLO_union_type au;
1.6590 ++
1.6591 ++ au.value = arg_a;
1.6592 ++ unpack_d (&au, &a);
1.6593 ++
1.6594 ++ flip_sign (&a);
1.6595 ++ return pack_d (&a);
1.6596 ++}
1.6597 ++#endif /* L_negate_sf || L_negate_df */
1.6598 ++
1.6599 ++#ifdef FLOAT
1.6600 ++
1.6601 ++#if defined(L_make_sf)
1.6602 ++SFtype
1.6603 ++__make_fp(fp_class_type class,
1.6604 ++ unsigned int sign,
1.6605 ++ int exp,
1.6606 ++ USItype frac)
1.6607 ++{
1.6608 ++ fp_number_type in;
1.6609 ++
1.6610 ++ in.class = class;
1.6611 ++ in.sign = sign;
1.6612 ++ in.normal_exp = exp;
1.6613 ++ in.fraction.ll = frac;
1.6614 ++ return pack_d (&in);
1.6615 ++}
1.6616 ++#endif /* L_make_sf */
1.6617 ++
1.6618 ++#ifndef FLOAT_ONLY
1.6619 ++
1.6620 ++/* This enables one to build an fp library that supports float but not double.
1.6621 ++ Otherwise, we would get an undefined reference to __make_dp.
1.6622 ++ This is needed for some 8-bit ports that can't handle well values that
1.6623 ++ are 8-bytes in size, so we just don't support double for them at all. */
1.6624 ++
1.6625 ++#if defined(L_sf_to_df)
1.6626 ++DFtype
1.6627 ++sf_to_df (SFtype arg_a)
1.6628 ++{
1.6629 ++ fp_number_type in;
1.6630 ++ FLO_union_type au;
1.6631 ++
1.6632 ++ au.value = arg_a;
1.6633 ++ unpack_d (&au, &in);
1.6634 ++
1.6635 ++ return __make_dp (in.class, in.sign, in.normal_exp,
1.6636 ++ ((UDItype) in.fraction.ll) << F_D_BITOFF);
1.6637 ++}
1.6638 ++#endif /* L_sf_to_df */
1.6639 ++
1.6640 ++#if defined(L_sf_to_tf) && defined(TMODES)
1.6641 ++TFtype
1.6642 ++sf_to_tf (SFtype arg_a)
1.6643 ++{
1.6644 ++ fp_number_type in;
1.6645 ++ FLO_union_type au;
1.6646 ++
1.6647 ++ au.value = arg_a;
1.6648 ++ unpack_d (&au, &in);
1.6649 ++
1.6650 ++ return __make_tp (in.class, in.sign, in.normal_exp,
1.6651 ++ ((UTItype) in.fraction.ll) << F_T_BITOFF);
1.6652 ++}
1.6653 ++#endif /* L_sf_to_df */
1.6654 ++
1.6655 ++#endif /* ! FLOAT_ONLY */
1.6656 ++#endif /* FLOAT */
1.6657 ++
1.6658 ++#ifndef FLOAT
1.6659 ++
1.6660 ++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
1.6661 ++
1.6662 ++#if defined(L_make_df)
1.6663 ++DFtype
1.6664 ++__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
1.6665 ++{
1.6666 ++ fp_number_type in;
1.6667 ++
1.6668 ++ in.class = class;
1.6669 ++ in.sign = sign;
1.6670 ++ in.normal_exp = exp;
1.6671 ++ in.fraction.ll = frac;
1.6672 ++ return pack_d (&in);
1.6673 ++}
1.6674 ++#endif /* L_make_df */
1.6675 ++
1.6676 ++#if defined(L_df_to_sf)
1.6677 ++SFtype
1.6678 ++df_to_sf (DFtype arg_a)
1.6679 ++{
1.6680 ++ fp_number_type in;
1.6681 ++ USItype sffrac;
1.6682 ++ FLO_union_type au;
1.6683 ++
1.6684 ++ au.value = arg_a;
1.6685 ++ unpack_d (&au, &in);
1.6686 ++
1.6687 ++ sffrac = in.fraction.ll >> F_D_BITOFF;
1.6688 ++
1.6689 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.6690 ++ zero bits. */
1.6691 ++ if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
1.6692 ++ sffrac |= 1;
1.6693 ++
1.6694 ++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
1.6695 ++}
1.6696 ++#endif /* L_df_to_sf */
1.6697 ++
1.6698 ++#if defined(L_df_to_tf) && defined(TMODES) \
1.6699 ++ && !defined(FLOAT) && !defined(TFLOAT)
1.6700 ++TFtype
1.6701 ++df_to_tf (DFtype arg_a)
1.6702 ++{
1.6703 ++ fp_number_type in;
1.6704 ++ FLO_union_type au;
1.6705 ++
1.6706 ++ au.value = arg_a;
1.6707 ++ unpack_d (&au, &in);
1.6708 ++
1.6709 ++ return __make_tp (in.class, in.sign, in.normal_exp,
1.6710 ++ ((UTItype) in.fraction.ll) << D_T_BITOFF);
1.6711 ++}
1.6712 ++#endif /* L_sf_to_df */
1.6713 ++
1.6714 ++#ifdef TFLOAT
1.6715 ++#if defined(L_make_tf)
1.6716 ++TFtype
1.6717 ++__make_tp(fp_class_type class,
1.6718 ++ unsigned int sign,
1.6719 ++ int exp,
1.6720 ++ UTItype frac)
1.6721 ++{
1.6722 ++ fp_number_type in;
1.6723 ++
1.6724 ++ in.class = class;
1.6725 ++ in.sign = sign;
1.6726 ++ in.normal_exp = exp;
1.6727 ++ in.fraction.ll = frac;
1.6728 ++ return pack_d (&in);
1.6729 ++}
1.6730 ++#endif /* L_make_tf */
1.6731 ++
1.6732 ++#if defined(L_tf_to_df)
1.6733 ++DFtype
1.6734 ++tf_to_df (TFtype arg_a)
1.6735 ++{
1.6736 ++ fp_number_type in;
1.6737 ++ UDItype sffrac;
1.6738 ++ FLO_union_type au;
1.6739 ++
1.6740 ++ au.value = arg_a;
1.6741 ++ unpack_d (&au, &in);
1.6742 ++
1.6743 ++ sffrac = in.fraction.ll >> D_T_BITOFF;
1.6744 ++
1.6745 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.6746 ++ zero bits. */
1.6747 ++ if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
1.6748 ++ sffrac |= 1;
1.6749 ++
1.6750 ++ return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
1.6751 ++}
1.6752 ++#endif /* L_tf_to_df */
1.6753 ++
1.6754 ++#if defined(L_tf_to_sf)
1.6755 ++SFtype
1.6756 ++tf_to_sf (TFtype arg_a)
1.6757 ++{
1.6758 ++ fp_number_type in;
1.6759 ++ USItype sffrac;
1.6760 ++ FLO_union_type au;
1.6761 ++
1.6762 ++ au.value = arg_a;
1.6763 ++ unpack_d (&au, &in);
1.6764 ++
1.6765 ++ sffrac = in.fraction.ll >> F_T_BITOFF;
1.6766 ++
1.6767 ++ /* We set the lowest guard bit in SFFRAC if we discarded any non
1.6768 ++ zero bits. */
1.6769 ++ if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
1.6770 ++ sffrac |= 1;
1.6771 ++
1.6772 ++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
1.6773 ++}
1.6774 ++#endif /* L_tf_to_sf */
1.6775 ++#endif /* TFLOAT */
1.6776 ++
1.6777 ++#endif /* ! FLOAT */
1.6778 ++#endif /* !EXTENDED_FLOAT_STUBS */
1.6779 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.h gcc-3.4.6/gcc/config/nios2/nios2.h
1.6780 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.h 1970-01-01 01:00:00.000000000 +0100
1.6781 ++++ gcc-3.4.6/gcc/config/nios2/nios2.h 2007-08-15 23:09:36.000000000 +0200
1.6782 +@@ -0,0 +1,824 @@
1.6783 ++/* Definitions of target machine for Altera NIOS 2G NIOS2 version.
1.6784 ++ Copyright (C) 2003 Altera
1.6785 ++ Contributed by Jonah Graham (jgraham@altera.com).
1.6786 ++
1.6787 ++This file is part of GNU CC.
1.6788 ++
1.6789 ++GNU CC is free software; you can redistribute it and/or modify
1.6790 ++it under the terms of the GNU General Public License as published by
1.6791 ++the Free Software Foundation; either version 2, or (at your option)
1.6792 ++any later version.
1.6793 ++
1.6794 ++GNU CC is distributed in the hope that it will be useful,
1.6795 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
1.6796 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.6797 ++GNU General Public License for more details.
1.6798 ++
1.6799 ++You should have received a copy of the GNU General Public License
1.6800 ++along with GNU CC; see the file COPYING. If not, write to
1.6801 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.6802 ++Boston, MA 02111-1307, USA. */
1.6803 ++
1.6804 ++
1.6805 ++
1.6806 ++#define TARGET_CPU_CPP_BUILTINS() \
1.6807 ++ do \
1.6808 ++ { \
1.6809 ++ builtin_define_std ("NIOS2"); \
1.6810 ++ builtin_define_std ("nios2"); \
1.6811 ++ builtin_define ("_GNU_SOURCE"); \
1.6812 ++ } \
1.6813 ++ while (0)
1.6814 ++#define TARGET_VERSION fprintf (stderr, " (Altera Nios II)")
1.6815 ++
1.6816 ++
1.6817 ++
1.6818 ++
1.6819 ++
1.6820 ++/*********************************
1.6821 ++ * Run-time Target Specification
1.6822 ++ *********************************/
1.6823 ++
1.6824 ++#define HAS_DIV_FLAG 0x0001
1.6825 ++#define HAS_MUL_FLAG 0x0002
1.6826 ++#define HAS_MULX_FLAG 0x0004
1.6827 ++#define FAST_SW_DIV_FLAG 0x0008
1.6828 ++#define INLINE_MEMCPY_FLAG 0x00010
1.6829 ++#define CACHE_VOLATILE_FLAG 0x0020
1.6830 ++#define BYPASS_CACHE_FLAG 0x0040
1.6831 ++
1.6832 ++extern int target_flags;
1.6833 ++#define TARGET_HAS_DIV (target_flags & HAS_DIV_FLAG)
1.6834 ++#define TARGET_HAS_MUL (target_flags & HAS_MUL_FLAG)
1.6835 ++#define TARGET_HAS_MULX (target_flags & HAS_MULX_FLAG)
1.6836 ++#define TARGET_FAST_SW_DIV (target_flags & FAST_SW_DIV_FLAG)
1.6837 ++#define TARGET_INLINE_MEMCPY (target_flags & INLINE_MEMCPY_FLAG)
1.6838 ++#define TARGET_CACHE_VOLATILE (target_flags & CACHE_VOLATILE_FLAG)
1.6839 ++#define TARGET_BYPASS_CACHE (target_flags & BYPASS_CACHE_FLAG)
1.6840 ++
1.6841 ++#define TARGET_SWITCHES \
1.6842 ++{ \
1.6843 ++ { "hw-div", HAS_DIV_FLAG, \
1.6844 ++ N_("Enable DIV, DIVU") }, \
1.6845 ++ { "no-hw-div", -HAS_DIV_FLAG, \
1.6846 ++ N_("Disable DIV, DIVU (default)") }, \
1.6847 ++ { "hw-mul", HAS_MUL_FLAG, \
1.6848 ++ N_("Enable MUL instructions (default)") }, \
1.6849 ++ { "hw-mulx", HAS_MULX_FLAG, \
1.6850 ++ N_("Enable MULX instructions, assume fast shifter") }, \
1.6851 ++ { "no-hw-mul", -HAS_MUL_FLAG, \
1.6852 ++ N_("Disable MUL instructions") }, \
1.6853 ++ { "no-hw-mulx", -HAS_MULX_FLAG, \
1.6854 ++ N_("Disable MULX instructions, assume slow shifter (default and implied by -mno-hw-mul)") }, \
1.6855 ++ { "fast-sw-div", FAST_SW_DIV_FLAG, \
1.6856 ++ N_("Use table based fast divide (default at -O3)") }, \
1.6857 ++ { "no-fast-sw-div", -FAST_SW_DIV_FLAG, \
1.6858 ++ N_("Don't use table based fast divide ever") }, \
1.6859 ++ { "inline-memcpy", INLINE_MEMCPY_FLAG, \
1.6860 ++ N_("Inline small memcpy (default when optimizing)") }, \
1.6861 ++ { "no-inline-memcpy", -INLINE_MEMCPY_FLAG, \
1.6862 ++ N_("Don't Inline small memcpy") }, \
1.6863 ++ { "cache-volatile", CACHE_VOLATILE_FLAG, \
1.6864 ++ N_("Volatile accesses use non-io variants of instructions (default)") }, \
1.6865 ++ { "no-cache-volatile", -CACHE_VOLATILE_FLAG, \
1.6866 ++ N_("Volatile accesses use io variants of instructions") }, \
1.6867 ++ { "bypass-cache", BYPASS_CACHE_FLAG, \
1.6868 ++ N_("All ld/st instructins use io variants") }, \
1.6869 ++ { "no-bypass-cache", -BYPASS_CACHE_FLAG, \
1.6870 ++ N_("All ld/st instructins do not use io variants (default)") }, \
1.6871 ++ { "smallc", 0, \
1.6872 ++ N_("Link with a limited version of the C library") }, \
1.6873 ++ { "ctors-in-init", 0, \
1.6874 ++ "" /* undocumented: N_("Link with static constructors and destructors in init") */ }, \
1.6875 ++ { "", TARGET_DEFAULT, 0 } \
1.6876 ++}
1.6877 ++
1.6878 ++
1.6879 ++extern const char *nios2_sys_nosys_string; /* for -msys=nosys */
1.6880 ++extern const char *nios2_sys_lib_string; /* for -msys-lib= */
1.6881 ++extern const char *nios2_sys_crt0_string; /* for -msys-crt0= */
1.6882 ++
1.6883 ++#define TARGET_OPTIONS \
1.6884 ++{ \
1.6885 ++ { "sys=nosys", &nios2_sys_nosys_string, \
1.6886 ++ N_("Use stub versions of OS library calls (default)"), 0}, \
1.6887 ++ { "sys-lib=", &nios2_sys_lib_string, \
1.6888 ++ N_("Name of System Library to link against. (Converted to a -l option)"), 0}, \
1.6889 ++ { "sys-crt0=", &nios2_sys_crt0_string, \
1.6890 ++ N_("Name of the startfile. (default is a crt0 for the ISS only)"), 0}, \
1.6891 ++}
1.6892 ++
1.6893 ++
1.6894 ++/* Default target_flags if no switches specified. */
1.6895 ++#ifndef TARGET_DEFAULT
1.6896 ++# define TARGET_DEFAULT (HAS_MUL_FLAG | CACHE_VOLATILE_FLAG)
1.6897 ++#endif
1.6898 ++
1.6899 ++/* Switch Recognition by gcc.c. Add -G xx support */
1.6900 ++#undef SWITCH_TAKES_ARG
1.6901 ++#define SWITCH_TAKES_ARG(CHAR) \
1.6902 ++ (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
1.6903 ++
1.6904 ++#define OVERRIDE_OPTIONS override_options ()
1.6905 ++#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) optimization_options (LEVEL, SIZE)
1.6906 ++#define CAN_DEBUG_WITHOUT_FP
1.6907 ++
1.6908 ++#define CC1_SPEC "\
1.6909 ++%{G*}"
1.6910 ++
1.6911 ++#undef LIB_SPEC
1.6912 ++#define LIB_SPEC \
1.6913 ++"--start-group %{msmallc: -lsmallc} %{!msmallc: -lc} -lgcc \
1.6914 ++ %{msys-lib=*: -l%*} \
1.6915 ++ %{!msys-lib=*: -lc } \
1.6916 ++ --end-group \
1.6917 ++ %{msys-lib=: %eYou need a library name for -msys-lib=} \
1.6918 ++"
1.6919 ++
1.6920 ++
1.6921 ++#undef STARTFILE_SPEC
1.6922 ++#define STARTFILE_SPEC \
1.6923 ++"%{msys-crt0=*: %*} %{!msys-crt0=*: crt1%O%s} \
1.6924 ++ %{msys-crt0=: %eYou need a C startup file for -msys-crt0=} \
1.6925 ++ %{mctors-in-init: crti%O%s crtbegin%O%s} \
1.6926 ++"
1.6927 ++
1.6928 ++#undef ENDFILE_SPEC
1.6929 ++#define ENDFILE_SPEC \
1.6930 ++ "%{mctors-in-init: crtend%O%s crtn%O%s}"
1.6931 ++
1.6932 ++
1.6933 ++/***********************
1.6934 ++ * Storage Layout
1.6935 ++ ***********************/
1.6936 ++
1.6937 ++#define DEFAULT_SIGNED_CHAR 1
1.6938 ++#define BITS_BIG_ENDIAN 0
1.6939 ++#define BYTES_BIG_ENDIAN 0
1.6940 ++#define WORDS_BIG_ENDIAN 0
1.6941 ++#define BITS_PER_UNIT 8
1.6942 ++#define BITS_PER_WORD 32
1.6943 ++#define UNITS_PER_WORD 4
1.6944 ++#define POINTER_SIZE 32
1.6945 ++#define BIGGEST_ALIGNMENT 32
1.6946 ++#define STRICT_ALIGNMENT 1
1.6947 ++#define FUNCTION_BOUNDARY 32
1.6948 ++#define PARM_BOUNDARY 32
1.6949 ++#define STACK_BOUNDARY 32
1.6950 ++#define PREFERRED_STACK_BOUNDARY 32
1.6951 ++#define MAX_FIXED_MODE_SIZE 64
1.6952 ++
1.6953 ++#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
1.6954 ++ ((TREE_CODE (EXP) == STRING_CST) \
1.6955 ++ && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
1.6956 ++
1.6957 ++
1.6958 ++/**********************
1.6959 ++ * Layout of Source Language Data Types
1.6960 ++ **********************/
1.6961 ++
1.6962 ++#define INT_TYPE_SIZE 32
1.6963 ++#define SHORT_TYPE_SIZE 16
1.6964 ++#define LONG_TYPE_SIZE 32
1.6965 ++#define LONG_LONG_TYPE_SIZE 64
1.6966 ++#define FLOAT_TYPE_SIZE 32
1.6967 ++#define DOUBLE_TYPE_SIZE 64
1.6968 ++#define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
1.6969 ++
1.6970 ++
1.6971 ++/*************************
1.6972 ++ * Condition Code Status
1.6973 ++ ************************/
1.6974 ++
1.6975 ++/* comparison type */
1.6976 ++/* ??? currently only CMP_SI is used */
1.6977 ++enum cmp_type {
1.6978 ++ CMP_SI, /* compare four byte integers */
1.6979 ++ CMP_DI, /* compare eight byte integers */
1.6980 ++ CMP_SF, /* compare single precision floats */
1.6981 ++ CMP_DF, /* compare double precision floats */
1.6982 ++ CMP_MAX /* max comparison type */
1.6983 ++};
1.6984 ++
1.6985 ++extern GTY(()) rtx branch_cmp[2]; /* operands for compare */
1.6986 ++extern enum cmp_type branch_type; /* what type of branch to use */
1.6987 ++
1.6988 ++/**********************
1.6989 ++ * Register Usage
1.6990 ++ **********************/
1.6991 ++
1.6992 ++/* ---------------------------------- *
1.6993 ++ * Basic Characteristics of Registers
1.6994 ++ * ---------------------------------- */
1.6995 ++
1.6996 ++/*
1.6997 ++Register Number
1.6998 ++ Register Name
1.6999 ++ Alternate Name
1.7000 ++ Purpose
1.7001 ++0 r0 zero always zero
1.7002 ++1 r1 at Assembler Temporary
1.7003 ++2-3 r2-r3 Return Location
1.7004 ++4-7 r4-r7 Register Arguments
1.7005 ++8-15 r8-r15 Caller Saved Registers
1.7006 ++16-22 r16-r22 Callee Saved Registers
1.7007 ++23 r23 sc Static Chain (Callee Saved)
1.7008 ++ ??? Does $sc want to be caller or callee
1.7009 ++ saved. If caller, 15, else 23.
1.7010 ++24 r24 Exception Temporary
1.7011 ++25 r25 Breakpoint Temporary
1.7012 ++26 r26 gp Global Pointer
1.7013 ++27 r27 sp Stack Pointer
1.7014 ++28 r28 fp Frame Pointer
1.7015 ++29 r29 ea Exception Return Address
1.7016 ++30 r30 ba Breakpoint Return Address
1.7017 ++31 r31 ra Return Address
1.7018 ++
1.7019 ++32 ctl0 status
1.7020 ++33 ctl1 estatus STATUS saved by exception ?
1.7021 ++34 ctl2 bstatus STATUS saved by break ?
1.7022 ++35 ctl3 ipri Interrupt Priority Mask ?
1.7023 ++36 ctl4 ecause Exception Cause ?
1.7024 ++
1.7025 ++37 pc Not an actual register
1.7026 ++
1.7027 ++38 rap Return address pointer, this does not
1.7028 ++ actually exist and will be eliminated
1.7029 ++
1.7030 ++39 fake_fp Fake Frame Pointer which will always be eliminated.
1.7031 ++40 fake_ap Fake Argument Pointer which will always be eliminated.
1.7032 ++
1.7033 ++41 First Pseudo Register
1.7034 ++
1.7035 ++
1.7036 ++The definitions for all the hard register numbers
1.7037 ++are located in nios2.md.
1.7038 ++*/
1.7039 ++
1.7040 ++#define FIRST_PSEUDO_REGISTER 41
1.7041 ++#define NUM_ARG_REGS (LAST_ARG_REGNO - FIRST_ARG_REGNO + 1)
1.7042 ++
1.7043 ++
1.7044 ++
1.7045 ++/* also see CONDITIONAL_REGISTER_USAGE */
1.7046 ++#define FIXED_REGISTERS \
1.7047 ++ { \
1.7048 ++/* +0 1 2 3 4 5 6 7 8 9 */ \
1.7049 ++/* 0 */ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, \
1.7050 ++/* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
1.7051 ++/* 20 */ 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, \
1.7052 ++/* 30 */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \
1.7053 ++/* 40 */ 1, \
1.7054 ++ }
1.7055 ++
1.7056 ++/* call used is the same as caller saved
1.7057 ++ + fixed regs + args + ret vals */
1.7058 ++#define CALL_USED_REGISTERS \
1.7059 ++ { \
1.7060 ++/* +0 1 2 3 4 5 6 7 8 9 */ \
1.7061 ++/* 0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1.7062 ++/* 10 */ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, \
1.7063 ++/* 20 */ 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, \
1.7064 ++/* 30 */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \
1.7065 ++/* 40 */ 1, \
1.7066 ++ }
1.7067 ++
1.7068 ++#define HARD_REGNO_NREGS(REGNO, MODE) \
1.7069 ++ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
1.7070 ++ / UNITS_PER_WORD)
1.7071 ++
1.7072 ++/* --------------------------- *
1.7073 ++ * How Values Fit in Registers
1.7074 ++ * --------------------------- */
1.7075 ++
1.7076 ++#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
1.7077 ++
1.7078 ++#define MODES_TIEABLE_P(MODE1, MODE2) 1
1.7079 ++
1.7080 ++
1.7081 ++/*************************
1.7082 ++ * Register Classes
1.7083 ++ *************************/
1.7084 ++
1.7085 ++enum reg_class
1.7086 ++{
1.7087 ++ NO_REGS,
1.7088 ++ ALL_REGS,
1.7089 ++ LIM_REG_CLASSES
1.7090 ++};
1.7091 ++
1.7092 ++#define N_REG_CLASSES (int) LIM_REG_CLASSES
1.7093 ++
1.7094 ++#define REG_CLASS_NAMES \
1.7095 ++ {"NO_REGS", \
1.7096 ++ "ALL_REGS"}
1.7097 ++
1.7098 ++#define GENERAL_REGS ALL_REGS
1.7099 ++
1.7100 ++#define REG_CLASS_CONTENTS \
1.7101 ++/* NO_REGS */ {{ 0, 0}, \
1.7102 ++/* ALL_REGS */ {~0,~0}} \
1.7103 ++
1.7104 ++#define REGNO_REG_CLASS(REGNO) ALL_REGS
1.7105 ++
1.7106 ++#define BASE_REG_CLASS ALL_REGS
1.7107 ++#define INDEX_REG_CLASS ALL_REGS
1.7108 ++
1.7109 ++/* only one reg class, 'r', is handled automatically */
1.7110 ++#define REG_CLASS_FROM_LETTER(CHAR) NO_REGS
1.7111 ++
1.7112 ++#define REGNO_OK_FOR_BASE_P2(REGNO, STRICT) \
1.7113 ++ ((STRICT) \
1.7114 ++ ? (REGNO) < FIRST_PSEUDO_REGISTER \
1.7115 ++ : (REGNO) < FIRST_PSEUDO_REGISTER || (reg_renumber && reg_renumber[REGNO] < FIRST_PSEUDO_REGISTER))
1.7116 ++
1.7117 ++#define REGNO_OK_FOR_INDEX_P2(REGNO, STRICT) \
1.7118 ++ (REGNO_OK_FOR_BASE_P2 (REGNO, STRICT))
1.7119 ++
1.7120 ++#define REGNO_OK_FOR_BASE_P(REGNO) \
1.7121 ++ (REGNO_OK_FOR_BASE_P2 (REGNO, 1))
1.7122 ++
1.7123 ++#define REGNO_OK_FOR_INDEX_P(REGNO) \
1.7124 ++ (REGNO_OK_FOR_INDEX_P2 (REGNO, 1))
1.7125 ++
1.7126 ++#define REG_OK_FOR_BASE_P2(X, STRICT) \
1.7127 ++ (STRICT \
1.7128 ++ ? REGNO_OK_FOR_BASE_P2 (REGNO (X), 1) \
1.7129 ++ : REGNO_OK_FOR_BASE_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
1.7130 ++
1.7131 ++#define REG_OK_FOR_INDEX_P2(X, STRICT) \
1.7132 ++ (STRICT \
1.7133 ++ ? REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1) \
1.7134 ++ : REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1) || REGNO(X) >= FIRST_PSEUDO_REGISTER)
1.7135 ++
1.7136 ++#define CLASS_MAX_NREGS(CLASS, MODE) \
1.7137 ++ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
1.7138 ++ / UNITS_PER_WORD)
1.7139 ++
1.7140 ++
1.7141 ++#define SMALL_INT(X) ((unsigned HOST_WIDE_INT) ((X) + 0x8000) < 0x10000)
1.7142 ++#define SMALL_INT_UNSIGNED(X) ((unsigned HOST_WIDE_INT) (X) < 0x10000)
1.7143 ++#define UPPER16_INT(X) (((X) & 0xffff) == 0)
1.7144 ++#define SHIFT_INT(X) ((X) >= 0 && (X) <= 31)
1.7145 ++#define RDWRCTL_INT(X) ((X) >= 0 && (X) <= 31)
1.7146 ++#define CUSTOM_INSN_OPCODE(X) ((X) >= 0 && (X) <= 255)
1.7147 ++
1.7148 ++#define CONST_OK_FOR_LETTER_P(VALUE, C) \
1.7149 ++ ( \
1.7150 ++ (C) == 'I' ? SMALL_INT (VALUE) : \
1.7151 ++ (C) == 'J' ? SMALL_INT_UNSIGNED (VALUE) : \
1.7152 ++ (C) == 'K' ? UPPER16_INT (VALUE) : \
1.7153 ++ (C) == 'L' ? SHIFT_INT (VALUE) : \
1.7154 ++ (C) == 'M' ? (VALUE) == 0 : \
1.7155 ++ (C) == 'N' ? CUSTOM_INSN_OPCODE (VALUE) : \
1.7156 ++ (C) == 'O' ? RDWRCTL_INT (VALUE) : \
1.7157 ++ 0)
1.7158 ++
1.7159 ++#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
1.7160 ++
1.7161 ++#define PREFERRED_RELOAD_CLASS(X, CLASS) \
1.7162 ++ ((CLASS) == NO_REGS ? GENERAL_REGS : (CLASS))
1.7163 ++
1.7164 ++/* 'S' matches immediates which are in small data
1.7165 ++ and therefore can be added to gp to create a
1.7166 ++ 32-bit value. */
1.7167 ++#define EXTRA_CONSTRAINT(VALUE, C) \
1.7168 ++ ((C) == 'S' \
1.7169 ++ && (GET_CODE (VALUE) == SYMBOL_REF) \
1.7170 ++ && SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (VALUE))
1.7171 ++
1.7172 ++
1.7173 ++
1.7174 ++
1.7175 ++/* Say that the epilogue uses the return address register. Note that
1.7176 ++ in the case of sibcalls, the values "used by the epilogue" are
1.7177 ++ considered live at the start of the called function. */
1.7178 ++#define EPILOGUE_USES(REGNO) ((REGNO) == RA_REGNO)
1.7179 ++
1.7180 ++
1.7181 ++#define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
1.7182 ++
1.7183 ++/**********************************
1.7184 ++ * Trampolines for Nested Functions
1.7185 ++ ***********************************/
1.7186 ++
1.7187 ++#define TRAMPOLINE_TEMPLATE(FILE) \
1.7188 ++ error ("trampolines not yet implemented")
1.7189 ++#define TRAMPOLINE_SIZE 20
1.7190 ++#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1.7191 ++ error ("trampolines not yet implemented")
1.7192 ++
1.7193 ++/***************************
1.7194 ++ * Stack Layout and Calling Conventions
1.7195 ++ ***************************/
1.7196 ++
1.7197 ++/* ------------------ *
1.7198 ++ * Basic Stack Layout
1.7199 ++ * ------------------ */
1.7200 ++
1.7201 ++/* The downward variants are used by the compiler,
1.7202 ++ the upward ones serve as documentation */
1.7203 ++#define STACK_GROWS_DOWNWARD
1.7204 ++#define FRAME_GROWS_UPWARD
1.7205 ++#define ARGS_GROW_UPWARD
1.7206 ++
1.7207 ++#define STARTING_FRAME_OFFSET current_function_outgoing_args_size
1.7208 ++#define FIRST_PARM_OFFSET(FUNDECL) 0
1.7209 ++
1.7210 ++/* Before the prologue, RA lives in r31. */
1.7211 ++#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (VOIDmode, RA_REGNO)
1.7212 ++
1.7213 ++/* -------------------------------------- *
1.7214 ++ * Registers That Address the Stack Frame
1.7215 ++ * -------------------------------------- */
1.7216 ++
1.7217 ++#define STACK_POINTER_REGNUM SP_REGNO
1.7218 ++#define STATIC_CHAIN_REGNUM SC_REGNO
1.7219 ++#define PC_REGNUM PC_REGNO
1.7220 ++#define DWARF_FRAME_RETURN_COLUMN RA_REGNO
1.7221 ++
1.7222 ++/* Base register for access to local variables of the function. We
1.7223 ++ pretend that the frame pointer is a non-existent hard register, and
1.7224 ++ then eliminate it to HARD_FRAME_POINTER_REGNUM. */
1.7225 ++#define FRAME_POINTER_REGNUM FAKE_FP_REGNO
1.7226 ++
1.7227 ++#define HARD_FRAME_POINTER_REGNUM FP_REGNO
1.7228 ++#define RETURN_ADDRESS_POINTER_REGNUM RAP_REGNO
1.7229 ++/* the argumnet pointer needs to always be eliminated
1.7230 ++ so it is set to a fake hard register. */
1.7231 ++#define ARG_POINTER_REGNUM FAKE_AP_REGNO
1.7232 ++
1.7233 ++/* ----------------------------------------- *
1.7234 ++ * Eliminating Frame Pointer and Arg Pointer
1.7235 ++ * ----------------------------------------- */
1.7236 ++
1.7237 ++#define FRAME_POINTER_REQUIRED 0
1.7238 ++
1.7239 ++#define ELIMINABLE_REGS \
1.7240 ++{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1.7241 ++ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1.7242 ++ { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1.7243 ++ { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1.7244 ++ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1.7245 ++ { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
1.7246 ++
1.7247 ++#define CAN_ELIMINATE(FROM, TO) 1
1.7248 ++
1.7249 ++#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1.7250 ++ (OFFSET) = nios2_initial_elimination_offset ((FROM), (TO))
1.7251 ++
1.7252 ++#define MUST_SAVE_REGISTER(regno) \
1.7253 ++ ((regs_ever_live[regno] && !call_used_regs[regno]) \
1.7254 ++ || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) \
1.7255 ++ || (regno == RA_REGNO && regs_ever_live[RA_REGNO]))
1.7256 ++
1.7257 ++/* Treat LOC as a byte offset from the stack pointer and round it up
1.7258 ++ to the next fully-aligned offset. */
1.7259 ++#define STACK_ALIGN(LOC) \
1.7260 ++ (((LOC) + ((PREFERRED_STACK_BOUNDARY / 8) - 1)) & ~((PREFERRED_STACK_BOUNDARY / 8) - 1))
1.7261 ++
1.7262 ++
1.7263 ++/* ------------------------------ *
1.7264 ++ * Passing Arguments in Registers
1.7265 ++ * ------------------------------ */
1.7266 ++
1.7267 ++/* see nios2.c */
1.7268 ++#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1.7269 ++ (function_arg (&CUM, MODE, TYPE, NAMED))
1.7270 ++
1.7271 ++#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1.7272 ++ (function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED))
1.7273 ++
1.7274 ++#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) 0
1.7275 ++
1.7276 ++#define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 0
1.7277 ++
1.7278 ++typedef struct nios2_args
1.7279 ++{
1.7280 ++ int regs_used;
1.7281 ++} CUMULATIVE_ARGS;
1.7282 ++
1.7283 ++/* This is to initialize the above unused CUM data type */
1.7284 ++#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
1.7285 ++ (init_cumulative_args (&CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS))
1.7286 ++
1.7287 ++#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1.7288 ++ (function_arg_advance (&CUM, MODE, TYPE, NAMED))
1.7289 ++
1.7290 ++#define FUNCTION_ARG_REGNO_P(REGNO) \
1.7291 ++ ((REGNO) >= FIRST_ARG_REGNO && (REGNO) <= LAST_ARG_REGNO)
1.7292 ++
1.7293 ++#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
1.7294 ++ { \
1.7295 ++ int pret_size = nios2_setup_incoming_varargs (&(CUM), (MODE), \
1.7296 ++ (TYPE), (NO_RTL)); \
1.7297 ++ if (pret_size) \
1.7298 ++ (PRETEND_SIZE) = pret_size; \
1.7299 ++ }
1.7300 ++
1.7301 ++/* ----------------------------- *
1.7302 ++ * Generating Code for Profiling
1.7303 ++ * ----------------------------- */
1.7304 ++
1.7305 ++#define PROFILE_BEFORE_PROLOGUE
1.7306 ++
1.7307 ++#define FUNCTION_PROFILER(FILE, LABELNO) \
1.7308 ++ function_profiler ((FILE), (LABELNO))
1.7309 ++
1.7310 ++/* --------------------------------------- *
1.7311 ++ * Passing Function Arguments on the Stack
1.7312 ++ * --------------------------------------- */
1.7313 ++
1.7314 ++#define PROMOTE_PROTOTYPES 1
1.7315 ++
1.7316 ++#define PUSH_ARGS 0
1.7317 ++#define ACCUMULATE_OUTGOING_ARGS 1
1.7318 ++
1.7319 ++#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACKSIZE) 0
1.7320 ++
1.7321 ++/* --------------------------------------- *
1.7322 ++ * How Scalar Function Values Are Returned
1.7323 ++ * --------------------------------------- */
1.7324 ++
1.7325 ++#define FUNCTION_VALUE(VALTYPE, FUNC) \
1.7326 ++ gen_rtx(REG, TYPE_MODE(VALTYPE), FIRST_RETVAL_REGNO)
1.7327 ++
1.7328 ++#define LIBCALL_VALUE(MODE) \
1.7329 ++ gen_rtx(REG, MODE, FIRST_RETVAL_REGNO)
1.7330 ++
1.7331 ++#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == FIRST_RETVAL_REGNO)
1.7332 ++
1.7333 ++/* ----------------------------- *
1.7334 ++ * How Large Values Are Returned
1.7335 ++ * ----------------------------- */
1.7336 ++
1.7337 ++
1.7338 ++#define RETURN_IN_MEMORY(TYPE) \
1.7339 ++ nios2_return_in_memory (TYPE)
1.7340 ++
1.7341 ++
1.7342 ++#define STRUCT_VALUE 0
1.7343 ++
1.7344 ++#define DEFAULT_PCC_STRUCT_RETURN 0
1.7345 ++
1.7346 ++/*******************
1.7347 ++ * Addressing Modes
1.7348 ++ *******************/
1.7349 ++
1.7350 ++
1.7351 ++#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
1.7352 ++
1.7353 ++#define CONSTANT_ADDRESS_P(X) (CONSTANT_P (X))
1.7354 ++
1.7355 ++#define MAX_REGS_PER_ADDRESS 1
1.7356 ++
1.7357 ++/* Go to ADDR if X is a valid address. */
1.7358 ++#ifndef REG_OK_STRICT
1.7359 ++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1.7360 ++ { \
1.7361 ++ if (nios2_legitimate_address ((X), (MODE), 0)) \
1.7362 ++ goto ADDR; \
1.7363 ++ }
1.7364 ++#else
1.7365 ++#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1.7366 ++ { \
1.7367 ++ if (nios2_legitimate_address ((X), (MODE), 1)) \
1.7368 ++ goto ADDR; \
1.7369 ++ }
1.7370 ++#endif
1.7371 ++
1.7372 ++#ifndef REG_OK_STRICT
1.7373 ++#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P2 (REGNO (X), 0)
1.7374 ++#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P2 (REGNO (X), 0)
1.7375 ++#else
1.7376 ++#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P2 (REGNO (X), 1)
1.7377 ++#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P2 (REGNO (X), 1)
1.7378 ++#endif
1.7379 ++
1.7380 ++#define LEGITIMATE_CONSTANT_P(X) 1
1.7381 ++
1.7382 ++/* Nios II has no mode dependent addresses. */
1.7383 ++#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)
1.7384 ++
1.7385 ++/* Set if this has a weak declaration */
1.7386 ++#define SYMBOL_FLAG_WEAK_DECL (1 << SYMBOL_FLAG_MACH_DEP_SHIFT)
1.7387 ++#define SYMBOL_REF_WEAK_DECL_P(RTX) \
1.7388 ++ ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_WEAK_DECL) != 0)
1.7389 ++
1.7390 ++
1.7391 ++/* true if a symbol is both small and not weak. In this case, gp
1.7392 ++ relative access can be used */
1.7393 ++#define SYMBOL_REF_IN_NIOS2_SMALL_DATA_P(RTX) \
1.7394 ++ (SYMBOL_REF_SMALL_P(RTX) && !SYMBOL_REF_WEAK_DECL_P(RTX))
1.7395 ++
1.7396 ++/*****************
1.7397 ++ * Describing Relative Costs of Operations
1.7398 ++ *****************/
1.7399 ++
1.7400 ++#define SLOW_BYTE_ACCESS 1
1.7401 ++
1.7402 ++/* It is as good to call a constant function address as to call an address
1.7403 ++ kept in a register.
1.7404 ++ ??? Not true anymore really. Now that call cannot address full range
1.7405 ++ of memory callr may need to be used */
1.7406 ++
1.7407 ++#define NO_FUNCTION_CSE
1.7408 ++#define NO_RECURSIVE_FUNCTION_CSE
1.7409 ++
1.7410 ++
1.7411 ++
1.7412 ++/*****************************************
1.7413 ++ * Defining the Output Assembler Language
1.7414 ++ *****************************************/
1.7415 ++
1.7416 ++/* ------------------------------------------ *
1.7417 ++ * The Overall Framework of an Assembler File
1.7418 ++ * ------------------------------------------ */
1.7419 ++
1.7420 ++#define ASM_APP_ON "#APP\n"
1.7421 ++#define ASM_APP_OFF "#NO_APP\n"
1.7422 ++
1.7423 ++#define ASM_COMMENT_START "# "
1.7424 ++
1.7425 ++/* ------------------------------- *
1.7426 ++ * Output and Generation of Labels
1.7427 ++ * ------------------------------- */
1.7428 ++
1.7429 ++#define GLOBAL_ASM_OP "\t.global\t"
1.7430 ++
1.7431 ++
1.7432 ++/* -------------- *
1.7433 ++ * Output of Data
1.7434 ++ * -------------- */
1.7435 ++
1.7436 ++#define DWARF2_UNWIND_INFO 0
1.7437 ++
1.7438 ++
1.7439 ++/* -------------------------------- *
1.7440 ++ * Assembler Commands for Alignment
1.7441 ++ * -------------------------------- */
1.7442 ++
1.7443 ++#define ASM_OUTPUT_ALIGN(FILE, LOG) \
1.7444 ++ do { \
1.7445 ++ fprintf ((FILE), "%s%d\n", ALIGN_ASM_OP, (LOG)); \
1.7446 ++ } while (0)
1.7447 ++
1.7448 ++
1.7449 ++/* -------------------------------- *
1.7450 ++ * Output of Assembler Instructions
1.7451 ++ * -------------------------------- */
1.7452 ++
1.7453 ++#define REGISTER_NAMES \
1.7454 ++{ \
1.7455 ++ "zero", \
1.7456 ++ "at", \
1.7457 ++ "r2", \
1.7458 ++ "r3", \
1.7459 ++ "r4", \
1.7460 ++ "r5", \
1.7461 ++ "r6", \
1.7462 ++ "r7", \
1.7463 ++ "r8", \
1.7464 ++ "r9", \
1.7465 ++ "r10", \
1.7466 ++ "r11", \
1.7467 ++ "r12", \
1.7468 ++ "r13", \
1.7469 ++ "r14", \
1.7470 ++ "r15", \
1.7471 ++ "r16", \
1.7472 ++ "r17", \
1.7473 ++ "r18", \
1.7474 ++ "r19", \
1.7475 ++ "r20", \
1.7476 ++ "r21", \
1.7477 ++ "r22", \
1.7478 ++ "r23", \
1.7479 ++ "r24", \
1.7480 ++ "r25", \
1.7481 ++ "gp", \
1.7482 ++ "sp", \
1.7483 ++ "fp", \
1.7484 ++ "ta", \
1.7485 ++ "ba", \
1.7486 ++ "ra", \
1.7487 ++ "status", \
1.7488 ++ "estatus", \
1.7489 ++ "bstatus", \
1.7490 ++ "ipri", \
1.7491 ++ "ecause", \
1.7492 ++ "pc", \
1.7493 ++ "rap", \
1.7494 ++ "fake_fp", \
1.7495 ++ "fake_ap", \
1.7496 ++}
1.7497 ++
1.7498 ++#define ASM_OUTPUT_OPCODE(STREAM, PTR)\
1.7499 ++ (PTR) = asm_output_opcode (STREAM, PTR)
1.7500 ++
1.7501 ++#define PRINT_OPERAND(STREAM, X, CODE) \
1.7502 ++ nios2_print_operand (STREAM, X, CODE)
1.7503 ++
1.7504 ++#define PRINT_OPERAND_ADDRESS(STREAM, X) \
1.7505 ++ nios2_print_operand_address (STREAM, X)
1.7506 ++
1.7507 ++#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1.7508 ++do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \
1.7509 ++ fprintf (FILE, ".L%u\n", (unsigned) (VALUE)); \
1.7510 ++ } while (0)
1.7511 ++
1.7512 ++
1.7513 ++/* ------------ *
1.7514 ++ * Label Output
1.7515 ++ * ------------ */
1.7516 ++
1.7517 ++
1.7518 ++/* ---------------------------------------------------- *
1.7519 ++ * Dividing the Output into Sections (Texts, Data, ...)
1.7520 ++ * ---------------------------------------------------- */
1.7521 ++
1.7522 ++/* Output before read-only data. */
1.7523 ++#define TEXT_SECTION_ASM_OP ("\t.section\t.text")
1.7524 ++
1.7525 ++/* Output before writable data. */
1.7526 ++#define DATA_SECTION_ASM_OP ("\t.section\t.data")
1.7527 ++
1.7528 ++
1.7529 ++/* Default the definition of "small data" to 8 bytes. */
1.7530 ++/* ??? How come I can't use HOST_WIDE_INT here? */
1.7531 ++extern unsigned long nios2_section_threshold;
1.7532 ++#define NIOS2_DEFAULT_GVALUE 8
1.7533 ++
1.7534 ++
1.7535 ++
1.7536 ++/* This says how to output assembler code to declare an
1.7537 ++ uninitialized external linkage data object. Under SVR4,
1.7538 ++ the linker seems to want the alignment of data objects
1.7539 ++ to depend on their types. We do exactly that here. */
1.7540 ++
1.7541 ++#undef COMMON_ASM_OP
1.7542 ++#define COMMON_ASM_OP "\t.comm\t"
1.7543 ++
1.7544 ++#undef ASM_OUTPUT_ALIGNED_COMMON
1.7545 ++#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
1.7546 ++do \
1.7547 ++{ \
1.7548 ++ if ((SIZE) <= nios2_section_threshold) \
1.7549 ++ { \
1.7550 ++ named_section (0, ".sbss", 0); \
1.7551 ++ (*targetm.asm_out.globalize_label) (FILE, NAME); \
1.7552 ++ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
1.7553 ++ if (!flag_inhibit_size_directive) \
1.7554 ++ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
1.7555 ++ ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
1.7556 ++ ASM_OUTPUT_LABEL(FILE, NAME); \
1.7557 ++ ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
1.7558 ++ } \
1.7559 ++ else \
1.7560 ++ { \
1.7561 ++ fprintf ((FILE), "%s", COMMON_ASM_OP); \
1.7562 ++ assemble_name ((FILE), (NAME)); \
1.7563 ++ fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
1.7564 ++ } \
1.7565 ++} \
1.7566 ++while (0)
1.7567 ++
1.7568 ++
1.7569 ++/* This says how to output assembler code to declare an
1.7570 ++ uninitialized internal linkage data object. Under SVR4,
1.7571 ++ the linker seems to want the alignment of data objects
1.7572 ++ to depend on their types. We do exactly that here. */
1.7573 ++
1.7574 ++#undef ASM_OUTPUT_ALIGNED_LOCAL
1.7575 ++#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
1.7576 ++do { \
1.7577 ++ if ((SIZE) <= nios2_section_threshold) \
1.7578 ++ named_section (0, ".sbss", 0); \
1.7579 ++ else \
1.7580 ++ named_section (0, ".bss", 0); \
1.7581 ++ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
1.7582 ++ if (!flag_inhibit_size_directive) \
1.7583 ++ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
1.7584 ++ ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
1.7585 ++ ASM_OUTPUT_LABEL(FILE, NAME); \
1.7586 ++ ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
1.7587 ++} while (0)
1.7588 ++
1.7589 ++
1.7590 ++
1.7591 ++/***************************
1.7592 ++ * Miscellaneous Parameters
1.7593 ++ ***************************/
1.7594 ++
1.7595 ++#define MOVE_MAX 4
1.7596 ++
1.7597 ++#define Pmode SImode
1.7598 ++#define FUNCTION_MODE QImode
1.7599 ++
1.7600 ++#define CASE_VECTOR_MODE Pmode
1.7601 ++
1.7602 ++#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1.7603 ++
1.7604 ++#define LOAD_EXTEND_OP(MODE) (ZERO_EXTEND)
1.7605 ++
1.7606 ++#define WORD_REGISTER_OPERATIONS
1.7607 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2.md gcc-3.4.6/gcc/config/nios2/nios2.md
1.7608 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2.md 1970-01-01 01:00:00.000000000 +0100
1.7609 ++++ gcc-3.4.6/gcc/config/nios2/nios2.md 2007-08-15 23:09:36.000000000 +0200
1.7610 +@@ -0,0 +1,2078 @@
1.7611 ++;; Machine Description for Altera NIOS 2G NIOS2 version.
1.7612 ++;; Copyright (C) 2003 Altera
1.7613 ++;; Contributed by Jonah Graham (jgraham@altera.com).
1.7614 ++;;
1.7615 ++;; This file is part of GNU CC.
1.7616 ++;;
1.7617 ++;; GNU CC is free software; you can redistribute it and/or modify
1.7618 ++;; it under the terms of the GNU General Public License as published by
1.7619 ++;; the Free Software Foundation; either version 2, or (at your option)
1.7620 ++;; any later version.
1.7621 ++;;
1.7622 ++;; GNU CC is distributed in the hope that it will be useful,
1.7623 ++;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1.7624 ++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.7625 ++;; GNU General Public License for more details.
1.7626 ++;;
1.7627 ++;; You should have received a copy of the GNU General Public License
1.7628 ++;; along with GNU CC; see the file COPYING. If not, write to
1.7629 ++;; the Free Software Foundation, 59 Temple Place - Suite 330,
1.7630 ++;; Boston, MA 02111-1307, USA. */
1.7631 ++
1.7632 ++
1.7633 ++
1.7634 ++;*****************************************************************************
1.7635 ++;*
1.7636 ++;* constants
1.7637 ++;*
1.7638 ++;*****************************************************************************
1.7639 ++(define_constants [
1.7640 ++ (GP_REGNO 26)
1.7641 ++ (SP_REGNO 27)
1.7642 ++ (FP_REGNO 28)
1.7643 ++ (RA_REGNO 31)
1.7644 ++ (RAP_REGNO 38)
1.7645 ++ (FIRST_RETVAL_REGNO 2)
1.7646 ++ (LAST_RETVAL_REGNO 3)
1.7647 ++ (FIRST_ARG_REGNO 4)
1.7648 ++ (LAST_ARG_REGNO 7)
1.7649 ++ (SC_REGNO 23)
1.7650 ++ (PC_REGNO 37)
1.7651 ++ (FAKE_FP_REGNO 39)
1.7652 ++ (FAKE_AP_REGNO 40)
1.7653 ++
1.7654 ++
1.7655 ++ (UNSPEC_BLOCKAGE 0)
1.7656 ++ (UNSPEC_LDBIO 1)
1.7657 ++ (UNSPEC_LDBUIO 2)
1.7658 ++ (UNSPEC_LDHIO 3)
1.7659 ++ (UNSPEC_LDHUIO 4)
1.7660 ++ (UNSPEC_LDWIO 5)
1.7661 ++ (UNSPEC_STBIO 6)
1.7662 ++ (UNSPEC_STHIO 7)
1.7663 ++ (UNSPEC_STWIO 8)
1.7664 ++ (UNSPEC_SYNC 9)
1.7665 ++ (UNSPEC_WRCTL 10)
1.7666 ++ (UNSPEC_RDCTL 11)
1.7667 ++
1.7668 ++])
1.7669 ++
1.7670 ++
1.7671 ++
1.7672 ++;*****************************************************************************
1.7673 ++;*
1.7674 ++;* instruction scheduler
1.7675 ++;*
1.7676 ++;*****************************************************************************
1.7677 ++
1.7678 ++; No schedule info is currently available, using an assumption that no
1.7679 ++; instruction can use the results of the previous instruction without
1.7680 ++; incuring a stall.
1.7681 ++
1.7682 ++; length of an instruction (in bytes)
1.7683 ++(define_attr "length" "" (const_int 4))
1.7684 ++(define_attr "type" "unknown,complex,control,alu,cond_alu,st,ld,shift,mul,div,custom" (const_string "complex"))
1.7685 ++
1.7686 ++(define_asm_attributes
1.7687 ++ [(set_attr "length" "4")
1.7688 ++ (set_attr "type" "complex")])
1.7689 ++
1.7690 ++(define_automaton "nios2")
1.7691 ++(automata_option "v")
1.7692 ++;(automata_option "no-minimization")
1.7693 ++(automata_option "ndfa")
1.7694 ++
1.7695 ++; The nios2 pipeline is fairly straightforward for the fast model.
1.7696 ++; Every alu operation is pipelined so that an instruction can
1.7697 ++; be issued every cycle. However, there are still potential
1.7698 ++; stalls which this description tries to deal with.
1.7699 ++
1.7700 ++(define_cpu_unit "cpu" "nios2")
1.7701 ++
1.7702 ++(define_insn_reservation "complex" 1
1.7703 ++ (eq_attr "type" "complex")
1.7704 ++ "cpu")
1.7705 ++
1.7706 ++(define_insn_reservation "control" 1
1.7707 ++ (eq_attr "type" "control")
1.7708 ++ "cpu")
1.7709 ++
1.7710 ++(define_insn_reservation "alu" 1
1.7711 ++ (eq_attr "type" "alu")
1.7712 ++ "cpu")
1.7713 ++
1.7714 ++(define_insn_reservation "cond_alu" 1
1.7715 ++ (eq_attr "type" "cond_alu")
1.7716 ++ "cpu")
1.7717 ++
1.7718 ++(define_insn_reservation "st" 1
1.7719 ++ (eq_attr "type" "st")
1.7720 ++ "cpu")
1.7721 ++
1.7722 ++(define_insn_reservation "custom" 1
1.7723 ++ (eq_attr "type" "custom")
1.7724 ++ "cpu")
1.7725 ++
1.7726 ++; shifts, muls and lds have three cycle latency
1.7727 ++(define_insn_reservation "ld" 3
1.7728 ++ (eq_attr "type" "ld")
1.7729 ++ "cpu")
1.7730 ++
1.7731 ++(define_insn_reservation "shift" 3
1.7732 ++ (eq_attr "type" "shift")
1.7733 ++ "cpu")
1.7734 ++
1.7735 ++(define_insn_reservation "mul" 3
1.7736 ++ (eq_attr "type" "mul")
1.7737 ++ "cpu")
1.7738 ++
1.7739 ++(define_insn_reservation "div" 1
1.7740 ++ (eq_attr "type" "div")
1.7741 ++ "cpu")
1.7742 ++
1.7743 ++
1.7744 ++;*****************************************************************************
1.7745 ++;*
1.7746 ++;* MOV Instructions
1.7747 ++;*
1.7748 ++;*****************************************************************************
1.7749 ++
1.7750 ++(define_expand "movqi"
1.7751 ++ [(set (match_operand:QI 0 "nonimmediate_operand" "")
1.7752 ++ (match_operand:QI 1 "general_operand" ""))]
1.7753 ++ ""
1.7754 ++{
1.7755 ++ if (nios2_emit_move_sequence (operands, QImode))
1.7756 ++ DONE;
1.7757 ++})
1.7758 ++
1.7759 ++(define_insn "movqi_internal"
1.7760 ++ [(set (match_operand:QI 0 "nonimmediate_operand" "=m, r,r, r")
1.7761 ++ (match_operand:QI 1 "general_operand" "rM,m,rM,I"))]
1.7762 ++ "(register_operand (operands[0], QImode)
1.7763 ++ || register_operand (operands[1], QImode)
1.7764 ++ || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
1.7765 ++ "@
1.7766 ++ stb%o0\\t%z1, %0
1.7767 ++ ldbu%o1\\t%0, %1
1.7768 ++ mov\\t%0, %z1
1.7769 ++ movi\\t%0, %1"
1.7770 ++ [(set_attr "type" "st,ld,alu,alu")])
1.7771 ++
1.7772 ++(define_insn "ldbio"
1.7773 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7774 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDBIO))
1.7775 ++ (use (match_operand:SI 1 "memory_operand" "m"))]
1.7776 ++ ""
1.7777 ++ "ldbio\\t%0, %1"
1.7778 ++ [(set_attr "type" "ld")])
1.7779 ++
1.7780 ++(define_insn "ldbuio"
1.7781 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7782 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDBUIO))
1.7783 ++ (use (match_operand:SI 1 "memory_operand" "m"))]
1.7784 ++ ""
1.7785 ++ "ldbuio\\t%0, %1"
1.7786 ++ [(set_attr "type" "ld")])
1.7787 ++
1.7788 ++(define_insn "stbio"
1.7789 ++ [(set (match_operand:SI 0 "memory_operand" "=m")
1.7790 ++ (match_operand:SI 1 "register_operand" "r"))
1.7791 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STBIO)]
1.7792 ++ ""
1.7793 ++ "stbio\\t%z1, %0"
1.7794 ++ [(set_attr "type" "st")])
1.7795 ++
1.7796 ++
1.7797 ++(define_expand "movhi"
1.7798 ++ [(set (match_operand:HI 0 "nonimmediate_operand" "")
1.7799 ++ (match_operand:HI 1 "general_operand" ""))]
1.7800 ++ ""
1.7801 ++{
1.7802 ++ if (nios2_emit_move_sequence (operands, HImode))
1.7803 ++ DONE;
1.7804 ++})
1.7805 ++
1.7806 ++(define_insn "movhi_internal"
1.7807 ++ [(set (match_operand:HI 0 "nonimmediate_operand" "=m, r,r, r,r")
1.7808 ++ (match_operand:HI 1 "general_operand" "rM,m,rM,I,J"))]
1.7809 ++ "(register_operand (operands[0], HImode)
1.7810 ++ || register_operand (operands[1], HImode)
1.7811 ++ || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
1.7812 ++ "@
1.7813 ++ sth%o0\\t%z1, %0
1.7814 ++ ldhu%o1\\t%0, %1
1.7815 ++ mov\\t%0, %z1
1.7816 ++ movi\\t%0, %1
1.7817 ++ movui\\t%0, %1"
1.7818 ++ [(set_attr "type" "st,ld,alu,alu,alu")])
1.7819 ++
1.7820 ++(define_insn "ldhio"
1.7821 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7822 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDHIO))
1.7823 ++ (use (match_operand:SI 1 "memory_operand" "m"))]
1.7824 ++ ""
1.7825 ++ "ldhio\\t%0, %1"
1.7826 ++ [(set_attr "type" "ld")])
1.7827 ++
1.7828 ++(define_insn "ldhuio"
1.7829 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7830 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDHUIO))
1.7831 ++ (use (match_operand:SI 1 "memory_operand" "m"))]
1.7832 ++ ""
1.7833 ++ "ldhuio\\t%0, %1"
1.7834 ++ [(set_attr "type" "ld")])
1.7835 ++
1.7836 ++(define_insn "sthio"
1.7837 ++ [(set (match_operand:SI 0 "memory_operand" "=m")
1.7838 ++ (match_operand:SI 1 "register_operand" "r"))
1.7839 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STHIO)]
1.7840 ++ ""
1.7841 ++ "sthio\\t%z1, %0"
1.7842 ++ [(set_attr "type" "st")])
1.7843 ++
1.7844 ++(define_expand "movsi"
1.7845 ++ [(set (match_operand:SI 0 "nonimmediate_operand" "")
1.7846 ++ (match_operand:SI 1 "general_operand" ""))]
1.7847 ++ ""
1.7848 ++{
1.7849 ++ if (nios2_emit_move_sequence (operands, SImode))
1.7850 ++ DONE;
1.7851 ++})
1.7852 ++
1.7853 ++(define_insn "movsi_internal"
1.7854 ++ [(set (match_operand:SI 0 "nonimmediate_operand" "=m, r,r, r,r,r,r")
1.7855 ++ (match_operand:SI 1 "general_operand" "rM,m,rM,I,J,S,i"))]
1.7856 ++ "(register_operand (operands[0], SImode)
1.7857 ++ || register_operand (operands[1], SImode)
1.7858 ++ || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
1.7859 ++ "@
1.7860 ++ stw%o0\\t%z1, %0
1.7861 ++ ldw%o1\\t%0, %1
1.7862 ++ mov\\t%0, %z1
1.7863 ++ movi\\t%0, %1
1.7864 ++ movui\\t%0, %1
1.7865 ++ addi\\t%0, gp, %%gprel(%1)
1.7866 ++ movhi\\t%0, %H1\;addi\\t%0, %0, %L1"
1.7867 ++ [(set_attr "type" "st,ld,alu,alu,alu,alu,alu")])
1.7868 ++
1.7869 ++(define_insn "ldwio"
1.7870 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7871 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_LDWIO))
1.7872 ++ (use (match_operand:SI 1 "memory_operand" "m"))]
1.7873 ++ ""
1.7874 ++ "ldwio\\t%0, %1"
1.7875 ++ [(set_attr "type" "ld")])
1.7876 ++
1.7877 ++(define_insn "stwio"
1.7878 ++ [(set (match_operand:SI 0 "memory_operand" "=m")
1.7879 ++ (match_operand:SI 1 "register_operand" "r"))
1.7880 ++ (unspec_volatile:SI [(const_int 0)] UNSPEC_STWIO)]
1.7881 ++ ""
1.7882 ++ "stwio\\t%z1, %0"
1.7883 ++ [(set_attr "type" "st")])
1.7884 ++
1.7885 ++
1.7886 ++
1.7887 ++;*****************************************************************************
1.7888 ++;*
1.7889 ++;* zero extension
1.7890 ++;*
1.7891 ++;*****************************************************************************
1.7892 ++
1.7893 ++
1.7894 ++(define_insn "zero_extendhisi2"
1.7895 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.7896 ++ (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1.7897 ++ ""
1.7898 ++ "@
1.7899 ++ andi\\t%0, %1, 0xffff
1.7900 ++ ldhu%o1\\t%0, %1"
1.7901 ++ [(set_attr "type" "alu,ld")])
1.7902 ++
1.7903 ++(define_insn "zero_extendqihi2"
1.7904 ++ [(set (match_operand:HI 0 "register_operand" "=r,r")
1.7905 ++ (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1.7906 ++ ""
1.7907 ++ "@
1.7908 ++ andi\\t%0, %1, 0xff
1.7909 ++ ldbu%o1\\t%0, %1"
1.7910 ++ [(set_attr "type" "alu,ld")])
1.7911 ++
1.7912 ++(define_insn "zero_extendqisi2"
1.7913 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.7914 ++ (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1.7915 ++ ""
1.7916 ++ "@
1.7917 ++ andi\\t%0, %1, 0xff
1.7918 ++ ldbu%o1\\t%0, %1"
1.7919 ++ [(set_attr "type" "alu,ld")])
1.7920 ++
1.7921 ++
1.7922 ++
1.7923 ++;*****************************************************************************
1.7924 ++;*
1.7925 ++;* sign extension
1.7926 ++;*
1.7927 ++;*****************************************************************************
1.7928 ++
1.7929 ++(define_expand "extendhisi2"
1.7930 ++ [(set (match_operand:SI 0 "register_operand" "")
1.7931 ++ (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
1.7932 ++ ""
1.7933 ++{
1.7934 ++ if (optimize && GET_CODE (operands[1]) == MEM)
1.7935 ++ operands[1] = force_not_mem (operands[1]);
1.7936 ++
1.7937 ++ if (GET_CODE (operands[1]) != MEM)
1.7938 ++ {
1.7939 ++ rtx op1 = gen_lowpart (SImode, operands[1]);
1.7940 ++ rtx temp = gen_reg_rtx (SImode);
1.7941 ++ rtx shift = GEN_INT (16);
1.7942 ++
1.7943 ++ emit_insn (gen_ashlsi3 (temp, op1, shift));
1.7944 ++ emit_insn (gen_ashrsi3 (operands[0], temp, shift));
1.7945 ++ DONE;
1.7946 ++ }
1.7947 ++})
1.7948 ++
1.7949 ++(define_insn "extendhisi2_internal"
1.7950 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.7951 ++ (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
1.7952 ++ ""
1.7953 ++ "ldh%o1\\t%0, %1"
1.7954 ++ [(set_attr "type" "ld")])
1.7955 ++
1.7956 ++(define_expand "extendqihi2"
1.7957 ++ [(set (match_operand:HI 0 "register_operand" "")
1.7958 ++ (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
1.7959 ++ ""
1.7960 ++{
1.7961 ++ if (optimize && GET_CODE (operands[1]) == MEM)
1.7962 ++ operands[1] = force_not_mem (operands[1]);
1.7963 ++
1.7964 ++ if (GET_CODE (operands[1]) != MEM)
1.7965 ++ {
1.7966 ++ rtx op0 = gen_lowpart (SImode, operands[0]);
1.7967 ++ rtx op1 = gen_lowpart (SImode, operands[1]);
1.7968 ++ rtx temp = gen_reg_rtx (SImode);
1.7969 ++ rtx shift = GEN_INT (24);
1.7970 ++
1.7971 ++ emit_insn (gen_ashlsi3 (temp, op1, shift));
1.7972 ++ emit_insn (gen_ashrsi3 (op0, temp, shift));
1.7973 ++ DONE;
1.7974 ++ }
1.7975 ++})
1.7976 ++
1.7977 ++(define_insn "extendqihi2_internal"
1.7978 ++ [(set (match_operand:HI 0 "register_operand" "=r")
1.7979 ++ (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
1.7980 ++ ""
1.7981 ++ "ldb%o1\\t%0, %1"
1.7982 ++ [(set_attr "type" "ld")])
1.7983 ++
1.7984 ++
1.7985 ++(define_expand "extendqisi2"
1.7986 ++ [(set (match_operand:SI 0 "register_operand" "")
1.7987 ++ (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1.7988 ++ ""
1.7989 ++{
1.7990 ++ if (optimize && GET_CODE (operands[1]) == MEM)
1.7991 ++ operands[1] = force_not_mem (operands[1]);
1.7992 ++
1.7993 ++ if (GET_CODE (operands[1]) != MEM)
1.7994 ++ {
1.7995 ++ rtx op1 = gen_lowpart (SImode, operands[1]);
1.7996 ++ rtx temp = gen_reg_rtx (SImode);
1.7997 ++ rtx shift = GEN_INT (24);
1.7998 ++
1.7999 ++ emit_insn (gen_ashlsi3 (temp, op1, shift));
1.8000 ++ emit_insn (gen_ashrsi3 (operands[0], temp, shift));
1.8001 ++ DONE;
1.8002 ++ }
1.8003 ++})
1.8004 ++
1.8005 ++(define_insn "extendqisi2_insn"
1.8006 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8007 ++ (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
1.8008 ++ ""
1.8009 ++ "ldb%o1\\t%0, %1"
1.8010 ++ [(set_attr "type" "ld")])
1.8011 ++
1.8012 ++
1.8013 ++
1.8014 ++;*****************************************************************************
1.8015 ++;*
1.8016 ++;* Arithmetic Operations
1.8017 ++;*
1.8018 ++;*****************************************************************************
1.8019 ++
1.8020 ++(define_insn "addsi3"
1.8021 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8022 ++ (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
1.8023 ++ (match_operand:SI 2 "arith_operand" "r,I")))]
1.8024 ++ ""
1.8025 ++ "add%i2\\t%0, %1, %z2"
1.8026 ++ [(set_attr "type" "alu")])
1.8027 ++
1.8028 ++(define_insn "subsi3"
1.8029 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8030 ++ (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8031 ++ (match_operand:SI 2 "register_operand" "r")))]
1.8032 ++ ""
1.8033 ++ "sub\\t%0, %z1, %2"
1.8034 ++ [(set_attr "type" "alu")])
1.8035 ++
1.8036 ++(define_insn "mulsi3"
1.8037 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8038 ++ (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1.8039 ++ (match_operand:SI 2 "arith_operand" "r,I")))]
1.8040 ++ "TARGET_HAS_MUL"
1.8041 ++ "mul%i2\\t%0, %1, %z2"
1.8042 ++ [(set_attr "type" "mul")])
1.8043 ++
1.8044 ++(define_expand "divsi3"
1.8045 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8046 ++ (div:SI (match_operand:SI 1 "register_operand" "r")
1.8047 ++ (match_operand:SI 2 "register_operand" "r")))]
1.8048 ++ ""
1.8049 ++{
1.8050 ++ if (!TARGET_HAS_DIV)
1.8051 ++ {
1.8052 ++ if (!TARGET_FAST_SW_DIV)
1.8053 ++ FAIL;
1.8054 ++ else
1.8055 ++ {
1.8056 ++ if (nios2_emit_expensive_div (operands, SImode))
1.8057 ++ DONE;
1.8058 ++ }
1.8059 ++ }
1.8060 ++})
1.8061 ++
1.8062 ++(define_insn "divsi3_insn"
1.8063 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8064 ++ (div:SI (match_operand:SI 1 "register_operand" "r")
1.8065 ++ (match_operand:SI 2 "register_operand" "r")))]
1.8066 ++ "TARGET_HAS_DIV"
1.8067 ++ "div\\t%0, %1, %2"
1.8068 ++ [(set_attr "type" "div")])
1.8069 ++
1.8070 ++(define_insn "udivsi3"
1.8071 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8072 ++ (udiv:SI (match_operand:SI 1 "register_operand" "r")
1.8073 ++ (match_operand:SI 2 "register_operand" "r")))]
1.8074 ++ "TARGET_HAS_DIV"
1.8075 ++ "divu\\t%0, %1, %2"
1.8076 ++ [(set_attr "type" "div")])
1.8077 ++
1.8078 ++(define_insn "smulsi3_highpart"
1.8079 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8080 ++ (truncate:SI
1.8081 ++ (lshiftrt:DI
1.8082 ++ (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
1.8083 ++ (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
1.8084 ++ (const_int 32))))]
1.8085 ++ "TARGET_HAS_MULX"
1.8086 ++ "mulxss\\t%0, %1, %2"
1.8087 ++ [(set_attr "type" "mul")])
1.8088 ++
1.8089 ++(define_insn "umulsi3_highpart"
1.8090 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8091 ++ (truncate:SI
1.8092 ++ (lshiftrt:DI
1.8093 ++ (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
1.8094 ++ (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
1.8095 ++ (const_int 32))))]
1.8096 ++ "TARGET_HAS_MULX"
1.8097 ++ "mulxuu\\t%0, %1, %2"
1.8098 ++ [(set_attr "type" "mul")])
1.8099 ++
1.8100 ++
1.8101 ++(define_expand "mulsidi3"
1.8102 ++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
1.8103 ++ (mult:SI (match_operand:SI 1 "register_operand" "")
1.8104 ++ (match_operand:SI 2 "register_operand" "")))
1.8105 ++ (set (subreg:SI (match_dup 0) 4)
1.8106 ++ (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
1.8107 ++ (sign_extend:DI (match_dup 2)))
1.8108 ++ (const_int 32))))]
1.8109 ++ "TARGET_HAS_MULX"
1.8110 ++ "")
1.8111 ++
1.8112 ++(define_expand "umulsidi3"
1.8113 ++ [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 0)
1.8114 ++ (mult:SI (match_operand:SI 1 "register_operand" "")
1.8115 ++ (match_operand:SI 2 "register_operand" "")))
1.8116 ++ (set (subreg:SI (match_dup 0) 4)
1.8117 ++ (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
1.8118 ++ (zero_extend:DI (match_dup 2)))
1.8119 ++ (const_int 32))))]
1.8120 ++ "TARGET_HAS_MULX"
1.8121 ++ "")
1.8122 ++
1.8123 ++
1.8124 ++
1.8125 ++;*****************************************************************************
1.8126 ++;*
1.8127 ++;* Negate and ones complement
1.8128 ++;*
1.8129 ++;*****************************************************************************
1.8130 ++
1.8131 ++(define_insn "negsi2"
1.8132 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8133 ++ (neg:SI (match_operand:SI 1 "register_operand" "r")))]
1.8134 ++ ""
1.8135 ++{
1.8136 ++ operands[2] = const0_rtx;
1.8137 ++ return "sub\\t%0, %z2, %1";
1.8138 ++}
1.8139 ++ [(set_attr "type" "alu")])
1.8140 ++
1.8141 ++(define_insn "one_cmplsi2"
1.8142 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8143 ++ (not:SI (match_operand:SI 1 "register_operand" "r")))]
1.8144 ++ ""
1.8145 ++{
1.8146 ++ operands[2] = const0_rtx;
1.8147 ++ return "nor\\t%0, %z2, %1";
1.8148 ++}
1.8149 ++ [(set_attr "type" "alu")])
1.8150 ++
1.8151 ++
1.8152 ++
1.8153 ++; Logical Operantions
1.8154 ++
1.8155 ++(define_insn "andsi3"
1.8156 ++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
1.8157 ++ (and:SI (match_operand:SI 1 "register_operand" "%r, r,r")
1.8158 ++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
1.8159 ++ ""
1.8160 ++ "@
1.8161 ++ and\\t%0, %1, %z2
1.8162 ++ and%i2\\t%0, %1, %2
1.8163 ++ andh%i2\\t%0, %1, %U2"
1.8164 ++ [(set_attr "type" "alu")])
1.8165 ++
1.8166 ++(define_insn "iorsi3"
1.8167 ++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
1.8168 ++ (ior:SI (match_operand:SI 1 "register_operand" "%r, r,r")
1.8169 ++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
1.8170 ++ ""
1.8171 ++ "@
1.8172 ++ or\\t%0, %1, %z2
1.8173 ++ or%i2\\t%0, %1, %2
1.8174 ++ orh%i2\\t%0, %1, %U2"
1.8175 ++ [(set_attr "type" "alu")])
1.8176 ++
1.8177 ++(define_insn "*norsi3"
1.8178 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8179 ++ (and:SI (not:SI (match_operand:SI 1 "register_operand" "%r"))
1.8180 ++ (not:SI (match_operand:SI 2 "reg_or_0_operand" "rM"))))]
1.8181 ++ ""
1.8182 ++ "nor\\t%0, %1, %z2"
1.8183 ++ [(set_attr "type" "alu")])
1.8184 ++
1.8185 ++(define_insn "xorsi3"
1.8186 ++ [(set (match_operand:SI 0 "register_operand" "=r, r,r")
1.8187 ++ (xor:SI (match_operand:SI 1 "register_operand" "%r, r,r")
1.8188 ++ (match_operand:SI 2 "logical_operand" "rM,J,K")))]
1.8189 ++ ""
1.8190 ++ "@
1.8191 ++ xor\\t%0, %1, %z2
1.8192 ++ xor%i2\\t%0, %1, %2
1.8193 ++ xorh%i2\\t%0, %1, %U2"
1.8194 ++ [(set_attr "type" "alu")])
1.8195 ++
1.8196 ++
1.8197 ++
1.8198 ++;*****************************************************************************
1.8199 ++;*
1.8200 ++;* Shifts
1.8201 ++;*
1.8202 ++;*****************************************************************************
1.8203 ++
1.8204 ++(define_insn "ashlsi3"
1.8205 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8206 ++ (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
1.8207 ++ (match_operand:SI 2 "shift_operand" "r,L")))]
1.8208 ++ ""
1.8209 ++ "sll%i2\\t%0, %1, %z2"
1.8210 ++ [(set_attr "type" "shift")])
1.8211 ++
1.8212 ++(define_insn "ashrsi3"
1.8213 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8214 ++ (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
1.8215 ++ (match_operand:SI 2 "shift_operand" "r,L")))]
1.8216 ++ ""
1.8217 ++ "sra%i2\\t%0, %1, %z2"
1.8218 ++ [(set_attr "type" "shift")])
1.8219 ++
1.8220 ++(define_insn "lshrsi3"
1.8221 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8222 ++ (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
1.8223 ++ (match_operand:SI 2 "shift_operand" "r,L")))]
1.8224 ++ ""
1.8225 ++ "srl%i2\\t%0, %1, %z2"
1.8226 ++ [(set_attr "type" "shift")])
1.8227 ++
1.8228 ++(define_insn "rotlsi3"
1.8229 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8230 ++ (rotate:SI (match_operand:SI 1 "register_operand" "r,r")
1.8231 ++ (match_operand:SI 2 "shift_operand" "r,L")))]
1.8232 ++ ""
1.8233 ++ "rol%i2\\t%0, %1, %z2"
1.8234 ++ [(set_attr "type" "shift")])
1.8235 ++
1.8236 ++(define_insn "rotrsi3"
1.8237 ++ [(set (match_operand:SI 0 "register_operand" "=r,r")
1.8238 ++ (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
1.8239 ++ (match_operand:SI 2 "register_operand" "r,r")))]
1.8240 ++ ""
1.8241 ++ "ror\\t%0, %1, %2"
1.8242 ++ [(set_attr "type" "shift")])
1.8243 ++
1.8244 ++(define_insn "*shift_mul_constants"
1.8245 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8246 ++ (ashift:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
1.8247 ++ (match_operand:SI 2 "const_int_operand" "I"))
1.8248 ++ (match_operand:SI 3 "const_int_operand" "I")))]
1.8249 ++ "TARGET_HAS_MUL && SMALL_INT (INTVAL (operands[2]) << INTVAL (operands[3]))"
1.8250 ++{
1.8251 ++ HOST_WIDE_INT mul = INTVAL (operands[2]) << INTVAL (operands[3]);
1.8252 ++ rtx ops[3];
1.8253 ++
1.8254 ++ ops[0] = operands[0];
1.8255 ++ ops[1] = operands[1];
1.8256 ++ ops[2] = GEN_INT (mul);
1.8257 ++
1.8258 ++ output_asm_insn ("muli\t%0, %1, %2", ops);
1.8259 ++ return "";
1.8260 ++}
1.8261 ++ [(set_attr "type" "mul")])
1.8262 ++
1.8263 ++
1.8264 ++
1.8265 ++
1.8266 ++;*****************************************************************************
1.8267 ++;*
1.8268 ++;* Prologue, Epilogue and Return
1.8269 ++;*
1.8270 ++;*****************************************************************************
1.8271 ++
1.8272 ++(define_expand "prologue"
1.8273 ++ [(const_int 1)]
1.8274 ++ ""
1.8275 ++{
1.8276 ++ expand_prologue ();
1.8277 ++ DONE;
1.8278 ++})
1.8279 ++
1.8280 ++(define_expand "epilogue"
1.8281 ++ [(return)]
1.8282 ++ ""
1.8283 ++{
1.8284 ++ expand_epilogue (false);
1.8285 ++ DONE;
1.8286 ++})
1.8287 ++
1.8288 ++(define_expand "sibcall_epilogue"
1.8289 ++ [(return)]
1.8290 ++ ""
1.8291 ++{
1.8292 ++ expand_epilogue (true);
1.8293 ++ DONE;
1.8294 ++})
1.8295 ++
1.8296 ++(define_insn "return"
1.8297 ++ [(return)]
1.8298 ++ "reload_completed && nios2_can_use_return_insn ()"
1.8299 ++ "ret\\t"
1.8300 ++)
1.8301 ++
1.8302 ++(define_insn "return_from_epilogue"
1.8303 ++ [(use (match_operand 0 "pmode_register_operand" ""))
1.8304 ++ (return)]
1.8305 ++ "reload_completed"
1.8306 ++ "ret\\t"
1.8307 ++)
1.8308 ++
1.8309 ++;; Block any insns from being moved before this point, since the
1.8310 ++;; profiling call to mcount can use various registers that aren't
1.8311 ++;; saved or used to pass arguments.
1.8312 ++
1.8313 ++(define_insn "blockage"
1.8314 ++ [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
1.8315 ++ ""
1.8316 ++ ""
1.8317 ++ [(set_attr "type" "unknown")
1.8318 ++ (set_attr "length" "0")])
1.8319 ++
1.8320 ++
1.8321 ++
1.8322 ++;*****************************************************************************
1.8323 ++;*
1.8324 ++;* Jumps and Calls
1.8325 ++;*
1.8326 ++;*****************************************************************************
1.8327 ++
1.8328 ++(define_insn "indirect_jump"
1.8329 ++ [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1.8330 ++ ""
1.8331 ++ "jmp\\t%0"
1.8332 ++ [(set_attr "type" "control")])
1.8333 ++
1.8334 ++(define_insn "jump"
1.8335 ++ [(set (pc)
1.8336 ++ (label_ref (match_operand 0 "" "")))]
1.8337 ++ ""
1.8338 ++ "br\\t%0"
1.8339 ++ [(set_attr "type" "control")])
1.8340 ++
1.8341 ++
1.8342 ++(define_insn "indirect_call"
1.8343 ++ [(call (mem:QI (match_operand:SI 0 "register_operand" "r"))
1.8344 ++ (match_operand 1 "" ""))
1.8345 ++ (clobber (reg:SI RA_REGNO))]
1.8346 ++ ""
1.8347 ++ "callr\\t%0"
1.8348 ++ [(set_attr "type" "control")])
1.8349 ++
1.8350 ++(define_insn "indirect_call_value"
1.8351 ++ [(set (match_operand 0 "" "")
1.8352 ++ (call (mem:QI (match_operand:SI 1 "register_operand" "r"))
1.8353 ++ (match_operand 2 "" "")))
1.8354 ++ (clobber (reg:SI RA_REGNO))]
1.8355 ++ ""
1.8356 ++ "callr\\t%1"
1.8357 ++)
1.8358 ++
1.8359 ++(define_expand "call"
1.8360 ++ [(parallel [(call (match_operand 0 "" "")
1.8361 ++ (match_operand 1 "" ""))
1.8362 ++ (clobber (reg:SI RA_REGNO))])]
1.8363 ++ ""
1.8364 ++ "")
1.8365 ++
1.8366 ++(define_expand "call_value"
1.8367 ++ [(parallel [(set (match_operand 0 "" "")
1.8368 ++ (call (match_operand 1 "" "")
1.8369 ++ (match_operand 2 "" "")))
1.8370 ++ (clobber (reg:SI RA_REGNO))])]
1.8371 ++ ""
1.8372 ++ "")
1.8373 ++
1.8374 ++(define_insn "*call"
1.8375 ++ [(call (mem:QI (match_operand:SI 0 "immediate_operand" "i"))
1.8376 ++ (match_operand 1 "" ""))
1.8377 ++ (clobber (match_operand:SI 2 "register_operand" "=r"))]
1.8378 ++ ""
1.8379 ++ "call\\t%0"
1.8380 ++ [(set_attr "type" "control")])
1.8381 ++
1.8382 ++(define_insn "*call_value"
1.8383 ++ [(set (match_operand 0 "" "")
1.8384 ++ (call (mem:QI (match_operand:SI 1 "immediate_operand" "i"))
1.8385 ++ (match_operand 2 "" "")))
1.8386 ++ (clobber (match_operand:SI 3 "register_operand" "=r"))]
1.8387 ++ ""
1.8388 ++ "call\\t%1"
1.8389 ++ [(set_attr "type" "control")])
1.8390 ++
1.8391 ++(define_expand "sibcall"
1.8392 ++ [(parallel [(call (match_operand 0 "" "")
1.8393 ++ (match_operand 1 "" ""))
1.8394 ++ (return)
1.8395 ++ (use (match_operand 2 "" ""))])]
1.8396 ++ ""
1.8397 ++ {
1.8398 ++ XEXP (operands[0], 0) = copy_to_mode_reg (SImode, XEXP (operands[0], 0));
1.8399 ++
1.8400 ++ if (operands[2] == NULL_RTX)
1.8401 ++ operands[2] = const0_rtx;
1.8402 ++ }
1.8403 ++)
1.8404 ++
1.8405 ++(define_expand "sibcall_value"
1.8406 ++ [(parallel [(set (match_operand 0 "" "")
1.8407 ++ (call (match_operand 1 "" "")
1.8408 ++ (match_operand 2 "" "")))
1.8409 ++ (return)
1.8410 ++ (use (match_operand 3 "" ""))])]
1.8411 ++ ""
1.8412 ++ {
1.8413 ++ XEXP (operands[1], 0) = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
1.8414 ++
1.8415 ++ if (operands[3] == NULL_RTX)
1.8416 ++ operands[3] = const0_rtx;
1.8417 ++ }
1.8418 ++)
1.8419 ++
1.8420 ++(define_insn "sibcall_insn"
1.8421 ++ [(call (mem:QI (match_operand:SI 0 "register_operand" "r"))
1.8422 ++ (match_operand 1 "" ""))
1.8423 ++ (return)
1.8424 ++ (use (match_operand 2 "" ""))]
1.8425 ++ ""
1.8426 ++ "jmp\\t%0"
1.8427 ++)
1.8428 ++
1.8429 ++(define_insn "sibcall_value_insn"
1.8430 ++ [(set (match_operand 0 "register_operand" "")
1.8431 ++ (call (mem:QI (match_operand:SI 1 "register_operand" "r"))
1.8432 ++ (match_operand 2 "" "")))
1.8433 ++ (return)
1.8434 ++ (use (match_operand 3 "" ""))]
1.8435 ++ ""
1.8436 ++ "jmp\\t%1"
1.8437 ++)
1.8438 ++
1.8439 ++
1.8440 ++
1.8441 ++
1.8442 ++(define_expand "tablejump"
1.8443 ++ [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
1.8444 ++ (use (label_ref (match_operand 1 "" "")))])]
1.8445 ++ ""
1.8446 ++ ""
1.8447 ++)
1.8448 ++
1.8449 ++(define_insn "*tablejump"
1.8450 ++ [(set (pc)
1.8451 ++ (match_operand:SI 0 "register_operand" "r"))
1.8452 ++ (use (label_ref (match_operand 1 "" "")))]
1.8453 ++ ""
1.8454 ++ "jmp\\t%0"
1.8455 ++ [(set_attr "type" "control")])
1.8456 ++
1.8457 ++
1.8458 ++
1.8459 ++;*****************************************************************************
1.8460 ++;*
1.8461 ++;* Comparisons
1.8462 ++;*
1.8463 ++;*****************************************************************************
1.8464 ++;; Flow here is rather complex (based on MIPS):
1.8465 ++;;
1.8466 ++;; 1) The cmp{si,di,sf,df} routine is called. It deposits the
1.8467 ++;; arguments into the branch_cmp array, and the type into
1.8468 ++;; branch_type. No RTL is generated.
1.8469 ++;;
1.8470 ++;; 2) The appropriate branch define_expand is called, which then
1.8471 ++;; creates the appropriate RTL for the comparison and branch.
1.8472 ++;; Different CC modes are used, based on what type of branch is
1.8473 ++;; done, so that we can constrain things appropriately. There
1.8474 ++;; are assumptions in the rest of GCC that break if we fold the
1.8475 ++;; operands into the branchs for integer operations, and use cc0
1.8476 ++;; for floating point, so we use the fp status register instead.
1.8477 ++;; If needed, an appropriate temporary is created to hold the
1.8478 ++;; of the integer compare.
1.8479 ++
1.8480 ++(define_expand "cmpsi"
1.8481 ++ [(set (cc0)
1.8482 ++ (compare:CC (match_operand:SI 0 "register_operand" "")
1.8483 ++ (match_operand:SI 1 "arith_operand" "")))]
1.8484 ++ ""
1.8485 ++{
1.8486 ++ branch_cmp[0] = operands[0];
1.8487 ++ branch_cmp[1] = operands[1];
1.8488 ++ branch_type = CMP_SI;
1.8489 ++ DONE;
1.8490 ++})
1.8491 ++
1.8492 ++(define_expand "tstsi"
1.8493 ++ [(set (cc0)
1.8494 ++ (match_operand:SI 0 "register_operand" ""))]
1.8495 ++ ""
1.8496 ++{
1.8497 ++ branch_cmp[0] = operands[0];
1.8498 ++ branch_cmp[1] = const0_rtx;
1.8499 ++ branch_type = CMP_SI;
1.8500 ++ DONE;
1.8501 ++})
1.8502 ++
1.8503 ++
1.8504 ++;*****************************************************************************
1.8505 ++;*
1.8506 ++;* setting a register from a comparison
1.8507 ++;*
1.8508 ++;*****************************************************************************
1.8509 ++
1.8510 ++(define_expand "seq"
1.8511 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8512 ++ (eq:SI (match_dup 1)
1.8513 ++ (match_dup 2)))]
1.8514 ++ ""
1.8515 ++{
1.8516 ++ if (branch_type != CMP_SI)
1.8517 ++ FAIL;
1.8518 ++
1.8519 ++ /* set up operands from compare. */
1.8520 ++ operands[1] = branch_cmp[0];
1.8521 ++ operands[2] = branch_cmp[1];
1.8522 ++
1.8523 ++ gen_int_relational (EQ, operands[0], operands[1], operands[2], NULL_RTX);
1.8524 ++ DONE;
1.8525 ++})
1.8526 ++
1.8527 ++
1.8528 ++(define_insn "*seq"
1.8529 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8530 ++ (eq:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
1.8531 ++ (match_operand:SI 2 "arith_operand" "rI")))]
1.8532 ++ ""
1.8533 ++ "cmpeq%i2\\t%0, %z1, %z2"
1.8534 ++ [(set_attr "type" "alu")])
1.8535 ++
1.8536 ++
1.8537 ++(define_expand "sne"
1.8538 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8539 ++ (ne:SI (match_dup 1)
1.8540 ++ (match_dup 2)))]
1.8541 ++ ""
1.8542 ++{
1.8543 ++ if (branch_type != CMP_SI)
1.8544 ++ FAIL;
1.8545 ++
1.8546 ++ /* set up operands from compare. */
1.8547 ++ operands[1] = branch_cmp[0];
1.8548 ++ operands[2] = branch_cmp[1];
1.8549 ++
1.8550 ++ gen_int_relational (NE, operands[0], operands[1], operands[2], NULL_RTX);
1.8551 ++ DONE;
1.8552 ++})
1.8553 ++
1.8554 ++
1.8555 ++(define_insn "*sne"
1.8556 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8557 ++ (ne:SI (match_operand:SI 1 "reg_or_0_operand" "%rM")
1.8558 ++ (match_operand:SI 2 "arith_operand" "rI")))]
1.8559 ++ ""
1.8560 ++ "cmpne%i2\\t%0, %z1, %z2"
1.8561 ++ [(set_attr "type" "alu")])
1.8562 ++
1.8563 ++
1.8564 ++(define_expand "sgt"
1.8565 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8566 ++ (gt:SI (match_dup 1)
1.8567 ++ (match_dup 2)))]
1.8568 ++ ""
1.8569 ++{
1.8570 ++ if (branch_type != CMP_SI)
1.8571 ++ FAIL;
1.8572 ++
1.8573 ++ /* set up operands from compare. */
1.8574 ++ operands[1] = branch_cmp[0];
1.8575 ++ operands[2] = branch_cmp[1];
1.8576 ++
1.8577 ++ gen_int_relational (GT, operands[0], operands[1], operands[2], NULL_RTX);
1.8578 ++ DONE;
1.8579 ++})
1.8580 ++
1.8581 ++
1.8582 ++(define_insn "*sgt"
1.8583 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8584 ++ (gt:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8585 ++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
1.8586 ++ ""
1.8587 ++ "cmplt\\t%0, %z2, %z1"
1.8588 ++ [(set_attr "type" "alu")])
1.8589 ++
1.8590 ++
1.8591 ++(define_expand "sge"
1.8592 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8593 ++ (ge:SI (match_dup 1)
1.8594 ++ (match_dup 2)))]
1.8595 ++ ""
1.8596 ++{
1.8597 ++ if (branch_type != CMP_SI)
1.8598 ++ FAIL;
1.8599 ++
1.8600 ++ /* set up operands from compare. */
1.8601 ++ operands[1] = branch_cmp[0];
1.8602 ++ operands[2] = branch_cmp[1];
1.8603 ++
1.8604 ++ gen_int_relational (GE, operands[0], operands[1], operands[2], NULL_RTX);
1.8605 ++ DONE;
1.8606 ++})
1.8607 ++
1.8608 ++
1.8609 ++(define_insn "*sge"
1.8610 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8611 ++ (ge:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8612 ++ (match_operand:SI 2 "arith_operand" "rI")))]
1.8613 ++ ""
1.8614 ++ "cmpge%i2\\t%0, %z1, %z2"
1.8615 ++ [(set_attr "type" "alu")])
1.8616 ++
1.8617 ++(define_expand "sle"
1.8618 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8619 ++ (le:SI (match_dup 1)
1.8620 ++ (match_dup 2)))]
1.8621 ++ ""
1.8622 ++{
1.8623 ++ if (branch_type != CMP_SI)
1.8624 ++ FAIL;
1.8625 ++
1.8626 ++ /* set up operands from compare. */
1.8627 ++ operands[1] = branch_cmp[0];
1.8628 ++ operands[2] = branch_cmp[1];
1.8629 ++
1.8630 ++ gen_int_relational (LE, operands[0], operands[1], operands[2], NULL_RTX);
1.8631 ++ DONE;
1.8632 ++})
1.8633 ++
1.8634 ++
1.8635 ++(define_insn "*sle"
1.8636 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8637 ++ (le:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8638 ++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
1.8639 ++ ""
1.8640 ++ "cmpge\\t%0, %z2, %z1"
1.8641 ++ [(set_attr "type" "alu")])
1.8642 ++
1.8643 ++
1.8644 ++(define_expand "slt"
1.8645 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8646 ++ (lt:SI (match_dup 1)
1.8647 ++ (match_dup 2)))]
1.8648 ++ ""
1.8649 ++{
1.8650 ++ if (branch_type != CMP_SI)
1.8651 ++ FAIL;
1.8652 ++
1.8653 ++ /* set up operands from compare. */
1.8654 ++ operands[1] = branch_cmp[0];
1.8655 ++ operands[2] = branch_cmp[1];
1.8656 ++
1.8657 ++ gen_int_relational (LT, operands[0], operands[1], operands[2], NULL_RTX);
1.8658 ++ DONE;
1.8659 ++})
1.8660 ++
1.8661 ++
1.8662 ++(define_insn "*slt"
1.8663 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8664 ++ (lt:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8665 ++ (match_operand:SI 2 "arith_operand" "rI")))]
1.8666 ++ ""
1.8667 ++ "cmplt%i2\\t%0, %z1, %z2"
1.8668 ++ [(set_attr "type" "alu")])
1.8669 ++
1.8670 ++
1.8671 ++(define_expand "sgtu"
1.8672 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8673 ++ (gtu:SI (match_dup 1)
1.8674 ++ (match_dup 2)))]
1.8675 ++ ""
1.8676 ++{
1.8677 ++ if (branch_type != CMP_SI)
1.8678 ++ FAIL;
1.8679 ++
1.8680 ++ /* set up operands from compare. */
1.8681 ++ operands[1] = branch_cmp[0];
1.8682 ++ operands[2] = branch_cmp[1];
1.8683 ++
1.8684 ++ gen_int_relational (GTU, operands[0], operands[1], operands[2], NULL_RTX);
1.8685 ++ DONE;
1.8686 ++})
1.8687 ++
1.8688 ++
1.8689 ++(define_insn "*sgtu"
1.8690 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8691 ++ (gtu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8692 ++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
1.8693 ++ ""
1.8694 ++ "cmpltu\\t%0, %z2, %z1"
1.8695 ++ [(set_attr "type" "alu")])
1.8696 ++
1.8697 ++
1.8698 ++(define_expand "sgeu"
1.8699 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8700 ++ (geu:SI (match_dup 1)
1.8701 ++ (match_dup 2)))]
1.8702 ++ ""
1.8703 ++{
1.8704 ++ if (branch_type != CMP_SI)
1.8705 ++ FAIL;
1.8706 ++
1.8707 ++ /* set up operands from compare. */
1.8708 ++ operands[1] = branch_cmp[0];
1.8709 ++ operands[2] = branch_cmp[1];
1.8710 ++
1.8711 ++ gen_int_relational (GEU, operands[0], operands[1], operands[2], NULL_RTX);
1.8712 ++ DONE;
1.8713 ++})
1.8714 ++
1.8715 ++
1.8716 ++(define_insn "*sgeu"
1.8717 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8718 ++ (geu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8719 ++ (match_operand:SI 2 "uns_arith_operand" "rJ")))]
1.8720 ++ ""
1.8721 ++ "cmpgeu%i2\\t%0, %z1, %z2"
1.8722 ++ [(set_attr "type" "alu")])
1.8723 ++
1.8724 ++(define_expand "sleu"
1.8725 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8726 ++ (leu:SI (match_dup 1)
1.8727 ++ (match_dup 2)))]
1.8728 ++ ""
1.8729 ++{
1.8730 ++ if (branch_type != CMP_SI)
1.8731 ++ FAIL;
1.8732 ++
1.8733 ++ /* set up operands from compare. */
1.8734 ++ operands[1] = branch_cmp[0];
1.8735 ++ operands[2] = branch_cmp[1];
1.8736 ++
1.8737 ++ gen_int_relational (LEU, operands[0], operands[1], operands[2], NULL_RTX);
1.8738 ++ DONE;
1.8739 ++})
1.8740 ++
1.8741 ++
1.8742 ++(define_insn "*sleu"
1.8743 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8744 ++ (leu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8745 ++ (match_operand:SI 2 "reg_or_0_operand" "rM")))]
1.8746 ++ ""
1.8747 ++ "cmpgeu\\t%0, %z2, %z1"
1.8748 ++ [(set_attr "type" "alu")])
1.8749 ++
1.8750 ++
1.8751 ++(define_expand "sltu"
1.8752 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8753 ++ (ltu:SI (match_dup 1)
1.8754 ++ (match_dup 2)))]
1.8755 ++ ""
1.8756 ++{
1.8757 ++ if (branch_type != CMP_SI)
1.8758 ++ FAIL;
1.8759 ++
1.8760 ++ /* set up operands from compare. */
1.8761 ++ operands[1] = branch_cmp[0];
1.8762 ++ operands[2] = branch_cmp[1];
1.8763 ++
1.8764 ++ gen_int_relational (LTU, operands[0], operands[1], operands[2], NULL_RTX);
1.8765 ++ DONE;
1.8766 ++})
1.8767 ++
1.8768 ++
1.8769 ++(define_insn "*sltu"
1.8770 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.8771 ++ (ltu:SI (match_operand:SI 1 "reg_or_0_operand" "rM")
1.8772 ++ (match_operand:SI 2 "uns_arith_operand" "rJ")))]
1.8773 ++ ""
1.8774 ++ "cmpltu%i2\\t%0, %z1, %z2"
1.8775 ++ [(set_attr "type" "alu")])
1.8776 ++
1.8777 ++
1.8778 ++
1.8779 ++
1.8780 ++;*****************************************************************************
1.8781 ++;*
1.8782 ++;* branches
1.8783 ++;*
1.8784 ++;*****************************************************************************
1.8785 ++
1.8786 ++(define_insn "*cbranch"
1.8787 ++ [(set (pc)
1.8788 ++ (if_then_else
1.8789 ++ (match_operator:SI 0 "comparison_operator"
1.8790 ++ [(match_operand:SI 2 "reg_or_0_operand" "rM")
1.8791 ++ (match_operand:SI 3 "reg_or_0_operand" "rM")])
1.8792 ++ (label_ref (match_operand 1 "" ""))
1.8793 ++ (pc)))]
1.8794 ++ ""
1.8795 ++ "b%0\\t%z2, %z3, %l1"
1.8796 ++ [(set_attr "type" "control")])
1.8797 ++
1.8798 ++
1.8799 ++(define_expand "beq"
1.8800 ++ [(set (pc)
1.8801 ++ (if_then_else (eq:CC (cc0)
1.8802 ++ (const_int 0))
1.8803 ++ (label_ref (match_operand 0 "" ""))
1.8804 ++ (pc)))]
1.8805 ++ ""
1.8806 ++{
1.8807 ++ gen_int_relational (EQ, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8808 ++ DONE;
1.8809 ++})
1.8810 ++
1.8811 ++
1.8812 ++(define_expand "bne"
1.8813 ++ [(set (pc)
1.8814 ++ (if_then_else (ne:CC (cc0)
1.8815 ++ (const_int 0))
1.8816 ++ (label_ref (match_operand 0 "" ""))
1.8817 ++ (pc)))]
1.8818 ++ ""
1.8819 ++{
1.8820 ++ gen_int_relational (NE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8821 ++ DONE;
1.8822 ++})
1.8823 ++
1.8824 ++
1.8825 ++(define_expand "bgt"
1.8826 ++ [(set (pc)
1.8827 ++ (if_then_else (gt:CC (cc0)
1.8828 ++ (const_int 0))
1.8829 ++ (label_ref (match_operand 0 "" ""))
1.8830 ++ (pc)))]
1.8831 ++ ""
1.8832 ++{
1.8833 ++ gen_int_relational (GT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8834 ++ DONE;
1.8835 ++})
1.8836 ++
1.8837 ++(define_expand "bge"
1.8838 ++ [(set (pc)
1.8839 ++ (if_then_else (ge:CC (cc0)
1.8840 ++ (const_int 0))
1.8841 ++ (label_ref (match_operand 0 "" ""))
1.8842 ++ (pc)))]
1.8843 ++ ""
1.8844 ++{
1.8845 ++ gen_int_relational (GE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8846 ++ DONE;
1.8847 ++})
1.8848 ++
1.8849 ++(define_expand "ble"
1.8850 ++ [(set (pc)
1.8851 ++ (if_then_else (le:CC (cc0)
1.8852 ++ (const_int 0))
1.8853 ++ (label_ref (match_operand 0 "" ""))
1.8854 ++ (pc)))]
1.8855 ++ ""
1.8856 ++{
1.8857 ++ gen_int_relational (LE, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8858 ++ DONE;
1.8859 ++})
1.8860 ++
1.8861 ++(define_expand "blt"
1.8862 ++ [(set (pc)
1.8863 ++ (if_then_else (lt:CC (cc0)
1.8864 ++ (const_int 0))
1.8865 ++ (label_ref (match_operand 0 "" ""))
1.8866 ++ (pc)))]
1.8867 ++ ""
1.8868 ++{
1.8869 ++ gen_int_relational (LT, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8870 ++ DONE;
1.8871 ++})
1.8872 ++
1.8873 ++
1.8874 ++(define_expand "bgtu"
1.8875 ++ [(set (pc)
1.8876 ++ (if_then_else (gtu:CC (cc0)
1.8877 ++ (const_int 0))
1.8878 ++ (label_ref (match_operand 0 "" ""))
1.8879 ++ (pc)))]
1.8880 ++ ""
1.8881 ++{
1.8882 ++ gen_int_relational (GTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8883 ++ DONE;
1.8884 ++})
1.8885 ++
1.8886 ++(define_expand "bgeu"
1.8887 ++ [(set (pc)
1.8888 ++ (if_then_else (geu:CC (cc0)
1.8889 ++ (const_int 0))
1.8890 ++ (label_ref (match_operand 0 "" ""))
1.8891 ++ (pc)))]
1.8892 ++ ""
1.8893 ++{
1.8894 ++ gen_int_relational (GEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8895 ++ DONE;
1.8896 ++})
1.8897 ++
1.8898 ++(define_expand "bleu"
1.8899 ++ [(set (pc)
1.8900 ++ (if_then_else (leu:CC (cc0)
1.8901 ++ (const_int 0))
1.8902 ++ (label_ref (match_operand 0 "" ""))
1.8903 ++ (pc)))]
1.8904 ++ ""
1.8905 ++{
1.8906 ++ gen_int_relational (LEU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8907 ++ DONE;
1.8908 ++})
1.8909 ++
1.8910 ++(define_expand "bltu"
1.8911 ++ [(set (pc)
1.8912 ++ (if_then_else (ltu:CC (cc0)
1.8913 ++ (const_int 0))
1.8914 ++ (label_ref (match_operand 0 "" ""))
1.8915 ++ (pc)))]
1.8916 ++ ""
1.8917 ++{
1.8918 ++ gen_int_relational (LTU, NULL_RTX, branch_cmp[0], branch_cmp[1], operands[0]);
1.8919 ++ DONE;
1.8920 ++})
1.8921 ++
1.8922 ++
1.8923 ++;*****************************************************************************
1.8924 ++;*
1.8925 ++;* String and Block Operations
1.8926 ++;*
1.8927 ++;*****************************************************************************
1.8928 ++
1.8929 ++; ??? This is all really a hack to get Dhrystone to work as fast as possible
1.8930 ++; things to be fixed:
1.8931 ++; * let the compiler core handle all of this, for that to work the extra
1.8932 ++; aliasing needs to be addressed.
1.8933 ++; * we use three temporary registers for loading and storing to ensure no
1.8934 ++; ld use stalls, this is excessive, because after the first ld/st only
1.8935 ++; two are needed. Only two would be needed all the way through if
1.8936 ++; we could schedule with other code. Consider:
1.8937 ++; 1 ld $1, 0($src)
1.8938 ++; 2 ld $2, 4($src)
1.8939 ++; 3 ld $3, 8($src)
1.8940 ++; 4 st $1, 0($dest)
1.8941 ++; 5 ld $1, 12($src)
1.8942 ++; 6 st $2, 4($src)
1.8943 ++; 7 etc.
1.8944 ++; The first store has to wait until 4. If it does not there will be one
1.8945 ++; cycle of stalling. However, if any other instruction could be placed
1.8946 ++; between 1 and 4, $3 would not be needed.
1.8947 ++; * In small we probably don't want to ever do this ourself because there
1.8948 ++; is no ld use stall.
1.8949 ++
1.8950 ++(define_expand "movstrsi"
1.8951 ++ [(parallel [(set (match_operand:BLK 0 "general_operand" "")
1.8952 ++ (match_operand:BLK 1 "general_operand" ""))
1.8953 ++ (use (match_operand:SI 2 "const_int_operand" ""))
1.8954 ++ (use (match_operand:SI 3 "const_int_operand" ""))
1.8955 ++ (clobber (match_scratch:SI 4 "=&r"))
1.8956 ++ (clobber (match_scratch:SI 5 "=&r"))
1.8957 ++ (clobber (match_scratch:SI 6 "=&r"))])]
1.8958 ++ "TARGET_INLINE_MEMCPY"
1.8959 ++{
1.8960 ++ rtx ld_addr_reg, st_addr_reg;
1.8961 ++
1.8962 ++ /* If the predicate for op2 fails in expr.c:emit_block_move_via_movstr
1.8963 ++ it trys to copy to a register, but does not re-try the predicate.
1.8964 ++ ??? Intead of fixing expr.c, I fix it here. */
1.8965 ++ if (!const_int_operand (operands[2], SImode))
1.8966 ++ FAIL;
1.8967 ++
1.8968 ++ /* ??? there are some magic numbers which need to be sorted out here.
1.8969 ++ the basis for them is not increasing code size hugely or going
1.8970 ++ out of range of offset addressing */
1.8971 ++ if (INTVAL (operands[3]) < 4)
1.8972 ++ FAIL;
1.8973 ++ if (!optimize
1.8974 ++ || (optimize_size && INTVAL (operands[2]) > 12)
1.8975 ++ || (optimize < 3 && INTVAL (operands[2]) > 100)
1.8976 ++ || INTVAL (operands[2]) > 200)
1.8977 ++ FAIL;
1.8978 ++
1.8979 ++ st_addr_reg
1.8980 ++ = replace_equiv_address (operands[0],
1.8981 ++ copy_to_mode_reg (Pmode, XEXP (operands[0], 0)));
1.8982 ++ ld_addr_reg
1.8983 ++ = replace_equiv_address (operands[1],
1.8984 ++ copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
1.8985 ++ emit_insn (gen_movstrsi_internal (st_addr_reg, ld_addr_reg,
1.8986 ++ operands[2], operands[3]));
1.8987 ++
1.8988 ++ DONE;
1.8989 ++})
1.8990 ++
1.8991 ++
1.8992 ++(define_insn "movstrsi_internal"
1.8993 ++ [(set (match_operand:BLK 0 "memory_operand" "=o")
1.8994 ++ (match_operand:BLK 1 "memory_operand" "o"))
1.8995 ++ (use (match_operand:SI 2 "const_int_operand" "i"))
1.8996 ++ (use (match_operand:SI 3 "const_int_operand" "i"))
1.8997 ++ (clobber (match_scratch:SI 4 "=&r"))
1.8998 ++ (clobber (match_scratch:SI 5 "=&r"))
1.8999 ++ (clobber (match_scratch:SI 6 "=&r"))]
1.9000 ++ "TARGET_INLINE_MEMCPY"
1.9001 ++{
1.9002 ++ int ld_offset = INTVAL (operands[2]);
1.9003 ++ int ld_len = INTVAL (operands[2]);
1.9004 ++ int ld_reg = 0;
1.9005 ++ rtx ld_addr_reg = XEXP (operands[1], 0);
1.9006 ++ int st_offset = INTVAL (operands[2]);
1.9007 ++ int st_len = INTVAL (operands[2]);
1.9008 ++ int st_reg = 0;
1.9009 ++ rtx st_addr_reg = XEXP (operands[0], 0);
1.9010 ++ int delay_count = 0;
1.9011 ++
1.9012 ++ /* ops[0] is the address used by the insn
1.9013 ++ ops[1] is the register being loaded or stored */
1.9014 ++ rtx ops[2];
1.9015 ++
1.9016 ++ if (INTVAL (operands[3]) < 4)
1.9017 ++ abort ();
1.9018 ++
1.9019 ++ while (ld_offset >= 4)
1.9020 ++ {
1.9021 ++ /* if the load use delay has been met, I can start
1.9022 ++ storing */
1.9023 ++ if (delay_count >= 3)
1.9024 ++ {
1.9025 ++ ops[0] = gen_rtx (MEM, SImode,
1.9026 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9027 ++ ops[1] = operands[st_reg + 4];
1.9028 ++ output_asm_insn ("stw\t%1, %0", ops);
1.9029 ++
1.9030 ++ st_reg = (st_reg + 1) % 3;
1.9031 ++ st_offset -= 4;
1.9032 ++ }
1.9033 ++
1.9034 ++ ops[0] = gen_rtx (MEM, SImode,
1.9035 ++ plus_constant (ld_addr_reg, ld_len - ld_offset));
1.9036 ++ ops[1] = operands[ld_reg + 4];
1.9037 ++ output_asm_insn ("ldw\t%1, %0", ops);
1.9038 ++
1.9039 ++ ld_reg = (ld_reg + 1) % 3;
1.9040 ++ ld_offset -= 4;
1.9041 ++ delay_count++;
1.9042 ++ }
1.9043 ++
1.9044 ++ if (ld_offset >= 2)
1.9045 ++ {
1.9046 ++ /* if the load use delay has been met, I can start
1.9047 ++ storing */
1.9048 ++ if (delay_count >= 3)
1.9049 ++ {
1.9050 ++ ops[0] = gen_rtx (MEM, SImode,
1.9051 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9052 ++ ops[1] = operands[st_reg + 4];
1.9053 ++ output_asm_insn ("stw\t%1, %0", ops);
1.9054 ++
1.9055 ++ st_reg = (st_reg + 1) % 3;
1.9056 ++ st_offset -= 4;
1.9057 ++ }
1.9058 ++
1.9059 ++ ops[0] = gen_rtx (MEM, HImode,
1.9060 ++ plus_constant (ld_addr_reg, ld_len - ld_offset));
1.9061 ++ ops[1] = operands[ld_reg + 4];
1.9062 ++ output_asm_insn ("ldh\t%1, %0", ops);
1.9063 ++
1.9064 ++ ld_reg = (ld_reg + 1) % 3;
1.9065 ++ ld_offset -= 2;
1.9066 ++ delay_count++;
1.9067 ++ }
1.9068 ++
1.9069 ++ if (ld_offset >= 1)
1.9070 ++ {
1.9071 ++ /* if the load use delay has been met, I can start
1.9072 ++ storing */
1.9073 ++ if (delay_count >= 3)
1.9074 ++ {
1.9075 ++ ops[0] = gen_rtx (MEM, SImode,
1.9076 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9077 ++ ops[1] = operands[st_reg + 4];
1.9078 ++ output_asm_insn ("stw\t%1, %0", ops);
1.9079 ++
1.9080 ++ st_reg = (st_reg + 1) % 3;
1.9081 ++ st_offset -= 4;
1.9082 ++ }
1.9083 ++
1.9084 ++ ops[0] = gen_rtx (MEM, QImode,
1.9085 ++ plus_constant (ld_addr_reg, ld_len - ld_offset));
1.9086 ++ ops[1] = operands[ld_reg + 4];
1.9087 ++ output_asm_insn ("ldb\t%1, %0", ops);
1.9088 ++
1.9089 ++ ld_reg = (ld_reg + 1) % 3;
1.9090 ++ ld_offset -= 1;
1.9091 ++ delay_count++;
1.9092 ++ }
1.9093 ++
1.9094 ++ while (st_offset >= 4)
1.9095 ++ {
1.9096 ++ ops[0] = gen_rtx (MEM, SImode,
1.9097 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9098 ++ ops[1] = operands[st_reg + 4];
1.9099 ++ output_asm_insn ("stw\t%1, %0", ops);
1.9100 ++
1.9101 ++ st_reg = (st_reg + 1) % 3;
1.9102 ++ st_offset -= 4;
1.9103 ++ }
1.9104 ++
1.9105 ++ while (st_offset >= 2)
1.9106 ++ {
1.9107 ++ ops[0] = gen_rtx (MEM, HImode,
1.9108 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9109 ++ ops[1] = operands[st_reg + 4];
1.9110 ++ output_asm_insn ("sth\t%1, %0", ops);
1.9111 ++
1.9112 ++ st_reg = (st_reg + 1) % 3;
1.9113 ++ st_offset -= 2;
1.9114 ++ }
1.9115 ++
1.9116 ++ while (st_offset >= 1)
1.9117 ++ {
1.9118 ++ ops[0] = gen_rtx (MEM, QImode,
1.9119 ++ plus_constant (st_addr_reg, st_len - st_offset));
1.9120 ++ ops[1] = operands[st_reg + 4];
1.9121 ++ output_asm_insn ("stb\t%1, %0", ops);
1.9122 ++
1.9123 ++ st_reg = (st_reg + 1) % 3;
1.9124 ++ st_offset -= 1;
1.9125 ++ }
1.9126 ++
1.9127 ++ return "";
1.9128 ++}
1.9129 ++; ??? lengths are not being used yet, but I will probably forget
1.9130 ++; to update this once I am using lengths, so set it to something
1.9131 ++; definetely big enough to cover it. 400 allows for 200 bytes
1.9132 ++; of motion.
1.9133 ++ [(set_attr "length" "400")])
1.9134 ++
1.9135 ++
1.9136 ++
1.9137 ++;*****************************************************************************
1.9138 ++;*
1.9139 ++;* Custom instructions
1.9140 ++;*
1.9141 ++;*****************************************************************************
1.9142 ++
1.9143 ++(define_constants [
1.9144 ++ (CUSTOM_N 100)
1.9145 ++ (CUSTOM_NI 101)
1.9146 ++ (CUSTOM_NF 102)
1.9147 ++ (CUSTOM_NP 103)
1.9148 ++ (CUSTOM_NII 104)
1.9149 ++ (CUSTOM_NIF 105)
1.9150 ++ (CUSTOM_NIP 106)
1.9151 ++ (CUSTOM_NFI 107)
1.9152 ++ (CUSTOM_NFF 108)
1.9153 ++ (CUSTOM_NFP 109)
1.9154 ++ (CUSTOM_NPI 110)
1.9155 ++ (CUSTOM_NPF 111)
1.9156 ++ (CUSTOM_NPP 112)
1.9157 ++ (CUSTOM_IN 113)
1.9158 ++ (CUSTOM_INI 114)
1.9159 ++ (CUSTOM_INF 115)
1.9160 ++ (CUSTOM_INP 116)
1.9161 ++ (CUSTOM_INII 117)
1.9162 ++ (CUSTOM_INIF 118)
1.9163 ++ (CUSTOM_INIP 119)
1.9164 ++ (CUSTOM_INFI 120)
1.9165 ++ (CUSTOM_INFF 121)
1.9166 ++ (CUSTOM_INFP 122)
1.9167 ++ (CUSTOM_INPI 123)
1.9168 ++ (CUSTOM_INPF 124)
1.9169 ++ (CUSTOM_INPP 125)
1.9170 ++ (CUSTOM_FN 126)
1.9171 ++ (CUSTOM_FNI 127)
1.9172 ++ (CUSTOM_FNF 128)
1.9173 ++ (CUSTOM_FNP 129)
1.9174 ++ (CUSTOM_FNII 130)
1.9175 ++ (CUSTOM_FNIF 131)
1.9176 ++ (CUSTOM_FNIP 132)
1.9177 ++ (CUSTOM_FNFI 133)
1.9178 ++ (CUSTOM_FNFF 134)
1.9179 ++ (CUSTOM_FNFP 135)
1.9180 ++ (CUSTOM_FNPI 136)
1.9181 ++ (CUSTOM_FNPF 137)
1.9182 ++ (CUSTOM_FNPP 138)
1.9183 ++ (CUSTOM_PN 139)
1.9184 ++ (CUSTOM_PNI 140)
1.9185 ++ (CUSTOM_PNF 141)
1.9186 ++ (CUSTOM_PNP 142)
1.9187 ++ (CUSTOM_PNII 143)
1.9188 ++ (CUSTOM_PNIF 144)
1.9189 ++ (CUSTOM_PNIP 145)
1.9190 ++ (CUSTOM_PNFI 146)
1.9191 ++ (CUSTOM_PNFF 147)
1.9192 ++ (CUSTOM_PNFP 148)
1.9193 ++ (CUSTOM_PNPI 149)
1.9194 ++ (CUSTOM_PNPF 150)
1.9195 ++ (CUSTOM_PNPP 151)
1.9196 ++])
1.9197 ++
1.9198 ++
1.9199 ++(define_insn "custom_n"
1.9200 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")] CUSTOM_N)]
1.9201 ++ ""
1.9202 ++ "custom\\t%0, zero, zero, zero"
1.9203 ++ [(set_attr "type" "custom")])
1.9204 ++
1.9205 ++(define_insn "custom_ni"
1.9206 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9207 ++ (match_operand:SI 1 "register_operand" "r")] CUSTOM_NI)]
1.9208 ++ ""
1.9209 ++ "custom\\t%0, zero, %1, zero"
1.9210 ++ [(set_attr "type" "custom")])
1.9211 ++
1.9212 ++(define_insn "custom_nf"
1.9213 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9214 ++ (match_operand:SF 1 "register_operand" "r")] CUSTOM_NF)]
1.9215 ++ ""
1.9216 ++ "custom\\t%0, zero, %1, zero"
1.9217 ++ [(set_attr "type" "custom")])
1.9218 ++
1.9219 ++(define_insn "custom_np"
1.9220 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9221 ++ (match_operand:SI 1 "register_operand" "r")] CUSTOM_NP)]
1.9222 ++ ""
1.9223 ++ "custom\\t%0, zero, %1, zero"
1.9224 ++ [(set_attr "type" "custom")])
1.9225 ++
1.9226 ++(define_insn "custom_nii"
1.9227 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9228 ++ (match_operand:SI 1 "register_operand" "r")
1.9229 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NII)]
1.9230 ++ ""
1.9231 ++ "custom\\t%0, zero, %1, %2"
1.9232 ++ [(set_attr "type" "custom")])
1.9233 ++
1.9234 ++(define_insn "custom_nif"
1.9235 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9236 ++ (match_operand:SI 1 "register_operand" "r")
1.9237 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NIF)]
1.9238 ++ ""
1.9239 ++ "custom\\t%0, zero, %1, %2"
1.9240 ++ [(set_attr "type" "custom")])
1.9241 ++
1.9242 ++(define_insn "custom_nip"
1.9243 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9244 ++ (match_operand:SI 1 "register_operand" "r")
1.9245 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NIP)]
1.9246 ++ ""
1.9247 ++ "custom\\t%0, zero, %1, %2"
1.9248 ++ [(set_attr "type" "custom")])
1.9249 ++
1.9250 ++(define_insn "custom_nfi"
1.9251 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9252 ++ (match_operand:SF 1 "register_operand" "r")
1.9253 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NFI)]
1.9254 ++ ""
1.9255 ++ "custom\\t%0, zero, %1, %2"
1.9256 ++ [(set_attr "type" "custom")])
1.9257 ++
1.9258 ++(define_insn "custom_nff"
1.9259 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9260 ++ (match_operand:SF 1 "register_operand" "r")
1.9261 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NFF)]
1.9262 ++ ""
1.9263 ++ "custom\\t%0, zero, %1, %2"
1.9264 ++ [(set_attr "type" "custom")])
1.9265 ++
1.9266 ++(define_insn "custom_nfp"
1.9267 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9268 ++ (match_operand:SF 1 "register_operand" "r")
1.9269 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NFP)]
1.9270 ++ ""
1.9271 ++ "custom\\t%0, zero, %1, %2"
1.9272 ++ [(set_attr "type" "custom")])
1.9273 ++
1.9274 ++(define_insn "custom_npi"
1.9275 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9276 ++ (match_operand:SI 1 "register_operand" "r")
1.9277 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NPI)]
1.9278 ++ ""
1.9279 ++ "custom\\t%0, zero, %1, %2"
1.9280 ++ [(set_attr "type" "custom")])
1.9281 ++
1.9282 ++(define_insn "custom_npf"
1.9283 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9284 ++ (match_operand:SI 1 "register_operand" "r")
1.9285 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_NPF)]
1.9286 ++ ""
1.9287 ++ "custom\\t%0, zero, %1, %2"
1.9288 ++ [(set_attr "type" "custom")])
1.9289 ++
1.9290 ++(define_insn "custom_npp"
1.9291 ++ [(unspec_volatile [(match_operand:SI 0 "custom_insn_opcode" "N")
1.9292 ++ (match_operand:SI 1 "register_operand" "r")
1.9293 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_NPP)]
1.9294 ++ ""
1.9295 ++ "custom\\t%0, zero, %1, %2"
1.9296 ++ [(set_attr "type" "custom")])
1.9297 ++
1.9298 ++
1.9299 ++
1.9300 ++(define_insn "custom_in"
1.9301 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9302 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_IN))]
1.9303 ++ ""
1.9304 ++ "custom\\t%1, %0, zero, zero"
1.9305 ++ [(set_attr "type" "custom")])
1.9306 ++
1.9307 ++(define_insn "custom_ini"
1.9308 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9309 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9310 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_INI))]
1.9311 ++ ""
1.9312 ++ "custom\\t%1, %0, %2, zero"
1.9313 ++ [(set_attr "type" "custom")])
1.9314 ++
1.9315 ++(define_insn "custom_inf"
1.9316 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9317 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9318 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_INF))]
1.9319 ++ ""
1.9320 ++ "custom\\t%1, %0, %2, zero"
1.9321 ++ [(set_attr "type" "custom")])
1.9322 ++
1.9323 ++(define_insn "custom_inp"
1.9324 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9325 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9326 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_INP))]
1.9327 ++ ""
1.9328 ++ "custom\\t%1, %0, %2, zero"
1.9329 ++ [(set_attr "type" "custom")])
1.9330 ++
1.9331 ++(define_insn "custom_inii"
1.9332 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9333 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9334 ++ (match_operand:SI 2 "register_operand" "r")
1.9335 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INII))]
1.9336 ++ ""
1.9337 ++ "custom\\t%1, %0, %2, %3"
1.9338 ++ [(set_attr "type" "custom")])
1.9339 ++
1.9340 ++(define_insn "custom_inif"
1.9341 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9342 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9343 ++ (match_operand:SI 2 "register_operand" "r")
1.9344 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INIF))]
1.9345 ++ ""
1.9346 ++ "custom\\t%1, %0, %2, %3"
1.9347 ++ [(set_attr "type" "custom")])
1.9348 ++
1.9349 ++(define_insn "custom_inip"
1.9350 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9351 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9352 ++ (match_operand:SI 2 "register_operand" "r")
1.9353 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INIP))]
1.9354 ++ ""
1.9355 ++ "custom\\t%1, %0, %2, %3"
1.9356 ++ [(set_attr "type" "custom")])
1.9357 ++
1.9358 ++(define_insn "custom_infi"
1.9359 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9360 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9361 ++ (match_operand:SF 2 "register_operand" "r")
1.9362 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INFI))]
1.9363 ++ ""
1.9364 ++ "custom\\t%1, %0, %2, %3"
1.9365 ++ [(set_attr "type" "custom")])
1.9366 ++
1.9367 ++(define_insn "custom_inff"
1.9368 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9369 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9370 ++ (match_operand:SF 2 "register_operand" "r")
1.9371 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INFF))]
1.9372 ++ ""
1.9373 ++ "custom\\t%1, %0, %2, %3"
1.9374 ++ [(set_attr "type" "custom")])
1.9375 ++
1.9376 ++(define_insn "custom_infp"
1.9377 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9378 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9379 ++ (match_operand:SF 2 "register_operand" "r")
1.9380 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INFP))]
1.9381 ++ ""
1.9382 ++ "custom\\t%1, %0, %2, %3"
1.9383 ++ [(set_attr "type" "custom")])
1.9384 ++
1.9385 ++(define_insn "custom_inpi"
1.9386 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9387 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9388 ++ (match_operand:SI 2 "register_operand" "r")
1.9389 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INPI))]
1.9390 ++ ""
1.9391 ++ "custom\\t%1, %0, %2, %3"
1.9392 ++ [(set_attr "type" "custom")])
1.9393 ++
1.9394 ++(define_insn "custom_inpf"
1.9395 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9396 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9397 ++ (match_operand:SI 2 "register_operand" "r")
1.9398 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_INPF))]
1.9399 ++ ""
1.9400 ++ "custom\\t%1, %0, %2, %3"
1.9401 ++ [(set_attr "type" "custom")])
1.9402 ++
1.9403 ++(define_insn "custom_inpp"
1.9404 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9405 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9406 ++ (match_operand:SI 2 "register_operand" "r")
1.9407 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_INPP))]
1.9408 ++ ""
1.9409 ++ "custom\\t%1, %0, %2, %3"
1.9410 ++ [(set_attr "type" "custom")])
1.9411 ++
1.9412 ++
1.9413 ++
1.9414 ++
1.9415 ++
1.9416 ++(define_insn "custom_fn"
1.9417 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9418 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_FN))]
1.9419 ++ ""
1.9420 ++ "custom\\t%1, %0, zero, zero"
1.9421 ++ [(set_attr "type" "custom")])
1.9422 ++
1.9423 ++(define_insn "custom_fni"
1.9424 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9425 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9426 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_FNI))]
1.9427 ++ ""
1.9428 ++ "custom\\t%1, %0, %2, zero"
1.9429 ++ [(set_attr "type" "custom")])
1.9430 ++
1.9431 ++(define_insn "custom_fnf"
1.9432 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9433 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9434 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_FNF))]
1.9435 ++ ""
1.9436 ++ "custom\\t%1, %0, %2, zero"
1.9437 ++ [(set_attr "type" "custom")])
1.9438 ++
1.9439 ++(define_insn "custom_fnp"
1.9440 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9441 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9442 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_FNP))]
1.9443 ++ ""
1.9444 ++ "custom\\t%1, %0, %2, zero"
1.9445 ++ [(set_attr "type" "custom")])
1.9446 ++
1.9447 ++(define_insn "custom_fnii"
1.9448 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9449 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9450 ++ (match_operand:SI 2 "register_operand" "r")
1.9451 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNII))]
1.9452 ++ ""
1.9453 ++ "custom\\t%1, %0, %2, %3"
1.9454 ++ [(set_attr "type" "custom")])
1.9455 ++
1.9456 ++(define_insn "custom_fnif"
1.9457 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9458 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9459 ++ (match_operand:SI 2 "register_operand" "r")
1.9460 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNIF))]
1.9461 ++ ""
1.9462 ++ "custom\\t%1, %0, %2, %3"
1.9463 ++ [(set_attr "type" "custom")])
1.9464 ++
1.9465 ++(define_insn "custom_fnip"
1.9466 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9467 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9468 ++ (match_operand:SI 2 "register_operand" "r")
1.9469 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNIP))]
1.9470 ++ ""
1.9471 ++ "custom\\t%1, %0, %2, %3"
1.9472 ++ [(set_attr "type" "custom")])
1.9473 ++
1.9474 ++(define_insn "custom_fnfi"
1.9475 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9476 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9477 ++ (match_operand:SF 2 "register_operand" "r")
1.9478 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNFI))]
1.9479 ++ ""
1.9480 ++ "custom\\t%1, %0, %2, %3"
1.9481 ++ [(set_attr "type" "custom")])
1.9482 ++
1.9483 ++(define_insn "custom_fnff"
1.9484 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9485 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9486 ++ (match_operand:SF 2 "register_operand" "r")
1.9487 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNFF))]
1.9488 ++ ""
1.9489 ++ "custom\\t%1, %0, %2, %3"
1.9490 ++ [(set_attr "type" "custom")])
1.9491 ++
1.9492 ++(define_insn "custom_fnfp"
1.9493 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9494 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9495 ++ (match_operand:SF 2 "register_operand" "r")
1.9496 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNFP))]
1.9497 ++ ""
1.9498 ++ "custom\\t%1, %0, %2, %3"
1.9499 ++ [(set_attr "type" "custom")])
1.9500 ++
1.9501 ++(define_insn "custom_fnpi"
1.9502 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9503 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9504 ++ (match_operand:SI 2 "register_operand" "r")
1.9505 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNPI))]
1.9506 ++ ""
1.9507 ++ "custom\\t%1, %0, %2, %3"
1.9508 ++ [(set_attr "type" "custom")])
1.9509 ++
1.9510 ++(define_insn "custom_fnpf"
1.9511 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9512 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9513 ++ (match_operand:SI 2 "register_operand" "r")
1.9514 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_FNPF))]
1.9515 ++ ""
1.9516 ++ "custom\\t%1, %0, %2, %3"
1.9517 ++ [(set_attr "type" "custom")])
1.9518 ++
1.9519 ++(define_insn "custom_fnpp"
1.9520 ++ [(set (match_operand:SF 0 "register_operand" "=r")
1.9521 ++ (unspec_volatile:SF [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9522 ++ (match_operand:SI 2 "register_operand" "r")
1.9523 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_FNPP))]
1.9524 ++ ""
1.9525 ++ "custom\\t%1, %0, %2, %3"
1.9526 ++ [(set_attr "type" "custom")])
1.9527 ++
1.9528 ++
1.9529 ++
1.9530 ++(define_insn "custom_pn"
1.9531 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9532 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")] CUSTOM_PN))]
1.9533 ++ ""
1.9534 ++ "custom\\t%1, %0, zero, zero"
1.9535 ++ [(set_attr "type" "custom")])
1.9536 ++
1.9537 ++(define_insn "custom_pni"
1.9538 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9539 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9540 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_PNI))]
1.9541 ++ ""
1.9542 ++ "custom\\t%1, %0, %2, zero"
1.9543 ++ [(set_attr "type" "custom")])
1.9544 ++
1.9545 ++(define_insn "custom_pnf"
1.9546 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9547 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9548 ++ (match_operand:SF 2 "register_operand" "r")] CUSTOM_PNF))]
1.9549 ++ ""
1.9550 ++ "custom\\t%1, %0, %2, zero"
1.9551 ++ [(set_attr "type" "custom")])
1.9552 ++
1.9553 ++(define_insn "custom_pnp"
1.9554 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9555 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9556 ++ (match_operand:SI 2 "register_operand" "r")] CUSTOM_PNP))]
1.9557 ++ ""
1.9558 ++ "custom\\t%1, %0, %2, zero"
1.9559 ++ [(set_attr "type" "custom")])
1.9560 ++
1.9561 ++(define_insn "custom_pnii"
1.9562 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9563 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9564 ++ (match_operand:SI 2 "register_operand" "r")
1.9565 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNII))]
1.9566 ++ ""
1.9567 ++ "custom\\t%1, %0, %2, %3"
1.9568 ++ [(set_attr "type" "custom")])
1.9569 ++
1.9570 ++(define_insn "custom_pnif"
1.9571 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9572 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9573 ++ (match_operand:SI 2 "register_operand" "r")
1.9574 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNIF))]
1.9575 ++ ""
1.9576 ++ "custom\\t%1, %0, %2, %3"
1.9577 ++ [(set_attr "type" "custom")])
1.9578 ++
1.9579 ++(define_insn "custom_pnip"
1.9580 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9581 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9582 ++ (match_operand:SI 2 "register_operand" "r")
1.9583 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNIP))]
1.9584 ++ ""
1.9585 ++ "custom\\t%1, %0, %2, %3"
1.9586 ++ [(set_attr "type" "custom")])
1.9587 ++
1.9588 ++(define_insn "custom_pnfi"
1.9589 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9590 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9591 ++ (match_operand:SF 2 "register_operand" "r")
1.9592 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNFI))]
1.9593 ++ ""
1.9594 ++ "custom\\t%1, %0, %2, %3"
1.9595 ++ [(set_attr "type" "custom")])
1.9596 ++
1.9597 ++(define_insn "custom_pnff"
1.9598 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9599 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9600 ++ (match_operand:SF 2 "register_operand" "r")
1.9601 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNFF))]
1.9602 ++ ""
1.9603 ++ "custom\\t%1, %0, %2, %3"
1.9604 ++ [(set_attr "type" "custom")])
1.9605 ++
1.9606 ++(define_insn "custom_pnfp"
1.9607 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9608 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9609 ++ (match_operand:SF 2 "register_operand" "r")
1.9610 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNFP))]
1.9611 ++ ""
1.9612 ++ "custom\\t%1, %0, %2, %3"
1.9613 ++ [(set_attr "type" "custom")])
1.9614 ++
1.9615 ++(define_insn "custom_pnpi"
1.9616 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9617 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9618 ++ (match_operand:SI 2 "register_operand" "r")
1.9619 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNPI))]
1.9620 ++ ""
1.9621 ++ "custom\\t%1, %0, %2, %3"
1.9622 ++ [(set_attr "type" "custom")])
1.9623 ++
1.9624 ++(define_insn "custom_pnpf"
1.9625 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9626 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9627 ++ (match_operand:SI 2 "register_operand" "r")
1.9628 ++ (match_operand:SF 3 "register_operand" "r")] CUSTOM_PNPF))]
1.9629 ++ ""
1.9630 ++ "custom\\t%1, %0, %2, %3"
1.9631 ++ [(set_attr "type" "custom")])
1.9632 ++
1.9633 ++(define_insn "custom_pnpp"
1.9634 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9635 ++ (unspec_volatile:SI [(match_operand:SI 1 "custom_insn_opcode" "N")
1.9636 ++ (match_operand:SI 2 "register_operand" "r")
1.9637 ++ (match_operand:SI 3 "register_operand" "r")] CUSTOM_PNPP))]
1.9638 ++ ""
1.9639 ++ "custom\\t%1, %0, %2, %3"
1.9640 ++ [(set_attr "type" "custom")])
1.9641 ++
1.9642 ++
1.9643 ++
1.9644 ++
1.9645 ++
1.9646 ++
1.9647 ++;*****************************************************************************
1.9648 ++;*
1.9649 ++;* Misc
1.9650 ++;*
1.9651 ++;*****************************************************************************
1.9652 ++
1.9653 ++(define_insn "nop"
1.9654 ++ [(const_int 0)]
1.9655 ++ ""
1.9656 ++ "nop\\t"
1.9657 ++ [(set_attr "type" "alu")])
1.9658 ++
1.9659 ++(define_insn "sync"
1.9660 ++ [(unspec_volatile [(const_int 0)] UNSPEC_SYNC)]
1.9661 ++ ""
1.9662 ++ "sync\\t"
1.9663 ++ [(set_attr "type" "control")])
1.9664 ++
1.9665 ++
1.9666 ++(define_insn "rdctl"
1.9667 ++ [(set (match_operand:SI 0 "register_operand" "=r")
1.9668 ++ (unspec_volatile:SI [(match_operand:SI 1 "rdwrctl_operand" "O")] UNSPEC_RDCTL))]
1.9669 ++ ""
1.9670 ++ "rdctl\\t%0, ctl%1"
1.9671 ++ [(set_attr "type" "control")])
1.9672 ++
1.9673 ++(define_insn "wrctl"
1.9674 ++ [(unspec_volatile:SI [(match_operand:SI 0 "rdwrctl_operand" "O")
1.9675 ++ (match_operand:SI 1 "register_operand" "r")] UNSPEC_WRCTL)]
1.9676 ++ ""
1.9677 ++ "wrctl\\tctl%0, %1"
1.9678 ++ [(set_attr "type" "control")])
1.9679 ++
1.9680 ++
1.9681 ++
1.9682 ++;*****************************************************************************
1.9683 ++;*
1.9684 ++;* Peepholes
1.9685 ++;*
1.9686 ++;*****************************************************************************
1.9687 ++
1.9688 ++
1.9689 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/nios2-protos.h gcc-3.4.6/gcc/config/nios2/nios2-protos.h
1.9690 +--- gcc-3.4.6.orig/gcc/config/nios2/nios2-protos.h 1970-01-01 01:00:00.000000000 +0100
1.9691 ++++ gcc-3.4.6/gcc/config/nios2/nios2-protos.h 2007-08-15 23:09:36.000000000 +0200
1.9692 +@@ -0,0 +1,70 @@
1.9693 ++/* Subroutines for assembler code output for Altera NIOS 2G NIOS2 version.
1.9694 ++ Copyright (C) 2003 Altera
1.9695 ++ Contributed by Jonah Graham (jgraham@altera.com).
1.9696 ++
1.9697 ++This file is part of GNU CC.
1.9698 ++
1.9699 ++GNU CC is free software; you can redistribute it and/or modify
1.9700 ++it under the terms of the GNU General Public License as published by
1.9701 ++the Free Software Foundation; either version 2, or (at your option)
1.9702 ++any later version.
1.9703 ++
1.9704 ++GNU CC is distributed in the hope that it will be useful,
1.9705 ++but WITHOUT ANY WARRANTY; without even the implied warranty of
1.9706 ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.9707 ++GNU General Public License for more details.
1.9708 ++
1.9709 ++You should have received a copy of the GNU General Public License
1.9710 ++along with GNU CC; see the file COPYING. If not, write to
1.9711 ++the Free Software Foundation, 59 Temple Place - Suite 330,
1.9712 ++Boston, MA 02111-1307, USA. */
1.9713 ++
1.9714 ++extern void dump_frame_size (FILE *);
1.9715 ++extern HOST_WIDE_INT compute_frame_size (void);
1.9716 ++extern int nios2_initial_elimination_offset (int, int);
1.9717 ++extern void override_options (void);
1.9718 ++extern void optimization_options (int, int);
1.9719 ++extern int nios2_can_use_return_insn (void);
1.9720 ++extern void expand_prologue (void);
1.9721 ++extern void expand_epilogue (bool);
1.9722 ++extern void function_profiler (FILE *, int);
1.9723 ++
1.9724 ++
1.9725 ++#ifdef RTX_CODE
1.9726 ++extern int nios2_legitimate_address (rtx, enum machine_mode, int);
1.9727 ++extern void nios2_print_operand (FILE *, rtx, int);
1.9728 ++extern void nios2_print_operand_address (FILE *, rtx);
1.9729 ++
1.9730 ++extern int nios2_emit_move_sequence (rtx *, enum machine_mode);
1.9731 ++extern int nios2_emit_expensive_div (rtx *, enum machine_mode);
1.9732 ++
1.9733 ++extern void gen_int_relational (enum rtx_code, rtx, rtx, rtx, rtx);
1.9734 ++extern void gen_conditional_move (rtx *, enum machine_mode);
1.9735 ++extern const char *asm_output_opcode (FILE *, const char *);
1.9736 ++
1.9737 ++/* predicates */
1.9738 ++extern int arith_operand (rtx, enum machine_mode);
1.9739 ++extern int uns_arith_operand (rtx, enum machine_mode);
1.9740 ++extern int logical_operand (rtx, enum machine_mode);
1.9741 ++extern int shift_operand (rtx, enum machine_mode);
1.9742 ++extern int reg_or_0_operand (rtx, enum machine_mode);
1.9743 ++extern int equality_op (rtx, enum machine_mode);
1.9744 ++extern int custom_insn_opcode (rtx, enum machine_mode);
1.9745 ++extern int rdwrctl_operand (rtx, enum machine_mode);
1.9746 ++
1.9747 ++# ifdef HAVE_MACHINE_MODES
1.9748 ++# if defined TREE_CODE
1.9749 ++extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
1.9750 ++extern rtx function_arg (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
1.9751 ++extern int function_arg_partial_nregs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
1.9752 ++extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int);
1.9753 ++extern int nios2_setup_incoming_varargs (const CUMULATIVE_ARGS *, enum machine_mode, tree, int);
1.9754 ++
1.9755 ++# endif /* TREE_CODE */
1.9756 ++# endif /* HAVE_MACHINE_MODES */
1.9757 ++#endif
1.9758 ++
1.9759 ++#ifdef TREE_CODE
1.9760 ++extern int nios2_return_in_memory (tree);
1.9761 ++
1.9762 ++#endif /* TREE_CODE */
1.9763 +diff -durN gcc-3.4.6.orig/gcc/config/nios2/t-nios2 gcc-3.4.6/gcc/config/nios2/t-nios2
1.9764 +--- gcc-3.4.6.orig/gcc/config/nios2/t-nios2 1970-01-01 01:00:00.000000000 +0100
1.9765 ++++ gcc-3.4.6/gcc/config/nios2/t-nios2 2007-08-15 23:09:36.000000000 +0200
1.9766 +@@ -0,0 +1,123 @@
1.9767 ++##
1.9768 ++## Compiler flags to use when compiling libgcc2.c.
1.9769 ++##
1.9770 ++## LIB2FUNCS_EXTRA
1.9771 ++## A list of source file names to be compiled or assembled and inserted into libgcc.a.
1.9772 ++
1.9773 ++LIB2FUNCS_EXTRA=$(srcdir)/config/nios2/lib2-divmod.c \
1.9774 ++ $(srcdir)/config/nios2/lib2-divmod-hi.c \
1.9775 ++ $(srcdir)/config/nios2/lib2-divtable.c \
1.9776 ++ $(srcdir)/config/nios2/lib2-mul.c
1.9777 ++
1.9778 ++##
1.9779 ++## Floating Point Emulation
1.9780 ++## To have GCC include software floating point libraries in libgcc.a define FPBIT
1.9781 ++## and DPBIT along with a few rules as follows:
1.9782 ++##
1.9783 ++## # We want fine grained libraries, so use the new code
1.9784 ++## # to build the floating point emulation libraries.
1.9785 ++FPBIT=$(srcdir)/config/nios2/nios2-fp-bit.c
1.9786 ++DPBIT=$(srcdir)/config/nios2/nios2-dp-bit.c
1.9787 ++
1.9788 ++TARGET_LIBGCC2_CFLAGS = -O2
1.9789 ++
1.9790 ++# FLOAT_ONLY - no doubles
1.9791 ++# SMALL_MACHINE - QI/HI is faster than SI
1.9792 ++# Actually SMALL_MACHINE uses chars and shorts instead of ints
1.9793 ++# since ints (16-bit ones as they are today) are at least as fast
1.9794 ++# as chars and shorts, don't define SMALL_MACHINE
1.9795 ++# CMPtype - type returned by FP compare, i.e. INT (hard coded in fp-bit - see code )
1.9796 ++
1.9797 ++$(FPBIT): $(srcdir)/config/fp-bit.c Makefile
1.9798 ++ echo '#define FLOAT' > ${FPBIT}
1.9799 ++ cat $(srcdir)/config/fp-bit.c >> ${FPBIT}
1.9800 ++
1.9801 ++$(DPBIT): $(srcdir)/config/fp-bit.c Makefile
1.9802 ++ echo '' > ${DPBIT}
1.9803 ++ cat $(srcdir)/config/fp-bit.c >> ${DPBIT}
1.9804 ++
1.9805 ++EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o
1.9806 ++
1.9807 ++# Assemble startup files.
1.9808 ++$(T)crti.o: $(srcdir)/config/nios2/crti.asm $(GCC_PASSES)
1.9809 ++ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
1.9810 ++ -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/nios2/crti.asm
1.9811 ++
1.9812 ++$(T)crtn.o: $(srcdir)/config/nios2/crtn.asm $(GCC_PASSES)
1.9813 ++ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
1.9814 ++ -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/nios2/crtn.asm
1.9815 ++
1.9816 ++
1.9817 ++## You may need to provide additional #defines at the beginning of
1.9818 ++## fp-bit.c and dp-bit.c to control target endianness and other options
1.9819 ++##
1.9820 ++## CRTSTUFF_T_CFLAGS
1.9821 ++## Special flags used when compiling crtstuff.c. See Initialization.
1.9822 ++##
1.9823 ++## CRTSTUFF_T_CFLAGS_S
1.9824 ++## Special flags used when compiling crtstuff.c for shared linking. Used
1.9825 ++## if you use crtbeginS.o and crtendS.o in EXTRA-PARTS. See Initialization.
1.9826 ++##
1.9827 ++## MULTILIB_OPTIONS
1.9828 ++## For some targets, invoking GCC in different ways produces objects that
1.9829 ++## can not be linked together. For example, for some targets GCC produces
1.9830 ++## both big and little endian code. For these targets, you must arrange
1.9831 ++## for multiple versions of libgcc.a to be compiled, one for each set of
1.9832 ++## incompatible options. When GCC invokes the linker, it arranges to link
1.9833 ++## in the right version of libgcc.a, based on the command line options
1.9834 ++## used.
1.9835 ++## The MULTILIB_OPTIONS macro lists the set of options for which special
1.9836 ++## versions of libgcc.a must be built. Write options that are mutually
1.9837 ++## incompatible side by side, separated by a slash. Write options that may
1.9838 ++## be used together separated by a space. The build procedure will build
1.9839 ++## all combinations of compatible options.
1.9840 ++##
1.9841 ++## For example, if you set MULTILIB_OPTIONS to m68000/m68020 msoft-float,
1.9842 ++## Makefile will build special versions of libgcc.a using the following
1.9843 ++## sets of options: -m68000, -m68020, -msoft-float, -m68000 -msoft-float,
1.9844 ++## and -m68020 -msoft-float.
1.9845 ++
1.9846 ++MULTILIB_OPTIONS = mno-hw-mul mhw-mulx
1.9847 ++
1.9848 ++## MULTILIB_DIRNAMES
1.9849 ++## If MULTILIB_OPTIONS is used, this variable specifies the directory names
1.9850 ++## that should be used to hold the various libraries. Write one element in
1.9851 ++## MULTILIB_DIRNAMES for each element in MULTILIB_OPTIONS. If
1.9852 ++## MULTILIB_DIRNAMES is not used, the default value will be
1.9853 ++## MULTILIB_OPTIONS, with all slashes treated as spaces.
1.9854 ++## For example, if MULTILIB_OPTIONS is set to m68000/m68020 msoft-float,
1.9855 ++## then the default value of MULTILIB_DIRNAMES is m68000 m68020
1.9856 ++## msoft-float. You may specify a different value if you desire a
1.9857 ++## different set of directory names.
1.9858 ++
1.9859 ++# MULTILIB_DIRNAMES =
1.9860 ++
1.9861 ++## MULTILIB_MATCHES
1.9862 ++## Sometimes the same option may be written in two different ways. If an
1.9863 ++## option is listed in MULTILIB_OPTIONS, GCC needs to know about any
1.9864 ++## synonyms. In that case, set MULTILIB_MATCHES to a list of items of the
1.9865 ++## form option=option to describe all relevant synonyms. For example,
1.9866 ++## m68000=mc68000 m68020=mc68020.
1.9867 ++##
1.9868 ++## MULTILIB_EXCEPTIONS
1.9869 ++## Sometimes when there are multiple sets of MULTILIB_OPTIONS being
1.9870 ++## specified, there are combinations that should not be built. In that
1.9871 ++## case, set MULTILIB_EXCEPTIONS to be all of the switch exceptions in
1.9872 ++## shell case syntax that should not be built.
1.9873 ++## For example, in the PowerPC embedded ABI support, it is not desirable to
1.9874 ++## build libraries compiled with the -mcall-aix option and either of the
1.9875 ++## -fleading-underscore or -mlittle options at the same time. Therefore
1.9876 ++## MULTILIB_EXCEPTIONS is set to
1.9877 ++##
1.9878 ++## *mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*
1.9879 ++##
1.9880 ++
1.9881 ++MULTILIB_EXCEPTIONS = *mno-hw-mul/*mhw-mulx*
1.9882 ++
1.9883 ++##
1.9884 ++## MULTILIB_EXTRA_OPTS Sometimes it is desirable that when building
1.9885 ++## multiple versions of libgcc.a certain options should always be passed on
1.9886 ++## to the compiler. In that case, set MULTILIB_EXTRA_OPTS to be the list
1.9887 ++## of options to be used for all builds.
1.9888 ++##
1.9889 ++
1.9890 +diff -durN gcc-3.4.6.orig/gcc/config.gcc gcc-3.4.6/gcc/config.gcc
1.9891 +--- gcc-3.4.6.orig/gcc/config.gcc 2007-08-15 23:07:00.000000000 +0200
1.9892 ++++ gcc-3.4.6/gcc/config.gcc 2007-08-15 23:09:36.000000000 +0200
1.9893 +@@ -1342,6 +1342,10 @@
1.9894 + thread_file='posix'
1.9895 + fi
1.9896 + ;;
1.9897 ++# JBG
1.9898 ++nios2-*-* | nios2-*-*)
1.9899 ++ tm_file="elfos.h ${tm_file}"
1.9900 ++ ;;
1.9901 + # m68hc11 and m68hc12 share the same machine description.
1.9902 + m68hc11-*-*|m6811-*-*)
1.9903 + tm_file="dbxelf.h elfos.h m68hc11/m68hc11.h"
1.9904 +diff -durN gcc-3.4.6.orig/gcc/cse.c gcc-3.4.6/gcc/cse.c
1.9905 +--- gcc-3.4.6.orig/gcc/cse.c 2005-12-31 01:39:42.000000000 +0100
1.9906 ++++ gcc-3.4.6/gcc/cse.c 2007-08-15 23:09:36.000000000 +0200
1.9907 +@@ -3134,6 +3134,10 @@
1.9908 + #ifdef FLOAT_STORE_FLAG_VALUE
1.9909 + REAL_VALUE_TYPE fsfv;
1.9910 + #endif
1.9911 ++#ifdef __nios2__
1.9912 ++ if (p->is_const)
1.9913 ++ break;
1.9914 ++#endif
1.9915 +
1.9916 + /* If the entry isn't valid, skip it. */
1.9917 + if (! exp_equiv_p (p->exp, p->exp, 1, 0))
1.9918 +diff -durN gcc-3.4.6.orig/gcc/doc/extend.texi gcc-3.4.6/gcc/doc/extend.texi
1.9919 +--- gcc-3.4.6.orig/gcc/doc/extend.texi 2005-02-26 23:17:26.000000000 +0100
1.9920 ++++ gcc-3.4.6/gcc/doc/extend.texi 2007-08-15 23:09:36.000000000 +0200
1.9921 +@@ -5638,12 +5638,118 @@
1.9922 + instructions, but allow the compiler to schedule those calls.
1.9923 +
1.9924 + @menu
1.9925 ++* Altera Nios II Built-in Functions::
1.9926 + * Alpha Built-in Functions::
1.9927 + * ARM Built-in Functions::
1.9928 + * X86 Built-in Functions::
1.9929 + * PowerPC AltiVec Built-in Functions::
1.9930 + @end menu
1.9931 +
1.9932 ++@node Altera Nios II Built-in Functions
1.9933 ++@subsection Altera Nios II Built-in Functions
1.9934 ++
1.9935 ++These built-in functions are available for the Altera Nios II
1.9936 ++family of processors.
1.9937 ++
1.9938 ++The following built-in functions are always available. They
1.9939 ++all generate the machine instruction that is part of the name.
1.9940 ++
1.9941 ++@example
1.9942 ++int __builtin_ldbio (volatile const void *)
1.9943 ++int __builtin_ldbuio (volatile const void *)
1.9944 ++int __builtin_ldhio (volatile const void *)
1.9945 ++int __builtin_ldhuio (volatile const void *)
1.9946 ++int __builtin_ldwio (volatile const void *)
1.9947 ++void __builtin_stbio (volatile void *, int)
1.9948 ++void __builtin_sthio (volatile void *, int)
1.9949 ++void __builtin_stwio (volatile void *, int)
1.9950 ++void __builtin_sync (void)
1.9951 ++int __builtin_rdctl (int)
1.9952 ++void __builtin_wrctl (int, int)
1.9953 ++@end example
1.9954 ++
1.9955 ++The following built-in functions are always available. They
1.9956 ++all generate a Nios II Custom Instruction. The name of the
1.9957 ++function represents the types that the function takes and
1.9958 ++returns. The letter before the @code{n} is the return type
1.9959 ++or void if absent. The @code{n} represnts the first parameter
1.9960 ++to all the custom instructions, the custom instruction number.
1.9961 ++The two letters after the @code{n} represent the up to two
1.9962 ++parameters to the function.
1.9963 ++
1.9964 ++The letters reprsent the following data types:
1.9965 ++@table @code
1.9966 ++@item <no letter>
1.9967 ++@code{void} for return type and no parameter for parameter types.
1.9968 ++
1.9969 ++@item i
1.9970 ++@code{int} for return type and parameter type
1.9971 ++
1.9972 ++@item f
1.9973 ++@code{float} for return type and parameter type
1.9974 ++
1.9975 ++@item p
1.9976 ++@code{void *} for return type and parameter type
1.9977 ++
1.9978 ++@end table
1.9979 ++
1.9980 ++And the function names are:
1.9981 ++@example
1.9982 ++void __builtin_custom_n (void)
1.9983 ++void __builtin_custom_ni (int)
1.9984 ++void __builtin_custom_nf (float)
1.9985 ++void __builtin_custom_np (void *)
1.9986 ++void __builtin_custom_nii (int, int)
1.9987 ++void __builtin_custom_nif (int, float)
1.9988 ++void __builtin_custom_nip (int, void *)
1.9989 ++void __builtin_custom_nfi (float, int)
1.9990 ++void __builtin_custom_nff (float, float)
1.9991 ++void __builtin_custom_nfp (float, void *)
1.9992 ++void __builtin_custom_npi (void *, int)
1.9993 ++void __builtin_custom_npf (void *, float)
1.9994 ++void __builtin_custom_npp (void *, void *)
1.9995 ++int __builtin_custom_in (void)
1.9996 ++int __builtin_custom_ini (int)
1.9997 ++int __builtin_custom_inf (float)
1.9998 ++int __builtin_custom_inp (void *)
1.9999 ++int __builtin_custom_inii (int, int)
1.10000 ++int __builtin_custom_inif (int, float)
1.10001 ++int __builtin_custom_inip (int, void *)
1.10002 ++int __builtin_custom_infi (float, int)
1.10003 ++int __builtin_custom_inff (float, float)
1.10004 ++int __builtin_custom_infp (float, void *)
1.10005 ++int __builtin_custom_inpi (void *, int)
1.10006 ++int __builtin_custom_inpf (void *, float)
1.10007 ++int __builtin_custom_inpp (void *, void *)
1.10008 ++float __builtin_custom_fn (void)
1.10009 ++float __builtin_custom_fni (int)
1.10010 ++float __builtin_custom_fnf (float)
1.10011 ++float __builtin_custom_fnp (void *)
1.10012 ++float __builtin_custom_fnii (int, int)
1.10013 ++float __builtin_custom_fnif (int, float)
1.10014 ++float __builtin_custom_fnip (int, void *)
1.10015 ++float __builtin_custom_fnfi (float, int)
1.10016 ++float __builtin_custom_fnff (float, float)
1.10017 ++float __builtin_custom_fnfp (float, void *)
1.10018 ++float __builtin_custom_fnpi (void *, int)
1.10019 ++float __builtin_custom_fnpf (void *, float)
1.10020 ++float __builtin_custom_fnpp (void *, void *)
1.10021 ++void * __builtin_custom_pn (void)
1.10022 ++void * __builtin_custom_pni (int)
1.10023 ++void * __builtin_custom_pnf (float)
1.10024 ++void * __builtin_custom_pnp (void *)
1.10025 ++void * __builtin_custom_pnii (int, int)
1.10026 ++void * __builtin_custom_pnif (int, float)
1.10027 ++void * __builtin_custom_pnip (int, void *)
1.10028 ++void * __builtin_custom_pnfi (float, int)
1.10029 ++void * __builtin_custom_pnff (float, float)
1.10030 ++void * __builtin_custom_pnfp (float, void *)
1.10031 ++void * __builtin_custom_pnpi (void *, int)
1.10032 ++void * __builtin_custom_pnpf (void *, float)
1.10033 ++void * __builtin_custom_pnpp (void *, void *)
1.10034 ++@end example
1.10035 ++
1.10036 ++
1.10037 + @node Alpha Built-in Functions
1.10038 + @subsection Alpha Built-in Functions
1.10039 +
1.10040 +diff -durN gcc-3.4.6.orig/gcc/doc/invoke.texi gcc-3.4.6/gcc/doc/invoke.texi
1.10041 +--- gcc-3.4.6.orig/gcc/doc/invoke.texi 2005-10-08 02:22:20.000000000 +0200
1.10042 ++++ gcc-3.4.6/gcc/doc/invoke.texi 2007-08-15 23:09:36.000000000 +0200
1.10043 +@@ -337,6 +337,14 @@
1.10044 + @item Machine Dependent Options
1.10045 + @xref{Submodel Options,,Hardware Models and Configurations}.
1.10046 +
1.10047 ++@emph{Altera Nios II Options}
1.10048 ++@gccoptlist{-msmallc -mno-bypass-cache -mbypass-cache @gol
1.10049 ++-mno-cache-volatile -mcache-volatile -mno-inline-memcpy @gol
1.10050 ++-minline-memcpy -mno-fast-sw-div -mfast-sw-div @gol
1.10051 ++-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx @gol
1.10052 ++-mno-hw-div -mhw-div @gol
1.10053 ++-msys-crt0= -msys-lib= -msys=nosys }
1.10054 ++
1.10055 + @emph{M680x0 Options}
1.10056 + @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1.10057 + -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol
1.10058 +@@ -5839,6 +5847,7 @@
1.10059 + that macro, which enables you to change the defaults.
1.10060 +
1.10061 + @menu
1.10062 ++* Altera Nios II Options::
1.10063 + * M680x0 Options::
1.10064 + * M68hc1x Options::
1.10065 + * VAX Options::
1.10066 +@@ -5874,6 +5883,103 @@
1.10067 + * FRV Options::
1.10068 + @end menu
1.10069 +
1.10070 ++
1.10071 ++@node Altera Nios II Options
1.10072 ++@subsection Altera Nios II Options
1.10073 ++@cindex Altera Nios II options
1.10074 ++
1.10075 ++These are the @samp{-m} options defined for the Altera Nios II
1.10076 ++processor.
1.10077 ++
1.10078 ++@table @gcctabopt
1.10079 ++
1.10080 ++@item -msmallc
1.10081 ++@opindex msmallc
1.10082 ++
1.10083 ++Link with a limited version of the C library, -lsmallc. For more
1.10084 ++information see the C Library Documentation.
1.10085 ++
1.10086 ++
1.10087 ++@item -mbypass-cache
1.10088 ++@itemx -mno-bypass-cache
1.10089 ++@opindex mno-bypass-cache
1.10090 ++@opindex mbypass-cache
1.10091 ++
1.10092 ++Force all load and store instructions to always bypass cache by
1.10093 ++using io variants of the instructions. The default is to not
1.10094 ++bypass the cache.
1.10095 ++
1.10096 ++@item -mno-cache-volatile
1.10097 ++@itemx -mcache-volatile
1.10098 ++@opindex mcache-volatile
1.10099 ++@opindex mno-cache-volatile
1.10100 ++
1.10101 ++Volatile memory access bypass the cache using the io variants of
1.10102 ++the ld and st instructions. The default is to cache volatile
1.10103 ++accesses.
1.10104 ++
1.10105 ++-mno-cache-volatile is deprecated and will be deleted in a
1.10106 ++future GCC release.
1.10107 ++
1.10108 ++
1.10109 ++@item -mno-inline-memcpy
1.10110 ++@itemx -minline-memcpy
1.10111 ++@opindex mno-inline-memcpy
1.10112 ++@opindex minline-memcpy
1.10113 ++
1.10114 ++Do not inline memcpy. The default is to inline when -O is on.
1.10115 ++
1.10116 ++
1.10117 ++@item -mno-fast-sw-div
1.10118 ++@itemx -mfast-sw-div
1.10119 ++@opindex mno-fast-sw-div
1.10120 ++@opindex mfast-sw-div
1.10121 ++
1.10122 ++Do no use table based fast divide for small numbers. The default
1.10123 ++is to use the fast divide at -O3 and above.
1.10124 ++
1.10125 ++
1.10126 ++@item -mno-hw-mul
1.10127 ++@itemx -mhw-mul
1.10128 ++@itemx -mno-hw-mulx
1.10129 ++@itemx -mhw-mulx
1.10130 ++@itemx -mno-hw-div
1.10131 ++@itemx -mhw-div
1.10132 ++@opindex mno-hw-mul
1.10133 ++@opindex mhw-mul
1.10134 ++@opindex mno-hw-mulx
1.10135 ++@opindex mhw-mulx
1.10136 ++@opindex mno-hw-div
1.10137 ++@opindex mhw-div
1.10138 ++
1.10139 ++Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
1.10140 ++instructions by the compiler. The default is to emit @code{mul}
1.10141 ++and not emit @code{div} and @code{mulx}.
1.10142 ++
1.10143 ++The different combinations of @code{mul} and @code{mulx} instructions
1.10144 ++generate a different multilib options.
1.10145 ++
1.10146 ++
1.10147 ++@item -msys-crt0=@var{startfile}
1.10148 ++@opindex msys-crt0
1.10149 ++
1.10150 ++@var{startfile} is the file name of the startfile (crt0) to use
1.10151 ++when linking. The default is crt0.o that comes with libgloss
1.10152 ++and is only suitable for use with the instruction set
1.10153 ++simulator.
1.10154 ++
1.10155 ++@item -msys-lib=@var{systemlib}
1.10156 ++@itemx -msys-lib=nosys
1.10157 ++@opindex msys-lib
1.10158 ++
1.10159 ++@var{systemlib} is the library name of the library which provides
1.10160 ++the system calls required by the C library, e.g. @code{read}, @code{write}
1.10161 ++etc. The default is to use nosys, this library provides
1.10162 ++stub implementations of the calls and is part of libgloss.
1.10163 ++
1.10164 ++@end table
1.10165 ++
1.10166 ++
1.10167 + @node M680x0 Options
1.10168 + @subsection M680x0 Options
1.10169 + @cindex M680x0 options
1.10170 +diff -durN gcc-3.4.6.orig/gcc/doc/md.texi gcc-3.4.6/gcc/doc/md.texi
1.10171 +--- gcc-3.4.6.orig/gcc/doc/md.texi 2004-11-13 23:31:42.000000000 +0100
1.10172 ++++ gcc-3.4.6/gcc/doc/md.texi 2007-08-15 23:09:36.000000000 +0200
1.10173 +@@ -1337,6 +1337,49 @@
1.10174 + available on some particular machines.
1.10175 +
1.10176 + @table @emph
1.10177 ++
1.10178 ++@item Altera Nios II family---@file{nios2.h}
1.10179 ++@table @code
1.10180 ++
1.10181 ++@item I
1.10182 ++Integer that is valid as an immediate operand in an
1.10183 ++instruction taking a signed 16-bit number. Range
1.10184 ++@minus{}32768 to 32767.
1.10185 ++
1.10186 ++@item J
1.10187 ++Integer that is valid as an immediate operand in an
1.10188 ++instruction taking an unsigned 16-bit number. Range
1.10189 ++0 to 65535.
1.10190 ++
1.10191 ++@item K
1.10192 ++Integer that is valid as an immediate operand in an
1.10193 ++instruction taking only the upper 16-bits of a
1.10194 ++32-bit number. Range 32-bit numbers with the lower
1.10195 ++16-bits being 0.
1.10196 ++
1.10197 ++@item L
1.10198 ++Integer that is valid as an immediate operand for a
1.10199 ++shift instruction. Range 0 to 31.
1.10200 ++
1.10201 ++
1.10202 ++@item M
1.10203 ++Integer that is valid as an immediate operand for
1.10204 ++only the value 0. Can be used in conjunction with
1.10205 ++the format modifier @code{z} to use @code{r0}
1.10206 ++instead of @code{0} in the assembly output.
1.10207 ++
1.10208 ++@item N
1.10209 ++Integer that is valid as an immediate operand for
1.10210 ++a custom instruction opcode. Range 0 to 255.
1.10211 ++
1.10212 ++@item S
1.10213 ++Matches immediates which are addresses in the small
1.10214 ++data section and therefore can be added to @code{gp}
1.10215 ++as a 16-bit immediate to re-create their 32-bit value.
1.10216 ++
1.10217 ++@end table
1.10218 ++
1.10219 ++
1.10220 + @item ARM family---@file{arm.h}
1.10221 + @table @code
1.10222 + @item f
1.10223 +diff -durN gcc-3.4.6.orig/gcc/Makefile.in gcc-3.4.6/gcc/Makefile.in
1.10224 +--- gcc-3.4.6.orig/gcc/Makefile.in 2005-02-24 10:26:59.000000000 +0100
1.10225 ++++ gcc-3.4.6/gcc/Makefile.in 2007-08-15 23:09:36.000000000 +0200
1.10226 +@@ -3094,7 +3094,7 @@
1.10227 + $(INSTALL_DATA) $(srcdir)/README-fixinc \
1.10228 + $(DESTDIR)$(itoolsdatadir)/include/README ; \
1.10229 + $(INSTALL_SCRIPT) fixinc.sh $(DESTDIR)$(itoolsdir)/fixinc.sh ; \
1.10230 +- $(INSTALL_PROGRAM) fixinc/fixincl $(DESTDIR)$(itoolsdir)/fixincl ; \
1.10231 ++ $(INSTALL_PROGRAM) fixinc/fixincl$(build_exeext) $(DESTDIR)$(itoolsdir)/fixincl$(build_exeext) ; \
1.10232 + $(INSTALL_DATA) $(srcdir)/gsyslimits.h \
1.10233 + $(DESTDIR)$(itoolsdatadir)/gsyslimits.h ; \
1.10234 + else :; fi