[compiler-rt] r310884 - [builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
Evgenii Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 14:02:29 PDT 2017
Hi, you broke x86:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/12323
On Mon, Aug 14, 2017 at 1:48 PM, Weiming Zhao via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: weimingz
> Date: Mon Aug 14 13:48:47 2017
> New Revision: 310884
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310884&view=rev
> Log:
> [builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
>
> Summary:
> Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
> mode (-mthumb, -marm), it reflect's capability of given CPU.
>
> Due to this:
> •use tbumb and thumb2 insteand of __ARM_ARCH_ISA_THUMB
> •use '.thumb' directive consistently in all affected files
> •decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION()
>
> (This is based off Michal's patch https://reviews.llvm.org/D30938)
>
> Reviewers: dim, rengolin, compnerd, strejda
>
> Reviewed By: compnerd
>
> Subscribers: peter.smith, kubamracek, mgorny, javed.absar, kristof.beyls, jamesduley, aemerson, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D31220
>
> Modified:
> compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S
> compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S
> compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
> compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S
> compiler-rt/trunk/lib/builtins/arm/bswapdi2.S
> compiler-rt/trunk/lib/builtins/arm/bswapsi2.S
> compiler-rt/trunk/lib/builtins/arm/clzdi2.S
> compiler-rt/trunk/lib/builtins/arm/clzsi2.S
> compiler-rt/trunk/lib/builtins/arm/comparesf2.S
> compiler-rt/trunk/lib/builtins/arm/divmodsi4.S
> compiler-rt/trunk/lib/builtins/arm/divsi3.S
> compiler-rt/trunk/lib/builtins/arm/modsi3.S
> compiler-rt/trunk/lib/builtins/arm/udivmodsi4.S
> compiler-rt/trunk/lib/builtins/arm/udivsi3.S
> compiler-rt/trunk/lib/builtins/arm/umodsi3.S
> compiler-rt/trunk/lib/builtins/assembly.h
>
> Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S Mon Aug 14 13:48:47 2017
> @@ -30,7 +30,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmp
> push {r0-r3, lr}
> bl __aeabi_cdcmpeq_check_nan
> cmp r0, #1
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> beq 1f
> // NaN has been ruled out, so __aeabi_cdcmple can't trap
> mov r0, sp
> @@ -78,7 +78,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmp
>
> bl __aeabi_dcmplt
> cmp r0, #1
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bne 1f
> // Z = 0, C = 0
> movs r0, #1
>
> Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S Mon Aug 14 13:48:47 2017
> @@ -30,7 +30,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmp
> push {r0-r3, lr}
> bl __aeabi_cfcmpeq_check_nan
> cmp r0, #1
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> beq 1f
> // NaN has been ruled out, so __aeabi_cfcmple can't trap
> mov r0, sp
> @@ -78,7 +78,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmp
>
> bl __aeabi_fcmplt
> cmp r0, #1
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bne 1f
> // Z = 0, C = 0
> movs r0, #1
>
> Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S Mon Aug 14 13:48:47 2017
> @@ -20,16 +20,18 @@
> #endif
>
> .syntax unified
> + .text
> + DEFINE_CODE_STATE
> .p2align 2
> DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> push {r0, r1, lr}
> bl SYMBOL_NAME(__divsi3)
> pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
> muls r2, r0, r2 // r2 = quot * denom
> subs r1, r1, r2
> JMP (r3)
> -#else
> +#else // defined(USE_THUMB_1)
> push { lr }
> sub sp, sp, #4
> mov r2, sp
> @@ -42,7 +44,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_idivm
> ldr r1, [sp]
> add sp, sp, #4
> pop { pc }
> -#endif // __ARM_ARCH_ISA_THUMB == 1
> +#endif // defined(USE_THUMB_1)
> END_COMPILERRT_FUNCTION(__aeabi_idivmod)
>
> NO_EXEC_STACK_DIRECTIVE
>
> Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S Mon Aug 14 13:48:47 2017
> @@ -21,9 +21,11 @@
> #endif
>
> .syntax unified
> + .text
> + DEFINE_CODE_STATE
> .p2align 2
> DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> cmp r0, r1
> bcc LOCAL_LABEL(case_denom_larger)
> push {r0, r1, lr}
> @@ -36,7 +38,7 @@ LOCAL_LABEL(case_denom_larger):
> movs r1, r0
> movs r0, #0
> JMP (lr)
> -#else
> +#else // defined(USE_THUMB_1)
> push { lr }
> sub sp, sp, #4
> mov r2, sp
>
> Modified: compiler-rt/trunk/lib/builtins/arm/bswapdi2.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/bswapdi2.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/bswapdi2.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/bswapdi2.S Mon Aug 14 13:48:47 2017
> @@ -11,9 +11,7 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> //
> // extern uint64_t __bswapdi2(uint64_t);
> @@ -21,11 +19,7 @@
> // 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)
>
> Modified: compiler-rt/trunk/lib/builtins/arm/bswapsi2.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/bswapsi2.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/bswapsi2.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/bswapsi2.S Mon Aug 14 13:48:47 2017
> @@ -11,9 +11,7 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> //
> // extern uint32_t __bswapsi2(uint32_t);
> @@ -21,11 +19,7 @@
> // 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
>
> Modified: compiler-rt/trunk/lib/builtins/arm/clzdi2.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/clzdi2.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/clzdi2.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/clzdi2.S Mon Aug 14 13:48:47 2017
> @@ -15,17 +15,10 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> -
> + DEFINE_CODE_STATE
>
> .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
>
> Modified: compiler-rt/trunk/lib/builtins/arm/clzsi2.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/clzsi2.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/clzsi2.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/clzsi2.S Mon Aug 14 13:48:47 2017
> @@ -15,16 +15,10 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> .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)
>
> Modified: compiler-rt/trunk/lib/builtins/arm/comparesf2.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/comparesf2.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/comparesf2.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/comparesf2.S Mon Aug 14 13:48:47 2017
> @@ -38,10 +38,9 @@
> //===----------------------------------------------------------------------===//
>
> #include "../assembly.h"
> -.syntax unified
> -#if __ARM_ARCH_ISA_THUMB == 2
> -.thumb
> -#endif
> + .syntax unified
> + .text
> + DEFINE_CODE_STATE
>
> @ int __eqsf2(float a, float b)
>
> @@ -53,7 +52,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> #endif
> // Make copies of a and b with the sign bit shifted off the top. These will
> // be used to detect zeros and NaNs.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> push {r6, lr}
> lsls r2, r0, #1
> lsls r3, r1, #1
> @@ -67,7 +66,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> // flag if both a and b are zero (of either sign). The shift of r3 doesn't
> // effect this at all, but it *does* make sure that the C flag is clear for
> // the subsequent operations.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> lsrs r6, r3, #1
> orrs r6, r2
> #else
> @@ -75,7 +74,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> #endif
> // Next, we check if a and b have the same or different signs. If they have
> // opposite signs, this eor will set the N flag.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> beq 1f
> movs r6, r0
> eors r6, r1
> @@ -89,7 +88,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> // ignoring NaNs for now), this subtract will zero out r0. If they have the
> // same sign, the flags are updated as they would be for a comparison of the
> // absolute values of a and b.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bmi 1f
> subs r0, r2, r3
> 1:
> @@ -108,7 +107,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> // still clear from the shift argument in orrs; if a is positive and b
> // negative, this places 0 in r0; if a is negative and b positive, -1 is
> // placed in r0.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bhs 1f
> // Here if a and b have the same sign and absA < absB, the result is thus
> // b < 0 ? 1 : -1. Same if a and b have the opposite sign (ignoring Nan).
> @@ -127,7 +126,7 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> // the sign of b in r0. Thus, if both are negative and a < b, -1 is placed
> // in r0, which is the desired result. Conversely, if both are positive
> // and a > b, zero is placed in r0.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bls 1f
> // Here both have the same sign and absA > absB.
> movs r0, #1
> @@ -145,14 +144,14 @@ DEFINE_COMPILERRT_FUNCTION(__eqsf2)
> // If a == b, then the Z flag is set, so we can get the correct final value
> // into r0 by simply or'ing with 1 if Z is clear.
> // For Thumb-1, r0 contains -1 if a < b, 0 if a > b and 0 if a == b.
> -#if __ARM_ARCH_ISA_THUMB != 1
> +#if !defined(USE_THUMB_1)
> it ne
> orrne r0, r0, #1
> #endif
>
> // Finally, we need to deal with NaNs. If either argument is NaN, replace
> // the value in r0 with 1.
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> LOCAL_LABEL(CHECK_NAN):
> movs r6, #0xff
> lsls r6, #24
> @@ -189,7 +188,7 @@ DEFINE_COMPILERRT_FUNCTION(__gtsf2)
> vmov r0, s0
> vmov r1, s1
> #endif
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> push {r6, lr}
> lsls r2, r0, #1
> lsls r3, r1, #1
> @@ -255,6 +254,7 @@ DEFINE_COMPILERRT_FUNCTION_ALIAS(__gesf2
>
> .p2align 2
> DEFINE_COMPILERRT_FUNCTION(__unordsf2)
> +
> #if defined(COMPILER_RT_ARMHF_TARGET)
> vmov r0, s0
> vmov r1, s1
> @@ -263,7 +263,7 @@ DEFINE_COMPILERRT_FUNCTION(__unordsf2)
> lsls r2, r0, #1
> lsls r3, r1, #1
> movs r0, #0
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> movs r1, #0xff
> lsls r1, #24
> cmp r2, r1
>
> Modified: compiler-rt/trunk/lib/builtins/arm/divmodsi4.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/divmodsi4.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/divmodsi4.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/divmodsi4.S Mon Aug 14 13:48:47 2017
> @@ -23,20 +23,14 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> @ int __divmodsi4(int divident, int divisor, int *remainder)
> @ Calculate the quotient and remainder of the (signed) division. The return
> @ 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)
>
> Modified: compiler-rt/trunk/lib/builtins/arm/divsi3.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/divsi3.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/divsi3.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/divsi3.S Mon Aug 14 13:48:47 2017
> @@ -20,11 +20,9 @@
> #define CLEAR_FRAME_AND_RETURN \
> pop {r4, r7, pc}
>
> - .syntax unified
> - .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + .syntax unified
> + .text
> + DEFINE_CODE_STATE
>
> .p2align 3
> // Ok, APCS and AAPCS agree on 32 bit args, so it's safe to use the same routine.
> @@ -33,11 +31,7 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_idiv
> @ 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)
> @@ -49,14 +43,14 @@ LOCAL_LABEL(divzero):
> #else
> ESTABLISH_FRAME
> // Set aside the sign of the quotient.
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_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
> +# if defined(USE_THUMB_1)
> asrs r2, r0, #31
> asrs r3, r1, #31
> eors r0, r2
> @@ -72,7 +66,7 @@ ESTABLISH_FRAME
> // abs(a) / abs(b)
> bl SYMBOL_NAME(__udivsi3)
> // Apply sign of quotient to result and return.
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> asrs r4, #31
> eors r0, r4
> subs r0, r0, r4
>
> Modified: compiler-rt/trunk/lib/builtins/arm/modsi3.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/modsi3.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/modsi3.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/modsi3.S Mon Aug 14 13:48:47 2017
> @@ -22,19 +22,13 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> @ int __modsi3(int divident, int divisor)
> @ 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)
>
> Modified: compiler-rt/trunk/lib/builtins/arm/udivmodsi4.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/udivmodsi4.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/udivmodsi4.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/udivmodsi4.S Mon Aug 14 13:48:47 2017
> @@ -16,10 +16,7 @@
>
> .syntax unified
> .text
> -
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> @ unsigned int __udivmodsi4(unsigned int divident, unsigned int divisor,
> @ unsigned int *remainder)
> @@ -27,11 +24,7 @@
> @ 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)
> @@ -67,7 +60,7 @@ DEFINE_COMPILERRT_FUNCTION(__udivmodsi4)
> clz r3, r1
> /* r0 >= r1 implies clz(r0) <= clz(r1), so ip <= r3. */
> sub r3, r3, ip
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> adr ip, LOCAL_LABEL(div0block) + 1
> sub ip, ip, r3, lsl #1
> # else
> @@ -78,7 +71,7 @@ DEFINE_COMPILERRT_FUNCTION(__udivmodsi4)
> mov r3, #0
> bx ip
> # else
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> # error THUMB mode requires CLZ or UDIV
> # endif
> str r4, [sp, #-8]!
>
> Modified: compiler-rt/trunk/lib/builtins/arm/udivsi3.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/udivsi3.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/udivsi3.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/udivsi3.S Mon Aug 14 13:48:47 2017
> @@ -17,9 +17,7 @@
> .syntax unified
> .text
>
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> +DEFINE_CODE_STATE
>
> .p2align 2
> DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_uidiv, __udivsi3)
> @@ -27,11 +25,7 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_uidi
> @ 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)
> @@ -49,7 +43,7 @@ LOCAL_LABEL(divby0):
> #else /* ! __ARM_ARCH_EXT_IDIV__ */
> cmp r1, #1
> bcc LOCAL_LABEL(divby0)
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bne LOCAL_LABEL(num_neq_denom)
> JMP(lr)
> LOCAL_LABEL(num_neq_denom):
> @@ -58,7 +52,7 @@ LOCAL_LABEL(num_neq_denom):
> JMPc(lr, eq)
> #endif
> cmp r0, r1
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> bhs LOCAL_LABEL(num_ge_denom)
> movs r0, #0
> JMP(lr)
> @@ -90,7 +84,7 @@ LOCAL_LABEL(num_ge_denom):
> clz r3, r1
> /* r0 >= r1 implies clz(r0) <= clz(r1), so ip <= r3. */
> sub r3, r3, ip
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> adr ip, LOCAL_LABEL(div0block) + 1
> sub ip, ip, r3, lsl #1
> # else
> @@ -101,17 +95,17 @@ LOCAL_LABEL(num_ge_denom):
> mov r3, #0
> bx ip
> # else /* No CLZ Feature */
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> # error THUMB mode requires CLZ or UDIV
> # endif
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> # define BLOCK_SIZE 10
> # else
> # define BLOCK_SIZE 12
> # endif
>
> mov r2, r0
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> mov ip, r0
> adr r0, LOCAL_LABEL(div0block)
> adds r0, #1
> @@ -120,7 +114,7 @@ LOCAL_LABEL(num_ge_denom):
> # endif
> lsrs r3, r2, #16
> cmp r3, r1
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> blo LOCAL_LABEL(skip_16)
> movs r2, r3
> subs r0, r0, #(16 * BLOCK_SIZE)
> @@ -132,7 +126,7 @@ LOCAL_LABEL(skip_16):
>
> lsrs r3, r2, #8
> cmp r3, r1
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> blo LOCAL_LABEL(skip_8)
> movs r2, r3
> subs r0, r0, #(8 * BLOCK_SIZE)
> @@ -144,7 +138,7 @@ LOCAL_LABEL(skip_8):
>
> lsrs r3, r2, #4
> cmp r3, r1
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> blo LOCAL_LABEL(skip_4)
> movs r2, r3
> subs r0, r0, #(4 * BLOCK_SIZE)
> @@ -156,7 +150,7 @@ LOCAL_LABEL(skip_4):
>
> lsrs r3, r2, #2
> cmp r3, r1
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> blo LOCAL_LABEL(skip_2)
> movs r2, r3
> subs r0, r0, #(2 * BLOCK_SIZE)
> @@ -167,7 +161,7 @@ LOCAL_LABEL(skip_2):
> # endif
>
> /* Last block, no need to update r2 or r3. */
> -# if __ARM_ARCH_ISA_THUMB == 1
> +# if defined(USE_THUMB_1)
> lsrs r3, r2, #1
> cmp r3, r1
> blo LOCAL_LABEL(skip_1)
> @@ -203,7 +197,7 @@ LOCAL_LABEL(divby0):
> # endif
>
>
> -#if __ARM_ARCH_ISA_THUMB == 1
> +#if defined(USE_THUMB_1)
> #define block(shift) \
> lsls r2, r1, IMM shift; \
> cmp r0, r2; \
>
> Modified: compiler-rt/trunk/lib/builtins/arm/umodsi3.S
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/umodsi3.S?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/arm/umodsi3.S (original)
> +++ compiler-rt/trunk/lib/builtins/arm/umodsi3.S Mon Aug 14 13:48:47 2017
> @@ -16,19 +16,13 @@
>
> .syntax unified
> .text
> -#if __ARM_ARCH_ISA_THUMB == 2
> - .thumb
> -#endif
> + DEFINE_CODE_STATE
>
> @ unsigned int __umodsi3(unsigned int divident, unsigned int divisor)
> @ 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)
> @@ -65,7 +59,7 @@ DEFINE_COMPILERRT_FUNCTION(__umodsi3)
> clz r3, r1
> /* r0 >= r1 implies clz(r0) <= clz(r1), so ip <= r3. */
> sub r3, r3, ip
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> adr ip, LOCAL_LABEL(div0block) + 1
> sub ip, ip, r3, lsl #1
> # else
> @@ -74,7 +68,7 @@ DEFINE_COMPILERRT_FUNCTION(__umodsi3)
> sub ip, ip, r3, lsl #3
> bx ip
> # else
> -# if __ARM_ARCH_ISA_THUMB == 2
> +# if defined(USE_THUMB_2)
> # error THUMB mode requires CLZ or UDIV
> # endif
> mov r2, r0
>
> Modified: compiler-rt/trunk/lib/builtins/assembly.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/assembly.h?rev=310884&r1=310883&r2=310884&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/assembly.h (original)
> +++ compiler-rt/trunk/lib/builtins/assembly.h Mon Aug 14 13:48:47 2017
> @@ -68,10 +68,42 @@
> #endif
>
> #if defined(__arm__)
> +
> +/*
> + * Determine actual [ARM][THUMB[1][2]] ISA using compiler predefined macros:
> + * - for '-mthumb -march=armv6' compiler defines '__thumb__'
> + * - for '-mthumb -march=armv7' compiler defines '__thumb__' and '__thumb2__'
> + */
> +#if defined(__thumb2__) || defined(__thumb__)
> +#define DEFINE_CODE_STATE .thumb
> +#define DECLARE_FUNC_ENCODING .thumb_func SEPARATOR
> +#if defined(__thumb2__)
> +#define USE_THUMB_2
> +#define IT(cond) it cond
> +#define ITT(cond) itt cond
> +#define ITE(cond) ite cond
> +#else
> +#define USE_THUMB_1
> +#define IT(cond)
> +#define ITT(cond)
> +#define ITE(cond)
> +#endif // defined(__thumb__2)
> +#else // !defined(__thumb2__) && !defined(__thumb__)
> +#define DEFINE_CODE_STATE .arm
> +#define DECLARE_FUNC_ENCODING
> +#define IT(cond)
> +#define ITT(cond)
> +#define ITE(cond)
> +#endif
> +
> +#if defined(USE_THUMB_1) && defined(USE_THUMB_2)
> +#error "USE_THUMB_1 and USE_THUMB_2 can't be defined together."
> +#endif
> +
> #if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5
> #define ARM_HAS_BX
> #endif
> -#if !defined(__ARM_FEATURE_CLZ) && __ARM_ARCH_ISA_THUMB != 1 && \
> +#if !defined(__ARM_FEATURE_CLZ) && !defined(USE_THUMB_1) && \
> (__ARM_ARCH >= 6 || (__ARM_ARCH == 5 && !defined(__ARM_ARCH_5__)))
> #define __ARM_FEATURE_CLZ
> #endif
> @@ -93,17 +125,7 @@
> JMP(ip)
> #endif
>
> -#if __ARM_ARCH_ISA_THUMB == 2
> -#define IT(cond) it cond
> -#define ITT(cond) itt cond
> -#define ITE(cond) ite cond
> -#else
> -#define IT(cond)
> -#define ITT(cond)
> -#define ITE(cond)
> -#endif
> -
> -#if __ARM_ARCH_ISA_THUMB == 2
> +#if defined(USE_THUMB_2)
> #define WIDE(op) op.w
> #else
> #define WIDE(op) op
> @@ -126,6 +148,7 @@
> .globl SYMBOL_NAME(name) SEPARATOR \
> SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
> DECLARE_SYMBOL_VISIBILITY(name) \
> + DECLARE_FUNC_ENCODING \
> SYMBOL_NAME(name):
>
> #define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \
> @@ -141,12 +164,14 @@
> .globl SYMBOL_NAME(name) SEPARATOR \
> SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
> HIDDEN(SYMBOL_NAME(name)) SEPARATOR \
> + DECLARE_FUNC_ENCODING \
> SYMBOL_NAME(name):
>
> #define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
> .globl name SEPARATOR \
> SYMBOL_IS_FUNC(name) SEPARATOR \
> HIDDEN(name) SEPARATOR \
> + DECLARE_FUNC_ENCODING \
> name:
>
> #define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list