一句话:提出以纯类型系统为核心的可扩展高阶中间表示 MimIR,让开发者以插件形式声明并优化领域特定操作。
面向图像处理、机器学习与数值模拟等计算密集型应用,传统面向底层代码的编译器难以理解领域原语,优化应在领域层面进行;而各 DSL 编译器又反复重造标准优化、代码生成与基础设施。本文提出 MimIR,一种可扩展的高阶中间表示。其核心是一个纯类型系统,本质上是一种带类型的 lambda 演算。开发者可以声明新(领域特定)操作的签名,即公理(axiom);公理可以是函数、类型构造子或任何具有多态、多型(polytypic)乃至依赖类型的实体,从而在任意高低层次上扩展 MimIR,并打包为插件。插件扩展编译器,并负责优化与 lowering 其公理。论文通过三个案例研究展示其表达力与有效性:与 LLVM 同抽象层次的底层插件、正则表达式匹配插件,以及线性代数与自动微分插件;结果表明 MimIR 生成的代码均达到当前最优性能。
Traditional compilers, designed for optimizing low-level code, fall short when dealing with modern, computation-heavy applications like image processing, machine learning, or numerical simulations. Optimizations should understand the primitive operations of the specific application domain and thus happen on that level. Domain-specific languages (DSLs) fulfill these requirements. However, DSL compilers reinvent the wheel over and over again as standard optimizations, code generators, and general infrastructure & boilerplate code must be reimplemented for each DSL compiler. This paper presents MImIR, an extensible, higher-order intermediate representation. At its core, MImIR is a pure type system and, hence, a form of a typed lambda calculus. Developers can declare the signatures of new (domain-specific) operations, called axioms . An axiom can be the declaration of a function, a type constructor, or any other entity with a possibly polymorphic, polytypic, and/or dependent type. This way, developers can extend MImIR at any low or high level and bundle them in a plugin . Plugins extend the compiler and take care of optimizing and lowering the plugins' axioms. We show the expressiveness and effectiveness of MImIR in three case studies: Low-level plugins that operate at the same level of abstraction as LLVM, a regular-expression matching plugin, and plugins for linear algebra and automatic differentiation. We show that in all three studies, MImIR produces code that has state-of-the-art performance.
@article{paperbot3231,
title = {MimIR: An Extensible and Type-Safe Intermediate Representation for the DSL Age},
author = {Roland Leißa and Marcel Ullrich and Joachim Meyer and Sebastian Hack},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {POPL},
year = {2025},
doi = {10.1145/3704840}
}