1 /* Copyright (C) 2008-2019 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 #define __muldf3 __muldf3_asm
55 __muldf3_support: /* This label makes debugger output saner. */
59 breq.d DBL1L,0,.Lret0_2 ; 0 input -> 0 output
69 sub_l DBL1L,DBL1L,DBL1H
75 machulw r4,DBL0L,DBL1L
76 ld.as r9,[pcl,0x67] ; ((.L7ff00000-.+2)/4)]
82 breq.d r11,0,.Ldenorm_dbl0
84 breq.d r12,0,.Ldenorm_dbl1
87 breq.d r11,r9,.Linf_nan
89 breq.d r12,r9,.Linf_nan
93 add_s r12,r12,r11 ; add exponents
97 machulw r7,r6,r10 ; fraction product in r7:acc2:r4:r8
99 bclr r8,r9,30 ; 0x3ff00000
100 bset.ne r4,r4,0 ; put least significant word into sticky bit
101 bclr r6,r9,20 ; 0x7fe00000
103 rsub.eq r8,r8,r9 ; 0x40000000
104 sub r12,r12,r8 ; subtract bias + implicit 1
105 brhs.d r12,r6,.Linf_denorm
113 cmp.eq r4,r4 ; round to nearest / round to even
122 bset.mi DBL0H,DBL0H,31
124 /* N.B. This is optimized for ARC700.
125 ARC600 has very different scheduling / instruction selection criteria. */
127 /* If one number is denormal, subtract some from the exponent of the other
128 one (if the other exponent is too small, return 0), and normalize the
129 denormal. Then re-run the computation. */
145 brhs r11,r9,.Linf_nan
146 brhs 0x3ca00001,r11,.Lret0
147 sub_s DBL0H,DBL0H,DBL1H
148 bmsk.f DBL1H,DBL1H,30
149 add_s DBL0H,DBL0H,DBL1H
154 asl_s DBL1H,DBL1H,r12
158 asl_s DBL1L,DBL1L,r12
162 .Lret0: xor_s DBL0H,DBL0H,DBL1H
164 xor_s DBL0H,DBL0H,DBL1H
171 xor_s DBL1H,DBL1H,DBL0H
172 bclr_s DBL0H,DBL0H,31
173 max r8,DBL0H,r12 ; either NaN -> NaN ; otherwise inf
176 or.ne.f DBL1L,DBL1L,r12
177 not_s DBL0H,DBL0L ; inf * 0 -> NaN
181 bset.mi DBL0H,DBL0H,31
183 /* We have checked for infinity / NaN input before, and transformed
184 denormalized inputs into normalized inputs. Thus, the worst case
185 exponent overflows are:
186 1 + 1 - 0x400 == 0xc02 : maximum underflow
187 0x7fe + 0x7fe - 0x3ff == 0xbfd ; maximum overflow
188 N.B. 0x7e and 0x7f are also values for overflow.
190 If (r12 <= -54), we have an underflow to zero. */
197 brgt.d r10,0,.Lshift_frac
206 brge.d r10,1,.Lshift_frac
208 breq.d r10,0,.Lround_frac
210 brgt r10,21,.Lshift32_frac
218 adc.eq.f DBL0L,DBL0L,0
223 xor.f DBL1H,DBL1H,DBL0H
226 bset.mi DBL0H,DBL0H,31