mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd::simd: Add preliminary debug print utils.
This commit is contained in:
parent
d456a42cdd
commit
526271e8cd
3 changed files with 71 additions and 0 deletions
|
@ -155,3 +155,19 @@ struct ircd::pshuf_imm8
|
|||
u8 dst1 : 2; // set src idx for word 1
|
||||
u8 dst0 : 2; // set src idx for word 0
|
||||
};
|
||||
|
||||
//
|
||||
// util
|
||||
//
|
||||
|
||||
namespace ircd::simd
|
||||
{
|
||||
template<class V>
|
||||
string_view print_lane(const mutable_buffer &buf, const V &) noexcept;
|
||||
|
||||
template<class V>
|
||||
string_view print_reg(const mutable_buffer &buf, const V &) noexcept;
|
||||
|
||||
template<class V>
|
||||
string_view print_mem(const mutable_buffer &buf, const V &) noexcept;
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ libircd_la_SOURCES += exception.cc
|
|||
libircd_la_SOURCES += util.cc
|
||||
libircd_la_SOURCES += demangle.cc
|
||||
libircd_la_SOURCES += backtrace.cc
|
||||
libircd_la_SOURCES += simd.cc
|
||||
libircd_la_SOURCES += fpe.cc
|
||||
libircd_la_SOURCES += icu.cc
|
||||
libircd_la_SOURCES += timedate.cc
|
||||
|
|
54
ircd/simd.cc
Normal file
54
ircd/simd.cc
Normal file
|
@ -0,0 +1,54 @@
|
|||
// The Construct
|
||||
//
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#include <ircd/simd.h>
|
||||
|
||||
template<>
|
||||
ircd::string_view
|
||||
ircd::simd::print_lane(const mutable_buffer &buf,
|
||||
const u8x16 &a)
|
||||
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]",
|
||||
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::print_lane(const mutable_buffer &buf,
|
||||
const u8x32 &a)
|
||||
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"
|
||||
"|%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]
|
||||
));
|
||||
|
||||
return string_view
|
||||
{
|
||||
data(buf), size_t(len)
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue