def nvec{T} = 0 def nvec{T if isvec{T}} = (width{T}==64) | (width{T}==128) def nvec{T,w} = 0 def nvec{T,w if nvec{T}} = elwidth{T}==w def nveci = genchk{nvec, isint} def nvecs = genchk{nvec, issigned} def nvecu = genchk{nvec, isunsigned} def nvecf = genchk{nvec, isfloat} def reinterpret{T, v if same{'pointer',typekind{T}} and ktup{v}} = { tmp:T=v } def nty{T} = { def q = quality{T} merge{if (q=='i') 's' else q, fmtnat{width{T}}} } def nty{T if isvec{T}} = nty{eltype{T}} def ntyp{S, ...S2, T if w128{T}} = merge{S, 'q', ...S2, '_', nty{T}} def ntyp{S, ...S2, T if w64{T}} = merge{S, ...S2, '_', nty{T}} def ntyp0{S, T} = merge{S, '_', nty{T}} def addwLo{a:T,b:T if w64i{T}} = emit{el_d{T}, ntyp{'vaddl', T}, a, b} def subwLo{a:T,b:T if w64i{T}} = emit{el_d{T}, ntyp{'vsubl', T}, a, b} def mulwLo{a:T,b:T if w64i{T}} = emit{el_d{T}, ntyp{'vmull', T}, a, b} def mulwHi{a:T,b:T if w128i{T}} = emit{el_m{T}, ntyp0{'vmull_high', T}, a, b} def mulw {a:T,b:T if w128{T}} = tup{mulwLo{half{a,0}, half{b,0}}, mulwHi{a,b}} def shrn{a:T, s if w128i{T} and elwidth{T}>8} = { def H=el_h{T}; emit{H, ntyp0{'vshrn_n', T}, a, s} } # a>>s, narrowed def shrm{a:T, s, d:T if nvecu{T}} = emit{T, ntyp{'vsri', '_n', T}, d, a, s} # (a>>s) | (d & (mask of new zeroes)) def shlm{a:T, s, d:T if nvecu{T}} = emit{T, ntyp{'vsli', '_n', T}, d, a, s} # (a< elwidth{X}*2} = widen{T, widen{el_s{T}, x}} def widen{T, x:X if w64{X} and isfloat{eltype{T}}!=isfloat{eltype{X}} and elwidth{T}>elwidth{X}} = cvt{eltype{T}, widen{[vcount{T}](to_w{eltype{X},elwidth{T}}), x}} def widen{T, x:X if w128{X} and vcount{X}>vcount{T}} = widen{T, half{x,0}} def narrow{T, x:X if w128{X} and eqqi{T,eltype{X}} and width{T}*2< elwidth{X}} = narrow{T, undefPromote{el_s{X}, narrow{w_h{eltype{X}}, x}}} def narrow{T, x:X if w128{X} and eqqi{T,eltype{X}} and width{T}*2==elwidth{X}} = emit{el_h{X}, ntyp0{'vmovn', X}, x} def narrow{T, x:X if w128{X} and isfloat{T}!=isfloat{eltype{X}} and width{T}=vcount{T}} = { truncBits{vcount{T}, fold_add{x & make{T, 1<1 and elwidth{type{select{as,0}}}>=32} = homMask{...each{{i}=>narrowPair{select{as,i*2},select{as,i*2+1}}, iota{length{as}/2}}} def homMask{a:T,b:T if vcount{T}*2<=elwidth{T}} = { def n = vcount{T} truncBits{n*2, fold_add{shrm{a,elwidth{T}-n,b} & make{T, (1<