From 54fc9a871036acefed04bcb0397676d6984896c1 Mon Sep 17 00:00:00 2001 From: Sasha Lopoukhine Date: Sun, 20 Oct 2024 09:19:27 -0700 Subject: [PATCH] dialects: (arith) fix attribute dictionary printing and parsing (#3327) Currently dropped, this is needed for #3315 to work correctly. --- tests/filecheck/dialects/arith/arith_ops.mlir | 4 ++++ xdsl/dialects/arith.py | 20 ++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/filecheck/dialects/arith/arith_ops.mlir b/tests/filecheck/dialects/arith/arith_ops.mlir index 9ab8e752f0..28d4a68d73 100644 --- a/tests/filecheck/dialects/arith/arith_ops.mlir +++ b/tests/filecheck/dialects/arith/arith_ops.mlir @@ -113,6 +113,10 @@ // CHECK-NEXT: %minf = arith.minnumf %lhsf32, %rhsf32 : f32 // CHECK-NEXT: %minf_vector = arith.minnumf %lhsvec, %rhsvec : vector<4xf32> + %addi = arith.addi %lhsi32, %rhsi32 {"hello" = "world"} : i32 + + // CHECK-NEXT: %addi = arith.addi %lhsi32, %rhsi32 {"hello" = "world"} : i32 + %addf = arith.addf %lhsf32, %rhsf32 : f32 %addf_vector = arith.addf %lhsvec, %rhsvec : vector<4xf32> diff --git a/xdsl/dialects/arith.py b/xdsl/dialects/arith.py index b5281171aa..0447d3edc2 100644 --- a/xdsl/dialects/arith.py +++ b/xdsl/dialects/arith.py @@ -181,6 +181,8 @@ class SignlessIntegerBinaryOperation(IRDLOperation, abc.ABC): rhs = operand_def(T) result = result_def(T) + assembly_format = "$lhs `,` $rhs attr-dict `:` type($result)" + def __init__( self, operand1: Operation | SSAValue, @@ -191,24 +193,6 @@ def __init__( result_type = SSAValue.get(operand1).type super().__init__(operands=[operand1, operand2], result_types=[result_type]) - @classmethod - def parse(cls, parser: Parser): - lhs = parser.parse_unresolved_operand() - parser.parse_punctuation(",") - rhs = parser.parse_unresolved_operand() - parser.parse_punctuation(":") - result_type = parser.parse_type() - (lhs, rhs) = parser.resolve_operands([lhs, rhs], 2 * [result_type], parser.pos) - return cls(lhs, rhs, result_type) - - def print(self, printer: Printer): - printer.print(" ") - printer.print_ssa_value(self.lhs) - printer.print(", ") - printer.print_ssa_value(self.rhs) - printer.print(" : ") - printer.print_attribute(self.result.type) - def __hash__(self) -> int: return id(self)