Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp249221lqa; Sat, 27 Apr 2024 00:21:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX36mK6L6DSqcse0AKk7TCQEjdP10jDzXXwJ2PqBGnqYrF9DF3XmJfTcWG5bqhlO8yVh2V///YirVIKVNPhT9Izak7qWQ6pX3z5eq6ssg== X-Google-Smtp-Source: AGHT+IGjnUCXpDhb/I3bdTY8hedIcCtOKLPkfJO+28VStu1RP/0/qvvt6F/378HGXvOHxNjM4XLD X-Received: by 2002:a50:9ee3:0:b0:56c:3dfb:a1f5 with SMTP id a90-20020a509ee3000000b0056c3dfba1f5mr3344586edf.22.1714202477236; Sat, 27 Apr 2024 00:21:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714202477; cv=pass; d=google.com; s=arc-20160816; b=rYiGEfcmhw6rVpUuqRqv0VoQh+g3MRSyLFXJq/ggPBJiK7+yuAxz32o9vnN24OB1H0 IRGcOgGClMtR1M2DBnuOLTFgU22Jekvj/iKCWjR0HE6MQixk9SdLswSpk23SpWZ6T0s1 XGFpuOq1iewgJfKO4vV1a7UMFtqdXgoor0udYIdTid7NvT+Zafe4SgiI8X2NLnGql4s3 /3r3mr58G2NnTgZRQoxNWbxB2hIW0geLrq1+UOy+ng+QnqQ9Y7+7OHnGzaf1+jYQu6Wg ipHykijsPCh15Dv69BRXejbLrbsp+AvLCLrFD3z0uhxG251q+TyDyEiFqnpyMzD5I6rL vXjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=SzhIAmQObPcWM8Ttho+9VJmJbaMCmyzMGa3/VbeOw+8=; fh=2gJFWWcn6B0K6o361edBHXufP4J9j3iWDNMLgKaqyuk=; b=JWK0P58laLs3LfdEn4Xzh4PclaehFV9GaGSeTM0X9MYGCVTPpOTVz64Wc2k67XmZoO ViXGt7pFMHYNkda0YKK6bzR7xKZQywq5CYVGyWg3rb6E/Cw8eY3auIq+XrZGrvyGeY9f 6GzsOarUSJuaU8HHsnNf0SUgPqt2HMOYbILnDC3Q1SHY07bN4TQRscmJCUA66v/kW5qZ VTh8s9Vj8uuE+e8A1w4AwqbFJfQ88J0x6pAo96rKaI0O0e8VMyed46QdUxnmpKltf4Mt VkxMsatjq9PoOihZB2LK5JQhgDGhrmA30rUTbo+rMJR/XOZkRXhmX1FT222Zj/oxUbZV 0kSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stlKKaU2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q11-20020a50c34b000000b00572301d0a7csi4426411edb.311.2024.04.27.00.21.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 00:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stlKKaU2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id F1D641F22AE6 for ; Sat, 27 Apr 2024 07:21:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DA5642062; Sat, 27 Apr 2024 07:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="stlKKaU2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4601E3BBD2 for ; Sat, 27 Apr 2024 07:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714202469; cv=none; b=RMJnVrjnPmgaqFVtivnK8RssSLZA0/VB16S0r/vSRXaKgkytIPAI7C2p5Apy5jzTtipZpJGK7bds/kqm0j2kI/fhxe31gJLjMGsu37UmPR6k9q8KUT3YX2nFxqpo3h8et766TP6bv/9YW/EhMgDFQBDySg+m5t1yJX7pJiRsQrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714202469; c=relaxed/simple; bh=fIKMQoy1qd6Gq+28Yk3Ch3hYiaG++Dtnw8dmDRpSlkQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sdc5CCyjpNVUHPG4n3t0vQJ1RGSS2hKRezS5Zl8PW6r9wxyiiX3s446RDy69GU/MsPOxijy5+hovrYI5rL+XJuVQdE6VXTecfTYe2QxYB5biI3+B4f7F5E2qI5j078OlnfVCWNiCbkQLOr9J2BXTY5N88IBWfOiTmXPn1WAnjMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=stlKKaU2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1435C116B1 for ; Sat, 27 Apr 2024 07:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714202468; bh=fIKMQoy1qd6Gq+28Yk3Ch3hYiaG++Dtnw8dmDRpSlkQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=stlKKaU2j2DjJyYwRzVaqC0juIAcGM+d33oITQw3cy+Zc7YSQlzZ7diR8n3WxvUyX e5wzdmswmkwiXhdYRu2Hk8k5hSnIB7JqNSVT1s42uUHIOLLeZpRCE4Fxm2PkdFPFtc oNxkk8sTHSlsuW+hpZSJFDNQwQovKgO4nuhW+S0RspLOAgX8dxf7kq/b4HIK36UKDN oj3mHBkom6uAInCMYAvtfdLngn0AdgYaD+GgVOVjaX5OolroPrtTxJJUrn2VlQzash xfZzZPJURQL459Pg7s+tA9u3fKVrtfeq8LNaQK0TGXEs2u8K7VObylbkCkZ61mtbda cTYDNB7931BGA== Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a587831809eso332646666b.1 for ; Sat, 27 Apr 2024 00:21:08 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVFufQ/CBMKjcu8YM1DXeb/s/hndU//A+wAWmKyvCf+VLUoV83BhoxrVhmTDKITG9WiMfW/TIPssaLCIkfZZNEWD7pMRG/gbLnAthXS X-Gm-Message-State: AOJu0YzLfabcGaM+QTuIqTJc2qNPmhuKQTT+LKTbcOA9R9uckzMSbpXc SF3ELIZsuek7ih4BcAi0FbRrV8wfSLTp2ZWlDmcV2SbqbPp4BJeKbPDfezrGXVlhG/Yuh25/Jjj bMS6x60X5e3qD42Uhk4M3dFDQYxg= X-Received: by 2002:a17:906:f348:b0:a52:6e3e:c55c with SMTP id hg8-20020a170906f34800b00a526e3ec55cmr3117324ejb.70.1714202467397; Sat, 27 Apr 2024 00:21:07 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240426121442.882029-1-xry111@xry111.site> <56414029e179d219442bde9b8eae81fa3e3ceec4.camel@xry111.site> In-Reply-To: <56414029e179d219442bde9b8eae81fa3e3ceec4.camel@xry111.site> From: Huacai Chen Date: Sat, 27 Apr 2024 15:20:55 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Provide __lshrti3, __ashrti3, and __ashrti3 To: Xi Ruoyao Cc: WANG Xuerui , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Tiezhu Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 27, 2024 at 12:13=E2=80=AFPM Xi Ruoyao wro= te: > > 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, > > > > > > I don't think #ifdef CONFIG_ARCH_SUPPORTS_INT128 is needed here. > > > S390/ARM64/RISCV all built it unconditionally. > > > > The problem here is RISCV and ARM64 are using an incorrect prototype fo= r > > these functions in asm-prototypes.h: > > > > long long __lshrti3(long long a, int b); > > long long __ashrti3(long long a, int b); > > long long __ashlti3(long long a, int b); > > > > where "long long" is not 128-bit. Despite this seems working for RISC-= V > > and ARM64 I really dislike it. > > > > 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). > > > > So if we don't want to check CONFIG_ARCH_SUPPORTS_INT128 and still use = a > > correct prototype, we'll do: > > > > diff --git a/arch/loongarch/include/asm/asm-prototypes.h b/arch/loongar= ch/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 @@ > > #include > > #include > > > > -#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? OK, then just keep the original status. Huacai > > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University >