public static void ByReference__ctor(Context context, MethodCompiler methodCompiler) { var instance = methodCompiler.Parameters[0]; var value = methodCompiler.Parameters[1]; var opInstance = methodCompiler.AllocateVirtualRegisterOrStackSlot(instance.Type); var opValue = methodCompiler.AllocateVirtualRegisterOrStackSlot(value.Type); // Load instance parameter var loadInstance = BaseMethodCompilerStage.GetLoadParameterInstruction(instance.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadInstance, opInstance, instance); // Load value parameter var loadValue = BaseMethodCompilerStage.GetLoadParameterInstruction(value.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadValue, opValue, value); // Store value inside instance var store = methodCompiler.Is32BitPlatform ? (BaseInstruction)IRInstruction.Store32 : IRInstruction.Store64; context.AppendInstruction(store, null, opInstance, methodCompiler.ConstantZero, opValue); context.MosaType = methodCompiler.TypeSystem.BuiltIn.I; context.AppendInstruction(IRInstruction.Jmp, methodCompiler.BasicBlocks.EpilogueBlock); }
public static void Unsafe_AreSame(Context context, MethodCompiler methodCompiler) { var left = methodCompiler.Parameters[0]; var right = methodCompiler.Parameters[1]; var opLeft = methodCompiler.AllocateVirtualRegisterOrStackSlot(left.Type); var opRight = methodCompiler.AllocateVirtualRegisterOrStackSlot(right.Type); var opReturn = methodCompiler.AllocateVirtualRegisterOrStackSlot(methodCompiler.Method.Signature.ReturnType); // Load left parameter var loadLeft = BaseMethodCompilerStage.GetLoadParameterInstruction(left.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadLeft, opLeft, left); // Load right parameter var loadRight = BaseMethodCompilerStage.GetLoadParameterInstruction(right.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadRight, opRight, right); // Compare and store into result operand context.AppendInstruction(IRInstruction.CompareObject, ConditionCode.Equal, opReturn, opLeft, opRight); // Set return var setReturn = BaseMethodCompilerStage.GetSetReturnInstruction(opReturn.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(setReturn, null, opReturn); context.AppendInstruction(IRInstruction.Jmp, methodCompiler.BasicBlocks.EpilogueBlock); }
public static void Unsafe_AddByteOffset(Context context, MethodCompiler methodCompiler) { var source = methodCompiler.Parameters[0]; var byteOffset = methodCompiler.Parameters[1]; var opSource = methodCompiler.AllocateVirtualRegisterOrStackSlot(source.Type); var opByteOffset = methodCompiler.AllocateVirtualRegisterOrStackSlot(byteOffset.Type); var opReturn = methodCompiler.AllocateVirtualRegisterOrStackSlot(methodCompiler.Method.Signature.ReturnType); // Load left parameter var loadSource = BaseMethodCompilerStage.GetLoadParameterInstruction(source.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadSource, opSource, source); // Load right parameter var loadByteOffset = BaseMethodCompilerStage.GetLoadParameterInstruction(byteOffset.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadByteOffset, opByteOffset, byteOffset); // Compare and store into result operand var add = methodCompiler.Is32BitPlatform ? (BaseInstruction)IRInstruction.Add32 : IRInstruction.Add64; context.AppendInstruction(add, opReturn, opSource, opByteOffset); // Return comparison result var setReturn = BaseMethodCompilerStage.GetSetReturnInstruction(opReturn.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(setReturn, null, opReturn); context.AppendInstruction(IRInstruction.Jmp, methodCompiler.BasicBlocks.EpilogueBlock); }
public static void Unsafe_As(Context context, MethodCompiler methodCompiler) { var source = methodCompiler.Parameters[0]; var opReturn = methodCompiler.AllocateVirtualRegisterOrStackSlot(methodCompiler.Method.Signature.ReturnType); // Load source into return operand var loadSource = BaseMethodCompilerStage.GetLoadParameterInstruction(source.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadSource, opReturn, source); // Set return var setReturn = BaseMethodCompilerStage.GetSetReturnInstruction(opReturn.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(setReturn, null, opReturn); context.AppendInstruction(IRInstruction.Jmp, methodCompiler.BasicBlocks.EpilogueBlock); }
public static void ByReference_get_Value(Context context, MethodCompiler methodCompiler) { var instance = methodCompiler.Parameters[0]; var opInstance = methodCompiler.AllocateVirtualRegisterOrStackSlot(instance.Type); var opReturn = methodCompiler.AllocateVirtualRegisterOrStackSlot(methodCompiler.Method.Signature.ReturnType); // Load instance parameter var loadInstance = BaseMethodCompilerStage.GetLoadParameterInstruction(instance.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(loadInstance, opInstance, instance); // Load value from instance into return operand var loadValue = methodCompiler.Is32BitPlatform ? (BaseInstruction)IRInstruction.Load32 : IRInstruction.Load64; context.AppendInstruction(loadValue, opReturn, opInstance, methodCompiler.ConstantZero); context.MosaType = methodCompiler.TypeSystem.BuiltIn.I; // Set return var setReturn = BaseMethodCompilerStage.GetSetReturnInstruction(opReturn.Type, methodCompiler.Is32BitPlatform); context.AppendInstruction(setReturn, null, opReturn); context.AppendInstruction(IRInstruction.Jmp, methodCompiler.BasicBlocks.EpilogueBlock); }