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 的互操作。我们通过三个用例(教学、DSL 编译与重写系统原型开发)展示 xDSL 对其开发流程的影响,以此评估辅助编译器框架的优势。同时研究了 xDSL 提供的权衡特性,并演示了如何利用 IRDL 方言简化框架间的过渡。借助辅助编译,我们展望未来工程师能够根据自身即时需求选择适配框架,以最小化开发成本,并在后续以极低开销实现向生产环境的过渡。