Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12703616rwd; Fri, 23 Jun 2023 09:28:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5roUC6OqVLPfinYJDXy0NXVLbF7EkI8x2s+ywMQPRwkGdTtMZ90vMYl34HUvfxPodMF/kt X-Received: by 2002:a05:6a00:2183:b0:666:81ae:feb9 with SMTP id h3-20020a056a00218300b0066681aefeb9mr25665348pfi.27.1687537727874; Fri, 23 Jun 2023 09:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687537727; cv=none; d=google.com; s=arc-20160816; b=xfw29DmZja6RyRmBDWrSQJOAIcK3ncoBO4mJfS61dVrsFPmWy13xwFwCpZnOWQw0Ov jOUyK+D5mfwPPGX5olTJkkiQFQerXac0O2aV/w30VdEsv9WdrhmMI+SLl5z8HTxxM2Uy MsrqV8+M5wg5kGGclja11pIQ7n5xopg/eA7h5bcnappOPvARz7Z53ySgPCeJ1TWQZBWu iSDr4NYpozVWvG/xwG7PlocS9hW7xESuoiullbXB8FaYwkqZaRP/ogVxeNoQjshVljM2 lhfrJTqMPSvoGNJ+9hTP55SAUe+/czXlrYEJ2npgYS33H0uhx81lfIhrgZpF3ld9Zm4M ht1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DVUxmN9ABgYI1DhLHG1dwno61DFNEUFqq+S2JOVmYy0=; b=ZmgmxOaogxRj5vnXOdG8Zfs5C9VVhOCrWRzd7MsB7Bs7h4VgxWUuc4J8aGDvMWkWvE t/ZQONCZY7qoveKvE7XSbOj5Ngu+HZZvkp4KRH1p6bzpQwjVIHafzVKykjQa7ABufa2A Jc5HNy9tKrwE45Dep1nZpLdsJ4gH1QBTqKfx8golpCLHsTxRfqUWlPligN9UTSgOtsYH 7W+2dYk80U4HvQMJZWfIlbb2vfjVzwGJms8Po4N5EE9I89VtHnrI08Cy1QKn54afe/6J v+2Ch7UHRFnlzbkuMLd1wNO2C+vldGLW9yvmGHhMwCuPr2PAdwEZRio+BwbqctNq4jV1 vJQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="GUX+/5uQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az9-20020a056a02004900b005074cff89b9si4788268pgb.250.2023.06.23.09.28.36; Fri, 23 Jun 2023 09:28:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="GUX+/5uQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjFWQDl (ORCPT + 99 others); Fri, 23 Jun 2023 12:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232043AbjFWQDc (ORCPT ); Fri, 23 Jun 2023 12:03:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01D1270D; Fri, 23 Jun 2023 09:03:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 58F8C61A9F; Fri, 23 Jun 2023 16:03:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCA79C433CB; Fri, 23 Jun 2023 16:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687536210; bh=rJAiY7DvRusfqKQ/9tX+7NJbcDf3hYdW67SlVu6b8Ps=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GUX+/5uQvg6Bg8M8YCLrvmARyhXRLswbU8k3dv9nbRrPpFW661aFVon7eaBwwbbPA z1CnV7sztvuCj19ZOEE/A0zElh24Lts+gtFjNjmrRDG+Jc0jOWdiVdyPsBjPIk7h3f Yz21LOC+pJXIDgGrP/xRVYkMFq3RO0Dhr/5XXfNPus1nej7ow5xt8gBeuYB0ZkcnbC GxMtQrTXFWMOw3O5Dehd0Qgziy24xTMRGPBQvtjdJTIIFWfI+T3cj0uNqofHSuQaMD kL5LGaHq1dAjehM2A1Jy8bIQMwpulI3vU+2hr2JuYy3bZZ+Fn/lwC+9YuaXOlhYTv8 ntCp/57bxACEQ== Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4f96da99965so1036935e87.1; Fri, 23 Jun 2023 09:03:30 -0700 (PDT) X-Gm-Message-State: AC+VfDxydiPehohwm8wXTafxqWF0fn3yy3EGGo+Ay80FDKqmIZhZYgE4 iOUJyIsRgvKw4QxGAdtsyZJIUlnQL0lu66pEvQg= X-Received: by 2002:ac2:499e:0:b0:4f8:6f40:4776 with SMTP id f30-20020ac2499e000000b004f86f404776mr10070198lfl.46.1687536208757; Fri, 23 Jun 2023 09:03:28 -0700 (PDT) MIME-Version: 1.0 References: <20230623134351.1898379-1-kernel@xen0n.name> <20230623134351.1898379-5-kernel@xen0n.name> In-Reply-To: <20230623134351.1898379-5-kernel@xen0n.name> From: Huacai Chen Date: Sat, 24 Jun 2023 00:03:16 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/9] LoongArch: Make {read,write}_fcsr compatible with LLVM/Clang To: WANG Xuerui Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Xuerui, On Fri, Jun 23, 2023 at 9:44=E2=80=AFPM WANG Xuerui wro= te: > > From: WANG Xuerui > > LLVM/Clang does not see FCSRs as GPRs, so make use of compiler > built-ins instead for better maintainability with less code. > > The existing version cannot be wholly removed though, because the > built-ins, while available on GCC too, is predicated TARGET_HARD_FLOAT, > which means soft-float code cannot make use of them. > > Signed-off-by: WANG Xuerui > --- > arch/loongarch/include/asm/loongarch.h | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/incl= ude/asm/loongarch.h > index ac83e60c60d1..eedc313b5241 100644 > --- a/arch/loongarch/include/asm/loongarch.h > +++ b/arch/loongarch/include/asm/loongarch.h > @@ -1445,12 +1445,6 @@ __BUILD_CSR_OP(tlbidx) > #define EXCCODE_INT_START 64 > #define EXCCODE_INT_END (EXCCODE_INT_START + EXCCODE_INT_= NUM - 1) > > -/* FPU register names */ > -#define LOONGARCH_FCSR0 $r0 > -#define LOONGARCH_FCSR1 $r1 > -#define LOONGARCH_FCSR2 $r2 > -#define LOONGARCH_FCSR3 $r3 > - > /* FPU Status Register Values */ > #define FPU_CSR_RSVD 0xe0e0fce0 > > @@ -1487,6 +1481,18 @@ __BUILD_CSR_OP(tlbidx) > #define FPU_CSR_RU 0x200 /* towards +Infinity */ > #define FPU_CSR_RD 0x300 /* towards -Infinity */ > > +#ifdef CONFIG_CC_IS_CLANG > +#define LOONGARCH_FCSR0 0 > +#define LOONGARCH_FCSR1 1 > +#define LOONGARCH_FCSR2 2 > +#define LOONGARCH_FCSR3 3 > +#define read_fcsr(source) __movfcsr2gr(source) > +#define write_fcsr(dest, val) __movgr2fcsr(dest, val) > +#else /* CONFIG_CC_IS_CLANG */ > +#define LOONGARCH_FCSR0 $r0 > +#define LOONGARCH_FCSR1 $r1 > +#define LOONGARCH_FCSR2 $r2 > +#define LOONGARCH_FCSR3 $r3 > #define read_fcsr(source) \ > ({ \ > unsigned int __res; \ Now the latest binutils also supports $fcsr, so I suggest to always use inline asm, and change CONFIG_CC_IS_CLANG to CONFIG_AS_HAS_FCSR_CLASS. And of course, Patch3 and Patch4 can be merged then. Huacai > @@ -1503,5 +1509,6 @@ do { \ > " movgr2fcsr "__stringify(dest)", %0 \n" \ > : : "r" (val)); \ > } while (0) > +#endif /* CONFIG_CC_IS_CLANG */ > > #endif /* _ASM_LOONGARCH_H */ > -- > 2.40.0 >