OSDN Git Service

tcg: Add tcg_swap_cond.
authorRichard Henderson <rth@twiddle.net>
Tue, 9 Feb 2010 20:33:09 +0000 (12:33 -0800)
committerBlue Swirl <blauwirbel@gmail.com>
Tue, 16 Feb 2010 17:52:12 +0000 (17:52 +0000)
Returns the condition as if with swapped comparison operands.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
tcg/tcg.h

index b218abe..563eccd 100644 (file)
--- 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);