Crate abstraps[][src]

Expand description

abstraps

CI crates.io docs.rs

Extensible compiler design with abstract interpreters.

This project started off as an experiment in compiler design. Specifically, the author was motivated by:

  1. studying the Julia language and compiler inference system to understand language design with extensible abstract interpretation as a compiler (and potentially language!) feature.
  2. studying MLIR and the new, powerful ideas for IR and compiler design which are emerging from the project.

It turns out that there are quite a few of languages (e.g. Crystal, Nim, Julia) experimenting with abstract interpretation as part of their type systems. In the long term, the goal of the project might be to provide a stable substrate to experiment on compiler design cons abstract interpreters inside of an IR framework which supports MLIR-like extensibility concepts.

Claims

The framework provides:

  1. An intermediate representation with concepts isomorphic to MLIR.
  2. Interfaces for defining interpreters which act as abstract virtual machines on the IR, as well as reference (usable!) interpreters for standard design patterns.
  3. Builder interfaces which support code generation to MLIR.

“Extensibility” means that there are no fixed intrinsics built into the IR (or any of the interfaces). The same is true for abstract lattices – the interpreter patterns describe how (certain instances) of abstract interpreters will traverse the IR, but the user must provide the semantics by specifying intrinsics and how the interpreter should interpret the intrinsics on a user-defined lattice.


Note:

The original author would have liked to just do this in MLIR proper -- but given time constraints and engineering ability (or lack thereof in C++), this project is implemented in Rust. In fact, for those interested in MLIR -- you may find "another implementation viewpoint" useful on the design concepts. The codebase has been documented with respect to non-trivial implementation decisions and their motivation from MLIR.
Started by McCoy R. Becker during Harvard CS 252r. All code is licensed under the MIT License.

Modules

Target-specific code generation capabilities.

Core functionality, including IR (Operation) definition, pass manager implementation, and declarative macro functionality for intrinsic/operation extension.

IR intrinsic dialects which are supported internally by the framework.

Macros

Return early with an error.

Inserts an interface into the global crate-managed virtual table at runtime.

A macro which exposes static (virtual) lookup for trait objects which implement the Object interface.

A declarative interface for defining new Intrinsic implementors.

Structs

The core error reporting type of the library, a wrapper around a dynamic error reporting type.