forked from mosa/MOSA-Project
-
Notifications
You must be signed in to change notification settings - Fork 4
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
10 changed files
with
625 additions
and
527 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
53 changes: 53 additions & 0 deletions
53
Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/StoreLoadObject.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,53 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
namespace Mosa.Compiler.Framework.Transforms.Optimizations.Manual.Special; | ||
|
||
public sealed class StoreLoadObject : BaseTransform | ||
{ | ||
public StoreLoadObject() : base(IRInstruction.StoreObject, TransformType.Manual | TransformType.Optimization) | ||
{ | ||
} | ||
|
||
public override bool Match(Context context, TransformContext transform) | ||
{ | ||
if (!context.Operand2.IsLocalStack) | ||
return false; | ||
|
||
if (!context.Operand1.IsCPURegister) | ||
return false; | ||
|
||
if (context.Operand1 != transform.StackFrame) | ||
return false; | ||
|
||
if (context.Operand2.Uses.Count != 2) // FUTURE: traverse all uses | ||
return false; | ||
|
||
if (!context.Operand3.IsDefinedOnce) | ||
return false; | ||
|
||
var load = context.Operand2.Uses[0] != context.Node | ||
? context.Operand2.Uses[0] | ||
: context.Operand2.Uses[1]; | ||
|
||
if (load.Instruction != IRInstruction.LoadManagedPointer) | ||
return false; | ||
|
||
if (!context.Operand3.IsDefinedOnce) | ||
return false; | ||
|
||
if (load.Operand1 != transform.StackFrame) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
public override void Transform(Context context, TransformContext transform) | ||
{ | ||
var load = context.Operand2.Uses[0] != context.Node | ||
? context.Operand2.Uses[0] | ||
: context.Operand2.Uses[1]; | ||
|
||
context.SetInstruction(IRInstruction.MoveObject, load.Result, context.Operand3); | ||
load.SetNop(); | ||
} | ||
} |
Oops, something went wrong.