本文整理汇总了C#中Reko.Core.Machine.MachineOperand.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# MachineOperand.GetType方法的具体用法?C# MachineOperand.GetType怎么用?C# MachineOperand.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reko.Core.Machine.MachineOperand
的用法示例。
在下文中一共展示了MachineOperand.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareOperands
private int CompareOperands(MachineOperand opA, MachineOperand opB)
{
if (!opA.GetType().IsAssignableFrom(opB.GetType()))
return -1;
RegisterOperand regOpA = opA as RegisterOperand;
if (regOpA != null)
{
RegisterOperand regOpB = (RegisterOperand) opB;
return (int) regOpB.Register.Number - (int) regOpA.Register.Number;
}
ImmediateOperand immOpA = opA as ImmediateOperand;
if (immOpA != null)
{
ImmediateOperand immOpB = (ImmediateOperand) opB;
return 0; // disregard immediate values.
}
throw new NotImplementedException("NYI");
}
示例2: GetEffectiveAddress
public Expression GetEffectiveAddress(MachineOperand op)
{
var mem = op as MemoryOperand;
if (mem != null)
{
if (mem.Base == null)
{
return mem.Offset;
}
else if (mem.Base == Registers.pc)
{
return di.Address + mem.Offset.ToInt32();
}
else if (mem.Offset == null)
{
return frame.EnsureRegister(mem.Base);
}
else {
return emitter.IAdd(
frame.EnsureRegister(mem.Base),
Constant.Int32(mem.Offset.ToInt32()));
}
}
var addrOp = di.op1 as AddressOperand;
if (addrOp != null)
{
return addrOp.Address;
}
var indIdx = di.op1 as IndirectIndexedOperand;
if (indIdx != null)
{
var a = frame.EnsureRegister(indIdx.ARegister);
var x = frame.EnsureRegister(indIdx.XRegister);
return emitter.IAdd(a, x); //$REVIEW: woefully incomplete...
}
throw new NotImplementedException(string.Format("{0} ({1})", op, op.GetType().Name));
}
示例3: CompareOperands
public bool CompareOperands(MachineOperand opA, MachineOperand opB)
{
if (opA.GetType() != opB.GetType())
return false;
RegisterOperand regOpA = opA as RegisterOperand;
if (regOpA != null)
{
RegisterOperand regOpB = (RegisterOperand) opB;
return NormalizeRegisters || regOpA.Register == regOpB.Register;
}
ImmediateOperand immOpA = opA as ImmediateOperand;
if (immOpA != null)
{
var immOpB = (ImmediateOperand) opB;
return NormalizeConstants || immOpA.Value.Equals(immOpB.Value); // disregard immediate values.
}
var addrOpA = opA as AddressOperand;
if (addrOpA != null)
{
var addrOpB = (AddressOperand)opB;
return NormalizeConstants || addrOpA.Address == addrOpB.Address;
}
var memOpA = opA as MemoryOperand;
if (memOpA != null)
{
var memOpB = (MemoryOperand)opB;
if (!base.CompareRegisters(memOpA.Base, memOpB.Base))
return false;
if (!base.CompareRegisters(memOpA.Index, memOpB.Index))
return false;
if (memOpA.Scale != memOpB.Scale)
return false;
return base.CompareValues(memOpA.Offset, memOpB.Offset);
}
throw new NotImplementedException("NYI");
}
示例4: RewriteSrc
/// <summary>
/// Rewrite operands being used as sources.
/// </summary>
/// <param name="operand"></param>
/// <param name="addrInstr">Address of the current instruction</param>
/// <returns></returns>
public Expression RewriteSrc(MachineOperand operand, Address addrInstr, bool addressAsAddress = false)
{
var reg = operand as RegisterOperand;
if (reg != null)
{
Expression r = frame.EnsureRegister(reg.Register);
if (DataWidth != null && DataWidth.Size != reg.Width.Size)
r = m.Cast(DataWidth, r);
return r;
}
var imm = operand as M68kImmediateOperand;
if (imm != null)
{
if (DataWidth != null && DataWidth.BitSize > imm.Width.BitSize)
return Constant.Create(DataWidth, imm.Constant.ToInt64());
else
return Constant.Create(imm.Width, imm.Constant.ToUInt32());
}
var mem = operand as MemoryOperand;
if (mem != null)
{
return RewriteMemoryAccess(mem, DataWidth, addrInstr);
}
var addr = operand as M68kAddressOperand;
if (addr != null)
{
if (addressAsAddress)
return addr.Address;
else
return m.Load(DataWidth, addr.Address);
}
var pre = operand as PredecrementMemoryOperand;
if (pre != null)
{
var ea = frame.EnsureRegister(pre.Register);
m.Assign(ea, m.ISub(ea, DataWidth.Size));
return m.Load(DataWidth, ea);
}
var post = operand as PostIncrementMemoryOperand;
if (post != null)
{
var r = frame.EnsureRegister(post.Register);
var tmp = frame.CreateTemporary(DataWidth);
m.Assign(tmp, m.Load(DataWidth, r));
m.Assign(r, m.IAdd(r, DataWidth.Size));
return tmp;
}
var indidx = operand as IndirectIndexedOperand;
if (indidx != null)
{
Expression ea = frame.EnsureRegister(indidx.ARegister);
if (indidx.Imm8 != 0)
ea = m.IAdd(ea, Constant.Int32(indidx.Imm8));
Expression ix = frame.EnsureRegister(indidx.XRegister);
if (indidx.Scale > 1)
ix = m.IMul(ix, Constant.Int32(indidx.Scale));
return m.Load(DataWidth, m.IAdd(ea, ix));
}
var indop = operand as IndexedOperand;
if (indop!=null)
{
Expression ea = Combine(indop.Base, indop.base_reg);
if (indop.postindex)
{
ea = m.LoadDw(ea);
}
if (indop.index_reg != null)
{
var idx = Combine(null, indop.index_reg);
if (indop.index_scale > 1)
idx = m.IMul(idx, indop.index_scale);
ea = Combine(ea, idx);
}
if (indop.preindex)
{
ea = m.LoadDw(ea);
}
ea = Combine(ea, indop.outer);
return m.Load(DataWidth, ea);
}
throw new NotImplementedException("Unimplemented RewriteSrc for operand type " + operand.GetType().Name);
}
示例5: RewriteMoveDst
public Expression RewriteMoveDst(MachineOperand opDst, Address addrInstr, PrimitiveType dataWidth, Expression src)
{
var reg = opDst as RegisterOperand;
if (reg != null)
{
var r = frame.EnsureRegister(reg.Register);
if (r.DataType.Size > dataWidth.Size)
{
var tmp = frame.CreateTemporary(dataWidth);
m.Assign(r, m.Dpb(r, src, 0, dataWidth.BitSize));
return tmp;
}
else
{
m.Assign(r, src);
return r;
}
}
var mem = opDst as MemoryOperand;
if (mem != null)
{
src = Spill(src, frame.EnsureRegister(mem.Base));
var load = RewriteMemoryAccess(mem, dataWidth,addrInstr);
var tmp = frame.CreateTemporary(dataWidth);
m.Assign(load, src);
return tmp;
}
var post = opDst as PostIncrementMemoryOperand;
if (post != null)
{
var r = frame.EnsureRegister(post.Register);
var rExp = Spill(src, r);
var load = m.Load(dataWidth, r);
m.Assign(load, rExp);
m.Assign(r, m.IAdd(r, dataWidth.Size));
return src;
}
var pre = opDst as PredecrementMemoryOperand;
if (pre != null)
{
var r = frame.EnsureRegister(pre.Register);
m.Assign(r, m.ISub(r, dataWidth.Size));
var rExp = Spill(src, r);
var load = m.Load(dataWidth, rExp);
m.Assign(load, src);
return src;
}
var indidx = opDst as IndirectIndexedOperand;
if (indidx != null)
{
var a = frame.EnsureRegister(indidx.ARegister);
var x = frame.EnsureRegister(indidx.XRegister);
var load = m.Load(dataWidth, m.IAdd(a, x));
m.Assign(load, src);
return src;
}
var mAddr = opDst as M68kAddressOperand;
if (mAddr != null)
{
m.Assign(
m.Load(
dataWidth,
Constant.Word32(mAddr.Address.ToUInt32())),
src);
return src;
}
throw new NotImplementedException("Unimplemented RewriteMoveDst for operand type " + opDst.GetType().Name);
}
示例6: GetHashCode
private int GetHashCode(MachineOperand op)
{
int h;
RegisterOperand regOp = op as RegisterOperand;
if (regOp != null)
{
return base.GetRegisterHash(regOp.Register);
}
ImmediateOperand immOp = op as ImmediateOperand;
if (immOp != null)
{
return base.GetConstantHash(immOp.Value);
}
var addrOp = op as AddressOperand;
if (addrOp != null)
{
return base.NormalizeConstants
? 1
: addrOp.Address.GetHashCode();
}
var memOp = op as MemoryOperand;
if (memOp != null)
{
h = 0;
if (memOp.Base != null)
{
h = base.GetRegisterHash(memOp.Base);
}
if (memOp.Index != null)
{
h = 13 * h ^ base.GetRegisterHash(memOp.Index);
h = 17 * h ^ memOp.Scale;
}
if (memOp.Offset != null)
{
h = 23 * h ^ GetConstantHash(memOp.Offset);
}
if (memOp.SegOverride != null)
{
h = 29 * h ^ GetRegisterHash(memOp.SegOverride);
}
return h;
}
throw new NotImplementedException("Unhandled operand type: " + op.GetType().FullName);
}