Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp194876lqa; Fri, 26 Apr 2024 21:13:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWg1Fdn0BBT5UDCGuw1CvPhuRmxTv+qfHxCIbP6n5aMe50oA/Ibgv+VApt5tRsUCYsJkKqJef/HTzAHY+euBSRQrA13sSK9EBpXeI1jdw== X-Google-Smtp-Source: AGHT+IFqIqxbwxg17CehQXhi+VOIXzW1tdiLXNgkZLxNYKDqsO523rhQUwJMJPbJYyfM+HXea2Hg X-Received: by 2002:a05:622a:90:b0:43a:74e9:6dd7 with SMTP id o16-20020a05622a009000b0043a74e96dd7mr4522706qtw.21.1714191223694; Fri, 26 Apr 2024 21:13:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714191223; cv=pass; d=google.com; s=arc-20160816; b=c7oglzVstyRlXGfbz6cDbyyi3v6nCvbCPaWEDNm1t60v8NE1D18whm5ucUY5yEBjOt 5IckI3q2Qt3PP5F0k/cgvY+2FieU+5BGSacouvIN/IAJjG7zrxSSx5nb8mxyAJDfte9M bnjgC8Dpgiu2mWKWFPpS1Pkx0Pn2U5fdKXkfd91REECwz7muOcXLYSLqzJ+xWqiZNzza cp5J8zczGNkOmW8ZOdHsiLpKJDYIslQiXHckG6aIBpHe85bJYBTwuNmU3SCzBxhZo3uq Y0l2g53wxOZ7thqyKk6qh0sx4t+4iOf4MM5MpyB1JQrraGhJj35Je0cupli/IwT5uE46 hwXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=Q329ZUKjcRM7NiA/wIA3POpWsdafH7a6cxQOJRrpDhY=; fh=snhKlX7XHt6q2sim2OSEqWRWsZF0IN4JResaPd8RRzw=; b=t7vgpg1Oc5sfReYh59FlGp99N4XMfhdz2qQx63e5kpBg+CB3x2mr7k3dQRk50bYUyX 7sPfehqHcFYQrY82YhMd+mGGXN74A+WrEMJsBptN5rYmU87KH63z5moIZHYj3A6ebR6n mefYVghLy+czIc8KxLBCg48M2TMM4o13vzaDc5aKjtABhoWbNV7c9BhvcpNFwTqYfzKJ 39OLvGpG+dsSpKMg1Fm9ykj2U82RfeyeC/+oP4H4L9rn87xCoK0OZ2xVKPei/wKXQURc ZXjyuWD5LorjVob9yy0G3sFQRCD4/CAna29ZNFz0UbC2vOzDyrNQ0G0uqSaYAuh6lQLJ 7jSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=WbB+5zsh; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-160887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c8-20020ac87dc8000000b0043aa0c8c132si703266qte.455.2024.04.26.21.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 21:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=WbB+5zsh; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-160887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6AC7B1C21394 for ; Sat, 27 Apr 2024 04:13:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 274913CF58; Sat, 27 Apr 2024 04:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="WbB+5zsh" Received: from xry111.site (xry111.site [89.208.246.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5B473BBEC for ; Sat, 27 Apr 2024 04:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.208.246.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714191217; cv=none; b=F5pTPGSmaAUnvuxFgdkXuoxoMw99xrKM+OUzIV3lOaFa5OBXElyuwym+SanbXUsBfqbBlF2tKSJFJ1BQi16eqbBnJPFsYqumpG3IiVIDn2H6nIkuYHjyZ+73JAmzWXViQsrK8OB6T2VbDr/BSmQ3moGqeGgvqq0Gn6M9UOTlSQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714191217; c=relaxed/simple; bh=L/SdhhR7cp15PtzHTJRI4OjluANgzw2oKI5pziWzQwU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=BRyIhOVvPnidVGjsHdIb2zSTA9jhPsPpP5NPl+AR/dXnPIS+EL+7bqfpdNzRCiI7neZQ2dHz5fvcTyqibkc045TZID3h5HPRPpBR+YSzDPcZOU0PMv8rmPDQTnLzi73ZC0ZrG4G+BXM9eNN9LQ+eiyn6gocZo/CKrcrns6sPXYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site; spf=pass smtp.mailfrom=xry111.site; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b=WbB+5zsh; arc=none smtp.client-ip=89.208.246.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1714191213; bh=L/SdhhR7cp15PtzHTJRI4OjluANgzw2oKI5pziWzQwU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=WbB+5zshh8lGx3TUlvTH9+9y9sU+Jcqd0LicWcF2Zpd54kH+mbNdq6nUBO9yFsMnd Jsf49g3V88xpeA4ZRCB33YjyMiFR2heDNs3usP7nqB91ka4LZYHBrsdGkkqL8FR960 o+6eEvEpB2hodKlX2i2ZXOjSi9WtkjLghPytUNAE= Received: from [IPv6:240e:358:1198:0:dc73:854d:832e:4] (unknown [IPv6:240e:358:1198:0:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 77B946591C; Sat, 27 Apr 2024 00:13:31 -0400 (EDT) Message-ID: <56414029e179d219442bde9b8eae81fa3e3ceec4.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Provide __lshrti3, __ashrti3, and __ashrti3 From: Xi Ruoyao To: Huacai Chen Cc: WANG Xuerui , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Tiezhu Yang Date: Sat, 27 Apr 2024 12:13:25 +0800 In-Reply-To: References: <20240426121442.882029-1-xry111@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Sat, 2024-04-27 at 12:00 +0800, Xi Ruoyao wrote: > On Sat, 2024-04-27 at 10:50 +0800, Huacai Chen wrote: > > Hi, Ruoyao, > >=20 > > I don't think #ifdef CONFIG_ARCH_SUPPORTS_INT128 is needed here. > > S390/ARM64/RISCV all built it unconditionally. >=20 > The problem here is RISCV and ARM64 are using an incorrect prototype for > these functions in asm-prototypes.h: >=20 > long long __lshrti3(long long a, int b);=20 > long long __ashrti3(long long a, int b);=20 > long long __ashlti3(long long a, int b);=20 >=20 > where "long long" is not 128-bit.=C2=A0 Despite this seems working for RI= SC-V > and ARM64 I really dislike it. >=20 > S390 seems assuming CONFIG_ARCH_SUPPORTS_INT128 is always true, but I > don't think we can assume it too (at least it'll likely to be false for > LA32, so doing so will cause trouble when we add LA32 support). >=20 > So if we don't want to check CONFIG_ARCH_SUPPORTS_INT128 and still use a > correct prototype, we'll do: >=20 > diff --git a/arch/loongarch/include/asm/asm-prototypes.h b/arch/loongarch= /include/asm/asm-prototypes.h > index 51f224bcfc65..0a57db01116d 100644 > --- a/arch/loongarch/include/asm/asm-prototypes.h > +++ b/arch/loongarch/include/asm/asm-prototypes.h > @@ -7,8 +7,6 @@ > =C2=A0#include > =C2=A0#include > =C2=A0 > -#ifdef CONFIG_ARCH_SUPPORTS_INT128 > -__int128_t __ashlti3(__int128_t a, int b); > -__int128_t __ashrti3(__int128_t a, int b); > -__int128_t __lshrti3(__int128_t a, int b); > -#endif > +struct { u64 lo, hi; } __ashlti3(u64 lo, u64 hi, int b); > +struct { u64 lo, hi; } __ashrti3(u64 lo, u64 hi, int b); > +struct { u64 lo, hi; } __lshrti3(u64 lo, u64 hi, int b); Whoops. This is still incorrect for LA32. On LA32 an "int128" (if it ever exists) should be passed as a pointer, but this is passing it in 4 GPRs. So if we want to keep the prototype correct we need to either use "struct { u64 lo, hi; }" in the parameter list too, or guard it with #ifdef CONFIG_64BIT. So to me checking CONFIG_ARCH_SUPPORTS_INT128 is just easier. If you insists on not checking CONFIG_ARCH_SUPPORTS_INT128 I'll just use an incorrect prototype like RISC-V but put a comment here, like: /* The prototypes are incorrect but this file is only used by modpost which does not care. */ long long __ashlti3(long long a, int b); long long __ashrti3(long long a, int b); long long __lshrti3(long long a, int b); How do you think? --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University