Write() public method

public Write ( System.IO.TextWriter writer ) : void
writer System.IO.TextWriter
return void
Example #1
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, gr);
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);
                ValueNumbering vn = new ValueNumbering(ssa.Identifiers);
                vn.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Example #2
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);
				DumpProc(proc, ssa, fut.TextWriter);
				vn.Write(fut.TextWriter);
				fut.AssertFilesEqual();
			}
		}
Example #3
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, gr);
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);

                DeadCode.Eliminate(proc, ssa);

                DumpProc(proc, ssa, fut.TextWriter);

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

                fut.AssertFilesEqual();
            }
        }
Example #4
0
 protected override void RunTest(Program program, TextWriter writer)
 {
     var progFlow = new ProgramDataFlow();
     foreach (Procedure proc in program.Procedures.Values)
     {
         var gr = proc.CreateBlockDominatorGraph();
         Aliases alias = new Aliases(proc, program.Architecture);
         alias.Transform();
         SsaTransform sst = new SsaTransform(progFlow, proc, gr);
         SsaState ssa = sst.SsaState;
         DumpProc(proc, ssa, writer);
         ValueNumbering vn = new ValueNumbering(ssa.Identifiers);
         vn.Write(writer);
         writer.WriteLine();
     }
 }
Example #5
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, gr);
                SsaState ssa = sst.SsaState;
                DumpProc(proc, ssa, fut.TextWriter);
                ValueNumbering vn = new ValueNumbering(ssa.Identifiers);
                vn.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Example #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, gr);
         SsaState ssa = sst.SsaState;
         ValueNumbering vn = new ValueNumbering(ssa.Identifiers);
         DumpProc(proc, ssa, fut.TextWriter);
         vn.Write(fut.TextWriter);
         fut.AssertFilesEqual();
     }
 }