1 /* Miscellaneous BPABI functions.
3 Copyright (C) 2003-2018 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__)
86 .ifc \signed, unsigned
90 movne xxh, #0xffffffff
91 movne xxl, #0xffffffff
95 movlt xxh, #0x80000000
100 movne xxh, #0x7fffffff
101 movne xxl, #0xffffffff
104 b SYM (__aeabi_ldiv0) __PLT__
107 /* Note: Thumb-1 code calls via an ARM shim on processors which
113 .ifc \signed, unsigned
115 movne xxh, #0xffffffff
116 movne xxl, #0xffffffff
118 movlt xxh, #0x80000000
122 movne xxh, #0x7fffffff
123 movne xxl, #0xffffffff
126 b SYM (__aeabi_ldiv0) __PLT__
131 /* we can use STRD/LDRD on v5TE and later, and any Thumb-2 architecture. */
132 #if (defined(__ARM_EABI__) \
133 && (defined(__thumb2__) \
134 || (__ARM_ARCH >= 5 && defined(__TARGET_FEATURE_DSP))))
135 #define CAN_USE_LDRD 1
137 #define CAN_USE_LDRD 0
140 /* set up stack from for call to __udivmoddi4. At the end of the macro the
141 stack is arranged as follows:
142 sp+12 / space for remainder
143 sp+8 \ (written by __udivmoddi4)
145 sp+0 sp+8 [rp (remainder pointer) argument for __udivmoddi4]
148 .macro push_for_divide fname
149 #if defined(__thumb2__) && CAN_USE_LDRD
151 strd ip, lr, [sp, #-16]!
156 .cfi_adjust_cfa_offset 16
161 .macro pop_for_divide
164 ldrd r2, r3, [sp, #8]
171 .cfi_adjust_cfa_offset 0
174 #ifdef L_aeabi_ldivmod
176 /* Perform 64 bit signed division.
184 ARM_FUNC_START aeabi_ldivmod
186 test_div_by_zero signed
188 push_for_divide __aeabi_ldivmod
193 /* arguments in (r0:r1), (r2:r3) and *sp */
194 bl SYM(__udivmoddi4) __PLT__
199 1: /* xxh:xxl is negative */
202 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
205 /* arguments in (r0:r1), (r2:r3) and *sp */
206 bl SYM(__udivmoddi4) __PLT__
210 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
212 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
215 2: /* only yyh:yyl is negative */
218 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
219 /* arguments in (r0:r1), (r2:r3) and *sp */
220 bl SYM(__udivmoddi4) __PLT__
224 sbc xxh, xxh, xxh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
227 3: /* both xxh:xxl and yyh:yyl are negative */
230 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
231 /* arguments in (r0:r1), (r2:r3) and *sp */
232 bl SYM(__udivmoddi4) __PLT__
235 sbc yyh, yyh, yyh, lsl #1 /* Thumb-2 has no RSC, so use X - 2X */
240 #endif /* L_aeabi_ldivmod */
242 #ifdef L_aeabi_uldivmod
244 /* Perform 64 bit signed division.
252 ARM_FUNC_START aeabi_uldivmod
254 test_div_by_zero unsigned
256 push_for_divide __aeabi_uldivmod
257 /* arguments in (r0:r1), (r2:r3) and *sp */
258 bl SYM(__udivmoddi4) __PLT__
263 #endif /* L_aeabi_divmod */