Skip to content

Commit

Permalink
Refactoring + Bug Fix (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Sep 3, 2023
1 parent c4e1030 commit 26c9b2d
Show file tree
Hide file tree
Showing 138 changed files with 488 additions and 1,021 deletions.
1 change: 0 additions & 1 deletion Source/Mosa.BareMetal.HelloWorld.x86/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using Mosa.Kernel.BareMetal;
using Mosa.UnitTests.Basic;
using Mosa.UnitTests.Primitive;

namespace Mosa.BareMetal.HelloWorld.x86;

Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.BareMetal.HelloWorld/Apps/Reboot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public void Execute()
var pc = Kernel.BareMetal.Kernel.ServiceManager.GetFirstService<PCService>();
pc.Reset();

for (;;) HAL.Yield();
for (; ; ) HAL.Yield();
}
}
2 changes: 0 additions & 2 deletions Source/Mosa.BareMetal.HelloWorld/Apps/ShowDisks.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System;
using Mosa.DeviceDriver.ISA;
using Mosa.DeviceSystem;
using Mosa.DeviceSystem.Service;

namespace Mosa.BareMetal.HelloWorld.Apps;

Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.BareMetal.HelloWorld/Apps/Shutdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public void Execute()
var pc = Kernel.BareMetal.Kernel.ServiceManager.GetFirstService<PCService>();
pc.Shutdown();

for (;;) HAL.Yield();
for (; ; ) HAL.Yield();
}
}
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM32/Stages/IRTransformationStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class IRTransformationStage : Compiler.Framework.Stages.BaseTransf
public override string Name => "ARM32." + GetType().Name;

public IRTransformationStage()
: base(true, false)
: base()
{
AddTranforms(IRTransforms.List);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM32/Stages/OptimizationStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class OptimizationStage : Compiler.Framework.Stages.BaseTransformS
public override string Name => "ARM32." + GetType().Name;

public OptimizationStage()
: base(true, false)
: base()
{
AddTranforms(AutoTransforms.List);
AddTranforms(ManualTransforms.List);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class PlatformTransformationStage : Compiler.Framework.Stages.Base
public override string Name => "ARM32." + GetType().Name;

public PlatformTransformationStage()
: base(true, false, 0)
: base(0)
{
AddTranforms(TweakTransforms.List);
AddTranforms(FixedRegistersTransforms.List);
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM32/Stages/RuntimeCallStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class RuntimeCallStage : Compiler.Framework.Stages.BaseTransformSt
public override string Name => "ARM32." + GetType().Name;

public RuntimeCallStage()
: base(true, false, 1)
: base(1)
{
AddTranforms(RuntimeCallTransforms.List);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM64/Stages/IRTransformationStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class IRTransformationStage : Compiler.Framework.Stages.BaseTransf
public override string Name => "ARM64." + GetType().Name;

public IRTransformationStage()
: base(true, false)
: base()
{
//AddTranforms(IRTransforms.List);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM64/Stages/OptimizationStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class OptimizationStage : Compiler.Framework.Stages.BaseTransformS
public override string Name => "ARM64." + GetType().Name;

public OptimizationStage()
: base(true, false)
: base()
{
AddTranforms(AutoTransforms.List);
AddTranforms(ManualTransforms.List);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class PlatformTransformationStage : Compiler.Framework.Stages.Base
public override string Name => "ARM64." + GetType().Name;

public PlatformTransformationStage()
: base(true, false, 0)
: base(0)
{
AddTranforms(TweakTransforms.List);
AddTranforms(FixedRegistersTransforms.List);
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.ARM64/Stages/RuntimeCallStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class RuntimeCallStage : Compiler.Framework.Stages.BaseTransformSt
public override string Name => "ARM64." + GetType().Name;

public RuntimeCallStage()
: base(true, false, 1)
: base(1)
{
AddTranforms(RuntimeCallTransforms.List);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Mosa.Compiler.Framework/BaseBlockTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public BaseBlockTransform(bool log = false)
{
Log = log;

Name = GetType().FullName.Replace("Mosa.Compiler.", string.Empty).Replace("Mosa.Compiler.Framework.Transforms", "IR").Replace("Transforms.", string.Empty);
Name = GetType().FullName.Replace("Mosa.Compiler.Framework.", string.Empty);
}

#endregion Constructors

#region Abstract Methods

public abstract bool Process(TransformContext transformContext);
public abstract int Process(TransformContext transformContext);

#endregion Abstract Methods

Expand Down
58 changes: 0 additions & 58 deletions Source/Mosa.Compiler.Framework/BaseCodeTransformationStage.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,5 +624,7 @@ protected bool CheckAllPhiInstructions()
return true;
}

// FUTURE: Check Block CompletelyEmpty flag

#endregion Check Methods
}
11 changes: 11 additions & 0 deletions Source/Mosa.Compiler.Framework/BasicBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,17 @@ public bool HasPhiInstruction()
return false;
}

public void RemoveNops()
{
for (var node = AfterFirst; !node.IsBlockEndInstruction; node = node.Next)
{
if (node.IsEmpty || !node.IsNop)
continue;

node.Empty();
}
}

#endregion Advanced Methods

public int CompareTo(BasicBlock other)
Expand Down
4 changes: 2 additions & 2 deletions Source/Mosa.Compiler.Framework/BitValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public sealed class BitValue

public ulong MinValue { get; private set; }

public bool Is32Bit { get; private set; }

#region Future

//public ulong A { get; private set; }
Expand All @@ -114,8 +116,6 @@ public sealed class BitValue

#endregion Future

public bool Is32Bit { get; private set; }

public bool Is64Bit => !Is32Bit;

public bool AreAll64BitsKnown => (BitsKnown & ulong.MaxValue) == ulong.MaxValue;
Expand Down
7 changes: 5 additions & 2 deletions Source/Mosa.Compiler.Framework/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ public sealed class Compiler
mosaSettings.TwoPassOptimization && mosaSettings.BitTracker ? new BitTrackerStage() : null,
mosaSettings.TwoPassOptimization && mosaSettings.BasicOptimizations && mosaSettings.SSA ? new OptimizationStage(mosaSettings.LongExpansion) : null,

new NopRemovalStage(),
new FastBlockOrderingStage(),

mosaSettings.SSA ? new ExitSSAStage() : null,

new IRCleanupStage(),
new DeadBlockStage(),

mosaSettings.InlineMethods || mosaSettings.InlineExplicit ? new InlineEvaluationStage() : null,
new NewObjectStage(),
Expand All @@ -217,7 +220,7 @@ public sealed class Compiler
new GreedyRegisterAllocatorStage(),
new StackLayoutStage(),
new DeadBlockStage(),
new BlockOrderingStage(),
new AdvancedBlockOrderingStage(),

//new PreciseGCStage(),

Expand Down
3 changes: 0 additions & 3 deletions Source/Mosa.Compiler.Framework/CompilerHooks.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System.Collections.Generic;
using Mosa.Compiler.Framework.Trace;
using Mosa.Compiler.MosaTypeSystem;

Expand All @@ -20,8 +19,6 @@ public class CompilerHooks

public delegate void NotifyMethodCompiledHandler(MosaMethod method);

public delegate IList<CustomELFSection> CustomElfSectionsHandler();

public delegate NotifyTraceLogHandler NotifyMethodInstructionTraceHandler(MosaMethod method);

public delegate NotifyTraceLogHandler NotifyMethodTranformTraceHandler(MosaMethod method);
Expand Down
24 changes: 0 additions & 24 deletions Source/Mosa.Compiler.Framework/CustomELFSection.cs

This file was deleted.

64 changes: 0 additions & 64 deletions Source/Mosa.Compiler.Framework/FlowControl.cs

This file was deleted.

1 change: 0 additions & 1 deletion Source/Mosa.Compiler.Framework/IRInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// This code was generated by an automated template.

using Mosa.Compiler.Framework;
using Mosa.Compiler.Framework.IR;

namespace Mosa.Compiler.Framework;
Expand Down

0 comments on commit 26c9b2d

Please sign in to comment.