From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13171 invoked by alias); 11 Feb 2016 16:59:26 -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 13152 invoked by uid 89); 11 Feb 2016 16:59:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:ca, UD:png, personal, stand 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; Thu, 11 Feb 2016 16:59:24 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id 15.8E.32102.3DDBCB65; Thu, 11 Feb 2016 17:59:00 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.98) with Microsoft SMTP Server id 14.3.248.2; Thu, 11 Feb 2016 11:59:21 -0500 Subject: Re: [PATCH 1/3] arm-tdep.c: Refactor arm_process_displaced_insn To: Yao Qi References: <1455121027-27061-1-git-send-email-simon.marchi@ericsson.com> <1455121027-27061-2-git-send-email-simon.marchi@ericsson.com> <86oabnpk4r.fsf@gmail.com> CC: From: Simon Marchi Message-ID: <56BCBDE9.1010106@ericsson.com> Date: Thu, 11 Feb 2016 16:59:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <86oabnpk4r.fsf@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00374.txt.bz2 On 16-02-11 06:21 AM, Yao Qi wrote: > Simon Marchi writes: > >> - if ((insn & 0xf0000000) == 0xf0000000) >> - err = arm_decode_unconditional (gdbarch, insn, regs, dsc); >> - else switch (((insn & 0x10) >> 4) | ((insn & 0xe000000) >> 24)) >> + cond = bits (insn, 28, 31); > > Variable 'cond' is only used once, so don't need to define it. This is > my personal flavour. Well, my goal was to use variables with names that refer to these tables: http://nova.polymtl.ca/~simark/ss/fileJVxJNx.png (ARM Architecture Reference Manual, section A5.1) If you only use the bits (insn, 28, 31) notation, I think you lose readability, because the you have to do one more indirection in the doc, to go see what those bits mean. >> + op1 = bits (insn, 25, 27); >> + op = bit (insn, 4); >> + >> + if (cond != 0xf) > > if (bits (insn, 28, 31) != INST_NV) > > this is consistent with other places in arm-tdep.c I agree, if there is a define for that it should be used. What does _NV stand for though? >> { >> - case 0x0: case 0x1: case 0x2: case 0x3: >> - err = arm_decode_dp_misc (gdbarch, insn, regs, dsc); >> - break; >> + switch (op1) >> + { >> + case 0x0: >> + case 0x1: >> + -/* Data-processing and miscellaneous instructions */ >> + err = arm_decode_dp_misc (gdbarch, insn, regs, dsc); >> + break; >> >> - case 0x4: case 0x5: case 0x6: >> - err = arm_decode_ld_st_word_ubyte (gdbarch, insn, regs, dsc); >> - break; >> + case 0x2: >> + /* Load/store word and unsigned byte */ >> + err = arm_decode_ld_st_word_ubyte (gdbarch, insn, regs, dsc); >> + break; >> >> - case 0x7: >> - err = arm_decode_media (gdbarch, insn, dsc); >> - break; >> + case 0x3: >> + if (op == 0) > > 'op' is only used here, let us define it in this block, or use > 'bit (insn, 4)' instead. Ok for moving it, but I would suggest keeping the variable op, for the same reason as cond mentioned above. Thanks, Simon