1 /* Miscellaneous BPABI functions.
3 Copyright (C) 2003-2014 Free Software Foundation, Inc.
4 Contributed by CodeSourcery, LLC.
6 This file is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 This file is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 .cfi_sections .debug_frame
28 /* Some attributes that are common to all routines in this file. */
29 /* Tag_ABI_align_needed: This code does not require 8-byte
30 alignment from the caller. */
31 /* .eabi_attribute 24, 0 -- default setting. */
32 /* Tag_ABI_align_preserved: This code preserves 8-byte
33 alignment in any callee. */
35 #endif /* __ARM_EABI__ */
39 ARM_FUNC_START aeabi_lcmp
55 #endif /* L_aeabi_lcmp */
59 ARM_FUNC_START aeabi_ulcmp
77 #endif /* L_aeabi_ulcmp */
79 .macro test_div_by_zero signed
80 /* Tail-call to divide-by-zero handlers which may be overridden by the user,
81 so unwinding works properly. */
82 #if defined(__thumb2__)
88 .ifc \signed, unsigned
96 movlt xxh, #0x80000000
98 movgt xxh, #0x7fffffff
99 movgt xxl, #0xffffffff
101 b SYM (__aeabi_ldiv0) __PLT__
104 /* Note: Thumb-1 code calls via an ARM shim on processors which
111 .ifc \signed, unsigned
112 movne xxh, #0xffffffff
113 movne xxl, #0xffffffff
115 movlt xxh, #0x80000000
117 movgt xxh, #0x7fffffff
118 movgt xxl, #0xffffffff
120 b SYM (__aeabi_ldiv0) __PLT__
125 /* we can use STRD/LDRD on v5TE and later, and any Thumb-2 architecture. */
126 #if (defined(__ARM_EABI__) \
127 && (defined(__thumb2__) \
128 || (__ARM_ARCH >= 5 && defined(__TARGET_FEATURE_DSP))))
129 #define CAN_USE_LDRD 1
131 #define CAN_USE_LDRD 0
134 /* set up stack from for call to __udivmoddi4. At the end of the macro the
135 stack is arranged as follows:
136 sp+12 / space for remainder
137 sp+8 \ (written by __udivmoddi4)
139 sp+0 sp+8 [rp (remainder pointer) argument for __udivmoddi4]
142 .macro push_for_divide fname
143 #if defined(__thumb2__) && CAN_USE_LDRD
145 strd ip, lr, [sp, #-16]!
150 .cfi_adjust_cfa_offset 16
155 .macro pop_for_divide
158 ldrd r2, r3, [sp, #8]
165 .cfi_adjust_cfa_offset 0
168 #ifdef L_aeabi_ldivmod
170 /* Perform 64 bit signed division.
178 ARM_FUNC_START aeabi_ldivmod
180 test_div_by_zero signed
182 push_for_divide __aeabi_ldivmod
187 /* arguments in (r0:r1), (r2:r3) and *sp */
188 bl SYM(__udivmoddi4) __PLT__
193 1: /* xxh:xxl is negative */
196 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
199 /* arguments in (r0:r1), (r2:r3) and *sp */
200 bl SYM(__udivmoddi4) __PLT__
204 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
206 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
209 2: /* only yyh:yyl is negative */
212 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
213 /* arguments in (r0:r1), (r2:r3) and *sp */
214 bl SYM(__udivmoddi4) __PLT__
218 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
221 3: /* both xxh:xxl and yyh:yyl are negative */
224 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
225 /* arguments in (r0:r1), (r2:r3) and *sp */
226 bl SYM(__udivmoddi4) __PLT__
229 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
234 #endif /* L_aeabi_ldivmod */
236 #ifdef L_aeabi_uldivmod
238 /* Perform 64 bit signed division.
246 ARM_FUNC_START aeabi_uldivmod
248 test_div_by_zero unsigned
250 push_for_divide __aeabi_uldivmod
251 /* arguments in (r0:r1), (r2:r3) and *sp */
252 bl SYM(__udivmoddi4) __PLT__
257 #endif /* L_aeabi_divmod */