From patchwork Sat Dec 19 22:32:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/3] tcg: Add tcg_swap_cond. Date: Sat, 19 Dec 2009 12:32:11 -0000 From: Richard Henderson X-Patchwork-Id: 41479 Message-Id: <3c054d6ab4be20981dc0087da4f580035b08ae4c.1261260692.git.rth@twiddle.net> To: qemu-devel@nongnu.org Returns the condition as if with swapped comparison operands. --- tcg/tcg.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) 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