From patchwork Mon Dec 27 19:05:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Engel X-Patchwork-Id: 49290 X-Patchwork-Delegate: rearnsha@gcc.gnu.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1134385841D for ; Mon, 27 Dec 2021 19:10:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by sourceware.org (Postfix) with ESMTPS id 974E03858436 for ; Mon, 27 Dec 2021 19:07:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 974E03858436 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=danielengel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=danielengel.com Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 55F05320098D; Mon, 27 Dec 2021 14:07:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 27 Dec 2021 14:07:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=danielengel.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=0KhhwKgFOewm0 VJh6lImUMOxWZozsi/bMx5noPDLSyo=; b=amyt1FxMVANv3fYelk6WIQljAg3tI 3DgW/178JP+OraQo80esO/8C3inrg20GnM9w9e9RguPZp73pO0avBUXGGFqelYg+ 2Fr+7ltwsV8BXVmxF9nXhOnIUObwgS39P411j+eRONHEw70rOIsFillk7caoaGNb ppGEf9xPu7AyWOk74GKCy7BC7r7CgnCVge4nyAnR3ZSpuhg7ntsFob9lfcMF5YK3 vkPaewnI3ev3zsrFu9mXgORmyUmOPwyycL98ATsg1e/lQfR0wxNNqvkCZV5UfQ43 oVGZYJ3xPbf/NkVLWJDCE3oc41EnC+iTOPz+OlPzYiye+lfZ5yxMfNg1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=0KhhwKgFOewm0VJh6lImUMOxWZozsi/bMx5noPDLSyo=; b=GdlJ1Yvf 0Y8CFmvNe6bqoDAd6gPEtq930PfjEYzUTe+1nWri+aYBKAQiR77JHR4XFs7kOU1k sLIK4hntEI6PQuUQjCgyBucwfdyGxNkeb+Vzd5bvJflWM7uEvj/zkQ7dP8Z7bETy JdrGzwTgKOHSP1mjUhnGwjmF2IETLsKq3MPJGW0Of8HrH/3fZgDQXPc45pz/0pTj nGUpIEApH/UytuuDH0Ujw3mOWMNkQl9245hQgXkDCD5gyl62VVfWiWoBUhz8I99H 4FtNjTTC6++LlPtVkZ7ehg0pP/RSxnkMReghCkqHzQ4PlarsNMHaNjqe0jSAnW6a OHGnCQSByFh4WQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddujedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhi vghlucfgnhhgvghluceoghhnuhesuggrnhhivghlvghnghgvlhdrtghomheqnecuggftrf grthhtvghrnhepiedugeduueehtdefhffgfedtgeffieejteeileethffggfeuleevgfeg fedvvdegnecuffhomhgrihhnpegtthiivddrshgspdhgnhhurdhorhhgpdhlihgsudhfuh hntghsrdhssgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehgnhhusegurghnihgvlhgvnhhgvghlrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Dec 2021 14:07:22 -0500 (EST) Received: from ubuntu.lorien.danielengel.com (ubuntu.lorien.danielengel.com [10.0.0.96]) by sendmail.lorien.danielengel.com (8.15.2/8.15.2) with ESMTP id 1BRJ7LR5060932; Mon, 27 Dec 2021 11:07:21 -0800 (PST) (envelope-from gnu@danielengel.com) From: Daniel Engel To: Richard Earnshaw , gcc-patches@gcc.gnu.org Subject: [PATCH v6 07/34] Refactor 'ctz' functions into a new file Date: Mon, 27 Dec 2021 11:05:03 -0800 Message-Id: <20211227190530.3136549-8-gnu@danielengel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211227190530.3136549-1-gnu@danielengel.com> References: <20211227190530.3136549-1-gnu@danielengel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SCC_10_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Engel , Christophe Lyon Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This will make it easier to isolate changes in subsequent patches. gcc/libgcc/ChangeLog: 2021-01-13 Daniel Engel * config/arm/lib1funcs.S (__ctzsi2): Moved to ... * config/arm/ctz2.S: New file. --- libgcc/config/arm/ctz2.S | 86 +++++++++++++++++++++++++++++++++++ libgcc/config/arm/lib1funcs.S | 65 +------------------------- 2 files changed, 87 insertions(+), 64 deletions(-) create mode 100644 libgcc/config/arm/ctz2.S diff --git a/libgcc/config/arm/ctz2.S b/libgcc/config/arm/ctz2.S new file mode 100644 index 00000000000..8702c9afb94 --- /dev/null +++ b/libgcc/config/arm/ctz2.S @@ -0,0 +1,86 @@ +/* Copyright (C) 1995-2021 Free Software Foundation, Inc. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This file is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + + +#ifdef L_ctzsi2 +#ifdef NOT_ISA_TARGET_32BIT +FUNC_START ctzsi2 + negs r1, r0 + ands r0, r0, r1 + movs r1, #28 + movs r3, #1 + lsls r3, r3, #16 + cmp r0, r3 /* 0x10000 */ + bcc 2f + lsrs r0, r0, #16 + subs r1, r1, #16 +2: lsrs r3, r3, #8 + cmp r0, r3 /* #0x100 */ + bcc 2f + lsrs r0, r0, #8 + subs r1, r1, #8 +2: lsrs r3, r3, #4 + cmp r0, r3 /* #0x10 */ + bcc 2f + lsrs r0, r0, #4 + subs r1, r1, #4 +2: adr r2, 1f + ldrb r0, [r2, r0] + subs r0, r0, r1 + bx lr +.align 2 +1: +.byte 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31 + FUNC_END ctzsi2 +#else +ARM_FUNC_START ctzsi2 + rsb r1, r0, #0 + and r0, r0, r1 +# if defined (__ARM_FEATURE_CLZ) + clz r0, r0 + rsb r0, r0, #31 + 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] + sub r0, r0, r1 + RET +.align 2 +1: +.byte 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31 +# endif /* !defined (__ARM_FEATURE_CLZ) */ + FUNC_END ctzsi2 +#endif +#endif /* L_clzsi2 */ + diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S index d92f73ba0c9..b1df00ac597 100644 --- a/libgcc/config/arm/lib1funcs.S +++ b/libgcc/config/arm/lib1funcs.S @@ -1804,70 +1804,7 @@ LSYM(Lover12): #endif /* __symbian__ */ #include "clz2.S" - -#ifdef L_ctzsi2 -#ifdef NOT_ISA_TARGET_32BIT -FUNC_START ctzsi2 - negs r1, r0 - ands r0, r0, r1 - movs r1, #28 - movs r3, #1 - lsls r3, r3, #16 - cmp r0, r3 /* 0x10000 */ - bcc 2f - lsrs r0, r0, #16 - subs r1, r1, #16 -2: lsrs r3, r3, #8 - cmp r0, r3 /* #0x100 */ - bcc 2f - lsrs r0, r0, #8 - subs r1, r1, #8 -2: lsrs r3, r3, #4 - cmp r0, r3 /* #0x10 */ - bcc 2f - lsrs r0, r0, #4 - subs r1, r1, #4 -2: adr r2, 1f - ldrb r0, [r2, r0] - subs r0, r0, r1 - bx lr -.align 2 -1: -.byte 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31 - FUNC_END ctzsi2 -#else -ARM_FUNC_START ctzsi2 - rsb r1, r0, #0 - and r0, r0, r1 -# if defined (__ARM_FEATURE_CLZ) - clz r0, r0 - rsb r0, r0, #31 - 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] - sub r0, r0, r1 - RET -.align 2 -1: -.byte 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31 -# endif /* !defined (__ARM_FEATURE_CLZ) */ - FUNC_END ctzsi2 -#endif -#endif /* L_clzsi2 */ +#include "ctz2.S" /* ------------------------------------------------------------------------ */ /* These next two sections are here despite the fact that they contain Thumb