Permalink
Browse files

- New comparison optimization + updated packages

  • Loading branch information...
tgiphil committed Nov 4, 2017
1 parent d26f52b commit 34aede489a275cb2c6b090aa68df83c1bfc91c13
Showing with 306 additions and 192 deletions.
  1. +17 −11 Source/Mosa.Compiler.Framework.xUnit/Mosa.Compiler.Framework.xUnit.csproj
  2. +8 −7 Source/Mosa.Compiler.Framework.xUnit/packages.config
  3. +1 −4 Source/Mosa.Compiler.Framework/Stages/DevirtualizeCallStage.cs
  4. +71 −57 Source/Mosa.Compiler.Framework/Stages/IROptimizationStage.cs
  5. +4 −4 Source/Mosa.Tool.Compiler/Mosa.Tool.Compiler.csproj
  6. +13 −13 Source/Mosa.Tool.Compiler/packages.config
  7. +4 −4 Source/Mosa.Tool.CreateBootImage/Mosa.Tool.CreateBootImage.csproj
  8. +13 −13 Source/Mosa.Tool.CreateBootImage/packages.config
  9. +2 −2 Source/Mosa.Tool.Debugger/Mosa.Tool.Debugger.csproj
  10. +1 −1 Source/Mosa.Tool.Debugger/packages.config
  11. +4 −4 Source/Mosa.Tool.Disassembler.Intel/Mosa.Tool.Disassembler.Intel.csproj
  12. +13 −13 Source/Mosa.Tool.Disassembler.Intel/packages.config
  13. +4 −4 Source/Mosa.Tool.Explorer/Mosa.Tool.Explorer.csproj
  14. +13 −13 Source/Mosa.Tool.Explorer/packages.config
  15. +4 −4 Source/Mosa.Tool.GDBDebugger/Mosa.Tool.GDBDebugger.csproj
  16. +2 −2 Source/Mosa.Tool.GDBDebugger/packages.config
  17. +51 −0 Source/Mosa.UnitTest.Collection.xUnit/CompilerFixture.cs
  18. +16 −11 Source/Mosa.UnitTest.Collection.xUnit/Mosa.UnitTest.Collection.xUnit.csproj
  19. +7 −6 Source/Mosa.UnitTest.Collection.xUnit/packages.config
  20. +37 −0 Source/Mosa.UnitTest.Collection/CompilerTests.cs
  21. +1 −0 Source/Mosa.UnitTest.Collection/Mosa.UnitTest.Collection.csproj
  22. +2 −1 Source/Mosa.UnitTest.Engine/UnitTestEngine.cs
  23. +4 −4 Source/Mosa.Utility.Launcher/Mosa.Utility.Launcher.csproj
  24. +13 −13 Source/Mosa.Utility.Launcher/packages.config
  25. +1 −1 Tests/RunAllUnitTests.bat
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props" Condition="Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" />
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.21022</ProductVersion>
@@ -109,22 +111,22 @@
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
@@ -136,6 +138,10 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
</Project>
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.2.0" targetFramework="net461" />
<package id="xunit" version="2.3.1" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
<package id="xunit.assert" version="2.2.0" targetFramework="net461" />
<package id="xunit.core" version="2.2.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net461" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net461" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net461" developmentDependency="true" />
<package id="xunit.analyzers" version="0.7.0" targetFramework="net461" />
<package id="xunit.assert" version="2.3.1" targetFramework="net461" />
<package id="xunit.core" version="2.3.1" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.3.1" targetFramework="net461" />
<package id="xunit.runner.console" version="2.3.1" targetFramework="net461" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.3.1" targetFramework="net461" developmentDependency="true" />
</packages>
@@ -44,10 +44,7 @@ private void CallVirtual(InstructionNode node)
var operands = node.GetOperands();
operands.RemoveAt(0);
if (trace.Active)
{
trace.Log("De-virtualize: " + method);
}
if (trace.Active) trace.Log("De-virtualize: " + method);
devirtualizedCount++;
@@ -51,6 +51,7 @@ public sealed class IROptimizationStage : BaseMethodCompilerStage
private int simplifyTo64 = 0;
private int simplifySplit64 = 0;
private int reduceSplit64 = 0;
private int simplifyIntegerCompare = 0;
private Stack<InstructionNode> worklist = new Stack<InstructionNode>();
@@ -115,6 +116,7 @@ protected override void Run()
UpdateCounter("IROptimizations.SimplifyTo64", simplifyTo64);
UpdateCounter("IROptimizations.SimplifySplit64", simplifySplit64);
UpdateCounter("IROptimizations.ReduceSplit64", reduceSplit64);
UpdateCounter("IROptimizations.SimplifyIntegerCompare", simplifyIntegerCompare);
worklist = null;
}
@@ -187,6 +189,8 @@ private List<Transformation> CreateTransformationList()
ReduceTruncationAndExpansion,
SimplifyExtendedMoveWithConstant,
SimplifyExtendedMove,
SimplifyIntegerCompare2,
SimplifyIntegerCompare,
FoldLoadStoreOffsets,
ConstantFoldingPhi,
SimplifyPhi,
@@ -1760,6 +1764,73 @@ private void SimplifyPhi2(InstructionNode node)
simplifyPhiCount++;
}
private void SimplifyIntegerCompare(InstructionNode node)
{
if (node.Instruction != IRInstruction.CompareInteger)
return;
if (node.ConditionCode != ConditionCode.NotEqual)
return;
if (!node.Result.IsVirtualRegister)
return;
if (node.Result.Definitions.Count != 1)
return;
if (!((node.Operand1.IsVirtualRegister && node.Operand2.IsConstantZero)
|| (node.Operand2.IsVirtualRegister && node.Operand1.IsConstantZero)))
return;
var operand = (node.Operand2.IsConstantZero) ? node.Operand1 : node.Operand2;
if (operand.Uses.Count != 1)
return;
if (operand.Definitions.Count != 1)
return;
if (operand.Is64BitInteger != node.Result.Is64BitInteger)
return;
if (trace.Active) trace.Log("*** SimplifyIntegerCompare");
if (trace.Active) trace.Log("BEFORE:\t" + node);
AddOperandUsageToWorkList(node);
node.SetInstruction(IRInstruction.MoveInteger, node.Result, operand);
if (trace.Active) trace.Log("AFTER: \t" + node);
simplifyIntegerCompare++;
}
private void SimplifyIntegerCompare2(InstructionNode node)
{
if (node.Instruction != IRInstruction.CompareInteger)
return;
if (node.ConditionCode != ConditionCode.UnsignedGreaterThan)
return;
if (!node.Result.IsVirtualRegister)
return;
if (node.Result.Definitions.Count != 1)
return;
if (!node.Operand2.IsConstantZero)
return;
if (!node.Operand1.IsVirtualRegister)
return;
if (trace.Active) trace.Log("*** SimplifyIntegerCompare");
if (trace.Active) trace.Log("BEFORE:\t" + node);
AddOperandUsageToWorkList(node);
node.SetInstruction(IRInstruction.CompareInteger, ConditionCode.NotEqual, node.Result, node.Operand1, node.Operand2);
if (trace.Active) trace.Log("AFTER: \t" + node);
simplifyIntegerCompare++;
}
private void DeadCodeEliminationPhi(InstructionNode node)
{
if (node.Instruction != IRInstruction.Phi)
@@ -1882,59 +1953,6 @@ private static int GetPowerOfTwo(ulong n)
return bits - 1;
}
private void ReplaceVirtualRegister(Operand local, Operand replacement)
{
if (trace.Active) trace.Log("Replacing: " + local + " with " + replacement);
foreach (var node in local.Uses.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetOperand(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node);
node.SetOperand(i, replacement);
if (node.Instruction == IRInstruction.MoveZeroExtended)
{
node.Instruction = IRInstruction.MoveInteger;
node.Size = InstructionSize.None;
}
if (trace.Active) trace.Log("AFTER: \t" + node);
}
}
}
foreach (var node in local.Definitions.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.ResultCount; i++)
{
var operand = node.GetResult(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node);
node.SetResult(i, replacement);
if (node.Instruction == IRInstruction.MoveZeroExtended)
{
node.Instruction = IRInstruction.MoveInteger;
node.Size = InstructionSize.None;
}
if (trace.Active) trace.Log("AFTER: \t" + node);
}
}
}
}
private void NormalizeConstantTo32Bit(InstructionNode node)
{
if (node.ResultCount != 1)
@@ -1969,10 +1987,6 @@ private void NormalizeConstantTo32Bit(InstructionNode node)
}
}
/// <summary>
/// Arithmetics the simplification rem unsigned modulus.
/// </summary>
/// <param name="node">The node.</param>
private void Split64Constant(InstructionNode node)
{
if (node.Instruction != IRInstruction.Split64)
@@ -71,11 +71,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.0.0\lib\net46\System.Console.dll</HintPath>
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.TypeExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net46\System.Reflection.TypeExtensions.dll</HintPath>
<Reference Include="System.Reflection.TypeExtensions, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.4.0\lib\net461\System.Reflection.TypeExtensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net461" />
<package id="System.Collections" version="4.0.11" targetFramework="net461" />
<package id="System.Console" version="4.0.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net461" />
<package id="System.Globalization" version="4.0.11" targetFramework="net461" />
<package id="System.IO" version="4.1.0" targetFramework="net461" />
<package id="System.Linq" version="4.1.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net461" />
<package id="System.Reflection" version="4.1.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net461" />
<package id="System.Reflection.TypeExtensions" version="4.1.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net461" />
<package id="System.Runtime" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
<package id="System.IO" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.TypeExtensions" version="4.4.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
</packages>
@@ -67,11 +67,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.0.0\lib\net46\System.Console.dll</HintPath>
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.TypeExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net46\System.Reflection.TypeExtensions.dll</HintPath>
<Reference Include="System.Reflection.TypeExtensions, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.4.0\lib\net461\System.Reflection.TypeExtensions.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net461" />
<package id="System.Collections" version="4.0.11" targetFramework="net461" />
<package id="System.Console" version="4.0.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net461" />
<package id="System.Globalization" version="4.0.11" targetFramework="net461" />
<package id="System.IO" version="4.1.0" targetFramework="net461" />
<package id="System.Linq" version="4.1.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net461" />
<package id="System.Reflection" version="4.1.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net461" />
<package id="System.Reflection.TypeExtensions" version="4.1.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net461" />
<package id="System.Runtime" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
<package id="System.IO" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.TypeExtensions" version="4.4.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
</packages>
@@ -50,8 +50,8 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5cded1a1a0a7b481, processorArchitecture=MSIL">
<HintPath>..\packages\DockPanelSuite.3.0.0\lib\net40\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5cded1a1a0a7b481, processorArchitecture=MSIL">
<HintPath>..\packages\DockPanelSuite.3.0.1\lib\net40\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DockPanelSuite" version="3.0.0" targetFramework="net461" />
<package id="DockPanelSuite" version="3.0.1" targetFramework="net461" />
</packages>
Oops, something went wrong.

0 comments on commit 34aede4

Please sign in to comment.