jerinphilip / toy-mlir

Isolating mlir tutorial dialect implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toy-mlir

This is an excerpt of the toy-language tutorial MLIR within LLVM. This repository (and commits, history) is alternate view of the toy language tutorial. I created this to have a smaller consolidated source and to follow what exactly is happening in source between chapters (by means of a diff view).

LLVM organizes this as different folders: ch1, ch2...

The following provides diffs corresponding to what's changing between chapters as opposed to the folder view, and for me is easier to follow and figure out.

  1. Initial setup for standalone builds + Chapter 1 847d15...716325
  2. Chapter 2: Emitting Basic MLIR
  3. Chapter 3: High-level Language-Specific Analysis and Transformation
  4. Chapter 4: Enabling Generic Transformation with Interfaces
  5. Chapter 5: Partial Lowering to Lower-Level Dialects for Optimization
  6. Chapter 6: Lowering to LLVM and CodeGeneration
  7. Chapter 7: Adding a Composite Type to Toy

Please be warned there could be errors, and this can go out-of-date in the future, the following pin marks an LLVM commit where this worked:

Build instructions

I build standalone locally using:

# Clone LLVM (for building MLIR)
LLVM_SOURCE_DIR=$HOME/code/llvm-project
git clone https://github.com/llvm/llvm-project $LLVM_SOURCE_DIR

# Move to a known working commit (?)
git -C $LLVM_SOURCE_DIR checkout 555a71b

# Clone this repository, and switch to source-root
git clone https://github.com/jerinphilip/toy-mlir
cd toy-mlir 

# Build MLIR to $LLVM_SOURCE_DIR/build-mlir
bash scripts/build-llvm-mlir.sh

# Build ToyC.
bash scripts/standalone-build.sh

The shell-scripts above assume the LLVM source is at $HOME/code/llvm-project. You may look within the scripts and adapt for your use-case accordingly.

About

Isolating mlir tutorial dialect implementation


Languages

Language:C++ 95.5%Language:CMake 2.1%Language:Shell 1.8%Language:Python 0.6%