From patchwork Mon Nov 6 09:31:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 10042949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2799A6032D for ; Mon, 6 Nov 2017 09:32:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2B928BB5 for ; Mon, 6 Nov 2017 09:32:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE2329B58; Mon, 6 Nov 2017 09:32:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 74849201B1 for ; Mon, 6 Nov 2017 09:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=s1wfu046cJyhZwd+BXQUpFvexJz29oD6iiYlNWO7+qE=; b=eegCJVFGCN7rAc+nz4Pb6tCSY7 cLxa05ZiZviNjorsoGb5u+9nk7JzKdeaBvRms+TvSsMX+lTN+Sm6iSdvMNUjQSP22kuPy9dzvtdme vCMAmUPg5cpaFJy5nwktX8IDqw3/bOfxMHvCCFlj5RN4zNbX20c0BYH9kJx0awLxUWrvtthuJ0wdX sCXuX/HPp90QIJPKzOIQ8kOJ+ArTLxrLVChQ2Y1sYWC2kQa5P1rq8TcdO60nHoeN1nzaihbKKgb9d eQ91070Ud8OUKIgSB/nEgSS6dxCQ7h6hjhyz8Itm4GApm037Fh6tYUnQ4S1b1xquZHObehRp5M5kN RlL9vd5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eBdlm-0001q1-Lo; Mon, 06 Nov 2017 09:32:38 +0000 Received: from frisell.zx2c4.com ([192.95.5.64]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eBdlh-0001WI-Ps for linux-arm-kernel@lists.infradead.org; Mon, 06 Nov 2017 09:32:36 +0000 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 25eeb4a8; Mon, 6 Nov 2017 09:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=mail; bh=n0oQ fue/dgzq+8e9bKySF5Xg47U=; b=SjQICA4QHJejOWwNwtyEKfye8aiF1I+qPy50 zzW0f+ULoZbsliDSFZs9y5X+S3Dro+pIzpn8ux0PJ0bTLQoElMiOsz5eE2rxiTD7 K1lETKPYzhvf3V3lfyehMcWa+5CBhUcjlLHRcXJ4C2JgZZFjCHh1Q4TuuMnmB+F7 GggwdBye5+tmBcs7Clgfqm8Q4JOtOEMeIAET/OXHZochi2924dxwmvo9PomTgR7u 09fEzeHeut6e/+bEb1u6q+ZKXLo37v9s95pCdFtmD2amdUR2Fnq2/S7OzGY/iFak ggzEsGYan8LRzvCqzgpIqavHqIW7cttLOt5hrK8drXATPrXrAg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4bbcf051 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 6 Nov 2017 09:29:03 +0000 (UTC) From: "Jason A. Donenfeld" To: Will Deacon , linux-arm-kernel@lists.infradead.org, LKML , Mark Rutland , wangkefeng.wang@huawei.com, Ard Biesheuvel Subject: [PATCH v4] arm64: support __int128 on gcc 5+ Date: Mon, 6 Nov 2017 10:31:51 +0100 Message-Id: <20171106093151.8312-1-Jason@zx2c4.com> In-Reply-To: <20171103141858.13149-1-Jason@zx2c4.com> References: <20171103141858.13149-1-Jason@zx2c4.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171106_013234_203436_95A700E8 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A. Donenfeld" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Versions of gcc prior to gcc 5 emitted a __multi3 function call when dealing with TI types, resulting in failures when trying to link to libgcc, and more generally, bad performance. However, since gcc 5, the compiler supports actually emitting fast instructions, which means we can at long last enable this option and receive the speedups. The gcc commit that added proper Aarch64 support is: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d1ae7bb994f49316f6f63e6173f2931e837a351d This commit appears to be part of the gcc 5 release. There are still a few instructions, __ashlti3 and __ashrti3, which require libgcc, which is fine. Rather than linking to libgcc, we simply provide them ourselves, since they're not that complicated. Signed-off-by: Jason A. Donenfeld --- Changes v3->v4: - Typo in comment - Relabel second function arch/arm64/Makefile | 2 ++ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/tishift.S | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/lib/tishift.S diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 939b310913cf..1f8a0fec6998 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -53,6 +53,8 @@ KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128) + ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__ diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index a0abc142c92b..55bdb01f1ea6 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -2,7 +2,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ - strchr.o strrchr.o + strchr.o strrchr.o tishift.o # Tell the compiler to treat all general purpose registers (with the # exception of the IP registers, which are already handled by the caller diff --git a/arch/arm64/lib/tishift.S b/arch/arm64/lib/tishift.S new file mode 100644 index 000000000000..bffe03c478a5 --- /dev/null +++ b/arch/arm64/lib/tishift.S @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 Jason A. Donenfeld . All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +ENTRY(__ashlti3) + cbz x2, 1f + mov x3, #64 + sub x3, x3, x2 + cmp x3, #0 + b.le 2f + lsl x1, x1, x2 + lsr x3, x0, x3 + lsl x2, x0, x2 + orr x1, x1, x3 + mov x0, x2 +1: + ret +2: + neg w1, w3 + mov x2, #0 + lsl x1, x0, x1 + mov x0, x2 + ret +ENDPROC(__ashlti3) + +ENTRY(__ashrti3) + cbz x2, 1f + mov x3, #64 + sub x3, x3, x2 + cmp x3, #0 + b.le 2f + lsr x0, x0, x2 + lsl x3, x1, x3 + asr x2, x1, x2 + orr x0, x0, x3 + mov x1, x2 +1: + ret +2: + neg w0, w3 + asr x2, x1, #63 + asr x0, x1, x0 + mov x1, x2 + ret +ENDPROC(__ashrti3)