]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
helper functions to print a m128 vector in debug mode
authorKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Tue, 24 Nov 2020 15:57:16 +0000 (17:57 +0200)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Tue, 24 Nov 2020 15:57:16 +0000 (17:57 +0200)
src/util/arch/common/simd_utils.h

index c16023ac80527b7a50ad29459585c65e171f9307..39cb91f049eb5e27fdcbc0191ed3ffc9003e3394 100644 (file)
 #error "You need at least a 128-bit capable SIMD engine!"
 #endif // HAVE_SIMD_128_BITS
 
+#ifdef DEBUG
+static inline void print_m128_16x8(char *label, m128 vector) {
+    uint8_t __attribute__((aligned(16))) data[16];
+    store128(data, vector);
+    DEBUG_PRINTF("%s: ", label);
+    for(int i=0; i < 16; i++)
+        printf("%02x ", data[i]);
+    printf("\n");
+}
+
+static inline void print_m128_8x16(char *label, m128 vector) {
+    uint16_t __attribute__((aligned(16))) data[8];
+    store128(data, vector);
+    DEBUG_PRINTF("%s: ", label);
+    for(int i=0; i < 8; i++)
+        printf("%04x ", data[i]);
+    printf("\n");
+}
+
+static inline void print_m128_4x32(char *label, m128 vector) {
+    uint32_t __attribute__((aligned(16))) data[4];
+    store128(data, vector);
+    DEBUG_PRINTF("%s: ", label);
+    for(int i=0; i < 4; i++)
+        printf("%08x ", data[i]);
+    printf("\n");
+}
+
+static inline void print_m128_2x64(char *label, m128 vector) {
+    uint64_t __attribute__((aligned(16))) data[2];
+    store128(data, vector);
+    DEBUG_PRINTF("%s: ", label);
+    for(int i=0; i < 2; i++)
+        printf("%016lx ", data[i]);
+    printf("\n");
+}
+#endif
+
 /****
  **** 256-bit Primitives
  ****/