From 949bf77b5cbff57e2cd98e30290ffa32fd3e5c18 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 28 Dec 2023 17:04:39 +0800 Subject: [PATCH] Add more examples, improve examples display --- code/common.h | 8 ++++---- code/examples.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ code/examples.md | 38 ++++++++++++++++++++++++++------------ main.py | 4 +++- 4 files changed, 73 insertions(+), 17 deletions(-) diff --git a/code/common.h b/code/common.h index 227bb610..a47e106f 100644 --- a/code/common.h +++ b/code/common.h @@ -185,14 +185,14 @@ union v256 { void test(); void print(const char *s, v128 num) { - printf("v128 as __m128i %s: %016lx %016lx\n", s, num.dword[0], num.dword[1]); + printf("v128 as __m128i %s: 0x%016lx 0x%016lx\n", s, num.dword[0], num.dword[1]); printf("v128 as __m128 %s: %f %f %f %f\n", s, num.fp32[0], num.fp32[1], num.fp32[2], num.fp32[3]); printf("v128 as __m128d %s: %lf %lf\n", s, num.fp64[0], num.fp64[1]); } void print(const char *s, __m128i num) { - printf("__m128i %s: %016llx %016llx\n", s, num[0], num[1]); + printf("__m128i %s: 0x%016llx 0x%016llx\n", s, num[0], num[1]); } void print(const char *s, __m128 num) { @@ -204,7 +204,7 @@ void print(const char *s, __m128d num) { } void print(const char *s, v256 num) { - printf("v256 as __m256i %s: %016lx %016lx %016lx %016lx\n", s, num.dword[0], + printf("v256 as __m256i %s: 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", s, num.dword[0], num.dword[1], num.dword[2], num.dword[3]); printf("v256 as __m256 %s: %f %f %f %f %f %f %f %f\n", s, num.fp32[0], num.fp32[1], num.fp32[2], num.fp32[3], num.fp32[4], num.fp32[5], @@ -214,7 +214,7 @@ void print(const char *s, v256 num) { } void print(const char *s, __m256i num) { - printf("__m256i %s: %016llx %016llx %016llx %016llx\n", s, num[0], num[1], + printf("__m256i %s: 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", s, num[0], num[1], num[2], num[3]); } diff --git a/code/examples.cpp b/code/examples.cpp index a927d11f..c31d28a2 100644 --- a/code/examples.cpp +++ b/code/examples.cpp @@ -3,14 +3,54 @@ void test() { PRINT(__lsx_vmsknz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmsknz_b(__m128i{0x0000111100000000, 0x0011000011111111})); + PRINT(__lasx_xvmsknz_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 0xabababab12121212, 0x1234567812345678})); + PRINT(__lasx_xvmsknz_b(__m256i{0x0000111100000000, 0x0011000011111111, + 0x1111000001010101, 0x0000000000000000})); + PRINT(__lsx_vmskgez_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmskgez_b(__m128i{0x0000808000000000, 0x0081000081716151})); + PRINT(__lasx_xvmskgez_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 0xabababab12121212, 0x1234567812345678})); + PRINT(__lasx_xvmskgez_b(__m256i{0x0000191100000000, 0x00a1000011b11c11, + 0x1181000008010101, 0x0000000000000000})); + PRINT(__lsx_vmskltz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmskltz_b(__m128i{0x0000808000000000, 0x0081000081716151})); + PRINT(__lasx_xvmskltz_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 0xabababab12121212, 0x1234567812345678})); + PRINT(__lasx_xvmskltz_b(__m256i{0x0000118100000000, 0x0081000081111118, + 0x1181000001010801, 0x0000000000000000})); + PRINT(__lsx_vmskltz_h(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmskltz_h(__m128i{0x0000808000000000, 0x0081000081716151})); + PRINT(__lasx_xvmskltz_h(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 0xabababab12121212, 0x1234567812345678})); + PRINT(__lasx_xvmskltz_h(__m256i{0x0000818100000000, 0x0018000018181881, + 0x1181000008080808, 0x0000000000000000})); + PRINT(__lsx_vmskltz_w(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmskltz_w(__m128i{0x0000808000000000, 0x0081000081716151})); + PRINT(__lasx_xvmskltz_w(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 0xabababab12121212, 0x1234567812345678})); + PRINT(__lasx_xvmskltz_w(__m256i{0x0000811100000000, 0x0018000081111111, + 0x8111000001010108, 0x0000000000000000})); + PRINT(__lsx_vmskltz_d(__m128i{0x1122334455667788, 0x99aabbccddeeff00})); PRINT(__lsx_vmskltz_d(__m128i{0x0000808000000000, 0x0081000081716151})); + PRINT(__lasx_xvmskltz_d(__m256i{0x1122334455667788, 0x99aabbccddeeff00, + 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 f6b68822..d0aef54b 100644 --- a/code/examples.md +++ b/code/examples.md @@ -1,13 +1,27 @@ Testing ./examples -__m128i __lsx_vmsknz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 000000000000feff 0000000000000000 -__m128i __lsx_vmsknz_b(__m128i{0x0000111100000000, 0x0011000011111111}): 0000000000004f30 0000000000000000 -__m128i __lsx_vmskgez_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 00000000000001fe 0000000000000000 -__m128i __lsx_vmskgez_b(__m128i{0x0000808000000000, 0x0081000081716151}): 000000000000b7cf 0000000000000000 -__m128i __lsx_vmskltz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 000000000000fe01 0000000000000000 -__m128i __lsx_vmskltz_b(__m128i{0x0000808000000000, 0x0081000081716151}): 0000000000004830 0000000000000000 -__m128i __lsx_vmskltz_h(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 00000000000000f0 0000000000000000 -__m128i __lsx_vmskltz_h(__m128i{0x0000808000000000, 0x0081000081716151}): 0000000000000024 0000000000000000 -__m128i __lsx_vmskltz_w(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 000000000000000c 0000000000000000 -__m128i __lsx_vmskltz_w(__m128i{0x0000808000000000, 0x0081000081716151}): 0000000000000004 0000000000000000 -__m128i __lsx_vmskltz_d(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0000000000000002 0000000000000000 -__m128i __lsx_vmskltz_d(__m128i{0x0000808000000000, 0x0081000081716151}): 0000000000000000 0000000000000000 +__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 +__m256i __lasx_xvmsknz_b(__m256i{0x0000111100000000, 0x0011000011111111, 0x1111000001010101, 0x0000000000000000}): 0x0000000000004f30 0x0000000000000000 0x00000000000000cf 0x0000000000000000 +__m128i __lsx_vmskgez_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x00000000000001fe 0x0000000000000000 +__m128i __lsx_vmskgez_b(__m128i{0x0000808000000000, 0x0081000081716151}): 0x000000000000b7cf 0x0000000000000000 +__m256i __lasx_xvmskgez_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x00000000000001fe 0x0000000000000000 0x000000000000ff0f 0x0000000000000000 +__m256i __lasx_xvmskgez_b(__m256i{0x0000191100000000, 0x00a1000011b11c11, 0x1181000008010101, 0x0000000000000000}): 0x000000000000bbff 0x0000000000000000 0x000000000000ffbf 0x0000000000000000 +__m128i __lsx_vmskltz_b(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x000000000000fe01 0x0000000000000000 +__m128i __lsx_vmskltz_b(__m128i{0x0000808000000000, 0x0081000081716151}): 0x0000000000004830 0x0000000000000000 +__m256i __lasx_xvmskltz_b(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x000000000000fe01 0x0000000000000000 0x00000000000000f0 0x0000000000000000 +__m256i __lasx_xvmskltz_b(__m256i{0x0000118100000000, 0x0081000081111118, 0x1181000001010801, 0x0000000000000000}): 0x0000000000004810 0x0000000000000000 0x0000000000000040 0x0000000000000000 +__m128i __lsx_vmskltz_h(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x00000000000000f0 0x0000000000000000 +__m128i __lsx_vmskltz_h(__m128i{0x0000808000000000, 0x0081000081716151}): 0x0000000000000024 0x0000000000000000 +__m256i __lasx_xvmskltz_h(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x00000000000000f0 0x0000000000000000 0x000000000000000c 0x0000000000000000 +__m256i __lasx_xvmskltz_h(__m256i{0x0000818100000000, 0x0018000018181881, 0x1181000008080808, 0x0000000000000000}): 0x0000000000000004 0x0000000000000000 0x0000000000000000 0x0000000000000000 +__m128i __lsx_vmskltz_w(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x000000000000000c 0x0000000000000000 +__m128i __lsx_vmskltz_w(__m128i{0x0000808000000000, 0x0081000081716151}): 0x0000000000000004 0x0000000000000000 +__m256i __lasx_xvmskltz_w(__m256i{0x1122334455667788, 0x99aabbccddeeff00, 0xabababab12121212, 0x1234567812345678}): 0x000000000000000c 0x0000000000000000 0x0000000000000002 0x0000000000000000 +__m256i __lasx_xvmskltz_w(__m256i{0x0000811100000000, 0x0018000081111111, 0x8111000001010108, 0x0000000000000000}): 0x0000000000000004 0x0000000000000000 0x0000000000000002 0x0000000000000000 +__m128i __lsx_vmskltz_d(__m128i{0x1122334455667788, 0x99aabbccddeeff00}): 0x0000000000000002 0x0000000000000000 +__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 1d31187d..04a6ba28 100644 --- a/main.py +++ b/main.py @@ -52,7 +52,9 @@ name = line.split('(')[0].split(' ')[-1] if name not in examples: examples[name] = [] - examples[name].append(line.strip()) + line = line.strip() + expr, res = line.split(":") + examples[name].append(f"{expr}\n={res}") # depends on implementation of env.macro() def my_macro(env):