Skip to content

Commit

Permalink
- Worked on register allocator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil authored and charsleysa committed Apr 14, 2015
1 parent 7a11a56 commit 3bc1093
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1544,12 +1544,17 @@ protected MoveKeyedList GetRegisterMoves()

foreach (var currentInterval in virtualRegister.LiveIntervals)
{
// No moves at block edges (these are done in the resolve move phase later)
if (blockEdges.ContainsKey(currentInterval.End))
continue;

// List is not sorted, so scan thru each one
foreach (var nextInterval in virtualRegister.LiveIntervals)
{
// same interval
if (currentInterval == nextInterval)
continue;

if (nextInterval.Start != currentInterval.End)
continue;

Expand All @@ -1562,6 +1567,18 @@ protected MoveKeyedList GetRegisterMoves()
nextInterval.AssignedOperand.Register == currentInterval.AssignedOperand.Register)
break;

// don't load from slot if next live interval starts with a def before use
if (nextInterval.DefPositions.Count != 0)
{
if (nextInterval.UsePositions.Count == 0)
continue;
else
{
if (nextInterval.LiveRange.FirstDef < nextInterval.LiveRange.FirstUse)
continue;
}
}

keyedList.Add(currentInterval.End, currentInterval.AssignedOperand, nextInterval.AssignedOperand);

break;
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.TinyCPUSimulator.TestSystem/TestCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void CompileTestCode()

Run<int>(string.Empty, "Default", "AssemblyInit", true);

simAdapter.SimCPU.Monitor.DebugOutput = true; // DEBUG OPTION
//simAdapter.SimCPU.Monitor.DebugOutput = true; // DEBUG OPTION
}

public T Run<T>(string ns, string type, string method, params object[] parameters)
Expand Down

0 comments on commit 3bc1093

Please sign in to comment.