This repository consists of the following four top-level projects:
qwerty_ast
(Rust): Defines the Qwerty AST and typechecking/optimizations on itqwerty_mlir
(C++/Tablegen): MLIR dialects/passes for optimizing Qwerty programs and producing OpenQASM 3 or QIRqwerty_util
(C++): C++ utility code, presently just a wrapper aroundtweedledum
qwerty_pyrt
(Python/Rust): Defines theqwerty
Python module (in Rust via PyO3), glues togetherqwerty_ast
andqwerty_mlir
, and JITs the resulting IR to simulate withqir-runner
There are also the following forks of third-party libraries that referenced as git submodules:
qir_runner
(Rust): Used for its implementation of the QIR runtime (which uses its good quantum simulator)tweedledum
(C++): Used for synthesizes classical circuits (or classical permutations) as quantum circuitsqwerty_mlir_sys
(Rust): Provides Rust bindings for the C API for MLIR dialects (both for ours and for upstream dialects)qwerty_melior
(Rust): A convenient wrapper for using MLIR APIs in Rust
How to get started depends on what portion of the compiler you want to work on.
If you just want to work on the AST, you can work on it in isolation as follows:
$ cd qwerty_ast
$ cargo build
To get coverage for the AST code, run:
$ cargo llvm-cov --html
Then you can open qwerty_ast/target/llvm-cov/html/index.html
(relative to the
repo root) in your browser.
You may need to install cargo-llvm-cov
first with:
$ cargo +stable install cargo-llvm-cov --locked
If you only want to work on MLIR (or the other C++ code in qwerty_util
, or
even tweedledum
):
$ git submodule update --init tweedledum
$ mkdir build && cd build
$ cmake -G Ninja ..
$ ninja
Note that the build you just created will not be used by Rust at all. It is strictly for your separate personal enjoyment.
To generate the Python extension, run the following:
$ git submodule update --init
$ python3 -m venv venv
$ . venv/bin/activate
$ cd qwerty_pyrt
$ maturin develop
This will (re)build everything. Passing -vv
to maturin develop
can give
you an idea of what is going on.