1# Toy Tutorial 2 3This tutorial runs through the implementation of a basic toy language on top of 4MLIR. The goal of this tutorial is to introduce the concepts of MLIR; in 5particular, how [dialects](../../LangRef.md#dialects) can help easily support 6language specific constructs and transformations while still offering an easy 7path to lower to LLVM or other codegen infrastructure. This tutorial is based on 8the model of the 9[LLVM Kaleidoscope Tutorial](https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html). 10 11This tutorial assumes you have cloned and built MLIR; if you have not yet done 12so, see 13[Getting started with MLIR](https://mlir.llvm.org/getting_started/). 14 15This tutorial is divided in the following chapters: 16 17- [Chapter #1](Ch-1.md): Introduction to the Toy language and the definition 18 of its AST. 19- [Chapter #2](Ch-2.md): Traversing the AST to emit a dialect in MLIR, 20 introducing base MLIR concepts. Here we show how to start attaching 21 semantics to our custom operations in MLIR. 22- [Chapter #3](Ch-3.md): High-level language-specific optimization using 23 pattern rewriting system. 24- [Chapter #4](Ch-4.md): Writing generic dialect-independent transformations 25 with Interfaces. Here we will show how to plug dialect specific information 26 into generic transformations like shape inference and inlining. 27- [Chapter #5](Ch-5.md): Partially lowering to lower-level dialects. We'll 28 convert some of our high level language specific semantics towards a generic 29 affine oriented dialect for optimization. 30- [Chapter #6](Ch-6.md): Lowering to LLVM and code generation. Here we'll 31 target LLVM IR for code generation, and detail more of the lowering 32 framework. 33- [Chapter #7](Ch-7.md): Extending Toy: Adding support for a composite type. 34 We'll demonstrate how to add a custom type to MLIR, and how it fits in the 35 existing pipeline. 36 37The [first chapter](Ch-1.md) will introduce the Toy language and AST. 38