From e27fa8a09678cce1e19b968ed18b2e64312cfae4 Mon Sep 17 00:00:00 2001 From: jackbackrack Date: Mon, 4 May 2015 13:11:14 -0700 Subject: add reduction operators --- src/main/stanza/passes.stanza | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 910b7f3d..e3e22f56 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -1869,6 +1869,9 @@ defn flo-op-name (op:PrimOp) -> String : BIT-NOT-OP : "not" BIT-OR-OP : "or" BIT-XOR-OP : "xor" + BIT-XOR-REDUCE-OP : "xorr" + BIT-AND-REDUCE-OP : "andr" + BIT-OR-REDUCE-OP : "orr" CONCAT-OP : "cat" BIT-SELECT-OP : "rsh" BITS-SELECT-OP : "rsh" -- cgit v1.2.3 From 67930a52eb8393a79c6440a31b79b270e4930abb Mon Sep 17 00:00:00 2001 From: jackbackrack Date: Thu, 7 May 2015 10:31:29 -0700 Subject: do signed padding as well --- src/main/stanza/passes.stanza | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index b5c3b22c..d04f7366 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -1854,10 +1854,10 @@ defn flo-op-name (op:PrimOp) -> String : EQUAL-SS-OP : "eq" MUX-UU-OP : "mux" MUX-SS-OP : "mux" - PAD-U-OP : "rsh" ;; todo: signed version - PAD-S-OP : "rsh" ;; todo: signed version - NEG-U-OP : "neg" - NEG-S-OP : "neg" + PAD-U-OP : "rsh" + PAD-S-OP : "arsh" + NEG-U-OP : "neg" + NEG-S-OP : "neg" ;AS-UINT-U-OP : ;AS-UINT-S-OP : ;AS-SINT-U-OP : @@ -1927,7 +1927,10 @@ defn emit! (e:Expression,top:Symbol) : (e:Subfield) : emit-all([exp(e) "/" name(e)], top) (e:Index) : emit-all([exp(e) "/" value(e)], top) (e:Pad) : - emit-all(["rsh'" prim-width(type(e)) " " value(e) " 0"], top) + val op-name = match(type(e)) : + (t:SIntType) : "arsh" + (u) : "rsh" + emit-all([op-name "'" prim-width(type(e)) " " value(e) " 0"], top) (e:Register) : emit-all(["reg'" prim-width(type(e)) " " enable(e) " " value(e)], top) (e:ReadPort) : -- cgit v1.2.3 From eb7d0913bd01cffdc2be944c7001721f737b44bf Mon Sep 17 00:00:00 2001 From: jackbackrack Date: Mon, 18 May 2015 21:53:35 -0700 Subject: get coercion running for flo backend and disable negative lit check --- src/main/stanza/errors.stanza | 6 +++--- src/main/stanza/passes.stanza | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index 30414afd..93250b6f 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -158,9 +158,9 @@ public defn check-high-form (c:Circuit) -> Circuit : match(exp(e)) : (e:Ref|Subfield|Index) : false (e) : add(errors,InvalidIndex(info)) - (e:UIntValue) : - if value(e) < 0 : - add(errors,NegUInt(info)) + ;; (e:UIntValue) : + ;; if value(e) < 0 : + ;; add(errors,NegUInt(info)) (e) : false e diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 131f0a7b..ee96708c 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -747,7 +747,7 @@ defn expand-expr (e:Expression) -> List : val f = {_ as Field} $ for f in fields(type(exp(e)) as BundleType) find : name(f) == name(e) if inst?(exp(e)) : - println-all(["here with " exp(e)]) + ;; println-all(["here with " exp(e)]) for x in generate-entry(name(f),type(f)) map : EF(WSubfield(exp(e),name(x),type(x),gender(e)),flip(x)) else : @@ -1886,10 +1886,10 @@ defn flo-op-name (op:PrimOp) -> String : PAD-S-OP : "arsh" NEG-U-OP : "neg" NEG-S-OP : "neg" - ;AS-UINT-U-OP : - ;AS-UINT-S-OP : - ;AS-SINT-U-OP : - ;AS-SINT-S-OP : + AS-UINT-U-OP : "mov" + AS-UINT-S-OP : "mov" + AS-SINT-U-OP : "mov" + AS-SINT-S-OP : "mov" SHIFT-LEFT-U-OP : "lsh" SHIFT-LEFT-S-OP : "lsh" SHIFT-RIGHT-U-OP : "rsh" @@ -1898,8 +1898,8 @@ defn flo-op-name (op:PrimOp) -> String : DYN-SHIFT-LEFT-S-OP : "lsh" DYN-SHIFT-RIGHT-U-OP : "rsh" DYN-SHIFT-RIGHT-S-OP : "arsh" - ;CONVERT-U-OP : - ;CONVERT-S-OP : + CONVERT-U-OP : "arsh" + CONVERT-S-OP : "mov" BIT-AND-OP : "and" BIT-NOT-OP : "not" BIT-OR-OP : "or" @@ -1970,6 +1970,8 @@ defn emit! (e:Expression,top:Symbol) : emit-all([" " args(e)[1] " " args(e)[0]], top) else : emit-all([" " args(e)[0] " " args(e)[1]], top) + else if op(e) == CONVERT-U-OP : + emit-all(["arsh'" prim-width(type(e)) " " args(e)[0] " 0"], top) else if op(e) == BIT-SELECT-OP : emit-all([flo-op-name(op(e)) "'1 " args(e)[0] " " consts(e)[0]], top) else if op(e) == BITS-SELECT-OP : -- cgit v1.2.3