• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RegisterAllocator.SlotIndex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PreferBlockBoundaryIntervalSplit

        private bool PreferBlockBoundaryIntervalSplit(LiveInterval liveInterval, SlotIndex at, bool addToQueue)
        {
            var low = GetLowerOptimalSplitLocation(liveInterval, at);
            var high = GetUpperOptimalSplitLocation(liveInterval, at);

            IList<LiveInterval> intervals;

            if (liveInterval.Start == low)
            {
                if (!liveInterval.LiveRange.CanSplitAt(high))
                    return false;

                intervals = liveInterval.SplitAt(high);
            }
            else if (high == liveInterval.End)
            {
                if (!liveInterval.LiveRange.CanSplitAt(low))
                    return false;

                intervals = liveInterval.SplitAt(low);
            }
            else
            {
                if (!liveInterval.LiveRange.CanSplitAt(low, high))
                {
                    return false;
                }

                intervals = liveInterval.SplitAt(low, high);
            }

            ReplaceIntervals(liveInterval, intervals, addToQueue);

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


示例17: GetUpperOptimalSplitLocation

        private SlotIndex GetUpperOptimalSplitLocation(LiveInterval liveInterval, SlotIndex at)
        {
            if (Trace.Active) Trace.Log("--High Splitting: " + liveInterval.ToString() + " move: " + at.ToString());

            var a = liveInterval.End;

            var blockEnd = GetBlockEnd(at);
            var b = blockEnd > liveInterval.End ? blockEnd : null;
            if (Trace.Active) Trace.Log("     Block End : " + (b != null ? b.ToString() : "null"));

            var c = liveInterval.LiveRange.GetNextUsePosition(at);
            if (c != null && c.HalfStepBack > at)
                c = c.HalfStepBack;
            if (Trace.Active) Trace.Log("      Next Use : " + (c != null ? c.ToString() : "null"));

            var d = liveInterval.LiveRange.GetNextDefPosition(at);
            if (Trace.Active) Trace.Log("      Next Def : " + (d != null ? d.ToString() : "null"));

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

            if (Trace.Active) Trace.Log("  High Optimal : " + min.ToString());

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


示例18: NumberInstructions

        private void NumberInstructions()
        {
            var number = new CompilerTrace(trace, "InstructionNumber");

            int index = SlotIncrement;

            foreach (BasicBlock block in basicBlocks)
            {
                for (Context context = new Context(instructionSet, block); ; context.GotoNext())
                {
                    if (!context.IsEmpty)
                    {
                        context.SlotNumber = index;
                        index = index + SlotIncrement;

                        if (number.Active)
                        {
                            if (context.IsBlockStartInstruction)
                            {
                                number.Log(context.SlotNumber.ToString() + " = " + context.ToString() + " # " + block.ToString());
                            }
                            else
                            {
                                number.Log(context.SlotNumber.ToString() + " = " + context.ToString());
                            }
                        }
                    }

                    if (context.IsBlockEndInstruction)
                        break;
                }

                SlotIndex start = new SlotIndex(instructionSet, block.StartIndex);
                SlotIndex end = new SlotIndex(instructionSet, block.EndIndex);
                extendedBlocks[block.Sequence].Interval = new Interval(start, end);
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:37,代码来源:GreedyRegisterAllocator.cs


示例19: GetBlockEnd

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


示例20: SplitIntervalAtCallSite

 protected override void SplitIntervalAtCallSite(LiveInterval liveInterval, SlotIndex callSite)
 {
     PreferBlockBoundaryIntervalSplit(liveInterval, callSite, false);
 }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:4,代码来源:GreedyRegisterAllocator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Metadata.Token类代码示例发布时间:2022-05-26
下一篇:
C# Operands.RegisterOperand类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap