xDSL
Project description
xDSL: A Python-native SSA Compiler Framework
xDSL is a Python-native compiler framework built around SSA-based intermediate representations (IRs). Users of xDSL build a compiler by assembling predefined domain-specific IRs and, optionally, defining their own custom IRs. xDSL uses multi-level IRs, meaning that during the compilation process, a program will be lowered through several of these IRs. This allows the implementation of abstraction-specific optimization passes, similar to the structure of common DSL compilers (such as Devito, Psyclone, and Firedrake). To simplify the writing of these passes, xDSL uses a uniform data structure based on SSA, basic blocks, and regions, which additionally enables the writing of generic passes.
The design of xDSL is influenced by MLIR, a compiler framework developed in C++, that is part of the LLVM project. An inherent advantage of a close design is the easy interaction between the two frameworks, making it possible to translate abstractions and programs back and forth. This results in one big SSA-based abstraction ecosystem that can be worked with through Python, making analysis through simple scripting languages possible. Additionally, xDSL can leverage MLIR's code generation and low-level optimization capabilities.
Installation
To use xDSL as part of a larger project for developing your own compiler, just install xDSL via pip:
pip install xdsl
Note: This version of xDSL is validated against a specific MLIR version,
interoperability with other versions may result in problems. The supported
MLIR version is commit 98e674c9f16d677d95c67bc130e267fae331e43c
.
Subprojects With Extra Dependencies
xDSL has a number of subprojects, some of which require extra dependencies. In order to keep the set of dependencies ot a minimum, these extra dependencies have to be specified explicitly. To install these, use:
pip install xdsl[gui,jax,riscv,wgpu,onnx]
To install the testing/development dependencies, use:
pip install xdsl[dev]
These may be useful for projects wanting to replicate the xDSL testing setup.
Getting Started
Check out the dedicated Getting Started guide for a comprehensive tutorial.
To get familiar with xDSL, we recommend starting with our Jupyter notebooks. The notebooks consist of examples and documentation concerning the core xDSL data structures and the xDSL's Python-embedded abstraction definition language, as well as examples of implementing custom compilers, like a database compiler. There also exists a small documentation showing how to connect xDSL with MLIR for users interested in that use case.
We provide a Makefile containing a lot of common tasks, which might provide an overview of common actions.
xDSL Developer Setup
To contribute to the development of xDSL follow the subsequent steps.
Developer Installation
git clone https://github.com/xdslproject/xdsl.git
cd xdsl
# set up the venv and install everything
make venv
# activate the venv
source venv/bin/activate
Testing
The xDSL project uses pytest unit tests and LLVM-style filecheck tests. They can be executed from the root directory:
# Executes pytests which are located in tests/
pytest
# Executes filecheck tests
lit tests/filecheck
# run all tests using makefile
make tests
Formatting and Typechecking
All python code used in xDSL uses ruff to format the code in a uniform manner.
To automate the formatting, we use pre-commit hooks from the pre-commit package.
# Install the pre-commit on your `.git` folder
make precommit-install
# to run the hooks:
make precommit
# alternatively, run ruff directly:
ruff format
Furthermore, all python code must run through pyright
without errors. Pyright can be run on all staged files through the
makefile using make pyright
.
Discussion
You can also join the discussion at our Zulip chat room, kindly supported by community hosting from Zulip.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file xdsl-0.23.0.tar.gz
.
File metadata
- Download URL: xdsl-0.23.0.tar.gz
- Upload date:
- Size: 688.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28b177543cd6d4a6cb85bf48c63b938e13c37baf152873fa1015b6c19b1732a6 |
|
MD5 | 735ade46e96b686036f8c4d472d1cac1 |
|
BLAKE2b-256 | 95615a8434d97067eca8e36bb00e711d5af3a6e3152d3cecb0c6b55f54fc6885 |
File details
Details for the file xdsl-0.23.0-py3-none-any.whl
.
File metadata
- Download URL: xdsl-0.23.0-py3-none-any.whl
- Upload date:
- Size: 765.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b3c24be081964ab35b711aeff23f481668b3a123f0054482d1464d8175f30cc |
|
MD5 | 9a8717c6d33d64e9332c4e89942a79ef |
|
BLAKE2b-256 | 90b5ef9f273d437bce5de637110bfe27f5b715a9f76dff7744f10e088def6b0a |