# A full linear scan register allocator, written entirely in Datalog

Original title: Linear scan register allocation in Datalog

> Hacker News story 50611889 · language: en · submitted 2026-11-23
> Web version: https://zeli.app/story/50611889
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 14 · by [torutofu](<https://news.ycombinator.com/user?id=torutofu>) · 💬 0
[original](<https://bernsteinbear.com/blog/lsra-datalog/>) · [HN discussion](<https://news.ycombinator.com/item?id=50611889>)

## Summary

After building a small linear scan register allocator in Ruby, Max Bernstein wanted to know whether the whole thing could live in Datalog. A conversation with Yannis Smaragdakis at PLDI turned the idea into code: basic blocks and liveness analysis fall out in a handful of rules, while the sequential, imperative steps of linear scan must be simulated declaratively, including a forall emulation for choosing which interval to spill.

## Key quote

> Datalog is fun. It's not for everyone or everything. But I love nerd sniping people at conferences.

---

## Cite

- Page: https://zeli.app/story/50611889
- Date: 2026-11-23
- Source: bernsteinbear.com (https://bernsteinbear.com/blog/lsra-datalog/)
- Hacker News: https://news.ycombinator.com/item?id=50611889

## Other languages

- zh: https://zeli.app/zh/story/50611889 · markdown: https://zeli.app/zh/story/50611889.md
- ja: https://zeli.app/ja/story/50611889 · markdown: https://zeli.app/ja/story/50611889.md
- ko: https://zeli.app/ko/story/50611889 · markdown: https://zeli.app/ko/story/50611889.md
- de: https://zeli.app/de/story/50611889 · markdown: https://zeli.app/de/story/50611889.md
- es: https://zeli.app/es/story/50611889 · markdown: https://zeli.app/es/story/50611889.md
- ru: https://zeli.app/ru/story/50611889 · markdown: https://zeli.app/ru/story/50611889.md
