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.
- Initial setup for standalone builds + Chapter 1 847d15...716325
- Chapter 2: Emitting Basic MLIR
- Chapter 3: High-level Language-Specific Analysis and Transformation
- Chapter 4: Enabling Generic Transformation with Interfaces
- Chapter 5: Partial Lowering to Lower-Level Dialects for Optimization
- Chapter 6: Lowering to LLVM and CodeGeneration
- 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:
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.