diff --git a/README.md b/README.md index 9c6f3b30..b90d8dd9 100644 --- a/README.md +++ b/README.md @@ -205,8 +205,6 @@ Vector Multiplication High ### vnor.v -### vandn.v - ### vorn.v ### vfrstp.b/h @@ -421,8 +419,6 @@ Vector Multiplication High ### vbitseli.b -### vandi.b - ### vori.b ### vxori.b diff --git a/code/common.h b/code/common.h index e6fd4728..e8eb4b8c 100644 --- a/code/common.h +++ b/code/common.h @@ -27,6 +27,7 @@ union v128 { v4i32 __v4i32; v8i16 __v8i16; v16i8 __v16i8; + v16u8 __v16u8; u8 byte[16]; u16 half[8]; @@ -45,6 +46,7 @@ union v128 { operator v4i32() { return __v4i32; } operator v8i16() { return __v8i16; } operator v16i8() { return __v16i8; } + operator v16u8() { return __v16u8; } bool operator==(const v128 &other) const { return memcmp(byte, other.byte, 16) == 0; } diff --git a/code/vand_v.cpp b/code/vand_v.cpp new file mode 100644 index 00000000..587bf52b --- /dev/null +++ b/code/vand_v.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v128 vand_v(v128 a, v128 b) { + v128 dst; +#include "vand_v.h" + return dst; +} + +void test() { + FUZZ2(vand_v); +} diff --git a/code/vand_v.h b/code/vand_v.h new file mode 100644 index 00000000..d655587e --- /dev/null +++ b/code/vand_v.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 2; i++) { + dst.dword[i] = a.dword[i] & b.dword[i]; +} \ No newline at end of file diff --git a/code/vandi_b.cpp b/code/vandi_b.cpp new file mode 100644 index 00000000..72a267c6 --- /dev/null +++ b/code/vandi_b.cpp @@ -0,0 +1,15 @@ +#include "common.h" + +v128 vandi_b(v128 a, int imm) { + v128 dst; +#include "vandi_b.h" + return dst; +} + +void test() { + FUZZ1(vandi_b, 0x00); + FUZZ1(vandi_b, 0x04); + FUZZ1(vandi_b, 0x08); + FUZZ1(vandi_b, 0x10); + FUZZ1(vandi_b, 0xFF); +} diff --git a/code/vandi_b.h b/code/vandi_b.h new file mode 100644 index 00000000..4c165079 --- /dev/null +++ b/code/vandi_b.h @@ -0,0 +1,3 @@ +for (int i = 0;i < 16;i++) { + dst.byte[i] = a.byte[i] & imm; +} \ No newline at end of file diff --git a/code/vandn_v.cpp b/code/vandn_v.cpp new file mode 100644 index 00000000..cac54574 --- /dev/null +++ b/code/vandn_v.cpp @@ -0,0 +1,11 @@ +#include "common.h" + +v128 vandn_v(v128 a, v128 b) { + v128 dst; +#include "vandn_v.h" + return dst; +} + +void test() { + FUZZ2(vandn_v); +} diff --git a/code/vandn_v.h b/code/vandn_v.h new file mode 100644 index 00000000..dbd70927 --- /dev/null +++ b/code/vandn_v.h @@ -0,0 +1,3 @@ +for (int i = 0; i < 2; i++) { + dst.dword[i] = b.dword[i] & (~a.dword[i]); +} \ No newline at end of file diff --git a/code/vbitsel_v.cpp b/code/vbitsel_v.cpp index 65e8ed8d..36ce706a 100644 --- a/code/vbitsel_v.cpp +++ b/code/vbitsel_v.cpp @@ -7,13 +7,5 @@ v128 vbitsel_v(v128 a, v128 b, v128 c) { } void test() { - __m128i a = {0x123456789ABCDEF0, 0x0FEDCBA987654321}; - __m128i b = {0x1122334455667788, 0x1212343456567878}; - __m128i c = {0x0FF0FFFF00000000, 0x0102040810204080}; - PRINT(a); - PRINT(b); - PRINT(c); - PRINT(__lsx_vbitsel_v(a, b, c)); - FUZZ3(vbitsel_v); } diff --git a/code/vshuf_b.cpp b/code/vshuf_b.cpp index 6b3613ab..5ab2098f 100644 --- a/code/vshuf_b.cpp +++ b/code/vshuf_b.cpp @@ -7,47 +7,5 @@ v128 vshuf_b(v128 a, v128 b, v128 c) { } void test() { - __m128i a = {0x123456789ABCDEF0, 0x0FEDCBA987654321}; - __m128i b = {0x1122334455667788, 0x1212343456567878}; - __m128i c = {0x0001020304050607, 0x0001020304050607}; - PRINT(a); - PRINT(b); - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x08090A0B0C0D0E0F, 0x08090A0B0C0D0E0F}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x1011121314151617, 0x1011121314151617}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x18191A1B1C1D1E1F, 0x18191A1B1C1D1E1F}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x2021FFFFFFFFFFFF, 0x2223FFFFFFFFFFFF}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x0706050403020100, 0x1F1E1D1C1B1A1918}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - c = __m128i{0x20406080A0C0E0FF, 0x1030507090B0D0F0}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - - a = __m128i{0x1716151413121110, 0x1F1E1D1C1B1A1918}; - b = __m128i{0x0706050403020100, 0x0F0E0D0C0B0A0908}; - - for (int i = 0; i < 64; i++) { - c = __m128i{i, 0}; - PRINT(c); - PRINT(__lsx_vshuf_b(a, b, c)); - PRINT(vshuf_b(a, b, c)); - } - FUZZ3(vshuf_b); } diff --git a/code/vshuf_h.cpp b/code/vshuf_h.cpp index c8c2c76b..57f82422 100644 --- a/code/vshuf_h.cpp +++ b/code/vshuf_h.cpp @@ -7,42 +7,5 @@ v128 vshuf_h(v128 a, v128 b, v128 c) { } void test() { - __m128i b = {0x123456789ABCDEF0, 0x0FEDCBA987654321}; - __m128i c = {0x1122334455667788, 0x1212343456567878}; - __m128i a = {0x0001020304050607, 0x0001020304050607}; - PRINT(a); - PRINT(b); - PRINT(c); - PRINT(__lsx_vshuf_h(a, b, c)); - - a = __m128i{0x08090A0B0C0D0E0F, 0x08090A0B0C0D0E0F}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - - a = __m128i{0x1011121314151617, 0x1011121314151617}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - - a = __m128i{0x18191A1B1C1D1E1F, 0x18191A1B1C1D1E1F}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - - a = __m128i{0x2021FFFFFFFFFFFF, 0x2223FFFFFFFFFFFF}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - - a = __m128i{0x0706050403020100, 0x1F1E1D1C1B1A1918}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - - b = __m128i{0x000B000A00090008, 0x000F000E000D000C}; - c = __m128i{0x0003000200010000, 0x0007000600050004}; - - for (int i = 0; i < 64; i++) { - a = __m128i{i, 0}; - PRINT(a); - PRINT(__lsx_vshuf_h(a, b, c)); - } - FUZZ3(vshuf_h); } diff --git a/code/vshuf_w.cpp b/code/vshuf_w.cpp index 8e5673ca..d6a921ef 100644 --- a/code/vshuf_w.cpp +++ b/code/vshuf_w.cpp @@ -7,42 +7,5 @@ v128 vshuf_w(v128 a, v128 b, v128 c) { } void test() { - __m128i b = {0x123456789ABCDEF0, 0x0FEDCBA987654321}; - __m128i c = {0x1122334455667788, 0x1212343456567878}; - __m128i a = {0x0001020304050607, 0x0001020304050607}; - PRINT(a); - PRINT(b); - PRINT(c); - PRINT(__lsx_vshuf_w(a, b, c)); - - a = __m128i{0x08090A0B0C0D0E0F, 0x08090A0B0C0D0E0F}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - - a = __m128i{0x1011121314151617, 0x1011121314151617}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - - a = __m128i{0x18191A1B1C1D1E1F, 0x18191A1B1C1D1E1F}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - - a = __m128i{0x2021FFFFFFFFFFFF, 0x2223FFFFFFFFFFFF}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - - a = __m128i{0x0706050403020100, 0x1F1E1D1C1B1A1918}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - - b = __m128i{0x0000000500000004, 0x0000000700000006}; - c = __m128i{0x0000000100000000, 0x0000000300000002}; - - for (int i = 0; i < 64; i++) { - a = __m128i{i, 0}; - PRINT(a); - PRINT(__lsx_vshuf_w(a, b, c)); - } - FUZZ3(vshuf_w); } diff --git a/docs/lsx_bitops/vlogic.md b/docs/lsx_bitops/vlogic.md new file mode 100644 index 00000000..cf60f69f --- /dev/null +++ b/docs/lsx_bitops/vlogic.md @@ -0,0 +1,64 @@ +# Bitwise Logical + +## __m128i __lsx_vandi_b (__m128i a, imm0_255 imm) + +### Synopsis + +```c++ +__m128i __lsx_vandi_b (__m128i a, imm0_255 imm) +#include +Instruction: vandi.b vr, vr, imm +CPU Flags: LSX +``` + +### Description + +Compute bitwise AND between 8-bit elements in `a` and `imm`. + +### Operation + +```c++ +{% include 'vandi_b.h' %} +``` + +## __m128i __lsx_vandn_v (__m128i a, __m128i b) + +### Synopsis + +```c++ +__m128i __lsx_vandn_v (__m128i a, __m128i b) +#include +Instruction: vandn.v vr, vr, vr +CPU Flags: LSX +``` + +### Description + +Compute bitwise ANDN between elements in `a` and `b`. + +### Operation + +```c++ +{% include 'vandn_v.h' %} +``` + +## __m128i __lsx_vand_v (__m128i a, __m128i b) + +### Synopsis + +```c++ +__m128i __lsx_vand_v (__m128i a, __m128i b) +#include +Instruction: vand.v vr, vr, vr +CPU Flags: LSX +``` + +### Description + +Compute bitwise AND between elements in `a` and `b`. + +### Operation + +```c++ +{% include 'vand_v.h' %} +```