本文整理汇总了C#中Reko.UnitTests.Mocks.ProcedureBuilder.Slice方法的典型用法代码示例。如果您正苦于以下问题:C# ProcedureBuilder.Slice方法的具体用法?C# ProcedureBuilder.Slice怎么用?C# ProcedureBuilder.Slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reko.UnitTests.Mocks.ProcedureBuilder
的用法示例。
在下文中一共展示了ProcedureBuilder.Slice方法的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: VpUndoUnnecessarySlicingOfSegmentPointer
public void VpUndoUnnecessarySlicingOfSegmentPointer()
{
var m = new ProcedureBuilder();
var es = m.Reg16("es", 1);
var bx = m.Reg16("bx", 3);
var es_bx = m.Frame.EnsureSequence(es.Storage, bx.Storage, PrimitiveType.Word32);
m.Assign(es_bx, m.SegMem(PrimitiveType.Word32, es, bx));
m.Assign(es, m.Slice(PrimitiveType.Word16, es_bx, 16));
m.Assign(bx, m.Cast(PrimitiveType.Word16, es_bx));
m.SegStore(es, m.IAdd(bx, 4), m.Byte(3));
var ssa = RunTest(m);
var sExp =
#region Expected
@"es:es
def: def es
uses: es_bx_3 = Mem0[es:bx:word32]
bx:bx
def: def bx
uses: es_bx_3 = Mem0[es:bx:word32]
Mem0:Global memory
def: def Mem0
uses: es_bx_3 = Mem0[es:bx:word32]
es_bx_3: orig: es_bx
def: es_bx_3 = Mem0[es:bx:word32]
uses: es_4 = SLICE(es_bx_3, word16, 16)
bx_5 = (word16) es_bx_3
Mem0[es_bx_3 + 0x0004:byte] = 0x03
es_4: orig: es
def: es_4 = SLICE(es_bx_3, word16, 16)
bx_5: orig: bx
def: bx_5 = (word16) es_bx_3
Mem6: orig: Mem0
def: Mem0[es_bx_3 + 0x0004:byte] = 0x03
// ProcedureBuilder
// Return size: 0
void ProcedureBuilder()
ProcedureBuilder_entry:
def es
def bx
def Mem0
// succ: l1
l1:
es_bx_3 = Mem0[es:bx:word32]
es_4 = SLICE(es_bx_3, word16, 16)
bx_5 = (word16) es_bx_3
Mem0[es_bx_3 + 0x0004:byte] = 0x03
ProcedureBuilder_exit:
";
#endregion
AssertStringsEqual(sExp, ssa);
}