Universe
universe
xDSL leverages Python plugins for user-provided compiler infrastructure.
Python packages that want to extend the passes and dialects available in xdsl-opt can
implement their own Universe, which will be discovered by Multiverse at runtime.
To opt into this behavior first add a Universe instance somewhere in your project,
for example in your_project/universe.py:
def get_dialect():
...
def get_pass():
...
YOUR_UNIVERSE = Universe(
all_dialects={"your_dialect": get_dialect},
all_passes={"your-pass": get_pass},
)
Then, add the following entry in your pyproject.toml file:
[project.entry-points.'xdsl.universe']
your_project = 'your_project.universe:YOUR_UNIVERSE'
Note that any clashes in names of dialects or passes will result in an error.
XDSL_UNIVERSE = Universe(all_dialects=(get_all_dialects()), all_passes=(get_all_passes()))
module-attribute
Universe
Contains all the dialects and passes from modules in the environment.
Source code in xdsl/universe.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
all_dialects: dict[str, Callable[[], Dialect]] = {} if all_dialects is None else all_dialects
instance-attribute
Dialects from all modules in the current environment.
all_passes: dict[str, Callable[[], type[ModulePass]]] = {} if all_passes is None else all_passes
instance-attribute
Passes from all modules in the current environment.
__init__(*, all_dialects: dict[str, Callable[[], Dialect]] | None = None, all_passes: dict[str, Callable[[], type[ModulePass]]] | None = None) -> None
Source code in xdsl/universe.py
53 54 55 56 57 58 59 60 | |
get_multiverse() -> Universe
staticmethod
Traverses the current environment looking for entry points in the
xdsl.universe group.
Source code in xdsl/universe.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |