From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4720 invoked by alias); 25 Jul 2014 17:02:05 -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 4599 invoked by uid 89); 25 Jul 2014 17:02:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp11.uk.ibm.com Received: from e06smtp11.uk.ibm.com (HELO e06smtp11.uk.ibm.com) (195.75.94.107) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 25 Jul 2014 17:02:01 +0000 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 Jul 2014 18:01:58 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 25 Jul 2014 18:01:56 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 581012190056 for ; Fri, 25 Jul 2014 18:01:41 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6PH1uJs15597670 for ; Fri, 25 Jul 2014 17:01:56 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6PH1tuM023220 for ; Fri, 25 Jul 2014 11:01:56 -0600 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s6PH1r7D023174; Fri, 25 Jul 2014 11:01:54 -0600 From: Andreas Arnez To: binutils@sourceware.org Cc: Martin Schwidefsky , Andreas Krebbel Subject: [PATCH 4/6] S/390: Simplify opcode search loop in disassembler Date: Fri, 25 Jul 2014 17:02:00 -0000 Message-Id: <1406307713-7926-5-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1406307713-7926-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1406307713-7926-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14072517-5024-0000-0000-000000CC000C X-SW-Source: 2014-07/txt/msg00204.txt.bz2 opcodes/ * s390-dis.c (print_insn_s390): Simplify the opcode search loop. Check architecture mask against all searched opcodes, not just the first matching one. --- opcodes/s390-dis.c | 52 +++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/opcodes/s390-dis.c b/opcodes/s390-dis.c index e6b0ee5..029f9f1 100644 --- a/opcodes/s390-dis.c +++ b/opcodes/s390-dis.c @@ -229,8 +229,7 @@ int print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info) { bfd_byte buffer[6]; - const struct s390_opcode *opcode; - const struct s390_opcode *opcode_end; + const struct s390_opcode *opcode = NULL; unsigned int value; int status, opsize, bufsize; @@ -266,41 +265,28 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info) { const struct s390_opcode *op; - /* Find the first match in the opcode table. */ - opcode_end = s390_opcodes + s390_num_opcodes; - for (opcode = s390_opcodes + opc_index[(int) buffer[0]]; - (opcode < opcode_end) && (buffer[0] == opcode->opcode[0]); - opcode++) + /* Find the "best match" in the opcode table. */ + for (op = s390_opcodes + opc_index[buffer[0]]; + op != s390_opcodes + s390_num_opcodes + && op->opcode[0] == buffer[0]; + op++) { - /* Check architecture. */ - if (!(opcode->modes & current_arch_mask)) - continue; - - if (!s390_insn_matches_opcode (buffer, opcode)) - continue; - - /* Advance to an opcode with a more specific mask. */ - for (op = opcode + 1; op < opcode_end; op++) - { - if ((buffer[0] & op->mask[0]) != op->opcode[0]) - break; - - if (!s390_insn_matches_opcode (buffer, op)) - continue; - - if (opcode_mask_more_specific (op, opcode)) - opcode = op; - } - - /* The instruction is valid. */ - s390_print_insn_with_opcode (memaddr, info, buffer, opcode); - - /* Found instruction, printed it, return its size. */ - return opsize; + if ((op->modes & current_arch_mask) + && s390_insn_matches_opcode (buffer, op) + && (opcode == NULL + || opcode_mask_more_specific (op, opcode))) + opcode = op; } - /* No matching instruction found, fall through to hex print. */ } + if (opcode != NULL) + { + /* The instruction is valid. Print it and return its size. */ + s390_print_insn_with_opcode (memaddr, info, buffer, opcode); + return opsize; + } + + /* Fall back to hex print. */ if (bufsize >= 4) { value = (unsigned int) buffer[0]; -- 1.8.4.2