use util/kind checks instead of custom isreg/istype/istup
This commit is contained in:
parent
ee1668c7ea
commit
64a71688fe
@ -13,16 +13,11 @@ oper ~~ reinterpret infix right 55
|
|||||||
oper ** broadcast infix right 55
|
oper ** broadcast infix right 55
|
||||||
def extend_each{G, ...args}{...fs} = each{{f, ...args} => (if (length{args}>0) G{...args} else G){f}, fs, ...args}
|
def extend_each{G, ...args}{...fs} = each{{f, ...args} => (if (length{args}>0) G{...args} else G){f}, fs, ...args}
|
||||||
|
|
||||||
def isreg = kreg
|
|
||||||
def isconst = kcon
|
|
||||||
def istype = ktyp
|
|
||||||
def istup = ktup
|
|
||||||
|
|
||||||
def isunsigned{T} = isint{T} and not issigned{T}
|
def isunsigned{T} = isint{T} and not issigned{T}
|
||||||
|
|
||||||
def isvec {T} = istype{T} and same{typekind{T}, 'vector'} # TODO rename these to better reflect that they apply to types
|
def isvec {T} = ktyp{T} and same{typekind{T}, 'vector'} # TODO rename these to better reflect that they apply to types
|
||||||
def isprim{T} = istype{T} and same{typekind{T}, 'primitive'}
|
def isprim{T} = ktyp{T} and same{typekind{T}, 'primitive'}
|
||||||
def isptr {T} = istype{T} and same{typekind{T}, 'pointer'}
|
def isptr {T} = ktyp{T} and same{typekind{T}, 'pointer'}
|
||||||
def any_num = match { {x:T}=>isprim{T}; {x} => knum{x} }
|
def any_num = match { {x:T}=>isprim{T}; {x} => knum{x} }
|
||||||
def any_int = match { {x:T}=>isint{T}; {x} => knum{x} and (x>>0) == x }
|
def any_int = match { {x:T}=>isint{T}; {x} => knum{x} and (x>>0) == x }
|
||||||
def int_idx{_, _} = 0
|
def int_idx{_, _} = 0
|
||||||
@ -52,8 +47,8 @@ def tree_fold{F, x} = {
|
|||||||
def tree_fold{F, {x}} = x
|
def tree_fold{F, {x}} = x
|
||||||
|
|
||||||
def eachx{F, ...args} = {
|
def eachx{F, ...args} = {
|
||||||
def l = tree_fold{__max, each{{x} => if(istup{x}) length{x} else 0, args}}
|
def l = tree_fold{__max, each{{x} => if(ktup{x}) length{x} else 0, args}}
|
||||||
each{F, ...each{{x} => if (istup{x}) x else l**x, args}}
|
each{F, ...each{{x} => if (ktup{x}) x else l**x, args}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +426,7 @@ def make_branch{Ts, F} = {
|
|||||||
}
|
}
|
||||||
def make_opt_branch{enable, Ts, F} = if (enable) make_branch{Ts, F} else 'not defined'
|
def make_opt_branch{enable, Ts, F} = if (enable) make_branch{Ts, F} else 'not defined'
|
||||||
|
|
||||||
def undef{T, n if istype{T}} = @collect(n) undef{T}
|
def undef{T, n if ktyp{T}} = @collect(n) undef{T}
|
||||||
def undef{Ts if istup{Ts}} = each{undef, Ts}
|
def undef{Ts if ktup{Ts}} = each{undef, Ts}
|
||||||
def undef{x:T} = undef{T}
|
def undef{x:T} = undef{T}
|
||||||
def undef{T if istype{T}} = { reg:=undefined{T} }
|
def undef{T if ktyp{T}} = { reg:=undefined{T} }
|
||||||
|
|||||||
@ -18,11 +18,11 @@ def new_shuf{...vs0 if isvec{try_same_type{vs0,'!'}}, {...is}} = { # : [length{i
|
|||||||
assert{all{(is >= -2) & (is < vn*vcount{S})}, 'bad shuffle indices', ...vs, is}
|
assert{all{(is >= -2) & (is < vn*vcount{S})}, 'bad shuffle indices', ...vs, is}
|
||||||
def widen_inds{sc, is} = flat_table{+, sc*is, range{sc}}
|
def widen_inds{sc, is} = flat_table{+, sc*is, range{sc}}
|
||||||
def data0{(E)} = tup{...vs, is}
|
def data0{(E)} = tup{...vs, is}
|
||||||
def data0{N if istype{N} and isunsigned{N} and N<E} = {
|
def data0{N if ktyp{N} and isunsigned{N} and N<E} = {
|
||||||
def sc = width{E} / width{N}
|
def sc = width{E} / width{N}
|
||||||
tup{...each{re_el{N,.}, vs}, widen_inds{sc, is}}
|
tup{...each{re_el{N,.}, vs}, widen_inds{sc, is}}
|
||||||
}
|
}
|
||||||
def data0{W if istype{W} and isunsigned{W} and W>E} = {
|
def data0{W if ktyp{W} and isunsigned{W} and W>E} = {
|
||||||
def sc = width{W} / width{E}
|
def sc = width{W} / width{E}
|
||||||
if (ni%sc == 0) {
|
if (ni%sc == 0) {
|
||||||
def is2 = (select{is, sc*range{ni/sc}} / sc) >> 0
|
def is2 = (select{is, sc*range{ni/sc}} / sc) >> 0
|
||||||
@ -39,7 +39,7 @@ def new_shuf{...vs0 if isvec{try_same_type{vs0,'!'}}, {...is}} = { # : [length{i
|
|||||||
|
|
||||||
re_el{E, shuf_impl{width{E}*ni, ...vn**width{S}, data}}
|
re_el{E, shuf_impl{width{E}*ni, ...vn**width{S}, data}}
|
||||||
}
|
}
|
||||||
def new_shuf{w if istype{w} or knum{w}, ...vs if isvec{try_same_type{vs,'!'}} and (not isvec{w} or width{w} == width{type0{vs}}), {...is}} = {
|
def new_shuf{w if ktyp{w} or knum{w}, ...vs if isvec{try_same_type{vs,'!'}} and (not isvec{w} or width{w} == width{type0{vs}}), {...is}} = {
|
||||||
def S = type0{vs}
|
def S = type0{vs}
|
||||||
def D = if (isvec{w}) w else re_el{if (isprim{w}) w else ty_u{w}, S}
|
def D = if (isvec{w}) w else re_el{if (isprim{w}) w else ty_u{w}, S}
|
||||||
S~~new_shuf{...each{~~{D,.}, vs}, is}
|
S~~new_shuf{...each{~~{D,.}, vs}, is}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
def has_sel8 = hasarch{'SSSE3'} or hasarch{'AARCH64'}
|
def has_sel8 = hasarch{'SSSE3'} or hasarch{'AARCH64'}
|
||||||
def sel8{v:V, t} = sel{[16]u8, v, make{re_el{i8,V}, t}}
|
def sel8{v:V, t} = sel{[16]u8, v, make{re_el{i8,V}, t}}
|
||||||
def sel8{v:V, t if w256{V} and istup{t} and length{t}==16} = sel8{v, merge{t,t}}
|
def sel8{v:V, t if w256{V} and ktup{t} and length{t}==16} = sel8{v, merge{t,t}}
|
||||||
|
|
||||||
local def rev{t} = { def l=length{t}; def j=l-1; select{j-t, j-range{l}} }
|
local def rev{t} = { def l=length{t}; def j=l-1; select{j-t, j-range{l}} }
|
||||||
local def rev{up,t} = if (up) t else rev{t}
|
local def rev{up,t} = if (up) t else rev{t}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ def arg{c,T} = if (c) *T else if (T==i32) T else tup{} # type of x
|
|||||||
# Modifies the input variable r
|
# Modifies the input variable r
|
||||||
# Assumes iter{} will increment r, by at most write_len
|
# Assumes iter{} will increment r, by at most write_len
|
||||||
def for_special_buffered{r:*T, write_len}{vars,begin,sum,iter} = {
|
def for_special_buffered{r:*T, write_len}{vars,begin,sum,iter} = {
|
||||||
assert{isreg{r}}; assert{begin==0}
|
assert{kreg{r}}; assert{begin==0}
|
||||||
def tw = width{T}
|
def tw = width{T}
|
||||||
def ov = write_len-1
|
def ov = write_len-1
|
||||||
def bufn = 2*(ov+1)
|
def bufn = 2*(ov+1)
|
||||||
@ -90,7 +90,7 @@ def getter{c, V=[k]T, x} = {
|
|||||||
{} => { v:=load{*V~~x, i}; ++i; v }
|
{} => { v:=load{*V~~x, i}; ++i; v }
|
||||||
} else {
|
} else {
|
||||||
i := iota{V}
|
i := iota{V}
|
||||||
if (isreg{x}) i += V**cast_i{T,x}
|
if (kreg{x}) i += V**cast_i{T,x}
|
||||||
ii := V**k
|
ii := V**k
|
||||||
{} => { v:=i; i+=ii; v }
|
{} => { v:=i; i+=ii; v }
|
||||||
}
|
}
|
||||||
@ -373,7 +373,7 @@ fn compress_bool(w:*u64, x:*u64, r:*u64, n:u64) : void = {
|
|||||||
}
|
}
|
||||||
ro = ro2%64
|
ro = ro2%64
|
||||||
}
|
}
|
||||||
def extract{t, i if istup{t}} = select{t,i}
|
def extract{t, i if ktup{t}} = select{t,i}
|
||||||
def v = pext_width{}
|
def v = pext_width{}
|
||||||
if (v > 1) {
|
if (v > 1) {
|
||||||
def V = [v]u64
|
def V = [v]u64
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user