arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1805.05400cs.PLcs.LO
收藏

控制流图机的结构操作语义

Structural Operational Semantics for Control Flow Graph Machines

Dmitri Garbuzov, William Mansky, Christine Rizkallah, Steve Zdancewic

摘要:

编译器使用低级程序的控制流图(CFG)表示,因为它们适合于程序分析和优化。然而,形式化的行为和元理论的CFG程序是不平凡的:CFG程序不组成好,他们的语义依赖于辅助状态,因此,他们不享受一个简单的方程理论,可用于推理的正确性程序转换。相比之下,基于λ演算的中间表示具有良好理解的操作语义和元理论,包括丰富的等式理论,所有这些都使它们适合于形式化验证。本文建立了一个严格的等价之间(一个变种)利维的按推值调用(CBPV)演算和控制流图机的指令是在静态单分配(SSA)的形式。通过一系列的抽象机器,对齐的转换的结构操作语义的CBPV语言的SSA形式的计算步骤的对应关系是精确的。目标机,这是从CBPV语言派生的,准确地捕捉控制流图的执行模型,包括直接跳转,相互递归的代码块,和多参数函数调用,和闭包自由的子集是类似的SSA中间表示在现代编译器,如LLVM和GCC。所有语言/抽象机器语义的定义和与它们相关的定理都在Coq中得到了充分的验证。

英文摘要:

Compilers use control flow graph (CFG) representations of low-level programs because they are suited to program analysis and optimizations. However, formalizing the behavior and metatheory of CFG programs is non-trivial: CFG programs don't compose well, their semantics depends on auxiliary state, and, as a consequence, they do not enjoy a simple equational theory that can be used for reasoning about the correctness of program transformations. Lambda-calculus-based intermediate representations, in contrast, have well-understood operational semantics and metatheory, including rich equational theories, all of which makes them amenable to formal verification. This paper establishes a tight equivalence between (a variant of) Levy's call-by-push-value (CBPV) calculus and a control flow graph machine whose instructions are in static single assignment (SSA) form. The correspondence is made precise via a series of abstract machines that align the transitions of the structural operational semantics of the CBPV language with the computation steps of the SSA form. The target machine, which is derived from the CBPV language, accurately captures the execution model of control flow graphs, including direct jumps, mutually recursive code blocks, and multi-argument function calls, and the closure-free subset is similar to the SSA intermediate representations found in modern compilers such as LLVM and GCC. The definitions of all the language/abstract machine semantics and the theorems relating them are fully verified in Coq.

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

↑