From patchwork Mon Dec 27 19:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Engel X-Patchwork-Id: 49317 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 E12BC3858439 for ; Mon, 27 Dec 2021 19:24:47 +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 5DEFF3858015 for ; Mon, 27 Dec 2021 19:12:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DEFF3858015 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 compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 200FB320098D; Mon, 27 Dec 2021 14:12:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 27 Dec 2021 14:12:19 -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=lGWxbnT0rBF/2 /rIyNmH4y/rYWFuDI+tA4o3rYj8uGo=; b=ObIcJnxwSSh65D2MI9rpKhXYD7I65 /zArQr2kcuVaTem3xFzbK2TyejcotHdKrIbDn+Z4N8uVT7DVAW7C8FbHwKxC/npj U8derzzDXPPyXEq4BqYdBYZ/v+vRxqbd13Kt+EfjhLYC7FiiLvuYuHTP/3dQ2YqT VM8ptRmxOKYcL6Fwk26Qr0AuRfT4DxtgO+b/u0lDyQ6BcDZOxE4icK+/B/DtmgJi MldPD8mxHIYgaf6+d8eq7a0PnVANEm/bHvpLBm12XHul3VfM1MidpEwP9NmdshIP uM8NVbhUpYR439mWLvzPlKXUvXgIxgs5f7F7ZCP1amzcop4C/6xAwSaWg== 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=lGWxbnT0rBF/2/rIyNmH4y/rYWFuDI+tA4o3rYj8uGo=; b=QXqPKzlN Bp3PQDhXTnKIzuJleKo2LZxVXiYPk5je+m3th1JwWXDQ2yLTVjx11uyoS4x/jQy0 MPHgwiwWeDAiOd/RgIZPrmgE/S4ZdBFM8lWaFRodCczaxRK+Bj9dHakZtYfu/gv4 DUltjnn7pl4wgRMw+jHaOcRRkQ+KVWzjFkN5cyUztuU7JSQwFCU2wL//cJ+jMOVa +TNrIoMVwpYalUgJOQcN3KuW0k5tFY8QxxBPlf48ArLULEOVn+5ye+dlqTXY8JW+ rzPFxV4CSegN6RHl/uT7yfTGfGppm4AAHtzwB4q2KrDb7J599mbAt3jmmpiSk3I3 i56bSbwI74AyBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddujedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhi vghlucfgnhhgvghluceoghhnuhesuggrnhhivghlvghnghgvlhdrtghomheqnecuggftrf grthhtvghrnhepkeeutdfhleevhfekieekgeehlefgvdfhgeehgefhudektdfhffejtdeg udeuvedtnecuffhomhgrihhnpegtlhiivddrshgspdgtthiivddrshgspdhlihgsudhfuh hntghsrdhssgdpphhophgtnhhtrdhssgdpghhnuhdrohhrghenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgnhhusegurghnihgvlhgvnhhgvg hlrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Dec 2021 14:12:18 -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 1BRJCGrN061109; Mon, 27 Dec 2021 11:12:16 -0800 (PST) (envelope-from gnu@danielengel.com) From: Daniel Engel To: Richard Earnshaw , gcc-patches@gcc.gnu.org Subject: [PATCH v6 34/34] Add -mpure-code support to the CM0 functions. Date: Mon, 27 Dec 2021 11:05:30 -0800 Message-Id: <20211227190530.3136549-35-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=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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" gcc/libgcc/ChangeLog: 2021-01-16 Daniel Engel Makefile.in (MPURE_CODE): New macro defines __PURE_CODE__. (gcc_compile): Appended MPURE_CODE. lib1funcs.S (FUNC_START_SECTION): Set flags for __PURE_CODE__. clz2.S (__clzsi2): Added -mpure-code compatible instructions. ctz2.S (__ctzsi2): Same. popcnt.S (__popcountsi2, __popcountdi2): Same. --- libgcc/Makefile.in | 5 ++++- libgcc/config/arm/clz2.S | 25 ++++++++++++++++++++++- libgcc/config/arm/ctz2.S | 38 +++++++++++++++++++++++++++++++++-- libgcc/config/arm/lib1funcs.S | 7 ++++++- libgcc/config/arm/popcnt.S | 33 +++++++++++++++++++++++++----- 5 files changed, 98 insertions(+), 10 deletions(-) diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 32e329f7764..e6b2ce5c6d7 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -307,6 +307,9 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ # Extra flags to use when compiling crt{begin,end}.o. CRTSTUFF_T_CFLAGS = +# Pass the -mpure-code flag into assembly for conditional compilation. +MPURE_CODE = $(if $(findstring -mpure-code,$(CFLAGS)), -D__PURE_CODE__) + MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory) MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory) @@ -316,7 +319,7 @@ inst_slibdir = $(slibdir)$(MULTIOSSUBDIR) gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) $(CFLAGS-$(. */ +#if defined(L_popcountdi2) || defined(L_popcountsi2) + +.macro ldmask reg, temp, value + #if defined(__PURE_CODE__) && (__PURE_CODE__) + #ifdef NOT_ISA_TARGET_32BIT + movs \reg, \value + lsls \temp, \reg, #8 + orrs \reg, \temp + lsls \temp, \reg, #16 + orrs \reg, \temp + #else + // Assumption: __PURE_CODE__ only support M-profile. + movw \reg ((\value) * 0x101) + movt \reg ((\value) * 0x101) + #endif + #else + ldr \reg, =((\value) * 0x1010101) + #endif +.endm + +#endif + + #ifdef L_popcountdi2 // int __popcountdi2(int) @@ -49,7 +72,7 @@ FUNC_START_SECTION popcountdi2 .text.sorted.libgcc.popcountdi2 #else /* !__OPTIMIZE_SIZE__ */ // Load the one-bit alternating mask. - ldr r3, =0x55555555 + ldmask r3, r2, 0x55 // Reduce the second word. lsrs r2, r1, #1 @@ -62,7 +85,7 @@ FUNC_START_SECTION popcountdi2 .text.sorted.libgcc.popcountdi2 subs r0, r2 // Load the two-bit alternating mask. - ldr r3, =0x33333333 + ldmask r3, r2, 0x33 // Reduce the second word. lsrs r2, r1, #2 @@ -140,7 +163,7 @@ FUNC_ENTRY popcountsi2 #else /* !__OPTIMIZE_SIZE__ */ // Load the one-bit alternating mask. - ldr r3, =0x55555555 + ldmask r3, r2, 0x55 // Reduce the word. lsrs r1, r0, #1 @@ -148,7 +171,7 @@ FUNC_ENTRY popcountsi2 subs r0, r1 // Load the two-bit alternating mask. - ldr r3, =0x33333333 + ldmask r3, r2, 0x33 // Reduce the word. lsrs r1, r0, #2 @@ -158,7 +181,7 @@ FUNC_ENTRY popcountsi2 adds r0, r1 // Load the four-bit alternating mask. - ldr r3, =0x0F0F0F0F + ldmask r3, r2, 0x0F // Reduce the word. lsrs r1, r0, #4