ScaIR: Type-safe Compiler Framework Compatible with MLIR
This program is tentative and subject to change.
There is a clear rise in the use of domain-specific languages (DSLs) expressing computations at a higher level of abstraction appropriate for domain experts, and enabling domain-aware optimizations. At the core of these innovations lies the compiler infrastructure, which supports the effective implementation and use of both. The complexity of compilers increases as the ecosystem of hardware and DSLs grows, with many pipelines re-implementing language abstractions and optimizations over them.
The current state-of-the-art solution to manage this complexity is the MLIR compiler framework. At its core, MLIR defines a shared SSA (Static-Single Assignment) intermediate representation (IR), which successfully encompasses many of the higher-level abstractions present in modern-day DSLs. Additionally, the MLIR framework provides the end-user with extensive tooling to develop extensible, efficient, and maintainable compilers that utilize and transform over that shared IR format. This elegant design enables the sharing of common abstractions across different compiler pipelines, directly addressing software fragmentation, and significantly reduces the engineering effort required when targeting multiple hardware backends.
However, the framework maintains a steep learning curve: DSLs (Dialects in MLIR) are written in TableGen, a specification language used to generate the C++ classes for language abstractions, or Operations in MLIR. However, TableGen itself is a legacy DSL repurposed from LLVM, and is not expressive enough to represent Turing-complete constraints. Such constraints require workarounds and are represented as custom snippets of C++ code. Additionally, the MLIR core data structure for representing Operations generated by TableGen has several shortcomings. Operations are packed into classes that lose all necessary typing context during their instantiation. The typing information is re-verified at runtime.
This talk will introduce ScaIR, a Scala-based compiler framework that leverages functional programming principles to address the limitations of MLIR and provide a fully MLIR-compatible compiler infrastructure, but with significantly more safety features.
Paper (PAPERS_2026_SCALAWORKSHOP_SCAIR.pdf) | 573KiB |