]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
convert print helper functions to class methods
authorKonstantinos Margaritis <markos@freevec.org>
Mon, 12 Jul 2021 17:59:09 +0000 (20:59 +0300)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Tue, 12 Oct 2021 08:51:34 +0000 (11:51 +0300)
src/util/supervector/supervector.hpp

index c9c5322c3a29ae921a68a70f886098bd778e770c..45e2f51857911322c15be2b03a79ec6950a43a67 100644 (file)
@@ -91,6 +91,7 @@ struct BaseVector
   static const bool is_valid = false;  // for template matches specialisation
   using type                 = void;
   using movemask_type        = uint32_t;
+  using previous_type        = void;
 };
 
 template <>
@@ -156,6 +157,7 @@ public:
     double   f64[SIZE / sizeof(double)];
   } u;
 
+  SuperVector() {};
   SuperVector(SuperVector const &other);
   SuperVector(typename base_type::type const v);
 
@@ -173,8 +175,6 @@ public:
 
   void operator=(SuperVector const &other);
 
-
-
   SuperVector operator&(SuperVector const &b) const;
   SuperVector operator|(SuperVector const &b) const;
   SuperVector operator^(SuperVector const &b) const;
@@ -202,51 +202,42 @@ public:
   // Constants
   static SuperVector Ones();
   static SuperVector Zeroes();
-};
 
-//class SuperVector<16>;
-// class SuperVector<32>;
-// class SuperVector<64>;
-// class SuperVector<128>;
-
-#if defined(DEBUG)
-template <uint16_t S>
-static void printv_u8(const char *label, SuperVector<S> const &v) {
-    printf("%s: ", label);
-    for(size_t i=0; i < S; i++)
-        printf("%02x ", v.u.u8[i]);
-    printf("\n");
-}
-
-template <uint16_t S>
-static void printv_u16(const char *label, SuperVector<S> const &v) {
-    printf("%s: ", label);
-    for(size_t i=0; i < S/sizeof(u16); i++)
-        printf("%04x ", v.u.u16[i]);
-    printf("\n");
-}
-
-template <uint16_t S>
-static void printv_u32(const char *label, SuperVector<S> const &v) {
-    printf("%s: ", label);
-    for(size_t i=0; i < S/sizeof(u32); i++)
-        printf("%08x ", v.u.u32[i]);
-    printf("\n");
-}
-
-template <uint16_t S>
-static inline void printv_u64(const char *label, SuperVector<S> const &v) {
-    printf("%s: ", label);
-    for(size_t i=0; i < S/sizeof(u64a); i++)
-        printf("%016lx ", v.u.u64[i]);
-    printf("\n");
-}
+  #if defined(DEBUG)
+  void print8(const char *label) {
+      printf("%12s: ", label);
+      for(s16 i=SIZE-1; i >= 0; i--)
+          printf("%02x ", u.u8[i]);
+      printf("\n");
+  }
+
+  void print16(const char *label) {
+      printf("%12s: ", label);
+      for(s16 i=SIZE/sizeof(u16)-1; i >= 0; i--)
+          printf("%04x ", u.u16[i]);
+      printf("\n");
+  }
+
+  void print32(const char *label) {
+      printf("%12s: ", label);
+      for(s16 i=SIZE/sizeof(u32)-1; i >= 0; i--)
+          printf("%08x ", u.u32[i]);
+      printf("\n");
+  }
+
+  void printv_u64(const char *label) {
+      printf("%12s: ", label);
+      for(s16 i=SIZE/sizeof(u64a)-1; i >= 0; i--)
+          printf("%016lx ", u.u64[i]);
+      printf("\n");
+  }
 #else
-#define printv_u8(a, b)   ;
-#define printv_u16(a, b)  ;
-#define printv_u32(a, b)  ;
-#define printv_u64(a, b)  ;
+  void print8(const char *label UNUSED) {};
+  void print16(const char *label UNUSED) {};
+  void print32(const char *label UNUSED) {};
+  void printv_u64(const char *label UNUSED) {};
 #endif
+};
 
 #if defined(HS_OPTIMIZE)
 #if defined(ARCH_IA32) || defined(ARCH_X86_64)