Checklists for adding dialects / transformations #485
Replies: 2 comments 3 replies
-
I guess we might want to distinguish between in-tree and out-of-tree dialects/transforms as our framework is flexible enough to handle both. For the transformations, I think you have mistaken PatternRewriter for RewritePatterns, right?. Usually, I use one pattern per operation when lowering. When optimizing, I try to apply on as small units as possible to have peephole rewrites. If you don't have state, you can also use anonymous rewrites (just a function), though I advise against it as they are not as flexible (say you need to add state in the future) and less intuitive to me personally. Also, the Walker can be parametrized to walk in several ways (regions-first, reverse block order, or recursive application). In the future, we probably want smarter PatternAppliers, but maybe we add docu to those, when they are actually implemented 😅 These are the main thoughts from the top of my head. |
Beta Was this translation helpful? Give feedback.
-
Nice thing to have, thanks!
I think this point may be too dialect-specific to put in general dialect guidelines? I'm not sure
There is
Is this true in general, or only for existing MLIR types? I have a feeling that many of our guidelines may slightly differ for MLIR dialects implementations in xDSL, and xDSL dialects "from scratch" (had similar thoughts on testing)
I would rephrase this, as it is often done during development to iterate? E.g. adding it to register_all_dialects was amongst my first steps. |
Beta Was this translation helpful? Give feedback.
-
I want to collect a bunch of things you should take care of when implementing a dialect / or a transformation. Ideally we also add some links to examples for each step?
Adding a dialect
xsl/dialects
<Opname>Op
for operations and<name>Type
for types.MLIRType
Dialect([list of ops], [list of attributes])
XdslOptMain.register_all_dialects
methodAdding a transformation
xdsl/transformations
PatternRewriter
per rewrite-kind you have (e.g. one optimization, or a lowering for a single op)XdslOptMain.register_all_passes
methodBeta Was this translation helpful? Give feedback.
All reactions