# MLIR -- Using Tablegen for Passes

DevFeed: [MLIR -- Using Tablegen for Passes](<https://devfeed.tech/articles/mlir-using-tablegen-for-passes-40469.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/08/10/mlir-using-tablegen-for-passes/>)

Published: 2023-08-10T14:41:45Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Code generation](<https://devfeed.tech/topics/code-generation.md>), [Code](<https://devfeed.tech/topics/code.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>)

Tags: [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [define](<https://devfeed.tech/tags/define.md>), [endif](<https://devfeed.tech/tags/endif.md>), [fhe](<https://devfeed.tech/tags/fhe.md>), [ifdef](<https://devfeed.tech/tags/ifdef.md>), [include](<https://devfeed.tech/tags/include.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tablegen](<https://devfeed.tech/tags/tablegen.md>), [undef](<https://devfeed.tech/tags/undef.md>)

## AI overview

This article explains how MLIR developers can use TableGen to define passes and generate boilerplate code, headers, documentation, and registration hooks. It also discusses the need to understand the generated C++ code and the tool's limited diagnostic information.

## Source excerpt

Table of Contents In the last article in this series, we defined some custom lowering passes that modified an MLIR program. Notably, we accomplished that by implementing the required interfaces of the MLIR API directly. This is not the way that most MLIR developers work. Instead, they use a code generation tool called tablegen to generate boilerplate for them, and then only add the implementation methods that are custom to their work.