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()), all_targets=(get_all_targets()))
module-attribute
Universe
Contains all the dialects, passes, and targets from modules in the environment.
Source code in xdsl/universe.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
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.
all_targets: dict[str, Callable[[], type[Target]]] = {} if all_targets is None else all_targets
instance-attribute
Targets 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, all_targets: dict[str, Callable[[], type[Target]]] | None = None) -> None
Source code in xdsl/universe.py
58 59 60 61 62 63 64 65 66 67 | |
get_multiverse() -> Universe
staticmethod
Traverses the current environment looking for entry points in the
xdsl.universe group.
Source code in xdsl/universe.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |