public SetInstruction ( |
||
instruction | The instruction. | |
return | void |
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { var result = context.Result; var op1 = context.Operand1; var op2 = context.Operand2; var constant = Operand.CreateConstant(BuiltInSigType.IntPtr, parameters.Count * 4); var eax = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX); // FIXME - need access to virtual register allocator var edx = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EDX); // FIXME - need access to virtual register allocator var esp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.ESP); // FIXME - need access to virtual register allocator var ebp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EBP); // FIXME - need access to virtual register allocator context.SetInstruction(X86.Sub, esp, constant); context.AppendInstruction(X86.Mov, edx, esp); var size = parameters.Count * 4 + 4; foreach (var parameter in parameters) { context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, ebp, new IntPtr(size + 4))); size -= 4; } context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), op1); context.AppendInstruction(X86.Mov, eax, op2); context.AppendInstruction(X86.Call, null, eax); context.AppendInstruction(X86.Add, esp, constant); context.AppendInstruction(X86.Mov, result, Operand.CreateCPURegister(result.Type, GeneralPurposeRegister.EAX)); // FIXME - need access to virtual register allocator }
/// <summary> /// Visitation function for <see cref="IX86Visitor.Mov"/> instructions. /// </summary> /// <param name="context">The context.</param> public void Mov(Context context) { if (context.Result.IsCPURegister && context.Operand1.IsMemoryAddress) { context.SetInstruction(X86.MovLoad, //context.Size, context.Result, (context.Operand1.IsLabel || context.Operand1.IsSymbol || context.Operand1.IsField) ? context.Operand1 : Operand.CreateCPURegister(context.Operand1.Type, context.Operand1.EffectiveOffsetBase), Operand.CreateConstant(MethodCompiler.TypeSystem, (int)context.Operand1.Displacement) ); } if (context.Result.IsMemoryAddress && (context.Operand1.IsCPURegister /*|| context.Operand1.IsConstant*/)) { context.SetInstruction(X86.MovStore, //InstructionSize.Size32, null, (context.Result.IsLabel || context.Result.IsSymbol || context.Result.IsField) ? context.Result : Operand.CreateCPURegister(context.Result.Type, context.Result.EffectiveOffsetBase), Operand.CreateConstant(MethodCompiler.TypeSystem, (int)context.Result.Displacement), context.Operand1 ); } }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { var result = context.Result; var dividend = context.Operand1; var divisor = context.Operand2; if (result.IsR8) { var xmm1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8); var xmm2 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8); var xmm3 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8); var size = InstructionSize.Size64; context.SetInstruction(X86.Divsd, size, xmm1, dividend, divisor); context.AppendInstruction(X86.Roundsd, size, xmm2, xmm1, Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.U1, 0x3)); context.AppendInstruction(X86.Mulsd, size, xmm3, divisor, xmm2); context.AppendInstruction(X86.Subsd, size, result, dividend, xmm3); } else { var xmm1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4); var xmm2 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4); var xmm3 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4); var size = InstructionSize.Size32; context.SetInstruction(X86.Divss, size, xmm1, dividend, divisor); context.AppendInstruction(X86.Roundss, size, xmm2, xmm1, Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.U1, 0x3)); context.AppendInstruction(X86.Mulss, size, xmm3, divisor, xmm2); context.AppendInstruction(X86.Subss, size, result, dividend, xmm3); } }
/// <summary> /// Emits the constant operands. /// </summary> /// <param name="node">The node.</param> protected void EmitFloatingPointConstants(InstructionNode node) { for (int i = 0; i < node.OperandCount; i++) { var operand = node.GetOperand(i); if (operand == null || !operand.IsConstant || !operand.IsR) continue; if (operand.IsUnresolvedConstant) continue; var v1 = AllocateVirtualRegister(operand.Type); var symbol = (operand.IsR4) ? MethodCompiler.Linker.GetConstantSymbol(operand.ConstantSingleFloatingPoint) : MethodCompiler.Linker.GetConstantSymbol(operand.ConstantDoubleFloatingPoint); var s1 = Operand.CreateLabel(operand.Type, symbol.Name); var before = new Context(node).InsertBefore(); if (operand.IsR4) { before.SetInstruction(X86.MovssLoad, InstructionSize.Size32, v1, s1, ConstantZero); } else { before.SetInstruction(X86.MovsdLoad, InstructionSize.Size64, v1, s1, ConstantZero); } node.SetOperand(i, v1); } }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand v0 = context.Operand1; Operand v1 = context.Operand2; Operand v2 = context.Operand3; Operand v3 = context.GetOperand(3); Operand esp = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP); Operand ebp = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP); Operand eax = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); Operand ebx = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX); Operand ecx = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ECX); Operand exceptionRegister = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.Object, methodCompiler.Architecture.ExceptionRegister); // Move all virtual registers into physical registers - necessary since stack frame pointer will change context.SetInstruction(X86.Mov, eax, v0); context.AppendInstruction(X86.Mov, ebx, v1); context.AppendInstruction(X86.Mov, ecx, v2); context.AppendInstruction(X86.Mov, exceptionRegister, v3); // Update the frame and stack registers context.AppendInstruction(X86.Mov, ebp, ecx); context.AppendInstruction(X86.Mov, esp, ebx); context.AppendInstruction(X86.Jmp, null, eax); // future - common code (refactor opportunity) context.GotoNext(); // Remove all remaining instructions in block and clear next block list while (!context.IsBlockEndInstruction) { if (!context.IsEmpty) { context.SetInstruction(X86.Nop); } context.GotoNext(); } var nextBlocks = context.Block.NextBlocks; foreach (var next in nextBlocks) { next.PreviousBlocks.Remove(context.Block); } nextBlocks.Clear(); }
/// <summary> /// Adds the epilogue instructions. /// </summary> /// <param name="context">The context.</param> private void AddEpilogueInstructions(Context context) { Operand ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP); Operand esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP); Operand edx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX); Operand edi = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDI); Operand ecx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ECX); Operand ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX); context.SetInstruction(X86.Nop); if (SaveRegisters) { context.AppendInstruction(X86.Pop, ebx); context.AppendInstruction(X86.Pop, ecx); context.AppendInstruction(X86.Pop, edi); // Save EDX for int32 return values (or do not save EDX for non-int64 return values) if (!MethodCompiler.Method.Signature.ReturnType.IsUI8) { context.AppendInstruction(X86.Pop, edx); } } if (MethodCompiler.StackLayout.StackSize != 0) { context.AppendInstruction(X86.Add, esp, esp, Operand.CreateConstantSignedInt(TypeSystem, -MethodCompiler.StackLayout.StackSize)); } context.AppendInstruction(X86.Pop, ebp); context.AppendInstruction(X86.Ret); }
/// <summary> /// Folds the mul S instruction. /// </summary> /// <param name="context">The context.</param> private void FoldMulSInstruction(Context context) { var cA = this.LoadSignedInteger(context.Operand1); var cB = this.LoadSignedInteger(context.Operand2); context.SetInstruction(Instruction.MoveInstruction, context.Result, new ConstantOperand(context.Result.Type, cA * cB)); }
/// <summary> /// Visitation function for <see cref="IX86Visitor.Div"/> instructions. /// </summary> /// <param name="context">The context.</param> public void Div(Context context) { if (context.Result.IsCPURegister && context.Result2.IsCPURegister && context.Operand1.IsCPURegister) if (context.Result.Register == GeneralPurposeRegister.EDX && context.Result2.Register == GeneralPurposeRegister.EAX && context.Operand1.Register == GeneralPurposeRegister.EDX && context.Operand2.Register == GeneralPurposeRegister.EAX) return; Operand operand1 = context.Operand1; Operand operand2 = context.Operand2; Operand operand3 = context.Operand3; Operand result = context.Result; Operand result2 = context.Result2; Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX); Operand EDX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX); context.SetInstruction(X86.Mov, EDX, operand1); context.AppendInstruction(X86.Mov, EAX, operand2); if (operand3.IsCPURegister) { context.AppendInstruction2(X86.Div, EDX, EAX, EDX, EAX, operand3); } else { Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4); context.AppendInstruction(X86.Mov, v3, operand3); context.AppendInstruction2(X86.Div, EDX, EAX, EDX, EAX, v3); } context.AppendInstruction(X86.Mov, result2, EAX); context.AppendInstruction(X86.Mov, result, EDX); }
private void HandleSplitAnd(Context context) { Operand r8 = Operand.CreateCPURegister(context.Operand1.Type, GeneralPurposeRegister.R8); context.SetInstruction(AVR32.Mov, r8, context.Operand1); context.AppendInstruction(AVR32.And, context.Result, r8); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { var zero = Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.I4, 0); var MultibootEAX = Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, Multiboot0695Stage.MultibootEAX); context.SetInstruction(IRInstruction.Load2, context.Result, MultibootEAX, zero); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { var result = context.Result; //var op1 = context.Operand1; var op2 = context.Operand2; var eax = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX); var edx = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EDX); var esp = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.ESP); var ebp = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EBP); context.SetInstruction(X86.Sub, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4)); context.AppendInstruction(X86.Mov, edx, esp); var size = parameters.Count * 4; foreach (var parameter in parameters) { context.AppendInstruction(X86.Mov, new MemoryOperand(BuiltInSigType.IntPtr, edx.Register, new IntPtr(size - 4)), new MemoryOperand(BuiltInSigType.IntPtr, ebp.Register, new IntPtr(size + 8))); size -= 4; } context.AppendInstruction(X86.Mov, eax, op2); context.AppendInstruction(X86.Call, null, new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX)); context.AppendInstruction(X86.Add, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4)); context.AppendInstruction(X86.Mov,result, new RegisterOperand(result.Type, GeneralPurposeRegister.EAX)); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { var result = context.Result; var address = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.I4); context.SetInstruction(IRInstruction.Move, address, Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, Multiboot0695Stage.MultibootEBX)); context.AppendInstruction(IRInstruction.Move, result, Operand.CreateMemoryAddress(methodCompiler.TypeSystem.BuiltIn.I4, address, 0)); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand methodAddress = context.Operand1; Operand newESP = context.Operand2; context.SetInstruction(X86.Call, null, methodAddress); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { // Retrieve register context //context.SetInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP, new IntPtr(28))); // Restore registers (Note: EAX and EDX are NOT restored!) //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(28))); //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(4))); //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDI), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(20))); //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESI), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(16))); //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(32))); //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(24))); //uint ebp, uint esp, int eip Operand edx = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EDX); Operand ebp = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP); Operand esp = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP); // Restore registers context.SetInstruction(X86.Mov, Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), context.Operand1); // Jmp to EIP (stored in EDX) context.AppendInstruction(X86.Jmp, null, edx); //context.SetOperand(0, edx); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { var operand = context.Operand1; if (!operand.IsConstant) { // try to find the constant - a bit of a hack Context ctx = new Context(operand.Definitions[0]); if (ctx.Instruction == IRInstruction.Move && ctx.Operand1.IsConstant) { operand = ctx.Operand1; } } Debug.Assert(operand.IsConstant); int irq = (int)operand.ConstantSignedLongInteger; // Find the method var method = methodCompiler.TypeSystem.DefaultLinkerType.FindMethodByName("InterruptISR" + irq.ToString()); if (method == null) { throw new InvalidCompilerException(); } context.SetInstruction(IRInstruction.Move, context.Result, Operand.CreateSymbolFromMethod(methodCompiler.TypeSystem, method)); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Debug.Assert(context.Result.IsI4 | context.Result.IsU4); Operand zero = Operand.CreateConstant(methodCompiler.TypeSystem, 0); context.SetInstruction(X86.MovzxLoad, InstructionSize.Size16, context.Result, context.Operand1, zero); }
/// <summary> /// Runs the specified method compiler. /// </summary> void IMethodCompilerStage.Run() { if (methodCompiler.PlugSystem != null) if (methodCompiler.PlugSystem.GetPlugMethod(this.methodCompiler.Method) != null) return; List<StackOperand> locals = CollectLocalVariablesFromIL(); // Iterate and collect locals from all blocks foreach (BasicBlock block in basicBlocks) { CollectLocalVariables(locals, block); } // Sort all found locals OrderVariables(locals, callingConvention); // Now we assign increasing stack offsets to each variable localsSize = LayoutVariables(locals, callingConvention, callingConvention.OffsetOfFirstLocal, 1); // Layout parameters LayoutParameters(methodCompiler); // Create a prologue instruction Context prologueCtx = new Context(instructionSet, FindBlock(-1)).InsertBefore(); prologueCtx.SetInstruction(IR.Instruction.PrologueInstruction); prologueCtx.Label = -1; // Create an epilogue instruction Context epilogueCtx = new Context(instructionSet, FindBlock(Int32.MaxValue)); epilogueCtx.AppendInstruction(IR.Instruction.EpilogueInstruction); epilogueCtx.Label = Int32.MaxValue; }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand result = context.Result; Operand imm = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4); context.SetInstruction(X86.MovCR, imm, Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U4, control)); context.AppendInstruction(X86.Mov, result, imm); }
private void HandleSplitMov(Context context) { Operand opL, opH; SplitFromConstantOperand(context.Operand1, out opL, out opH); context.SetInstruction(AVR32.Mov, context.Result, opL); context.AppendInstruction(AVR32.Orh, context.Result, opH); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { // Create constant operand and pointer to variable containing the lock Operand const0 = Operand.CreateConstantSignedInt(methodCompiler.TypeSystem, 0x0); Operand locked = Operand.CreateMemoryAddress(methodCompiler.TypeSystem.BuiltIn.Pointer, context.Operand1, 0); // Set the variable locked to 0 signifying that the lock is free context.SetInstruction(X86.Mov, locked, const0); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { Operand result = context.Result; RegisterOperand imm = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX); context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(BuiltInSigType.UInt32, control)); context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="methodCompiler">The method compiler.</param> void IIntrinsicInternalMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { var ctor = context.Operand1; var thisObject = context.Operand2; var result = context.Result; context.SetInstruction(IRInstruction.Call, null, ctor, thisObject); context.AppendInstruction(IRInstruction.MoveInteger, result, thisObject); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { Operand result = context.Result; Operand imm = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX); context.SetInstruction(IR.IRInstruction.Move, imm, Operand.CreateCPURegister(BuiltInSigType.UInt32, control)); context.AppendInstruction(IR.IRInstruction.Move, result, imm); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand operand1 = context.Operand1; Operand v1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4); context.SetInstruction(X86.Mov, v1, operand1); context.AppendInstruction(X86.Mov, Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U4, SegmentRegister.FS), v1); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand result = context.Result; Operand edx = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.Pointer); Operand operand = Operand.CreateMemoryAddress(context.Operand1.Type, edx, 0); context.SetInstruction(X86.Mov, edx, context.Operand1); context.AppendInstruction(X86.Mov, result, operand); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand methodAddress = context.Operand1; Operand newESP = context.Operand2; Operand esp = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP); Operand edx = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX); context.SetInstruction(X86.Call, null, methodAddress); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { Operand result = context.Result; RegisterOperand tmp = new RegisterOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EDX); MemoryOperand operand = new MemoryOperand(context.Operand1.Type, GeneralPurposeRegister.EDX, new System.IntPtr(0)); context.SetInstruction(X86.Mov, tmp, context.Operand1); context.AppendInstruction(X86.Mov, result, operand); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { Operand operand1 = context.Operand1; Operand eax = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX); Operand cr = Operand.CreateCPURegister(BuiltInSigType.UInt32, control); context.SetInstruction(IR.IRInstruction.Move, eax, operand1); context.AppendInstruction(IR.IRInstruction.Move, cr, eax); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler) { Operand esp = Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP); context.SetInstruction(X86.Mov, esp, context.Operand1); context.AppendInstruction(X86.Popad); context.AppendInstruction(X86.Add, esp, esp, Operand.CreateConstant(methodCompiler.TypeSystem, 0x08)); context.AppendInstruction(X86.Sti); context.AppendInstruction(X86.IRetd); }
/// <summary> /// Replaces the intrinsic call site /// </summary> /// <param name="context">The context.</param> /// <param name="typeSystem">The type system.</param> void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters) { Operand esp = Operand.CreateCPURegister(BuiltInSigType.Int32, GeneralPurposeRegister.ESP); context.SetInstruction(X86.Mov, esp, context.Operand1); context.AppendInstruction(X86.Popad); context.AppendInstruction(X86.Add, esp, Operand.CreateConstant(BuiltInSigType.Int32, 0x08)); context.AppendInstruction(X86.Sti); context.AppendInstruction(X86.IRetd); }