convert print helper functions to class methods

This commit is contained in:
Konstantinos Margaritis 2021-07-12 20:59:09 +03:00 committed by Konstantinos Margaritis
parent 78e098661f
commit c45e72775f

View File

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