本文整理汇总了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;
}
示例2: Interval
public Interval(SlotIndex start, SlotIndex end)
{
Debug.Assert(start <= end);
this.Start = start;
this.End = end;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例7: GetSpillCost
private int GetSpillCost(SlotIndex use, int factor)
{
return (factor * SlotIncrement) * GetLoopDepth(use) * 100;
}
示例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;
}
示例9: GetLoopDepth
private int GetLoopDepth(SlotIndex slotIndex)
{
return GetContainingBlock(slotIndex).LoopDepth + 1;
}
示例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);
}
示例11: IsAdjacent
public bool IsAdjacent(SlotIndex start, SlotIndex end)
{
return LiveRange.IsAdjacent(start, end);
}
示例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));
}
}
}
示例13: GetSpillCost
private int GetSpillCost(SlotIndex use, int factor)
{
return factor * GetLoopDepth(use) * 100;
}
示例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);
}
//.........这里部分代码省略.........
示例15: SplitIntervalAtCallSite
protected virtual void SplitIntervalAtCallSite(LiveInterval liveInterval, SlotIndex callSite)
{
}