From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27838 invoked by alias); 13 Aug 2014 11:13:35 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 27817 invoked by uid 89); 13 Aug 2014 11:13:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 13 Aug 2014 11:13:33 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id B32483404AA for ; Wed, 13 Aug 2014 11:13:30 +0000 (UTC) From: Mike Frysinger To: binutils@sourceware.org Subject: [PATCH 2/3] opcodes: blackfin: simplify decode_CC2stat_0 logic Date: Wed, 13 Aug 2014 11:13:00 -0000 Message-Id: <1407928407-13270-2-git-send-email-vapier@gentoo.org> In-Reply-To: <1407928407-13270-1-git-send-email-vapier@gentoo.org> References: <1407928407-13270-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00100.txt.bz2 These multiple if statements can be condensed down into a single if statement and an array of strings. Signed-off-by: Mike Frysinger 2013-12-03 Mike Frysinger * bfin-dis.c (OUT): Define. (decode_CC2stat_0): Declare new op_names array. Replace multiple if statements with a single one. --- opcodes/bfin-dis.c | 46 +++++----------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c index e7d6706..ba33152 100644 --- a/opcodes/bfin-dis.c +++ b/opcodes/bfin-dis.c @@ -484,6 +484,7 @@ static const enum machine_registers decode_allregs[] = #ifndef OUTS #define OUTS(p, txt) (p)->fprintf_func ((p)->stream, "%s", txt) #endif +#define OUT(p, txt, ...) (p)->fprintf_func ((p)->stream, txt, ## __VA_ARGS__) static void amod0 (int s0, int x0, disassemble_info *outf) @@ -1224,6 +1225,7 @@ decode_CC2stat_0 (TIword iw0, disassemble_info *outf) int cbit = ((iw0 >> CC2stat_cbit_bits) & CC2stat_cbit_mask); const char *bitname = statbits (cbit); + const char * const op_names[] = { "", "|", "&", "^" } ; if (priv->parallel) return 0; @@ -1241,48 +1243,10 @@ decode_CC2stat_0 (TIword iw0, disassemble_info *outf) bitname = bitnames; } - if (op == 0 && D == 0) - { - OUTS (outf, "CC = "); - OUTS (outf, bitname); - } - else if (op == 1 && D == 0) - { - OUTS (outf, "CC |= "); - OUTS (outf, bitname); - } - else if (op == 2 && D == 0) - { - OUTS (outf, "CC &= "); - OUTS (outf, bitname); - } - else if (op == 3 && D == 0) - { - OUTS (outf, "CC ^= "); - OUTS (outf, bitname); - } - else if (op == 0 && D == 1) - { - OUTS (outf, bitname); - OUTS (outf, " = CC"); - } - else if (op == 1 && D == 1) - { - OUTS (outf, bitname); - OUTS (outf, " |= CC"); - } - else if (op == 2 && D == 1) - { - OUTS (outf, bitname); - OUTS (outf, " &= CC"); - } - else if (op == 3 && D == 1) - { - OUTS (outf, bitname); - OUTS (outf, " ^= CC"); - } + if (D == 0) + OUT (outf, "CC %s= %s", op_names[op], bitname); else - return 0; + OUT (outf, "%s %s= CC", bitname, op_names[op]); return 2; } -- 2.0.0