diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index 2585e89e..2c876bff 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -25,6 +25,7 @@ def cdiv{a,b} = (a+b-1)/b def lb{n & knum{n} & (n>>1<<1) == n & n>0} = lb{n>>1}+1 def lb{n==1} = 0 +def zlow{n,x} = (x >> n) << n # zero out n least significant bits def tail{n,x} = x & ((1< def widen{T, x:X & n128{X} & vcount{X}>vcount{T}} = widen{T, half{x,0}} def narrow{T, x:X & n128{X} & eqqi{T,eltype{X}} & width{T}*2< elwidth{X}} = narrow{T, undefPromote{ty_half{X}, narrow{ty_half{eltype{X}}, x}}} -def narrow{T, x:X & n128{X} & eqqi{T,eltype{X}} & width{T}*2==elwidth{X}} = emit{ty_half{v_half{X}}, ntyp{'vmovn', v_half{X}}, x} +def narrow{T, x:X & n128{X} & eqqi{T,eltype{X}} & width{T}*2==elwidth{X}} = emit{ty_half{v_half{X}}, ntyp0{'vmovn', X}, x} +def narrowUpper{lowRes:L, x:X & n64{L} & n128{X} & isint{eltype{X}} & ty_dbl{v_dbl{L}}==X} = emit{[vcount{L}*2](eltype{L}), ntyp0{'vmovn_high', X}, lowRes, x} +def narrowPair{a, b} = narrowUpper{narrow{ty_half{eltype{type{a}}}, a}, b} +def widenUpper{x:T & n128{T} & isint{eltype{T}}} = emit{ty_dbl{T}, ntyp0{'vmovl_high', T}, x} +def widen{x:T & n128{T}} = tup{widen{ty_dbl{T}, x}, widenUpper{x}} def bitAny{x:T} = fold_max{to_el{u32, x}}!=0 def bitAll{x:T} = fold_min{to_el{u32, x}}==0xffff_ffff