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


C# Context.SetResult方法代码示例

本文整理汇总了C#中Mosa.Runtime.CompilerFramework.Context.SetResult方法的典型用法代码示例。如果您正苦于以下问题:C# Context.SetResult方法的具体用法?C# Context.SetResult怎么用?C# Context.SetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mosa.Runtime.CompilerFramework.Context的用法示例。


在下文中一共展示了Context.SetResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplaceOperand

        /// <summary>
        /// Replaces the operand.
        /// </summary>
        /// <param name="lr">The lr.</param>
        /// <param name="replacement">The replacement.</param>
        private void ReplaceOperand(LiveRange lr, RegisterOperand replacement)
        {
            int opIdx;

            // Iterate all definition sites first
            foreach (int index in lr.Op.Definitions.ToArray()) {
                Context def = new Context(InstructionSet, index);
                if (def.Offset == lr.Start) {
                    opIdx = 0;
                    foreach (Operand r in def.Results) {
                        // Is this the operand?
                        if (object.ReferenceEquals(r, lr.Op))
                            def.SetResult(opIdx, replacement);

                        opIdx++;
                    }

                    break;
                }
            }

            // Iterate all use sites
            foreach (int index in lr.Op.Uses.ToArray()) {
                Context instr = new Context(InstructionSet, index);

                if (instr.Offset <= lr.Start) {
                    // A use on instr.Offset == lr.Start is one From a previous definition!!
                }
                else if (instr.Offset <= lr.End) {
                    opIdx = 0;
                    foreach (Operand r in instr.Operands) {
                        // Is this the operand?
                        if (object.ReferenceEquals(r, lr.Op))
                            instr.SetOperand(opIdx, replacement);

                        opIdx++;
                    }
                }
                else {
                    break;
                }
            }
        }
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:48,代码来源:LinearRegisterAllocator.cs

示例2: AssignRegisters


//.........这里部分代码省略.........
                 * the arg list. If the register is also a result reg, and they represent the same operand,
                 * we may get away without spilling... Oo?
                 */
                //Register[] used = rc.GetRegistersUsed();

                opIdx = 0;

                Context at = ctx.Clone();

                foreach (Operand op in ctx.Operands) {
                    // Only allocate registers, if we really have to.
                    if (!rc.IsValidOperand(opIdx, op)) {
                        // The register operand allocated
                        RegisterOperand rop;
                        // List of compatible registers
                        Register[] regs = rc.GetRegistersForOperand(opIdx);
                        Debug.Assert(null != regs, @"IRegisterConstraint.GetRegistersForOperand returned null.");
                        Debug.Assert(0 != regs.Length, @"WTF IRegisterConstraint.GetRegistersForOperand returned zero-length array - what shall we pass then if no register/memory?");

                        // Is this operand in a register?
                        rop = GetRegisterOfOperand(op);
                        if (rop != null && Array.IndexOf(regs, rop.Register) == -1) {
                            // Spill the register...
                            SpillRegister(ctx, op, rop);
                            rop = null;
                        }

                        // Attempt to allocate a free register
                        if (rop == null) {
                            rop = AllocateRegister(regs, op);
                            if (rop != null) {
                                // We need to place a load here... :(
                                InsertMove(ctx, rop, op);
                            }
                        }

                        // Still failed to get one? Spill!
                        if (rop == null) {
                            // Darn, need to spill one... Always use the first one.
                            rop = SpillRegister(at, op.Type, regs);

                            // We need to place a load here... :(
                            InsertMove(at, rop, op);
                        }

                        // Assign the register
                        Debug.Assert(rop != null, @"Whoa: Failed to allocate a register operand??");
                        AssignRegister(rop, op, at);
                        ctx.SetOperand(opIdx, rop); // FIXME PG - opIdx? hmmm. is this phidata?
                    }

                    opIdx++;
                }

                opIdx = 0;
                foreach (Operand res in ctx.Results) {
                    // FIXME: Check support first, spill if register is target and in use
                    if (!rc.IsValidResult(opIdx, res)) {
                        // Is this operand in a register?
                        RegisterOperand rop = GetRegisterOfOperand(res);
                        if (rop == null && !rc.IsValidResult(opIdx, res) && res.Uses.Count == 0)
                            // Do not allocate: Not in a register, allows memory & has no uses... oO wtf?
                            continue;

                        // Retrieve compliant registers
                        Register[] regs = rc.GetRegistersForResult(opIdx);

                        // Do we already have a register?
                        if (rop != null && Array.IndexOf(regs, rop.Register) == -1) {
                            // Hmm, current register doesn't match, release it - since we're overwriting the operand,
                            // we don't need to spill. This should be safe.
                            _activeOperands[rop.Register.Index] = null;
                        }

                        // Allocate a register
                        if (rop == null)
                            rop = AllocateRegister(regs, res);

                        // Do we need to spill?
                        if (rop == null) {
                            // Darn, need to spill one...
                            rop = SpillRegister(at, res.Type, regs);
                            // We don't need to place a load here, as we're defining the register...
                        }

                        // Assign the register
                        Debug.Assert(null != rop, @"Whoa: Failed to allocate a register operand??");
                        AssignRegister(rop, res, at);
                        ctx.SetResult(opIdx, rop); // FIXME PG - same
                    }
                    else {
                        RegisterOperand rop = res as RegisterOperand;
                        if (rop != null)
                            SpillRegisterIfInUse(ctx, rop);
                    }

                    opIdx++;
                }
            }
        }
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:101,代码来源:SimpleRegisterAllocator.cs

示例3: ProcessInvokeInstruction

        /// <summary>
        /// Processes a method call instruction.
        /// </summary>
        /// <param name="ctx">The transformation context.</param>
        /// <param name="destinationOperand">The operand, which holds the call destination.</param>
        /// <param name="resultOperand"></param>
        /// <param name="operands"></param>
        private void ProcessInvokeInstruction(Context ctx, Operand destinationOperand, Operand resultOperand, List<Operand> operands)
        {
            ctx.SetInstruction(Instruction.CallInstruction, (byte)(operands.Count + 1), (byte)(resultOperand != null ? 1 : 0));
            ctx.SetResult(resultOperand);

            int operandIndex = 0;
            ctx.SetOperand(operandIndex++, destinationOperand);
            foreach (Operand op in operands)
            {
                ctx.SetOperand(operandIndex++, op);
            }
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:19,代码来源:CILTransformationStage.cs


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