summaryrefslogtreecommitdiff
path: root/lib/builtins/assembly.h
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-07-20 04:44:21 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-07-20 04:44:21 +0000
commitdc7280602611b4966e86a29795ae04cdbe977252 (patch)
tree8d645637b9ab61523b79337f82dcca652941c0da /lib/builtins/assembly.h
parent9582d07ec52282a2d91b6ecd63b82000921d82db (diff)
ARM: fix division in some cases
For ARM cores that are ARMv6T2+ but not ARMv7ve or ARMv7-r and not an updated ARMv7-a that has the idiv extension (chips with clz but not idiv), an incorrect jump would be calculated due to the preference to thumb instructions over ARM. Rather than computing the target at runtime, use a jumptable instead. This trades a bit of storage for performance. The overhead is 32-bytes for each of the three routines, but avoid the calculation of the offset. Because clz was introduced in ARMv6T2 and idiv in certain versions of ARMv7, the non-clz, non-idiv case implies a target which does not support Thumb-2, and thus we cannot use Thumb on those targets (as it is unlikely that the assembly will assemble). Take the opportunity to refactor the IT block macros into assembly.h rather than redefining them in the TUs where they are used. Existing tests cover the full change already, so no new tests are added. This effectively reverts SVN r213309. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/builtins/assembly.h')
-rw-r--r--lib/builtins/assembly.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h
index d415a5f8d..b09fcd55a 100644
--- a/lib/builtins/assembly.h
+++ b/lib/builtins/assembly.h
@@ -22,6 +22,16 @@
#define SEPARATOR ;
#endif
+#if defined(__arm__)
+#if __ARM_ARCH_ISA_THUMB == 2
+#define IT it
+#define ITT itt
+#else
+#define IT @
+#define ITT @
+#endif
+#endif
+
#if defined(__APPLE__)
#define HIDDEN(name) .private_extern name
#define LOCAL_LABEL(name) L_##name
@@ -86,7 +96,9 @@
#ifdef ARM_HAS_BX
#define JMP(r) bx r
-#define JMPc(r, c) bx##c r
+#define JMPc(r, c) \
+ IT c; \
+ bx##c r
#else
#define JMP(r) mov pc, r
#define JMPc(r, c) mov##c pc, r