# tablegen

Published articles for tablegen.

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 Patterns with PDLL

DevFeed: [MLIR -- Defining Patterns with PDLL](<https://devfeed.tech/articles/mlir-defining-patterns-with-pdll-40485.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2024/08/04/mlir-pdll/>)

Published: 2024-08-04T14:00:00Z

Content type: tutorial

Language: en

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

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [Tooling](<https://devfeed.tech/topics/tooling.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [heir](<https://devfeed.tech/tags/heir.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [primer](<https://devfeed.tech/tags/primer.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tablegen](<https://devfeed.tech/tags/tablegen.md>)

### AI overview

A tutorial on using PDLL to define MLIR patterns. It explains PDLL's relationship to PDL, its intended role as an alternative to TableGen pattern definitions, and how PDLL files are transformed into IR and then C++ code for compilation into a pass.

### Source excerpt

Table of Contents In this article I'll show how to use PDLL, a tool for defining MLIR patterns, which itself is built with MLIR. PDLL is intended to be a replacement for defining patterns in tablegen, though there are few public examples of its use. In fact, the main impetus for PDLL is that tablegen makes it difficult to express things like: Operations that return multiple results Operations with regions Operations with variadic operands Arithmetic on static values While not all these features are fully supported in PDLL yet, they are within scope of the language and tooling.

## MLIR -- Canonicalizers and Declarative Rewrite Patterns

DevFeed: [MLIR -- Canonicalizers and Declarative Rewrite Patterns](<https://devfeed.tech/articles/mlir-canonicalizers-and-declarative-rewrite-patterns-40477.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/09/20/mlir-canonicalizers-and-declarative-rewrite-patterns/>)

Published: 2023-09-20T08:00:00Z

Content type: tutorial

Language: en

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

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

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [canonicalization](<https://devfeed.tech/tags/canonicalization.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [complex-numbers](<https://devfeed.tech/tags/complex-numbers.md>), [declarative](<https://devfeed.tech/tags/declarative.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [maintenance](<https://devfeed.tech/tags/maintenance.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [polynomials](<https://devfeed.tech/tags/polynomials.md>), [primer](<https://devfeed.tech/tags/primer.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rewrite](<https://devfeed.tech/tags/rewrite.md>), [tablegen](<https://devfeed.tech/tags/tablegen.md>), [test](<https://devfeed.tech/tags/test.md>)

### AI overview

This tutorial explains how to implement general canonicalization patterns in MLIR. It covers both C++ canonicalizers and declarative rewrite rules in TableGen, including an identity-based polynomial rewrite and its testing considerations.

### Source excerpt

Table of Contents In a previous article we defined folding functions, and used them to enable some canonicalization and the sccp constant propagation pass for the poly dialect. This time we'll see how to add more general canonicalization patterns. The code for this article is in this pull request, and as usual the commits are organized to be read in order. Why is Canonicalization Needed? MLIR provides folding as a mechanism to simplify an IR, which can result in simpler, more efficient ops (e.

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