We develop the first theory of control-flow graphs from first principles, and use it to create an algorithm for automatically synthesizing many variants of control-flow graph generators from a language's operational semantics. Our approach first introduces a new algorithm for converting a large class of small-step operational semantics to an abstract machine. It next uses a technique called "abstract rewriting" to automatically abstract the semantics of a language, which is used both to directly generate a CFG from a program ("interpreted mode") and to generate standalone code, similar to a human-written CFG generator, for any program in a language. We show how the choice of two abstraction and projection parameters allow our approach to synthesize several families of CFG-generators useful for different kinds of tools. We prove the correspondence between the generated graphs and the original semantics. We provide and prove an algorithm for automatically proving the termination of interpreted-mode generators. In addition to our theoretical results, we have implemented this algorithm in a tool called Mandate, and show that it produces human-readable code on two medium-size languages with 60-80 rules, featuring nearly all intraprocedural control constructs common in modern languages. We then showed these CFG-generators were sufficient to build two static analyzers atop them. Our work is a promising step towards the grand vision of being able to synthesize all desired tools from the semantics of a programming language.
翻译:我们从最初的原则中开发了第一个控制流图理论, 并用它来创建一种算法, 自动合成一个语言操作的语义。 我们的方法首先引入了一个新的算法, 将一大批小步操作语义转换成一个抽象的机器。 我们接下来使用一种叫作“ 抽象重写” 的技术来自动抽取一种语言的语义。 它既用来直接从一个程序( “ 解释模式 ” ) 生成一个 CFG, 也用来为任何一种语言的程序自动合成一个独立的代码, 类似于人写成的 CFG 生成器。 我们展示了两种抽象和预测参数的选择方法如何使我们能够将一大批CFG 的小型操作语系组合综合到一个对不同工具有用的抽象。 我们证明了生成的图形和原始语义的对应性。 我们提供并证明一种算法, 自动证明一个解释式模型生成器( “ 解释式模式” ) 的终止。 除了我们的理论结果外, 我们用一个工具“ 任务” 来应用这个算法,, 并显示它在近80 人类- 可读的代数代码, 在两种中型结构中, 结构中, 展示了两种常规中, 我们用两种语言来展示了一种具有充分的系统, 。