-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
99 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...sa.Tool.Explorer/Stages/DebugInfoStage.cs → ...ework/Stages/Diagnostic/DebugInfoStage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...l.Explorer/Stages/DominanceOutputStage.cs → ...ages/Diagnostic/DominanceAnalysisStage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...osa.Tool.Explorer/Stages/GraphVizStage.cs → ...mework/Stages/Diagnostic/GraphVizStage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Source/Mosa.Compiler.Framework/Stages/Diagnostic/LoopAnalysisStage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using Mosa.Compiler.Framework.Analysis; | ||
|
||
namespace Mosa.Compiler.Framework.Stages.Diagnostic; | ||
|
||
/// <summary> | ||
/// Loop Analysis Stage | ||
/// </summary> | ||
public sealed class LoopAnalysisStage : BaseMethodCompilerStage | ||
{ | ||
private readonly Counter LoopCount = new("LoopAnalysis.LoopCount"); | ||
private readonly Counter LoopSize1 = new("LoopAnalysis.LoopSize-1"); | ||
private readonly Counter LoopSize2 = new("LoopAnalysis.LoopSize-2"); | ||
private readonly Counter LoopSize3 = new("LoopAnalysis.LoopSize-3"); | ||
private readonly Counter LoopSize4 = new("LoopAnalysis.LoopSize-4"); | ||
private readonly Counter LoopSize5Plus = new("LoopAnalysis.LoopSize-5+"); | ||
|
||
protected override void Initialize() | ||
{ | ||
Register(LoopCount); | ||
Register(LoopSize1); | ||
Register(LoopSize2); | ||
Register(LoopSize3); | ||
Register(LoopSize4); | ||
Register(LoopSize5Plus); | ||
} | ||
|
||
protected override void Run() | ||
{ | ||
if (HasProtectedRegions) | ||
return; | ||
|
||
// Method is empty - must be a plugged method | ||
if (BasicBlocks.HeadBlocks.Count != 1) | ||
return; | ||
|
||
if (BasicBlocks.PrologueBlock == null) | ||
return; | ||
|
||
if (!MethodCompiler.IsInSSAForm) | ||
return; | ||
|
||
var loops = LoopDetector.FindLoops(BasicBlocks); | ||
|
||
LoopCount.Set(loops.Count); | ||
|
||
foreach (var loop in loops) | ||
{ | ||
var size = loop.LoopBlocks.Count; | ||
|
||
switch (size) | ||
{ | ||
case 1: LoopSize1.Increment(); break; | ||
case 2: LoopSize2.Increment(); break; | ||
case 3: LoopSize3.Increment(); break; | ||
case 4: LoopSize4.Increment(); break; | ||
default: | ||
LoopSize5Plus.Increment(); break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Source/Mosa.Utility.Disassembler/Mosa.Utility.Disassembler.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters