public void LciInsertAssignmentCopy() { Build(new LiveCopyMock().Procedure, new FakeArchitecture()); var lci = new LiveCopyInserter(proc, ssaIds); int i = lci.IndexOfInsertedCopy(proc.ControlGraph.Blocks[2]); Assert.AreEqual(i, 0); var idNew = lci.InsertAssignmentNewId(ssaIds.Where(s => s.Identifier.Name == "reg").Single().Identifier, proc.ControlGraph.Blocks[2], i); Assert.AreEqual("reg_4 = reg", proc.ControlGraph.Blocks[2].Statements[0].Instruction.ToString()); Assert.AreSame(proc.ControlGraph.Blocks[2].Statements[0], ssaIds[idNew].DefStatement); }
public void LciInsertAssignmentLiveLoop() { Build(new LiveLoopMock().Procedure, new FakeArchitecture()); var lci = new LiveCopyInserter(proc, ssaIds); var i_4 = ssaIds.Where(s => s.Identifier.Name == "i_1").Single(); var idNew = lci.InsertAssignmentNewId(i_4.Identifier, proc.ControlGraph.Blocks[2], 2); Assert.AreEqual("i_5 = i_1", proc.ControlGraph.Blocks[2].Statements[2].Instruction.ToString()); Assert.AreSame(proc.ControlGraph.Blocks[2].Statements[2], ssaIds[idNew].DefStatement); }
public void LciRenameDominatedIdentifiers() { Build(new LiveLoopMock().Procedure, new FakeArchitecture()); var lci = new LiveCopyInserter(proc, ssaIds); proc.ControlGraph.Blocks[1].Dump(); var i_1 = ssaIds.Where(s => s.Identifier.Name == "i_1").Single(); var idNew = lci.InsertAssignmentNewId(i_1.Identifier, proc.ControlGraph.Blocks[2], 2); lci.RenameDominatedIdentifiers(i_1, ssaIds[idNew]); Assert.AreEqual("return i_5", proc.ControlGraph.Blocks[2].ElseBlock.Statements[0].Instruction.ToString()); }