From patchwork Fri Jun 14 08:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengqinggang X-Patchwork-Id: 1947720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W0sKN38fHz20Pb for ; Fri, 14 Jun 2024 18:05:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 306B6388206F for ; Fri, 14 Jun 2024 08:05:42 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id F32DA3882100 for ; Fri, 14 Jun 2024 08:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F32DA3882100 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F32DA3882100 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718352322; cv=none; b=BxuWMefi8mDqpRduKw24NvJrC6WqFzvNBhAJBUfImSA09x9HFKoivXsn0vVV8h3VnF2okaI2xLnFIVdfwXto4+SVPJp77KPjCh1+pI8PdCaKTRylJOr3E89AUynGF599jIa+8PFCVjuyDLVU3MGlDt3ujNP9cgKH5q9TTElyRK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718352322; c=relaxed/simple; bh=YDYlqf4xJNfuFSY86WNXvyF9u69FzZp+MXDpoalMkb4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=vPZZdEEnKZ3KzAVIzt3shKqz0Ql8GG2ZlB3MA2laSDmedU5scwUxYYOE7+L0lTEVzJsAJYZ6bhPxgWGBFFuN5uXB66ZQmHWlPSBjQk4blfRDiEN/C9bViKQQiQEg/O6cLuaYXieK7BYGH3Pvv2oQ+q/Cqxzlbw3bg2pWOpEvwaw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8DxzOq8+Wtm1dMGAA--.27653S3; Fri, 14 Jun 2024 16:05:16 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axw8S6+WtmA_MfAA--.1753S2; Fri, 14 Jun 2024 16:05:14 +0800 (CST) From: mengqinggang To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, xuchenghua@loongson.cn, caiyinyu@loongson.cn, chenglulu@loongson.cn, cailulu@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, mengqinggang@loongson.cn Subject: [PATCH v2] LoongArch: Fix tst-gnu2-tls2 with -Og flag Date: Fri, 14 Jun 2024 16:05:12 +0800 Message-Id: <20240614080512.4186221-1-mengqinggang@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Axw8S6+WtmA_MfAA--.1753S2 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj9fXoW3KrykKFWDurWfAF15Ww4fXrc_yoW8Aw48Zo Wq9rn5W3W7t347XFn7Ca43Zrya9FsI9rs5Gr1jgr17CFy2vFWUK3yUCFZFvF93ZF45Kr9r WryfXrs8C3yYka4Ul-sFpf9Il3svdjkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUY87kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUXVWUAwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r1j6r4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI 0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280 aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28Icx kI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2Iq xVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42 IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8vApUUUUUU== X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, 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 server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org asm volatile ("movfcsr2gr $t0, $fcsr0" ::: "$t0"); asm volatile ("st.d $t0, %0" :"=m"(restore_fcsr)); generate to the following instructions with -Og flag: movfcsr2gr $t0, $zero addi.d $t0, $sp, 2047(0x7ff) addi.d $t0, $t0, 77(0x4d) st.w $t0, $t0, 0 fcsr0 register and restore_fcsr variable are both stored in t0 register. Change to: asm volatile ("movfcsr2gr %0, $fcsr0" :"=r"(restore_fcsr)); to avoid restore_fcsr address in t0. --- Changes v0 -> v1: - Use one line inline assembly to save fcsr/fcc registers. sysdeps/loongarch/tst-gnu2-tls2.h | 286 +++++++++++++++--------------- 1 file changed, 147 insertions(+), 139 deletions(-) diff --git a/sysdeps/loongarch/tst-gnu2-tls2.h b/sysdeps/loongarch/tst-gnu2-tls2.h index 8e4216785d..54f181c068 100644 --- a/sysdeps/loongarch/tst-gnu2-tls2.h +++ b/sysdeps/loongarch/tst-gnu2-tls2.h @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include #include @@ -42,35 +43,35 @@ #else /* hard float */ #define SAVE_REGISTER_FCC(src) \ - asm volatile ("movcf2gr $t0, $fcc0" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[0]) :); \ - asm volatile ("movcf2gr $t0, $fcc1" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[1]) :); \ - asm volatile ("movcf2gr $t0, $fcc2" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[2]) :); \ - asm volatile ("movcf2gr $t0, $fcc3" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[3]) :); \ - asm volatile ("movcf2gr $t0, $fcc4" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[4]) :); \ - asm volatile ("movcf2gr $t0, $fcc5" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[5]) :); \ - asm volatile ("movcf2gr $t0, $fcc6" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[6]) :); \ - asm volatile ("movcf2gr $t0, $fcc7" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(src[7]) :); + asm volatile ("movcf2gr %0, $fcc0" :"=r"(src[0])); \ + asm volatile ("movcf2gr %0, $fcc1" :"=r"(src[1])); \ + asm volatile ("movcf2gr %0, $fcc2" :"=r"(src[2])); \ + asm volatile ("movcf2gr %0, $fcc3" :"=r"(src[3])); \ + asm volatile ("movcf2gr %0, $fcc4" :"=r"(src[4])); \ + asm volatile ("movcf2gr %0, $fcc5" :"=r"(src[5])); \ + asm volatile ("movcf2gr %0, $fcc6" :"=r"(src[6])); \ + asm volatile ("movcf2gr %0, $fcc7" :"=r"(src[7])); \ #define LOAD_REGISTER_FCSR() \ + uint64_t src_fcsr = 0x01010101; \ asm volatile ("li.d $t0, 0x01010101" ::: "$t0"); \ asm volatile ("movgr2fcsr $fcsr0, $t0" :::); -#define SAVE_REGISTER_FCSR() \ - asm volatile ("movfcsr2gr $t0, $fcsr0" ::: "$t0"); \ - asm volatile ("st.d $t0, %0" :"=m"(restore_fcsr) :); +#define SAVE_REGISTER_FCSR() \ + uint64_t restore_fcsr; \ + asm volatile ("movfcsr2gr %0, $fcsr0" :"=r"(restore_fcsr)); \ + if (src_fcsr != restore_fcsr) \ + { \ + printf ("FCSR registers compare failed!\n"); \ + abort (); \ + } \ -# define INIT_TLSDESC_CALL() \ +#define INIT_TLSDESC_CALL() \ unsigned long hwcap = getauxval (AT_HWCAP); #define LOAD_REGISTER_FLOAT() \ + for (int i = 0; i < 32; i++) \ + src_float[i] = i + 1; \ asm volatile ("fld.d $f0, %0" ::"m"(src_float[0]) :"$f0"); \ asm volatile ("fld.d $f1, %0" ::"m"(src_float[1]) :"$f1"); \ asm volatile ("fld.d $f2, %0" ::"m"(src_float[2]) :"$f2"); \ @@ -105,38 +106,45 @@ asm volatile ("fld.d $f31, %0" ::"m"(src_float[31]) :"$f31"); #define SAVE_REGISTER_FLOAT() \ - asm volatile ("fst.d $f0, %0" :"=m"(restore_float[0]) :); \ - asm volatile ("fst.d $f1, %0" :"=m"(restore_float[1]) :); \ - asm volatile ("fst.d $f2, %0" :"=m"(restore_float[2]) :); \ - asm volatile ("fst.d $f3, %0" :"=m"(restore_float[3]) :); \ - asm volatile ("fst.d $f4, %0" :"=m"(restore_float[4]) :); \ - asm volatile ("fst.d $f5, %0" :"=m"(restore_float[5]) :); \ - asm volatile ("fst.d $f6, %0" :"=m"(restore_float[6]) :); \ - asm volatile ("fst.d $f7, %0" :"=m"(restore_float[7]) :); \ - asm volatile ("fst.d $f8, %0" :"=m"(restore_float[8]) :); \ - asm volatile ("fst.d $f9, %0" :"=m"(restore_float[9]) :); \ - asm volatile ("fst.d $f10, %0" :"=m"(restore_float[10]) :); \ - asm volatile ("fst.d $f11, %0" :"=m"(restore_float[11]) :); \ - asm volatile ("fst.d $f12, %0" :"=m"(restore_float[12]) :); \ - asm volatile ("fst.d $f13, %0" :"=m"(restore_float[13]) :); \ - asm volatile ("fst.d $f14, %0" :"=m"(restore_float[14]) :); \ - asm volatile ("fst.d $f15, %0" :"=m"(restore_float[15]) :); \ - asm volatile ("fst.d $f16, %0" :"=m"(restore_float[16]) :); \ - asm volatile ("fst.d $f17, %0" :"=m"(restore_float[17]) :); \ - asm volatile ("fst.d $f18, %0" :"=m"(restore_float[18]) :); \ - asm volatile ("fst.d $f19, %0" :"=m"(restore_float[19]) :); \ - asm volatile ("fst.d $f20, %0" :"=m"(restore_float[20]) :); \ - asm volatile ("fst.d $f21, %0" :"=m"(restore_float[21]) :); \ - asm volatile ("fst.d $f22, %0" :"=m"(restore_float[22]) :); \ - asm volatile ("fst.d $f23, %0" :"=m"(restore_float[23]) :); \ - asm volatile ("fst.d $f24, %0" :"=m"(restore_float[24]) :); \ - asm volatile ("fst.d $f25, %0" :"=m"(restore_float[25]) :); \ - asm volatile ("fst.d $f26, %0" :"=m"(restore_float[26]) :); \ - asm volatile ("fst.d $f27, %0" :"=m"(restore_float[27]) :); \ - asm volatile ("fst.d $f28, %0" :"=m"(restore_float[28]) :); \ - asm volatile ("fst.d $f29, %0" :"=m"(restore_float[29]) :); \ - asm volatile ("fst.d $f30, %0" :"=m"(restore_float[30]) :); \ - asm volatile ("fst.d $f31, %0" :"=m"(restore_float[31]) :); + double restore_float[32]; \ + asm volatile ("fst.d $f0, %0" :"=m"(restore_float[0])); \ + asm volatile ("fst.d $f1, %0" :"=m"(restore_float[1])); \ + asm volatile ("fst.d $f2, %0" :"=m"(restore_float[2])); \ + asm volatile ("fst.d $f3, %0" :"=m"(restore_float[3])); \ + asm volatile ("fst.d $f4, %0" :"=m"(restore_float[4])); \ + asm volatile ("fst.d $f5, %0" :"=m"(restore_float[5])); \ + asm volatile ("fst.d $f6, %0" :"=m"(restore_float[6])); \ + asm volatile ("fst.d $f7, %0" :"=m"(restore_float[7])); \ + asm volatile ("fst.d $f8, %0" :"=m"(restore_float[8])); \ + asm volatile ("fst.d $f9, %0" :"=m"(restore_float[9])); \ + asm volatile ("fst.d $f10, %0" :"=m"(restore_float[10])); \ + asm volatile ("fst.d $f11, %0" :"=m"(restore_float[11])); \ + asm volatile ("fst.d $f12, %0" :"=m"(restore_float[12])); \ + asm volatile ("fst.d $f13, %0" :"=m"(restore_float[13])); \ + asm volatile ("fst.d $f14, %0" :"=m"(restore_float[14])); \ + asm volatile ("fst.d $f15, %0" :"=m"(restore_float[15])); \ + asm volatile ("fst.d $f16, %0" :"=m"(restore_float[16])); \ + asm volatile ("fst.d $f17, %0" :"=m"(restore_float[17])); \ + asm volatile ("fst.d $f18, %0" :"=m"(restore_float[18])); \ + asm volatile ("fst.d $f19, %0" :"=m"(restore_float[19])); \ + asm volatile ("fst.d $f20, %0" :"=m"(restore_float[20])); \ + asm volatile ("fst.d $f21, %0" :"=m"(restore_float[21])); \ + asm volatile ("fst.d $f22, %0" :"=m"(restore_float[22])); \ + asm volatile ("fst.d $f23, %0" :"=m"(restore_float[23])); \ + asm volatile ("fst.d $f24, %0" :"=m"(restore_float[24])); \ + asm volatile ("fst.d $f25, %0" :"=m"(restore_float[25])); \ + asm volatile ("fst.d $f26, %0" :"=m"(restore_float[26])); \ + asm volatile ("fst.d $f27, %0" :"=m"(restore_float[27])); \ + asm volatile ("fst.d $f28, %0" :"=m"(restore_float[28])); \ + asm volatile ("fst.d $f29, %0" :"=m"(restore_float[29])); \ + asm volatile ("fst.d $f30, %0" :"=m"(restore_float[30])); \ + asm volatile ("fst.d $f31, %0" :"=m"(restore_float[31])); \ + for (int i = 0; i < 32; i++) \ + if (src_float[i] != restore_float[i]) \ + { \ + printf ("Float registers compare failed!\n"); \ + abort (); \ + } \ #ifdef HAVE_LOONGARCH_VEC_COM #define LOAD_REGISTER_LSX() \ @@ -181,44 +189,47 @@ #define SAVE_REGISTER_LSX() \ int src_lsx[32][4]; \ int restore_lsx[32][4]; \ - asm volatile ("vst $vr0, %0" :"=m"(restore_lsx[0]) :); \ - asm volatile ("vst $vr1, %0" :"=m"(restore_lsx[1]) :); \ - asm volatile ("vst $vr2, %0" :"=m"(restore_lsx[2]) :); \ - asm volatile ("vst $vr3, %0" :"=m"(restore_lsx[3]) :); \ - asm volatile ("vst $vr4, %0" :"=m"(restore_lsx[4]) :); \ - asm volatile ("vst $vr5, %0" :"=m"(restore_lsx[5]) :); \ - asm volatile ("vst $vr6, %0" :"=m"(restore_lsx[6]) :); \ - asm volatile ("vst $vr7, %0" :"=m"(restore_lsx[7]) :); \ - asm volatile ("vst $vr8, %0" :"=m"(restore_lsx[8]) :); \ - asm volatile ("vst $vr9, %0" :"=m"(restore_lsx[9]) :); \ - asm volatile ("vst $vr10, %0" :"=m"(restore_lsx[10]) :); \ - asm volatile ("vst $vr11, %0" :"=m"(restore_lsx[11]) :); \ - asm volatile ("vst $vr12, %0" :"=m"(restore_lsx[12]) :); \ - asm volatile ("vst $vr13, %0" :"=m"(restore_lsx[13]) :); \ - asm volatile ("vst $vr14, %0" :"=m"(restore_lsx[14]) :); \ - asm volatile ("vst $vr15, %0" :"=m"(restore_lsx[15]) :); \ - asm volatile ("vst $vr16, %0" :"=m"(restore_lsx[16]) :); \ - asm volatile ("vst $vr17, %0" :"=m"(restore_lsx[17]) :); \ - asm volatile ("vst $vr18, %0" :"=m"(restore_lsx[18]) :); \ - asm volatile ("vst $vr19, %0" :"=m"(restore_lsx[19]) :); \ - asm volatile ("vst $vr20, %0" :"=m"(restore_lsx[20]) :); \ - asm volatile ("vst $vr21, %0" :"=m"(restore_lsx[21]) :); \ - asm volatile ("vst $vr22, %0" :"=m"(restore_lsx[22]) :); \ - asm volatile ("vst $vr23, %0" :"=m"(restore_lsx[23]) :); \ - asm volatile ("vst $vr24, %0" :"=m"(restore_lsx[24]) :); \ - asm volatile ("vst $vr25, %0" :"=m"(restore_lsx[25]) :); \ - asm volatile ("vst $vr26, %0" :"=m"(restore_lsx[26]) :); \ - asm volatile ("vst $vr27, %0" :"=m"(restore_lsx[27]) :); \ - asm volatile ("vst $vr28, %0" :"=m"(restore_lsx[28]) :); \ - asm volatile ("vst $vr29, %0" :"=m"(restore_lsx[29]) :); \ - asm volatile ("vst $vr30, %0" :"=m"(restore_lsx[30]) :); \ - asm volatile ("vst $vr31, %0" :"=m"(restore_lsx[31]) :); \ + asm volatile ("vst $vr0, %0" :"=m"(restore_lsx[0])); \ + asm volatile ("vst $vr1, %0" :"=m"(restore_lsx[1])); \ + asm volatile ("vst $vr2, %0" :"=m"(restore_lsx[2])); \ + asm volatile ("vst $vr3, %0" :"=m"(restore_lsx[3])); \ + asm volatile ("vst $vr4, %0" :"=m"(restore_lsx[4])); \ + asm volatile ("vst $vr5, %0" :"=m"(restore_lsx[5])); \ + asm volatile ("vst $vr6, %0" :"=m"(restore_lsx[6])); \ + asm volatile ("vst $vr7, %0" :"=m"(restore_lsx[7])); \ + asm volatile ("vst $vr8, %0" :"=m"(restore_lsx[8])); \ + asm volatile ("vst $vr9, %0" :"=m"(restore_lsx[9])); \ + asm volatile ("vst $vr10, %0" :"=m"(restore_lsx[10])); \ + asm volatile ("vst $vr11, %0" :"=m"(restore_lsx[11])); \ + asm volatile ("vst $vr12, %0" :"=m"(restore_lsx[12])); \ + asm volatile ("vst $vr13, %0" :"=m"(restore_lsx[13])); \ + asm volatile ("vst $vr14, %0" :"=m"(restore_lsx[14])); \ + asm volatile ("vst $vr15, %0" :"=m"(restore_lsx[15])); \ + asm volatile ("vst $vr16, %0" :"=m"(restore_lsx[16])); \ + asm volatile ("vst $vr17, %0" :"=m"(restore_lsx[17])); \ + asm volatile ("vst $vr18, %0" :"=m"(restore_lsx[18])); \ + asm volatile ("vst $vr19, %0" :"=m"(restore_lsx[19])); \ + asm volatile ("vst $vr20, %0" :"=m"(restore_lsx[20])); \ + asm volatile ("vst $vr21, %0" :"=m"(restore_lsx[21])); \ + asm volatile ("vst $vr22, %0" :"=m"(restore_lsx[22])); \ + asm volatile ("vst $vr23, %0" :"=m"(restore_lsx[23])); \ + asm volatile ("vst $vr24, %0" :"=m"(restore_lsx[24])); \ + asm volatile ("vst $vr25, %0" :"=m"(restore_lsx[25])); \ + asm volatile ("vst $vr26, %0" :"=m"(restore_lsx[26])); \ + asm volatile ("vst $vr27, %0" :"=m"(restore_lsx[27])); \ + asm volatile ("vst $vr28, %0" :"=m"(restore_lsx[28])); \ + asm volatile ("vst $vr29, %0" :"=m"(restore_lsx[29])); \ + asm volatile ("vst $vr30, %0" :"=m"(restore_lsx[30])); \ + asm volatile ("vst $vr31, %0" :"=m"(restore_lsx[31])); \ for (int i = 0; i < 32; i++) \ for (int j = 0; j < 4; j++) \ { \ src_lsx[i][j] = 0x01010101 * (i + 1); \ if (src_lsx[i][j] != restore_lsx[i][j]) \ - abort (); \ + { \ + printf ("LSX registers compare failed!\n"); \ + abort (); \ + } \ } #else #define SAVE_REGISTER_LSX() @@ -267,44 +278,48 @@ #define SAVE_REGISTER_LASX() \ int src_lasx[32][8]; \ int restore_lasx[32][8]; \ - asm volatile ("xvst $xr0, %0" :"=m"(restore_lasx[0]) :); \ - asm volatile ("xvst $xr1, %0" :"=m"(restore_lasx[1]) :); \ - asm volatile ("xvst $xr2, %0" :"=m"(restore_lasx[2]) :); \ - asm volatile ("xvst $xr3, %0" :"=m"(restore_lasx[3]) :); \ - asm volatile ("xvst $xr4, %0" :"=m"(restore_lasx[4]) :); \ - asm volatile ("xvst $xr5, %0" :"=m"(restore_lasx[5]) :); \ - asm volatile ("xvst $xr6, %0" :"=m"(restore_lasx[6]) :); \ - asm volatile ("xvst $xr7, %0" :"=m"(restore_lasx[7]) :); \ - asm volatile ("xvst $xr8, %0" :"=m"(restore_lasx[8]) :); \ - asm volatile ("xvst $xr9, %0" :"=m"(restore_lasx[9]) :); \ - asm volatile ("xvst $xr10, %0" :"=m"(restore_lasx[10]) :); \ - asm volatile ("xvst $xr11, %0" :"=m"(restore_lasx[11]) :); \ - asm volatile ("xvst $xr12, %0" :"=m"(restore_lasx[12]) :); \ - asm volatile ("xvst $xr13, %0" :"=m"(restore_lasx[13]) :); \ - asm volatile ("xvst $xr14, %0" :"=m"(restore_lasx[14]) :); \ - asm volatile ("xvst $xr15, %0" :"=m"(restore_lasx[15]) :); \ - asm volatile ("xvst $xr16, %0" :"=m"(restore_lasx[16]) :); \ - asm volatile ("xvst $xr17, %0" :"=m"(restore_lasx[17]) :); \ - asm volatile ("xvst $xr18, %0" :"=m"(restore_lasx[18]) :); \ - asm volatile ("xvst $xr19, %0" :"=m"(restore_lasx[19]) :); \ - asm volatile ("xvst $xr20, %0" :"=m"(restore_lasx[20]) :); \ - asm volatile ("xvst $xr21, %0" :"=m"(restore_lasx[21]) :); \ - asm volatile ("xvst $xr22, %0" :"=m"(restore_lasx[22]) :); \ - asm volatile ("xvst $xr23, %0" :"=m"(restore_lasx[23]) :); \ - asm volatile ("xvst $xr24, %0" :"=m"(restore_lasx[24]) :); \ - asm volatile ("xvst $xr25, %0" :"=m"(restore_lasx[25]) :); \ - asm volatile ("xvst $xr26, %0" :"=m"(restore_lasx[26]) :); \ - asm volatile ("xvst $xr27, %0" :"=m"(restore_lasx[27]) :); \ - asm volatile ("xvst $xr28, %0" :"=m"(restore_lasx[28]) :); \ - asm volatile ("xvst $xr29, %0" :"=m"(restore_lasx[29]) :); \ - asm volatile ("xvst $xr30, %0" :"=m"(restore_lasx[30]) :); \ - asm volatile ("xvst $xr31, %0" :"=m"(restore_lasx[31]) :); \ + asm volatile ("xvst $xr0, %0" :"=m"(restore_lasx[0])); \ + asm volatile ("xvst $xr1, %0" :"=m"(restore_lasx[1])); \ + asm volatile ("xvst $xr2, %0" :"=m"(restore_lasx[2])); \ + asm volatile ("xvst $xr3, %0" :"=m"(restore_lasx[3])); \ + asm volatile ("xvst $xr4, %0" :"=m"(restore_lasx[4])); \ + asm volatile ("xvst $xr5, %0" :"=m"(restore_lasx[5])); \ + asm volatile ("xvst $xr6, %0" :"=m"(restore_lasx[6])); \ + asm volatile ("xvst $xr7, %0" :"=m"(restore_lasx[7])); \ + asm volatile ("xvst $xr8, %0" :"=m"(restore_lasx[8])); \ + asm volatile ("xvst $xr9, %0" :"=m"(restore_lasx[9])); \ + asm volatile ("xvst $xr10, %0" :"=m"(restore_lasx[10])); \ + asm volatile ("xvst $xr11, %0" :"=m"(restore_lasx[11])); \ + asm volatile ("xvst $xr12, %0" :"=m"(restore_lasx[12])); \ + asm volatile ("xvst $xr13, %0" :"=m"(restore_lasx[13])); \ + asm volatile ("xvst $xr14, %0" :"=m"(restore_lasx[14])); \ + asm volatile ("xvst $xr15, %0" :"=m"(restore_lasx[15])); \ + asm volatile ("xvst $xr16, %0" :"=m"(restore_lasx[16])); \ + asm volatile ("xvst $xr17, %0" :"=m"(restore_lasx[17])); \ + asm volatile ("xvst $xr18, %0" :"=m"(restore_lasx[18])); \ + asm volatile ("xvst $xr19, %0" :"=m"(restore_lasx[19])); \ + asm volatile ("xvst $xr20, %0" :"=m"(restore_lasx[20])); \ + asm volatile ("xvst $xr21, %0" :"=m"(restore_lasx[21])); \ + asm volatile ("xvst $xr22, %0" :"=m"(restore_lasx[22])); \ + asm volatile ("xvst $xr23, %0" :"=m"(restore_lasx[23])); \ + asm volatile ("xvst $xr24, %0" :"=m"(restore_lasx[24])); \ + asm volatile ("xvst $xr25, %0" :"=m"(restore_lasx[25])); \ + asm volatile ("xvst $xr26, %0" :"=m"(restore_lasx[26])); \ + asm volatile ("xvst $xr27, %0" :"=m"(restore_lasx[27])); \ + asm volatile ("xvst $xr28, %0" :"=m"(restore_lasx[28])); \ + asm volatile ("xvst $xr29, %0" :"=m"(restore_lasx[29])); \ + asm volatile ("xvst $xr30, %0" :"=m"(restore_lasx[30])); \ + asm volatile ("xvst $xr31, %0" :"=m"(restore_lasx[31])); \ + /* memcmp_lasx/strlen_lasx corrupts LSX/LASX registers, */ \ for (int i = 0; i < 32; i++) \ for (int j = 0; j < 8; j++) \ { \ src_lasx[i][j] = 0x01010101 * (i + 1); \ if (src_lasx[i][j] != restore_lasx[i][j]) \ - abort (); \ + { \ + printf ("LASX registers compare failed!\n"); \ + abort (); \ + } \ } #else #define SAVE_REGISTER_LASX() @@ -314,9 +329,6 @@ uint64_t src; \ double src_float[32]; \ uint64_t src_fcc[8]; \ - for (int i = 0; i < 32; i++) \ - src_float[i] = i + 1; \ - \ SAVE_REGISTER (src); \ LOAD_REGISTER_FCSR (); \ SAVE_REGISTER_FCC(src_fcc) \ @@ -336,15 +348,25 @@ #define AFTER_TLSDESC_CALL() \ uint64_t restore; \ - uint64_t src_fcsr = 0x01010101; \ - uint64_t restore_fcsr; \ uint64_t restore_fcc[8]; \ + \ SAVE_REGISTER (restore); \ + if (src != restore) \ + { \ + printf ("General registers compare failed!\n"); \ + abort (); \ + } \ + \ SAVE_REGISTER_FCSR (); \ + \ SAVE_REGISTER_FCC(restore_fcc) \ + for (int i = 0; i < 8; i++) \ + if (src_fcc[i] != restore_fcc[i]) \ + { \ + printf ("FCC registers compare failed!\n"); \ + abort (); \ + } \ \ - /* memcmp_lasx/strlen_lasx corrupts LSX/LASX registers, */ \ - /* compare LSX/LASX registers first. */ \ if (hwcap & HWCAP_LOONGARCH_LASX) \ { \ SAVE_REGISTER_LASX (); \ @@ -355,22 +377,8 @@ } \ else \ { \ - double restore_float[32]; \ SAVE_REGISTER_FLOAT (); \ - \ - for (int i = 0; i < 32; i++) \ - if (src_float[i] != restore_float[i]) \ - abort (); \ } \ - \ - if (src_fcsr != restore_fcsr) \ - abort (); \ - \ - if (memcmp (src_fcc, restore_fcc, sizeof (src_fcc)) != 0) \ - abort (); \ - \ - if (src != restore) \ - abort (); #endif /* #ifdef __loongarch_soft_float */