From patchwork Mon Nov 6 23:58:18 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: 10044941 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 37379602CC for ; Mon, 6 Nov 2017 23:59:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27B622A0C1 for ; Mon, 6 Nov 2017 23:59:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AA242A0D4; Mon, 6 Nov 2017 23:59:03 +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 62AAC2A0D2 for ; Mon, 6 Nov 2017 23:59:01 +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=x9DwB0Wm9n/imKp9t62ZxnaMdDvUp/kW37pH7xrkwno=; b=asIyggX3+OguJbMhdZGJnn2jw5 rV9u2dmzhTG8XVrwXNE92IdrHM/IF6ZMasEkTJ0gxsHr3suBEYwW/XH/sTe6mpKt7uSt/VnU9Xawl 785w+QNRsChu6KGNyKExXGIQiLtUlf+taA0sViiT1nnaK80QaUfsPOdCn6Dn+h0iy9ZPJz4uR6ryp KES83C7wYuX+PqMdvLNMyiHY/YV/lbLayGj2CxHsSXjCYVRGwdvmnUq70g3j/ewYRyoT0pjz8VNSt j04QyPp6hxoDQ6hkjzc/a4a+hyLxH+Cv5nUjjBMTKfI0/qMnE99iehWmPZh6VgFKHiU8oJuxsMWgf NFEmCAZg==; 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 1eBrIB-0007Xe-3z; Mon, 06 Nov 2017 23:58:59 +0000 Received: from frisell.zx2c4.com ([192.95.5.64]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eBrI6-0007VC-Rb for linux-arm-kernel@lists.infradead.org; Mon, 06 Nov 2017 23:58:57 +0000 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 74b4d44d; Mon, 6 Nov 2017 23:55:21 +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=cQNB D2Q8gHmV8aJfxodMW5fUMj0=; b=BPXvxOMhtjmwCt93Lu3s646Gqoe6m/nbodbN 4jowBlSxqnTGJ0V2v8XAH9gxkaVtANQh1t8uEGcoDYJImJ8uXINuKjqYfbHlk7fM ku7PLaFS+4KuPWqfMsyc2TRDVv3/jskkhpvqbTJT9hmUqH9XpB68A+dKTHXat8Cw PTyWa+NkbodJGQEl+JEKGkUmi55lA+fyDwk74fVh4D1EHJXSN6ItX5IAM8kBbpgt ubLcH3ugwGM/6wEmrwxCSLPEsQGe4fhKuahdk3qk53yrSVCdHKSI9lwktiYmJVNi ZXsIYq1yp+05zGsqBjfMkkb0lbbWtSvl3AyeXEPiG8fN/isLZw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 10a739dd (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 6 Nov 2017 23:55:21 +0000 (UTC) From: "Jason A. Donenfeld" To: Catalin Marinas , Mark Rutland , wangkefeng.wang@huawei.com, Arnd Bergmann , Ard Biesheuvel , Will Deacon , LKML , linux-arm-kernel@lists.infradead.org Subject: [PATCH v5] arm64: support __int128 on gcc 5+ Date: Tue, 7 Nov 2017 08:58:18 +0900 Message-Id: <20171106235818.30182-1-Jason@zx2c4.com> In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171106_155855_046066_0429D5A1 X-CRM114-Status: GOOD ( 14.06 ) 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, __ashrti3, and __lshrti3 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 v4->v5: - Add implementation of __lshrti3. (Note that __lshlti3 is not a function.) arch/arm64/Makefile | 2 ++ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/tishift.S | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 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 9a8cb96555d6..4e696f96451f 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -3,7 +3,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..d3db9b2cd479 --- /dev/null +++ b/arch/arm64/lib/tishift.S @@ -0,0 +1,80 @@ +/* + * 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) + +ENTRY(__lshrti3) + cbz x2, 1f + mov x3, #64 + sub x3, x3, x2 + cmp x3, #0 + b.le 2f + lsr x0, x0, x2 + lsl x3, x1, x3 + lsr x2, x1, x2 + orr x0, x0, x3 + mov x1, x2 +1: + ret +2: + neg w0, w3 + mov x2, #0 + lsr x0, x1, x0 + mov x1, x2 + ret +ENDPROC(__lshrti3)