A compiler to convert Cairo's intermediate representation "Sierra" code to MLIR.

Related tags

GUI rust cairo mlir
Overview

Cairo Sierra to MLIR compiler

test mdbook

A compiler to convert Cairo's intermediate representation "Sierra" code to MLIR.

Documentation

There is an mdbook in the docs folder. Build and read it with

cd docs
mdbook serve

Dependencies

  • mdbook
  • LLVM 16+ with MLIR
  • Rust

CLI Interface

Usage: cli --input <INPUT> <COMMAND>

Commands:
  compile  Compile to MLIR with LLVM dialect, ready to be converted by `mlir-translate --mlir-to-llvmir`
  run      Compile and run a program. The entry point must be a function without arguments
  help     Print this message or the help of the given subcommand(s)

Options:
  -i, --input <INPUT>  The input sierra file
  -h, --help           Print help (see more with '--help')
  -V, --version        Print version

Setup

Install mdbook and other documentation dependencies:

cargo install mdbook mdbook-toc mdbook-mermaid

Install LLVM with MLIR

wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0-rc3/llvm-project-16.0.0rc3.src.tar.xz

mkdir ~/mlir
tar -xf llvm-project-16.0.0rc3.src.tar.xz
cd llvm-project-16.0.0rc3.src.tar
mkdir build
cd build

cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;AArch64;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DLLVM_INSTALL_UTILS=ON \
   -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON \
   -DCMAKE_INSTALL_PREFIX=~/mlir

Setup a environment variable called MLIR_SYS_160_PREFIX pointing to the mlir directory:

MLIR_SYS_160_PREFIX=~/mlir

Benchmarking

cargo bench

MLIR Resources

Translate output MLIR to LLVM IR

mlir-translate --mlir-to-llvmir output.mlir -o output.ll

# Compile with clang
clang -O3 output.ll -o program
./program

# With JIT
lli output.ll
You might also like...
A Rust trait to convert numbers of any type and size to their English representation.

num2english This Rust crate provides the NumberToEnglish trait which can be used to convert any* number to its string representation in English. It us

Why not play with MLIR from Rust?

rmlir rmlir aims to provide Rustaceans with: Parser for MLIR Way to write passes (& pass managers) Ports for code generators e.g. LLVM, Cranelift, ...

Bindings to MLIR using the full C++ API

Mithril Oxide Mithril MLIR is hard to rust but we did it anyway. Rust bindings to MLIR via the C++ API. Project structure mithril-oxide: Our Rusty bin

The best Intermediate Rust course out there!

Ultimate Rust 2: Intermediate Concepts This is the companion repository for the Ultimate Rust 2: Intermediate Concepts (the followup to the popular Ul

C-like language compiler, the final project of ZJU Compiler Principle course
C-like language compiler, the final project of ZJU Compiler Principle course

cc99 cc99 (not cc98.org) is a C-like language compiler, which is the final project of ZJU Compiler Principle course. It supports many of the C99 langu

A bit-packed k-mer representation (and relevant utilities) for rust

K-mer class for rust The purpose of this repository is to build a simple library that exposes a bit-packed k-mer class for use in rust-based bioinform

Simple and efficient time representation in Rust.

timens-rs Simple and efficient timestamp representation. The main objective being interoperability with OCaml Core_kernel.Time_ns. A significant part

CBOR: Concise Binary Object Representation

CBOR 0x(4+4)9 0x49 “The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small cod

An efficient method of heaplessly converting numbers into their string representations, storing the representation within a reusable byte array.

NumToA #![no_std] Compatible with Zero Heap Allocations The standard library provides a convenient method of converting numbers into strings, but thes

A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

A pure, low-level tensor program representation enabling tensor program optimization via program rewriting

Glenside is a pure, low-level tensor program representation which enables tensor program optimization via program rewriting, using rewriting frameworks such as the egg equality saturation library.

This crate allows to generate a flat binary with the memory representation of an ELF.

flatelf Library This crate allows to generate a flat binary with the memory representation of an ELF. It also allows to generate a FLATELF with the fo

🏭 Convert Markdown documents into themed HTML pages with support for code syntax highlighting, LaTeX and Mermaid diagrams.
🏭 Convert Markdown documents into themed HTML pages with support for code syntax highlighting, LaTeX and Mermaid diagrams.

Marky Markdown Magician 🧙 Features Hot reload previewing 🔥 Conversion to HTML / PDF 🏭 Themes! ✨ Extensions - Math, diagrams, syntax-highlighting 🧩

Tool to convert variable and function names in C/C++ source code to snake_case

FixNameCase Tool to convert variable and function names in C/C++ source code to snake_case. Hidden files and files listed in .gitignore are untouched.

FlatBuffers compiler (flatc) as API (with focus on transparent `.fbs` to `.rs` code-generation via Cargo build scripts integration)

FlatBuffers flatc API for Rust This crate provides a programmatical way to invoke flatc command (e.g. from build.rs) to generate Rust (or, in fact, an

Jex Compiler Server - Server that runs Jex code

Server that compiles and runs Jex code.

Program to check if stereo wav files have identical channels (faux-stereo) and convert them to mono.

zrtstr Command line application for checking WAV-files for identical channels, detecting faux-stereo files generated by some audio-editing software an

Owner
Lambdaclass
A venture studio and a engineering powerhouse at the same time
Lambdaclass
将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart

cxx2flow 将 C/C++ 代码转换为流程图 效果 更多效果图请参考 GALLERY 两种样式: 折线 平滑 安装 自行编译 cargo install cxx2flow 下载预构建二进制 可以到 GitHub Actions 或 Nightly.link 下载最新构建的二进制,包含 Linu

mgt 427 Dec 26, 2022
this is an initial working version, ALL code will be replaced and rewritten at SOME point

fracgen-gui this is an initial working version, ALL code will be replaced and rewritten at SOME point z | x less/more der bail alt: <- | -> adjust col

Jacob 4 Nov 18, 2022
Generates TypeScript code from a Move IDL.

Move TS Code generator for Move packages. Documentation is currently extremely sparse but will be improved in the near future. Setup Install the CLI u

The Moving Company 17 Sep 18, 2022
Bril: A Compiler Intermediate Representation for Learning

Bril: A Compiler Intermediate Representation for Learning Bril (the Big Red Intermediate Language) is a compiler IR made for teaching CS 6120, a grad

Lesley Lai 0 Dec 5, 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
TTVM Intermediate Representation driver

ttir - TTVM IR Driver ttir is driver for the TTVM IR located in ttvm. Usage Run the following command in your shell: cargo install ttir Features Easy

maDeveloper 1 Nov 2, 2021
PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).

PyQIR PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR). It consists of the following component

QIR Alliance 37 Dec 31, 2022
An interpreter for Rust's mid-level intermediate representation

Miri An experimental interpreter for Rust's mid-level intermediate representation (MIR). It can run binaries and test suites of cargo projects and det

The Rust Programming Language 2.9k Jan 8, 2023
An Intermediate Representation which can be compiled into WebAssembly

WebAssembly Intermediate Representation This is an Intermediate Representation which can be compiled into WebAssembly. The source code is in an experi

Blue Forest 2 Dec 7, 2022
MLIR Rust multi-level compiler framework

MLIR-RS Multi-Level Intermediate Representation framework for Rust. What Modern programming language design is moving towards multi-level lowering to

Conrad Ludgate 16 May 29, 2023