[1/3] tcg: Add tcg_swap_cond.

Submitted by Richard Henderson on Dec. 19, 2009, 10:32 p.m.

Details

Message ID 3c054d6ab4be20981dc0087da4f580035b08ae4c.1261260692.git.rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Dec. 19, 2009, 10:32 p.m.
Returns the condition as if with swapped comparison operands.
---
 tcg/tcg.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tcg/tcg.h b/tcg/tcg.h
index 376d6af..ac38390 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);
+}
+
 #define TEMP_VAL_DEAD  0
 #define TEMP_VAL_REG   1
 #define TEMP_VAL_MEM   2