本文整理汇总了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());
}
示例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());
}