Ejemplo n.º 1
0
        public void SrtSimpleLoop()
        {
            Procedure proc = BuildSimpleLoop();

            var          dom = proc.CreateBlockDominatorGraph();
            SsaTransform ssa = new SsaTransform(new ProgramDataFlow(), proc, dom);

            proc.Write(false, Console.Out);
            LinearInductionVariableFinder lif = new LinearInductionVariableFinder(proc, ssa.SsaState.Identifiers, dom);

            lif.Find();

            Assert.AreEqual(1, lif.InductionVariables.Count, "Should have found one induction variable");
            Assert.AreEqual(1, lif.Contexts.Count);
            LinearInductionVariableContext ctx = lif.Contexts[lif.InductionVariables[0]];

            StrengthReduction str = new StrengthReduction(ssa.SsaState, lif.InductionVariables[0], ctx);

            str.ClassifyUses();
            Assert.AreEqual(1, str.IncrementedUses.Count);
            str.ModifyUses();
            Assert.AreEqual("(0x00003000 0x00000004 0x00007000)", lif.InductionVariables[0].ToString());
            using (FileUnitTester fut = new FileUnitTester("Analysis/SrtSimpleLoop.txt"))
            {
                proc.Write(false, fut.TextWriter);
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 2
0
        //[Test]
        public void VnRedundantStore()
        {
            Program program = RewriteCodeFragment(
                @".i86
	mov	ax,2
isdone:
	cmp	bx,10
	jz  yay
boo: mov ax,3
	jmp done
yay:
	mov ax,3
done:
	ret
");

            using (FileUnitTester fut = new FileUnitTester("Analysis/VnRedundantStore.txt"))
            {
                Procedure proc  = program.Procedures.Values[0];
                var       gr    = proc.CreateBlockDominatorGraph();
                Aliases   alias = new Aliases(proc, program.Architecture);
                alias.Transform();
                SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, null, gr,
                                                    new HashSet <RegisterStorage>());
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);
                ValueNumbering vn = new ValueNumbering(ssa.Identifiers, null);
                vn.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 3
0
        //[Test]
        public void VnSumTest()
        {
            Program prog = RewriteCodeFragment(
                @".i86
	push bp
	mov	 bp,sp
	mov	dx,3
	add dx,dx

	mov bx,3
	lea dx,[bx+3]
	mov sp,bp
	pop	bp
	ret
	"    );

            using (FileUnitTester fut = new FileUnitTester("Analysis/VnSumTest.txt"))
            {
                Procedure proc  = prog.Procedures.Values[0];
                Aliases   alias = new Aliases(proc, prog.Architecture);
                alias.Transform();
                var          gr  = proc.CreateBlockDominatorGraph();
                SsaTransform sst = new SsaTransform(
                    new ProgramDataFlow(),
                    proc,
                    null,
                    gr,
                    new HashSet <RegisterStorage>());
                SsaState       ssa = sst.SsaState;
                ValueNumbering vn  = new ValueNumbering(ssa.Identifiers, null);
                DumpProc(proc, ssa, fut.TextWriter);
                vn.Write(fut.TextWriter);
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 4
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);

            this.proc = proc;
            Aliases alias = new Aliases(proc, arch);

            alias.Transform();
            var          gr  = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, gr);
            SsaState     ssa = sst.SsaState;

            this.ssaIds = ssa.Identifiers;

            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, platform);

            cce.Transform();
            DeadCode.Eliminate(proc, ssa);

            ValuePropagator vp = new ValuePropagator(arch, ssa.Identifiers, proc);

            vp.Transform();

            Coalescer coa = new Coalescer(proc, ssa);

            coa.Transform();

            DeadCode.Eliminate(proc, ssa);
        }
Ejemplo n.º 5
0
        //[Test]
        public void VnLoop()
        {
            Program program = RewriteCodeFragment(@".i86
	push ax
	jmp looptest
again:
    mov si,[0x302]
	mov ax,[si+04]
	add [si+06],ax
looptest:
    cmp	ax,bx
	jl again

	pop ax
	ret
");

            using (FileUnitTester fut = new FileUnitTester("Analysis/VnLoop.txt"))
            {
                Procedure proc  = program.Procedures.Values[0];
                var       gr    = proc.CreateBlockDominatorGraph();
                Aliases   alias = new Aliases(proc, program.Architecture);
                alias.Transform();
                SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, null, gr,
                                                    new HashSet <RegisterStorage>());
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);
                ValueNumbering vn = new ValueNumbering(ssa.Identifiers, null);
                vn.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 6
0
        //[Test]
        public void VnMemoryTest()
        {
            Program program = RewriteCodeFragment(
                @".i86
	mov word ptr [bx+2],0
	mov si,[bx+4]
	mov ax,[bx+2]
	mov cx,[bx+2]
	mov dx,[bx+4]
	ret
");

            using (FileUnitTester fut = new FileUnitTester("Analysis/VnMemoryTest.txt"))
            {
                Procedure proc  = program.Procedures.Values[0];
                var       gr    = proc.CreateBlockDominatorGraph();
                Aliases   alias = new Aliases(proc, program.Architecture);
                alias.Transform();
                SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, null, gr,
                                                    new HashSet <RegisterStorage>());
                SsaState       ssa = sst.SsaState;
                ValueNumbering vn  = new ValueNumbering(ssa.Identifiers, null);
                DumpProc(proc, ssa, fut.TextWriter);
                vn.Write(fut.TextWriter);
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 7
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);

            this.proc = proc;
            Aliases alias = new Aliases(proc, arch);

            alias.Transform();
            SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                null,
                proc.CreateBlockDominatorGraph(),
                new HashSet <RegisterStorage>());

            ssa = sst.SsaState;
            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform);

            cce.Transform();
            ValuePropagator vp = new ValuePropagator(arch, ssa.Identifiers, proc);

            vp.Transform();
            DeadCode.Eliminate(proc, ssa);
            Coalescer coa = new Coalescer(proc, ssa);

            coa.Transform();
            DeadCode.Eliminate(proc, ssa);

            sla  = new SsaLivenessAnalysis(proc, ssa.Identifiers);
            sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers);
            sla2.Analyze();
        }
Ejemplo n.º 8
0
        public void VpDbpDbp()
        {
            var m   = new ProcedureBuilder();
            var d1  = m.Reg32("d32");
            var a1  = m.Reg32("a32");
            var tmp = m.Frame.CreateTemporary(PrimitiveType.Word16);

            m.Assign(d1, m.Dpb(d1, m.LoadW(a1), 0, 16));
            m.Assign(d1, m.Dpb(d1, m.LoadW(m.IAdd(a1, 4)), 0, 16));

            Procedure    proc = m.Procedure;
            var          gr   = proc.CreateBlockDominatorGraph();
            SsaTransform sst  = new SsaTransform(new ProgramDataFlow(), proc, gr);
            SsaState     ssa  = sst.SsaState;

            ssa.DebugDump(true);

            var vp = new ValuePropagator(arch, ssa.Identifiers, proc);

            vp.Transform();

            using (FileUnitTester fut = new FileUnitTester("Analysis/VpDpbDpb.txt"))
            {
                proc.Write(false, fut.TextWriter);
                fut.TextWriter.WriteLine();
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 9
0
        private void Prepare(Procedure proc)
        {
            var listener       = new FakeDecompilerEventListener();
            var importResolver = new Mock <IImportResolver>().Object;

            this.proc = proc;
            doms      = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                importResolver,
                doms,
                new HashSet <RegisterStorage>());
            SsaState ssa = sst.SsaState;

            ssaIds = ssa.Identifiers;

            var arch = new FakeArchitecture();
            var cce  = new ConditionCodeEliminator(ssa, new DefaultPlatform(null, arch));

            cce.Transform();

            DeadCode.Eliminate(proc, ssa);

            var segmentMap = new SegmentMap(Address.Ptr32(0x00123400));
            var vp         = new ValuePropagator(segmentMap, ssa, new CallGraph(), importResolver, listener);

            vp.Transform();

            DeadCode.Eliminate(proc, ssa);
        }
Ejemplo n.º 10
0
        public void VpDbpDbp()
        {
            var m  = new ProcedureBuilder();
            var d1 = m.Reg32("d32", 0);
            var a1 = m.Reg32("a32", 1);

            m.Assign(d1, m.Dpb(d1, m.LoadW(a1), 0));
            m.Assign(d1, m.Dpb(d1, m.LoadW(m.IAdd(a1, 4)), 0));

            Procedure proc           = m.Procedure;
            var       gr             = proc.CreateBlockDominatorGraph();
            var       importResolver = MockRepository.GenerateStub <IImportResolver>();

            importResolver.Replay();
            var sst = new SsaTransform(new ProgramDataFlow(), proc, importResolver, gr, new HashSet <RegisterStorage>());
            var ssa = sst.SsaState;

            var vp = new ValuePropagator(arch, ssa, listener);

            vp.Transform();

            using (FileUnitTester fut = new FileUnitTester("Analysis/VpDpbDpb.txt"))
            {
                proc.Write(false, fut.TextWriter);
                fut.TextWriter.WriteLine();
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 11
0
        private void Prepare(Procedure proc)
        {
            var listener      = new FakeDecompilerEventListener();
            var dynamicLinker = new Mock <IDynamicLinker>().Object;

            doms = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(
                new Program(),
                proc,
                new HashSet <Procedure>(),
                dynamicLinker,
                new ProgramDataFlow());

            sst.Transform();
            this.ssa = sst.SsaState;

            var arch = new FakeArchitecture();
            var cce  = new ConditionCodeEliminator(ssa, new DefaultPlatform(null, arch));

            cce.Transform();

            DeadCode.Eliminate(ssa);

            var segmentMap = new SegmentMap(Address.Ptr32(0x00123400));
            var vp         = new ValuePropagator(segmentMap, ssa, new CallGraph(), dynamicLinker, listener);

            vp.Transform();

            DeadCode.Eliminate(ssa);
        }
Ejemplo n.º 12
0
 public LiveCopyInserter(Procedure proc, SsaIdentifierCollection ssaIds)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
     this.sla    = new SsaLivenessAnalysis(proc, ssaIds);
     this.doms   = proc.CreateBlockDominatorGraph();
 }
Ejemplo n.º 13
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);

            this.proc = proc;
            Aliases alias = new Aliases(proc);

            alias.Transform();
            var          importResolver = new Mock <IImportResolver>().Object;
            SsaTransform sst            = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                importResolver,
                proc.CreateBlockDominatorGraph(),
                new HashSet <RegisterStorage>());

            ssa = sst.SsaState;
            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform);

            cce.Transform();
            var             segmentMap = new SegmentMap(Address.Ptr32(0x00123400));
            ValuePropagator vp         = new ValuePropagator(segmentMap, ssa, importResolver, new FakeDecompilerEventListener());

            vp.Transform();
            DeadCode.Eliminate(proc, ssa);
            Coalescer coa = new Coalescer(proc, ssa);

            coa.Transform();
            DeadCode.Eliminate(proc, ssa);

            sla  = new SsaLivenessAnalysis(proc, ssa.Identifiers);
            sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers);
            sla2.Analyze();
        }
        private void Prepare(ProcedureBuilder mock)
        {
            proc = mock.Procedure;
            SsaTransform tr = new SsaTransform(new ProgramDataFlow(), proc, null, proc.CreateBlockDominatorGraph(), new HashSet <RegisterStorage>());

            ssaIds = tr.SsaState.Identifiers;
        }
Ejemplo n.º 15
0
        public void VpDbpDbp()
        {
            var m  = new ProcedureBuilder();
            var d1 = m.Reg32("d32", 0);
            var a1 = m.Reg32("a32", 1);

            m.Assign(d1, m.Dpb(d1, m.Mem16(a1), 0));
            m.Assign(d1, m.Dpb(d1, m.Mem16(m.IAdd(a1, 4)), 0));

            Procedure proc          = m.Procedure;
            var       gr            = proc.CreateBlockDominatorGraph();
            var       dynamicLinker = new Mock <IDynamicLinker>();
            var       sst           = new SsaTransform(
                program,
                proc,
                new HashSet <Procedure>(),
                dynamicLinker.Object,
                new ProgramDataFlow());

            sst.Transform();
            var ssa = sst.SsaState;

            var vp = new ValuePropagator(segmentMap, ssa, program.CallGraph, dynamicLinker.Object, listener);

            vp.Transform();

            using (FileUnitTester fut = new FileUnitTester("Analysis/VpDpbDpb.txt"))
            {
                proc.Write(false, fut.TextWriter);
                fut.TextWriter.WriteLine();
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 16
0
        private void Prepare(Procedure proc)
        {
            this.proc = proc;
            doms      = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                null,
                doms,
                new HashSet <RegisterStorage>());
            SsaState ssa = sst.SsaState;

            ssaIds = ssa.Identifiers;

            var arch = new FakeArchitecture();
            var cce  = new ConditionCodeEliminator(ssa, new DefaultPlatform(null, arch));

            cce.Transform();

            DeadCode.Eliminate(proc, ssa);

            var vp = new ValuePropagator(arch, ssa.Identifiers, proc);

            vp.Transform();

            DeadCode.Eliminate(proc, ssa);
        }
Ejemplo n.º 17
0
		public LiveCopyInserter(Procedure proc, SsaIdentifierCollection ssaIds)
		{
			this.proc = proc;
			this.ssaIds = ssaIds;
			this.sla = new SsaLivenessAnalysis(proc, ssaIds);
			this.doms = proc.CreateBlockDominatorGraph();
		}
Ejemplo n.º 18
0
        private void Build(Procedure proc)
        {
            this.proc = proc;
            this.doms = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, doms);

            this.ssaIds = sst.SsaState.Identifiers;
        }
Ejemplo n.º 19
0
        private void Build(Procedure proc)
        {
            this.proc = proc;
            this.doms = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, doms);

            this.ssaIds = sst.SsaState.Identifiers;
        }
Ejemplo n.º 20
0
 public WebBuilder(Procedure proc, SsaIdentifierCollection ssaIds, Dictionary <Identifier, LinearInductionVariable> ivs)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
     this.ivs    = ivs;
     this.sla    = new SsaLivenessAnalysis(proc, ssaIds);
     this.doms   = proc.CreateBlockDominatorGraph();
     this.webs   = new List <Web>();
 }
Ejemplo n.º 21
0
 public WebBuilder(Procedure proc, SsaIdentifierCollection ssaIds, Dictionary<Identifier,LinearInductionVariable> ivs)
 {
     this.proc = proc;
     this.ssaIds = ssaIds;
     this.ivs = ivs;
     this.sla = new SsaLivenessAnalysis(proc, ssaIds);
     this.doms = proc.CreateBlockDominatorGraph();
     this.webs = new List<Web>();
 }
Ejemplo n.º 22
0
        public void DiamondDominatorTest()
        {
            Program             prog = RewriteFile("Fragments/diamond.asm");
            Procedure           proc = prog.Procedures.Values[0];
            BlockDominatorGraph doms = proc.CreateBlockDominatorGraph();
            var diamondTop           = proc.ControlGraph.Blocks[2];

            Assert.AreSame(diamondTop, doms.ImmediateDominator(diamondTop.ElseBlock));
            Assert.AreSame(diamondTop, doms.ImmediateDominator(diamondTop.ThenBlock));
        }
Ejemplo n.º 23
0
		private void Build(Procedure proc)
		{
			this.proc = proc;
			this.doms = proc.CreateBlockDominatorGraph();

			SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(), 
                proc, 
                null, 
                doms,
                new HashSet<RegisterStorage>());
			
			this.ssaIds = sst.SsaState.Identifiers;
		}
Ejemplo n.º 24
0
        private void Build(Procedure proc)
        {
            this.proc = proc;
            this.doms = proc.CreateBlockDominatorGraph();

            SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                null,
                doms,
                new HashSet <RegisterStorage>());

            this.ssaIds = sst.SsaState.Identifiers;
        }
Ejemplo n.º 25
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);
            var program  = new Program()
            {
                Architecture = arch,
                Platform     = platform,
            };

            this.proc = proc;
            var          dynamicLinker = new Mock <IDynamicLinker>().Object;
            var          gr            = proc.CreateBlockDominatorGraph();
            SsaTransform sst           = new SsaTransform(
                program,
                proc,
                new HashSet <Procedure>(),
                null,
                new ProgramDataFlow());

            sst.Transform();
            this.ssa    = sst.SsaState;
            this.ssaIds = ssa.Identifiers;

            var listener = new FakeDecompilerEventListener();
            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform, listener);

            cce.Transform();
            DeadCode.Eliminate(ssa);

            var             segmentMap = new SegmentMap(Address.Ptr32(0x00400000));
            ValuePropagator vp         = new ValuePropagator(
                segmentMap,
                ssa,
                program.CallGraph,
                null,
                listener);

            vp.Transform();

            Coalescer coa = new Coalescer(ssa);

            coa.Transform();

            DeadCode.Eliminate(ssa);
        }
Ejemplo n.º 26
0
        public void Create1()
        {
            Prepare(new WhileLtIncMock().Procedure);
            var doms = proc.CreateBlockDominatorGraph();
            LinearInductionVariableFinder liv = new LinearInductionVariableFinder(proc, ssaIds, doms);

            Assert.IsNull(liv.Context.PhiIdentifier);
            Assert.IsNull(liv.Context.PhiStatement);
            Assert.Fail(); /*
                            * liv.Context.PhiStatement = ssaIds[5].DefStatement;
                            * liv.Context.PhiIdentifier = (Identifier) ((PhiAssignment) liv.Context.PhiStatement.Instruction).Dst;
                            * liv.Context.TestStatement = proc.ControlGraph.Blocks[2].Statements[1];
                            * liv.Context.DeltaStatement = ssaIds[8].DefStatement;
                            * liv.Context.InitialValue = Constant.Word32(0);
                            * liv.Context.DeltaValue = Constant.Word32(1);
                            * liv.Context.TestValue = Constant.Word32(10);
                            * LinearInductionVariable iv = liv.CreateInductionVariable();
                            * Assert.AreEqual("X", iv.ToString()); */
        }
Ejemplo n.º 27
0
        //[Test]
        public void VnLoopTest()
        {
            Program program = this.RewriteCodeFragment(
                @".i86
	mov	ax,1
	mov	bx,1
isdone:
	cmp	ax,10
	jz  done

	inc ax
	inc bx
	jmp isdone
done:
	mov [0002],ax
	mov	[0004],bx
	ret
");

            using (FileUnitTester fut = new FileUnitTester("Analysis/VnLoopTest.txt"))
            {
                Procedure proc  = program.Procedures.Values[0];
                var       gr    = proc.CreateBlockDominatorGraph();
                Aliases   alias = new Aliases(proc, program.Architecture);
                alias.Transform();
                SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, null, gr,
                                                    new HashSet <RegisterStorage>());
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);

                DeadCode.Eliminate(proc, ssa);

                DumpProc(proc, ssa, fut.TextWriter);

                ValueNumbering vn = new ValueNumbering(ssa.Identifiers, null);
                vn.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 28
0
        private void Prepare(Procedure proc)
        {
            this.proc = proc;
            doms      = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, doms);
            SsaState     ssa = sst.SsaState;

            ssaIds = ssa.Identifiers;

            var cce = new ConditionCodeEliminator(ssaIds, new DefaultPlatform(null, new FakeArchitecture()));

            cce.Transform();

            DeadCode.Eliminate(proc, ssa);

            var vp = new ValuePropagator(ssa.Identifiers, proc);

            vp.Transform();

            DeadCode.Eliminate(proc, ssa);
            proc.Dump(true); //$DEBUG
        }
Ejemplo n.º 29
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);

            this.proc = proc;
            var importResolver = MockRepository.GenerateStub <IImportResolver>();

            importResolver.Replay();
            Aliases alias = new Aliases(proc);

            alias.Transform();
            var          gr  = proc.CreateBlockDominatorGraph();
            SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                null,
                gr,
                new HashSet <RegisterStorage>());
            SsaState ssa = sst.SsaState;

            this.ssaIds = ssa.Identifiers;

            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform);

            cce.Transform();
            DeadCode.Eliminate(proc, ssa);

            var             segmentMap = new SegmentMap(Address.Ptr32(0x00400000));
            ValuePropagator vp         = new ValuePropagator(segmentMap, ssa, new FakeDecompilerEventListener());

            vp.Transform();

            Coalescer coa = new Coalescer(proc, ssa);

            coa.Transform();

            DeadCode.Eliminate(proc, ssa);
        }
Ejemplo n.º 30
0
		private void Build(Procedure proc, IProcessorArchitecture arch)
		{
            var platform = new DefaultPlatform(null, arch);
			this.proc = proc;
            var importResolver = MockRepository.GenerateStub<IImportResolver>();
            importResolver.Replay();
            Aliases alias = new Aliases(proc, arch);
			alias.Transform();
			var gr = proc.CreateBlockDominatorGraph();
			SsaTransform sst = new SsaTransform(
                new ProgramDataFlow(),
                proc,
                null,
                gr,
                new HashSet<RegisterStorage>());
			SsaState ssa = sst.SsaState;
			this.ssaIds = ssa.Identifiers;

			ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform);
			cce.Transform();
			DeadCode.Eliminate(proc, ssa);

			ValuePropagator vp = new ValuePropagator(arch, ssa);
			vp.Transform();

			Coalescer coa = new Coalescer(proc, ssa);
			coa.Transform();

			DeadCode.Eliminate(proc, ssa);
		}
		private void Prepare(ProcedureBuilder mock)
		{
			proc = mock.Procedure;
			SsaTransform tr = new SsaTransform(new ProgramDataFlow(), proc, proc.CreateBlockDominatorGraph());
			ssaIds = tr.SsaState.Identifiers;
		}
Ejemplo n.º 32
0
        private void Build(Procedure proc, IProcessorArchitecture arch)
        {
            var platform = new DefaultPlatform(null, arch);
            this.proc = proc;
            Aliases alias = new Aliases(proc, arch);
            alias.Transform();
            SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, proc.CreateBlockDominatorGraph());
            ssa = sst.SsaState;
            ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, platform);
            cce.Transform();
            ValuePropagator vp = new ValuePropagator(arch, ssa.Identifiers, proc);
            vp.Transform();
            DeadCode.Eliminate(proc, ssa);
            Coalescer coa = new Coalescer(proc, ssa);
            coa.Transform();
            DeadCode.Eliminate(proc, ssa);

            sla = new SsaLivenessAnalysis(proc, ssa.Identifiers);
            sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers);
            sla2.Analyze();
        }
Ejemplo n.º 33
0
		private void Build(Procedure proc, IProcessorArchitecture arch)
		{
            var platform = new DefaultPlatform(null, arch);
			this.proc = proc;
			Aliases alias = new Aliases(proc, arch);
			alias.Transform();
			var gr = proc.CreateBlockDominatorGraph();
			SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, gr);
			SsaState ssa = sst.SsaState;
			this.ssaIds = ssa.Identifiers;

			ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, platform);
			cce.Transform();
			DeadCode.Eliminate(proc, ssa);

			ValuePropagator vp = new ValuePropagator(ssa.Identifiers, proc);
			vp.Transform();

			Coalescer coa = new Coalescer(proc, ssa);
			coa.Transform();

			DeadCode.Eliminate(proc, ssa);
            proc.Dump(true, false); //$DEBUG
		}
		private void Prepare(Procedure proc)
		{
			this.proc = proc;
            doms = proc.CreateBlockDominatorGraph();
			SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, doms);
			SsaState ssa = sst.SsaState;
			ssaIds = ssa.Identifiers;

            var arch = new FakeArchitecture();
            var cce = new ConditionCodeEliminator(ssaIds, new DefaultPlatform(null, arch));
			cce.Transform();

			DeadCode.Eliminate(proc, ssa);

			var vp = new ValuePropagator(arch, ssa.Identifiers, proc);
			vp.Transform();

			DeadCode.Eliminate(proc, ssa);
		}