Skip to content

Commit

Permalink
Update pdl_to_irdl check
Browse files Browse the repository at this point in the history
  • Loading branch information
math-fehr committed May 15, 2024
1 parent a481f5d commit d4fdb0b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions xdsl_pdl/tools/pdl_to_irdl_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

from xdsl.dialects.pdl import (
PDL,
AttributeOp,
OperandOp,
OperationOp,
PatternOp,
ReplaceOp,
ResultOp,
RewriteOp,
TypeOp,
)

from xdsl.dialects.builtin import Builtin
Expand Down Expand Up @@ -103,6 +105,18 @@ def convert_pattern_to_check_subset(program: PatternOp) -> CheckSubsetOp:
assert isinstance(root, OpResult)

while (op := rewrite.body.ops.first) is not None:
if isinstance(op, AttributeOp):
op.detach()
if op.value_type:
assert isinstance(op.value_type, OpResult)
Rewriter.insert_op_after(op.value_type.owner, op)
else:
Rewriter.insert_op_before(root.owner, op)
continue
if isinstance(op, TypeOp):
op.detach()
Rewriter.insert_op_before(root.owner, op)
continue
if isinstance(op, OperationOp):
op.detach()
Rewriter.insert_op_before(root.owner, op)
Expand Down

0 comments on commit d4fdb0b

Please sign in to comment.