Skip to content

Commit

Permalink
Add missing tests, fix vext2xv
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 14, 2023
1 parent c37c238 commit fcb7d85
Show file tree
Hide file tree
Showing 27 changed files with 141 additions and 19 deletions.
2 changes: 1 addition & 1 deletion code/gen_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@
else:
sign = "s"
with open(f"{prefix}ext2xv_{width}_{width2}.h", "w") as f:
print(f"for (int i = 0;i < {vlen // w};i++) {{", file=f)
print(f"for (int i = 0;i < {256 // w};i++) {{", file=f)
print(
f" dst.{m}[i] = ({sign}{w})({sign}{w2})a.{m2}[i];",
file=f,
Expand Down
18 changes: 13 additions & 5 deletions code/gen_tb.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"v128 a, v128 b, int imm",
[0, 3, 7, 15, 16, 32, 64, 128, 255],
),
"vext2xv": (widths_vsllwil, "v128 a"),
"vfrstp": (widths_vfrstp, "v128 a, v128 b, v128 c"),
"vfrstpi": (widths_vfrstp, "v128 a, v128 b, int imm", [0, 4, 31]),
"vhaddw": (widths_vexth, "v128 a, v128 b"),
Expand Down Expand Up @@ -115,12 +116,11 @@
"vsat": (widths_all, "v128 a, int imm", [0, 7]),
"vseq": (widths_signed, "v128 a, v128 b"),
"vseqi": (widths_signed, "v128 a, int imm", [-16, 0, 15]),
"vshuf4i": (["b", "h", "w"], "v128 a, int imm", [0, 13, 100, 128, 255]),
"vshuf": (widths_signed, "v128 a, v128 b, v128 c"),
"vshuf4i": (["b", "h", "w", "d"], "v128 a, int imm", [0, 13, 100, 128, 255]),
"vsigncov": (widths_signed, "v128 a, v128 b"),
"vsllwil": (widths_vsllwil, "v128 a, int imm", [0, 7]),
"vssub": (widths_all, "v128 a, v128 b"),
"vsub": (widths_signed + ["q"], "v128 a, v128 b"),
"vsubi": (widths_unsigned, "v128 a, int imm", [0, 31]),
"vsll": (widths_signed, "v128 a, v128 b"),
"vslli": (widths_signed, "v128 a, int imm", [0, 7]),
"vslt": (widths_all, "v128 a, v128 b"),
Expand Down Expand Up @@ -151,7 +151,8 @@
"vssrlni": (widths_vssrlni, "v128 a, v128 b, int imm", [0, 7, 15]),
"vssrlrn": (widths_vssrln, "v128 a, v128 b"),
"vssrlrni": (widths_vssrlni, "v128 a, v128 b, int imm", [0, 7, 15]),
"vsub": (widths_signed, "v128 a, v128 b"),
"vsub": (widths_signed + ["q"], "v128 a, v128 b"),
"vsubi": (widths_unsigned, "v128 a, int imm", [0, 31]),
"vsubwev": (widths_vsubw, "v128 a, v128 b"),
"vsubwod": (widths_vsubw, "v128 a, v128 b"),
"vxor": (["v"], "v128 a, v128 b"),
Expand All @@ -171,9 +172,15 @@
# skip xvinsgr2vr_b/h
if inst_name in ["xvinsgr2vr_b", "xvinsgr2vr_h"]:
continue
# skip xvext2xv
if inst_name.startswith("xvext2xv"):
continue
# skip xvreplvei
if inst_name.startswith("xvreplvei"):
continue
# skip xv/vshuf4i.d due to extra argument
if inst_name == "vshuf4i_d" or inst_name == "xvshuf4i_d":
continue

fuzz_args = 0
for arg in args.split(", "):
Expand All @@ -182,7 +189,8 @@

print(f"Saving {inst_name}.cpp")
with open(f"{inst_name}.cpp", "w") as f:
if prefix == "":
# vext2xv is in lasx
if prefix == "" and not inst_name.startswith("vext2xv"):
vtype = "v128"
fuzz = "FUZZ"
else:
Expand Down
2 changes: 1 addition & 1 deletion code/vext2xv_d_b.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (s64)(s8)a.byte[i];
}
2 changes: 1 addition & 1 deletion code/vext2xv_d_h.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (s64)(s16)a.half[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_d_w.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_d_w(v256 a) {
v256 dst;
#include "vext2xv_d_w.h"
return dst;
}

void test() { XFUZZ1(vext2xv_d_w); }
2 changes: 1 addition & 1 deletion code/vext2xv_d_w.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (s64)(s32)a.word[i];
}
2 changes: 1 addition & 1 deletion code/vext2xv_du_bu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (u64)(u8)a.byte[i];
}
2 changes: 1 addition & 1 deletion code/vext2xv_du_hu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (u64)(u16)a.half[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_du_wu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_du_wu(v256 a) {
v256 dst;
#include "vext2xv_du_wu.h"
return dst;
}

void test() { XFUZZ1(vext2xv_du_wu); }
2 changes: 1 addition & 1 deletion code/vext2xv_du_wu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 4; i++) {
dst.dword[i] = (u64)(u32)a.word[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_h_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_h_b(v256 a) {
v256 dst;
#include "vext2xv_h_b.h"
return dst;
}

void test() { XFUZZ1(vext2xv_h_b); }
2 changes: 1 addition & 1 deletion code/vext2xv_h_b.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 8; i++) {
for (int i = 0; i < 16; i++) {
dst.half[i] = (s16)(s8)a.byte[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_hu_bu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_hu_bu(v256 a) {
v256 dst;
#include "vext2xv_hu_bu.h"
return dst;
}

void test() { XFUZZ1(vext2xv_hu_bu); }
2 changes: 1 addition & 1 deletion code/vext2xv_hu_bu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 8; i++) {
for (int i = 0; i < 16; i++) {
dst.half[i] = (u16)(u8)a.byte[i];
}
2 changes: 1 addition & 1 deletion code/vext2xv_w_b.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 8; i++) {
dst.word[i] = (s32)(s8)a.byte[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_w_h.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_w_h(v256 a) {
v256 dst;
#include "vext2xv_w_h.h"
return dst;
}

void test() { XFUZZ1(vext2xv_w_h); }
2 changes: 1 addition & 1 deletion code/vext2xv_w_h.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 8; i++) {
dst.word[i] = (s32)(s16)a.half[i];
}
2 changes: 1 addition & 1 deletion code/vext2xv_wu_bu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 8; i++) {
dst.word[i] = (u32)(u8)a.byte[i];
}
9 changes: 9 additions & 0 deletions code/vext2xv_wu_hu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 vext2xv_wu_hu(v256 a) {
v256 dst;
#include "vext2xv_wu_hu.h"
return dst;
}

void test() { XFUZZ1(vext2xv_wu_hu); }
2 changes: 1 addition & 1 deletion code/vext2xv_wu_hu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 8; i++) {
dst.word[i] = (u32)(u16)a.half[i];
}
2 changes: 1 addition & 1 deletion code/xvperm_w.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0;i < 8;i++) {
for (int i = 0; i < 8; i++) {
dst.word[i] = a.word[b.word[i] & 0x8];
}
15 changes: 15 additions & 0 deletions code/xvshuf4i_d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"

v256 xvshuf4i_d(v256 a, v256 b, int imm) {
v256 dst;
#include "xvshuf4i_d.h"
return dst;
}

void test() {
XFUZZ2(xvshuf4i_d, 0);
XFUZZ2(xvshuf4i_d, 13);
XFUZZ2(xvshuf4i_d, 100);
XFUZZ2(xvshuf4i_d, 128);
XFUZZ2(xvshuf4i_d, 255);
}
9 changes: 9 additions & 0 deletions code/xvshuf_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 xvshuf_b(v256 a, v256 b, v256 c) {
v256 dst;
#include "xvshuf_b.h"
return dst;
}

void test() { XFUZZ3(xvshuf_b); }
9 changes: 9 additions & 0 deletions code/xvshuf_d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 xvshuf_d(v256 a, v256 b, v256 c) {
v256 dst;
#include "xvshuf_d.h"
return dst;
}

void test() { XFUZZ3(xvshuf_d); }
9 changes: 9 additions & 0 deletions code/xvshuf_h.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 xvshuf_h(v256 a, v256 b, v256 c) {
v256 dst;
#include "xvshuf_h.h"
return dst;
}

void test() { XFUZZ3(xvshuf_h); }
9 changes: 9 additions & 0 deletions code/xvshuf_w.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 xvshuf_w(v256 a, v256 b, v256 c) {
v256 dst;
#include "xvshuf_w.h"
return dst;
}

void test() { XFUZZ3(xvshuf_w); }
9 changes: 9 additions & 0 deletions code/xvsub_q.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v256 xvsub_q(v256 a, v256 b) {
v256 dst;
#include "xvsub_q.h"
return dst;
}

void test() { XFUZZ2(xvsub_q); }

0 comments on commit fcb7d85

Please sign in to comment.