Funktionen

Print[PRINT]
.  Home  .  Publikationen  .  Fopra/SEP/Bachelor  .  schw24a

Schwaiger, J. (2024):

Designing a MLIR Dialect for the Brainfuck Language


MLIR is an extensible compiler infrastructure with support for parsing, printing, documentation, conversion and optimization of intermediate representation (IR). While being a rather young project, it is already used in applications ranging from representation of machine learning models, polyhedral optimization and quantum assembly languages. The extensibility of MLIR's IR is enabled by the concepts of operation (Op) and dialect. While Ops are a way to model functionality of any level, dialects can group operations of a common functionality or motivation.

The extensibility of MLIR makes it a rather complex framework. Users can extend the MLIR IR and pass infrastructure, both declarative and imperative. Furthermore, they can use existing dialects and passes to combine them with their custom ones. To improve the accessibility of MLIR for the general public, we designed a starter project simple enough to focus on the possibilities of MLIR and complex enough to include the use of many of MLIR's features.

This thesis presents a MLIR-based compiler for the Brainfuck language: the MLIR Brainfuck project. We implemented frontend, middleware and backend based on an import script to translate Brainfuck programs to an MLIR representation, three MLIR inherent abstractions to model Brainfuck on different levels, conversion passes between them and a conversion to the LLVM intermediate representation.