diff --git a/tests/filecheck/dialects/scf/unregistered.mlir b/tests/filecheck/dialects/scf/unregistered.mlir new file mode 100644 index 0000000000..47651093d5 --- /dev/null +++ b/tests/filecheck/dialects/scf/unregistered.mlir @@ -0,0 +1,22 @@ +// RUN: xdsl-opt %s --print-op-generic --allow-unregistered-dialect | xdsl-opt --allow-unregistered-dialect | filecheck %s + +// CHECK: func.func @for_unregistered() { +// CHECK-NEXT: %lb = arith.constant 0 : index +// CHECK-NEXT: %ub = arith.constant 42 : index +// CHECK-NEXT: %s = arith.constant 3 : index +// CHECK-NEXT: scf.for %iv = %lb to %ub step %s { +// CHECK-NEXT: "unregistered_op"() : () -> () +// CHECK-NEXT: } +// CHECK-NEXT: func.return +// CHECK-NEXT: } + +func.func @for_unregistered() { + %lb = arith.constant 0 : index + %ub = arith.constant 42 : index + %s = arith.constant 3 : index + scf.for %iv = %lb to %ub step %s { + "unregistered_op"() : () -> () + scf.yield + } + func.return +} diff --git a/xdsl/printer.py b/xdsl/printer.py index 6741a5503e..e11997c249 100644 --- a/xdsl/printer.py +++ b/xdsl/printer.py @@ -356,7 +356,9 @@ def print_block( with self.indented(): for op in block.ops: - if not print_block_terminator and op.has_trait(IsTerminator): + if not print_block_terminator and op.has_trait( + IsTerminator, value_if_unregistered=False + ): continue self._print_new_line() self.print_op(op)