chomsky-linker
Linker for E-Graphs, handling cross-module references and fusion in the Chomsky framework.
Overview
chomsky-linker allows for merging multiple independent E-Graphs into a single global graph. It resolves Import and Export references across modules, enabling whole-program optimization and cross-module fusion.
Features
- E-Graph Merging: Robust logic to copy nodes and e-classes from multiple source graphs into a global
IKunLinker. - Symbol Resolution: Automatically links
Importnodes to their correspondingExportdefinitions across modules. - Cross-Module Fusion: By merging graphs, the optimizer can reason about calls between modules as if they were in the same graph, unlocking further rewrite opportunities.
- Recursive Node Mapping: Handles complex graph structures and maintains canonical forms during the merge process.
Core Concepts
IKunLinker
The main linker implementation. It:
- Maintains a
global_graph. - Tracks
exportsfrom all added modules. - Performs symbol resolution by unifying
Importe-classes with their targetExporte-classes.
Usage
use IKunLinker;
use ;
let mut linker = new;
let mod1 = new;
// ... add exports to mod1 ...
linker.add_module;
let mod2 = new;
// ... add imports to mod2 ...
linker.add_module;
linker.link;