From 56d1453185d4e90be4dcb5e3b7b9e7cb5edf42c3 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 6 May 2023 13:18:00 +0300 Subject: [PATCH] use destructuring more in Singeli --- src/singeli/src/dyarith.singeli | 12 ++++-------- src/singeli/src/squeeze.singeli | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/singeli/src/dyarith.singeli b/src/singeli/src/dyarith.singeli index 10608919..35ae63e9 100644 --- a/src/singeli/src/dyarith.singeli +++ b/src/singeli/src/dyarith.singeli @@ -103,8 +103,8 @@ def runner{u, R, F} = { run{F, M, VS~~toggleTop{w}, VS~~toggleTop{x}} } def run{F, M, w:VU, x:VS & is_u{VU} & is_s{VS}} = { # 'a'+3, 'a'-3 - def r = run{F, M, VS~~toggleTop{w}, x} - tup{toggleTop{VU~~tupsel{0,r}}, tupsel{1,r}} + def {res, ok} = run{F, M, VS~~toggleTop{w}, x} + tup{toggleTop{VU~~res}, ok} } def run{F==__add, M, w:VS, x:VU & is_s{VS} & is_u{VU}} = run{F, M, x, w} # 3+'a' → 'a'+3 @@ -122,9 +122,7 @@ def runChecks{type=='topAny', vals, M} = runChecks_any{topAny, vals} def runChecks{type=='none', vals, M} = 0 def runChecks{type=='~andAllZero', vals, M & ~M{0}} = ~tree_fold{&, each{andAllZero, ...slice{flip{vals}, 1}}} def runChecks{type=='anyne', vals, M} = { - def cols = flip{vals} - def xs = tupsel{1, cols} - def ys = tupsel{2, cols} + def {_, xs, ys} = flip{vals} if (tuplen{vals}==1) { anyne{...xs, ...ys, M} } else { @@ -134,9 +132,7 @@ def runChecks{type=='anyne', vals, M} = { } def arithProcess{F, run, overflow, M, is, cw, cx, TY} = { - def r0 = flip{each{{w1, x1} => run{F, M, w1, x1}, cw, cx}} - def values = tupsel{0, r0} - def checks = tupsel{1, r0} + def {values, checks} = flip{each{{w1, x1} => run{F, M, w1, x1}, cw, cx}} def ctype = tupsel{0,tupsel{0,checks}} assert{tree_fold{&, each{{c}=>match{ctype, tupsel{0,c}}, checks}}} if (rare{runChecks{ctype, checks, M}}) overflow{tupsel{0, is}} diff --git a/src/singeli/src/squeeze.singeli b/src/singeli/src/squeeze.singeli index 302cb064..d76954cb 100644 --- a/src/singeli/src/squeeze.singeli +++ b/src/singeli/src/squeeze.singeli @@ -116,7 +116,7 @@ fn squeeze{vw, X, CHR, B}(x0:*void, len:Size) : u32 = { def v0 = loadBatch{xp, is, XV} def int = { - def tmp = { + def {int, wdn} = { if (hasarch{'AARCH64'} and tuplen{is}==2) { def intp = narrowPair{...each{{v}=>cvt{i64,v}, v0}} def wdn = each{{v}=>cvt{f64,v}, widen{intp}} @@ -135,8 +135,6 @@ fn squeeze{vw, X, CHR, B}(x0:*void, len:Size) : u32 = { } } } - def int = tupsel{0, tmp} - def wdn = tupsel{1, tmp} def conv{x} = tern{preserve_negative_zero, ty_u{x}, x} def as = each{conv, v0}