Skip to content

gt-tinker/qwerty-rust-ast

Repository files navigation

The (New) Qwerty Compiler

Project Structure

This repository consists of the following four top-level projects:

  1. qwerty_ast (Rust): Defines the Qwerty AST and typechecking/optimizations on it
  2. qwerty_mlir (C++/Tablegen): MLIR dialects/passes for optimizing Qwerty programs and producing OpenQASM 3 or QIR
  3. qwerty_util (C++): C++ utility code, presently just a wrapper around tweedledum
  4. qwerty_pyrt (Python/Rust): Defines the qwerty Python module (in Rust via PyO3), glues together qwerty_ast and qwerty_mlir, and JITs the resulting IR to simulate with qir-runner

There are also the following forks of third-party libraries that referenced as git submodules:

  1. qir_runner (Rust): Used for its implementation of the QIR runtime (which uses its good quantum simulator)
  2. tweedledum (C++): Used for synthesizes classical circuits (or classical permutations) as quantum circuits
  3. qwerty_mlir_sys (Rust): Provides Rust bindings for the C API for MLIR dialects (both for ours and for upstream dialects)
  4. qwerty_melior (Rust): A convenient wrapper for using MLIR APIs in Rust

Getting Started

How to get started depends on what portion of the compiler you want to work on.

Building Just the AST

If you just want to work on the AST, you can work on it in isolation as follows:

$ cd qwerty_ast
$ cargo build

Coverage

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

Fiddling with MLIR

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.

Building the Python Extension

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.

About

Rewritten Qwerty frontend in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 13