Simple – Sea of Nodes

2 pointsposted 17 hours ago
by cliffc

4 Comments

fuhsnn

14 hours ago

I'm currently pondering an IR format for a mildly optimizing C23 implementation, and am curious how C11 atomic operations would look like in sea-of-nodes. The representation seems to be completely opposite to the programming model, where strict ordering and memory fencing are required. libFirm[0] is probably the most sophisticated sea-of-nodes based AOT compilers I'm aware of, it's a shame they ceased development before implementing atomics.

[0] https://pp.ipd.kit.edu/firm/Features.html

cliffc

17 hours ago

Simple (https://github.com/SeaOfNodes) is a compiler tutorial featuring the Sea-of-Nodes IR, with ports in Java (@cliffclick), Go (@yardenlaif), Rust (@RobertObkircher), and C++ (@Hels15), with help from @XmiliaH, @ThaliaArchi. If you'd like to help reach out to cliffc@acm.org or on GitHub.

cliffc

13 hours ago

C2/HotSpot uses a MemBarrier / MemFence node type for these. Serializes the memory ops as needed. Used to implement the Java memory model on all hardware. Sometimes (x86) the ops encode as (empty), sometimes its a Real Fence op.

fuhsnn

8 minutes ago

Thanks for the info. So in practice there are node types that encode sequential flow as needed. I wonder if the other way around works: keep the CFG form for side effects and only promote SSA values to be "floating".