-
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
3 changed files
with
50 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
Source/Mosa.Compiler.x86/Transforms/Optimizations/Auto/Rewrite/Lea32RemoveScale.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,39 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
// This code was generated by an automated template. | ||
|
||
using Mosa.Compiler.Framework; | ||
|
||
namespace Mosa.Compiler.x86.Transforms.Optimizations.Auto.Rewrite; | ||
|
||
[Transform("x86.Optimizations.Auto.Rewrite")] | ||
public sealed class Lea32RemoveScale : BaseTransform | ||
{ | ||
public Lea32RemoveScale() : base(X86.Lea32, TransformType.Auto | TransformType.Optimization, true) | ||
{ | ||
} | ||
|
||
public override bool Match(Context context, Transform transform) | ||
{ | ||
if (!context.Operand2.IsConstantZero) | ||
return false; | ||
|
||
if (IsOne(context.Operand3)) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
public override void Transform(Context context, Transform transform) | ||
{ | ||
var result = context.Result; | ||
|
||
var t1 = context.Operand1; | ||
var t2 = context.GetOperand(3); | ||
|
||
var c1 = Operand.CreateConstant(0); | ||
var c2 = Operand.CreateConstant(1); | ||
|
||
context.SetInstruction(X86.Lea32, result, t1, c1, c2, t2); | ||
} | ||
} |