Giter Site home page Giter Site logo

johannst / llvm-kaleidoscope-rs Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 0.0 2.77 MB

LLVM Kaleidoscope Tutorial in Rust

Home Page: https://johannst.github.io/llvm-kaleidoscope-rs

License: MIT License

Rust 99.38% Dockerfile 0.53% Makefile 0.09%
llvm-tutorial llvm rust rust-lang rust-ffi codegen compiler kaleidoscope llvm-ir tutorial

llvm-kaleidoscope-rs's Introduction

llvm-kaleidoscope-rs

Rust Rustdoc

The purpose of this repository is to learn about the llvm compiler infrastructure and practice some rust-lang.

To reach the goals set, we follow the official llvm tutorial Kaleidoscope: Implementing a Language with LLVM. This tutorial is written in C++ and structured in multiple chapters, we will try to follow along and implement every chapter in rust.

The topics of the chapters are as follows:

The implementation after each chapter can be compiled and executed by checking out the corresponding tag for the chapter.

> git tag -l
chapter1
chapter2
chapter3
chapter4
chapter5

Names of variables and functions as well as the structure of the functions are mainly kept aligned with the official tutorial. This aims to make it easy to map the rust implementation onto the C++ implementation when following the tutorial.

One further note on the llvm API, instead of using the llvm C++ API we are going to use the llvm C API and build our own safe wrapper specialized for this tutorial. The wrapper offers a similar interface as the C++ API and is implemented in src/llvm/

Demo

# Run kaleidoscope program from file.
cargo run ks/<file>

# Run REPL loop, parsing from stdin.
cargo run

Documentation

Rustdoc for this crate is available at johannst.github.io/llvm-kaleidoscope-rs.

Build with provided container file

The provided Dockerfile documents the required dependencies for an ubuntu based system and serves as a build environment with the correct llvm version as specified in the Cargo.toml file.

## Either user podman ..

# Build the image *ks-rs*. Depending on the downlink this may take some minutes.
make -C container

podman run --rm -it -v $PWD:/work -w /work ks-rs
# Drops into a shell in the container, just use cargo build / run ...

## .. or docker.

# Build the image *ks-rs*. Depending on the downlink this may take some minutes.
make -C container docker

docker run --rm -it -v $PWD:/work -w /work ks-rs
# Drops into a shell in the container, just use cargo build / run ...

License

This project is licensed under the MIT license.

llvm-kaleidoscope-rs's People

Contributors

johannst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.