1/* Copyright (C) 2008-2018 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 __fixsfsi
30	FUNC(__fixsfsi)
31	.balign 4
32__fixsfsi:
33	push_s blink
34	bl.d __fixsfsi_c
35	push_s r0
36	ld_s r1,[sp]
37	st_s r0,[sp]
38	bl.d __fixsfsi_asm
39	mov_s r0,r1
40	pop_s r1
41	pop_s blink
42	cmp r0,r1
43	jeq_s [blink]
44	bl abort
45	ENDFUNC(__fixsfsi)
46#define __fixsfsi __fixsfsi_asm
47#endif /* DEBUG */
48
49	.global __fixsfsi
50	FUNC(__fixsfsi)
51	.balign 4
52__fixsfsi:
53	bbit0 r0,30,.Lret0or1
54	lsr r2,r0,23
55	bmsk_s r0,r0,22
56	bset_s r0,r0,23
57	sub_s r2,r2,22;0x7f+23-0x80
58	asl.f 0,r2,24
59	neg r3,r2
60	asl.mi r0,r0,r2
61	lsr.pl r0,r0,r3
62	j_s.d [blink]
63	neg.cs r0,r0
64.Lret0or1:
65	add.f r0,r0,0x800000
66	lsr_s r0,r0,30
67
68	bmsk_s r0,r0,0
69	j_s.d [blink]
70	neg.mi r0,r0
71	ENDFUNC(__fixsfsi)
72