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/>. */
26 /* Some attributes that are common to all routines in this file. */
27 /* Tag_ABI_align_needed: This code does not require 8-byte
28 alignment from the caller. */
29 /* .eabi_attribute 24, 0 -- default setting. */
30 /* Tag_ABI_align_preserved: This code preserves 8-byte
31 alignment in any callee. */
33 #endif /* __ARM_EABI__ */
37 ARM_FUNC_START aeabi_lcmp
53 #endif /* L_aeabi_lcmp */
57 ARM_FUNC_START aeabi_ulcmp
75 #endif /* L_aeabi_ulcmp */
77 .macro test_div_by_zero signed
78 /* Tail-call to divide-by-zero handlers which may be overridden by the user,
79 so unwinding works properly. */
80 #if defined(__thumb2__)
86 .ifc \signed, unsigned
94 movlt xxh, #0x80000000
96 movgt xxh, #0x7fffffff
97 movgt xxl, #0xffffffff
99 b SYM (__aeabi_ldiv0) __PLT__
102 /* Note: Thumb-1 code calls via an ARM shim on processors which
109 .ifc \signed, unsigned
110 movne xxh, #0xffffffff
111 movne xxl, #0xffffffff
113 movlt xxh, #0x80000000
115 movgt xxh, #0x7fffffff
116 movgt xxl, #0xffffffff
118 b SYM (__aeabi_ldiv0) __PLT__
123 /* we can use STRD/LDRD on v5TE and later, and any Thumb-2 architecture. */
124 #if (defined(__ARM_EABI__) \
125 && (defined(__thumb2__) \
126 || (__ARM_ARCH >= 5 && defined(__TARGET_FEATURE_DSP))))
127 #define CAN_USE_LDRD 1
129 #define CAN_USE_LDRD 0
132 /* set up stack from for call to __udivmoddi4. At the end of the macro the
133 stack is arranged as follows:
134 sp+12 / space for remainder
135 sp+8 \ (written by __udivmoddi4)
137 sp+0 sp+8 [rp (remainder pointer) argument for __udivmoddi4]
140 .macro push_for_divide fname
141 #if defined(__thumb2__) && CAN_USE_LDRD
143 strd ip, lr, [sp, #-16]!
148 98: cfi_push 98b - \fname, 0xe, -0xc, 0x10
152 .macro pop_for_divide
155 ldrd r2, r3, [sp, #8]
163 #ifdef L_aeabi_ldivmod
165 /* Perform 64 bit signed division.
173 ARM_FUNC_START aeabi_ldivmod
174 cfi_start __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
175 test_div_by_zero signed
178 #if defined(__thumb2__)
184 98: cfi_push 98b - __aeabi_ldivmod, 0xe, -0xc, 0x10
185 bl SYM(__gnu_ldivmod_helper) __PLT__
190 cfi_end LSYM(Lend_aeabi_ldivmod)
192 #endif /* L_aeabi_ldivmod */
194 #ifdef L_aeabi_uldivmod
196 /* Perform 64 bit signed division.
204 ARM_FUNC_START aeabi_uldivmod
205 cfi_start __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
206 test_div_by_zero unsigned
208 push_for_divide __aeabi_uldivmod
209 /* arguments in (r0:r1), (r2:r3) and *sp */
210 bl SYM(__udivmoddi4) __PLT__
213 cfi_end LSYM(Lend_aeabi_uldivmod)
215 #endif /* L_aeabi_divmod */