1/* Copyright (C) 2008-2016 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	.global __floatsidf
30	.balign 4
31	FUNC(__floatsidf)
32__floatsidf:
33	push_s blink
34	bl.d __floatsidf_c
35	push_s r0
36	ld_s r2,[sp]
37	st_s r1,[sp]
38	push_s r0
39	bl.d __floatsidf_asm
40	mov_s r0,r2
41	pop_s r2
42	pop_s r3
43	pop_s blink
44	cmp r0,r2
45	cmp.eq r1,r3
46	jeq_s [blink]
47	bl abort
48	ENDFUNC(__floatsidf)
49#define __floatsidf __floatsidf_asm
50#endif /* DEBUG */
51
52	.global __floatsidf
53	.balign 4
54	FUNC(__floatsidf)
55__floatsidf:
56	abs.f r1,r0
57	jeq_s [blink]
58	lsr r2,r1
59	mov r12,-0x41d ; -(0x3ff+31-1)
60	norm r2,r2
61	bclr.cs r12,r12,11
62	rsub.f r3,r2,11
63	add_s r12,r2,r12
64	add_s r2,r2,21
65#ifdef __LITTLE_ENDIAN__
66	asl DBL0L,r1,r2
67	lsr_s DBL0H,r1,r3
68#else
69	lsr DBL0H,r1,r3
70	asl_s DBL0L,r1,r2
71#endif
72	asl_s r12,r12,20
73	mov.lo DBL0H,DBL0L
74	sub_s DBL0H,DBL0H,r12
75	j_s.d [blink]
76	mov.ls DBL0L,0
77	ENDFUNC(__floatsidf)
78