From dcb031d142fb218b1804908a3599ed9890f49a10 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 26 Dec 2023 22:36:06 -0500 Subject: [PATCH] Make sure value in store{} has an appropriate type --- src/singeli/src/bins.singeli | 6 +++--- src/singeli/src/search.singeli | 18 +++++++++--------- src/singeli/src/selfsearch.singeli | 5 +++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/singeli/src/bins.singeli b/src/singeli/src/bins.singeli index 2ed5648f..adc56ef7 100644 --- a/src/singeli/src/bins.singeli +++ b/src/singeli/src/bins.singeli @@ -85,7 +85,7 @@ fn write_indices{I,T}(t:*I, w:*T, n:u64) : void = { id := i+d wi := undefined{T} if (id >= n) { - @for (w over j from i to n) store{t, w, cast_i{i64, j+1}} + @for (w over j from i to n) store{t, w, cast_i{I, j+1}} goto{break} } else if ((wi = load{w, i}) == load{w, id}) { # Gallop @@ -102,14 +102,14 @@ fn write_indices{I,T}(t:*I, w:*T, n:u64) : void = { l -= h } } else { - @unroll (j to 8) store{t, load{w, i+j}, cast_i{i64, i+j+1}} + @unroll (j to 8) store{t, load{w, i+j}, cast_i{I, i+j+1}} i += 8 } } setlabel{break} } fn write_indices{I,T & width{I}==8}(t:*I, w:*T, n:u64) : void = { - @for (w over j to n) store{t, w, j+1} + @for (w over j to n) store{t, w, cast_i{I, j+1}} } def bins_lookup{I, T, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void} = { # Build table diff --git a/src/singeli/src/search.singeli b/src/singeli/src/search.singeli index 9b6e166c..e4f8bb7d 100644 --- a/src/singeli/src/search.singeli +++ b/src/singeli/src/search.singeli @@ -149,7 +149,7 @@ def do_bittab{x0:*void, n:u64, tab:*void, u:u8, t, mode, r0} = { btab:= *i8~~tab def settab_sub{x, v, i} = { if (rval) store{*u8~~r0, u, x} - if (rind and v!=t) store{r0, x, i} + if (rind and v!=t) store{r0, x, cast_i{u32, i}} u+= u8~~i8~~(t - v) # u tracks the total of btab store{btab, x, t} v @@ -324,8 +324,8 @@ fn getRange{E}(x0:*void, res:*i64, n:u64) : u1 = { max1 = max{max1, x} } } - store{res, 0, min1} - store{res, 1, max1} + store{res, 0, cast_i{i64, min1}} + store{res, 1, cast_i{i64, max1}} 1 } @@ -337,13 +337,13 @@ oper &- ({v:T,m} => v & -promote{T,m}) infix left 35 def rty{name} = if (to_prim{name}=='∊') i8 else i32 def ity{name} = (to_prim{name}=='⊒')**(*u32) -fn hashtab{T, name}(rp:*rty{name}, iv:*void, mi:usz, fv:*void, ni:usz, links:ity{name}) = { +fn hashtab{T, name}(rpi:*rty{name}, iv:*void, mi:usz, fv:*void, ni:usz, links:ity{name}) = { # iv,mi/ip,m - searched-in; fv,ni/fp,n - searched-for; may get swapped around & back def prim = to_prim{name} def U = if (prim=='∊') usz else u32 m := cast_i{U,mi}; n := cast_i{U,ni} def wt = width{T} - ip := *T~~iv; fp := *T~~fv + ip := *T~~iv; fp := *T~~fv; rp := if (prim=='∊') rpi else *u32~~rpi def swap_sides{} = each{{a,b}=>{t:=a; a=b; b=t}, tup{ip,m}, tup{fp,n}} swap:u1 = n+(1024*(prim!='⊒')) < (if (prim!='∊') m else m-m/4) if (swap) swap_sides{} @@ -541,18 +541,18 @@ fn hashtab{T, name}(rp:*rty{name}, iv:*void, mi:usz, fv:*void, ni:usz, links:ity } insert_all{set, set_maxh, dup} store{inds, get_end{}, (m-ind_maxh) &- has_maxh} - lookup_all{{found, j} => i32~~(m - (load{inds, j} &- found))} + lookup_all{{found, j} => m - (load{inds, j} &- found)} } else { # swap # After insert_all, position i in rp contains: # - ≠𝕨, if i is the first occurrence of its value in 𝕩, or # - j-≠𝕩, where j>has_radix} else tup{0,2*n64} log := clzc{n} @@ -30,7 +31,7 @@ fn selfhashtab{T, name}(rp:*rty{name}, xp:*T, n:usz) = { } def {output, write_res} = match (prim) { - {('∊')} => tup{{b}=>b, {j,h,k,x0} => { hash<-{j}h; k!=h }} + {('∊')} => tup{{b}=>b, {j,h,k,x0} => { hash<-{j}h; promote{i8,k!=h} }} {('⊒')} => { ctr0:u32 = 1; def {val} = vals def res{j,h,k,x0} = {