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	.global __floatsisf
30	FUNC(__floatsisf)
31	.balign 4
32__floatsisf:
33	push_s blink
34	bl.d __floatsisf_c
35	push_s r0
36	ld_s r1,[sp]
37	st_s r0,[sp]
38	bl.d __floatsisf_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(__floatsisf)
46	.global __floatunsisf
47	FUNC(__floatunsisf)
48	.balign 4
49__floatunsisf:
50	push_s blink
51	bl.d __floatunsisf_c
52	push_s r0
53	ld_s r1,[sp]
54	st_s r0,[sp]
55	bl.d __floatunsisf_asm
56	mov_s r0,r1
57	pop_s r1
58	pop_s blink
59	cmp r0,r1
60	jeq_s [blink]
61	bl abort
62	ENDFUNC(__floatunsisf)
63#define __floatsisf __floatsisf_asm
64#define __floatunsisf __floatunsisf_asm
65#endif /* DEBUG */
66
67	.global __floatunsisf
68	.global __floatsisf
69	FUNC(__floatsisf)
70	FUNC(__floatunsisf)
71	.balign 4
72__floatunsisf:
73	lsr_s r2,r0
74	mov_l r12,0x9d ; 0x7f + 31 - 1
75	norm r2,r2
76	brne_l r0,0,0f
77	j_s [blink]
78	.balign 4
79__floatsisf:
80	abs.f r0,r0
81	jeq_s [blink]
82	lsr_s r2,r0
83	mov_s r12,0x9d ; 0x7f + 31 - 1
84	norm r2,r2
85	bset.cs r12,r12,8
860:	rsub.f r3,r2,8
87	bmsk r1,r0,r3
88	ror r1,r1,r3
89	lsr.pl r0,r0,r3
90	neg_s r3,r3
91	asl.mi r0,r0,r3
92	sub_s r12,r12,r2
93	asl_s r12,r12,23
94	bxor.pl.f r1,r1,31
95	add_s r0,r0,r12
96	j_s.d [blink]
97	add.pnz r0,r0,1
98	ENDFUNC(__floatunsisf)
99	ENDFUNC(__floatsisf)
100