From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7877) id 7A8903858CDA; Thu, 14 Sep 2023 00:44:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A8903858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694652269; bh=CM14MXyA/1fYwpL+vK74IQgLNSrzEWS8Og/LXh7hJGI=; h=From:To:Subject:Date:From; b=pv7tr/ckBiW/+7X9Bm3xtcHVCczfvDtw0Dw9FFzyWfB6GcJh+mu5vUVuLRUvuO2Jh 7RiVgRbhqzahL5zg7V4NQvPZH/0vFWdenIYVgIPE98sLS5TfVYCZQqLTyM2w2/F9m7 6Tp0IY/7R/5rkqHXgHG4h31/ePAkvtBu4N786c3o= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: LuluCheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-3929] LoongArch: Add testsuite framework for Loongson SX/ASX. X-Act-Checkin: gcc X-Git-Author: Xiaolong Chen X-Git-Refname: refs/heads/master X-Git-Oldrev: 4fedd6b14d90ab17bdb5a8ddf50c17560520d3b3 X-Git-Newrev: a53d7133616dbcdd95ee7376ae382933fac8fd66 Message-Id: <20230914004429.7A8903858CDA@sourceware.org> Date: Thu, 14 Sep 2023 00:44:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a53d7133616dbcdd95ee7376ae382933fac8fd66 commit r14-3929-ga53d7133616dbcdd95ee7376ae382933fac8fd66 Author: Xiaolong Chen Date: Mon Sep 11 09:36:35 2023 +0800 LoongArch: Add testsuite framework for Loongson SX/ASX. gcc/testsuite/ChangeLog: * gcc.target/loongarch/vector/loongarch-vector.exp: New test. * gcc.target/loongarch/vector/simd_correctness_check.h: New test. Diff: --- .../loongarch/vector/loongarch-vector.exp | 42 +++++++++++++++++ .../loongarch/vector/simd_correctness_check.h | 54 ++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp b/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp new file mode 100644 index 000000000000..2c37aa91d4ce --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp @@ -0,0 +1,42 @@ +#Copyright(C) 2023 Free Software Foundation, Inc. + +#This program is free software; you can redistribute it and / or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3 of the License, or +#(at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with GCC; see the file COPYING3.If not see +# . + +#GCC testsuite that uses the `dg.exp' driver. + +#Exit immediately if this isn't a LoongArch target. +if ![istarget loongarch*-*-*] then { + return +} + +#Load support procs. +load_lib gcc-dg.exp + +#If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " " +} + +#Initialize `dg'. +dg-init + +#Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/lsx/*.\[cS\]]] \ + " -mlsx" $DEFAULT_CFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/lasx/*.\[cS\]]] \ + " -mlasx" $DEFAULT_CFLAGS +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h b/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h new file mode 100644 index 000000000000..eb7fbd59cc73 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h @@ -0,0 +1,54 @@ +#include +#include +#include + +#define ASSERTEQ_64(line, ref, res) \ + do \ + { \ + int fail = 0; \ + for (size_t i = 0; i < sizeof (res) / sizeof (res[0]); ++i) \ + { \ + long *temp_ref = &ref[i], *temp_res = &res[i]; \ + if (abs (*temp_ref - *temp_res) > 0) \ + { \ + printf (" error: %s at line %ld , expected " #ref \ + "[%ld]:0x%lx, got: 0x%lx\n", \ + __FILE__, line, i, *temp_ref, *temp_res); \ + fail = 1; \ + } \ + } \ + if (fail == 1) \ + abort (); \ + } \ + while (0) + +#define ASSERTEQ_32(line, ref, res) \ + do \ + { \ + int fail = 0; \ + for (size_t i = 0; i < sizeof (res) / sizeof (res[0]); ++i) \ + { \ + int *temp_ref = &ref[i], *temp_res = &res[i]; \ + if (abs (*temp_ref - *temp_res) > 0) \ + { \ + printf (" error: %s at line %ld , expected " #ref \ + "[%ld]:0x%x, got: 0x%x\n", \ + __FILE__, line, i, *temp_ref, *temp_res); \ + fail = 1; \ + } \ + } \ + if (fail == 1) \ + abort (); \ + } \ + while (0) + +#define ASSERTEQ_int(line, ref, res) \ + do \ + { \ + if (ref != res) \ + { \ + printf (" error: %s at line %ld , expected %d, got %d\n", __FILE__, \ + line, ref, res); \ + } \ + } \ + while (0)