[PATCH] D27472: [builtin] Add Thumb1 implementation for idivsi3 and aeabi_idivmod

Weiming Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 11:47:18 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL288960: [builtin] Add Thumb1 implementation for idivsi3 and aeabi_idivmod (authored by weimingz).

Changed prior to commit:
  https://reviews.llvm.org/D27472?vs=80629&id=80634#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27472

Files:
  compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
  compiler-rt/trunk/lib/builtins/arm/divsi3.S


Index: compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
===================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
@@ -22,6 +22,14 @@
         .syntax unified
         .p2align 2
 DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
+#if __ARM_ARCH_ISA_THUMB == 1
+        push    {r0, r1, lr}
+        bl      SYMBOL_NAME(__divsi3)
+        pop     {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
+        muls    r2, r2, r0   // r2 = quot * denom
+        subs    r1, r1, r2
+        JMP     (r3)
+#else
         push    { lr }
         sub     sp, sp, #4
         mov     r2, sp
@@ -34,6 +42,7 @@
         ldr     r1, [sp]
         add     sp, sp, #4
         pop     { pc }
+#endif // __ARM_ARCH_ISA_THUMB == 1
 END_COMPILERRT_FUNCTION(__aeabi_idivmod)
 
 NO_EXEC_STACK_DIRECTIVE
Index: compiler-rt/trunk/lib/builtins/arm/divsi3.S
===================================================================
--- compiler-rt/trunk/lib/builtins/arm/divsi3.S
+++ compiler-rt/trunk/lib/builtins/arm/divsi3.S
@@ -49,17 +49,37 @@
 #else
 ESTABLISH_FRAME
 //  Set aside the sign of the quotient.
+#  if __ARM_ARCH_ISA_THUMB == 1
+    movs    r4,     r0
+    eors    r4,     r1
+#  else
     eor     r4,     r0, r1
+#  endif
 //  Take absolute value of a and b via abs(x) = (x^(x >> 31)) - (x >> 31).
+#  if   __ARM_ARCH_ISA_THUMB == 1
+    asrs    r2,     r0, #31
+    asrs    r3,     r1, #31
+    eors    r0,     r2
+    eors    r1,     r3
+    subs    r0,     r0, r2
+    subs    r1,     r1, r3
+#  else
     eor     r2,     r0, r0, asr #31
     eor     r3,     r1, r1, asr #31
     sub     r0,     r2, r0, asr #31
     sub     r1,     r3, r1, asr #31
+#  endif
 //  abs(a) / abs(b)
     bl      SYMBOL_NAME(__udivsi3)
 //  Apply sign of quotient to result and return.
+#  if __ARM_ARCH_ISA_THUMB == 1
+    asrs    r4,     #31
+    eors    r0,     r4
+    subs    r0,     r0, r4
+#  else
     eor     r0,     r0, r4, asr #31
     sub     r0,     r0, r4, asr #31
+#  endif
     CLEAR_FRAME_AND_RETURN
 #endif
 END_COMPILERRT_FUNCTION(__divsi3)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27472.80634.patch
Type: text/x-patch
Size: 2149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/7f75432c/attachment.bin>


More information about the llvm-commits mailing list