diff mbox

[1/2] tcg: Add tcg_swap_cond.

Message ID eb72f2f72a369835ba32ef26ee2ead895fd78549.1265751626.git.rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Feb. 9, 2010, 8:33 p.m. UTC
Returns the condition as if with swapped comparison operands.
---
 tcg/tcg.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tcg/tcg.h b/tcg/tcg.h
index b218abe..563eccd 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -205,11 +205,19 @@  typedef enum {
     TCG_COND_GTU,
 } TCGCond;
 
+/* Invert the sense of the comparison.  */
 static inline TCGCond tcg_invert_cond(TCGCond c)
 {
     return (TCGCond)(c ^ 1);
 }
 
+/* Swap the operands in a comparison.  */
+static inline TCGCond tcg_swap_cond(TCGCond c)
+{
+    int mask = (c < TCG_COND_LT ? 0 : c < TCG_COND_LTU ? 7 : 15);
+    return (TCGCond)(c ^ mask);
+}
+
 static inline TCGCond tcg_unsigned_cond(TCGCond c)
 {
     return (c >= TCG_COND_LT && c <= TCG_COND_GT ? c + 4 : c);