Getting Started
Don’t miss the MLIR Tutorial! slides - recording - online step-by-step
Please refer to the LLVM Getting Started in general to build LLVM. Below are quick instructions to build MLIR with LLVM.
The following instructions for compiling and testing MLIR assume that you have
git
,
ninja
, and a working C++ toolchain (see
LLVM requirements
).
git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
# -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON
cmake --build . --target check-mlir
It is recommended that you install clang
and lld
on your machine (sudo apt-get install clang lld
on Ubuntu for example) and uncomment the last part of the
cmake invocation above.
To compile and test on Windows using Visual Studio 2017:
REM In shell with Visual Studio environment set up, e.g., with command such as
REM $visual-studio-install\Auxiliary\Build\vcvarsall.bat" x64
REM invoked.
git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project\build
cd llvm-project\build
cmake ..\llvm -G "Visual Studio 15 2017 Win64" -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD="host" -DCMAKE_BUILD_TYPE=Release -Thost=x64 -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
cmake --build . --target check-mlir
As a starter, you may try the tutorial on building a compiler for a Toy language.