mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::simd: Simplify string/debug interface.
This commit is contained in:
parent
99f203a4b7
commit
1ad2a1546a
2 changed files with 195 additions and 24 deletions
|
@ -164,17 +164,9 @@ namespace ircd::simd
|
|||
template<int bits> u128x1 shl(const u128x1 &a) noexcept;
|
||||
template<int bits> u128x1 shr(const u128x1 &a) noexcept;
|
||||
|
||||
// debug print lanes hex
|
||||
template<class V>
|
||||
string_view print_lane(const mutable_buffer &buf, const V &) noexcept;
|
||||
|
||||
// debug print register hex
|
||||
template<class V>
|
||||
string_view print_reg(const mutable_buffer &buf, const V &) noexcept;
|
||||
|
||||
// debug print memory hex
|
||||
template<class V>
|
||||
string_view print_mem(const mutable_buffer &buf, const V &) noexcept;
|
||||
// readable output and debug
|
||||
template<class T> string_view str_reg(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept;
|
||||
template<class T> string_view str_mem(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept;
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
|
|
205
ircd/simd.cc
205
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
|
||||
|
|
Loading…
Reference in a new issue