Abstract bootstraps.

Overview

abstraps

crates.io CI

Extensible compiler middle layer with abstract interpreters.

This project started off as an experiment in compiler design. Specifically, the author was motivated by studying the Julia language and compiler inference system to understand language design with extensible abstract interpretation as a compiler (and potentially language!) feature.

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.


The framework provides:

  1. A fixed intermediate representation with concepts isomorphic to a subset of 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 (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.

Started by McCoy R. Becker during Harvard CS 252r. All code is licensed under the MIT License.
You might also like...
Comments
  • Merge the MLIR changes (including changes to IR structure, and lattice passes via pass manager interface)

    Merge the MLIR changes (including changes to IR structure, and lattice passes via pass manager interface)

    Closed by #1.

    Completely changes the IR structure to reflect MLIR design choices. Ultimately, after carefully reading the MLIR documentation, I'm convinced that the MLIR design is a good optimum for extensibility -- clearly well thought out and designed, and supports the interfaces which I'd like to use to interact with extensible lattice interpreters.

    • [X] IR re-implementation.
    • [X] Test examples for a builtin dialect.
    • [X] Operation traits.
    • [x] Pass manager.

    This change has introduced many advanced things into the codebase. It's likely less clear to someone observing how things actually work here, because I had to introduce concepts like trait objects, casting, and dynamic dispatch from Rust into the implementation to support the ability for my IR containers (e.g. Operation) to hold containers with intrinsics that are user-defined. The common solution in Rust for this is to use trait objects -- which is great and works (!), but trait objects prevents you from customizing behavior (e.g. by using Rust traits) on the thing that you just turned into Box<dyn SatisfiesTrait> (e.g. that you just introduced dynamic dispatch for). This thus requires designing an entirely new mechanism for enforcing traits (again, just like MLIR traits on these intrinsic-agnostic containers. The mechanism which I've implemented here relies on casting of trait objects, which is advanced usage of Rust's type system (specifically, std::Any and downcasting).

    • [X] Implement operation trait - like mechanism.
    • [X] Test examples.
    • [x] Ruminate on this interface by writing a pass which uses it.
    breaking 
    opened by femtomc 2
  • Provide a diagnostics infrastructure using `ariadne` and a custom `Error` type.

    Provide a diagnostics infrastructure using `ariadne` and a custom `Error` type.

    ariadne provides beautiful, contextual error messages (and so does things like codespan-reporting) -- I'd like to understand the right way to expose these error messages as part of a diagnostic infrastructure.

    Mostly, ariadne has been used when you have a parser combinator, and the original String -- so you know the spans of objects after parsing. In the IR framework here, we actually have the IR first -- so this may require a novel Formatter implementation (e.g. a struct implement fmt::Write) which somehow tracks the spans for IR objects when being formatted into a string.

    Re -- it's also not clear what parts of the infra should support these pretty error messages. Passes would be a good starting place to work on.

    opened by femtomc 1
  • Investigate equality saturation as a pass

    Investigate equality saturation as a pass

    Discussion tracking: https://github.com/egraphs-good/egg/discussions/145

    curious about this. Depends on scope of project, etc — but would certainly be interesting to look at

    enhancement 
    opened by femtomc 0
Owner
McCoy R. Becker
Bayesian brain-in-a-jar.
McCoy R. Becker
Rust mid-level IR Abstract Interpreter

MIRAI MIRAI is an abstract interpreter for the Rust compiler's mid-level intermediate representation (MIR). It is intended to become a widely used sta

Facebook Experimental 793 Jan 2, 2023
Abstract over the atomicity of reference-counting pointers in rust

Archery Archery is a rust library that offers a way to abstraction over Rc and Arc smart pointers. This allows you to create data structures where the

Diogo Sousa 107 Nov 23, 2022
a simple compiled language i made in rust. it uses intermediate representation (IR) instead of an abstract syntax tree (AST).

a simple compiled language i made in rust. it uses intermediate representation (IR) instead of an abstract syntax tree (AST).

null 4 Oct 3, 2022
Abstract GPU Project - The easiest and most ergonomic GPU library

Abstract GPU Project - The easiest and most ergonomic GPU library

LyricWulf 9 Nov 30, 2022
Rust mid-level IR Abstract Interpreter

MIRAI MIRAI is an abstract interpreter for the Rust compiler's mid-level intermediate representation (MIR). It is intended to become a widely used sta

Meta Experimental 789 Dec 26, 2022
An abstract, safe, and concise color conversion library for rust nightly This requires the feature adt_const_params

colortypes A type safe color conversion library This crate provides many methods for converting between color types. Everything is implemented abstrac

Jacob 13 Dec 7, 2022
Library for abstract mathematics written by Rust. It is aiming to replace SageMath.

ankolib Roadmap Mathematical Structures Sets Monoids Groups Semirings Rings Algebras Basic Rings and Fields Integers and Rational Numbers Integer Rati

anko 6 Sep 3, 2022
Minimal flashloan borrower contracts with an extensible rust sdk to abstract wrapping generic onchain calls (similar to multicall3) with flashloans.

flashloan-rs • Minimal flashloan borrower contracts with an extensible rust sdk. Getting Started Flashloan-rs is published to crates.io as flashloan-r

White Noise 71 Apr 15, 2023
Build Abstract Syntax Trees and tree-walking models quickly in Rust.

astmaker Build Abstract Syntax Trees and tree-walking models quickly in Rust. Example This example creates an AST for simple math expressions, and an

David Delassus 100 Jun 5, 2023