From patchwork Wed Feb 20 05:04:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158761 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4495817jaa; Tue, 19 Feb 2019 21:05:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGkD9BMn8nUEh2t3mc2iNy2gA6V8hnXKU7W0TfzR3qvGYsFBhPy1G4+ft4cp+TvHL9GKjX X-Received: by 2002:a5b:a8e:: with SMTP id h14mr13443382ybq.105.1550639129438; Tue, 19 Feb 2019 21:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550639129; cv=none; d=google.com; s=arc-20160816; b=lts6OOUiFZNA1IDjiYVPEmf0zYj3TpHgzsr51jBWafAqjUTSL9CcODbBMRB233gg+p YGUjzD4flx7DJaf+Lc+FIyYCeSFvFc3lI5c0nIvUlCOlg7mjlY2lyB6gmluC4UCPYKTZ sQ7+9dVJoAGjsF25zoEmtgVHaBpivcwDKD6KGgPJwJQF7+hlecJnMgMllqTg+rY7s8Q8 V8Xg7URRw2IT2nm0NnNpEgWhyw2/Ds5RH8wplV4NXron5J00KDKzTkIDzQwASNWcQ5Nl 0uRnHvsTZnqlwc8xt9c1Kc4sopCHRCjJQtQVlioK4lhlyqqR9+0PCS33f0/WmGbJzsXg A30g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=MjTYCeNUm+JYCExjYhxWQqZvxq9w8zwkpl2DdNOcx+U=; b=WOThx4nLiB9UoI90JuoUtrzjewqCxpf1CcqI/4x7PFUG5fVZX0Fq8QuQcgr4lkdnoD moBGky1Wqw0+q00/9IVZfm2M/ajFl4T6MfKnaGpb0QrVlYVTwv0P7lw8tMyi2zlARHDT Bv/9AJMRiq5IJGGQHwmOo7Xgb/mak3zNjyOISwyvEFtu6YXhb2pE+B1XwEMU9d+R6c5l SQ7CG+fvGi7qa/kywaheM0YvUZ7aq8TkMk3UlfVkoSQ6pioCtnG5sCsxhV6NQnG/Fk+l yxTMNlOZ8QYVcTuE1N2BJRC7Pav2zvdibnJ4kne9OAY9sNeBLhPlb8v6itvJBxmm8WVC LZIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F9udte9D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w2si10739431ywe.142.2019.02.19.21.05.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Feb 2019 21:05:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F9udte9D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:33948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwK4W-0003ty-Lo for patch@linaro.org; Wed, 20 Feb 2019 00:05:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwK44-0003tK-3C for qemu-devel@nongnu.org; Wed, 20 Feb 2019 00:05:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwK43-0004xo-0Q for qemu-devel@nongnu.org; Wed, 20 Feb 2019 00:05:00 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:43815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwK41-0004wP-9P for qemu-devel@nongnu.org; Wed, 20 Feb 2019 00:04:58 -0500 Received: by mail-pl1-x632.google.com with SMTP id m10so1912758plt.10 for ; Tue, 19 Feb 2019 21:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MjTYCeNUm+JYCExjYhxWQqZvxq9w8zwkpl2DdNOcx+U=; b=F9udte9DT0sddn+ZneTRM5X7JuyXsGA+6f2d9TZklngtFt2EoLr0ppRR9CdlgxoQF+ cvIbBDf/QNWsvIJVGBZNAu3cBhWQOQaJ29jTl3acO5P5NgRbCKsaSV81kmt7usBHY8de KBqZEIvsUKLcyTXW1KMGrVYqirkBxGOltiALKLjcDUdr9zPwGgtUsHeBGCI+DN9HrOP+ 8HBrUONENFdfncHohf7TXBNeiGry41l2EH1lQBq/18m4h6e16yXtTZubZGggChCkfKsY MJd+5aX0isdliNCHuNwkxBM+NFXS9+oBKn8Zl+B3nx8B39Z206YJqJxFMmJJp7wbfHvB 9eMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MjTYCeNUm+JYCExjYhxWQqZvxq9w8zwkpl2DdNOcx+U=; b=f0YDJdDvMYoggnO7H5uvRbv3m74JBGi38irsDjXTjWJRCfTfK4CkxGiBt+uo0xEHgu gnXegS256TaPc8EqD3EW7LouwRoTogkq/jgaCgCk8f5cOkc1SnAZZljfqqbm3FitT9q0 JV8aT0BPZdIq0LrM9JYlXGTXSP4saSB5n7cdEbSAZijbU5k4u5F/epvQt43DKPPnvuwp xOMLD34m2/CmXja8xPgKe7CHcE6k6lVybVFc1v3AfoeRLVvoUuFwM8265RFfncSlgNui oczfs8ojFB7nP0QNSHRYTqUpt0FiP9rB5erXO6s04DitB2aQ/Zk5wcwp3DzwoJ/BOIPY ltdw== X-Gm-Message-State: AHQUAuZxtbIpZzrfF74LCUFZTjAz1BF1ejB82DMyixea2jY9cdUKzyJK QFURej4d4+KjZ7wmPhS2XO7oy7IljWI= X-Received: by 2002:a17:902:be15:: with SMTP id r21mr32354491pls.143.1550639095491; Tue, 19 Feb 2019 21:04:55 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w10sm25228143pge.8.2019.02.19.21.04.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 21:04:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Feb 2019 21:04:49 -0800 Message-Id: <20190220050451.10939-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190220050451.10939-1-richard.henderson@linaro.org> References: <20190220050451.10939-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::632 Subject: [Qemu-devel] [PATCH 1/3] target/arm: Rearrange disas_data_proc_reg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This decoding more closely matches the ARMv8.4 Table C4-6, Encoding table for Data Processing - Register Group. In particular, op2 == 0 is now more than just Add/sub (with carry). Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 98 ++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-) -- 2.17.2 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 951c8f4129..0e16487be0 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4694,11 +4694,10 @@ static void disas_data_proc_3src(DisasContext *s, uint32_t insn) } /* Add/subtract (with carry) - * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 - * +--+--+--+------------------------+------+---------+------+-----+ - * |sf|op| S| 1 1 0 1 0 0 0 0 | rm | opcode2 | Rn | Rd | - * +--+--+--+------------------------+------+---------+------+-----+ - * [000000] + * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 + * +--+--+--+------------------------+------+-------------+------+-----+ + * |sf|op| S| 1 1 0 1 0 0 0 0 | rm | 0 0 0 0 0 0 | Rn | Rd | + * +--+--+--+------------------------+------+-------------+------+-----+ */ static void disas_adc_sbc(DisasContext *s, uint32_t insn) @@ -4706,11 +4705,6 @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn) unsigned int sf, op, setflags, rm, rn, rd; TCGv_i64 tcg_y, tcg_rn, tcg_rd; - if (extract32(insn, 10, 6) != 0) { - unallocated_encoding(s); - return; - } - sf = extract32(insn, 31, 1); op = extract32(insn, 30, 1); setflags = extract32(insn, 29, 1); @@ -5397,47 +5391,69 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) } } -/* Data processing - register */ +/* + * Data processing - register + * 31 30 29 28 25 21 20 16 10 0 + * +--+---+--+---+-------+-----+-------+-------+---------+ + * | |op0| |op1| 1 0 1 | op2 | | op3 | | + * +--+---+--+---+-------+-----+-------+-------+---------+ + */ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) { - switch (extract32(insn, 24, 5)) { - case 0x0a: /* Logical (shifted register) */ - disas_logic_reg(s, insn); - break; - case 0x0b: /* Add/subtract */ - if (insn & (1 << 21)) { /* (extended register) */ - disas_add_sub_ext_reg(s, insn); + int op0 = extract32(insn, 30, 1); + int op1 = extract32(insn, 28, 1); + int op2 = extract32(insn, 21, 4); + int op3 = extract32(insn, 10, 6); + + if (!op1) { + if (op2 & 8) { + if (op2 & 1) { + /* Add/sub (extended register) */ + disas_add_sub_ext_reg(s, insn); + } else { + /* Add/sub (shifted register) */ + disas_add_sub_reg(s, insn); + } } else { - disas_add_sub_reg(s, insn); + /* Logical (shifted register) */ + disas_logic_reg(s, insn); } - break; - case 0x1b: /* Data-processing (3 source) */ - disas_data_proc_3src(s, insn); - break; - case 0x1a: - switch (extract32(insn, 21, 3)) { - case 0x0: /* Add/subtract (with carry) */ + return; + } + + switch (op2) { + case 0x0: + switch (op3) { + case 0x00: /* Add/subtract (with carry) */ disas_adc_sbc(s, insn); break; - case 0x2: /* Conditional compare */ - disas_cc(s, insn); /* both imm and reg forms */ - break; - case 0x4: /* Conditional select */ - disas_cond_select(s, insn); - break; - case 0x6: /* Data-processing */ - if (insn & (1 << 30)) { /* (1 source) */ - disas_data_proc_1src(s, insn); - } else { /* (2 source) */ - disas_data_proc_2src(s, insn); - } - break; + default: - unallocated_encoding(s); - break; + goto do_unallocated; } break; + + case 0x2: /* Conditional compare */ + disas_cc(s, insn); /* both imm and reg forms */ + break; + + case 0x4: /* Conditional select */ + disas_cond_select(s, insn); + break; + + case 0x6: /* Data-processing */ + if (op0) { /* (1 source) */ + disas_data_proc_1src(s, insn); + } else { /* (2 source) */ + disas_data_proc_2src(s, insn); + } + break; + case 0x8 ... 0xf: /* (3 source) */ + disas_data_proc_3src(s, insn); + break; + default: + do_unallocated: unallocated_encoding(s); break; }