MidenIR for compiling to Miden Assembly from higher-level languages

Overview

Miden IR

This repository provides a compiler for the Miden VM, specifically for Miden Assembly. It does this by lowering from a higher-level intermediate representation intended as a target for source language frontends. This repo defines not only the compiler and associated tooling, but the IR and code generation libraries as well.

This project is a work-in-progress, stay tuned for updates as things develop.

While there is a standalone midenc compiler provided here, the compiler backend is intended and able to be used as a library by Rust-based compilers that wish to target the Miden VM without having to do the code generation work themselves.

Building

You'll need to have Rust installed (at time of writing, we're doing development against Rust 1.67).

Additionally, you'll want to have cargo-make installed:

$ cargo install cargo-make

From there, you can build all of the tooling used for the compiler, including the compiler itself with:

$ cargo make

To build just the compiler:

$ cargo make midenc

This will build the compiler frontend and place it under the bin folder in the project root.

$ bin/midenc help compile
Usage: midenc compile [OPTIONS] [-- <INPUTS>...]

Arguments:
  [INPUTS]...
          Path(s) to the source file(s) to compile.

          You may also use `-` as a file name to read a file from stdin.

Options:
      --output-dir <DIR>
          Write all compiler artifacts to DIR

  -W <LEVEL>
          Modify how warnings are treated by the compiler

          [default: auto]

          Possible values:
          - none:  Disable all warnings
          - auto:  Enable all warnings
          - error: Promotes warnings to errors

  -v, --verbose
          When set, produces more verbose output during compilation

  -h, --help
          Print help (see a summary with '-h')

Testing

To run the compiler test suite:

$ cargo make test

This will run all of the unit tests in the workspace, as well as all of our literate tests, which are executed by the filecheck helper found in the tools folder.

Packaging

TBD

You might also like...
Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages.

Turbine Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages. It’s described as a to

Cloc - cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.

cloc Count Lines of Code cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. Latest release: v1.9

⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.

This repository lists static analysis tools for all programming languages, build tools, config files and more. The official website, analysis-tools.de

Run code from many programming languages!

Langbot Creating an image Install podman Build an image: podman build -t langbot . Running a language Run podman run --rm -i langbot ./scripts/run.sh

Growing languages with interpreters and staging.

language-greenhouse This is a small collection of interpreters/compilers focused on the technique of compilation by staging. For more information, ple

Generate Soufflé Datalog types, relations, and facts that represent ASTs from a variety of programming languages.

treeedb treeedb makes it easier to start writing a source-level program analysis in Soufflé Datalog. First, treeedb generates Soufflé types and relati

🎄 Advent of Code written in various languages. (2015-2022)

🎄 Advent of Code This repository contains my solutions to the Advent of Code puzzles. Every year, I will try to solve the puzzles in a different lang

Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language)

Advent of Code 2022: 15/25 langs I’ll try to solve this Advent of Code using different language for each day. Any programs needed to run the code will

An AST viewer UI for languages with an AST.

AST Viewer UI This project was inspired by "Zoom Out": The missing feature of IDEs. I want to create a GUI with text fields, boxes, arrows, etc. and g

Comments
  • feat: implement stage 1 (hir) infra

    feat: implement stage 1 (hir) infra

    The stage 1 IR (or HIR), is a sea-of-nodes style, SSA form intermediate representation. It is intended to be a target from higher level languages, so it supports a wider array of operations and control flow than is supported in MASM (and in the stage 2 IR), but provides a useful foundation on which to perform the necessary analyses and transformations in order to lower to MASM.

    This commit introduces the basic infrastructure for the IR, namely the minimum data structures necessary to represent functions in the IR, which are composed of blocks containing one or more instructions in a specific order. The set of instructions defined is based on what is provided in MASM, as well as what is needed to represent programs written in Sway or Move (barring some features which we can not yet support in Miden).

    Follow on commits will flesh out the IR builder, introduce modules, provide textual output for debugging, and implement control flow and dominator tree analyses.

    opened by bitwalker 0
  • AST type definition

    AST type definition

    The type definition for Miden IR ASTs.

    Only u32 and bool are currently allowed as types, but the definition is set up so that u64 and other integer types can be added later. The cast expression has not yet been added, since there is nothing to cast to yet.

    The definition represents an AST in SSA form except for block arguments/phi nodes. These require a liveness analysis, which should be added as a pass once we get to it.

    opened by jjcnn 0
Owner
Polygon Miden
Polygon Miden
A domain-specific language for writing AIR constraints for Miden VM

AirScript A domain-specific language for expressing AIR constraints for STARKs, especially for STARK-based virtual machines like Miden VM. An in-depth

Polygon Miden 16 Nov 9, 2022
Wrapper around atspi-code to provide higher-level at-spi Rust bindings

atspi Wrapper around atspi-codegen to provide higher-level at-spi Rust bindings. Contributions Take a look at our atspi-codegen crate, and try inpleme

Odilia 3 Feb 7, 2022
garbage-collecting on-disk object store, supporting higher level KV stores and databases.

marble Garbage-collecting disk-based object-store. See examples/kv.rs for a minimal key-value store built on top of this. Supports 4 methods: read: de

Komora 215 Dec 30, 2022
Take a break while compiling.

Coffee break Coffee break is a ?? blazing ?? fast ?? Rust ?? library, by Rust developers for Rust developers. It is: Developer-friendly: Lets you take

Radek Vít 404 Oct 2, 2024
Source code for our paper "Higher-order finite elements for embedded simulation"

Higher-order Finite Elements for Embedded Simulation This repository contains the source code used to produce the results for our paper: Longva, A., L

Interactive Computer Graphics 18 Sep 30, 2022
Library to write x64 Assembly code from Rust, more properly. Designed for the nasm assembler

x64asm Library to write x64 Assembly code from Rust, more properly. Designed for the nasm assembler How to use let mut f = Formatter::new(false); // f

Anтo 7 Dec 30, 2022
A visual canvas and virtual machine for writing assembly to build cool things. Create machines and connect them together.

Visual Assembly Canvas A highly visual assembly editor, infinite canvas for wiring blocks and machines together, bytecode virtual machine runnable nat

Phoomparin Mano 31 Oct 11, 2023
A visual canvas and virtual machine for writing assembly to build cool things. Create machines and connect them together.

Visual Assembly Canvas A highly visual assembly editor, infinite canvas for wiring blocks and machines together, bytecode virtual machine runnable nat

Phoomparin Mano 32 Oct 11, 2023
.NET assembly loader with patchless AMSI and ETW bypass in Rust

RustPatchlessCLRLoader The RustPatchlessCLRLoader leverages a sophisticated integration of patchless techniques for bypassing both Event Tracing for W

C2Pain 25 Oct 23, 2024
A CLI for analyzing the programming languages and how much code written in a project.

projlyzer A CLI for analyzing the programming languages and how much code written in a project. New features are on the way... Example Screenshot Buil

null 10 Apr 10, 2022