Skip to content

Commit

Permalink
Add transfer dialect for experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
math-fehr committed Aug 19, 2024
1 parent 8acfe91 commit a710ac4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions xdsl_pdl/dialects/transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from xdsl.ir import ParametrizedAttribute, TypeAttribute, Dialect

from xdsl.irdl import (
irdl_attr_definition,
ParametrizedAttribute,
)


@irdl_attr_definition
class IntegerType(ParametrizedAttribute, TypeAttribute):
name = "transfer.integer"


Transfer = Dialect("transfer", [], [IntegerType])
5 changes: 4 additions & 1 deletion xdsl_pdl/passes/pdl_to_irdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RewritePattern,
op_type_rewrite_pattern,
)

from xdsl_pdl.dialects import transfer
from xdsl.dialects.pdl import (
ApplyNativeConstraintOp,
ApplyNativeRewriteOp,
Expand Down Expand Up @@ -201,6 +201,9 @@ def match_and_rewrite(self, op: TypeOp, rewriter: PatternRewriter, /):
if op.constantType is None:
rewriter.replace_matched_op(irdl.AnyOp())
return
if op.constantType == transfer.IntegerType():
rewriter.replace_matched_op(irdl.BaseOp("!builtin.integer_type"))
return
rewriter.replace_matched_op(irdl.IsOp(op.constantType))


Expand Down
2 changes: 2 additions & 0 deletions xdsl_pdl/tools/analyze_irdl_invariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from xdsl.rewriter import InsertPoint, Rewriter
from xdsl_pdl.analysis.check_subset_to_z3 import check_subset_to_z3
from xdsl_pdl.dialects.irdl_extension import IRDLExtension
from xdsl_pdl.dialects.transfer import Transfer

from xdsl.dialects.builtin import (
Builtin,
Expand Down Expand Up @@ -39,6 +40,7 @@ def main():
ctx.load_dialect(IRDL)
ctx.load_dialect(IRDLExtension)
ctx.load_dialect(PDL)
ctx.load_dialect(Transfer)

# Parse the input program
with open(args.input_file) as f:
Expand Down

0 comments on commit a710ac4

Please sign in to comment.