Skip to content

Commit

Permalink
transforms: use Rewriter instead of PatternRewriter in mlir-opt (xdsl…
Browse files Browse the repository at this point in the history
…project#3537)

Stacked PRs:
 * xdslproject#3540
 * xdslproject#3539
 * xdslproject#3538
 * __->__#3537


--- --- ---

### transforms: use Rewriter instead of PatternRewriter in mlir-opt


`PatternRewriter` should only be used for rewrite patterns.
  • Loading branch information
math-fehr authored and EdmundGoodman committed Dec 6, 2024
1 parent 3934c6a commit 66e761e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xdsl/transforms/mlir_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from xdsl.dialects.builtin import ModuleOp
from xdsl.parser import Parser
from xdsl.passes import ModulePass
from xdsl.pattern_rewriter import PatternRewriter
from xdsl.printer import Printer
from xdsl.rewriter import Rewriter
from xdsl.utils.exceptions import DiagnosticException


Expand Down Expand Up @@ -52,9 +52,10 @@ def apply(self, ctx: MLContext, op: ModuleOp) -> None:

new_module = parser.parse_module()

rewriter = PatternRewriter(op)
op.detach_region(op.body)
op.add_region(rewriter.move_region_contents_to_new_regions(new_module.body))
op.add_region(
Rewriter().move_region_contents_to_new_regions(new_module.body)
)
op.attributes = new_module.attributes
except Exception as e:
raise DiagnosticException(
Expand Down

0 comments on commit 66e761e

Please sign in to comment.