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
5 changed files
with
55 additions
and
13 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
48 changes: 48 additions & 0 deletions
48
Source/Mosa.Compiler.x86/Transforms/Optimizations/Manual/Special/Mul32Ditto.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,48 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using Mosa.Compiler.Framework; | ||
|
||
namespace Mosa.Compiler.x86.Transforms.Optimizations.Manual.Special; | ||
|
||
[Transform("x86.Optimizations.Manual.Special")] | ||
public sealed class Mul32Ditto : BaseTransform | ||
{ | ||
public Mul32Ditto() : base(X86.Mul32, TransformType.Manual | TransformType.Optimization) | ||
{ | ||
} | ||
|
||
public override bool Match(Context context, TransformContext transform) | ||
{ | ||
if (transform.AreCPURegistersAllocated) | ||
return false; | ||
|
||
if (!context.Result.IsVirtualRegister) | ||
return false; | ||
|
||
if (!context.Result2.IsVirtualRegister) | ||
return false; | ||
|
||
var previous = context.Node.PreviousNonEmpty; | ||
|
||
if (previous == null || previous.Instruction != X86.Mul32) | ||
return false; | ||
|
||
if (context.Operand1 != previous.Operand1) | ||
return false; | ||
|
||
if (context.Operand2 != previous.Operand2) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
public override void Transform(Context context, TransformContext transform) | ||
{ | ||
var previous = context.Node.PreviousNonEmpty; | ||
var result = context.Result; | ||
var result2 = context.Result2; | ||
|
||
context.SetInstruction(X86.Mov32, result, previous.Result); | ||
context.AppendInstruction(X86.Mov32, result2, previous.Result2); | ||
} | ||
} |