Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mlir-tutorial

> 编程语言
Open source

MLIR For Beginners tutorial

1.3K stars0 likes1 views
WebsiteGitHub

About

MLIR For Beginners tutorial

MLIR For Beginners

This is the code repository for a series of articles on the MLIR framework for building compilers.

Articles

  1. Build System (Getting Started)
  2. Running and Testing a Lowering
  3. Writing Our First Pass
  4. Using Tablegen for Passes
  5. Defining a New Dialect
  6. Using Traits
  7. Folders and Constant Propagation
  8. Verifiers
  9. Canonicalizers and Declarative Rewrite Patterns
  10. Dialect Conversion
  11. Lowering through LLVM
  12. A Global Optimization and Dataflow Analysis
  13. Defining Patterns with PDLL

Bazel build

Bazel is one of two supported build systems for this tutorial. The other is CMake. If you're unfamiliar with Bazel, you can read the tutorials at https://bazel.build/start. Familiarity with Bazel is not required to build or test, but it is required to follow the articles in the tutorial series and explained in the first article, Build System (Getting Started). The CMake build is maintained, but was added at article 10 (Dialect Conversion) and will not be explained in the articles.

Note: This project has been upgraded to Bazel 8.3.1 and migrated to use Bzlmod for dependency management, replacing the traditional WORKSPACE file approach. Dependencies are now managed through MODULE.bazel using the Bazel Central Registry (BCR) where possible.

Prerequisites

Install Bazelisk via instructions at https://github.com/bazelbuild/bazelisk#installation. This should create the bazel command on your system.

You should also have a modern C++ compiler on your system, either gcc or clang, which Bazel will detect.

Bazel Version: This project requires Bazel 8.3.1 or newer. The specific version is pinned in .bazelversion.

Build and test

Run

bash
bazel build ...:all
bazel test ...:all

Dependency Management

The project uses Bzlmod (MODULE.bazel) for dependency management:

  • Core dependencies: Managed through Bazel Central Registry (BCR)
    • rules_python, rules_java, protobuf, abseil-cpp, or-tools, etc.
  • LLVM dependencies: Managed through custom module extension
    • LLVM/MLIR source code via git repository
  • Development tools: hedron_compile_commands via git_override

This approach provides better dependency resolution, versioning, and compatibility compared to the legacy WORKSPACE approach.

CMake build

CMake is one of two supported build systems for this tutorial. The other is Bazel. If you're unfamiliar with CMake, you can read the tutorials at https://cmake.org/getting-started/. The CMake build is maintained, but was added at article 10 (Dialect Conversion) and will not be explained in the articles.

Prerequisites

  • Make sure you have installed everything needed to build LLVM https://llvm.org/docs/GettingStarted.html#software
  • For this recipe Ninja is used so be sure to have it as well installed https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages

Checking out the code

Checkout the tutorial including the LLVM dependency (submodules):

bash
git clone --recurse-submodules https://github.com/j2kun/mlir-tutorial.git
cd mlir-tutorial

Building dependencies

Note: The following steps are suitable for macOs and use ninja as building system, they should not be hard to adapt for your environment.

Build LLVM/MLIR

…

Build and test

…

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++compilersmlirtutorial

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言