From: Paul Brook Date: Thu, 12 Jun 2008 17:29:47 +0000 (+0000) Subject: longlong.h (__arm__): Define count_leading_zeros. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef0a4b673817ad7e866e00a5078b9410411e1c49;p=gcc.git longlong.h (__arm__): Define count_leading_zeros. 2008-06-12 Paul Brook gcc/ * longlong.h (__arm__): Define count_leading_zeros. * config/arm/lib1funcs.asm (xxh, xxl, yyh, yyl): Define. (clzsi2, clzdi2): New functions. * config/arm/bpabi-v6m.S (xxh, xxl, yyh, yyl): Remove. * config/arm/bpabi.S (xxh, xxl, yyh, yyl): Remove. * config/arm/t-strongarm-elf (LIB1ASMFUNCS): Ditto. * config/arm/t-vxworks (LIB1ASMFUNCS): Ditto. * config/arm/t-pe (LIB1ASMFUNCS): Ditto. * config/arm/t-arm-elf (LIB1ASMFUNCS): Ditto. * config/arm/t-arm-coff (LIB1ASMFUNCS): Ditto. * config/arm/t-linux (LIB1ASMFUNCS): Ditto. * config/arm/t-symbian (LIB1ASMFUNCS): Ditto. * config/arm/t-wince-pe (LIB1ASMFUNCS): Ditto. From-SVN: r136718 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 936c2ffda50..cf53434d579 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2008-06-12 Paul Brook + + * longlong.h (__arm__): Define count_leading_zeros. + * config/arm/lib1funcs.asm (xxh, xxl, yyh, yyl): Define. + (clzsi2, clzdi2): New functions. + * config/arm/bpabi-v6m.S (xxh, xxl, yyh, yyl): Remove. + * config/arm/bpabi.S (xxh, xxl, yyh, yyl): Remove. + * config/arm/t-strongarm-elf (LIB1ASMFUNCS): Ditto. + * config/arm/t-vxworks (LIB1ASMFUNCS): Ditto. + * config/arm/t-pe (LIB1ASMFUNCS): Ditto. + * config/arm/t-arm-elf (LIB1ASMFUNCS): Ditto. + * config/arm/t-arm-coff (LIB1ASMFUNCS): Ditto. + * config/arm/t-linux (LIB1ASMFUNCS): Ditto. + * config/arm/t-symbian (LIB1ASMFUNCS): Ditto. + * config/arm/t-wince-pe (LIB1ASMFUNCS): Ditto. + 2008-06-12 Kazu Hirata * config/m68k/m68k.c (m68k_tune_flags): New. diff --git a/gcc/config/arm/bpabi-v6m.S b/gcc/config/arm/bpabi-v6m.S index fa3b9c41478..3a20227499b 100644 --- a/gcc/config/arm/bpabi-v6m.S +++ b/gcc/config/arm/bpabi-v6m.S @@ -27,18 +27,6 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef __ARMEB__ -#define xxh r0 -#define xxl r1 -#define yyh r2 -#define yyl r3 -#else -#define xxh r1 -#define xxl r0 -#define yyh r3 -#define yyl r2 -#endif - #ifdef L_aeabi_lcmp FUNC_START aeabi_lcmp diff --git a/gcc/config/arm/bpabi.S b/gcc/config/arm/bpabi.S index 1f083465980..82ca140a6bc 100644 --- a/gcc/config/arm/bpabi.S +++ b/gcc/config/arm/bpabi.S @@ -27,18 +27,6 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef __ARMEB__ -#define xxh r0 -#define xxl r1 -#define yyh r2 -#define yyl r3 -#else -#define xxh r1 -#define xxl r0 -#define yyh r3 -#define yyl r2 -#endif - #ifdef L_aeabi_lcmp ARM_FUNC_START aeabi_lcmp diff --git a/gcc/config/arm/lib1funcs.asm b/gcc/config/arm/lib1funcs.asm index 2fc66be80d5..fe315bcb69b 100644 --- a/gcc/config/arm/lib1funcs.asm +++ b/gcc/config/arm/lib1funcs.asm @@ -406,6 +406,18 @@ SYM (__\name): .endm #endif +#ifdef __ARMEB__ +#define xxh r0 +#define xxl r1 +#define yyh r2 +#define yyl r3 +#else +#define xxh r1 +#define xxl r0 +#define yyh r3 +#define yyl r2 +#endif + #ifdef __thumb__ /* Register aliases. */ @@ -1212,6 +1224,120 @@ LSYM(Lover12): #endif /* __symbian__ */ +#if ((__ARM_ARCH__ > 5) && !defined(__ARM_ARCH_6M__)) \ + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) +#define HAVE_ARM_CLZ 1 +#endif + +#ifdef L_clzsi2 +#if defined(__ARM_ARCH_6M__) +FUNC_START clzsi2 + mov r1, #28 + mov r3, #1 + lsl r3, r3, #16 + cmp r0, r3 /* 0x10000 */ + bcc 2f + lsr r0, r0, #16 + sub r1, r1, #16 +2: lsr r3, r3, #8 + cmp r0, r3 /* #0x100 */ + bcc 2f + lsr r0, r0, #8 + sub r1, r1, #8 +2: lsr r3, r3, #4 + cmp r0, r3 /* #0x10 */ + bcc 2f + lsr r0, r0, #4 + sub r1, r1, #4 +2: adr r2, 1f + ldrb r0, [r2, r0] + add r0, r0, r1 + bx lr +.align 2 +1: +.byte 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 + FUNC_END clzsi2 +#else +ARM_FUNC_START clzsi2 +# if defined(HAVE_ARM_CLZ) + clz r0, r0 + RET +# else + mov r1, #28 + cmp r0, #0x10000 + do_it cs, t + movcs r0, r0, lsr #16 + subcs r1, r1, #16 + cmp r0, #0x100 + do_it cs, t + movcs r0, r0, lsr #8 + subcs r1, r1, #8 + cmp r0, #0x10 + do_it cs, t + movcs r0, r0, lsr #4 + subcs r1, r1, #4 + adr r2, 1f + ldrb r0, [r2, r0] + add r0, r0, r1 + bx lr +.align 2 +1: +.byte 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 +# endif /* !HAVE_ARM_CLZ */ + FUNC_END clzsi2 +#endif +#endif /* L_clzsi2 */ + +#ifdef L_clzdi2 +#if !defined(HAVE_ARM_CLZ) + +# if defined(__ARM_ARCH_6M__) +FUNC_START clzdi2 + push {r4, lr} +# else +ARM_FUNC_START clzdi2 + do_push {r4, lr} +# endif + cmp xxh, #0 + bne 1f +# ifdef __ARMEB__ + mov r0, xxl + bl __clzsi2 + add r0, r0, #32 + b 2f +1: + bl __clzsi2 +# else + bl __clzsi2 + add r0, r0, #32 + b 2f +1: + mov r0, xxh + bl __clzsi2 +# endif +2: +# if defined(__ARM_ARCH_6M__) + pop {r4, pc} +# else + RETLDM r4 +# endif + FUNC_END clzdi2 + +#else /* HAVE_ARM_CLZ */ + +ARM_FUNC_START clzdi2 + cmp xxh, #0 + do_it eq, et + clzeq r0, xxl + clzne r0, xxh + addeq r0, r0, #32 + RET + FUNC_END clzdi2 + +#endif +#endif /* L_clzdi2 */ + /* ------------------------------------------------------------------------ */ /* These next two sections are here despite the fact that they contain Thumb assembler because their presence allows interworked code to be linked even diff --git a/gcc/config/arm/t-arm-coff b/gcc/config/arm/t-arm-coff index 763add31dac..4fa1929bb4b 100644 --- a/gcc/config/arm/t-arm-coff +++ b/gcc/config/arm/t-arm-coff @@ -1,5 +1,5 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX clzsi2 _clzdi2 # We want fine grained libraries, so use the new code to build the # floating point emulation libraries. diff --git a/gcc/config/arm/t-arm-elf b/gcc/config/arm/t-arm-elf index 31ba396b433..33462939994 100644 --- a/gcc/config/arm/t-arm-elf +++ b/gcc/config/arm/t-arm-elf @@ -10,7 +10,8 @@ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \ _arm_fixdfsi _arm_fixunsdfsi \ _arm_truncdfsf2 _arm_negsf2 _arm_addsubsf3 _arm_muldivsf3 \ _arm_cmpsf2 _arm_unordsf2 _arm_fixsfsi _arm_fixunssfsi \ - _arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf + _arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \ + _clzsi2 _clzdi2 MULTILIB_OPTIONS = marm/mthumb MULTILIB_DIRNAMES = arm thumb diff --git a/gcc/config/arm/t-linux b/gcc/config/arm/t-linux index 75da2dd29cd..0e5c0b2501b 100644 --- a/gcc/config/arm/t-linux +++ b/gcc/config/arm/t-linux @@ -3,7 +3,7 @@ TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx clzsi2 _clzdi2 # MULTILIB_OPTIONS = mhard-float/msoft-float # MULTILIB_DIRNAMES = hard-float soft-float diff --git a/gcc/config/arm/t-pe b/gcc/config/arm/t-pe index 741e2b85ab7..83c096ced70 100644 --- a/gcc/config/arm/t-pe +++ b/gcc/config/arm/t-pe @@ -1,5 +1,5 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX _clzsi2 _clzdi2 # We want fine grained libraries, so use the new code to build the # floating point emulation libraries. @@ -29,4 +29,4 @@ MULTILIB_DIRNAMES = fpu thumb LIBGCC = stmp-multilib INSTALL_LIBGCC = install-multilib -TARGET_LIBGCC2_CFLAGS = \ No newline at end of file +TARGET_LIBGCC2_CFLAGS = diff --git a/gcc/config/arm/t-strongarm-elf b/gcc/config/arm/t-strongarm-elf index c8193548a76..bc076e88a04 100644 --- a/gcc/config/arm/t-strongarm-elf +++ b/gcc/config/arm/t-strongarm-elf @@ -1,5 +1,5 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _clzsi2 _clzdi2 # We want fine grained libraries, so use the new code to build the # floating point emulation libraries. diff --git a/gcc/config/arm/t-symbian b/gcc/config/arm/t-symbian index db891381828..cadbd2236b3 100644 --- a/gcc/config/arm/t-symbian +++ b/gcc/config/arm/t-symbian @@ -1,4 +1,4 @@ -LIB1ASMFUNCS = _bb_init_func _call_via_rX _interwork_call_via_rX +LIB1ASMFUNCS = _bb_init_func _call_via_rX _interwork_call_via_rX _clzsi2 _clzdi2 # These functions have __aeabi equivalents and will never be called by GCC. # By putting them in LIB1ASMFUNCS, we avoid the standard libgcc2.c code being diff --git a/gcc/config/arm/t-vxworks b/gcc/config/arm/t-vxworks index 978aa5ef2f5..565b33d6ce9 100644 --- a/gcc/config/arm/t-vxworks +++ b/gcc/config/arm/t-vxworks @@ -1,5 +1,5 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX _clzsi2 _clzdi2 # We want fine grained libraries, so use the new code to build the # floating point emulation libraries. diff --git a/gcc/config/arm/t-wince-pe b/gcc/config/arm/t-wince-pe index fca9853e75c..84b8170ecdf 100644 --- a/gcc/config/arm/t-wince-pe +++ b/gcc/config/arm/t-wince-pe @@ -1,5 +1,5 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX _clzsi2 _clzdi2 # We want fine grained libraries, so use the new code to build the # floating point emulation libraries. diff --git a/gcc/longlong.h b/gcc/longlong.h index 38b4c6fb221..45a95c40eb5 100644 --- a/gcc/longlong.h +++ b/gcc/longlong.h @@ -226,6 +226,12 @@ UDItype __umulsidi3 (USItype, USItype); #define UDIV_TIME 100 #endif /* __arm__ */ +#if defined(__arm__) +/* Let gcc decide how best to implement count_leading_zeros. */ +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) +#define COUNT_LEADING_ZEROS_0 32 +#endif + #if defined (__CRIS__) && __CRIS_arch_version >= 3 #define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X)) #if __CRIS_arch_version >= 8