Skip to content

Commit 7c07542

Browse files
committed
Add Commutative traits
1 parent 3053bb4 commit 7c07542

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

asl_xdsl/dialects/asl.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from xdsl.printer import Printer
4747
from xdsl.traits import (
4848
CallableOpInterface,
49+
Commutative,
4950
ConstantLike,
5051
HasParent,
5152
IsolatedFromAbove,
@@ -519,6 +520,8 @@ class AddIntOp(BinaryIntOp):
519520

520521
name = "asl.add_int"
521522

523+
traits = traits_def(Commutative())
524+
522525

523526
@irdl_op_definition
524527
class SubIntOp(BinaryIntOp):
@@ -533,6 +536,8 @@ class MulIntOp(BinaryIntOp):
533536

534537
name = "asl.mul_int"
535538

539+
traits = traits_def(Commutative())
540+
536541

537542
@irdl_op_definition
538543
class ExpIntOp(BinaryIntOp):
@@ -697,13 +702,17 @@ class EqIntOp(PredicateIntOp):
697702

698703
name = "asl.eq_int"
699704

705+
traits = traits_def(Commutative())
706+
700707

701708
@irdl_op_definition
702709
class NeIntOp(PredicateIntOp):
703710
"""An integer inequality operation."""
704711

705712
name = "asl.ne_int"
706713

714+
traits = traits_def(Commutative())
715+
707716

708717
@irdl_op_definition
709718
class LeIntOp(PredicateIntOp):
@@ -765,6 +774,8 @@ class AddBitsOp(BinaryBitsOp):
765774

766775
name = "asl.add_bits"
767776

777+
traits = traits_def(Commutative())
778+
768779

769780
@irdl_op_definition
770781
class SubBitsOp(BinaryBitsOp):
@@ -779,27 +790,35 @@ class MulBitsOp(BinaryBitsOp):
779790

780791
name = "asl.mul_bits"
781792

793+
traits = traits_def(Commutative())
794+
782795

783796
@irdl_op_definition
784797
class AndBitsOp(BinaryBitsOp):
785798
"""A bit vector AND operation."""
786799

787800
name = "asl.and_bits"
788801

802+
traits = traits_def(Commutative())
803+
789804

790805
@irdl_op_definition
791806
class OrBitsOp(BinaryBitsOp):
792807
"""A bit vector OR operation."""
793808

794809
name = "asl.or_bits"
795810

811+
traits = traits_def(Commutative())
812+
796813

797814
@irdl_op_definition
798815
class XorBitsOp(BinaryBitsOp):
799816
"""A bit vector XOR operation."""
800817

801818
name = "asl.xor_bits"
802819

820+
traits = traits_def(Commutative())
821+
803822

804823
@irdl_op_definition
805824
class AddBitsIntOp(IRDLOperation):
@@ -1203,6 +1222,8 @@ class EqBitsOp(IRDLOperation):
12031222

12041223
name = "asl.eq_bits"
12051224

1225+
traits = traits_def(Commutative())
1226+
12061227
T: ClassVar = VarConstraint("T", BaseAttr(BitVectorType))
12071228

12081229
lhs = operand_def(T)
@@ -1232,6 +1253,8 @@ class NeBitsOp(IRDLOperation):
12321253

12331254
name = "asl.ne_bits"
12341255

1256+
traits = traits_def(Commutative())
1257+
12351258
T: ClassVar = VarConstraint("T", BaseAttr(BitVectorType))
12361259

12371260
lhs = operand_def(T)

0 commit comments

Comments
 (0)