Traditionally, compiler researchers either conduct experiments within an existing production compiler or develop their own prototype compiler; both options come with trade-offs. On one hand, prototyping in a production compiler can be cumbersome, as they are often optimized for program compilation speed at the expense of software simplicity and development speed. On the other hand, the transition from a prototype compiler to production requires significant engineering work. To bridge this gap, we introduce the concept of sidekick compiler frameworks, an approach that uses multiple frameworks that interoperate with each other by leveraging textual interchange formats and declarative descriptions of abstractions. Each such compiler framework is specialized for specific use cases, such as performance or prototyping. Abstractions are by design shared across frameworks, simplifying the transition from prototyping to production. We demonstrate this idea with xDSL, a sidekick for MLIR focused on prototyping and teaching. xDSL interoperates with MLIR through a shared textual IR and the exchange of IRs through an IR Definition Language. The benefits of sidekick compiler frameworks are evaluated by showing on three use cases how xDSL impacts their development: teaching, DSL compilation, and rewrite system prototyping. We also investigate the trade-offs that xDSL offers, and demonstrate how we simplify the transition between frameworks using the IRDL dialect. With sidekick compilation, we envision a future in which engineers minimize the cost of development by choosing a framework built for their immediate needs, and later transitioning to production with minimal overhead.
翻译:传统上,编译器研究人员要么在现有生产级编译器中进行实验,要么自行开发原型编译器;这两种选择均需权衡利弊。一方面,在生产级编译器中开发原型往往繁琐复杂,因为此类编译器通常为追求程序编译速度而牺牲软件简洁性与开发效率。另一方面,从原型编译器向生产级编译器的迁移需要大量工程投入。为弥合这一鸿沟,我们提出"辅助编译器框架"概念——这是一种利用文本交换格式与抽象声明的描述来实现多个框架互操作的方法。每个此类编译器框架专为特定用例场景(如性能优化或原型开发)而设计。不同框架间通过设计共享抽象机制,从而简化从原型开发到生产部署的过渡。我们通过xDSL演示这一理念——这是一个面向原型开发与教学、作为MLIR辅助框架的编译器框架。xDSL通过共享文本中间表示(IR)以及基于IR定义语言的IR交换机制实现与MLIR的互操作。我们通过三个用例(教学、特定领域语言编译、重写系统原型开发)展示xDSL对开发过程的影响,从而评估辅助编译器框架的效能。同时,我们考察了xDSL在权衡取舍方面的特性,并演示如何借助IRDL方言简化框架间的迁移过程。通过辅助编译技术,我们展望这样一个未来:工程师能够根据即时需求选择匹配的框架以最小化开发成本,随后以极低开销过渡至生产级部署。