mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Add Phi functions to the IR to support full SSA #58

Open mfichman opened 11 years ago

mfichman commented 11 years ago

Currently, each variable assignment does not use a new register, so the IR is not truly SSA. For example, the code:

x = 9
if (true) {
    x = 10 
}

Generates

main:
.L1:
    t0 <- load 1
    t1 <- load 1
    if not t1 goto .L3
.L2:
    t0 <- load 42
.L3:

A truly SSA IR would generate a new temporary for each assignment, and Phi functions at the correct locations:

main:
.L1:
    t0 <- load 1
    t1 <- load 1
    if not t1 goto .L3
.L2:
    t2 <- load 42
.L3:
    phi(t0, t2)