1/* Copyright (C) 2008-2021 Free Software Foundation, Inc.
2   Contributor: Joern Rennecke <joern.rennecke@embecosm.com>
3		on behalf of Synopsys Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see 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(__fixunsdfsi)
30	.global __fixunsdfsi
31	.balign 4
32__fixunsdfsi:
33	push_s blink
34	push_s r0
35	bl.d __fixunsdfsi_c
36	push_s r1
37	mov_s r2,r0
38	pop_s r1
39	ld r0,[sp]
40	bl.d __fixunsdfsi_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(__fixunsdfsi)
48#define __fixunsdfsi __fixunsdfsi_asm
49#endif /* DEBUG */
50
51	.global __fixunsdfsi
52	FUNC(__fixunsdfsi)
53	.balign 4
54__fixunsdfsi:
55	bbit0 DBL0H,30,.Lret0or1
56	lsr r2,DBL0H,20
57	bmsk_s DBL0H,DBL0H,19
58	sub_s r2,r2,19; 0x3ff+20-0x400
59	neg_s r3,r2
60	btst_s r3,10
61	bset_s DBL0H,DBL0H,20
62#ifdef __LITTLE_ENDIAN__
63	mov.ne DBL0L,DBL0H
64	asl DBL0H,DBL0H,r2
65#else
66	asl.eq DBL0H,DBL0H,r2
67	lsr.ne DBL0H,DBL0H,r3
68#endif
69	lsr DBL0L,DBL0L,r3
70	j_s.d [blink]
71	add.eq r0,r0,r1
72.Lret0:
73	j_s.d [blink]
74	mov_l r0,0
75.Lret0or1:
76	add_s DBL0H,DBL0H,0x100000
77	lsr_s DBL0H,DBL0H,30
78	j_s.d [blink]
79	bmsk_l r0,DBL0H,0
80	ENDFUNC(__fixunsdfsi)
81