Skip to content

Commit

Permalink
transforms: use Rewriter instead of PatternRewriter in mlir-opt
Browse files Browse the repository at this point in the history
`PatternRewriter` should only be used for rewrite patterns.

stack-info: PR: #3537, branch: math-fehr/stack/1
  • Loading branch information
math-fehr committed Nov 29, 2024
1 parent 190c4f8 commit eb30740
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 eb30740

Please sign in to comment.