From patchwork Thu Jun 30 13:14:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 102758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C8FC6B6F57 for ; Thu, 30 Jun 2011 23:15:45 +1000 (EST) Received: (qmail 12029 invoked by alias); 30 Jun 2011 13:15:43 -0000 Received: (qmail 12020 invoked by uid 22791); 30 Jun 2011 13:15:42 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, SARE_BAYES_5x8, TW_CL, TW_EG X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 13:15:00 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by smtp.strato.de (cohen mo64) (RZmta 26.0) with ESMTPA id t01323n5UBVSOP ; Thu, 30 Jun 2011 15:14:51 +0200 (MEST) Message-ID: <4E0C76CB.3050201@gjlay.de> Date: Thu, 30 Jun 2011 15:14:51 +0200 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Anatoly Sokolov , Denis Chertykov , Eric Weddington Subject: [Patch, AVR, longlong.h]: Implement __clrsbhi2. X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. 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))