From patchwork Mon Aug 19 21:37:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171689 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3547722ily; Mon, 19 Aug 2019 15:02:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXPZN1yzEoDLh1BOBj+vK8xCLOzG/Bn2opMHgIaiRxY11Cm67PwaSWCCxusvg/Ms21kUk8 X-Received: by 2002:aa7:df03:: with SMTP id c3mr27543844edy.112.1566252176360; Mon, 19 Aug 2019 15:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566252176; cv=none; d=google.com; s=arc-20160816; b=Nnf1oa52N3Vncll9zoxZ4X2owrk7gyzNNxNw3J0QSk5lL+/1lCTQcjyd3IC5zPfkhh G4xaUBUXc1Ofv/lWuUsD6KTk7FrB+xSm1LclJCYJLd/kBPn+DcdTBF3SCIdUFZUNE1Rd OMKFM5Xc6jxSyB6WdDMu2WzW2I4GWkKZQXGttEHOm+sng8q0s2HC2tYnhbkzAGHHu7SQ nTxOWyeJ1ttjiscVaBLoELTTCLrZchLsGg95vboksZdTYi+YPjQ4CyA7rt9qRNZzagWD McsOEsT0sCzxFI9D4Y5Q/aP19QZ4RK0vedvceDhSn4J5jkQ1Q0qQsfEX5uZMtiI5e0vw 6Kew== 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=4oWyeRO7VGSUxbfq5SQ/Ttd5DuqgQfk+9PyV2J/44KI=; b=mo6RCAmodDNy04zD5dvL0tSo/+a6//oupeUcQQrh4AZi4aBxTiYNLExaS5zU9vftPJ dqs1yRfkXbI43T2mxitqTJoDlv762Bsx7/LHaNG+Xf5Gti3GdlTnGDpTzrwYnAVybBoz 90KlJki0qLxICpQ8BDO95fcJ3ddibAS2rtMba1pSrY7C3Un0d6IiySx/uUFu0WnsNYdI ZqsYHO0/h1KlSglIu90DyACKAzG1F/LcMrxYO6t4RRcT0c0Uti5LvgwR0V/dMj+3ROky oHv1K3H2+W4H/Qc/dWD52c1T/HdEsgp2Xe8EgJ+oIJw/pcwJL/5iRQO4LaKUpwD9Cnim yjDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Drn5lIP0; 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 j50si9346793ede.66.2019.08.19.15.02.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 15:02:56 -0700 (PDT) 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=Drn5lIP0; 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 ([::1]:59418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpjq-0008QD-U1 for patch@linaro.org; Mon, 19 Aug 2019 18:02:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59474) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpMX-0002Nn-AD for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzpMU-0006Vw-UP for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:49 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:37319) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzpMU-0006V9-Ok for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:46 -0400 Received: by mail-pl1-x62c.google.com with SMTP id bj8so1586758plb.4 for ; Mon, 19 Aug 2019 14:38:46 -0700 (PDT) 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=4oWyeRO7VGSUxbfq5SQ/Ttd5DuqgQfk+9PyV2J/44KI=; b=Drn5lIP0XEn3UHgMzXP+UrnGrtO4PcM2S5eHx1MB/XvLft3S26wpbgY6YWxiEZU47P j/WsmtsegP82//AY+U5OjxHLXJumJCU4BAXOTWV3/vApTXI1xg/wVX+wFcGmbsAnBIRj qT+wdPJuEI+AX6lRr4H/Gz15yOZqTHWjqYw+bI3hvd/u6CBFCbd5ovtlXJwcff6tZp8c eUWd+ZBUUn+YcmG/pXqjM7BaBb5c4/HhFIeOY1RqOrgWyLkQNxKOWXS0mvY06Bg7/pte ToYvZmioZHUtDvQnAcvnnpq7i4zLdj8CQ/QnLts8YfDV68V1PwmuuI36/fl+Jh8cEybQ AZWA== 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=4oWyeRO7VGSUxbfq5SQ/Ttd5DuqgQfk+9PyV2J/44KI=; b=gVICezs2t3grFKSX2rX517ZRO9hTB2bA3lVXEG3Ab1zoVfgr7KJgg/022t4IDa5ahR O8djM/0dey6/+YWiP2vk0J5G5b5n44fG8lyfMHFVCH/y/R5s4AHzq1B0T59OfjzM3jc7 Y16YnxDTfpYdm+ReC60uywf1fdcxTon0+FnTRJhrIPibCq6cmIkS4kDo6c/9Sg4gAKwA VVSPSFSNHBKL3zAbtyKdBnmxfO/k3/PX1110VCeFJcPBot4QJUw8eh/kfOG51OyYGE0v BVu7q77ZYGh/LhCeo32GQFwvGmuCqBTO3KqqiwxeiLhw2Grkq0R8fa6atbvUgEceBRUB 7FKg== X-Gm-Message-State: APjAAAXITkjlQvocOFEIPcia6OMIPG0H9OHQc6I3QqMhb7d3DHdvFS/I ot3QKIHjWSd4EX1+aZw+ZPJeBjA0iBU= X-Received: by 2002:a17:902:a509:: with SMTP id s9mr25303891plq.310.1566250725114; Mon, 19 Aug 2019 14:38:45 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d2sm13446951pjs.21.2019.08.19.14.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 14:38:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 14:37:26 -0700 Message-Id: <20190819213755.26175-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819213755.26175-1-richard.henderson@linaro.org> References: <20190819213755.26175-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::62c Subject: [Qemu-devel] [PATCH v2 39/68] target/arm: Convert Table Branch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/translate.c | 57 +++++++++++++++++++++++++----------------- target/arm/t32.decode | 8 +++++- 2 files changed, 41 insertions(+), 24 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/translate.c b/target/arm/translate.c index 9ec6b25c03..7c05e7006e 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9968,6 +9968,37 @@ static bool trans_BLX_i(DisasContext *s, arg_BLX_i *a) return true; } +static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) +{ + TCGv_i32 addr, tmp; + + tmp = load_reg(s, a->rm); + if (half) { + tcg_gen_add_i32(tmp, tmp, tmp); + } + addr = load_reg(s, a->rn); + tcg_gen_add_i32(addr, addr, tmp); + + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), + half ? MO_UW | s->be_data : MO_UB); + tcg_temp_free_i32(addr); + + tcg_gen_add_i32(tmp, tmp, tmp); + tcg_gen_addi_i32(tmp, tmp, read_pc(s)); + store_reg(s, 15, tmp); + return true; +} + +static bool trans_TBB(DisasContext *s, arg_tbranch *a) +{ + return op_tbranch(s, a, false); +} + +static bool trans_TBH(DisasContext *s, arg_tbranch *a) +{ + return op_tbranch(s, a, true); +} + /* * Supervisor call */ @@ -10350,9 +10381,7 @@ static bool thumb_insn_is_16bit(DisasContext *s, uint32_t pc, uint32_t insn) /* Translate a 32-bit thumb instruction. */ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) { - uint32_t rd, rn, rm, rs; - TCGv_i32 tmp; - TCGv_i32 addr; + uint32_t rd, rn, rs; int op; /* @@ -10398,7 +10427,6 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; - rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: /* 16-bit instructions. Should never happen. */ @@ -10471,25 +10499,8 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) /* Load/store exclusive, in decodetree */ goto illegal_op; } else if ((insn & (7 << 5)) == 0) { - /* Table Branch. */ - addr = load_reg(s, rn); - tmp = load_reg(s, rm); - tcg_gen_add_i32(addr, addr, tmp); - if (insn & (1 << 4)) { - /* tbh */ - tcg_gen_add_i32(addr, addr, tmp); - tcg_temp_free_i32(tmp); - tmp = tcg_temp_new_i32(); - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); - } else { /* tbb */ - tcg_temp_free_i32(tmp); - tmp = tcg_temp_new_i32(); - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); - } - tcg_temp_free_i32(addr); - tcg_gen_shli_i32(tmp, tmp, 1); - tcg_gen_addi_i32(tmp, tmp, read_pc(s)); - store_reg(s, 15, tmp); + /* Table Branch, in decodetree */ + goto illegal_op; } else { /* Load/store exclusive, load-acq/store-rel, in decodetree */ goto illegal_op; diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 354ad77fe6..0cc0808c05 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -487,7 +487,7 @@ LDRD_ri_t32 1110 1001 .101 .... .... .... ........ @ldstd_ri8 w=0 p=1 STRD_ri_t32 1110 1001 .110 .... .... .... ........ @ldstd_ri8 w=1 p=1 LDRD_ri_t32 1110 1001 .111 .... .... .... ........ @ldstd_ri8 w=1 p=1 -# Load/Store Exclusive and Load-Acquire/Store-Release +# Load/Store Exclusive, Load-Acquire/Store-Release, and Table Branch @strex_i .... .... .... rn:4 rt:4 rd:4 .... .... \ &strex rt2=15 imm=%imm8x4 @@ -531,6 +531,12 @@ LDA 1110 1000 1101 .... .... 1111 1010 1111 @ldrex_0 LDAB 1110 1000 1101 .... .... 1111 1000 1111 @ldrex_0 LDAH 1110 1000 1101 .... .... 1111 1001 1111 @ldrex_0 +&tbranch rn rm +@tbranch .... .... .... rn:4 .... .... .... rm:4 &tbranch + +TBB 1110 1000 1101 .... 1111 0000 0000 .... @tbranch +TBH 1110 1000 1101 .... 1111 0000 0001 .... @tbranch + # Parallel addition and subtraction SADD8 1111 1010 1000 .... 1111 .... 0000 .... @rndm