当前位置: 首页>>代码示例>>C#>>正文


C# ProcedureBuilder.Emit方法代码示例

本文整理汇总了C#中Reko.UnitTests.Mocks.ProcedureBuilder.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# ProcedureBuilder.Emit方法的具体用法?C# ProcedureBuilder.Emit怎么用?C# ProcedureBuilder.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reko.UnitTests.Mocks.ProcedureBuilder的用法示例。


在下文中一共展示了ProcedureBuilder.Emit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssertSmallConst

        private void AssertSmallConst(string sExp, int shift, uint mult)
        {
            var m = new ProcedureBuilder();
            var c = Constant.Int32((int)mult);
            var r1 = m.Reg32("r1", 1);
            var r2 = m.Reg32("r2", 2);
            var r2_r1 = m.Frame.EnsureSequence(r2.Storage, r1.Storage, PrimitiveType.Word64);

            var ass = m.Assign(r2_r1, m.SMul(r1, c));
            m.Emit(new AliasAssignment(r2, m.Slice(PrimitiveType.Word32, r2_r1, 32)));
            if (shift != 0)
                m.Assign(r2, m.Sar(r2, shift));

            var proc = m.Procedure;
            var ssa = new SsaTransform(
                null, 
                proc,
                null,
                proc.CreateBlockDominatorGraph(),
                new HashSet<RegisterStorage>()).Transform();
            var ctx = new SsaEvaluationContext(null, ssa.Identifiers);
            var rule = new ConstDivisionImplementedByMultiplication(ssa);
            ctx.Statement = proc.EntryBlock.Succ[0].Statements[0];
            Assert.IsTrue(rule.Match(ass));
            ass = rule.TransformInstruction();
            Assert.AreEqual(sExp, ass.Src.ToString());
        }
开发者ID:relaxar,项目名称:reko,代码行数:27,代码来源:ConstDivisionImplementedByMultiplicationTests.cs

示例2: VpPhiLoops

 public void VpPhiLoops()
 {
     var m = new ProcedureBuilder();
     var ssa = new SsaState(m.Procedure, null);
     ssaIds = ssa.Identifiers;
     var fp = Reg16("fp");
     var a = Reg16("a");
     var b = Reg16("b");
     var c = Reg16("c");
     var d = Reg16("d");
     var x = Reg16("x");
     var y = Reg16("y");
     var z = Reg16("z");
     m.Emit(m.Assign(y, m.IAdd(x, 4)));
     m.Emit(m.Assign(z, m.ISub(x, 8)));
     m.Emit(m.Assign(a, m.ISub(fp, 12)));
     m.Emit(m.Assign(b, m.ISub(fp, 12)));
     m.Emit(m.Assign(c, m.ISub(y, 4)));
     m.Emit(m.Assign(d, m.IAdd(z, 8)));
     var phiStm = m.Phi(x, a, b, c, d);
     var stms = m.Procedure.EntryBlock.Succ[0].Statements;
     stms.ForEach(stm =>
     {
         var ass = stm.Instruction as Assignment;
         if (ass != null)
             ssaIds[ass.Dst].DefStatement = stm;
         var phiAss = stm.Instruction as PhiAssignment;
         if (phiAss != null)
             ssaIds[phiAss.Dst].DefStatement = stm;
     });
     var vp = new ValuePropagator(arch, ssa);
     vp.Transform();
     Assert.AreEqual("x = fp - 0x000C", phiStm.Instruction.ToString());
 }
开发者ID:uxmal,项目名称:reko,代码行数:34,代码来源:ValuePropagationTests.cs


注:本文中的Reko.UnitTests.Mocks.ProcedureBuilder.Emit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。