# ifdef

Published articles for ifdef.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## MLIR -- Defining a New Dialect

DevFeed: [MLIR -- Defining a New Dialect](<https://devfeed.tech/articles/mlir-defining-a-new-dialect-40471.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/08/21/mlir-defining-a-new-dialect/>)

Published: 2023-08-21T08:00:00Z

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>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [polynomials](<https://devfeed.tech/topics/polynomials.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [define](<https://devfeed.tech/tags/define.md>), [endif](<https://devfeed.tech/tags/endif.md>), [ifdef](<https://devfeed.tech/tags/ifdef.md>), [include](<https://devfeed.tech/tags/include.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [polynomials](<https://devfeed.tech/tags/polynomials.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tablegen](<https://devfeed.tech/tags/tablegen.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [undef](<https://devfeed.tech/tags/undef.md>)

### AI overview

This tutorial explains how to define a new MLIR dialect for arithmetic on single-variable polynomials with 32-bit unsigned integer coefficients. It covers the design, an empty dialect, generated code, registration, and a simple custom type.

### Source excerpt

Table of Contents In the last article in the series, we migrated the passes we had written to use the tablegen code generation framework. That was a preface to using tablegen to define dialects. In this article we'll define a dialect that represents arithmetic on single-variable polynomials, with coefficients in $\mathbb{Z} / 2^{32} \mathbb{Z}$ (32-bit unsigned integers). The code for this article is in this pull request, and as usual the commits are organized to be read in order.

## 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.