diff --git a/include/ircd/simd.h b/include/ircd/simd.h index bd16df8ea..ee23b8968 100644 --- a/include/ircd/simd.h +++ b/include/ircd/simd.h @@ -164,17 +164,9 @@ namespace ircd::simd template u128x1 shl(const u128x1 &a) noexcept; template u128x1 shr(const u128x1 &a) noexcept; - // debug print lanes hex - template - string_view print_lane(const mutable_buffer &buf, const V &) noexcept; - - // debug print register hex - template - string_view print_reg(const mutable_buffer &buf, const V &) noexcept; - - // debug print memory hex - template - string_view print_mem(const mutable_buffer &buf, const V &) noexcept; + // readable output and debug + template string_view str_reg(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept; + template string_view str_mem(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept; } namespace ircd diff --git a/ircd/simd.cc b/ircd/simd.cc index 7012dd1c4..1fb85b6f2 100644 --- a/ircd/simd.cc +++ b/ircd/simd.cc @@ -77,14 +77,16 @@ ircd::simd::u128x1_lane_id template<> ircd::string_view -ircd::simd::print_lane(const mutable_buffer &buf, - const u8x16 &a) +ircd::simd::str_reg(const mutable_buffer &buf, + const u8x16 &a, + const uint &fmt) noexcept { const auto len(::snprintf ( data(buf), size(buf), - "[%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x]", + "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " + "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] )); @@ -97,19 +99,196 @@ noexcept template<> ircd::string_view -ircd::simd::print_lane(const mutable_buffer &buf, - const u8x32 &a) +ircd::simd::str_reg(const mutable_buffer &buf, + const u16x8 &a_, + const uint &fmt) noexcept { - const auto len(::snprintf - ( + const u8x16 a(a_); + const auto len(::snprintf + ( data(buf), size(buf), - "[%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x" - "|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x]", - a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], - a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f], - a[0x10], a[0x11], a[0x12], a[0x13], a[0x14], a[0x15], a[0x16], a[0x17], - a[0x18], a[0x19], a[0x1a], a[0x1b], a[0x1c], a[0x1d], a[0x1e], a[0x1f] + "0x%02x%02x 0x%02x%02x 0x%02x%02x 0x%02x%02x " + "0x%02x%02x 0x%02x%02x 0x%02x%02x 0x%02x%02x", + a[0x01], a[0x00], a[0x03], a[0x02], a[0x05], a[0x04], a[0x07], a[0x06], + a[0x09], a[0x08], a[0x0b], a[0x0a], a[0x0d], a[0x0c], a[0x0f], a[0x0e] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_reg(const mutable_buffer &buf, + const u32x4 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "0x%02x%02x%02x%02x 0x%02x%02x%02x%02x " + "0x%02x%02x%02x%02x 0x%02x%02x%02x%02x", + a[0x03], a[0x02], a[0x01], a[0x00], a[0x07], a[0x06], a[0x05], a[0x04], + a[0x0b], a[0x0a], a[0x09], a[0x08], a[0x0f], a[0x0e], a[0x0d], a[0x0c] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_reg(const mutable_buffer &buf, + const u64x2 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "0x%02x%02x%02x%02x%02x%02x%02x%02x 0x%02x%02x%02x%02x%02x%02x%02x%02x", + a[0x07], a[0x06], a[0x05], a[0x04], a[0x03], a[0x02], a[0x01], a[0x00], + a[0x0f], a[0x0e], a[0x0d], a[0x0c], a[0x0b], a[0x0a], a[0x09], a[0x08] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_reg(const mutable_buffer &buf, + const u128x1 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + a[0x0f], a[0x0e], a[0x0d], a[0x0c], a[0x0b], a[0x0a], a[0x09], a[0x08], + a[0x07], a[0x06], a[0x05], a[0x04], a[0x03], a[0x02], a[0x01], a[0x00] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_mem(const mutable_buffer &buf, + const u8x16 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", + a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], + a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_mem(const mutable_buffer &buf, + const u16x8 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x", + a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], + a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_mem(const mutable_buffer &buf, + const u32x4 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x", + a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], + a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_mem(const mutable_buffer &buf, + const u64x2 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x", + a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], + a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] + )); + + return string_view + { + data(buf), size_t(len) + }; +} + +template<> +ircd::string_view +ircd::simd::str_mem(const mutable_buffer &buf, + const u128x1 &a_, + const uint &fmt) +noexcept +{ + const u8x16 a(a_); + const auto len(::snprintf + ( + data(buf), size(buf), + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + a[0x00], a[0x01], a[0x02], a[0x03], a[0x04], a[0x05], a[0x06], a[0x07], + a[0x08], a[0x09], a[0x0a], a[0x0b], a[0x0c], a[0x0d], a[0x0e], a[0x0f] )); return string_view