summaryrefslogtreecommitdiffstats
path: root/lib/libc/arm/aeabi/aeabi_vfp_double.S
blob: 842412b3377cbda3040aed4bf3c65d1cb47cb956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * Copyright (C) 2013 Andrew Turner
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include <machine/asm.h>
__FBSDID("$FreeBSD$");

#include "aeabi_vfp.h"

.fpu	vfp
.syntax	unified

/* int __aeabi_dcmpeq(double, double) */
AEABI_ENTRY(dcmpeq)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movne    r0, #0
	moveq    r0, #1
	RET
AEABI_END(dcmpeq)

/* int __aeabi_dcmplt(double, double) */
AEABI_ENTRY(dcmplt)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movcs    r0, #0
	movlt    r0, #1
	RET
AEABI_END(dcmplt)

/* int __aeabi_dcmple(double, double) */
AEABI_ENTRY(dcmple)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movhi    r0, #0
	movls    r0, #1
	RET
AEABI_END(dcmple)

/* int __aeabi_dcmpge(double, double) */
AEABI_ENTRY(dcmpge)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movlt    r0, #0
	movge    r0, #1
	RET
AEABI_END(dcmpge)

/* int __aeabi_dcmpgt(double, double) */
AEABI_ENTRY(dcmpgt)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movle    r0, #0
	movgt    r0, #1
	RET
AEABI_END(dcmpgt)

/* int __aeabi_dcmpun(double, double) */
AEABI_ENTRY(dcmpun)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vcmp.f64 d0, d1
	vmrs     APSR_nzcv, fpscr
	movvc    r0, #0
	movvs    r0, #1
	RET
AEABI_END(dcmpun)

/* int __aeabi_d2iz(double) */
AEABI_ENTRY(d2iz)
	LOAD_DREG(d0, r0, r1)
#if 0
	/*
	 * This should be the correct instruction, but binutils incorrectly
	 * encodes it as the version that used FPSCR to determine the rounding.
	 * When binutils is fixed we can use this again.
	 */
	vcvt.s32.f64 s0, d0
#else
	ftosizd s0, d0
#endif
	vmov         r0, s0
	RET
AEABI_END(d2iz)

/* float __aeabi_d2f(double) */
AEABI_ENTRY(d2f)
	LOAD_DREG(d0, r0, r1)
	vcvt.f32.f64 s0, d0
	UNLOAD_SREG(r0, s0)
	RET
AEABI_END(d2f)

/* double __aeabi_i2d(int) */
AEABI_ENTRY(i2d)
	vmov         s0, r0
	vcvt.f64.s32 d0, s0
	UNLOAD_DREG(r0, r1, d0)
	RET
AEABI_END(i2d)

/* double __aeabi_dadd(double, double) */
AEABI_ENTRY(dadd)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vadd.f64 d0, d0, d1
	UNLOAD_DREG(r0, r1, d0)
	RET
AEABI_END(dadd)

/* double __aeabi_ddiv(double, double) */
AEABI_ENTRY(ddiv)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vdiv.f64 d0, d0, d1
	UNLOAD_DREG(r0, r1, d0)
	RET
AEABI_END(ddiv)

/* double __aeabi_dmul(double, double) */
AEABI_ENTRY(dmul)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vmul.f64 d0, d0, d1
	UNLOAD_DREG(r0, r1, d0)
	RET
AEABI_END(dmul)

/* double __aeabi_dsub(double, double) */
AEABI_ENTRY(dsub)
	LOAD_DREG(d0, r0, r1)
	LOAD_DREG(d1, r2, r3)
	vsub.f64 d0, d0, d1
	UNLOAD_DREG(r0, r1, d0)
	RET
AEABI_END(dsub)

OpenPOWER on IntegriCloud