aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/CodeGen/X86/X86Condition.cs
diff options
context:
space:
mode:
authorFicture Seven <FICTURE7@gmail.com>2020-08-05 02:52:33 +0400
committerGitHub <noreply@github.com>2020-08-05 08:52:33 +1000
commitee22517d92c48eab9643b6fc8ce4dac2b7e95f57 (patch)
tree5df92a3e83f9daafba44ad11862683af8185ffaf /ARMeilleure/CodeGen/X86/X86Condition.cs
parenta33dc2f4919f7fdc8ea9db41c4c70c38cedfd3df (diff)
Improve branch operations (#1442)
* Add Compare instruction * Add BranchIf instruction * Use test when BranchIf & Compare against 0 * Propagate Compare into BranchIfTrue/False use - Propagate Compare operations into their BranchIfTrue/False use and turn these into a BranchIf. - Clean up Comparison enum. * Replace BranchIfTrue/False with BranchIf * Use BranchIf in EmitPtPointerLoad - Using BranchIf early instead of BranchIfTrue/False improves LCQ and reduces the amount of work needed by the Optimizer. EmitPtPointerLoader was a/the big producer of BranchIfTrue/False. - Fix asserts firing when assembling BitwiseAnd because of type mismatch in EmitStoreExclusive. This is harmless and should not cause any diffs. * Increment PPTC interval version * Improve IRDumper for BranchIf & Compare * Use BranchIf in EmitNativeCall * Clean up * Do not emit test when immediately preceded by and
Diffstat (limited to 'ARMeilleure/CodeGen/X86/X86Condition.cs')
-rw-r--r--ARMeilleure/CodeGen/X86/X86Condition.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/ARMeilleure/CodeGen/X86/X86Condition.cs b/ARMeilleure/CodeGen/X86/X86Condition.cs
index a17c6d6c..c82cbdec 100644
--- a/ARMeilleure/CodeGen/X86/X86Condition.cs
+++ b/ARMeilleure/CodeGen/X86/X86Condition.cs
@@ -1,3 +1,6 @@
+using ARMeilleure.IntermediateRepresentation;
+using System;
+
namespace ARMeilleure.CodeGen.X86
{
enum X86Condition
@@ -19,4 +22,26 @@ namespace ARMeilleure.CodeGen.X86
LessOrEqual = 0xe,
Greater = 0xf
}
+
+ static class ComparisonX86Extensions
+ {
+ public static X86Condition ToX86Condition(this Comparison comp)
+ {
+ return comp switch
+ {
+ Comparison.Equal => X86Condition.Equal,
+ Comparison.NotEqual => X86Condition.NotEqual,
+ Comparison.Greater => X86Condition.Greater,
+ Comparison.LessOrEqual => X86Condition.LessOrEqual,
+ Comparison.GreaterUI => X86Condition.Above,
+ Comparison.LessOrEqualUI => X86Condition.BelowOrEqual,
+ Comparison.GreaterOrEqual => X86Condition.GreaterOrEqual,
+ Comparison.Less => X86Condition.Less,
+ Comparison.GreaterOrEqualUI => X86Condition.AboveOrEqual,
+ Comparison.LessUI => X86Condition.Below,
+
+ _ => throw new ArgumentException(null, nameof(comp))
+ };
+ }
+ }
} \ No newline at end of file