本文整理汇总了C#中Instruction.As方法的典型用法代码示例。如果您正苦于以下问题:C# Instruction.As方法的具体用法?C# Instruction.As怎么用?C# Instruction.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instruction
的用法示例。
在下文中一共展示了Instruction.As方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
/// <summary>
/// Determine whether <paramref name="instr"/> is a match for
/// the pattern that is a constant division
/// </summary>
/// <remarks>
/// The pattern is:
/// <code>
/// hi:lo = r * const
/// hi = slice(hi:lo) (alias)
/// hi = hi >> shift (optional)
/// </code>
/// This transformation must be carried out before value propagation
/// pushes the shift inside other operations.
/// </remarks>
/// <param name="instr"></param>
/// <returns></returns>
public bool Match(Instruction instr)
{
Assignment ass;
SequenceStorage dst;
BinaryExpression bin;
Constant cRight;
// Look for hi:lo = a * C
if (!instr.As(out ass) ||
!ass.Dst.Storage.As(out dst) ||
!ass.Src.As(out bin) ||
!(bin.Operator is IMulOperator) ||
!bin.Right.As(out cRight) ||
ass.Dst.DataType.Size <= bin.Left.DataType.Size)
{
return false;
}
this.idOrig = ass.Dst;
this.idDst = FindAlias(ass.Dst, dst.Head);
if (idDst == null)
return false;
var best = FindBestRational(cRight.ToUInt32());
// There may be a subsequent SAR / SHR to increase
// the divisor.
var idSlice = idDst;
Constant rShift = null;
if (idSlice != null)
{
rShift = FindShiftUse(idSlice);
if (rShift != null)
{
best = best / (1 << rShift.ToInt32());
}
}
this.bestRational = best;
this.dividend = bin.Left;
return true;
}