Skip to content

Commit

Permalink
Merge branch 'master' into launcher-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AnErrupTion committed Apr 20, 2024
2 parents b390a8c + 922e74c commit 2b027cc
Show file tree
Hide file tree
Showing 35 changed files with 1,257 additions and 284 deletions.
4 changes: 2 additions & 2 deletions Source/Mosa.BareMetal.HelloWorld/Apps/ShowPCI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void Execute()
Program.Bullet(ConsoleColor.Yellow);
Console.Write(" ");

var pciDevice = (PCIDevice)device.Parent.DeviceDriver;
var pciDevice = (PCIDeviceConfiguration)device.Configuration;
var name = device.DeviceDriverRegistryEntry == null ? "UnknownPCIDevice" : device.Name;

Program.InBrackets(pciDevice.Device.Name + ": " + name + " " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubSystemVendorID.ToString("x") + " (" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ConsoleColor.White, ConsoleColor.Green);
Program.InBrackets(pciDevice.Name + ": " + name + " " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubSystemVendorID.ToString("x") + " (" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ConsoleColor.White, ConsoleColor.Green);
Console.WriteLine();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.6.0" />
<PackageReference Include="xunit.assert" Version="2.6.2" />
<PackageReference Include="xunit.core" Version="2.6.2" />
<PackageReference Include="xunit.extensibility.core" Version="2.6.2" />
<PackageReference Include="xunit.extensibility.execution" Version="2.6.2" />
<PackageReference Include="xunit.runner.console" Version="2.6.2">
<PackageReference Include="xunit.analyzers" Version="1.12.0" />
<PackageReference Include="xunit.assert" Version="2.7.1" />
<PackageReference Include="xunit.core" Version="2.7.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.7.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.7.1" />
<PackageReference Include="xunit.runner.console" Version="2.7.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.6.0" />
<PackageReference Include="xunit.assert" Version="2.6.2" />
<PackageReference Include="xunit.core" Version="2.6.2" />
<PackageReference Include="xunit.extensibility.core" Version="2.6.2" />
<PackageReference Include="xunit.extensibility.execution" Version="2.6.2" />
<PackageReference Include="xunit.runner.console" Version="2.6.2">
<PackageReference Include="xunit.analyzers" Version="1.12.0" />
<PackageReference Include="xunit.assert" Version="2.7.1" />
<PackageReference Include="xunit.core" Version="2.7.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.7.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.7.1" />
<PackageReference Include="xunit.runner.console" Version="2.7.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.Framework/Analysis/LoopDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static void PopulateLoopNodes(BasicBlocks basicBlocks, Loop loop)
continue;

visited.Add(node);
loop.LoopBlocks.Add(node);
loop.AddNode(node);

foreach (var previous in node.PreviousBlocks)
{
Expand Down
32 changes: 16 additions & 16 deletions Source/Mosa.Compiler.Framework/BaseTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,19 +1183,19 @@ protected static bool IsBitValueZeroOrOne(Operand operand)
{
return (int)value1.BitsSet > (int)value2.BitsSet;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue > value2.MaxValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue > value2.MaxValue)
{
return true;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue < value2.MinValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue < value2.MinValue)
{
return false;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue > value2.MaxValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue > value2.MaxValue)
{
return true;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue < value2.MinValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue < value2.MinValue)
{
return false;
}
Expand All @@ -1211,19 +1211,19 @@ protected static bool IsBitValueZeroOrOne(Operand operand)
{
return (int)value1.BitsSet < (int)value2.BitsSet;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue < value2.MinValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue < value2.MinValue)
{
return true;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue > value2.MaxValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue > value2.MaxValue)
{
return false;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue < value2.MinValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue < value2.MinValue)
{
return true;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue > value2.MaxValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue > value2.MaxValue)
{
return false;
}
Expand All @@ -1239,19 +1239,19 @@ protected static bool IsBitValueZeroOrOne(Operand operand)
{
return (int)value1.BitsSet >= (int)value2.BitsSet;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue >= value2.MaxValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue >= value2.MaxValue)
{
return true;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue <= value2.MinValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue <= value2.MinValue)
{
return false;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue >= value2.MaxValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue >= value2.MaxValue)
{
return true;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue <= value2.MinValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue <= value2.MinValue)
{
return false;
}
Expand All @@ -1267,19 +1267,19 @@ protected static bool IsBitValueZeroOrOne(Operand operand)
{
return (int)value1.BitsSet <= (int)value2.BitsSet;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue <= value2.MinValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MaxValue <= value2.MinValue)
{
return true;
}
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue >= value2.MaxValue)
else if (value1.Is32Bit && value2.Is32Bit && value1.IsSignBitKnown32 && value2.IsSignBitKnown32 && value1.IsSignBitClear32 && value2.IsSignBitClear32 && value1.MinValue >= value2.MaxValue)
{
return false;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue <= value2.MinValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MaxValue <= value2.MinValue)
{
return true;
}
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue >= value2.MaxValue)
else if (value1.Is64Bit && value2.Is64Bit && value1.IsSignBitKnown64 && value2.IsSignBitKnown64 && value1.IsSignBitClear64 && value2.IsSignBitClear64 && value1.MinValue >= value2.MaxValue)
{
return false;
}
Expand Down
34 changes: 29 additions & 5 deletions Source/Mosa.Compiler.Framework/BitValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,30 @@ public BitValue NarrowMin(ulong minValue)
return Narrow();
}

public BitValue NarrowSignRange(long minValue, long maxValue)
{
if (IsFixed)
return this;

if (minValue > maxValue)
{
(minValue, maxValue) = (maxValue, minValue); // swap
}

if (minValue >= 0 && maxValue >= 0)
{
return NarrowMax((ulong)maxValue).NarrowMin((ulong)minValue);
}
else if (minValue < 0 && maxValue < 0)
{
return NarrowMin((ulong)maxValue).NarrowMax((ulong)minValue);
}

// unable to narrow

return this;
}

public BitValue NarrowSetBits(ulong bitsSet)
{
if (IsFixed)
Expand Down Expand Up @@ -322,11 +346,11 @@ public override string ToString()
{
var sb = new StringBuilder();

sb.Append($"MaxValue: {MaxValue}");
sb.Append($"MinValue: {MinValue}");
sb.Append($"BitsSet: {Convert.ToString((long)BitsSet, 2).PadLeft(64, '0')}");
sb.Append($"BitsClear: {Convert.ToString((long)BitsClear, 2).PadLeft(64, '0')}");
sb.Append($"BitsKnown: {Convert.ToString((long)BitsKnown, 2).PadLeft(64, '0')}");
sb.AppendLine($" Min: {MinValue}");
sb.AppendLine($" Max: {MaxValue}");
sb.AppendLine($" BitsSet: {Convert.ToString((long)BitsSet, 2).PadLeft(64, '0')}");
sb.AppendLine($" BitsClear: {Convert.ToString((long)BitsClear, 2).PadLeft(64, '0')}");
sb.AppendLine($" BitsKnown: {Convert.ToString((long)BitsKnown, 2).PadLeft(64, '0')}");

return sb.ToString();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Mosa.Compiler.Framework/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ public sealed class Compiler
mosaSettings.SparseConditionalConstantPropagation && mosaSettings.SSA ? new SparseConditionalConstantPropagationStage() : null,
mosaSettings.BasicOptimizations && mosaSettings.SSA && (mosaSettings.ValueNumbering || mosaSettings.LoopInvariantCodeMotion || mosaSettings.SparseConditionalConstantPropagation) ? new OptimizationStage(false) : null,
mosaSettings.BitTracker ? new BitTrackerStage() : null,
//mosaSettings.LoopRangeTracker && mosaSettings.SSA ? new LoopRangeTrackerStage() : null,
mosaSettings.LoopRangeTracker && mosaSettings.SSA ? new LoopRangeTrackerStage() : null,
mosaSettings.BasicOptimizations ? new OptimizationStage(mosaSettings.LongExpansion) : null,

mosaSettings.TwoPassOptimization && mosaSettings.ValueNumbering && mosaSettings.SSA ? new ValueNumberingStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.LoopInvariantCodeMotion && mosaSettings.SSA ? new LoopInvariantCodeMotionStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.SparseConditionalConstantPropagation && mosaSettings.SSA ? new SparseConditionalConstantPropagationStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.BitTracker ? new BitTrackerStage() : null,
//mosaSettings.TwoPassOptimization && mosaSettings.LoopRangeTracker && mosaSettings.SSA ? new LoopRangeTrackerStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.LoopRangeTracker && mosaSettings.SSA ? new LoopRangeTrackerStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.BasicOptimizations && mosaSettings.SSA ? new OptimizationStage(mosaSettings.LongExpansion) : null,

new NopRemovalStage(),
Expand Down
7 changes: 0 additions & 7 deletions Source/Mosa.Compiler.Framework/Loop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public sealed class Loop
public BasicBlock Header { get; set; }
public readonly List<BasicBlock> Backedges = new();
public readonly List<BasicBlock> LoopBlocks = new();
//private readonly HashSet<BasicBlock> LoopBlocksSet = new();

public Loop(BasicBlock header, BasicBlock backedge)
{
Expand All @@ -26,11 +25,5 @@ public void AddNode(BasicBlock block)
{
Debug.Assert(!LoopBlocks.Contains(block));
LoopBlocks.Add(block);
//LoopBlocksSet.Add(block);
}

//public bool Contains(BasicBlock block)
//{
// return LoopBlocksSet.Contains(block);
//}
}
21 changes: 21 additions & 0 deletions Source/Mosa.Compiler.Framework/Operand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ public bool IsConstantZero
}
}

public bool IsNegative
{
get
{
if (!IsResolvedConstant)
return false;
else if (IsLocalStack || IsOnStack || IsParameter)
return ConstantUnsigned64 < 0;
else if (IsNull)
return false;
else if (IsR8)
return ConstantDouble < 0;
else if (IsR4)
return ConstantFloat < 0;
else if (IsInt32)
return ConstantSigned32 < 0;
else
return ConstantSigned64 < 0;
}
}

public bool IsPhysicalRegister => Location == LocationType.PhysicalRegister;

public bool IsFloatingPoint => IsR4 | IsR8;
Expand Down
10 changes: 8 additions & 2 deletions Source/Mosa.Compiler.Framework/Stages/BaseTransformStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,15 @@ private bool ApplyBlockTransforms()
var updated = count != 0;
changed |= updated;

if (updated && MethodCompiler.Statistics)
if (updated)
{
UpdateCounter(transform.Name, count);
MethodCompiler.CreateTranformInstructionTrace(this, Steps++);

if (MosaSettings.FullCheckMode)
FullCheck(false);

if (MethodCompiler.Statistics)
UpdateCounter(transform.Name, count);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.Compiler.Framework;

namespace Mosa.Tool.Explorer.Stages;
namespace Mosa.Compiler.Framework.Stages.Diagnostic;

public class DebugInfoStage : BaseMethodCompilerStage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System.Text;
using Mosa.Compiler.Framework;
using Mosa.Compiler.Framework.Analysis;

namespace Mosa.Tool.Explorer.Stages;
namespace Mosa.Compiler.Framework.Stages.Diagnostic;

public class DominanceOutputStage : BaseMethodCompilerStage
public class DominanceAnalysisStage : BaseMethodCompilerStage
{
private const int TraceLevel = 5;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.Compiler.Framework;

namespace Mosa.Tool.Explorer.Stages;
namespace Mosa.Compiler.Framework.Stages.Diagnostic;

public class GraphVizStage : BaseMethodCompilerStage
{
Expand Down

0 comments on commit 2b027cc

Please sign in to comment.