Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nexqe-0002aE-Mf for qemu-devel@nongnu.org; Tue, 09 Feb 2010 16:42:20 -0500 Received: from [199.232.76.173] (port=49440 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nexqb-0002X2-RN for qemu-devel@nongnu.org; Tue, 09 Feb 2010 16:42:17 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nexqa-0003od-M1 for qemu-devel@nongnu.org; Tue, 09 Feb 2010 16:42:17 -0500 Received: from are.twiddle.net ([75.149.56.221]:60028) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NexqZ-0003oC-NH for qemu-devel@nongnu.org; Tue, 09 Feb 2010 16:42:15 -0500 Message-Id: From: Richard Henderson Date: Tue, 9 Feb 2010 12:33:09 -0800 Subject: [Qemu-devel] [PATCH 1/2] tcg: Add tcg_swap_cond. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com 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 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); -- 1.6.6