mirror of
https://github.com/rdolbeau/VexRiscvBPluginGenerator.git
synced 2025-04-18 18:44:42 -04:00
more systematic synthetic tests
This commit is contained in:
parent
63aa6881f4
commit
86c0e2b282
4 changed files with 877 additions and 901 deletions
8
Makefile
8
Makefile
|
@ -136,7 +136,7 @@ include r5.mk
|
|||
|
||||
NEWINST_H=new_instructions_support_b.h new_instructions_support.h new_instructions_support_k.h new_instructions_support_p.h
|
||||
|
||||
tests: test_b test_p
|
||||
tests: test_b test_p test_b.txt test_p.txt
|
||||
|
||||
signal.o: signal.c
|
||||
$(R5IMA_GCC) $(R5IMA_OPT) -c $< -o $@
|
||||
|
@ -159,6 +159,12 @@ test_b: test_b.o signal.o
|
|||
test_p: test_p.o signal.o
|
||||
$(R5IMA_GCC) $(R5IMA_OPT) $^ -o $@
|
||||
|
||||
test_b.txt: test_b.c
|
||||
gcc -I. -O2 $< -o /tmp/a.out && /tmp/a.out | tee $@
|
||||
|
||||
test_p.txt: test_p.c
|
||||
gcc -I. -O2 $< -o /tmp/a.out && /tmp/a.out | tee $@
|
||||
|
||||
## avoid builtin rule for .o
|
||||
.SUFFIXES:
|
||||
SUFFIXES :=
|
||||
|
|
87
test_b.c
87
test_b.c
|
@ -29,6 +29,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#ifdef __riscv
|
||||
|
||||
#include "new_instructions_support_b.h"
|
||||
|
@ -95,23 +97,13 @@ static inline int64_t _rv64_clmul2(int64_t rs1, int64_t rs2)
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
unsigned int a = 0x01234567;
|
||||
|
||||
//#define CHECK_SIGILL
|
||||
|
||||
#if defined(CHECK_SIGILL)
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf jb;
|
||||
void installillhandler(void);
|
||||
#endif // CHECK_SIGILL
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
unsigned int b = 0xdeadbeef;
|
||||
unsigned int c;
|
||||
unsigned int d = 0xC0FFEE00;
|
||||
unsigned int index;
|
||||
unsigned int index2;
|
||||
unsigned int index, index1, index2, index3;
|
||||
|
||||
#if defined(CHECK_SIGILL)
|
||||
installillhandler();
|
||||
|
@ -124,51 +116,18 @@ int main(int argc, char **argv) {
|
|||
if (argc > 3)
|
||||
d = strtoul(argv[3], NULL, 16);
|
||||
|
||||
#if !defined(CHECK_SIGILL)
|
||||
#define T2(X) \
|
||||
c = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c)
|
||||
#define T1(X) \
|
||||
c = X(a);printf(#X "(0x%08x) -> 0x%08x\n", a, c)
|
||||
#define T3(X) \
|
||||
c = X(a,b,d);printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c)
|
||||
#define T2W(X) \
|
||||
cq = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq)
|
||||
#else
|
||||
#define T2(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
c = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T1(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x) -> *SIGILL*\n", a); \
|
||||
} else { \
|
||||
c = X(a); \
|
||||
printf(#X "(0x%08x) -> 0x%08x\n", a, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T3(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> *SIGILL*\n", a, b, d); \
|
||||
} else { \
|
||||
c = X(a,b,d); \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T2W(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
cq = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif // CHECK_SIGILL
|
||||
for (index = 0 ; index < nonrandom_cnt[0] ; index++) {
|
||||
a = nonrandom_a[index];
|
||||
|
||||
for (index = 0 ; index < 32 ; index++) {
|
||||
T1(_rv32_sext_b);
|
||||
T1(_rv32_sext_h);
|
||||
|
||||
T1(_rv32_clz);
|
||||
T1(_rv32_ctz);
|
||||
T1(_rv32_pcnt);
|
||||
|
||||
for (index1 = 0 ; index1 < nonrandom_cnt[1] ; index1++) {
|
||||
b = nonrandom_b[index1];
|
||||
|
||||
T2(_rv32_ror);
|
||||
T2(_rv32_rol);
|
||||
|
@ -206,13 +165,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
//T2(_rv32_xperm_b);
|
||||
|
||||
T1(_rv32_sext_b);
|
||||
T1(_rv32_sext_h);
|
||||
|
||||
T1(_rv32_clz);
|
||||
T1(_rv32_ctz);
|
||||
T1(_rv32_pcnt);
|
||||
|
||||
T2(_rv32_clmul);
|
||||
T2(_rv32_clmulr);
|
||||
T2(_rv32_clmulh);
|
||||
|
@ -239,16 +191,20 @@ int main(int argc, char **argv) {
|
|||
T2(xperm_b);
|
||||
T2(xperm_h);
|
||||
|
||||
T2(_rv32_bfp);
|
||||
|
||||
for (index2 = 0 ; index2 < nonrandom_cnt[2] ; index2++) {
|
||||
d = nonrandom_d[index2];
|
||||
T3(_rv_cmix);
|
||||
T3(_rv_cmov);
|
||||
|
||||
T3(_rv32_fsl);
|
||||
T3(_rv32_fsr);
|
||||
|
||||
T2(_rv32_bfp);
|
||||
|
||||
b = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
#if defined(CHECK_SIGILL)
|
||||
if (setjmp(jb)) {
|
||||
printf("bfp: **SIGILL**\n");
|
||||
|
@ -276,6 +232,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
65
test_common.h
Normal file
65
test_common.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
#ifndef __TEST_COMMON_H__
|
||||
#define __TEST_COMMON_H__
|
||||
|
||||
#if !defined(CHECK_SIGILL)
|
||||
#define T2(X) \
|
||||
c = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c)
|
||||
#define T1(X) \
|
||||
c = X(a);printf(#X "(0x%08x) -> 0x%08x\n", a, c)
|
||||
#define T3(X) \
|
||||
c = X(a,b,d);printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c)
|
||||
#define T2W(X) \
|
||||
cq = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq)
|
||||
#else
|
||||
#define T2(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
c = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T1(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x) -> *SIGILL*\n", a); \
|
||||
} else { \
|
||||
c = X(a); \
|
||||
printf(#X "(0x%08x) -> 0x%08x\n", a, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T3(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> *SIGILL*\n", a, b, d); \
|
||||
} else { \
|
||||
c = X(a,b,d); \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T2W(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
cq = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf jb;
|
||||
void installillhandler(void);
|
||||
|
||||
#endif // CHECK_SIGILL
|
||||
|
||||
const unsigned int nonrandom_a[15] = { 0x01234567, 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
0x80000000, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFF7FFF,
|
||||
0x7F7F7F7F, 0x80808080 };
|
||||
const unsigned int nonrandom_b[15] = { 0xdeadbeef, 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
0x80000000, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFF7FFF,
|
||||
0x7F7F7F7F, 0x80808080 };
|
||||
const unsigned int nonrandom_d[14] = { 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
0x80000000, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFF7FFF,
|
||||
0x7F7F7F7F, 0x80808080 };
|
||||
|
||||
const int nonrandom_cnt[4] = { 15, 14, 14};
|
||||
|
||||
#endif // __TEST_COMMON_H__
|
118
test_p.c
118
test_p.c
|
@ -13,6 +13,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#ifdef __riscv
|
||||
|
||||
#include "new_instructions_support_p.h"
|
||||
|
@ -100,7 +102,7 @@ uint32_t __rv__clo8(const uint32_t rs1) {
|
|||
return r;
|
||||
}
|
||||
uint32_t __rv__clrs8(const uint32_t rs1) {
|
||||
uint4x8_t a, c;
|
||||
int4x8_t a, c;
|
||||
uint32_t r;
|
||||
memcpy(a, &rs1, 4);
|
||||
c[0] = __builtin_clrsb((int32_t)a[0]) - 24;
|
||||
|
@ -785,87 +787,45 @@ GEN_ZUNPKD8(3,2)
|
|||
|
||||
unsigned int a = 0x01234567;
|
||||
|
||||
//#define CHECK_SIGILL
|
||||
|
||||
#if defined(CHECK_SIGILL)
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf jb;
|
||||
void installillhandler(void);
|
||||
#endif // CHECK_SIGILL
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
unsigned int b = 0xdeadbeef;
|
||||
unsigned int c = 0;
|
||||
unsigned int d = 0xC0FFEE00;
|
||||
unsigned int index;
|
||||
unsigned int index2;
|
||||
unsigned int index, index1, index2, index3;
|
||||
unsigned long long cq = 0;
|
||||
|
||||
#if defined(CHECK_SIGILL)
|
||||
installillhandler();
|
||||
#endif // CHECK_SIGILL
|
||||
for (index = 0 ; index < nonrandom_cnt[0] ; index++) {
|
||||
a = nonrandom_a[index];
|
||||
|
||||
if (argc > 1)
|
||||
a = strtoul(argv[1], NULL, 16);
|
||||
if (argc > 2)
|
||||
b = strtoul(argv[2], NULL, 16);
|
||||
if (argc > 3)
|
||||
d = strtoul(argv[3], NULL, 16);
|
||||
T1(__rv__sunpkd810);
|
||||
T1(__rv__sunpkd820);
|
||||
T1(__rv__sunpkd830);
|
||||
T1(__rv__sunpkd831);
|
||||
T1(__rv__sunpkd832);
|
||||
T1(__rv__zunpkd810);
|
||||
T1(__rv__zunpkd820);
|
||||
T1(__rv__zunpkd830);
|
||||
T1(__rv__zunpkd831);
|
||||
T1(__rv__zunpkd832);
|
||||
|
||||
#if !defined(CHECK_SIGILL)
|
||||
#define T2(X) \
|
||||
c = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c)
|
||||
#define T1(X) \
|
||||
c = X(a);printf(#X "(0x%08x) -> 0x%08x\n", a, c)
|
||||
#define T3(X) \
|
||||
c = X(a,b,d);printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c)
|
||||
#define T2W(X) \
|
||||
cq = X(a,b);printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq)
|
||||
#else
|
||||
#define T2(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
c = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%08x\n", a, b, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T1(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x) -> *SIGILL*\n", a); \
|
||||
} else { \
|
||||
c = X(a); \
|
||||
printf(#X "(0x%08x) -> 0x%08x\n", a, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T3(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> *SIGILL*\n", a, b, d); \
|
||||
} else { \
|
||||
c = X(a,b,d); \
|
||||
printf(#X "(0x%08x, 0x%08x, 0x%08x) -> 0x%08x\n", a, b, d, c); \
|
||||
} \
|
||||
} while (0)
|
||||
#define T2W(X) do { \
|
||||
if (setjmp(jb)) { \
|
||||
printf(#X "(0x%08x, 0x%08x) -> *SIGILL*\n", a, b); \
|
||||
} else { \
|
||||
cq = X(a,b); \
|
||||
printf(#X "(0x%08x, 0x%08x) -> 0x%016llx\n", a, b, cq); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif // CHECK_SIGILL
|
||||
T1(__rv__clz8);
|
||||
T1(__rv__clo8);
|
||||
T1(__rv__clrs8);
|
||||
T1(__rv__swap8);
|
||||
|
||||
for (index = 0 ; index < 32 ; index++) {
|
||||
//T1(__rv__clz16); /* unimplemented */
|
||||
//T1(__rv__clo16); /* unimplemented */
|
||||
//T1(__rv__clrs16); /* unimplemented */
|
||||
T1(__rv__swap16);
|
||||
|
||||
for (index1 = 0 ; index1 < nonrandom_cnt[1] ; index1++) {
|
||||
b = nonrandom_b[index];
|
||||
#if 1
|
||||
T2(__rv__add8);
|
||||
T2(__rv__radd8);
|
||||
T2(__rv__rsub8);
|
||||
T2(__rv__cmpeq8);
|
||||
T1(__rv__clz8);
|
||||
T1(__rv__clo8);
|
||||
T1(__rv__clrs8);
|
||||
T1(__rv__swap8);
|
||||
|
||||
T2(__rv__scmple8);
|
||||
T2(__rv__scmplt8);
|
||||
T2(__rv__sll8);
|
||||
|
@ -884,10 +844,7 @@ int main(int argc, char **argv) {
|
|||
T2(__rv__radd16);
|
||||
T2(__rv__rsub16);
|
||||
T2(__rv__cmpeq16);
|
||||
//T1(__rv__clz16); /* unimplemented */
|
||||
//T1(__rv__clo16); /* unimplemented */
|
||||
//T1(__rv__clrs16); /* unimplemented */
|
||||
T1(__rv__swap16);
|
||||
|
||||
T2(__rv__scmple16);
|
||||
T2(__rv__scmplt16);
|
||||
T2(__rv__sll16);
|
||||
|
@ -931,24 +888,15 @@ int main(int argc, char **argv) {
|
|||
T2W(__rv__smulx16);
|
||||
T2W(__rv__umulx16);
|
||||
|
||||
for (index2 = 0 ; index2 < nonrandom_cnt[2] ; index2++) {
|
||||
d = nonrandom_d[index2];
|
||||
T3(__rv__smaqa);
|
||||
T3(__rv__umaqa);
|
||||
|
||||
T3(__rv__maddr32);
|
||||
T3(__rv__msubr32);
|
||||
|
||||
T1(__rv__sunpkd810);
|
||||
T1(__rv__sunpkd820);
|
||||
T1(__rv__sunpkd830);
|
||||
T1(__rv__sunpkd831);
|
||||
T1(__rv__sunpkd832);
|
||||
T1(__rv__zunpkd810);
|
||||
T1(__rv__zunpkd820);
|
||||
T1(__rv__zunpkd830);
|
||||
T1(__rv__zunpkd831);
|
||||
T1(__rv__zunpkd832);
|
||||
|
||||
b = 0x0100F004 + index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue