From patchwork Mon Jun 27 16:51:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 641152 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rdZjG2BYZz9sDC for ; Tue, 28 Jun 2016 02:52:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KQOOh7VP; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=Bt9OSE/mfunanPG35T3+9u3HYCC82x560ZGe/CjIoBNS7jJtNkpXg 4Mtmj0J45ZmRJtquwnjnNq0M6C2Qk017IInDDE7D8djBNV3d/RjO2x/QogR4bbbH xcYBsVWeISdG0pJ8DwGntTKpE5F0vuh3N1vbklmmtzBET0R89Rb6JA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=9u0VzKsxN/KFEG6/svN6Cr1vjQs=; b=KQOOh7VPUeYEkQHktlmRUml6cmKp B5izGHDVRQbaGJbpnc4/uapagGayqk1kM9tDDOVzqP0to2ME67ROSfrMOJYgnNlY J58Oh88OzMxeyutlBsd4hchHjn3rEozsyMNoiEGqbiUp45kd3WRUjIORd+0Ov/+O yIxg18PeSvJwkbM= Received: (qmail 51852 invoked by alias); 27 Jun 2016 16:51:52 -0000 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 Received: (qmail 51840 invoked by uid 89); 27 Jun 2016 16:51:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:3522, UD:arm.com, states X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Jun 2016 16:51:42 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD3A92F; Mon, 27 Jun 2016 09:52:31 -0700 (PDT) Received: from e108577-lin.localnet (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A6CA3F246; Mon, 27 Jun 2016 09:51:40 -0700 (PDT) From: Thomas Preudhomme To: gcc-patches@gcc.gnu.org Cc: Ramana Radhakrishnan Subject: Re: [PATCH, libgcc/ARM 1/6] Fix Thumb-1 only == ARMv6-M & Thumb-2 only == ARMv7-M assumptions Date: Mon, 27 Jun 2016 17:51:34 +0100 Message-ID: <4707964.lx3ShB1mLb@e108577-lin> User-Agent: KMail/4.13.3 (Linux/3.13.0-85-generic; KDE/4.13.3; x86_64; ; ) In-Reply-To: References: <001301d14d1b$27cc4810$7764d830$@foss.arm.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi Ramana, On Wednesday 01 June 2016 10:00:52 Ramana Radhakrishnan wrote: > > From here down to .... > > > -#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__) > > +#if !__ARM_ARCH_ISA_ARM && __ARM_ARCH_ISA_THUMB == 1 > > > > FUNC_START clzsi2 > > > > mov r1, #28 > > mov r3, #1 > > > > @@ -1544,7 +1538,7 @@ FUNC_START clzsi2 > > > > FUNC_END clzsi2 > > > > #else > > ARM_FUNC_START clzsi2 > > > > -# if defined(HAVE_ARM_CLZ) > > +# if defined(__ARM_FEATURE_CLZ) > > > > clz r0, r0 > > RET > > > > # else > > > > @@ -1568,15 +1562,15 @@ ARM_FUNC_START clzsi2 > > > > .align 2 > > 1: > > .byte 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 > > > > -# endif /* !HAVE_ARM_CLZ */ > > +# endif /* !__ARM_FEATURE_CLZ */ > > > > FUNC_END clzsi2 > > > > #endif > > #endif /* L_clzsi2 */ > > > > #ifdef L_clzdi2 > > > > -#if !defined(HAVE_ARM_CLZ) > > +#if !defined(__ARM_FEATURE_CLZ) > > here should be it's own little patchlet and can go in separately. The patch in attachment changes the CLZ availability check in libgcc to test ISA supported and architecture version rather than encode a specific list of architectures. __ARM_FEATURE_CLZ is not used because its value depends on what mode the user is targeting but only the architecture support matters in this case. Indeed, the code using CLZ is written in assembler and uses mnemonics available both in ARM and Thumb mode so only CLZ availability in one of the mode matters. This change was split out from [PATCH, GCC, ARM 1/7] Fix Thumb-1 only == ARMv6-M & Thumb-2 only == ARMv7-M assumptions. ChangeLog entry is as follows: *** libgcc/ChangeLog *** 2016-06-16 Thomas Preud'homme * config/arm/lib1funcs.S (HAVE_ARM_CLZ): Define for ARMv6* or later and ARMv5t* rather than for a fixed list of architectures. Looking for code generation change accross a number of combinations of ISAs (ARM/Thumb), optimization levels (Os/O2), and architectures (armv4, armv4t, armv5, armv5t, armv5te, armv6, armv6j, armv6k, armv6s-m, armv6kz, armv6t2, armv6z, armv6zk, armv7, armv7-a, armv7e-m, armv7-m, armv7-r, armv7ve, armv8-a, armv8-a+crc, iwmmxt and iwmmxt2) shows that only ARMv5T is impacted (uses CLZ now). This is expected because currently HAVE_ARM_CLZ is not defined for this architecture while the ARMv7-a/ARMv7-R Architecture Reference Manual [1] states that all ARMv5T* architectures have CLZ. ARMv5E should also be impacted (not using CLZ anymore) but testing it is difficult since current binutils does not support ARMv5E. [1] Document ARM DDI0406C in http://infocenter.arm.com Best regards, Thomas diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S index 951dcda1c3bf7f323423a3e2813bdf0501653016..c4f061f8196d243159903cac4eb0291d1bf0b1ad 100644 --- a/libgcc/config/arm/lib1funcs.S +++ b/libgcc/config/arm/lib1funcs.S @@ -1512,9 +1512,10 @@ LSYM(Lover12): #endif /* __symbian__ */ -#if ((__ARM_ARCH__ > 5) && !defined(__ARM_ARCH_6M__)) \ - || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ - || defined(__ARM_ARCH_5TEJ__) +#if (__ARM_ARCH_ISA_THUMB == 2 \ + || (__ARM_ARCH_ISA_ARM \ + && (__ARM_ARCH__ > 5 \ + || (__ARM_ARCH__ == 5 && __ARM_ARCH_ISA_THUMB)))) #define HAVE_ARM_CLZ 1 #endif