arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.07443cs.PL
收藏

MimIR:面向 DSL 时代的可扩展且类型安全的中间表示

MimIR: An Extensible and Type-Safe Intermediate Representation for the DSL Age

Roland Leißa, Marcel Ulrich, Joachim Meyer, Sebastian Hack

AI总结:

本文提出可扩展高阶中间表示 MimIR,通过类型化 axiom 和插件机制让 DSL 开发者无需重写编译器基础设施即可扩展优化与代码生成,并在底层、正则匹配、线性代数与自动微分三个案例中验证其生成代码达到最先进性能。

摘要:

传统编译器旨在优化底层代码,在处理图像处理、机器学习或数值模拟等现代计算密集型应用时力不从心。优化应当理解特定应用领域的基本操作,因此应在该层级上进行。领域特定语言(DSL)满足这些要求。然而,DSL 编译器反复重新发明轮子,因为标准优化、代码生成器以及通用基础设施和样板代码必须为每个 DSL 编译器重新实现。本文提出了 MimIR,一种可扩展的高阶中间表示。其核心是一个纯类型系统,因此是带类型 lambda 演算的一种形式。开发者可以声明新的(领域特定的)操作签名,称为“axiom(公理)”。一个 axiom 可以是函数声明、类型构造器,或任何其他具有可能多态、多型(polytypic)和/或依赖类型的实体。通过这种方式,开发者可以在任意低层或高层扩展 MimIR,并将它们打包为“plugin(插件)”。插件扩展编译器,并负责优化和降级插件的 axiom。我们通过三个案例研究展示了 MimIR 的表达能力和有效性:与 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑