Merge branch 'develop' into wip-cppcheck271-part2

This commit is contained in:
g. economou
2024-05-17 11:08:09 +03:00
committed by GitHub
211 changed files with 3167 additions and 2125 deletions

View File

@@ -68,7 +68,8 @@ namespace ue2 {
#endif
void *aligned_malloc_internal(size_t size, size_t align) {
void *mem;
// cppcheck-suppress cstyleCast
void *mem= nullptr;;
int rv = posix_memalign(&mem, align, size);
if (rv != 0) {
DEBUG_PRINTF("posix_memalign returned %d when asked for %zu bytes\n",
@@ -104,17 +105,17 @@ void *aligned_zmalloc(size_t size) {
const size_t alloc_size = size + HACK_OFFSET;
void *mem = aligned_malloc_internal(alloc_size, 64);
char *mem = static_cast<char *>(aligned_malloc_internal(alloc_size, 64));
if (!mem) {
DEBUG_PRINTF("unable to allocate %zu bytes\n", alloc_size);
throw std::bad_alloc();
}
DEBUG_PRINTF("alloced %p reporting %p\n", mem, (char *)mem + HACK_OFFSET);
DEBUG_PRINTF("alloced %p reporting %p\n", mem, mem + HACK_OFFSET);
assert(ISALIGNED_N(mem, 64));
memset(mem, 0, alloc_size);
return (void *)((char *)mem + HACK_OFFSET);
return reinterpret_cast<void *>(mem + HACK_OFFSET);
}
/** \brief Free a pointer allocated with \ref aligned_zmalloc. */
@@ -123,7 +124,8 @@ void aligned_free(void *ptr) {
return;
}
void *addr = (void *)((char *)ptr - HACK_OFFSET);
char *addr_c = static_cast<char *>(ptr);
void *addr = static_cast<void *>(addr_c - HACK_OFFSET);
DEBUG_PRINTF("asked to free %p freeing %p\n", ptr, addr);
assert(ISALIGNED_N(addr, 64));

View File

@@ -68,7 +68,7 @@ public:
AlignedAllocator() noexcept {}
template <class U, std::size_t N2>
AlignedAllocator(const AlignedAllocator<U, N2> &) noexcept {}
explicit AlignedAllocator(const AlignedAllocator<U, N2> &) noexcept {}
template <class U> struct rebind {
using other = AlignedAllocator<U, N>;

View File

@@ -155,13 +155,13 @@ u32 compress32_impl_c(u32 x, u32 m) {
return 0;
}
u32 mk, mp, mv, t;
u32 mk, mv;
x &= m; // clear irrelevant bits
mk = ~m << 1; // we will count 0's to right
for (u32 i = 0; i < 5; i++) {
mp = mk ^ (mk << 1);
u32 mp = mk ^ (mk << 1);
mp ^= mp << 2;
mp ^= mp << 4;
mp ^= mp << 8;
@@ -169,7 +169,7 @@ u32 compress32_impl_c(u32 x, u32 m) {
mv = mp & m; // bits to move
m = (m ^ mv) | (mv >> (1 << i)); // compress m
t = x & mv;
u32 t = x & mv;
x = (x ^ t) | (t >> (1 << i)); // compress x
mk = mk & ~mp;
}
@@ -239,14 +239,14 @@ u32 expand32_impl_c(u32 x, u32 m) {
return 0;
}
u32 m0, mk, mp, mv, t;
u32 m0, mk, mv;
u32 array[5];
m0 = m; // save original mask
mk = ~m << 1; // we will count 0's to right
for (int i = 0; i < 5; i++) {
mp = mk ^ (mk << 1); // parallel suffix
u32 mp = mk ^ (mk << 1); // parallel suffix
mp = mp ^ (mp << 2);
mp = mp ^ (mp << 4);
mp = mp ^ (mp << 8);
@@ -259,7 +259,7 @@ u32 expand32_impl_c(u32 x, u32 m) {
for (int i = 4; i >= 0; i--) {
mv = array[i];
t = x << (1 << i);
u32 t = x << (1 << i);
x = (x & ~mv) | (t & mv);
}
@@ -409,7 +409,7 @@ u64a pdep64_impl_c(u64a x, u64a _m) {
u64a result = 0x0UL;
const u64a mask = 0x8000000000000000UL;
u64a m = _m;
u64a c, t;
u64a p;
/* The pop-count of the mask gives the number of the bits from
@@ -421,8 +421,8 @@ u64a pdep64_impl_c(u64a x, u64a _m) {
each mask bit as it is processed. */
while (m != 0)
{
c = __builtin_clzl (m);
t = x << (p - c);
u64a c = __builtin_clzl (m);
u64a t = x << (p - c);
m ^= (mask >> c);
result |= (t & (mask >> c));
p++;

View File

@@ -64,7 +64,7 @@ public:
assert(none());
}
bitfield(const boost::dynamic_bitset<> &a) : bits{{0}} {
explicit bitfield(const boost::dynamic_bitset<> &a) : bits{{0}} {
assert(a.size() == requested_size);
assert(none());
for (auto i = a.find_first(); i != a.npos; i = a.find_next(i)) {
@@ -89,9 +89,7 @@ public:
/// Set all bits.
void setall() {
for (auto &e : bits) {
e = all_ones;
}
std::fill(bits.begin(), bits.end(), all_ones);
clear_trailer();
}
@@ -102,9 +100,7 @@ public:
/// Clear all bits.
void clear() {
for (auto &e : bits) {
e = 0;
}
std::fill(bits.begin(), bits.end(), 0);
}
/// Clear all bits (alias for bitset::clear).

View File

@@ -66,7 +66,7 @@ public:
}
}
bytecode_ptr(std::nullptr_t) {}
explicit bytecode_ptr(std::nullptr_t) {}
T *get() const { return ptr.get(); }

View File

@@ -79,7 +79,7 @@ vector<u32> findCliqueGroup(CliqueGraph &cg) {
// Choose a vertex from the graph
u32 id = g[0];
CliqueVertex &n = vertexMap.at(id);
const CliqueVertex &n = vertexMap.at(id);
clique.emplace_back(id);
// Corresponding vertex in the original graph
set<u32> subgraphId(g.begin(), g.end());

View File

@@ -102,7 +102,7 @@ bool determinise(Auto &n, std::vector<ds> &dstates, size_t state_limit,
dstates.emplace_back(ds(alphabet_size));
}
std::vector<StateSet> succs(alphabet_size, n.dead);
std::vector<StateSet> succrs(alphabet_size, n.dead);
while (!q.empty()) {
auto m = std::move(q.front());
@@ -133,13 +133,13 @@ bool determinise(Auto &n, std::vector<ds> &dstates, size_t state_limit,
}
/* fill in successor states */
n.transition(curr, &succs[0]);
n.transition(curr, &succrs[0]);
for (symbol_t s = 0; s < n.alphasize; s++) {
dstate_id_t succ_id;
if (s && succs[s] == succs[s - 1]) {
if (s && succrs[s] == succrs[s - 1]) {
succ_id = dstates[curr_id].next[s - 1];
} else {
auto p = dstate_ids.find(succs[s]);
auto p = dstate_ids.find(succrs[s]);
if (p != dstate_ids.end()) { // succ[s] is already present
succ_id = p->second;
if (succ_id > curr_id && !dstates[succ_id].daddy
@@ -148,10 +148,10 @@ bool determinise(Auto &n, std::vector<ds> &dstates, size_t state_limit,
}
} else {
succ_id = dstate_ids.size();
dstate_ids.emplace(succs[s], succ_id);
dstate_ids.emplace(succrs[s], succ_id);
dstates.emplace_back(ds(alphabet_size));
dstates.back().daddy = n.unalpha[s] < N_CHARS ? curr_id : 0;
q.emplace(succs[s], succ_id);
q.emplace(succrs[s], succ_id);
}
DEBUG_PRINTF("-->%hu on %02hx\n", succ_id, n.unalpha[s]);

View File

@@ -178,9 +178,9 @@ size_t describeClassInt(ostream &os, const CharReach &incr, size_t maxLength,
// Render charclass as a series of ranges
size_t c_start = cr.find_first();
size_t c = c_start, c_last = 0;
size_t c = c_start;
while (c != CharReach::npos) {
c_last = c;
size_t c_last = c;
c = cr.find_next(c);
if (c != c_last + 1 || c_last == 0xff) {
describeRange(os, c_start, c_last, out_type);

View File

@@ -195,10 +195,10 @@ public:
// Constructors.
flat_set(const Compare &compare = Compare(),
explicit flat_set(const Compare &compare = Compare(),
const Allocator &alloc = Allocator())
: base_type(compare, alloc) {}
template <class InputIt>
flat_set(InputIt first, InputIt last, const Compare &compare = Compare(),
const Allocator &alloc = Allocator())
@@ -425,7 +425,7 @@ public:
// Constructors.
flat_map(const Compare &compare = Compare(),
explicit flat_map(const Compare &compare = Compare(),
const Allocator &alloc = Allocator())
: base_type(compare, alloc) {}
@@ -615,7 +615,7 @@ public:
friend class flat_map;
protected:
Compare c;
value_compare(Compare c_in) : c(c_in) {}
explicit value_compare(Compare c_in) : c(c_in) {}
public:
bool operator()(const value_type &lhs, const value_type &rhs) {
return c(lhs.first, rhs.first);

View File

@@ -102,10 +102,10 @@ public:
using category = boost::read_write_property_map_tag;
small_color_map(size_t n_in, const IndexMap &index_map_in)
: n(n_in), index_map(index_map_in) {
size_t num_bytes = (n + entries_per_byte - 1) / entries_per_byte;
data = std::make_shared<std::vector<unsigned char>>(num_bytes);
fill(small_color::white);
: n(n_in),
index_map(index_map_in),
data(std::make_shared<std::vector<unsigned char>>((n_in + entries_per_byte - 1) / entries_per_byte)) {
fill(small_color::white);
}
void fill(small_color color) {

View File

@@ -56,7 +56,7 @@ struct hash_output_it {
using reference = void;
using iterator_category = std::output_iterator_tag;
hash_output_it(size_t *hash_out = nullptr) : out(hash_out) {}
explicit hash_output_it(size_t *hash_out = nullptr) : out(hash_out) {}
hash_output_it &operator++() {
return *this;
}
@@ -65,7 +65,7 @@ struct hash_output_it {
}
struct deref_proxy {
deref_proxy(size_t *hash_out) : out(hash_out) {}
explicit deref_proxy(size_t *hash_out) : out(hash_out) {}
template<typename T>
void operator=(const T &val) const {
@@ -76,7 +76,7 @@ struct hash_output_it {
size_t *out; /* output location of the owning iterator */
};
deref_proxy operator*() { return {out}; }
deref_proxy operator*() { return deref_proxy(out); }
private:
size_t *out; /* location to output the hashes to */

View File

@@ -1421,7 +1421,7 @@ uplevel:
if (level == 0) {
return; // we are done
}
u8 *block_ptr =
const u8 *block_ptr =
mmbit_get_level_root(bits, level) + key * sizeof(MMB_TYPE);
MMB_TYPE real_block = mmb_load(block_ptr);
key >>= MMB_KEY_SHIFT;

View File

@@ -256,7 +256,7 @@ void mmbBuildInitRangePlan(u32 total_bits, u32 begin, u32 end,
/* handle the multilevel case */
s32 ks = mmbit_keyshift(total_bits);
u32 level = 0;
assert(sizeof(MMB_TYPE) == sizeof(u64a));
assert(sizeof(MMB_TYPE) == sizeof(u64a)); // cppcheck-suppress duplicateExpression
if (begin == end) {
add_scatter(&out->p_u64a, 0, 0);

View File

@@ -167,7 +167,7 @@ char mmbit_decompress(u8 *bits, u32 total_bits, const u8 *comp,
comp += sizeof(MMB_TYPE);
while (1) {
if (key_rem < MMB_KEY_BITS) {
u8 *block_ptr = mmbit_get_level_root(bits, level) +
const u8 *block_ptr = mmbit_get_level_root(bits, level) +
key * sizeof(MMB_TYPE);
MMB_TYPE block = mmb_load(block_ptr);
MMB_TYPE block_1 = block & ~mmb_mask_zero_to_nocheck(key_rem);

View File

@@ -159,13 +159,13 @@ really_inline SuperVector<16>::SuperVector(uint64_t const other)
template<>
really_inline SuperVector<16> SuperVector<16>::Ones(void)
{
return {vdupq_n_u8(0xFF)};
return SuperVector<16>(vdupq_n_u8(0xFF));
}
template<>
really_inline SuperVector<16> SuperVector<16>::Zeroes(void)
{
return {vdupq_n_u8(0)};
return SuperVector<16>(vdupq_n_u8(0));
}
// Methods
@@ -179,37 +179,37 @@ really_inline void SuperVector<16>::operator=(SuperVector<16> const &other)
template <>
really_inline SuperVector<16> SuperVector<16>::operator&(SuperVector<16> const &b) const
{
return {vandq_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(vandq_u8(u.u8x16[0], b.u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator|(SuperVector<16> const &b) const
{
return {vorrq_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(vorrq_u8(u.u8x16[0], b.u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator^(SuperVector<16> const &b) const
{
return {veorq_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(veorq_u8(u.u8x16[0], b.u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator!() const
{
return {vmvnq_u8(u.u8x16[0])};
return SuperVector<16>(vmvnq_u8(u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::opandnot(SuperVector<16> const &b) const
{
return {vandq_u8(vmvnq_u8(u.u8x16[0]), b.u.u8x16[0])};
return SuperVector<16>(vandq_u8(vmvnq_u8(u.u8x16[0]), b.u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator==(SuperVector<16> const &b) const
{
return {vceqq_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(vceqq_u8(u.u8x16[0], b.u.u8x16[0]));
}
template <>
@@ -221,25 +221,25 @@ really_inline SuperVector<16> SuperVector<16>::operator!=(SuperVector<16> const
template <>
really_inline SuperVector<16> SuperVector<16>::operator>(SuperVector<16> const &b) const
{
return {vcgtq_s8(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vcgtq_s8(u.s8x16[0], b.u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator>=(SuperVector<16> const &b) const
{
return {vcgeq_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(vcgeq_u8(u.u8x16[0], b.u.u8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator<(SuperVector<16> const &b) const
{
return {vcltq_s8(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vcltq_s8(u.s8x16[0], b.u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator<=(SuperVector<16> const &b) const
{
return {vcgeq_s8(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vcgeq_s8(u.s8x16[0], b.u.s8x16[0]));
}
template <>
@@ -274,35 +274,35 @@ template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_8_imm() const
{
return {vshlq_n_u8(u.u8x16[0], N)};
return SuperVector<16>(vshlq_n_u8(u.u8x16[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_16_imm() const
{
return {vshlq_n_u16(u.u16x8[0], N)};
return SuperVector<16>(vshlq_n_u16(u.u16x8[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_32_imm() const
{
return {vshlq_n_u32(u.u32x4[0], N)};
return SuperVector<16>(vshlq_n_u32(u.u32x4[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_64_imm() const
{
return {vshlq_n_u64(u.u64x2[0], N)};
return SuperVector<16>(vshlq_n_u64(u.u64x2[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_128_imm() const
{
return {vextq_u8(vdupq_n_u8(0), u.u8x16[0], 16 - N)};
return SuperVector<16>(vextq_u8(vdupq_n_u8(0), u.u8x16[0], 16 - N));
}
template <>
@@ -316,35 +316,35 @@ template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_8_imm() const
{
return {vshrq_n_u8(u.u8x16[0], N)};
return SuperVector<16>(vshrq_n_u8(u.u8x16[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_16_imm() const
{
return {vshrq_n_u16(u.u16x8[0], N)};
return SuperVector<16>(vshrq_n_u16(u.u16x8[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_32_imm() const
{
return {vshrq_n_u32(u.u32x4[0], N)};
return SuperVector<16>(vshrq_n_u32(u.u32x4[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_64_imm() const
{
return {vshrq_n_u64(u.u64x2[0], N)};
return SuperVector<16>(vshrq_n_u64(u.u64x2[0], N));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_128_imm() const
{
return {vextq_u8(u.u8x16[0], vdupq_n_u8(0), N)};
return SuperVector<16>(vextq_u8(u.u8x16[0], vdupq_n_u8(0), N));
}
template <>
@@ -376,7 +376,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_8 (uint8_t const N) const
if (N == 0) return *this;
if (N == 8) return Zeroes();
int8x16_t shift_indices = vdupq_n_s8(N);
return { vshlq_s8(u.s8x16[0], shift_indices) };
return SuperVector<16>(vshlq_s8(u.s8x16[0], shift_indices));
}
template <>
@@ -385,7 +385,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_16 (uint8_t const N) const
if (N == 0) return *this;
if (N == 16) return Zeroes();
int16x8_t shift_indices = vdupq_n_s16(N);
return { vshlq_s16(u.s16x8[0], shift_indices) };
return SuperVector<16>(vshlq_s16(u.s16x8[0], shift_indices));
}
template <>
@@ -394,7 +394,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_32 (uint8_t const N) const
if (N == 0) return *this;
if (N == 32) return Zeroes();
int32x4_t shift_indices = vdupq_n_s32(N);
return { vshlq_s32(u.s32x4[0], shift_indices) };
return SuperVector<16>(vshlq_s32(u.s32x4[0], shift_indices));
}
template <>
@@ -403,7 +403,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_64 (uint8_t const N) const
if (N == 0) return *this;
if (N == 64) return Zeroes();
int64x2_t shift_indices = vdupq_n_s64(N);
return { vshlq_s64(u.s64x2[0], shift_indices) };
return SuperVector<16>(vshlq_s64(u.s64x2[0], shift_indices));
}
template <>
@@ -413,11 +413,11 @@ really_inline SuperVector<16> SuperVector<16>::vshl_128(uint8_t const N) const
if (N == 16) return Zeroes();
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (__builtin_constant_p(N)) {
return {vextq_u8(vdupq_n_u8(0), u.u8x16[0], 16 - N)};
return SuperVector<16>(vextq_u8(vdupq_n_u8(0), u.u8x16[0], 16 - N));
}
#endif
SuperVector result;
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {vextq_u8(vdupq_n_u8(0), v->u.u8x16[0], 16 - n)}; });
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = SuperVector<16>(vextq_u8(vdupq_n_u8(0), v->u.u8x16[0], 16 - n)); });
return result;
}
@@ -433,7 +433,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_8 (uint8_t const N) const
if (N == 0) return *this;
if (N == 8) return Zeroes();
int8x16_t shift_indices = vdupq_n_s8(-N);
return { vshlq_s8(u.s8x16[0], shift_indices) };
return SuperVector<16>(vshlq_s8(u.s8x16[0], shift_indices));
}
template <>
@@ -442,7 +442,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_16 (uint8_t const N) const
if (N == 0) return *this;
if (N == 16) return Zeroes();
int16x8_t shift_indices = vdupq_n_s16(-N);
return { vshlq_s16(u.s16x8[0], shift_indices) };
return SuperVector<16>(vshlq_s16(u.s16x8[0], shift_indices));
}
template <>
@@ -451,7 +451,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_32 (uint8_t const N) const
if (N == 0) return *this;
if (N == 32) return Zeroes();
int32x4_t shift_indices = vdupq_n_s32(-N);
return { vshlq_s32(u.s32x4[0], shift_indices) };
return SuperVector<16>(vshlq_s32(u.s32x4[0], shift_indices));
}
template <>
@@ -460,7 +460,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_64 (uint8_t const N) const
if (N == 0) return *this;
if (N == 64) return Zeroes();
int64x2_t shift_indices = vdupq_n_s64(-N);
return { vshlq_s64(u.s64x2[0], shift_indices) };
return SuperVector<16>(vshlq_s64(u.s64x2[0], shift_indices));
}
template <>
@@ -470,11 +470,11 @@ really_inline SuperVector<16> SuperVector<16>::vshr_128(uint8_t const N) const
if (N == 16) return Zeroes();
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (__builtin_constant_p(N)) {
return {vextq_u8(u.u8x16[0], vdupq_n_u8(0), N)};
return SuperVector<16>(vextq_u8(u.u8x16[0], vdupq_n_u8(0), N));
}
#endif
SuperVector result;
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {vextq_u8(v->u.u8x16[0], vdupq_n_u8(0), n)}; });
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = SuperVector<16>(vextq_u8(v->u.u8x16[0], vdupq_n_u8(0), n)); });
return result;
}
@@ -511,7 +511,7 @@ really_inline SuperVector<16> SuperVector<16>::Ones_vshl(uint8_t const N)
template <>
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
{
return {vld1q_s32((const int32_t *)ptr)};
return {SuperVector<16>(vld1q_s32(reinterpret_cast<const int32_t *>(ptr)))};
}
template <>
@@ -519,7 +519,7 @@ really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
return {vld1q_s32((const int32_t *)ptr)};
return {SuperVector<16>(vld1q_s32(reinterpret_cast<const int32_t *>(ptr)))};
}
template <>
@@ -537,11 +537,11 @@ really_inline SuperVector<16> SuperVector<16>::alignr(SuperVector<16> &other, in
if (offset == 16) return *this;
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (__builtin_constant_p(offset)) {
return {vextq_u8(other.u.u8x16[0], u.u8x16[0], offset)};
return SuperVector<16>(vextq_u8(other.u.u8x16[0], u.u8x16[0], offset));
}
#endif
SuperVector result;
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (offset == n) result = {vextq_u8(other.u.u8x16[0], v->u.u8x16[0], n)}; });
Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (offset == n) result = SuperVector<16>(vextq_u8(other.u.u8x16[0], v->u.u8x16[0], n)); });
return result;
}
@@ -549,7 +549,7 @@ template<>
template<>
really_inline SuperVector<16> SuperVector<16>::pshufb<false>(SuperVector<16> b)
{
return {vqtbl1q_u8(u.u8x16[0], b.u.u8x16[0])};
return SuperVector<16>(vqtbl1q_u8(u.u8x16[0], b.u.u8x16[0]));
}
template<>

View File

@@ -183,13 +183,13 @@ really_inline SuperVector<16>::SuperVector(uint64_t const other)
template<>
really_inline SuperVector<16> SuperVector<16>::Ones(void)
{
return { vec_splat_s8(-1)};
return SuperVector<16>(vec_splat_s8(-1));
}
template<>
really_inline SuperVector<16> SuperVector<16>::Zeroes(void)
{
return { vec_splat_s8(0) };
return SuperVector<16>(vec_splat_s8(0));
}
// Methods
@@ -203,38 +203,38 @@ really_inline void SuperVector<16>::operator=(SuperVector<16> const &other)
template <>
really_inline SuperVector<16> SuperVector<16>::operator&(SuperVector<16> const &b) const
{
return { vec_and(u.v128[0], b.u.v128[0]) };
return SuperVector<16>(vec_and(u.v128[0], b.u.v128[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator|(SuperVector<16> const &b) const
{
return { vec_or(u.v128[0], b.u.v128[0]) };
return SuperVector<16>(vec_or(u.v128[0], b.u.v128[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator^(SuperVector<16> const &b) const
{
return { vec_xor(u.v128[0], b.u.v128[0]) };
return SuperVector<16>(vec_xor(u.v128[0], b.u.v128[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator!() const
{
return { vec_xor(u.v128[0], u.v128[0]) };
return SuperVector<16>(vec_xor(u.v128[0], u.v128[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::opandnot(SuperVector<16> const &b) const
{
int8x16_t not_res = vec_xor(u.s8x16[0], vec_splat_s8(-1));
return { vec_and(not_res, b.u.s8x16[0]) };
return SuperVector<16>(vec_and(not_res, b.u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator==(SuperVector<16> const &b) const
{
return { vec_cmpeq(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vec_cmpeq(u.s8x16[0], b.u.s8x16[0]));
}
template <>
@@ -246,25 +246,25 @@ really_inline SuperVector<16> SuperVector<16>::operator!=(SuperVector<16> const
template <>
really_inline SuperVector<16> SuperVector<16>::operator>(SuperVector<16> const &b) const
{
return { vec_cmpgt(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vec_cmpgt(u.s8x16[0], b.u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator>=(SuperVector<16> const &b) const
{
return { vec_cmpge(u.s8x16[0], b.u.s8x16[0])};
return SuperVector<16>(vec_cmpge(u.s8x16[0], b.u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator<(SuperVector<16> const &b) const
{
return { vec_cmpgt(b.u.s8x16[0], u.s8x16[0])};
return SuperVector<16>(vec_cmpgt(b.u.s8x16[0], u.s8x16[0]));
}
template <>
really_inline SuperVector<16> SuperVector<16>::operator<=(SuperVector<16> const &b) const
{
return { vec_cmpge(b.u.s8x16[0], u.s8x16[0])};
return SuperVector<16>(vec_cmpge(b.u.s8x16[0], u.s8x16[0]));
}
template <>
@@ -310,35 +310,35 @@ template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_8_imm() const
{
return { vec_sl(u.s8x16[0], vec_splat_u8(N)) };
return SuperVector<16>(vec_sl(u.s8x16[0], vec_splat_u8(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_16_imm() const
{
return { vec_sl(u.s16x8[0], vec_splat_u16(N)) };
return SuperVector<16>(vec_sl(u.s16x8[0], vec_splat_u16(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_32_imm() const
{
return { vec_sl(u.s32x4[0], vec_splat_u32(N)) };
return SuperVector<16>(vec_sl(u.s32x4[0], vec_splat_u32(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_64_imm() const
{
return { vec_sl(u.s64x2[0], vec_splats((ulong64_t) N)) };
return SuperVector<16>(vec_sl(u.s64x2[0], vec_splats((ulong64_t) N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshl_128_imm() const
{
return { vec_sld(u.s8x16[0], vec_splat_s8(0), N)};
return SuperVector<16>(vec_sld(u.s8x16[0], vec_splat_s8(0), N));
}
template <>
@@ -352,35 +352,35 @@ template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_8_imm() const
{
return { vec_sr(u.s8x16[0], vec_splat_u8(N)) };
return SuperVector<16>(vec_sr(u.s8x16[0], vec_splat_u8(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_16_imm() const
{
return { vec_sr(u.s16x8[0], vec_splat_u16(N)) };
return SuperVector<16>(vec_sr(u.s16x8[0], vec_splat_u16(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_32_imm() const
{
return { vec_sr(u.s32x4[0], vec_splat_u32(N)) };
return SuperVector<16>(vec_sr(u.s32x4[0], vec_splat_u32(N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_64_imm() const
{
return { vec_sr(u.s64x2[0], vec_splats((ulong64_t)N)) };
return SuperVector<16>(vec_sr(u.s64x2[0], vec_splats((ulong64_t)N)));
}
template <>
template<uint8_t N>
really_inline SuperVector<16> SuperVector<16>::vshr_128_imm() const
{
return { vec_sld(vec_splat_s8(0), u.s8x16[0], 16 - N) };
return SuperVector<16>(vec_sld(vec_splat_s8(0), u.s8x16[0], 16 - N));
}
template <>
@@ -411,7 +411,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_8 (uint8_t const N) const
{
if (N == 0) return *this;
uint8x16_t shift_indices = vec_splats((uint8_t) N);
return { vec_sl(u.u8x16[0], shift_indices) };
return SuperVector<16>(vec_sl(u.u8x16[0], shift_indices));
}
template <>
@@ -419,7 +419,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_16 (uint8_t const UNUSED N)
{
if (N == 0) return *this;
uint16x8_t shift_indices = vec_splats((uint16_t) N);
return { vec_sl(u.u16x8[0], shift_indices) };
return SuperVector<16>(vec_sl(u.u16x8[0], shift_indices));
}
template <>
@@ -427,7 +427,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_32 (uint8_t const N) const
{
if (N == 0) return *this;
uint32x4_t shift_indices = vec_splats((uint32_t) N);
return { vec_sl(u.u32x4[0], shift_indices) };
return SuperVector<16>(vec_sl(u.u32x4[0], shift_indices));
}
template <>
@@ -435,7 +435,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_64 (uint8_t const N) const
{
if (N == 0) return *this;
uint64x2_t shift_indices = vec_splats((ulong64_t) N);
return { vec_sl(u.u64x2[0], shift_indices) };
return SuperVector<16>(vec_sl(u.u64x2[0], shift_indices));
}
template <>
@@ -443,7 +443,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_128(uint8_t const N) const
{
if (N == 0) return *this;
SuperVector sl{N << 3};
return { vec_slo(u.u8x16[0], sl.u.u8x16[0]) };
return SuperVector<16>(vec_slo(u.u8x16[0], sl.u.u8x16[0]));
}
template <>
@@ -457,7 +457,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_8 (uint8_t const N) const
{
if (N == 0) return *this;
uint8x16_t shift_indices = vec_splats((uint8_t) N);
return { vec_sr(u.u8x16[0], shift_indices) };
return SuperVector<16>(vec_sr(u.u8x16[0], shift_indices));
}
template <>
@@ -465,7 +465,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_16 (uint8_t const N) const
{
if (N == 0) return *this;
uint16x8_t shift_indices = vec_splats((uint16_t) N);
return { vec_sr(u.u16x8[0], shift_indices) };
return SuperVector<16>(vec_sr(u.u16x8[0], shift_indices));
}
template <>
@@ -473,7 +473,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_32 (uint8_t const N) const
{
if (N == 0) return *this;
uint32x4_t shift_indices = vec_splats((uint32_t) N);
return { vec_sr(u.u32x4[0], shift_indices) };
return SuperVector<16>(vec_sr(u.u32x4[0], shift_indices));
}
template <>
@@ -481,7 +481,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_64 (uint8_t const N) const
{
if (N == 0) return *this;
uint64x2_t shift_indices = vec_splats((ulong64_t) N);
return { vec_sr(u.u64x2[0], shift_indices) };
return SuperVector<16>(vec_sr(u.u64x2[0], shift_indices));
}
template <>
@@ -489,7 +489,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_128(uint8_t const N) const
{
if (N == 0) return *this;
SuperVector sr{N << 3};
return { vec_sro(u.u8x16[0], sr.u.u8x16[0]) };
return SuperVector<16>(vec_sro(u.u8x16[0], sr.u.u8x16[0]));
}
template <>
@@ -504,7 +504,7 @@ really_inline SuperVector<16> SuperVector<16>::operator>>(uint8_t const N) const
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (N == 0) return *this;
if (__builtin_constant_p(N)) {
return { vec_sld(vec_splat_s8(0), u.s8x16[0], 16 - N) };
return SuperVector<16>(vec_sld(vec_splat_s8(0), u.s8x16[0], 16 - N));
}
#endif
return vshr_128(N);
@@ -516,7 +516,7 @@ really_inline SuperVector<16> SuperVector<16>::operator<<(uint8_t const N) const
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (N == 0) return *this;
if (__builtin_constant_p(N)) {
return { vec_sld(u.s8x16[0], vec_splat_s8(0), N)};
return SuperVector<16>(vec_sld(u.s8x16[0], vec_splat_s8(0), N));
}
#endif
return vshl_128(N);
@@ -537,14 +537,14 @@ really_inline SuperVector<16> SuperVector<16>::Ones_vshl(uint8_t const N)
template <>
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
{
return { vec_xl(0, (const long64_t*)ptr) };
return SuperVector<16>(vec_xl(0, (const long64_t*)ptr));
}
template <>
really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
return { vec_xl(0, (const long64_t*)ptr) };
return SuperVector<16>(vec_xl(0, (const long64_t*)ptr));
}
template <>
@@ -562,14 +562,14 @@ really_inline SuperVector<16> SuperVector<16>::alignr(SuperVector<16> &other, in
if (offset == 16) return *this;
#if defined(HAVE__BUILTIN_CONSTANT_P)
if (__builtin_constant_p(offset)) {
return { vec_sld(u.s8x16[0], other.u.s8x16[0], offset) };
return SuperVector<16>(vec_sld(u.s8x16[0], other.u.s8x16[0], offset));
}
#endif
uint8x16_t sl = vec_splats((uint8_t) (offset << 3));
uint8x16_t sr = vec_splats((uint8_t) ((16 - offset) << 3));
uint8x16_t rhs = vec_slo(u.u8x16[0], sr);
uint8x16_t lhs = vec_sro(other.u.u8x16[0], sl);
return { vec_or(lhs, rhs) };
return SuperVector<16>(vec_or(lhs, rhs));
}
template<>
@@ -581,7 +581,7 @@ really_inline SuperVector<16> SuperVector<16>::pshufb<false>(SuperVector<16> b)
below is the version that is converted from Intel to PPC. */
uint8x16_t mask =(uint8x16_t)vec_cmpge(b.u.u8x16[0], vec_splats((uint8_t)0x80));
uint8x16_t res = vec_perm (u.u8x16[0], u.u8x16[0], b.u.u8x16[0]);
return { vec_sel(res, vec_splat_u8(0), mask) };
return SuperVector<16>(vec_sel(res, vec_splat_u8(0), mask));
}
template<>

File diff suppressed because it is too large Load Diff

View File

@@ -205,21 +205,21 @@ public:
constexpr SuperVector() {};
SuperVector(SuperVector const &other)
:u(other.u) {};
SuperVector(typename base_type::type const v);
explicit SuperVector(typename base_type::type const v);
template<typename T>
SuperVector(T const other);
explicit SuperVector(T const other);
SuperVector(SuperVector<SIZE/2> const lo, SuperVector<SIZE/2> const hi);
SuperVector(previous_type const lo, previous_type const hi);
static SuperVector dup_u8 (uint8_t other) { return {other}; };
static SuperVector dup_s8 (int8_t other) { return {other}; };
static SuperVector dup_u8 (uint8_t other) { return {SuperVector(other)}; };
static SuperVector dup_s8 (int8_t other) { return {SuperVector(other)}; };
static SuperVector dup_u16(uint16_t other) { return {other}; };
static SuperVector dup_s16(int16_t other) { return {other}; };
static SuperVector dup_u32(uint32_t other) { return {other}; };
static SuperVector dup_s32(int32_t other) { return {other}; };
static SuperVector dup_u64(uint64_t other) { return {other}; };
static SuperVector dup_u64(uint64_t other) { return {SuperVector(other)}; };
static SuperVector dup_s64(int64_t other) { return {other}; };
void operator=(SuperVector const &other);

View File

@@ -210,7 +210,7 @@ public:
* edge() and add_edge(). As we have null_edges and we always allow
* parallel edges, the bool component of the return from these functions is
* not required. */
edge_descriptor(const std::pair<edge_descriptor, bool> &tup)
explicit edge_descriptor(const std::pair<edge_descriptor, bool> &tup)
: p(tup.first.p), serial(tup.first.serial) {
assert(tup.second == (bool)tup.first);
}
@@ -432,7 +432,7 @@ public:
vertex_descriptor> {
using super = typename adjacency_iterator::iterator_adaptor_;
public:
adjacency_iterator(out_edge_iterator a) : super(std::move(a)) { }
explicit adjacency_iterator(out_edge_iterator a) : super(std::move(a)) { }
adjacency_iterator() { }
vertex_descriptor dereference() const {
@@ -448,7 +448,7 @@ public:
vertex_descriptor> {
using super = typename inv_adjacency_iterator::iterator_adaptor_;
public:
inv_adjacency_iterator(in_edge_iterator a) : super(std::move(a)) { }
explicit inv_adjacency_iterator(in_edge_iterator a) : super(std::move(a)) { }
inv_adjacency_iterator() { }
vertex_descriptor dereference() const {
@@ -793,7 +793,7 @@ public:
typedef typename boost::lvalue_property_map_tag category;
prop_map(value_type P_of::*m_in) : member(m_in) { }
explicit prop_map(value_type P_of::*m_in) : member(m_in) { }
reference operator[](key_type k) const {
return k.raw()->props.*member;