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