NJVLis an intermediate representation that eliminates unstructured control flow (return, break, goto) in favor of control flow variables. Versioned locationsgive us all the benefits of SSA without its quirky phi nodes that are subtle to understand and to get rid of during code generation. This design enables powerful optimizations with simple, single-pass algorithms.
1. Control Flow Variables (cfvars)
Instead of jumps, use boolean variables to represent control flow:
(In the actual implementation control flow vars get some special instructions like jtrueand jfalsethat ensure these collapse to goto instructions without overhead.)
2. Versioned Locations
All variables get version numbers (like SSA, but for any location):
(var (v x.0 +0) +42) # x version 0 = 42
(asgn (v x.0 +1) +99) # x version 1 = 99
(call foo (v x.0 +1)) # Use x version 1
SSA's phi nodes are replaced by joininformation for ifs and eitherfor loop back edges. These are at fixed positions in the tree and cannot occur arbitrarily. The versioning scheme (plus joinand either) can be ignored entirely by a code generator.