1 /* Copyright (C) 2006-2017 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"
47 bic.f 0,0x7f800000,r12
51 jne_s [blink] ; both NaN -> OK
54 #define __truncdfsf2 __truncdfsf2_asm
65 brhs r3,0xff,.Lill_exp
69 0x2fffffff /* Check if msb guard bit wants rounding up. */
73 add_s DBL0H,DBL0H,DBL0L
83 rsub.f r12,r12,8+0x400-32 ; Go from 9 to 1 guard bit in MSW. */
86 rrc DBL0H,DBL0H ; insert leading 1
87 asl.f 0,DBL0L,8 ; check lower 24 guard bits
89 add.pnz r3,r3,1 ; assemble fraction with compressed guard bits.
106 0x5fffffff /* Check if msb guard bit wants rounding up. */
110 bset_s DBL0H,DBL0H,23
111 add_s DBL0H,DBL0H,DBL0L
116 /* We would generally say that NaNs must have a non-zero high fraction part,
117 but to allow hardware double precision floating point to interoperate
118 with single precision software floating point, we make an exception here.
119 The cost is to replace a tst_s DBL0H with an or.f DBL0L,DBL0L,DBL0H .
120 As we start out unaligned, and there is an odd number of other short insns,
121 we have a choice of letting this cost us a misalign penalty or
122 4 more bytes (if we align the code). We choose the former here because
123 infinity / NaN is not expected to be prevalent in time-critical code. */
125 or.f DBL0L,DBL0L,DBL0H
134 ENDFUNC(__truncdfsf2)