ARM: fix division in some cases
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 20 Jul 2014 04:44:21 +0000 (04:44 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 20 Jul 2014 04:44:21 +0000 (04:44 +0000)
commit8817bfe7e265e4a24bcb39e866e82c38a248f663
treeca147825197af6208489e474a912f70f1780c512
parent8eb82fc453f10ff8b99ab31b2e013e7168965fba
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.

llvm-svn: 213467
compiler-rt/lib/builtins/arm/udivmodsi4.S
compiler-rt/lib/builtins/arm/udivsi3.S
compiler-rt/lib/builtins/arm/umodsi3.S
compiler-rt/lib/builtins/assembly.h