本文整理汇总了C#中BaseMethodCompiler.StoreOnStack方法的典型用法代码示例。如果您正苦于以下问题:C# BaseMethodCompiler.StoreOnStack方法的具体用法?C# BaseMethodCompiler.StoreOnStack怎么用?C# BaseMethodCompiler.StoreOnStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseMethodCompiler
的用法示例。
在下文中一共展示了BaseMethodCompiler.StoreOnStack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Push
/// <summary>
/// Pushes the specified instructions.
/// </summary>
/// <param name="compiler">The compiler.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="context">The context.</param>
/// <param name="operand">The op.</param>
/// <param name="offset">Size of the stack.</param>
/// <param name="size">Size of the parameter.</param>
/// <param name="scratch">The scratch.</param>
private void Push(BaseMethodCompiler compiler, Context context, Operand operand, int offset, int size, Operand scratch)
{
var offsetOperand = Operand.CreateConstant(compiler.TypeSystem, offset);
if (operand.Is64BitInteger)
{
var offset4Operand = Operand.CreateConstant(compiler.TypeSystem, offset + 4);
architecture.InsertStoreInstruction(context, scratch, offsetOperand, operand.Low);
architecture.InsertStoreInstruction(context, scratch, offset4Operand, operand.High);
}
else if (operand.IsR)
{
if (operand.IsR8 && size == 4)
{
Operand op2 = Operand.CreateCPURegister(compiler.TypeSystem.BuiltIn.R4, returnFloatingPointRegister);
architecture.InsertMoveInstruction(context, op2, operand);
architecture.InsertStoreInstruction(context, scratch, offsetOperand, op2);
}
else
{
architecture.InsertStoreInstruction(context, scratch, offsetOperand, operand);
}
}
else if (compiler.StoreOnStack(operand.Type))
{
var offset2 = Operand.CreateConstant(compiler.TypeSystem, offset);
architecture.InsertCompoundMoveInstruction(compiler, context, scratch, offset2, compiler.StackFrame, operand, compiler.TypeLayout.GetTypeSize(operand.Type));
}
else
{
architecture.InsertStoreInstruction(context, scratch, offsetOperand, operand);
}
}
示例2: CleanupReturnValue
/// <summary>
/// Cleanups the return value.
/// </summary>
/// <param name="compiler">The compiler.</param>
/// <param name="typeLayout">The type layouts.</param>
/// <param name="context">The context.</param>
/// <param name="result">The result.</param>
private void CleanupReturnValue(BaseMethodCompiler compiler, Context context, Operand result)
{
if (result == null)
return;
if (result.IsR)
{
Operand returnFP = Operand.CreateCPURegister(result.Type, returnFloatingPointRegister);
context.AppendInstruction(IRInstruction.Gen, returnFP);
architecture.InsertMoveInstruction(context, result, returnFP);
}
else if (result.Is64BitInteger)
{
Operand returnLow = Operand.CreateCPURegister(result.Type, return32BitRegister);
Operand returnHigh = Operand.CreateCPURegister(compiler.TypeSystem.BuiltIn.U4, return64BitRegister);
context.AppendInstruction(IRInstruction.Gen, returnLow);
context.AppendInstruction(IRInstruction.Gen, returnHigh);
architecture.InsertMoveInstruction(context, result.Low, returnLow);
architecture.InsertMoveInstruction(context, result.High, returnHigh);
}
else if (compiler.StoreOnStack(result.Type))
{
Debug.Assert(result.IsStackLocal);
int size = compiler.TypeLayout.GetTypeSize(result.Type);
var stackPointerRegister = Operand.CreateCPURegister(compiler.TypeSystem.BuiltIn.Pointer, architecture.StackPointerRegister);
architecture.InsertCompoundMoveInstruction(compiler, context, result, result, stackPointerRegister, compiler.ConstantZero, size);
}
else
{
Operand returnLow = Operand.CreateCPURegister(result.Type, return32BitRegister);
context.AppendInstruction(IRInstruction.Gen, returnLow);
architecture.InsertMoveInstruction(context, result, returnLow);
}
}
示例3: CalculateReturnSize
private static int CalculateReturnSize(BaseMethodCompiler compiler, Operand result)
{
if (result == null)
return 0;
if (compiler.StoreOnStack(result.Type))
{
return compiler.TypeLayout.GetTypeSize(result.Type);
}
return 0;
}
示例4: SetReturnValue
/// <summary>
/// Requests the calling convention to create an appropriate move instruction to populate the return
/// value of a method.
/// </summary>
/// <param name="compiler">The compiler.</param>
/// <param name="typeLayout">The type layouts.</param>
/// <param name="context">The context.</param>
/// <param name="operand">The operand, that's holding the return value.</param>
public override void SetReturnValue(BaseMethodCompiler compiler, Context context, Operand operand)
{
int size, alignment;
architecture.GetTypeRequirements(compiler.TypeLayout, operand.Type, out size, out alignment);
size = Alignment.AlignUp(size, alignment);
if (operand.IsR4)
{
architecture.InsertMoveInstruction(context, Operand.CreateCPURegister(operand.Type, returnFloatingPointRegister), operand);
}
else if (operand.IsR8)
{
architecture.InsertMoveInstruction(context, Operand.CreateCPURegister(operand.Type, returnFloatingPointRegister), operand);
}
else if (operand.IsLong)
{
MosaType highType = (operand.IsI8) ? compiler.TypeSystem.BuiltIn.I4 : compiler.TypeSystem.BuiltIn.U4;
architecture.InsertMoveInstruction(context, Operand.CreateCPURegister(compiler.TypeSystem.BuiltIn.U4, return32BitRegister), operand.Low);
architecture.InsertMoveInstruction(context, Operand.CreateCPURegister(highType, return64BitRegister), operand.High);
}
else if (size == 4 || size == 2 || size == 1)
{
architecture.InsertMoveInstruction(context, Operand.CreateCPURegister(operand.Type, return32BitRegister), operand);
}
else if (compiler.StoreOnStack(operand.Type))
{
int size2 = compiler.TypeLayout.GetTypeSize(operand.Type);
var OffsetOfFirstParameterOperand = Operand.CreateConstant(compiler.TypeSystem, OffsetOfFirstParameter);
architecture.InsertCompoundMoveInstruction(compiler, context, compiler.StackFrame, OffsetOfFirstParameterOperand, compiler.StackFrame, operand, size2);
}
}
示例5: SetInvokeTarget
/// <summary>
/// Sets the invoke target.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="compiler">The compiler.</param>
/// <param name="method">The method.</param>
private static void SetInvokeTarget(InstructionNode context, BaseMethodCompiler compiler, MosaMethod method)
{
context.InvokeMethod = method;
// Fix the parameter list
int paramCount = method.Signature.Parameters.Count;
if (method.HasThis && !method.HasExplicitThis)
paramCount++;
// Setup operands for parameters and the return value
if (!method.Signature.ReturnType.IsVoid)
{
context.ResultCount = 1;
if (compiler.StoreOnStack(method.Signature.ReturnType))
{
context.Result = AllocateVirtualRegisterOrStackSlot(compiler, method.Signature.ReturnType);
}
else
{
context.Result = compiler.CreateVirtualRegister(method.Signature.ReturnType.GetStackType());
}
}
else
{
context.ResultCount = 0;
}
context.OperandCount = (byte)paramCount;
}