builtins: rework use of DEFINE_COMPILERRT_THUMB_FUNCTION

This is simply to help clarity of the code.  The functions are built as thumb
only if Thumb2 is available (__ARM_ARCH_ISA_THUMB == 2).  Sink the selection
into the location of the definition and make DEFINE_COMPILERRT_THUMB_FUNCTION
always define a thumb function while DEFINE_COMPILERRT_FUNCTION always selects
the default.

Since the .thumb_func directive is always available (at least on Linux, Windows,
and BSD), sinking the macro right into the macro works just as well.

No functional change intended.

llvm-svn: 219182
This commit is contained in:
Saleem Abdulrasool 2014-10-07 02:39:13 +00:00
parent 59cca5dc29
commit 48d4e4dd35
11 changed files with 44 additions and 8 deletions

View File

@ -21,7 +21,11 @@
// Reverse all the bytes in a 64-bit integer.
//
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapdi2)
#else
DEFINE_COMPILERRT_FUNCTION(__bswapdi2)
#endif
#if __ARM_ARCH < 6
// before armv6 does not have "rev" instruction
// r2 = rev(r0)

View File

@ -21,7 +21,11 @@
// Reverse all the bytes in a 32-bit integer.
//
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapsi2)
#else
DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
#endif
#if __ARM_ARCH < 6
// before armv6 does not have "rev" instruction
eor r1, r0, r0, ror #16

View File

@ -21,7 +21,11 @@
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__clzdi2)
#else
DEFINE_COMPILERRT_FUNCTION(__clzdi2)
#endif
#ifdef __ARM_FEATURE_CLZ
#ifdef __ARMEB__
cmp r0, 0

View File

@ -20,7 +20,11 @@
#endif
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__clzsi2)
#else
DEFINE_COMPILERRT_FUNCTION(__clzsi2)
#endif
#ifdef __ARM_FEATURE_CLZ
clz r0, r0
JMP(lr)

View File

@ -32,7 +32,11 @@
@ value is the quotient, the remainder is placed in the variable.
.p2align 3
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__divmodsi4)
#else
DEFINE_COMPILERRT_FUNCTION(__divmodsi4)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1, r1
beq LOCAL_LABEL(divzero)

View File

@ -33,7 +33,11 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_idiv, __divsi3)
@ int __divsi3(int divident, int divisor)
@ Calculate and return the quotient of the (signed) division.
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__divsi3)
#else
DEFINE_COMPILERRT_FUNCTION(__divsi3)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1,r1
beq LOCAL_LABEL(divzero)

View File

@ -30,7 +30,11 @@
@ Calculate and return the remainder of the (signed) division.
.p2align 3
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__modsi3)
#else
DEFINE_COMPILERRT_FUNCTION(__modsi3)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1, r1
beq LOCAL_LABEL(divzero)

View File

@ -27,7 +27,11 @@
@ value is the quotient, the remainder is placed in the variable.
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__udivmodsi4)
#else
DEFINE_COMPILERRT_FUNCTION(__udivmodsi4)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1, r1
beq LOCAL_LABEL(divby0)

View File

@ -27,7 +27,11 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_uidiv, __udivsi3)
@ unsigned int __udivsi3(unsigned int divident, unsigned int divisor)
@ Calculate and return the quotient of the (unsigned) division.
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__udivsi3)
#else
DEFINE_COMPILERRT_FUNCTION(__udivsi3)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1, r1
beq LOCAL_LABEL(divby0)

View File

@ -24,7 +24,11 @@
@ Calculate and return the remainder of the (unsigned) division.
.p2align 2
#if __ARM_ARCH_ISA_THUMB == 2
DEFINE_COMPILERRT_THUMB_FUNCTION(__umodsi3)
#else
DEFINE_COMPILERRT_FUNCTION(__umodsi3)
#endif
#if __ARM_ARCH_EXT_IDIV__
tst r1, r1
beq LOCAL_LABEL(divby0)

View File

@ -28,15 +28,11 @@
// tell linker it can break up file at label boundaries
#define FILE_LEVEL_DIRECTIVE .subsections_via_symbols
#define SYMBOL_IS_FUNC(name)
#if __ARM_ARCH_ISA_THUMB == 2
#define THUMB_FUNC .thumb_func
#endif
#elif defined(__ELF__)
#define HIDDEN(name) .hidden name
#define LOCAL_LABEL(name) .L_##name
#define THUMB_FUNC
#define FILE_LEVEL_DIRECTIVE
#if defined(__arm__)
#define SYMBOL_IS_FUNC(name) .type name,%function
@ -48,13 +44,13 @@
#define HIDDEN_DIRECTIVE(name)
#define LOCAL_LABEL(name) .L ## name
#define FILE_LEVEL_DIRECTIVE
#define SYMBOL_IS_FUNC(name) \
.def name SEPARATOR \
.scl 2 SEPARATOR \
.type 32 SEPARATOR \
.endef
#define THUMB_FUNC
#define FILE_LEVEL_DIRECTIVE
#endif
#if defined(__arm__)
@ -110,9 +106,9 @@
#define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \
FILE_LEVEL_DIRECTIVE SEPARATOR \
.globl SYMBOL_NAME(name) SEPARATOR \
THUMB_FUNC \
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
DECLARE_SYMBOL_VISIBILITY(name) \
DECLARE_SYMBOL_VISIBILITY(name) SEPARATOR \
.thumb_func \
SYMBOL_NAME(name):
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \