-
Notifications
You must be signed in to change notification settings - Fork 82
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
13 changed files
with
481 additions
and
272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using System; | ||
|
||
namespace Mosa.Compiler.Framework; | ||
|
||
public abstract class BaseBlockTransform : IComparable<BaseBlockTransform> | ||
{ | ||
#region Properties | ||
|
||
public bool Log { get; private set; } | ||
|
||
public string Name { get; } | ||
|
||
public virtual int Priority { get; } = 0; | ||
|
||
#endregion Properties | ||
|
||
#region Constructors | ||
|
||
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); | ||
} | ||
|
||
#endregion Constructors | ||
|
||
#region Abstract Methods | ||
|
||
public abstract bool Process(TransformContext transformContext); | ||
|
||
#endregion Abstract Methods | ||
|
||
#region Internals | ||
|
||
int IComparable<BaseBlockTransform>.CompareTo(BaseBlockTransform other) | ||
{ | ||
return Priority.CompareTo(other.Priority); | ||
} | ||
|
||
#endregion Internals | ||
|
||
#region Block Helpers | ||
|
||
protected static void RemoveRemainingInstructionInBlock(Context context) | ||
{ | ||
BaseTransform.RemoveRemainingInstructionInBlock(context); | ||
} | ||
|
||
protected static BasicBlock GetOtherBranchTarget(BasicBlock block, BasicBlock target) | ||
{ | ||
return BaseTransform.GetOtherBranchTarget(block, target); | ||
} | ||
|
||
#endregion Block Helpers | ||
} |
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
Oops, something went wrong.