Skip to content

cranelift egraphs #42

@pca006132

Description

@pca006132

Just opening this to discuss how we want to add it. I thought I can do it in an afternoon, but apparently there are some issues here...

  1. Just add the patch to cranelift in this repo, or do we want to upstream the code that serialize the egraph?
  2. How should we deal with root e-class? The main issue is that in cranelift, they don't extract a single thing, but they compute the best extraction cost for each e-class (yeah, they don't care about sharing...).

If someone wants to have a look, here is their code: https://github.com/bytecodealliance/wasmtime/blob/8ea25906f561d6d2e16e6152963f3a87af5a4e46/cranelift/codegen/src/egraph/elaborate.rs#L221

There are some minor annoyance, e.g. they use union nodes instead of e-classes, and e-nodes may belong to one union node or no union node. Haven't yet checked if they can belong to multiple union nodes or something else can reference an e-node with a union node without going through that union node. But this can be canonicalized easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions