diff mbox

[AVR,longlong.h] : Implement __clrsbhi2.

Message ID 4E0C76CB.3050201@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay June 30, 2011, 1:14 p.m. UTC
The new count leading signs is not implemented for HI:

builtin-bitops-1.c:(.text+0xd1e): undefined reference to `__clrsbhi2'
FAIL: gcc.c-torture/execute/builtin-bitops-1.c compilation,  -O0

Extended clz/ctz support in longlong.h

With the patch testcase passes.

Johann

libgcc/
	* config/avr/t-avr (intfuncs16): Add _clrsbXX2.

gcc/
	* longlong.h (count_leading_zeros, count_trailing_zeros,
	COUNT_LEADING_ZEROS_0): Define for target avr if W_TYPE_SIZE is 16
	resp. 64.

Comments

Denis Chertykov June 30, 2011, 6:08 p.m. UTC | #1
2011/6/30 Georg-Johann Lay <avr@gjlay.de>:
> The new count leading signs is not implemented for HI:
>
> builtin-bitops-1.c:(.text+0xd1e): undefined reference to `__clrsbhi2'
> FAIL: gcc.c-torture/execute/builtin-bitops-1.c compilation,  -O0
>
> Extended clz/ctz support in longlong.h
>
> With the patch testcase passes.
>
> Johann
>
> libgcc/
>        * config/avr/t-avr (intfuncs16): Add _clrsbXX2.
>
> gcc/
>        * longlong.h (count_leading_zeros, count_trailing_zeros,
>        COUNT_LEADING_ZEROS_0): Define for target avr if W_TYPE_SIZE is 16
>        resp. 64.

Approved.

Denis.
diff mbox

Patch

Index: libgcc/config/avr/t-avr
===================================================================
--- libgcc/config/avr/t-avr	(revision 175628)
+++ libgcc/config/avr/t-avr	(working copy)
@@ -1,5 +1,5 @@ 
 # Extra 16-bit integer functions.
-intfuncs16 = _absvXX2 _addvXX3 _subvXX3 _mulvXX3 _negvXX2 
+intfuncs16 = _absvXX2 _addvXX3 _subvXX3 _mulvXX3 _negvXX2 _clrsbXX2
 
 hiintfuncs16 = $(subst XX,hi,$(intfuncs16))
 siintfuncs16 = $(subst XX,si,$(intfuncs16))
Index: gcc/longlong.h
===================================================================
--- gcc/longlong.h	(revision 175628)
+++ gcc/longlong.h	(working copy)
@@ -250,11 +250,27 @@  UDItype __umulsidi3 (USItype, USItype);
 #define COUNT_LEADING_ZEROS_0 32
 #endif
 
-#if defined (__AVR__) && W_TYPE_SIZE == 32
+#if defined (__AVR__)
+
+#if W_TYPE_SIZE == 16
+#define count_leading_zeros(COUNT,X)  ((COUNT) = __builtin_clz (X))
+#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X))
+#define COUNT_LEADING_ZEROS_0 16
+#endif /* W_TYPE_SIZE == 16 */
+
+#if W_TYPE_SIZE == 32
 #define count_leading_zeros(COUNT,X)  ((COUNT) = __builtin_clzl (X))
 #define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
 #define COUNT_LEADING_ZEROS_0 32
-#endif /* defined (__AVR__) && W_TYPE_SIZE == 32 */
+#endif /* W_TYPE_SIZE == 32 */
+
+#if W_TYPE_SIZE == 64
+#define count_leading_zeros(COUNT,X)  ((COUNT) = __builtin_clzll (X))
+#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzll (X))
+#define COUNT_LEADING_ZEROS_0 64
+#endif /* W_TYPE_SIZE == 64 */
+
+#endif /* defined (__AVR__) */
 
 #if defined (__CRIS__) && __CRIS_arch_version >= 3
 #define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))