mirror of
https://github.com/anoma/juvix.git
synced 2024-12-26 09:04:18 +03:00
cb808c1696
* Closes #2560 * Adds a transformation of JuvixReg into SSA form. * Adds an "output variable" field to branching instructions (`Case`, `Branch`) which indicates the output variable to which the result is assigned in both branches. The output variable corresponds to top of stack in JuvixAsm after executing the branches. In the SSA transformation, differently renamed output variables are unified by inserting assignment instructions at the end of branches. * Adds tests for the SSA transformation. * Depends on #2641.
45 lines
737 B
Plaintext
45 lines
737 B
Plaintext
|
|
function loop() : *;
|
|
function main() : *;
|
|
|
|
function loop() : * {
|
|
tcall loop ();
|
|
}
|
|
|
|
function main() : * {
|
|
tmp[0] = 3;
|
|
tmp[1] = 0;
|
|
tmp[0] = lt tmp[1] tmp[0];
|
|
br tmp[0], out: tmp[0] {
|
|
true: {
|
|
tmp[0] = 1;
|
|
};
|
|
false: {
|
|
tmp[0] = call loop ();
|
|
};
|
|
};
|
|
tmp[1] = 1;
|
|
tmp[2] = 2;
|
|
tmp[1] = le tmp[2] tmp[1];
|
|
br tmp[1], out: tmp[1] {
|
|
true: {
|
|
tmp[1] = call loop (), live: (tmp[0]);
|
|
};
|
|
false: {
|
|
tmp[1] = 7;
|
|
tmp[2] = 8;
|
|
tmp[1] = le tmp[2] tmp[1];
|
|
br tmp[1], out: tmp[1] {
|
|
true: {
|
|
tmp[1] = call loop (), live: (tmp[0]);
|
|
};
|
|
false: {
|
|
tmp[1] = 1;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
tmp[0] = add tmp[1] tmp[0];
|
|
ret tmp[0];
|
|
}
|