From 76e63d449ffd4253e0bc2afc2992ce326e42a964 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 28 Dec 2023 17:17:45 +0800 Subject: [PATCH] Fix lasx example rendering --- code/examples.cpp | 33 ++++++++++++++++++++++----------- code/examples.md | 6 ++++-- main.py | 4 +++- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/code/examples.cpp b/code/examples.cpp index c31d28a2..3c17aa81 100644 --- a/code/examples.cpp +++ b/code/examples.cpp @@ -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, @@ -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})); } \ No newline at end of file diff --git a/code/examples.md b/code/examples.md index d0aef54b..424e9e3a 100644 --- a/code/examples.md +++ b/code/examples.md @@ -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 @@ -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 diff --git a/main.py b/main.py index 04a6ba28..61592055 100644 --- a/main.py +++ b/main.py @@ -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() @@ -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(".", "_")