From 937c897942aa193787f9c5da958fdc29c9b4587b Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 14 Dec 2023 13:51:04 +0800 Subject: [PATCH] Add missing tests --- code/gen_impl.py | 8 +++++++- code/xvinsve0_d.cpp | 13 +++++++++++++ code/xvinsve0_w.cpp | 13 +++++++++++++ code/xvperm_w.cpp | 13 +++++++++++++ code/xvperm_w.h | 2 +- code/xvpermi_d.cpp | 14 ++++++++++++++ code/xvpermi_q.cpp | 16 ++++++++++++++++ code/xvpermi_q.h | 7 +++---- code/xvpermi_w.cpp | 14 ++++++++++++++ code/xvpickve_d.cpp | 14 ++++++++++++++ code/xvpickve_d_f.cpp | 14 ++++++++++++++ code/xvpickve_w.cpp | 14 ++++++++++++++ code/xvpickve_w_f.cpp | 14 ++++++++++++++ code/xvrepl128vei_b.cpp | 14 ++++++++++++++ code/xvrepl128vei_b.h | 5 ++++- code/xvrepl128vei_d.cpp | 12 ++++++++++++ code/xvrepl128vei_d.h | 5 ++++- code/xvrepl128vei_h.cpp | 14 ++++++++++++++ code/xvrepl128vei_h.h | 5 ++++- code/xvrepl128vei_w.cpp | 14 ++++++++++++++ code/xvrepl128vei_w.h | 5 ++++- code/xvreplve0_b.cpp | 11 +++++++++++ code/xvreplve0_d.cpp | 11 +++++++++++ code/xvreplve0_h.cpp | 11 +++++++++++ code/xvreplve0_q.cpp | 11 +++++++++++ code/xvreplve0_w.cpp | 11 +++++++++++ 26 files changed, 275 insertions(+), 10 deletions(-) create mode 100644 code/xvinsve0_d.cpp create mode 100644 code/xvinsve0_w.cpp create mode 100644 code/xvperm_w.cpp create mode 100644 code/xvpermi_d.cpp create mode 100644 code/xvpermi_q.cpp create mode 100644 code/xvpermi_w.cpp create mode 100644 code/xvpickve_d.cpp create mode 100644 code/xvpickve_d_f.cpp create mode 100644 code/xvpickve_w.cpp create mode 100644 code/xvpickve_w_f.cpp create mode 100644 code/xvrepl128vei_b.cpp create mode 100644 code/xvrepl128vei_d.cpp create mode 100644 code/xvrepl128vei_h.cpp create mode 100644 code/xvrepl128vei_w.cpp create mode 100644 code/xvreplve0_b.cpp create mode 100644 code/xvreplve0_d.cpp create mode 100644 code/xvreplve0_h.cpp create mode 100644 code/xvreplve0_q.cpp create mode 100644 code/xvreplve0_w.cpp diff --git a/code/gen_impl.py b/code/gen_impl.py index 041910e7..5f681a2f 100644 --- a/code/gen_impl.py +++ b/code/gen_impl.py @@ -1262,12 +1262,18 @@ print(f"}}", file=f) else: with open(f"{prefix}repl128vei_{width}.h", "w") as f: - print(f"for (int i = 0;i < {vlen // w};i++) {{", file=f) + print(f"for (int i = 0;i < {vlen // 2 // w};i++) {{", file=f) print( f" dst.{m}[i] = a.{m}[idx];", file=f, ) print(f"}}", file=f) + print(f"for (int i = {vlen // 2 // w};i < {vlen // w};i++) {{", file=f) + print( + f" dst.{m}[i] = a.{m}[idx + {vlen // 2 // w}];", + file=f, + ) + print(f"}}", file=f) with open(f"{prefix}replgr2vr_{width}.h", "w") as f: print(f"for (int i = 0;i < {vlen // w};i++) {{", file=f) print( diff --git a/code/xvinsve0_d.cpp b/code/xvinsve0_d.cpp new file mode 100644 index 00000000..a3e969bd --- /dev/null +++ b/code/xvinsve0_d.cpp @@ -0,0 +1,13 @@ +#include "common.h" + +v256 xvinsve0_d(v256 a, v256 b, int imm) { + v256 dst; +#include "xvinsve0_d.h" + return dst; +} + +void test() { + XFUZZ2(xvinsve0_d, 0); + XFUZZ2(xvinsve0_d, 1); + XFUZZ2(xvinsve0_d, 2); +} diff --git a/code/xvinsve0_w.cpp b/code/xvinsve0_w.cpp new file mode 100644 index 00000000..beed2bec --- /dev/null +++ b/code/xvinsve0_w.cpp @@ -0,0 +1,13 @@ +#include "common.h" + +v256 xvinsve0_w(v256 a, v256 b, int imm) { + v256 dst; +#include "xvinsve0_w.h" + return dst; +} + +void test() { + XFUZZ2(xvinsve0_w, 0); + XFUZZ2(xvinsve0_w, 1); + XFUZZ2(xvinsve0_w, 2); +} diff --git a/code/xvperm_w.cpp b/code/xvperm_w.cpp new file mode 100644 index 00000000..bccacdf4 --- /dev/null +++ b/code/xvperm_w.cpp @@ -0,0 +1,13 @@ +#include "common.h" + +v256 xvperm_w(v256 a, v256 b) { + v256 dst; +#include "xvperm_w.h" + return dst; +} + +void test() { + XFUZZ2(xvperm_w); + XFUZZ2(xvperm_w); + XFUZZ2(xvperm_w); +} diff --git a/code/xvperm_w.h b/code/xvperm_w.h index 8c5fa4e8..e97175ff 100644 --- a/code/xvperm_w.h +++ b/code/xvperm_w.h @@ -1,3 +1,3 @@ for (int i = 0; i < 8; i++) { - dst.word[i] = a.word[b.word[i] & 0x8]; + dst.word[i] = a.word[b.word[i] % 0x8]; } \ No newline at end of file diff --git a/code/xvpermi_d.cpp b/code/xvpermi_d.cpp new file mode 100644 index 00000000..b671ed44 --- /dev/null +++ b/code/xvpermi_d.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpermi_d(v256 a, int imm) { + v256 dst; +#include "xvpermi_d.h" + return dst; +} + +void test() { + XFUZZ1(xvpermi_d, 0); + XFUZZ1(xvpermi_d, 1); + XFUZZ1(xvpermi_d, 2); + XFUZZ1(xvpermi_d, 0xFF); +} diff --git a/code/xvpermi_q.cpp b/code/xvpermi_q.cpp new file mode 100644 index 00000000..2e8eb281 --- /dev/null +++ b/code/xvpermi_q.cpp @@ -0,0 +1,16 @@ +#include "common.h" + +v256 xvpermi_q(v256 a, v256 b, int imm) { + v256 dst; +#include "xvpermi_q.h" + return dst; +} + +void test() { + XFUZZ2(xvpermi_q, 0); + XFUZZ2(xvpermi_q, 1); + XFUZZ2(xvpermi_q, 2); + XFUZZ2(xvpermi_q, 0x10); + XFUZZ2(xvpermi_q, 0xF0); + XFUZZ2(xvpermi_q, 0xFF); +} diff --git a/code/xvpermi_q.h b/code/xvpermi_q.h index 8eb08bb0..451f8d0c 100644 --- a/code/xvpermi_q.h +++ b/code/xvpermi_q.h @@ -1,4 +1,3 @@ -dst.word[0] = b.word[imm & 0x3]; -dst.word[1] = b.word[(imm >> 2) & 0x3]; -dst.word[2] = a.word[(imm >> 4) & 0x3]; -dst.word[3] = a.word[(imm >> 6) & 0x3]; +dst.qword[0] = (imm & 2) ? a.qword[imm & 0x1] : b.qword[imm & 0x1]; +dst.qword[1] = + (imm & 0x20) ? a.qword[(imm >> 4) & 0x1] : b.qword[(imm >> 4) & 0x1]; diff --git a/code/xvpermi_w.cpp b/code/xvpermi_w.cpp new file mode 100644 index 00000000..12323250 --- /dev/null +++ b/code/xvpermi_w.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpermi_w(v256 a, v256 b, int imm) { + v256 dst; +#include "xvpermi_w.h" + return dst; +} + +void test() { + XFUZZ2(xvpermi_w, 0); + XFUZZ2(xvpermi_w, 1); + XFUZZ2(xvpermi_w, 2); + XFUZZ2(xvpermi_w, 0xFF); +} diff --git a/code/xvpickve_d.cpp b/code/xvpickve_d.cpp new file mode 100644 index 00000000..30c3e1e9 --- /dev/null +++ b/code/xvpickve_d.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpickve_d(v256 a, int imm) { + v256 dst; +#include "xvpickve_d.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve_d, 0); + XFUZZ1(xvpickve_d, 1); + XFUZZ1(xvpickve_d, 2); + XFUZZ1(xvpickve_d, 3); +} diff --git a/code/xvpickve_d_f.cpp b/code/xvpickve_d_f.cpp new file mode 100644 index 00000000..835a1433 --- /dev/null +++ b/code/xvpickve_d_f.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpickve_d_f(v256 a, int imm) { + v256 dst; +#include "xvpickve_d_f.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve_d_f, 0); + XFUZZ1(xvpickve_d_f, 1); + XFUZZ1(xvpickve_d_f, 2); + XFUZZ1(xvpickve_d_f, 3); +} diff --git a/code/xvpickve_w.cpp b/code/xvpickve_w.cpp new file mode 100644 index 00000000..0aae5091 --- /dev/null +++ b/code/xvpickve_w.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpickve_w(v256 a, int imm) { + v256 dst; +#include "xvpickve_w.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve_w, 0); + XFUZZ1(xvpickve_w, 1); + XFUZZ1(xvpickve_w, 2); + XFUZZ1(xvpickve_w, 3); +} diff --git a/code/xvpickve_w_f.cpp b/code/xvpickve_w_f.cpp new file mode 100644 index 00000000..0aae5091 --- /dev/null +++ b/code/xvpickve_w_f.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvpickve_w(v256 a, int imm) { + v256 dst; +#include "xvpickve_w.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve_w, 0); + XFUZZ1(xvpickve_w, 1); + XFUZZ1(xvpickve_w, 2); + XFUZZ1(xvpickve_w, 3); +} diff --git a/code/xvrepl128vei_b.cpp b/code/xvrepl128vei_b.cpp new file mode 100644 index 00000000..1193f620 --- /dev/null +++ b/code/xvrepl128vei_b.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvrepl128vei_b(v256 a, int idx) { + v256 dst; +#include "xvrepl128vei_b.h" + return dst; +} + +void test() { + XFUZZ1(xvrepl128vei_b, 0); + XFUZZ1(xvrepl128vei_b, 1); + XFUZZ1(xvrepl128vei_b, 2); + XFUZZ1(xvrepl128vei_b, 3); +} diff --git a/code/xvrepl128vei_b.h b/code/xvrepl128vei_b.h index 965b15ce..bb2064ae 100644 --- a/code/xvrepl128vei_b.h +++ b/code/xvrepl128vei_b.h @@ -1,3 +1,6 @@ -for (int i = 0; i < 32; i++) { +for (int i = 0; i < 16; i++) { dst.byte[i] = a.byte[idx]; } +for (int i = 16; i < 32; i++) { + dst.byte[i] = a.byte[idx + 16]; +} diff --git a/code/xvrepl128vei_d.cpp b/code/xvrepl128vei_d.cpp new file mode 100644 index 00000000..5b0901e9 --- /dev/null +++ b/code/xvrepl128vei_d.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +v256 xvrepl128vei_d(v256 a, int idx) { + v256 dst; +#include "xvrepl128vei_d.h" + return dst; +} + +void test() { + XFUZZ1(xvrepl128vei_d, 0); + XFUZZ1(xvrepl128vei_d, 1); +} diff --git a/code/xvrepl128vei_d.h b/code/xvrepl128vei_d.h index fbb3bc0c..4dd3e9a1 100644 --- a/code/xvrepl128vei_d.h +++ b/code/xvrepl128vei_d.h @@ -1,3 +1,6 @@ -for (int i = 0; i < 4; i++) { +for (int i = 0; i < 2; i++) { dst.dword[i] = a.dword[idx]; } +for (int i = 2; i < 4; i++) { + dst.dword[i] = a.dword[idx + 2]; +} diff --git a/code/xvrepl128vei_h.cpp b/code/xvrepl128vei_h.cpp new file mode 100644 index 00000000..dc1a9533 --- /dev/null +++ b/code/xvrepl128vei_h.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvrepl128vei_h(v256 a, int idx) { + v256 dst; +#include "xvrepl128vei_h.h" + return dst; +} + +void test() { + XFUZZ1(xvrepl128vei_h, 0); + XFUZZ1(xvrepl128vei_h, 1); + XFUZZ1(xvrepl128vei_h, 2); + XFUZZ1(xvrepl128vei_h, 3); +} diff --git a/code/xvrepl128vei_h.h b/code/xvrepl128vei_h.h index 979487d1..61eebaee 100644 --- a/code/xvrepl128vei_h.h +++ b/code/xvrepl128vei_h.h @@ -1,3 +1,6 @@ -for (int i = 0; i < 16; i++) { +for (int i = 0; i < 8; i++) { dst.half[i] = a.half[idx]; } +for (int i = 8; i < 16; i++) { + dst.half[i] = a.half[idx + 8]; +} diff --git a/code/xvrepl128vei_w.cpp b/code/xvrepl128vei_w.cpp new file mode 100644 index 00000000..a6d8a33b --- /dev/null +++ b/code/xvrepl128vei_w.cpp @@ -0,0 +1,14 @@ +#include "common.h" + +v256 xvrepl128vei_w(v256 a, int idx) { + v256 dst; +#include "xvrepl128vei_w.h" + return dst; +} + +void test() { + XFUZZ1(xvrepl128vei_w, 0); + XFUZZ1(xvrepl128vei_w, 1); + XFUZZ1(xvrepl128vei_w, 2); + XFUZZ1(xvrepl128vei_w, 3); +} diff --git a/code/xvrepl128vei_w.h b/code/xvrepl128vei_w.h index 110f6304..beb631b9 100644 --- a/code/xvrepl128vei_w.h +++ b/code/xvrepl128vei_w.h @@ -1,3 +1,6 @@ -for (int i = 0; i < 8; i++) { +for (int i = 0; i < 4; i++) { dst.word[i] = a.word[idx]; } +for (int i = 4; i < 8; i++) { + dst.word[i] = a.word[idx + 4]; +} diff --git a/code/xvreplve0_b.cpp b/code/xvreplve0_b.cpp new file mode 100644 index 00000000..62fa86ef --- /dev/null +++ b/code/xvreplve0_b.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v256 xvreplve0_b(v256 a) { + v256 dst; +#include "xvreplve0_b.h" + return dst; +} + +void test() { + XFUZZ1(xvreplve0_b); +} diff --git a/code/xvreplve0_d.cpp b/code/xvreplve0_d.cpp new file mode 100644 index 00000000..dfedb5c1 --- /dev/null +++ b/code/xvreplve0_d.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v256 xvreplve0_d(v256 a) { + v256 dst; +#include "xvreplve0_d.h" + return dst; +} + +void test() { + XFUZZ1(xvreplve0_d); +} diff --git a/code/xvreplve0_h.cpp b/code/xvreplve0_h.cpp new file mode 100644 index 00000000..7da0b757 --- /dev/null +++ b/code/xvreplve0_h.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v256 xvreplve0_h(v256 a) { + v256 dst; +#include "xvreplve0_h.h" + return dst; +} + +void test() { + XFUZZ1(xvreplve0_h); +} diff --git a/code/xvreplve0_q.cpp b/code/xvreplve0_q.cpp new file mode 100644 index 00000000..14d5dbfa --- /dev/null +++ b/code/xvreplve0_q.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v256 xvreplve0_q(v256 a) { + v256 dst; +#include "xvreplve0_q.h" + return dst; +} + +void test() { + XFUZZ1(xvreplve0_q); +} diff --git a/code/xvreplve0_w.cpp b/code/xvreplve0_w.cpp new file mode 100644 index 00000000..64947a68 --- /dev/null +++ b/code/xvreplve0_w.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v256 xvreplve0_w(v256 a) { + v256 dst; +#include "xvreplve0_w.h" + return dst; +} + +void test() { + XFUZZ1(xvreplve0_w); +}