From 427898760862bc4c0910f8194fed2260a29315cc Mon Sep 17 00:00:00 2001 From: azidar Date: Sun, 17 Jan 2016 14:42:04 -0800 Subject: BIT-AND, BIT-OR, and BIT-XOR now can accept SInts. Fixed tests --- src/main/stanza/errors.stanza | 20 ++++++++++---------- src/main/stanza/primop.stanza | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'src') 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,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()) -- cgit v1.2.3