diff --git a/code/common.h b/code/common.h index 1d88643f..227bb610 100644 --- a/code/common.h +++ b/code/common.h @@ -227,6 +227,8 @@ void print(const char *s, __m256d num) { printf("__m256d %s: %lf %lf %lf %lf\n", s, num[0], num[1], num[2], num[3]); } +void print(const char *s, int num) { printf("int %s: %d\n", s, num); } + #define PRINT(x) print(#x, x) #define FUZZ_N 128 diff --git a/code/gen_impl.py b/code/gen_impl.py index 2402b239..041910e7 100644 --- a/code/gen_impl.py +++ b/code/gen_impl.py @@ -795,7 +795,7 @@ # skip xvpickve2gr_b/bu/h/hu if prefix != "xv" or (width[0] != "b" and width[0] != "h"): with open(f"{prefix}pickve2gr_{width}.h", "w") as f: - print(f"dst = a.{m}[idx];", file=f) + print(f"dst = ({sign}{w})a.{m}[idx];", file=f) for width in ["b", "bu", "h", "hu", "w", "wu", "d", "du"]: double_width = double_widths[width] diff --git a/code/gen_tb.py b/code/gen_tb.py index d572749d..2b8321fd 100644 --- a/code/gen_tb.py +++ b/code/gen_tb.py @@ -5,7 +5,20 @@ widths_fp = ["s", "d"] widths_all = ["b", "bu", "h", "hu", "w", "wu", "d", "du"] widths_vexth = ["h_b", "hu_bu", "w_h", "wu_hu", "d_w", "du_wu", "q_d", "qu_du"] -widths_vext2xv = ["h_b", "hu_bu", "w_b", "wu_bu", "w_h", "wu_hu", "d_b", "du_bu", "d_h", "du_hu", "d_w", "du_wu"] +widths_vext2xv = [ + "h_b", + "hu_bu", + "w_b", + "wu_bu", + "w_h", + "wu_hu", + "d_b", + "du_bu", + "d_h", + "du_hu", + "d_w", + "du_wu", +] widths_vsllwil = ["h_b", "hu_bu", "w_h", "wu_hu", "d_w", "du_wu"] widths_vsrln = ["b_h", "h_w", "w_d"] widths_vssrln = ["b_h", "bu_h", "h_w", "hu_w", "w_d", "wu_d"] diff --git a/code/untested.py b/code/untested.py index 71d7b317..0188625c 100644 --- a/code/untested.py +++ b/code/untested.py @@ -4,4 +4,16 @@ for f in sorted(glob.glob("*.h")): src = f.replace(".h", ".cpp") if not os.path.exists(src): - print(f"Missing {src}") \ No newline at end of file + if ( + src.startswith("xvf") + or src.startswith("vf") + or src.startswith("xvset") + or src.startswith("vset") + or src.startswith("xvld") + or src.startswith("vld") + or src.startswith("xvst") + or src.startswith("vst") + ): + # skipped + continue + print(f"Missing {src}") diff --git a/code/vpickve2gr_b.cpp b/code/vpickve2gr_b.cpp new file mode 100644 index 00000000..94342852 --- /dev/null +++ b/code/vpickve2gr_b.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +int vpickve2gr_b(v128 a, int idx) { + int dst; +#include "vpickve2gr_b.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_b, 0); + FUZZ1(vpickve2gr_b, 7); +} diff --git a/code/vpickve2gr_b.h b/code/vpickve2gr_b.h index 0a384fe4..f10c6a4d 100644 --- a/code/vpickve2gr_b.h +++ b/code/vpickve2gr_b.h @@ -1 +1 @@ -dst = a.byte[idx]; +dst = (s8)a.byte[idx]; diff --git a/code/vpickve2gr_bu.cpp b/code/vpickve2gr_bu.cpp new file mode 100644 index 00000000..7b801376 --- /dev/null +++ b/code/vpickve2gr_bu.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned int vpickve2gr_bu(v128 a, int idx) { + unsigned int dst; +#include "vpickve2gr_bu.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_bu, 0); + FUZZ1(vpickve2gr_bu, 7); +} diff --git a/code/vpickve2gr_bu.h b/code/vpickve2gr_bu.h index 0a384fe4..27438607 100644 --- a/code/vpickve2gr_bu.h +++ b/code/vpickve2gr_bu.h @@ -1 +1 @@ -dst = a.byte[idx]; +dst = (u8)a.byte[idx]; diff --git a/code/vpickve2gr_d.cpp b/code/vpickve2gr_d.cpp new file mode 100644 index 00000000..69c8ca66 --- /dev/null +++ b/code/vpickve2gr_d.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +long int vpickve2gr_d(v128 a, int idx) { + long int dst; +#include "vpickve2gr_d.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_d, 0); + FUZZ1(vpickve2gr_d, 1); +} diff --git a/code/vpickve2gr_d.h b/code/vpickve2gr_d.h index 148c432f..5c14eeed 100644 --- a/code/vpickve2gr_d.h +++ b/code/vpickve2gr_d.h @@ -1 +1 @@ -dst = a.dword[idx]; +dst = (s64)a.dword[idx]; diff --git a/code/vpickve2gr_du.cpp b/code/vpickve2gr_du.cpp new file mode 100644 index 00000000..9202c12f --- /dev/null +++ b/code/vpickve2gr_du.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned long int vpickve2gr_du(v128 a, int idx) { + unsigned long int dst; +#include "vpickve2gr_du.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_du, 0); + FUZZ1(vpickve2gr_du, 1); +} diff --git a/code/vpickve2gr_du.h b/code/vpickve2gr_du.h index 148c432f..5f45b5f9 100644 --- a/code/vpickve2gr_du.h +++ b/code/vpickve2gr_du.h @@ -1 +1 @@ -dst = a.dword[idx]; +dst = (u64)a.dword[idx]; diff --git a/code/vpickve2gr_h.cpp b/code/vpickve2gr_h.cpp new file mode 100644 index 00000000..39cfbef2 --- /dev/null +++ b/code/vpickve2gr_h.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +int vpickve2gr_h(v128 a, int idx) { + int dst; +#include "vpickve2gr_h.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_h, 0); + FUZZ1(vpickve2gr_h, 7); +} diff --git a/code/vpickve2gr_h.h b/code/vpickve2gr_h.h index cd2394af..6b74955b 100644 --- a/code/vpickve2gr_h.h +++ b/code/vpickve2gr_h.h @@ -1 +1 @@ -dst = a.half[idx]; +dst = (s16)a.half[idx]; diff --git a/code/vpickve2gr_hu.cpp b/code/vpickve2gr_hu.cpp new file mode 100644 index 00000000..57fbfd82 --- /dev/null +++ b/code/vpickve2gr_hu.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned int vpickve2gr_hu(v128 a, int idx) { + unsigned int dst; +#include "vpickve2gr_hu.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_hu, 0); + FUZZ1(vpickve2gr_hu, 7); +} diff --git a/code/vpickve2gr_hu.h b/code/vpickve2gr_hu.h index cd2394af..c5d47c29 100644 --- a/code/vpickve2gr_hu.h +++ b/code/vpickve2gr_hu.h @@ -1 +1 @@ -dst = a.half[idx]; +dst = (u16)a.half[idx]; diff --git a/code/vpickve2gr_w.cpp b/code/vpickve2gr_w.cpp new file mode 100644 index 00000000..c9595454 --- /dev/null +++ b/code/vpickve2gr_w.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +int vpickve2gr_w(v128 a, int idx) { + int dst; +#include "vpickve2gr_w.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_w, 0); + FUZZ1(vpickve2gr_w, 3); +} diff --git a/code/vpickve2gr_w.h b/code/vpickve2gr_w.h index 70d56526..cc0c3ddc 100644 --- a/code/vpickve2gr_w.h +++ b/code/vpickve2gr_w.h @@ -1 +1 @@ -dst = a.word[idx]; +dst = (s32)a.word[idx]; diff --git a/code/vpickve2gr_wu.cpp b/code/vpickve2gr_wu.cpp new file mode 100644 index 00000000..a194a8ce --- /dev/null +++ b/code/vpickve2gr_wu.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned int vpickve2gr_wu(v128 a, int idx) { + unsigned int dst; +#include "vpickve2gr_wu.h" + return dst; +} + +void test() { + FUZZ1(vpickve2gr_wu, 0); + FUZZ1(vpickve2gr_wu, 3); +} diff --git a/code/vpickve2gr_wu.h b/code/vpickve2gr_wu.h index 70d56526..1ad51339 100644 --- a/code/vpickve2gr_wu.h +++ b/code/vpickve2gr_wu.h @@ -1 +1 @@ -dst = a.word[idx]; +dst = (u32)a.word[idx]; diff --git a/code/vssran_du_q.h b/code/vssran_du_q.h deleted file mode 100644 index 8234c1f0..00000000 --- a/code/vssran_du_q.h +++ /dev/null @@ -1,8 +0,0 @@ -for (int i = 0; i < 2; i++) { - if (i < 1) { - s128 temp = (s128)a.qword[i] >> (b.qword[i] & 127); - dst.dword[i] = clamp(temp, 0, 18446744073709551615); - } else { - dst.dword[i] = 0; - } -} diff --git a/code/vssrln_du_q.h b/code/vssrln_du_q.h deleted file mode 100644 index 4c678cde..00000000 --- a/code/vssrln_du_q.h +++ /dev/null @@ -1,8 +0,0 @@ -for (int i = 0; i < 2; i++) { - if (i < 1) { - u128 temp = (u128)a.qword[i] >> (b.qword[i] & 127); - dst.dword[i] = clamp(temp, 0, 18446744073709551615); - } else { - dst.dword[i] = 0; - } -} diff --git a/code/xvbitsel_v.cpp b/code/xvbitsel_v.cpp new file mode 100644 index 00000000..480b2f3e --- /dev/null +++ b/code/xvbitsel_v.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +v256 xvbitsel_v(v256 a, v256 b, v256 c) { + v256 dst; +#include "xvbitsel_v.h" + return dst; +} + +void test() { XFUZZ3(xvbitsel_v); } diff --git a/code/xvbitseli_b.cpp b/code/xvbitseli_b.cpp new file mode 100644 index 00000000..20ae49ec --- /dev/null +++ b/code/xvbitseli_b.cpp @@ -0,0 +1,15 @@ +#include "common.h" + +v256 xvbitseli_b(v256 a, v256 b, int imm) { + v256 dst; +#include "xvbitseli_b.h" + return dst; +} + +void test() { + XFUZZ2(xvbitseli_b, 0x00); + XFUZZ2(xvbitseli_b, 0x01); + XFUZZ2(xvbitseli_b, 0x01); + XFUZZ2(xvbitseli_b, 0x80); + XFUZZ2(xvbitseli_b, 0xFF); +} diff --git a/code/xvpickve2gr_d.cpp b/code/xvpickve2gr_d.cpp new file mode 100644 index 00000000..a7ba7d09 --- /dev/null +++ b/code/xvpickve2gr_d.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +long int xvpickve2gr_d(v256 a, int idx) { + long int dst; +#include "xvpickve2gr_d.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve2gr_d, 0); + XFUZZ1(xvpickve2gr_d, 3); +} diff --git a/code/xvpickve2gr_d.h b/code/xvpickve2gr_d.h index 148c432f..5c14eeed 100644 --- a/code/xvpickve2gr_d.h +++ b/code/xvpickve2gr_d.h @@ -1 +1 @@ -dst = a.dword[idx]; +dst = (s64)a.dword[idx]; diff --git a/code/xvpickve2gr_du.cpp b/code/xvpickve2gr_du.cpp new file mode 100644 index 00000000..5a8d5bf1 --- /dev/null +++ b/code/xvpickve2gr_du.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned long int xvpickve2gr_du(v256 a, int idx) { + unsigned long int dst; +#include "xvpickve2gr_du.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve2gr_du, 0); + XFUZZ1(xvpickve2gr_du, 3); +} diff --git a/code/xvpickve2gr_du.h b/code/xvpickve2gr_du.h index 148c432f..5f45b5f9 100644 --- a/code/xvpickve2gr_du.h +++ b/code/xvpickve2gr_du.h @@ -1 +1 @@ -dst = a.dword[idx]; +dst = (u64)a.dword[idx]; diff --git a/code/xvpickve2gr_w.cpp b/code/xvpickve2gr_w.cpp new file mode 100644 index 00000000..f474ffe4 --- /dev/null +++ b/code/xvpickve2gr_w.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +int xvpickve2gr_w(v256 a, int idx) { + int dst; +#include "xvpickve2gr_w.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve2gr_w, 0); + XFUZZ1(xvpickve2gr_w, 7); +} diff --git a/code/xvpickve2gr_w.h b/code/xvpickve2gr_w.h index 70d56526..cc0c3ddc 100644 --- a/code/xvpickve2gr_w.h +++ b/code/xvpickve2gr_w.h @@ -1 +1 @@ -dst = a.word[idx]; +dst = (s32)a.word[idx]; diff --git a/code/xvpickve2gr_wu.cpp b/code/xvpickve2gr_wu.cpp new file mode 100644 index 00000000..1fe6b749 --- /dev/null +++ b/code/xvpickve2gr_wu.cpp @@ -0,0 +1,12 @@ +#include "common.h" + +unsigned int xvpickve2gr_wu(v256 a, int idx) { + unsigned int dst; +#include "xvpickve2gr_wu.h" + return dst; +} + +void test() { + XFUZZ1(xvpickve2gr_wu, 0); + XFUZZ1(xvpickve2gr_wu, 7); +} diff --git a/code/xvpickve2gr_wu.h b/code/xvpickve2gr_wu.h index 70d56526..1ad51339 100644 --- a/code/xvpickve2gr_wu.h +++ b/code/xvpickve2gr_wu.h @@ -1 +1 @@ -dst = a.word[idx]; +dst = (u32)a.word[idx];