本文整理汇总了C#中Reko.UnitTests.Mocks.ProcedureBuilder.Phi方法的典型用法代码示例。如果您正苦于以下问题:C# ProcedureBuilder.Phi方法的具体用法?C# ProcedureBuilder.Phi怎么用?C# ProcedureBuilder.Phi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reko.UnitTests.Mocks.ProcedureBuilder
的用法示例。
在下文中一共展示了ProcedureBuilder.Phi方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutpReplacePhi
public void OutpReplacePhi()
{
var m = new ProcedureBuilder();
var foo = new Identifier("foo", PrimitiveType.Word32, null);
var foo1 = new Identifier("foo1", PrimitiveType.Word32, null);
var foo2 = new Identifier("foo2", PrimitiveType.Word32, null);
var foo3 = new Identifier("foo3", PrimitiveType.Word32, null);
var pfoo = new Identifier("pfoo", PrimitiveType.Pointer32, null);
Block block1 = m.Label("block1");
m.Assign(foo1, Constant.Word32(1));
Statement stmFoo1 = m.Block.Statements.Last;
Block block2 = m.Label("block2");
m.Assign(foo2, Constant.Word32(2));
Statement stmFoo2 = m.Block.Statements.Last;
Block block3 = m.Label("block3");
Statement stmFoo3 = m.Phi(foo3, foo1, foo2);
SsaIdentifierCollection ssaIds = new SsaIdentifierCollection();
ssaIds.Add(foo1, new SsaIdentifier(foo1, foo, stmFoo1, null, false));
ssaIds.Add(foo2, new SsaIdentifier(foo2, foo, stmFoo2, null, false));
ssaIds.Add(foo3, new SsaIdentifier(foo3, foo, stmFoo3, null, false));
OutParameterTransformer opt = new OutParameterTransformer(null, ssaIds);
opt.ReplaceDefinitionsWithOutParameter(foo3, pfoo);
Assert.AreEqual("*pfoo = 0x00000001", stmFoo1.Instruction.ToString());
Assert.AreEqual("*pfoo = 0x00000002", stmFoo2.Instruction.ToString());
Assert.AreEqual("foo3 = PHI(foo1, foo2)", stmFoo3.Instruction.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());
}
示例3: CreateNoincInitialValue
public void CreateNoincInitialValue()
{
ProcedureBuilder m = new ProcedureBuilder();
ssaIds = new SsaIdentifierCollection();
SsaId(new Identifier("id0", PrimitiveType.Word32, new TemporaryStorage("id0", 0, PrimitiveType.Word32)), null, null, false);
SsaId(new Identifier("id1", PrimitiveType.Word32, new TemporaryStorage("id1", 1, PrimitiveType.Word32)), null, null, false);
LinearInductionVariableFinder liv = new LinearInductionVariableFinder(null, ssaIds, null);
liv.Context.InitialValue = Constant.Word32(0);
Identifier id2 = m.Local32("id_2");
SsaId(id2, new Statement(0, null, null), null, false);
Assert.AreEqual(3, ssaIds.Count);
Identifier id3 = m.Local32("id_3");
Identifier id4 = m.Local32("id_4");
liv.Context.PhiStatement = m.Phi(id3, id2, id4);
liv.Context.PhiIdentifier = id3;
SsaId(id3, liv.Context.PhiStatement, ((PhiAssignment)liv.Context.PhiStatement.Instruction).Src, false);
Assert.AreEqual(4, ssaIds.Count);
Statement use = new Statement(0, null, null);
ssaIds[id3].Uses.Add(use);
liv.Context.DeltaValue = m.Int32(1);
m.Assign(id4, m.IAdd(id3, liv.Context.DeltaValue));
liv.Context.DeltaStatement = m.Block.Statements.Last;
ssaIds[id3].Uses.Add(liv.Context.DeltaStatement);
LinearInductionVariable iv = liv.CreateInductionVariable();
Assert.AreEqual("(0x00000000 0x00000001 ?)", iv.ToString());
}