News for hackers. Stuff that matters.
Re:SSA is Functional Programming (1998) [pdf] by XMPPwocky on Saturday January 12, 2019 @07:17PM (#18894116)
The issue is mostly the need for phi nodes everywhere for "true" SSA.

Might get away with something like- and I cite Rust here because I know it well, but these features are probably from ML-

> let x = if foo { 1 } else { 2 };

Loops are trickier- maybe you could write them as "unfolds"- where the loop body is effectively a fn foo(T) -> T, where T is a struct containing all the variables "modified" by the loop. Then evaluate iteratively, starting from the live values on entry. On exit, the live values are the result of the final invocation

Re:SSA is Functional Programming (1998) [pdf] by chubot on Saturday January 12, 2019 @08:19PM (#18894391)
Yeah now I remember from reading this paper a few weeks ago: An important point is that SSA is not executable!!! The Phi nodes need to be removed I suppose.

I will have to read this paper about Appel to see how that comes into play.

SSA form cannot be directly interpreted in order to generate code. Therefore it must be destructed before compilation can continue. This involves using an algorithm that converts phi-functions into appropriately-placed copy instructions.

Intermediate representations in imperative compilers: A survey

https://scholar.google.com/scholar?cluster=15761365096026414...

Re:SSA is Functional Programming (1998) [pdf] by nickpsecurity on Saturday January 12, 2019 @11:52PM (#18895149)
Like with parallel DFS, I always look for anything people say is not possible. Here's my first hit on Google with a super-quick skim indicating it runs with phi instructions:

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.74....

May or may not be what you're looking for. Probably interesting nonetheless.

Re:SSA is Functional Programming (1998) [pdf] by chubot on Sunday January 13, 2019 @01:38AM (#18895467)
Thanks, that does look interesting. The fact that interpreting SSA requires a paper means it's nontrivial, which lends credence to the original statement :) In the abstract it says they present a variant of SSA. I will take a look.
Re:SSA is Functional Programming (1998) [pdf] by zozbot123 on Saturday January 12, 2019 @08:44PM (#18894493)
Phi functions are a syntactical hack which can be avoided by allowing a basic block that would contain a "phi function" to instead take parameters (similar to the ANF representation). It's a lot more principled than the "phi" hack, but still quite simple and intuitive.
Re:SSA is Functional Programming (1998) [pdf] by abecedarius on Saturday January 12, 2019 @10:07PM (#18894781)
I saw somewhere a short paper presenting a syntax to write programs in essentially SSA directly, which I think was sort of like that, but it's not coming up in a quick search. I'd thought it was by Anton Ertl.

FWIW, I used this idea (extended basic blocks are functions with m arguments and n results) in https://github.com/darius/idel with a Forth-like syntax back in 2001.