From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id DDE083894C27 for ; Fri, 21 Jun 2024 08:09:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DDE083894C27 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 DDE083894C27 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=1718957350; cv=none; b=Izc8iYVw7KvxHC1VXHbtjSEd33p4TtgyBYE3ULYGpUcr8ONxKr7nRVQ/pETYyS+UO4EPPdqBJSluQIr+3OGcTbAnwZetMakJz1AVJ3eZt62A3+bniz+TcCy/HD+/5gKm/bUmUDOipsuVDPD1MbWAmYchLkqo4ix/E/ZBDXSW6wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718957350; c=relaxed/simple; bh=rtJWWAlrCK1md3oba50+/Ev5n6mTwvMjAtq+YDSSzdw=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=DyJ85uqwGo5DkxFHw3sy50CayN/yUXbbufbsyQzhn2EhA5GJhumXnJgo6IDCwKnm+N2wsCVkb1uynFxW+NHYHyN+h0OSR51FPm/bq0CzZgcwxH0kA7YPhmkGjx0hzyl7JbakITsbYh4tEItq/3/nDtPc+7e6mG3GQ6dWrnMcx5s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8DxP_AaNXVmW84IAA--.35686S3; Fri, 21 Jun 2024 16:08:58 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx08QWNXVmPEMrAA--.28127S2; Fri, 21 Jun 2024 16:08:55 +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 v3] LoongArch: Fix tst-gnu2-tls2 test case Date: Fri, 21 Jun 2024 16:08:53 +0800 Message-Id: <20240621080853.3610846-1-mengqinggang@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:AQAAf8Bx08QWNXVmPEMrAA--.28127S2 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj9fXoW3ZFWxCr1kGw1rCw15AF47trc_yoW8CF1rWo Wq9rn5W3W7t347XFn7Ca43Zrya9FsI9rs5Gr1jgr17CFy2vFWUK3yUCFZFvF93ZF45Kr9r WryfXrs8C3yYka4Ul-sFpf9Il3svdjkaLaAFLSUrUUUU1b8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUYy7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUGVWUXwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AK xVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVF xhVjvjDU0xZFpf9x07je0PfUUUUU= 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. Comparing float value using memcmp because float value cannot be directly compared for equality. Put LOAD_REGISTER_FCSR and SAVE_REGISTER_FCC after LOAD_REGISTER_FLOAT. Some float instructions may change fcsr register. --- Changes v1 -> v2: - Comparing float value using memcmp. - Put LOAD_REGISTER_FCSR and SAVE_REGISTER_FCC after LOAD_REGISTER_FLOAT. Changes v0 -> v1: - Use one line inline assembly to save fcsr/fcc registers. sysdeps/loongarch/tst-gnu2-tls2.h | 296 +++++++++++++++--------------- 1 file changed, 153 insertions(+), 143 deletions(-) diff --git a/sysdeps/loongarch/tst-gnu2-tls2.h b/sysdeps/loongarch/tst-gnu2-tls2.h index 8e4216785d..863abe597e 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,44 @@ 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])); \ + if (memcmp (src_float, restore_float, sizeof (src_float)) != 0) \ + { \ + printf ("Float registers compare failed!\n"); \ + abort (); \ + } #ifdef HAVE_LOONGARCH_VEC_COM #define LOAD_REGISTER_LSX() \ @@ -181,44 +188,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 +277,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,12 +328,7 @@ 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) \ \ if (hwcap & HWCAP_LOONGARCH_LASX) \ { \ @@ -332,19 +341,34 @@ else \ { \ LOAD_REGISTER_FLOAT (); \ - } + } \ + \ + /* LOAD_REGISTER_FLOAT convert int double may change fcsr. */ \ + LOAD_REGISTER_FCSR (); \ + SAVE_REGISTER_FCC (src_fcc) + #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) \ \ - /* memcmp_lasx/strlen_lasx corrupts LSX/LASX registers, */ \ - /* compare LSX/LASX registers first. */ \ + 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 (); \ + } \ + \ if (hwcap & HWCAP_LOONGARCH_LASX) \ { \ SAVE_REGISTER_LASX (); \ @@ -355,22 +379,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 */ -- 2.38.1