]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
bpabi.S (__aeabi_uldivmod): Optimise stack pointer manipulation.
authorCharles Baylis <charles.baylis@linaro.org>
Wed, 18 Jun 2014 15:40:31 +0000 (15:40 +0000)
committerCharles Baylis <cbaylis@gcc.gnu.org>
Wed, 18 Jun 2014 15:40:31 +0000 (15:40 +0000)
2014-06-18  Charles Baylis  <charles.baylis@linaro.org>

* config/arm/bpabi.S (__aeabi_uldivmod): Optimise stack pointer
manipulation.

From-SVN: r211791

gcc/ChangeLog
libgcc/config/arm/bpabi.S

index d68089ffedd7de1dee1e1f5fd1eb1d9bbb462300..bc9c6a97ec43f557d9f2fcb294a458b699e482d4 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-18  Charles Baylis  <charles.baylis@linaro.org>
+
+       * config/arm/bpabi.S (__aeabi_uldivmod): Optimise stack pointer
+       manipulation.
+
 2014-06-18  Charles Baylis  <charles.baylis@linaro.org>
 
        * config/arm/bpabi.S (__aeabi_uldivmod, __aeabi_ldivmod): Add comment
index ae76cd3c788035ce4ff2d5a610ac3fbd93b08ef0..67246b0f095beefda7f06360f1e64fd3ee0caaf9 100644 (file)
@@ -120,6 +120,46 @@ ARM_FUNC_START aeabi_ulcmp
 #endif
 .endm
 
+/* we can use STRD/LDRD on v5TE and later, and any Thumb-2 architecture. */
+#if (defined(__ARM_EABI__)                                            \
+     && (defined(__thumb2__)                                          \
+         || (__ARM_ARCH >= 5 && defined(__TARGET_FEATURE_DSP))))
+#define CAN_USE_LDRD 1
+#else
+#define CAN_USE_LDRD 0
+#endif
+
+/* set up stack from for call to __udivmoddi4. At the end of the macro the
+   stack is arranged as follows:
+               sp+12   / space for remainder
+               sp+8    \ (written by __udivmoddi4)
+               sp+4    lr
+               sp+0    sp+8 [rp (remainder pointer) argument for __udivmoddi4]
+
+ */
+.macro push_for_divide fname
+#if defined(__thumb2__) && CAN_USE_LDRD
+       sub     ip, sp, #8
+       strd    ip, lr, [sp, #-16]!
+#else
+       sub     sp, sp, #8
+       do_push {sp, lr}
+#endif
+98:    cfi_push        98b - \fname, 0xe, -0xc, 0x10
+.endm
+
+/* restore stack */
+.macro pop_for_divide
+       ldr     lr, [sp, #4]
+#if CAN_USE_LDRD
+       ldrd    r2, r3, [sp, #8]
+       add     sp, sp, #16
+#else
+       add     sp, sp, #8
+       do_pop  {r2, r3}
+#endif
+.endm
+
 #ifdef L_aeabi_ldivmod
 
 /* Perform 64 bit signed division.
@@ -165,18 +205,10 @@ ARM_FUNC_START aeabi_uldivmod
        cfi_start       __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
        test_div_by_zero        unsigned
 
-       sub     sp, sp, #8
-#if defined(__thumb2__)
-       mov     ip, sp
-       push    {ip, lr}
-#else
-       do_push {sp, lr}
-#endif
-98:    cfi_push 98b - __aeabi_uldivmod, 0xe, -0xc, 0x10
+       push_for_divide __aeabi_uldivmod
+       /* arguments in (r0:r1), (r2:r3) and *sp */
        bl      SYM(__gnu_uldivmod_helper) __PLT__
-       ldr     lr, [sp, #4]
-       add     sp, sp, #8
-       do_pop  {r2, r3}
+       pop_for_divide
        RET
        cfi_end LSYM(Lend_aeabi_uldivmod)