2020-06-27 23:25:56 +02:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_SIMD_PRINT_H
|
|
|
|
|
|
|
|
namespace ircd::simd
|
|
|
|
{
|
2022-04-30 22:57:29 +02:00
|
|
|
struct print;
|
|
|
|
|
2020-06-27 23:25:56 +02:00
|
|
|
/// Print the contents of the vector in "register layout" which are
|
|
|
|
/// little-endian hex integer preceded by '0x' with each lane being
|
|
|
|
/// space-separated. The fmt argument is reserved to offer some additional
|
|
|
|
/// variations on the output format.
|
|
|
|
template<class T>
|
|
|
|
string_view
|
|
|
|
print_reg(const mutable_buffer &buf,
|
2020-06-29 02:04:27 +02:00
|
|
|
const T,
|
2020-06-27 23:25:56 +02:00
|
|
|
const uint &fmt = 0)
|
|
|
|
noexcept;
|
|
|
|
|
|
|
|
/// Print the contents of the vector in "memory layout" which are indice-
|
|
|
|
/// ordered hex values for each byte space-separated by lane. The fmt
|
|
|
|
/// argument is reserved to offer some additional variations on the output
|
|
|
|
/// format.
|
|
|
|
template<class T>
|
|
|
|
string_view
|
|
|
|
print_mem(const mutable_buffer &buf,
|
2020-06-29 02:04:27 +02:00
|
|
|
const T,
|
2020-06-27 23:25:56 +02:00
|
|
|
const uint &fmt = 0)
|
|
|
|
noexcept;
|
2021-02-23 22:06:42 +01:00
|
|
|
|
|
|
|
/// Print the contents of the vector as characters for each byte
|
|
|
|
/// space-separated by lane. The fmt argument is reserved to offer some
|
|
|
|
/// additional variations on the output format.
|
|
|
|
template<class T>
|
|
|
|
string_view
|
|
|
|
print_chr(const mutable_buffer &buf,
|
|
|
|
const T,
|
|
|
|
const uint &fmt = 0)
|
|
|
|
noexcept;
|
2022-04-30 22:57:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the contents of the vector to stdout; developer convenience.
|
|
|
|
/// One of the other functions in this suite must be selected by this
|
|
|
|
/// template to generate the desired string.
|
|
|
|
class ircd::simd::print
|
|
|
|
{
|
|
|
|
bool output(const mutable_buffer &, const string_view &, const bool lf);
|
2021-03-05 21:43:03 +01:00
|
|
|
|
2022-04-30 22:57:29 +02:00
|
|
|
public:
|
2021-03-05 21:43:03 +01:00
|
|
|
template<class T,
|
2022-04-30 22:35:47 +02:00
|
|
|
class F = decltype(print_mem<T>)>
|
2021-03-05 21:43:03 +01:00
|
|
|
print(const T,
|
|
|
|
F&& printer = print_mem<T>,
|
|
|
|
const uint &fmt = 0,
|
|
|
|
const bool &lf = true);
|
2022-04-30 22:57:29 +02:00
|
|
|
};
|
2021-03-05 21:43:03 +01:00
|
|
|
|
|
|
|
/// Developer convenience. Reference another print_*() in the template. All
|
|
|
|
/// arguments are passed thru.
|
|
|
|
template<class T,
|
|
|
|
class F>
|
2022-04-30 22:57:29 +02:00
|
|
|
inline
|
|
|
|
ircd::simd::print::print(const T vec,
|
|
|
|
F&& printer,
|
|
|
|
const uint &fmt,
|
|
|
|
const bool &lf)
|
2021-03-05 21:43:03 +01:00
|
|
|
{
|
|
|
|
thread_local char buf[1024];
|
|
|
|
const string_view str
|
|
|
|
{
|
|
|
|
printer(buf, vec, fmt)
|
|
|
|
};
|
|
|
|
|
2022-04-30 22:57:29 +02:00
|
|
|
const bool done
|
2021-03-05 21:43:03 +01:00
|
|
|
{
|
2022-04-30 22:57:29 +02:00
|
|
|
output(buf, str, lf)
|
2021-03-05 21:43:03 +01:00
|
|
|
};
|
2020-06-27 23:25:56 +02:00
|
|
|
}
|