[PATCH v2 2/4] LoongArch: Add testsuite framework for Loongson SX/ASX.

Xi Ruoyao xry111@xry111.site
Thu Sep 7 07:49:36 GMT 2023


On Thu, 2023-09-07 at 15:00 +0800, Xiaolong Chen wrote:

/* snip */

> 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 00000000000..7be199ee3a0
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/vector/simd_correctness_check.h

Please reformat with GNU style (maybe using clang-format --style=GNU).

> @@ -0,0 +1,39 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#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) 

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Gcc-patches mailing list