File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
optvm/src/main/java/com/compilerprogramming/ezlang/compiler Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public ExitSSA2(CompiledFunction function, EnumSet<Options> options) {
1818 insertPCopiesForEachBlock ();
1919 makeConventionalSSA ();
2020 removePhis ();
21- sequentialzeParallelCopies ();
21+ sequenceParallelCopies ();
2222 }
2323
2424 private void insertPCopiesForEachBlock () {
@@ -100,10 +100,26 @@ private void makeConventionalSSA() {
100100 }
101101
102102 private void removePhis () {
103-
103+ var blocks = function .getBlocks ();
104+ for (BasicBlock block : blocks ) {
105+ var phis = block .phis ();
106+ if (phis .isEmpty ())
107+ continue ;
108+ // Insert copy in predecessor
109+ for (var phi : phis ) {
110+ for (int j = 0 ; j < phi .numInputs (); j ++) {
111+ BasicBlock pred = block .predecessor (j );
112+ var pCopyBEnd = getParallelCopyAtEnd (pred );
113+ var phiInput = phi .input (j );
114+ var phiVar = phi .value ();
115+ pCopyBEnd .addCopy (phiInput ,new Operand .RegisterOperand (phiVar ));
116+ }
117+ }
118+ block .instructions .removeIf (instruction -> instruction instanceof Instruction .Phi );
119+ }
104120 }
105121
106- private void sequentialzeParallelCopies () {
122+ private void sequenceParallelCopies () {
107123
108124 }
109125
You can’t perform that action at this time.
0 commit comments