Skip to content

Commit

Permalink
Fix lasx example rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 28, 2023
1 parent 949bf77 commit 76e63d4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
33 changes: 22 additions & 11 deletions code/examples.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#include "common.h"

#define COMMA ,

void test() {
// Bitwise Operations
PRINT(__lsx_vbitsel_v(__m128i{0x1122334455667788, 0x99aabbccddeeff00},
__m128i{0xabababababababab, 0x1234123443214321},
__m128i{0xffff0000aaaabbbb, 0x1111222233334444}));
PRINT(__lasx_xvbitsel_v(__m256i{0x1122334455667788, 0x99aabbccddeeff00,
0xabcdef1212341234, 0xaabbaabbddeeddee},
__m256i{0xabababababababab, 0x1234123443214321,
0x1234123443214321, 0x5678567856785678},
__m256i{0xffff0000aaaabbbb, 0x1111222233334444,
0x00000000ffffffff, 0xffffffff00000000}));
PRINT(__lsx_vbitseli_b(__m128i{0x1122334455667788 COMMA 0x99aabbccddeeff00},
__m128i{0xabababababababab COMMA 0x1234123443214321},
0x12));
PRINT(__lasx_xvbitseli_b(__m256i{0x1122334455667788 COMMA 0x99aabbccddeeff00 COMMA
0xabcdef1212341234 COMMA 0xaabbaabbddeeddee},
__m256i{0xabababababababab COMMA 0x1234123443214321 COMMA
0x1234123443214321 COMMA 0x5678567856785678},
0x12));

// Misc
PRINT(__lsx_vmsknz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}));
PRINT(__lsx_vmsknz_b(__m128i{0x0000111100000000, 0x0011000011111111}));
PRINT(__lasx_xvmsknz_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00,
Expand Down Expand Up @@ -42,15 +64,4 @@ void test() {
0xabababab12121212, 0x1234567812345678}));
PRINT(__lasx_xvmskltz_d(__m256i{0x0000111800000000, 0x0081000081111111,
0x8111000008010101, 0x0000000000000000}));

PRINT(__lsx_vbitsel_v(__m128i{0x1122334455667788, 0x99aabbccddeeff00},
__m128i{0xabababababababab, 0x1234123443214321},
__m128i{0xffff0000aaaabbbb, 0x1111222233334444}));

PRINT(__lasx_xvbitsel_v(__m256i{0x1122334455667788, 0x99aabbccddeeff00,
0xabcdef1212341234, 0xaabbaabbddeeddee},
__m256i{0xabababababababab, 0x1234123443214321,
0x1234123443214321, 0x5678567856785678},
__m256i{0xffff0000aaaabbbb, 0x1111222233334444,
0x00000000ffffffff, 0xffffffff00000000}));
}
6 changes: 4 additions & 2 deletions code/examples.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Testing ./examples
__m128i __lsx_vbitsel_v(__m128i{0x1122334455667788, 0x99aabbccddeeff00}, __m128i{0xabababababababab, 0x1234123443214321}, __m128i{0xffff0000aaaabbbb, 0x1111222233334444}): 0xabab3344ffeeefab 0x98ba9beccfedfb00
__m256i __lasx_xvbitsel_v(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabcdef1212341234, 0xaabbaabbddeeddee}, __m256i{0xabababababababab, 0x1234123443214321, 0x1234123443214321, 0x5678567856785678}, __m256i{0xffff0000aaaabbbb, 0x1111222233334444, 0x00000000ffffffff, 0xffffffff00000000}): 0xabab3344ffeeefab 0x98ba9beccfedfb00 0xabcdef1243214321 0x56785678ddeeddee
__m128i __lsx_vbitseli_b(__m128i{0x1122334455667788 COMMA 0x99aabbccddeeff00}, __m128i{0xabababababababab COMMA 0x1234123443214321}, 0x12): 0xba8b9aabba8b9a23 0x1216123012031221
__m256i __lasx_xvbitseli_b(__m256i{0x1122334455667788 COMMA 0x99aabbccddeeff00 COMMA 0xabcdef1212341234 COMMA 0xaabbaabbddeeddee}, __m256i{0xabababababababab COMMA 0x1234123443214321 COMMA 0x1234123443214321 COMMA 0x5678567856785678}, 0x12): 0xba8b9aabba8b9a23 0x1216123012031221 0x1230123653115311 0x5652565212121212
__m128i __lsx_vmsknz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x000000000000feff 0x0000000000000000
__m128i __lsx_vmsknz_b(__m128i{0x0000111100000000, 0x0011000011111111}): 0x0000000000004f30 0x0000000000000000
__m256i __lasx_xvmsknz_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x000000000000feff 0x0000000000000000 0x000000000000ffff 0x0000000000000000
Expand All @@ -23,5 +27,3 @@ __m128i __lsx_vmskltz_d(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x0000
__m128i __lsx_vmskltz_d(__m128i{0x0000808000000000, 0x0081000081716151}): 0x0000000000000000 0x0000000000000000
__m256i __lasx_xvmskltz_d(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x0000000000000002 0x0000000000000000 0x0000000000000001 0x0000000000000000
__m256i __lasx_xvmskltz_d(__m256i{0x0000111800000000, 0x0081000081111111, 0x8111000008010101, 0x0000000000000000}): 0x0000000000000000 0x0000000000000000 0x0000000000000001 0x0000000000000000
__m128i __lsx_vbitsel_v(__m128i{0x1122334455667788, 0x99aabbccddeeff00}, __m128i{0xabababababababab, 0x1234123443214321}, __m128i{0xffff0000aaaabbbb, 0x1111222233334444}): 0xabab3344ffeeefab 0x98ba9beccfedfb00
__m256i __lasx_xvbitsel_v(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabcdef1212341234, 0xaabbaabbddeeddee}, __m256i{0xabababababababab, 0x1234123443214321, 0x1234123443214321, 0x5678567856785678}, __m256i{0xffff0000aaaabbbb, 0x1111222233334444, 0x00000000ffffffff, 0xffffffff00000000}): 0xabab3344ffeeefab 0x98ba9beccfedfb00 0xabcdef1243214321 0x56785678ddeeddee
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
examples = {}
for line in open('code/examples.md', 'r'):
if '(' in line:
name = line.split('(')[0].split(' ')[-1]
name = line.split('(')[0].strip().split(' ')[-1]
if name not in examples:
examples[name] = []
line = line.strip()
expr, res = line.split(":")
expr = expr.replace(" COMMA ", ", ")
examples[name].append(f"{expr}\n={res}")

# depends on implementation of env.macro()
Expand Down Expand Up @@ -127,6 +128,7 @@ def instruction(intrinsic, instr, desc):
intrinsic = intrinsic.replace("m128", "m256").replace("_lsx_", "_lasx_x")
# replace vr to xr in instr
instr = re.sub("\\bvr\\b", "xr", instr)
intrinsic_name = intrinsic_name.replace("__lsx_", "__lasx_x")
if not os.path.exists(f"code/{file_name}.h"):
file_name = instr.split(" ")[0].replace(".", "_")

Expand Down

0 comments on commit 76e63d4

Please sign in to comment.