diff options
| author | azidar | 2015-07-31 17:13:25 -0700 |
|---|---|---|
| committer | azidar | 2015-07-31 17:13:25 -0700 |
| commit | 612d59c10fa2a320305144e7aeaae7040aba4ed7 (patch) | |
| tree | a09beea722ec64f9cba4ececd9c7b94560af30e6 /src/main | |
| parent | ba55a55ee07805d28995b535beb5a19bd4a99c5c (diff) | |
Allow bit operations on sints
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/stanza/errors.stanza | 28 | ||||
| -rw-r--r-- | src/main/stanza/primop.stanza | 14 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index f97b43b7..924eba2c 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -543,20 +543,28 @@ defn s () -> SIntType : SIntType(UnknownWidth()) defn check-types-primop (e:DoPrim, errors:Vector<PassException>,info:FileInfo) -> False : defn all-same-type (ls:List<Expression>) -> False : + var error? = false for x in ls do : if type(head(ls)) != type(x) : - add(errors,OpNotAllSameType(info,to-symbol $ op(e))) + error? = true + if error? : add(errors,OpNotAllSameType(info,to-symbol $ op(e))) defn all-ground (ls:List<Expression>) -> False : + var error? = false for x in ls do : if not (type(x) typeof UIntType or type(x) typeof SIntType) : - add(errors,OpNotGround(info,to-symbol $ op(e))) + error? = true + if error? : add(errors,OpNotGround(info,to-symbol $ op(e))) defn all-uint (ls:List<Expression>) -> False : + var error? = false for x in ls do : if not (type(x) typeof UIntType) : - add(errors,OpNotAllUInt(info,to-symbol $ op(e))) + error? = true + if error? : add(errors,OpNotAllUInt(info,to-symbol $ op(e))) defn is-uint (x:Expression) -> False : + var error? = false if not (type(x) typeof UIntType) : - add(errors,OpNotUInt(info,to-symbol $ op(e),to-symbol(x))) + error? = true + if error? : add(errors,OpNotUInt(info,to-symbol $ op(e),to-symbol(x))) all-ground(args(e)) @@ -590,16 +598,16 @@ defn check-types-primop (e:DoPrim, errors:Vector<PassException>,info:FileInfo) - SHIFT-RIGHT-OP : false CONVERT-OP : false NEG-OP : false - BIT-NOT-OP : all-uint(args(e)) - BIT-AND-OP : all-uint(args(e)) - BIT-OR-OP : all-uint(args(e)) - BIT-XOR-OP : all-uint(args(e)) + BIT-NOT-OP : all-same-type(args(e)) + BIT-AND-OP : all-same-type(args(e)) + BIT-OR-OP : all-same-type(args(e)) + BIT-XOR-OP : all-same-type(args(e)) + BIT-SELECT-OP : false + BITS-SELECT-OP : false BIT-AND-REDUCE-OP : all-uint(args(e)) BIT-OR-REDUCE-OP : all-uint(args(e)) BIT-XOR-REDUCE-OP : all-uint(args(e)) CONCAT-OP : all-uint(args(e)) - BIT-SELECT-OP : all-uint(args(e)) - BITS-SELECT-OP : all-uint(args(e)) ;----------------- Check Types Pass --------------------- public defn check-types (c:Circuit) -> Circuit : diff --git a/src/main/stanza/primop.stanza b/src/main/stanza/primop.stanza index f7eb6d04..0d304d32 100644 --- a/src/main/stanza/primop.stanza +++ b/src/main/stanza/primop.stanza @@ -50,14 +50,14 @@ public defn lower-and-type-primop (e:DoPrim) -> DoPrim : SHIFT-LEFT-OP : DoPrim(SHIFT-LEFT-OP,args(e),consts(e),of-type(args(e)[0])) SHIFT-RIGHT-OP : DoPrim(SHIFT-RIGHT-OP,args(e),consts(e),of-type(args(e)[0])) CONVERT-OP : DoPrim(CONVERT-OP,args(e),consts(e),s()) - NEG-OP : DoPrim(NEG-OP,args(e),consts(e),u()) - BIT-NOT-OP : DoPrim(op(e),args(e),consts(e),u()) - BIT-AND-OP : DoPrim(op(e),args(e),consts(e),u()) - BIT-OR-OP : DoPrim(op(e),args(e),consts(e),u()) - BIT-XOR-OP : DoPrim(op(e),args(e),consts(e),u()) + NEG-OP : DoPrim(NEG-OP,args(e),consts(e),s()) + BIT-NOT-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) + BIT-AND-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) + BIT-OR-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) + BIT-XOR-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) + BIT-SELECT-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) + BITS-SELECT-OP : DoPrim(op(e),args(e),consts(e),of-type(args(e)[0]))) CONCAT-OP : DoPrim(op(e),args(e),consts(e),u()) - BIT-SELECT-OP : DoPrim(op(e),args(e),consts(e),u()) - BITS-SELECT-OP : DoPrim(op(e),args(e),consts(e),u()) BIT-AND-REDUCE-OP : DoPrim(op(e),args(e),consts(e),u()) BIT-OR-REDUCE-OP : DoPrim(op(e),args(e),consts(e),u()) BIT-XOR-REDUCE-OP : DoPrim(op(e),args(e),consts(e),u()) |
