From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102175 invoked by alias); 10 Feb 2016 16:17:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 102105 invoked by uid 89); 10 Feb 2016 16:17:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=0x01, 0x04, 0x08, bfi X-HELO: usplmg21.ericsson.net Received: from usplmg21.ericsson.net (HELO usplmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 10 Feb 2016 16:17:31 +0000 Received: from EUSAAHC002.ericsson.se (Unknown_Domain [147.117.188.78]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id 24.39.32102.A726BB65; Wed, 10 Feb 2016 17:16:58 +0100 (CET) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.78) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 10 Feb 2016 11:17:15 -0500 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 3/3] arm-tdep.c: Refactor arm_decode_media Date: Wed, 10 Feb 2016 16:17:00 -0000 Message-ID: <1455121027-27061-4-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1455121027-27061-1-git-send-email-simon.marchi@ericsson.com> References: <1455121027-27061-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00303.txt.bz2 Refactor arm_decode_media to make it more readable. The new layout matches very closely the description in the ARM Architecture Reference Manual. It uses the same order and same nomenclature. gdb/ChangeLog: * arm-tdep.c (arm_decode_media): Refactor instruction decoding. --- gdb/arm-tdep.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index e17a1a4..bf5bc49 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -6625,49 +6625,63 @@ static int arm_decode_media (struct gdbarch *gdbarch, uint32_t insn, struct displaced_step_closure *dsc) { - switch (bits (insn, 20, 24)) + uint8_t op1 = bits (insn, 20, 24); + uint8_t rd = bits (insn, 12, 15); + uint8_t op2 = bits (insn, 5, 7); + uint8_t rn = bits (insn, 0, 3); + + switch (op1) { case 0x00: case 0x01: case 0x02: case 0x03: + /* Parallel addition and subtraction, signed */ return arm_copy_unmodified (gdbarch, insn, "parallel add/sub signed", dsc); case 0x04: case 0x05: case 0x06: case 0x07: + /* Parallel addition and subtraction, unsigned */ return arm_copy_unmodified (gdbarch, insn, "parallel add/sub unsigned", dsc); case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: + /* Packing, unpacking, saturation, and reversal */ return arm_copy_unmodified (gdbarch, insn, "decode/pack/unpack/saturate/reverse", dsc); case 0x18: - if (bits (insn, 5, 7) == 0) /* op2. */ + if (op2 == 0) { - if (bits (insn, 12, 15) == 0xf) + if (rd == 0xf) + /* USAD8 */ return arm_copy_unmodified (gdbarch, insn, "usad8", dsc); else + /* USADA8 */ return arm_copy_unmodified (gdbarch, insn, "usada8", dsc); } else - return arm_copy_undef (gdbarch, insn, dsc); + return arm_copy_undef (gdbarch, insn, dsc); case 0x1a: case 0x1b: - if (bits (insn, 5, 6) == 0x2) /* op2[1:0]. */ + if ((op2 & 0x3) == 0x2) + /* SBFX */ return arm_copy_unmodified (gdbarch, insn, "sbfx", dsc); else return arm_copy_undef (gdbarch, insn, dsc); case 0x1c: case 0x1d: - if (bits (insn, 5, 6) == 0x0) /* op2[1:0]. */ + if ((op2 & 0x3) == 0x0) { - if (bits (insn, 0, 3) == 0xf) + if (rn == 0xf) + /* BFC */ return arm_copy_unmodified (gdbarch, insn, "bfc", dsc); else + /* BFI */ return arm_copy_unmodified (gdbarch, insn, "bfi", dsc); } else return arm_copy_undef (gdbarch, insn, dsc); case 0x1e: case 0x1f: - if (bits (insn, 5, 6) == 0x2) /* op2[1:0]. */ + if ((op2 & 0x3) == 0x2) + /* UBFX */ return arm_copy_unmodified (gdbarch, insn, "ubfx", dsc); else return arm_copy_undef (gdbarch, insn, dsc); -- 2.5.1