一句话:提出首个通用 Datalog 编译器框架,以可扩展的带类型多级 IR 支持任意前端、逐层优化与多种后端。
Datalog 系统众多,但各自方言、记法与优化策略不同,导致改进难以跨系统移植。本文提出首个通用 Datalog 编译器框架,支持任意前端语言并面向任意后端求解器。核心是带类型的多级 Datalog IR,可扩展且保证可执行性:前端将方言翻译到扩展 IR,再逐级降低到核心 Datalog 并在各层优化,最后交给不同求解器。作者形式化了该 IR 的类型系统,其具有双向、流敏感、双极和三值类型环境等特性,同时校验类型兼容并跟踪逻辑变量绑定。框架已实现,集成 4 个前端、3 个后端和 16 个 IR 扩展。
The resurgence of Datalog in the last two decades has led to a multitude of new Datalog systems. These systems explore novel ideas for improving Datalog’s programmability and performance, making important contributions to the field. Unfortunately, the individual systems progress at a much slower pace than the overall field, because improvements in one system are rarely ported to other systems. The reason for this rift is that each system provides its own Datalog dialect with specific notation, language features, and invariants, enabling specific optimization and execution strategies. This paper presents the first compiler framework for Datalog that can be used to support any Datalog frontend language and to target any Datalog backend. The centerpiece of our framework is a novel typed multi-level Datalog IR that supports IR extensions and guarantees executability. Existing Datalog systems can provide a compiler frontend that translates their Datalog dialect to the extended IR. The IR is then progressively lowered toward core Datalog, allowing optimizations at each level. At last, compiler backends can target different Datalog solvers. We have implemented the compiler framework and integrated 4 Datalog frontends and 3 Datalog backends, using 16 IR extensions. We also formalize the IR’s flexible type system, which is bidirectional, flow-sensitive, bipolar, and uses three-valued typing contexts. The type system simultaneously validates type compatibility and precisely tracks bindings of logic variables while permitting IR extensions.
@article{KloppEP24a,
title = {A Typed Multi-level Datalog IR and Its Compiler Framework},
author = {David Klopp and Sebastian Erdweg and André Pacak},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {OOPSLA2},
year = {2024},
doi = {10.1145/3689767}
}