From patchwork Tue Feb 9 20:33:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 44963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7550BB7DBF for ; Wed, 10 Feb 2010 08:54:44 +1100 (EST) Received: from localhost ([127.0.0.1]:48148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NexvV-0004GJ-F8 for incoming@patchwork.ozlabs.org; Tue, 09 Feb 2010 16:47:21 -0500 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 Received: by are.twiddle.net (Postfix, from userid 5000) id 79C93C28; Tue, 9 Feb 2010 13:42:14 -0800 (PST) Message-Id: From: Richard Henderson Date: Tue, 9 Feb 2010 12:33:09 -0800 To: qemu-devel@nongnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 1/2] tcg: Add tcg_swap_cond. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 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);