mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-17 09:45:28 +03:00
renamed matcher functions, added new ones for Vermicelli
This commit is contained in:
@@ -29,7 +29,44 @@
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
const u8 *first_non_zero_match<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
uint32x4_t m = mask.u.u32x4[0];
|
||||
uint64_t vmax = vgetq_lane_u64 (vreinterpretq_u64_u32 (vpmaxq_u32(m, m)), 0);
|
||||
if (vmax != 0) {
|
||||
typename SuperVector<16>::movemask_type z = mask.movemask();
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
u32 pos = ctz32(z & 0xffff);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos < 16);
|
||||
DEBUG_PRINTF("buf + pos %p\n", buf + pos);
|
||||
return buf + pos;
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *last_non_zero_match<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
uint32x4_t m = mask.u.u32x4[0];
|
||||
uint64_t vmax = vgetq_lane_u64 (vreinterpretq_u64_u32 (vpmaxq_u32(m, m)), 0);
|
||||
if (vmax != 0) {
|
||||
typename SuperVector<16>::movemask_type z = mask.movemask();
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
u32 pos = clz32(z & 0xffff);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos >= 16 && pos < 32);
|
||||
return buf + (31 - pos);
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *first_zero_match_inverted<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
uint32x4_t m = mask.u.u32x4[0];
|
||||
uint64_t vmax = vgetq_lane_u64 (vreinterpretq_u64_u32 (vpmaxq_u32(m, m)), 0);
|
||||
if (vmax != 0) {
|
||||
@@ -48,7 +85,7 @@ const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *lastMatch<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
const u8 *last_zero_match_inverted<16>(const u8 *buf, SuperVector<16> mask) {
|
||||
uint32x4_t m = mask.u.u32x4[0];
|
||||
uint64_t vmax = vgetq_lane_u64 (vreinterpretq_u64_u32 (vpmaxq_u32(m, m)), 0);
|
||||
if (vmax != 0) {
|
||||
|
||||
@@ -29,7 +29,98 @@
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> v) {
|
||||
const u8 *first_non_zero_match<16>(const u8 *buf, SuperVector<16> v) {
|
||||
SuperVector<16>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = ctz32(z);
|
||||
DEBUG_PRINTF("~z %08x\n", ~z);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos < 16);
|
||||
return buf + pos;
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *first_non_zero_match<32>(const u8 *buf, SuperVector<32> v) {
|
||||
SuperVector<32>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%08x\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = ctz32(z);
|
||||
assert(pos < 32);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
return buf + pos;
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *first_non_zero_match<64>(const u8 *buf, SuperVector<64>v) {
|
||||
SuperVector<64>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%016llx\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = ctz64(z);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos < 64);
|
||||
return buf + pos;
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *last_non_zero_match<16>(const u8 *buf, SuperVector<16> v) {
|
||||
SuperVector<16>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = clz32(z);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos >= 16 && pos < 32);
|
||||
return buf + (31 - pos);
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *last_non_zero_match<32>(const u8 *buf, SuperVector<32> v) {
|
||||
SuperVector<32>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%08x\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = clz32(z);
|
||||
assert(pos < 32);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
return buf + (31 - pos);
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *last_non_zero_match<64>(const u8 *buf, SuperVector<64>v) {
|
||||
SuperVector<64>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%016llx\n", z);
|
||||
if (unlikely(z)) {
|
||||
u32 pos = clz64(z);
|
||||
DEBUG_PRINTF("match @ pos %u\n", pos);
|
||||
assert(pos < 64);
|
||||
return buf + (31 - pos);
|
||||
} else {
|
||||
return NULL; // no match
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *first_zero_match_inverted<16>(const u8 *buf, SuperVector<16> v) {
|
||||
SuperVector<16>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
@@ -46,7 +137,7 @@ const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> v) {
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *firstMatch<32>(const u8 *buf, SuperVector<32> v) {
|
||||
const u8 *first_zero_match_inverted<32>(const u8 *buf, SuperVector<32> v) {
|
||||
SuperVector<32>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%08x\n", z);
|
||||
if (unlikely(z != 0xffffffff)) {
|
||||
@@ -60,7 +151,7 @@ const u8 *firstMatch<32>(const u8 *buf, SuperVector<32> v) {
|
||||
}
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *firstMatch<64>(const u8 *buf, SuperVector<64>v) {
|
||||
const u8 *first_zero_match_inverted<64>(const u8 *buf, SuperVector<64>v) {
|
||||
SuperVector<64>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%016llx\n", z);
|
||||
if (unlikely(z != ~0ULL)) {
|
||||
@@ -75,7 +166,7 @@ const u8 *firstMatch<64>(const u8 *buf, SuperVector<64>v) {
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *lastMatch<16>(const u8 *buf, SuperVector<16> v) {
|
||||
const u8 *last_zero_match_inverted<16>(const u8 *buf, SuperVector<16> v) {
|
||||
SuperVector<16>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("buf %p z %08x \n", buf, z);
|
||||
DEBUG_PRINTF("z %08x\n", z);
|
||||
@@ -92,7 +183,7 @@ const u8 *lastMatch<16>(const u8 *buf, SuperVector<16> v) {
|
||||
|
||||
template<>
|
||||
really_really_inline
|
||||
const u8 *lastMatch<32>(const u8 *buf, SuperVector<32> v) {
|
||||
const u8 *last_zero_match_inverted<32>(const u8 *buf, SuperVector<32> v) {
|
||||
SuperVector<32>::movemask_type z = v.movemask();
|
||||
if (unlikely(z != 0xffffffff)) {
|
||||
u32 pos = clz32(~z);
|
||||
@@ -106,7 +197,7 @@ const u8 *lastMatch<32>(const u8 *buf, SuperVector<32> v) {
|
||||
|
||||
template <>
|
||||
really_really_inline
|
||||
const u8 *lastMatch<64>(const u8 *buf, SuperVector<64> v) {
|
||||
const u8 *last_zero_match_inverted<64>(const u8 *buf, SuperVector<64> v) {
|
||||
SuperVector<64>::movemask_type z = v.movemask();
|
||||
DEBUG_PRINTF("z 0x%016llx\n", z);
|
||||
if (unlikely(z != ~0ULL)) {
|
||||
|
||||
@@ -38,10 +38,16 @@
|
||||
#include "util/supervector/supervector.hpp"
|
||||
|
||||
template <u16 S>
|
||||
const u8 *firstMatch(const u8 *buf, SuperVector<S> v);
|
||||
const u8 *first_non_zero_match(const u8 *buf, SuperVector<S> v);
|
||||
|
||||
template <u16 S>
|
||||
const u8 *lastMatch(const u8 *buf, SuperVector<S> v);
|
||||
const u8 *last_non_zero_match(const u8 *buf, SuperVector<S> v);
|
||||
|
||||
template <u16 S>
|
||||
const u8 *first_zero_match_inverted(const u8 *buf, SuperVector<S> v);
|
||||
|
||||
template <u16 S>
|
||||
const u8 *last_zero_match_inverted(const u8 *buf, SuperVector<S> v);
|
||||
|
||||
#if defined(ARCH_IA32) || defined(ARCH_X86_64)
|
||||
#include "util/arch/x86/match.hpp"
|
||||
|
||||
Reference in New Issue
Block a user