当前位置: 首页>>代码示例>>C#>>正文


C# Operands.RegisterOperand类代码示例

本文整理汇总了C#中Mosa.Compiler.Framework.Operands.RegisterOperand的典型用法代码示例。如果您正苦于以下问题:C# RegisterOperand类的具体用法?C# RegisterOperand怎么用?C# RegisterOperand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RegisterOperand类属于Mosa.Compiler.Framework.Operands命名空间,在下文中一共展示了RegisterOperand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignRegisters

        /// <summary>
        /// Assigns the registers.
        /// </summary>
        private void AssignRegisters()
        {
            List<LiveRange> active = new List<LiveRange>();
            _registers = FillRegisterList();

            for (int i = 0; i < _liveRanges.Count; i++)
            {
                LiveRange lr = _liveRanges[i];
                ExpireOldRanges(lr.Start, active);

                Register reg = AllocateRegister(lr.Op);
                if (reg == null)
                    reg = SpillRegister(active, lr);

                Debug.Assert(reg != null, @"Failed to allocate a register type.");
                RegisterOperand rop = new RegisterOperand(lr.Op.Type, reg);
                ReplaceOperand(lr, rop); ;
                lr.Reg = reg;

                int insIdx = active.FindIndex(delegate(LiveRange match)
                {
                    return ((lr.End - match.End) > 0);
                });

                active.Insert(insIdx + 1, lr);
            }
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:30,代码来源:LinearRegisterAllocator.cs

示例2: RegisterOperand

        /// <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)
        {
            // Retrieve register context
            //context.SetInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX), new MemoryOperand(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), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(28)));
            //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBX), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(4)));
            //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDI), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(20)));
            //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESI), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(16)));
            //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(32)));
            //context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP), new MemoryOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(24)));

            //uint ebp, uint esp, int eip

            RegisterOperand edx = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDX);
            RegisterOperand ebp = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP);
            RegisterOperand esp = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP);

            // Restore registers
            context.AppendInstruction(X86.Mov, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), context.Operand1);

            // Jmp to EIP (stored in EDX)
            context.AppendInstruction(X86.Jmp, null, edx);
            //context.SetOperand(0, edx);
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:31,代码来源:RestoreContext.cs

示例3: CreateExceptionVector

        /// <summary>
        /// Creates the ISR methods.
        /// </summary>
        private void CreateExceptionVector()
        {
            RuntimeType runtimeType = typeSystem.GetType(@"Mosa.Kernel.x86.IDT");

            if (runtimeType == null)
                return;

            RuntimeMethod runtimeMethod = runtimeType.FindMethod(@"ExceptionHandler");

            if (runtimeMethod == null)
                return;

            SymbolOperand exceptionMethod = SymbolOperand.FromMethod(runtimeMethod);

            RegisterOperand esp = new RegisterOperand(BuiltInSigType.Int32, GeneralPurposeRegister.ESP);

            InstructionSet instructionSet = new InstructionSet(100);
            Context ctx = new Context(instructionSet);

            // TODO - setup stack for call to the managed exception handler

            //1.
            //2.

            //3. Call the managed exception handler
            ctx.AppendInstruction(Instruction.CallInstruction, null, exceptionMethod);

            LinkTimeCodeGenerator.Compile(this.compiler, @"ExceptionVector", instructionSet, typeSystem);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:32,代码来源:ExceptionVectorStage.cs

示例4: RegisterOperand

        /// <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));
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:30,代码来源:InvokeDelegateWithReturn.cs

示例5: CreateInterruptVectors

        /// <summary>
        /// Creates the interrupt service routine (ISR) methods.
        /// </summary>
        private void CreateInterruptVectors()
        {
            RuntimeType runtimeType = typeSystem.GetType(@"Mosa.Kernel.x86.IDT");

            if (runtimeType == null)
                return;

            RuntimeMethod runtimeMethod = runtimeType.FindMethod(@"ProcessInterrupt");

            if (runtimeMethod == null)
                return;

            SymbolOperand interruptMethod = SymbolOperand.FromMethod(runtimeMethod);

            RegisterOperand esp = new RegisterOperand(BuiltInSigType.Int32, GeneralPurposeRegister.ESP);

            for (int i = 0; i <= 255; i++)
            {
                InstructionSet instructionSet = new InstructionSet(100);
                Context ctx = new Context(instructionSet);

                ctx.AppendInstruction(X86.Cli);
                if (i <= 7 || i >= 16 | i == 9) // For IRQ 8, 10, 11, 12, 13, 14 the cpu will automatically pushed the error code
                    ctx.AppendInstruction(X86.Push, null, new ConstantOperand(BuiltInSigType.SByte, 0x0));
                ctx.AppendInstruction(X86.Push, null, new ConstantOperand(BuiltInSigType.SByte, (byte)i));
                ctx.AppendInstruction(X86.Pushad);
                ctx.AppendInstruction(X86.Call, null, interruptMethod);
                ctx.AppendInstruction(X86.Popad);
                ctx.AppendInstruction(X86.Add, esp, new ConstantOperand(BuiltInSigType.Int32, 0x08));
                ctx.AppendInstruction(X86.Sti);
                ctx.AppendInstruction(X86.IRetd);

                LinkTimeCodeGenerator.Compile(this.compiler, @"InterruptISR" + i.ToString(), instructionSet, typeSystem);
            }
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:38,代码来源:InterruptVectorStage.cs

示例6: ThreeTwoAddressConversion

        /// <summary>
        /// Converts the given instruction from three address format to a two address format.
        /// </summary>
        /// <param name="ctx">The conversion context.</param>
        private static void ThreeTwoAddressConversion(Context ctx)
        {
            if (!(ctx.Instruction is BaseIRInstruction))
                return;

            if (ctx.Instruction is IntegerCompare
                || ctx.Instruction is FloatCompare
                || ctx.Instruction is Load
                || ctx.Instruction is Store
                || ctx.Instruction is Call
                || ctx.Instruction is ZeroExtendedMove
                || ctx.Instruction is SignExtendedMove)
                return;

            Operand result = ctx.Result;
            Operand op1 = ctx.Operand1;
            Operand op2 = ctx.Operand2;

            // Create registers for different data types
            RegisterOperand eax = new RegisterOperand(op1.Type, op1.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);
            RegisterOperand storeOperand = new RegisterOperand(result.Type, result.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);

            ctx.Result = storeOperand;
            ctx.Operand1 = op2;
            ctx.Operand2 = null;
            ctx.OperandCount = 1;

            if (op1.StackType != StackTypeCode.F)
            {
                if (IsSigned(op1) && !(op1 is ConstantOperand))
                    ctx.InsertBefore().SetInstruction(IRInstruction.SignExtendedMove, eax, op1);
                else if (IsUnsigned(op1) && !(op1 is ConstantOperand))
                    ctx.InsertBefore().SetInstruction(IRInstruction.ZeroExtendedMove, eax, op1);
                else
                    ctx.InsertBefore().SetInstruction(X86.Mov, eax, op1);
            }
            else
            {
                if (op1.Type.Type == CilElementType.R4)
                {
                    if (op1 is ConstantOperand)
                    {
                        Context before = ctx.InsertBefore();
                        before.SetInstruction(X86.Mov, eax, op1);
                        before.AppendInstruction(X86.Cvtss2sd, eax, eax);
                    }
                    else
                    {
                        ctx.InsertBefore().SetInstruction(X86.Cvtss2sd, eax, op1);
                    }
                }
                else
                {
                    ctx.InsertBefore().SetInstruction(X86.Mov, eax, op1);
                }
            }

            ctx.AppendInstruction(X86.Mov, result, eax);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:63,代码来源:AddressModeConversionStage.cs

示例7: RegisterOperand

        /// <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);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:14,代码来源:GetControlRegisterBase.cs

示例8: RegisterOperand

        /// <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 operand1 = context.Operand1;

            RegisterOperand eax = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX);
            RegisterOperand cr = new RegisterOperand(BuiltInSigType.UInt32, control);

            context.SetInstruction(IR.IRInstruction.Move, eax, operand1);
            context.AppendInstruction(IR.IRInstruction.Move, cr, eax);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:15,代码来源:SetControlRegisterBase.cs

示例9: RegisterOperand

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IR.IIRVisitor.AddressOfInstruction(Context context)
        {
            var opRes = context.Result;

            RegisterOperand register = new RegisterOperand(opRes.Type, GeneralPurposeRegister.EAX);
            context.Result = register;
            context.ReplaceInstructionOnly(Instruction.LeaInstruction);
            //context.Ignore = true;
            context.AppendInstruction(Instruction.MovInstruction, opRes, register);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:14,代码来源:IRTransformationStage.cs

示例10: RegisterOperand

        /// <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);
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:15,代码来源:Get.cs

示例11: RegisterOperand

        /// <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(Instruction.SubInstruction, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4 + 4));
            //context.AppendInstruction(Instruction.MovInstruction, edx, esp);

            //var size = parameters.Count * 4 + 4;
            //foreach (var parameter in parameters)
            //{
            //    context.AppendInstruction(Instruction.MovInstruction, new MemoryOperand(BuiltInSigType.IntPtr, edx.Register, new IntPtr(size - 4)), new MemoryOperand(BuiltInSigType.IntPtr, ebp.Register, new IntPtr(size + 4)));
            //    size -= 4;
            //}
            //context.AppendInstruction(Instruction.MovInstruction, new MemoryOperand(BuiltInSigType.IntPtr, edx.Register, new IntPtr(size - 4)), op1);

            //context.AppendInstruction(Instruction.MovInstruction, eax, op2);
            //context.AppendInstruction(Instruction.CallPointerInstruction, null, new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX));
            //context.AppendInstruction(Instruction.AddInstruction, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4 + 4));
            //context.AppendInstruction(Instruction.MovInstruction, result, new RegisterOperand(result.Type, GeneralPurposeRegister.EAX));

            var result = context.Result;
            var op1 = context.Operand1;
            var op2 = context.Operand2;

            var r8 = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R8);
            var r9 = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R9);
            var sp = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.SP);
            var r11 = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R11);
            var r10 = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.R10);
            context.SetInstruction(Instruction.SubInstruction, sp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4 + 4));
            context.AppendInstruction(Instruction.MovInstruction, r9, sp);

            var size = parameters.Count * 4 + 4;
            foreach (var parameter in parameters)
            {
                context.AppendInstruction(Instruction.LdInstruction, r10, new MemoryOperand(BuiltInSigType.IntPtr, r11.Register, new IntPtr(size + 4)));
                context.AppendInstruction(Instruction.StInstruction, new MemoryOperand(BuiltInSigType.IntPtr, r9.Register, new IntPtr(size - 4)), r10);
                size -= 4;
            }
            context.AppendInstruction(Instruction.LdInstruction, r10, op1);
            context.AppendInstruction(Instruction.StInstruction, new MemoryOperand(BuiltInSigType.IntPtr, r9.Register, new IntPtr(size - 4)), r10);

            context.AppendInstruction(Instruction.MovInstruction, r8, op2);
            context.AppendInstruction(Instruction.IcallInstruction, null, new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R8));
            context.AppendInstruction(Instruction.MovInstruction, r10, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4));
            context.AppendInstruction(Instruction.AddInstruction, sp, r10);
            context.AppendInstruction(Instruction.StInstruction, result, new RegisterOperand(result.Type, GeneralPurposeRegister.R8));
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:59,代码来源:InvokeInstanceDelegateWithReturn.cs

示例12: RegisterOperand

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.AddressOf(Context context)
        {
            var opRes = context.Result;

            RegisterOperand register = new RegisterOperand(opRes.Type, GeneralPurposeRegister.EAX);
            //VirtualRegisterOperand register = methodCompiler.VirtualRegisterLayout.AllocateVirtualRegister(opRes.Type);

            context.Result = register;
            context.ReplaceInstructionOnly(X86.Lea);
            context.AppendInstruction(X86.Mov, opRes, register);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:15,代码来源:IRTransformationStage.cs

示例13: Emit

 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="emitter">The emitter.</param>
 protected override void Emit(Context context, MachineCodeEmitter emitter)
 {
     if (context.Result is RegisterOperand)
     {
         RegisterOperand sp = new RegisterOperand(BuiltInSigType.Int32, GeneralPurposeRegister.SP);
         RegisterOperand register = context.Operand1 as RegisterOperand;
         emitter.EmitTwoRegisterInstructions((byte)0x0D, (byte)sp.Register.RegisterCode, (byte)register.Register.RegisterCode); // st.w --Rp, Rs
     }
     else
         throw new Exception("Not supported combination of operands");
 }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:16,代码来源:PushInstruction.cs

示例14: RegisterOperand

        /// <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)
        {
            SigType I4 = BuiltInSigType.Int32;
            RegisterOperand esp = new RegisterOperand(I4, GeneralPurposeRegister.ESP);

            context.SetInstruction(X86.Mov, esp, context.Operand1);
            context.AppendInstruction(X86.Popad);
            context.AppendInstruction(X86.Add, esp, new ConstantOperand(I4, 0x08));
            context.AppendInstruction(X86.Sti);
            context.AppendInstruction(X86.IRetd);
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:16,代码来源:SwitchTask.cs

示例15: RegisterOperand

        /// <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;
            Operand operand1 = context.Operand1;

            RegisterOperand edx = new RegisterOperand(operand1.Type, GeneralPurposeRegister.EDX);
            RegisterOperand eax = new RegisterOperand(result.Type, GeneralPurposeRegister.EAX);

            context.SetInstruction(X86.Mov, edx, operand1);
            context.AppendInstruction(X86.In, eax, edx);
            context.AppendInstruction(X86.Mov, result, eax);
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:17,代码来源:In.cs


注:本文中的Mosa.Compiler.Framework.Operands.RegisterOperand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。