论文标题

Lambda最终SSA:在SSA中优化功能程序

Lambda the Ultimate SSA: Optimizing Functional Programs in SSA

论文作者

Bhat, Siddharth, Grosser, Tobias

论文摘要

静态单分配(SSA)是现代优化编译器急需编程语言的主力。但是,由于SSA无法表达高级构造,功能性语言采用SSA的采用速度很慢,并且更喜欢基于最小的Lambda Cilculi使用中间表示。我们利用新的SSA结构 - 区域 - 以通过基于经典的SSA推理表达功能优化。当前,区域优化依赖于急需计划的临时分析和转换。这些临时转型足以用于命令式语言,因为区域以有限的方式使用。相比之下,我们在功能性IR中使用区域来模拟子表达。这促使我们系统化区域优化。我们将经典的SSA推理扩展到用于功能式分析和转换的区域。我们实现了基于SSA+区域的新的后端,该后端是Lean4,这是一种实现纯粹功能性的,依赖型的编程语言的定理供体。我们的后端是功能完整的,并处理SSA框架内Lean4功能中间表示λRC的所有构造。我们通过在MLIR实施的基于SSA+区域的框架内优化λRC来评估我们提出的区域优化,并证明了与当前的Lean4后端的性能奇偶校验。我们认为,我们的工作将为能够代表,分析和优化功能和命令性语言的统一优化框架铺平道路。

Static Single Assignment (SSA) is the workhorse of modern optimizing compilers for imperative programming languages. However, functional languages have been slow to adopt SSA and prefer to use intermediate representations based on minimal lambda calculi due to SSA's inability to express higher order constructs. We exploit a new SSA construct -- regions -- in order to express functional optimizations via classical SSA based reasoning. Region optimization currently relies on ad-hoc analyses and transformations on imperative programs. These ad-hoc transformations are sufficient for imperative languages as regions are used in a limited fashion. In contrast, we use regions pervasively to model sub-expressions in our functional IR. This motivates us to systematize region optimizations. We extend classical SSA reasoning to regions for functional-style analyses and transformations. We implement a new SSA+regions based backend for LEAN4, a theorem prover that implements a purely functional, dependently typed programming language. Our backend is feature-complete and handles all constructs of LEAN4's functional intermediate representation λrc within the SSA framework. We evaluate our proposed region optimizations by optimizing λrc within an SSA+regions based framework implemented in MLIR and demonstrating performance parity with the current LEAN4 backend. We believe our work will pave the way for a unified optimization framework capable of representing, analyzing, and optimizing both functional and imperative languages.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源