Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14104118rwd; Sat, 24 Jun 2023 12:07:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5C6pxBGH1wb7MOBesICyFQgY/X2XLuk7GYQcu3pZZ57FGcZ6cxPGs8luksTR78RdfVeEJ8 X-Received: by 2002:a05:6a21:3293:b0:10a:ee1b:fdc4 with SMTP id yt19-20020a056a21329300b0010aee1bfdc4mr31472538pzb.47.1687633664965; Sat, 24 Jun 2023 12:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687633664; cv=none; d=google.com; s=arc-20160816; b=J0RzC9pQMib+5Wjq77Xwoyih5rB8nVVlZfitowGZh3qSPzJ5gH/+xpMKHn8ZdeS67L l+b+dumfFPts4txBiHMThQ/QBff9LPrwW2+jzqDWxfNg6Wxd53qWWZYlDCSeofNZAFpG 2DDm27zWa9e6ndc9nPd8mYSm1kzuHra22iV6IF9SZWVeI2wyeTsXgUgb50s3jnBlfZCL Yy5xmbPSco7WU2BFLfU+JEY6LX49f/u4Y84H/rvbkgFncl6+QepiON+iihWrk2ROzhC5 Py16JY4Ajc4Lyb++5uvQA8jmCyn5bYlCgT432jePeHhlqgTL5bPB9UBO0UNrjRP1hTav zRmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BNOa6KUqmUx9uB6fR2YZQjaDTT63knseKFi1dIqAvjM=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=esshutj6MzzYuEImz2RcUpb14mpMGQu7fV7PmvOuis1exiw468Z9tTl8JrVvvBSx0x R5zYKvCvgHm5FCgeymPypD9vUEsQtUTVA4Q4maP+z90wd+xdHrc+9cnljRTrLgNO4y+w CLWHHHgBd4soBhSMToQ46yfHd+PxCSE0y+r8ettSIBGo9kfG0k7vsfykYpTRxu+sYKig L+tUx6ecsmKUIDoUFdw+jJqhVQKUUaH2lHd56SYp5xYnKgF5XZ86Axt9x/CL700bpdh4 3ulkKQEgj3/gUy9cZC2mhouNAhEWpeheGgcr1RaZRe4Y4eAnwB7EXiF8t5pilwldg/Oy TIfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=OQeSqC3s; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br12-20020a056a00440c00b0063b8a054e06si378272pfb.259.2023.06.24.12.07.31; Sat, 24 Jun 2023 12:07:44 -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=@xen0n.name header.s=mail header.b=OQeSqC3s; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233247AbjFXSlf (ORCPT + 99 others); Sat, 24 Jun 2023 14:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbjFXSlY (ORCPT ); Sat, 24 Jun 2023 14:41:24 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075321BE2; Sat, 24 Jun 2023 11:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687632081; bh=NOCcPZczdsomiPtC0nBfEgK1XfX0lPqE5Cxg6R5R4g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQeSqC3sECHenzvybqjfuRyAjSaCo0e490rGBUFKJVUIsvUJgJ75ENipcEAK37XG7 kcHtY9xJSkKDWLvQDn/iikcGaEl6hlYDVEBG4TMnbVAPKcaU6hPfOQcQOig9hEDxzE FmZ2X11ZoGX3vWCwC3vDT09u2giwPbj47Yl9d6IM= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 89CD9600B5; Sun, 25 Jun 2023 02:41:21 +0800 (CST) From: WANG Xuerui To: Huacai Chen 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 Subject: [PATCH v2 3/9] LoongArch: Prepare for assemblers with proper FCSR class support Date: Sun, 25 Jun 2023 02:40:49 +0800 Message-Id: <20230624184055.3000636-4-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230624184055.3000636-1-kernel@xen0n.name> References: <20230624184055.3000636-1-kernel@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 From: WANG Xuerui The GNU assembler (as of 2.40) mis-treats FCSR operands as GPRs, but the LLVM IAS does not. Probe for this and refer to FCSRs as "$fcsrNN" if support is present. Signed-off-by: WANG Xuerui --- arch/loongarch/Kconfig | 3 +++ arch/loongarch/include/asm/fpregdef.h | 7 +++++++ arch/loongarch/include/asm/loongarch.h | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 743d87655742..ac3564935281 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -242,6 +242,9 @@ config SCHED_OMIT_FRAME_POINTER config AS_HAS_EXPLICIT_RELOCS def_bool $(as-instr,x:pcalau12i \$t0$(comma)%pc_hi20(x)) +config AS_HAS_FCSR_CLASS + def_bool $(as-instr,x:movfcsr2gr \$t0$(comma)\$fcsr0) + config CC_HAS_LSX_EXTENSION def_bool $(cc-option,-mlsx) diff --git a/arch/loongarch/include/asm/fpregdef.h b/arch/loongarch/include/asm/fpregdef.h index b6be527831dd..3eb7ff9e1d8e 100644 --- a/arch/loongarch/include/asm/fpregdef.h +++ b/arch/loongarch/include/asm/fpregdef.h @@ -40,6 +40,12 @@ #define fs6 $f30 #define fs7 $f31 +#ifdef CONFIG_AS_HAS_FCSR_CLASS +#define fcsr0 $fcsr0 +#define fcsr1 $fcsr1 +#define fcsr2 $fcsr2 +#define fcsr3 $fcsr3 +#else /* * Current binutils expects *GPRs* at FCSR position for the FCSR * operation instructions, so define aliases for those used. @@ -48,5 +54,6 @@ #define fcsr1 $r1 #define fcsr2 $r2 #define fcsr3 $r3 +#endif #endif /* _ASM_FPREGDEF_H */ diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h index ac83e60c60d1..ff4482fd8ad7 100644 --- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -1445,11 +1445,18 @@ __BUILD_CSR_OP(tlbidx) #define EXCCODE_INT_START 64 #define EXCCODE_INT_END (EXCCODE_INT_START + EXCCODE_INT_NUM - 1) -/* FPU register names */ +/* FPU Status Register Names */ +#ifdef CONFIG_AS_HAS_FCSR_CLASS +#define LOONGARCH_FCSR0 $fcsr0 +#define LOONGARCH_FCSR1 $fcsr1 +#define LOONGARCH_FCSR2 $fcsr2 +#define LOONGARCH_FCSR3 $fcsr3 +#else #define LOONGARCH_FCSR0 $r0 #define LOONGARCH_FCSR1 $r1 #define LOONGARCH_FCSR2 $r2 #define LOONGARCH_FCSR3 $r3 +#endif /* FPU Status Register Values */ #define FPU_CSR_RSVD 0xe0e0fce0 -- 2.40.0