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


C# RegisterAllocator.SlotIndex类代码示例

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


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

示例1: MoveHint

 public MoveHint(SlotIndex slot, VirtualRegister from, VirtualRegister to, int bonus)
 {
     Slot = slot;
     From = from;
     To = to;
     Bonus = bonus;
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:7,代码来源:MoveHint.cs

示例2: Interval

		public Interval(SlotIndex start, SlotIndex end)
		{
			Debug.Assert(start <= end);

			this.Start = start;
			this.End = end;
		}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:7,代码来源:Interval.cs

示例3: LiveInterval

        private LiveInterval(VirtualRegister virtualRegister, SlotIndex start, SlotIndex end, IList<SlotIndex> uses, IList<SlotIndex> defs)
        {
            LiveRange = new LiveRange(start, end, uses, defs);

            VirtualRegister = virtualRegister;
            SpillValue = 0;
            Stage = AllocationStage.Initial;
            ForceSpilled = false;
            NeverSpill = false;
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:10,代码来源:LiveInterval.cs

示例4: LiveRange

        public LiveRange(SlotIndex start, SlotIndex end, IList<SlotIndex> uses, IList<SlotIndex> defs)
            : base(start, end)
        {
            // live intervals can not start/end at the same location
            Debug.Assert(start != end);

            SlotIndex max = null;
            SlotIndex min = null;

            foreach (var use in uses)
            {
                if (use != Start && (End == use || Contains(use)))
                {
                    usePositions.Add(use, use);

                    if (max == null || use > max)
                        max = use;
                    if (min == null || use < min)
                        min = use;
                }
            }

            foreach (var def in defs)
            {
                if (Contains(def))
                {
                    defPositions.Add(def, def);

                    if (max == null || def > max)
                        max = def;
                    if (min == null || def < min)
                        min = def;
                }
            }

            Minimum = min;
            Maximum = max;

            if (FirstDef == null)
                IsDefFirst = false;
            else if (FirstUse == null)
                IsDefFirst = true;
            else if (FirstDef < FirstUse)
                IsDefFirst = true;
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:45,代码来源:LiveRange.cs

示例5: LiveInterval

        private LiveInterval(VirtualRegister virtualRegister, SlotIndex start, SlotIndex end, IList<SlotIndex> uses, IList<SlotIndex> defs)
            : base(start, end)
        {
            this.VirtualRegister = virtualRegister;
            this.SpillValue = 0;
            this.Stage = AllocationStage.Initial;
            this.ForceSpilled = false;
            this.NeverSpill = false;

            SlotIndex max = null;
            SlotIndex min = null;

            foreach (var use in uses)
            {
                if (Contains(use))
                {
                    usePositions.Add(use, use);

                    if (max == null || use > max)
                        max = use;
                    if (min == null || use < min)
                        min = use;
                }
            }

            foreach (var def in defs)
            {
                if (Contains(def))
                {
                    defPositions.Add(def, def);

                    if (max == null || def > max)
                        max = def;
                    if (min == null || def < min)
                        min = def;
                }
            }

            this.Minimum = min;
            this.Maximum = max;
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:41,代码来源:LiveInterval.cs

示例6: GetLowOptimalSplitLocation

        private SlotIndex GetLowOptimalSplitLocation(LiveInterval liveInterval, SlotIndex from, bool check)
        {
            Debug.Assert(liveInterval.Start != from);

            if (trace.Active) trace.Log("--Low Splitting: " + liveInterval.ToString() + " move: " + from.ToString());

            if (check)
            {
                if (liveInterval.UsePositions.Contains(from) || liveInterval.DefPositions.Contains(from))
                {
                    if (trace.Active) trace.Log("  No optimal. Split move: " + from.ToString());
                    return from;
                }
            }

            SlotIndex blockStart = GetBlockStart(from);
            if (trace.Active) trace.Log("  Block Start : " + blockStart.ToString());

            SlotIndex lowerBound = blockStart > liveInterval.Start ? blockStart : liveInterval.Start.Next;
            if (trace.Active) trace.Log("  Lower Bound : " + lowerBound.ToString());

            SlotIndex previousUse = liveInterval.GetPreviousDefOrUsePosition(from);
            if (trace.Active) trace.Log("  Previous Use: " + (previousUse != null ? previousUse.ToString() : "null"));

            if (previousUse != null && previousUse >= lowerBound)
            {
                if (trace.Active) trace.Log("  Low Optimal : " + previousUse.Next.ToString());
                return previousUse.Next;
            }

            if (trace.Active) trace.Log("  Low Optimal : " + lowerBound.ToString());
            return lowerBound;
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:33,代码来源:GreedyRegisterAllocator.cs

示例7: GetSpillCost

 private int GetSpillCost(SlotIndex use, int factor)
 {
     return (factor * SlotIncrement) * GetLoopDepth(use) * 100;
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:4,代码来源:GreedyRegisterAllocator.cs

示例8: GetMinimum

        private SlotIndex GetMinimum(SlotIndex a, SlotIndex b, SlotIndex c, SlotIndex d)
        {
            var min = a;

            if (min == null || (b != null && b < min))
                min = b;

            if (min == null || (c != null && c < min))
                min = c;

            if (min == null || (d != null && d < min))
                min = d;

            return min;
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:15,代码来源:GreedyRegisterAllocator.cs

示例9: GetLoopDepth

 private int GetLoopDepth(SlotIndex slotIndex)
 {
     return GetContainingBlock(slotIndex).LoopDepth + 1;
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:4,代码来源:GreedyRegisterAllocator.cs

示例10: CreateExpandedLiveRange

        public LiveInterval CreateExpandedLiveRange(SlotIndex start, SlotIndex end)
        {
            var mergedStart = Start < start ? Start : start;
            var mergedEnd = End > end ? End : end;

            return new LiveInterval(VirtualRegister, mergedStart, mergedEnd);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:7,代码来源:LiveInterval.cs

示例11: IsAdjacent

 public bool IsAdjacent(SlotIndex start, SlotIndex end)
 {
     return LiveRange.IsAdjacent(start, end);
 }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:4,代码来源:LiveInterval.cs

示例12: CollectMoveHints

        private void CollectMoveHints()
        {
            foreach (var block in basicBlocks)
            {
                for (Context context = new Context(instructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
                {
                    if (context.IsEmpty || context.IsBlockStartInstruction || context.IsBlockEndInstruction)
                        continue;

                    if (!architecture.IsInstructionMove(context.Instruction))
                        continue;

                    var from = virtualRegisters[GetIndex(context.Operand1)];
                    var to = virtualRegisters[GetIndex(context.Result)];

                    if (from.IsPhysicalRegister && to.IsPhysicalRegister)
                        continue;

                    var slot = new SlotIndex(context);

                    int factor = (from.IsPhysicalRegister || to.IsPhysicalRegister) ? 150 : 125;

                    int bonus = GetLoopDepth(slot);

                    moveHints.Add(slot, new MoveHint(slot, from, to, bonus));
                }
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:28,代码来源:GreedyRegisterAllocator.cs

示例13: GetSpillCost

 private int GetSpillCost(SlotIndex use, int factor)
 {
     return factor * GetLoopDepth(use) * 100;
 }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:4,代码来源:BasicRegisterAllocator.cs

示例14: BuildLiveIntervals

        private void BuildLiveIntervals()
        {
            var intervalTrace = new CompilerTrace(trace, "BuildLiveIntervals");

            for (int b = basicBlocks.Count - 1; b >= 0; b--)
            {
                var block = extendedBlocks[b];

                for (int r = 0; r < registerCount; r++)
                {
                    if (!block.LiveOut.Get(r))
                        continue;

                    var register = virtualRegisters[r];

                    if (b + 1 != basicBlocks.Count && extendedBlocks[b + 1].LiveIn.Get(r))
                    {
                        if (intervalTrace.Active) intervalTrace.Log("Add (LiveOut) " + register.ToString() + " : " + block.Start + " to " + extendedBlocks[b + 1].Start);
                        if (intervalTrace.Active) intervalTrace.Log("   Before: " + LiveIntervalsToString(register.LiveIntervals));
                        register.AddLiveInterval(block.Start, extendedBlocks[b + 1].Start);
                        if (intervalTrace.Active) intervalTrace.Log("    After: " + LiveIntervalsToString(register.LiveIntervals));
                    }
                    else
                    {
                        if (intervalTrace.Active) intervalTrace.Log("Add (!LiveOut) " + register.ToString() + " : " + block.Interval.Start + " to " + block.Interval.End);
                        if (intervalTrace.Active) intervalTrace.Log("   Before: " + LiveIntervalsToString(register.LiveIntervals));
                        register.AddLiveInterval(block.Interval);
                        if (intervalTrace.Active) intervalTrace.Log("    After: " + LiveIntervalsToString(register.LiveIntervals));
                    }
                }

                Context context = new Context(instructionSet, block.BasicBlock, block.BasicBlock.EndIndex);

                while (!context.IsBlockStartInstruction)
                {
                    if (!context.IsEmpty)
                    {
                        SlotIndex slotIndex = new SlotIndex(context);

                        OperandVisitor visitor = new OperandVisitor(context);

                        if (context.Instruction.FlowControl == FlowControl.Call)
                        {
                            SlotIndex nextSlotIndex = slotIndex.Next;

                            for (int s = 0; s < physicalRegisterCount; s++)
                            {
                                var register = virtualRegisters[s];
                                if (intervalTrace.Active) intervalTrace.Log("Add (Call) " + register.ToString() + " : " + slotIndex + " to " + nextSlotIndex);
                                if (intervalTrace.Active) intervalTrace.Log("   Before: " + LiveIntervalsToString(register.LiveIntervals));
                                register.AddLiveInterval(slotIndex, nextSlotIndex);
                                if (intervalTrace.Active) intervalTrace.Log("    After: " + LiveIntervalsToString(register.LiveIntervals));
                            }

                            callSlots.Add(slotIndex);
                        }

                        foreach (var result in visitor.Output)
                        {
                            var register = virtualRegisters[GetIndex(result)];

                            if (register.IsReserved)
                                continue;

                            var first = register.FirstRange;

                            if (!register.IsPhysicalRegister)
                            {
                                register.AddDefPosition(slotIndex);
                            }

                            if (first != null)
                            {
                                if (intervalTrace.Active) intervalTrace.Log("Replace First " + register.ToString() + " : " + slotIndex + " to " + first.End);
                                if (intervalTrace.Active) intervalTrace.Log("   Before: " + LiveIntervalsToString(register.LiveIntervals));
                                register.FirstRange = new LiveInterval(register, slotIndex, first.End);
                                if (intervalTrace.Active) intervalTrace.Log("    After: " + LiveIntervalsToString(register.LiveIntervals));
                            }
                            else
                            {
                                // This is necesary to handled a result that is never used!
                                // Common with instructions which more than one result
                                if (intervalTrace.Active) intervalTrace.Log("Add (Unused) " + register.ToString() + " : " + slotIndex + " to " + slotIndex.Next);
                                if (intervalTrace.Active) intervalTrace.Log("   Before: " + LiveIntervalsToString(register.LiveIntervals));
                                register.AddLiveInterval(slotIndex, slotIndex.Next);
                                if (intervalTrace.Active) intervalTrace.Log("    After: " + LiveIntervalsToString(register.LiveIntervals));
                            }
                        }

                        foreach (var result in visitor.Input)
                        {
                            var register = virtualRegisters[GetIndex(result)];

                            if (register.IsReserved)
                                continue;

                            if (!register.IsPhysicalRegister)
                            {
                                register.AddUsePosition(slotIndex);
                            }
//.........这里部分代码省略.........
开发者ID:tea,项目名称:MOSA-Project,代码行数:101,代码来源:GreedyRegisterAllocator.cs

示例15: SplitIntervalAtCallSite

 protected virtual void SplitIntervalAtCallSite(LiveInterval liveInterval, SlotIndex callSite)
 {
 }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:3,代码来源:BasicRegisterAllocator.cs


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