Bases: RewritePattern
A rewrite pattern that uses the pdl_interp dialect for matching and rewriting operations.
Source code in xdsl/transforms/apply_pdl_interp.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 | @dataclass
class PDLInterpRewritePattern(RewritePattern):
"""
A rewrite pattern that uses the pdl_interp dialect for matching and rewriting operations.
"""
interpreter: Interpreter
functions: PDLInterpFunctions
matcher: pdl_interp.FuncOp
name: None | str = None
def __init__(
self,
matcher: pdl_interp.FuncOp,
interpreter: Interpreter,
functions: PDLInterpFunctions,
name: None | str = None,
):
self.functions = functions
module = matcher.parent_op()
assert isinstance(module, ModuleOp)
self.interpreter = interpreter
if matcher.sym_name.data != "matcher":
raise ValueError("Matcher function name must be 'matcher'")
self.matcher = matcher
self.name = name
def match_and_rewrite(self, xdsl_op: Operation, rewriter: PatternRewriter) -> None:
# Setup the rewriter
self.functions.set_rewriter(self.interpreter, rewriter)
# Call the matcher function on the operation
self.interpreter.call_op(self.matcher, (xdsl_op,))
|
Source code in xdsl/transforms/apply_pdl_interp.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 | def __init__(
self,
matcher: pdl_interp.FuncOp,
interpreter: Interpreter,
functions: PDLInterpFunctions,
name: None | str = None,
):
self.functions = functions
module = matcher.parent_op()
assert isinstance(module, ModuleOp)
self.interpreter = interpreter
if matcher.sym_name.data != "matcher":
raise ValueError("Matcher function name must be 'matcher'")
self.matcher = matcher
self.name = name
|
Source code in xdsl/transforms/apply_pdl_interp.py
| def match_and_rewrite(self, xdsl_op: Operation, rewriter: PatternRewriter) -> None:
# Setup the rewriter
self.functions.set_rewriter(self.interpreter, rewriter)
# Call the matcher function on the operation
self.interpreter.call_op(self.matcher, (xdsl_op,))
|