1 /* Copyright (C) 2008-2021 Free Software Foundation, Inc.
2 Contributor: Joern Rennecke <joern.rennecke@embecosm.com>
3 on behalf of Synopsys Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #include "../arc-ieee-754.h"
52 bic.f 0,0x7ff80000,r12 ; both NaN -> OK
55 #define __muldf3 __muldf3_asm
58 __muldf3_support: /* This label makes debugger output saner. */
62 breq.d DBL1L,0,.Lret0_2 ; 0 input -> 0 output
72 sub_l DBL1L,DBL1L,DBL1H
78 ld.as r9,[pcl,0x68] ; ((.L7ff00000-.+2)/4)]
82 breq.d r11,0,.Ldenorm_dbl0
84 breq.d r12,0,.Ldenorm_dbl1
88 breq.d r11,r9,.Linf_nan
90 breq.d r12,r9,.Linf_nan
95 add_s r12,r12,r11 ; add exponents
100 bclr r8,r9,30 ; 0x3ff00000
101 bset.ne r4,r4,0 ; put least significant word into sticky bit
102 bclr r6,r9,20 ; 0x7fe00000
104 adc r7,mhi,0 ; fraction product in r7:r5:r4
106 rsub.eq r8,r8,r9 ; 0x40000000
107 sub r12,r12,r8 ; subtract bias + implicit 1
108 brhs.d r12,r6,.Linf_denorm
116 cmp.eq r4,r4 ; round to nearest / round to even
125 bset.mi DBL0H,DBL0H,31
127 /* N.B. This is optimized for ARC700.
128 ARC600 has very different scheduling / instruction selection criteria. */
130 /* If one number is denormal, subtract some from the exponent of the other
131 one (if the other exponent is too small, return 0), and normalize the
132 denormal. Then re-run the computation. */
148 brhs r11,r9,.Linf_nan
149 brhs 0x3ca00001,r11,.Lret0
150 sub_s DBL0H,DBL0H,DBL1H
151 bmsk.f DBL1H,DBL1H,30
152 add_s DBL0H,DBL0H,DBL1H
157 asl_s DBL1H,DBL1H,r12
161 asl_s DBL1L,DBL1L,r12
165 .Lret0: xor_s DBL0H,DBL0H,DBL1H
167 xor_s DBL0H,DBL0H,DBL1H
174 xor_s DBL1H,DBL1H,DBL0H
175 bclr_s DBL0H,DBL0H,31
176 max r8,DBL0H,r12 ; either NaN -> NaN ; otherwise inf
179 or.ne.f DBL1L,DBL1L,r12
180 not_s DBL0H,DBL0L ; inf * 0 -> NaN
184 bset.mi DBL0H,DBL0H,31
186 /* We have checked for infinity / NaN input before, and transformed
187 denormalized inputs into normalized inputs. Thus, the worst case
188 exponent overflows are:
189 1 + 1 - 0x400 == 0xc02 : maximum underflow
190 0x7fe + 0x7fe - 0x3ff == 0xbfd ; maximum overflow
191 N.B. 0x7e and 0x7f are also values for overflow.
193 If (r12 <= -54), we have an underflow to zero. */
200 brgt.d r10,0,.Lshift_frac
209 brge.d r10,1,.Lshift_frac
211 breq.d r10,0,.Lround_frac
213 brgt r10,21,.Lshift32_frac
221 adc.eq.f DBL0L,DBL0L,0
226 xor.f DBL1H,DBL1H,DBL0H
229 bset.mi DBL0H,DBL0H,31