private void RunTest(string sExp, Action <ProcedureBuilder> bld)
        {
            var m = new ProcedureBuilder();

            bld(m);
            var proc = m.Procedure;
            var ssa  = new SsaTransform(
                new Program {
                Architecture = m.Architecture
            },
                proc,
                null,
                null,
                null).Transform();
            var segmentMap = new SegmentMap(Address.Ptr32(0));
            var vp         = new ValuePropagator(segmentMap, ssa, new CallGraph(), null, null);

            vp.Transform();
            var rule = new ConstDivisionImplementedByMultiplication(ssa);

            rule.Transform();
            var sw = new StringWriter();

            proc.Write(false, sw);
            if (sExp != sw.ToString())
            {
                Debug.Print("{0}", sw);
                Assert.AreEqual(sExp, sw.ToString());
            }
        }
Ejemplo n.º 2
0
        private void RunTest(string sExp, Action <ProcedureBuilder> bld)
        {
            var m = new ProcedureBuilder();

            bld(m);
            var proc  = m.Procedure;
            var alias = new Aliases(proc);

            alias.Transform();
            var ssa = new SsaTransform(
                null,
                proc,
                null,
                proc.CreateBlockDominatorGraph(),
                new HashSet <RegisterStorage>()).Transform();
            var segmentMap = new SegmentMap(Address.Ptr32(0));
            var vp         = new ValuePropagator(segmentMap, ssa, null, null);

            vp.Transform();
            var rule = new ConstDivisionImplementedByMultiplication(ssa);

            rule.Transform();
            var sw = new StringWriter();

            proc.Write(false, sw);
            if (sExp != sw.ToString())
            {
                Debug.Print("{0}", sw);
                Assert.AreEqual(sExp, sw.ToString());
            }
        }