gcc50: Disconnect from buildworld.
[dragonfly.git] / contrib / gcc-5.0 / libgcc / config / arc / ieee-754 / fixdfsi.S
1 /* Copyright (C) 2008-2015 Free Software Foundation, Inc.
2    Contributor: Joern Rennecke <joern.rennecke@embecosm.com>
3                 on behalf of Synopsys Inc.
4
5 This file is part of GCC.
6
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
10 version.
11
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
15 for more details.
16
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.
20
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/>.  */
25
26 #include "arc-ieee-754.h"
27
28 #if 0 /* DEBUG */
29         FUNC(__fixdfsi)
30         .global __fixdfsi
31         .balign 4
32 __fixdfsi:
33         push_s blink
34         push_s r0
35         bl.d __fixdfsi_c
36         push_s r1
37         mov_s r2,r0
38         pop_s r1
39         ld r0,[sp]
40         bl.d __fixdfsi_asm
41         st r2,[sp]
42         pop_s r1
43         pop_s blink
44         cmp r0,r1
45         jeq_s [blink]
46         bl abort
47         ENDFUNC(__fixdfsi)
48 #define __fixdfsi __fixdfsi_asm
49 #endif /* DEBUG */
50
51 /*      If the fraction has to be shifted left by a positive non-zero amount,
52         we have to combine bits from DBL0L and DBL0H.  If we shift right,
53         or shift by zero, we only want to have the bits from DBL0H in r0.  */
54
55         .global __fixdfsi
56         FUNC(__fixdfsi)
57         .balign 4
58 __fixdfsi:
59         bbit0 DBL0H,30,.Lret0or1
60         asr r2,DBL0H,20
61         bmsk_s DBL0H,DBL0H,19
62         sub_s r2,r2,19; 0x3ff+20-0x400
63         neg_s r3,r2
64         asr.f 0,r3,11
65         bset_s DBL0H,DBL0H,20
66 #ifdef __LITTLE_ENDIAN__
67         mov.cs DBL0L,DBL0H
68         asl DBL0H,DBL0H,r2
69 #else
70         asl.cc DBL0H,DBL0H,r2
71         lsr.cs DBL0H,DBL0H,r3
72 #endif
73         lsr_s DBL0L,DBL0L,r3
74
75         add.cc r0,r0,r1
76         j_s.d [blink]
77         neg.pl r0,r0
78 .Lret0or1:
79         add.f r0,DBL0H,0x100000
80         lsr_s r0,r0,30
81
82         bmsk_s r0,r0,0
83         j_s.d [blink]
84         neg.mi r0,r0
85         ENDFUNC(__fixdfsi)