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 {\lambda}rc within the SSA framework. We evaluate our proposed region optimizations by optimizing {\lambda}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.
翻译:单一任务(SSA)是现代最优化编译者为急需的编程语言工作的一部分。然而,功能性语言在采用特别服务协议方面进展缓慢,而且由于特别服务协议无法表达更高的秩序结构,因此倾向于使用基于最低的羊肉计算器的中间表达方式。我们利用一个新的特别服务协议建筑 -- -- 区域 -- -- 来通过传统的特别服务协议推理来表达功能优化。区域优化目前依赖于对紧急程序进行临时分析和转换。这些临时转换对于急需的语言来说是足够的,因为各区域使用的方式有限。相比之下,我们使用区域在功能性综合信息协议中普遍使用次级表达方式。这促使我们系统化区域优化。我们将传统的特别服务协议推理扩大到功能性分析和改造的区域。我们实施了一个新的特别服务协议+区域,以基于传统服务协议的后端为主。我们的后端功能性语言功能性转换和处理所有LEEA4功能性过渡语言的构建方式。我们用SISA框架的后端化和最优化了我们目前具有可持续性的区域的功能性框架。我们相信,在以可持续战略性框架范围内的SISAREA+最优化工作框架,我们将以展示我们以展示我们目前具有可持续性的区域。