aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorazidar2016-01-17 14:42:04 -0800
committerazidar2016-01-17 14:42:04 -0800
commit427898760862bc4c0910f8194fed2260a29315cc (patch)
tree13f7da1f4ef4302fda94f153d29e9b5f93fd30f5 /src
parent81e47120c8586871fd96e22e0626591d3b5a7cc5 (diff)
BIT-AND, BIT-OR, and BIT-XOR now can accept SInts. Fixed tests
Diffstat (limited to 'src')
-rw-r--r--src/main/stanza/errors.stanza20
-rw-r--r--src/main/stanza/primop.stanza18
2 files changed, 25 insertions, 13 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza
index 63199b4b..fb754406 100644
--- a/src/main/stanza/errors.stanza
+++ b/src/main/stanza/errors.stanza
@@ -517,16 +517,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-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-NOT-OP : all-same-type(args(e)) ;can be either uint or sint
+ BIT-AND-OP : all-same-type(args(e)) ;can be either uint or sint
+ BIT-OR-OP : all-same-type(args(e)) ;can be either uint or sint
+ BIT-XOR-OP : all-same-type(args(e)) ;can be either uint or sint
+ BIT-SELECT-OP : false ;can be either uint or sint
+ BITS-SELECT-OP : false ;can be either uint or sint
+ BIT-AND-REDUCE-OP : false ;can be either uint or sint
+ BIT-OR-REDUCE-OP : false ;can be either uint or sint
+ BIT-XOR-REDUCE-OP : false ;can be either uint or sint
+ CONCAT-OP : false ;can be either uint or sint
;----------------- 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 6c43c494..2a2d75f2 100644
--- a/src/main/stanza/primop.stanza
+++ b/src/main/stanza/primop.stanza
@@ -146,9 +146,21 @@ public defn set-primop-type (e:DoPrim) -> DoPrim :
(t1:SIntType) : SIntType(w1())
(t1) : UnknownType()
BIT-NOT-OP : DoPrim(o,a,c,t1())
- BIT-AND-OP : DoPrim(o,a,c,UIntType(MAX(w1(),w2())))
- BIT-OR-OP : DoPrim(o,a,c,UIntType(MAX(w1(),w2())))
- BIT-XOR-OP : DoPrim(o,a,c,UIntType(MAX(w1(),w2())))
+ BIT-AND-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType) : UIntType(MAX(w1(),w2()))
+ (t1:SIntType) : SIntType(MAX(w1(),w2()))
+ (t1) : UnknownType()
+ BIT-OR-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType) : UIntType(MAX(w1(),w2()))
+ (t1:SIntType) : SIntType(MAX(w1(),w2()))
+ (t1) : UnknownType()
+ BIT-XOR-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType) : UIntType(MAX(w1(),w2()))
+ (t1:SIntType) : SIntType(MAX(w1(),w2()))
+ (t1) : UnknownType()
BIT-AND-REDUCE-OP : DoPrim(o,a,c,BoolType())
BIT-OR-REDUCE-OP : DoPrim(o,a,c,BoolType())
BIT-XOR-REDUCE-OP : DoPrim(o,a,c,BoolType())