make match functions take ux instead of u64 for length

This commit is contained in:
dzaima 2025-05-23 00:47:04 +03:00
parent 2a57cb30b8
commit 1e53078324
3 changed files with 8 additions and 8 deletions

View File

@ -115,7 +115,7 @@ u8 const matchFnData[] = { // for the main diagonal, amount to shift length by;
#include "../utils/includeSingeli.h" #include "../utils/includeSingeli.h"
#else #else
#define F(X) equal_##X #define F(X) equal_##X
bool F(1_1)(void* w, void* x, u64 l, u64 d) { bool F(1_1)(void* w, void* x, ux l, u64 d) {
assert(l>0); assert(l>0);
u64* wp = w; u64* xp = x; u64* wp = w; u64* xp = x;
usz q = l/64; usz q = l/64;
@ -123,7 +123,7 @@ u8 const matchFnData[] = { // for the main diagonal, amount to shift length by;
usz r = (-l)%64; return r==0 || (wp[q]^xp[q])<<r == 0; usz r = (-l)%64; return r==0 || (wp[q]^xp[q])<<r == 0;
} }
#define DEF_EQ_U1(N, T) \ #define DEF_EQ_U1(N, T) \
bool F(1_##N)(void* w, void* x, u64 l, u64 d) { assert(l>0); \ bool F(1_##N)(void* w, void* x, ux l, u64 d) { assert(l>0); \
if (d!=0) { void* t=w; w=x; x=t; } \ if (d!=0) { void* t=w; w=x; x=t; } \
u64* wp = w; T* xp = x; \ u64* wp = w; T* xp = x; \
for (usz i=0; i<l; i++) if (bitp_get(wp,i)!=xp[i]) return false; \ for (usz i=0; i<l; i++) if (bitp_get(wp,i)!=xp[i]) return false; \
@ -136,7 +136,7 @@ u8 const matchFnData[] = { // for the main diagonal, amount to shift length by;
#undef DEF_EQ_U1 #undef DEF_EQ_U1
#define DEF_EQ_I(NAME, S, T, INIT) \ #define DEF_EQ_I(NAME, S, T, INIT) \
bool F(NAME)(void* w, void* x, u64 l, u64 d) { \ bool F(NAME)(void* w, void* x, ux l, u64 d) { \
assert(l>0); INIT \ assert(l>0); INIT \
S* wp = w; T* xp = x; \ S* wp = w; T* xp = x; \
for (usz i=0; i<l; i++) if (wp[i]!=xp[i]) return false; \ for (usz i=0; i<l; i++) if (wp[i]!=xp[i]) return false; \
@ -153,10 +153,10 @@ u8 const matchFnData[] = { // for the main diagonal, amount to shift length by;
#undef DEF_EQ_I #undef DEF_EQ_I
#undef DEF_EQ #undef DEF_EQ
#endif #endif
static NOINLINE bool notEq(void* a, void* b, u64 l, u64 data) { assert(l>0); return false; } static NOINLINE bool notEq(void* a, void* b, ux l, u64 data) { assert(l>0); return false; }
static NOINLINE bool eequalFloat(void* wp, void* xp, u64 ia, u64 data) { static NOINLINE bool eequalFloat(void* wp, void* xp, ux l, u64 data) {
bool r = true; bool r = true;
for (ux i = 0; i < (ux)ia; i++) { for (ux i = 0; i < l; i++) {
f64 w = ((f64*)wp)[i]; f64 w = ((f64*)wp)[i];
f64 x = ((f64*)xp)[i]; f64 x = ((f64*)xp)[i];
r&= (w==x) | (w!=w & x!=x); r&= (w==x) | (w!=w & x!=x);

View File

@ -11,7 +11,7 @@ def swap{w,x} = {
} }
# width{W} ≤ width{X} # width{W} ≤ width{X}
fn equal{W, X}(w:*void, x:*void, l:u64, d:u64) : u1 = { fn equal{W, X}(w:*void, x:*void, l:ux, d:u64) : u1 = {
def vw = arch_defvw def vw = arch_defvw
def bulk = vw / width{X} def bulk = vw / width{X}
if (W!=X) if (d!=0) swap{w,x} if (W!=X) if (d!=0) swap{w,x}

View File

@ -26,7 +26,7 @@ CMP_DEF(le, AS);
#define CMP_AA_IMM(FN, ELT, WHERE, WP, XP, LEN) CMP_AA_CALL(CMP_AA_FN(FN, ELT), WHERE, WP, XP, LEN) #define CMP_AA_IMM(FN, ELT, WHERE, WP, XP, LEN) CMP_AA_CALL(CMP_AA_FN(FN, ELT), WHERE, WP, XP, LEN)
#define CMP_AS_IMM(FN, ELT, WHERE, WP, X, LEN) CMP_AS_CALL(CMP_AS_FN(FN, ELT), WHERE, WP, X, LEN) #define CMP_AS_IMM(FN, ELT, WHERE, WP, X, LEN) CMP_AS_CALL(CMP_AS_FN(FN, ELT), WHERE, WP, X, LEN)
typedef bool (*MatchFn)(void* a, void* b, u64 l, u64 data); typedef bool (*MatchFn)(void* a, void* b, ux l, u64 data);
extern INIT_GLOBAL MatchFn matchFns[]; extern INIT_GLOBAL MatchFn matchFns[];
extern INIT_GLOBAL MatchFn matchFnsR[]; extern INIT_GLOBAL MatchFn matchFnsR[];
extern u8 const matchFnData[]; extern u8 const matchFnData[];