From patchwork Wed Sep 4 19:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172990 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp372536ilq; Wed, 4 Sep 2019 12:57:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkwUCZOQ7h7IREPV8a5paAjiHRQzKWBg9RRCgct80s28+hWCD4VF086N8Sf1WZxKSW6kte X-Received: by 2002:a37:6358:: with SMTP id x85mr30998805qkb.229.1567627046023; Wed, 04 Sep 2019 12:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567627046; cv=none; d=google.com; s=arc-20160816; b=odceCW/TSCAzRrKBHYXNHydK4HUDPTvF9aIhdY3iAjCcv87Ss+0wfXhiuwSqPsj1uU kDzrR+4OYmlOF9Qnlqjc4uaz+dcj1ijB3+4DsdJZCAfeLiR+nW8BjunOFMG5eB/e1r9o Vnn50UwaQ8/sw/FL4Gmn40H4z5mtplC3oVO5Tj2Xxi4o0pLFmLNN78+rNAHO+guiho5q Nscyd2ucA9LvmLGxEKKJr4sBDLfmSRptcLb9KzMcOCl+rEHhubLoQ8er9zeCkoMJwSJG I1rMrX9queZdJgCM3xwOGYrt3lFC3Ykvdvyitmd7h6eOZ54Y+ZbuZkuxidEOsFSpYmV4 rn3g== 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=g/QDb2kvmqcOm71+AOuMbvaZW1g+/6rTDU0HkFA7so8=; b=o5Q3ak+Gl7A9RhSO9E3N3GAxhwTnMgGH099FlCbClorFw/gEs+l774MbrFkdAQEcwJ VkmiPu/g7k7yjZxwYsBFufd/vqlbSv+ymXLl2B7tlpa1Py9C7LNcHMxHKEa031hqwCaB gCjM0+82c3rrpKL2xrsETbnKHWVG3LihKF403k7s12qvwSJv+GZd74hKBOmDvEpj7BsF TW5jsUyo26PY4zt8OjA7JkCNRGGtkx46qsYRM4R245uSvEAYkUGWsLmXLkUQb/pNpn5m 8K6BxamHz10uCOleLVTpBAByZLo142fCBtefpKzhnOusH0vBu6jdc+7O2xNefDqg1lu1 7kGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EE+5fAWr; 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 q136si14770189qke.342.2019.09.04.12.57.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 12:57:26 -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=EE+5fAWr; 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]:38034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5bPA-0006iG-OV for patch@linaro.org; Wed, 04 Sep 2019 15:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40337) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5b0G-0004pT-Qp for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5b0E-0002XU-1D for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:40 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5b0D-0002Wj-Kg for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:37 -0400 Received: by mail-pl1-x643.google.com with SMTP id f19so7524plr.3 for ; Wed, 04 Sep 2019 12:31:37 -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=g/QDb2kvmqcOm71+AOuMbvaZW1g+/6rTDU0HkFA7so8=; b=EE+5fAWrJbdaUB+8b9wkCmqR6WzEPJ+vHmw1zHyCeAjQ5I4FxnmF+Ejod0TAAyN9ru q/b5vAoqMPI167hBWEKK3DEV/5ZCfEkkyPljC3KLhoecJUFSO5ZQ3g+p64kNnCtyw+aM DuhApSZ0mwVgjKz1TE85P+rU1yweAsf23RyUH21U8Q02rwNB3/m/0JkEUdA6RM2NWB7B M8TTdl7hs5rfw89zai4aOk7HRxEYjWFfvZWmcpzR8Rr9luaoretfzUxHgm0UXXjjcZb/ voGsMS+quwR2OOQfTZHxY7oZxRcZv0Es5gT2Uuw2TwFeRzDDtTqgRnMlOR9dOpaG/96U wpvw== 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=g/QDb2kvmqcOm71+AOuMbvaZW1g+/6rTDU0HkFA7so8=; b=frcXLqbj4HqtLtdcarKQqFJBQJt0ieBZK3TCIX/hj0FgOaQWxFE2dc0qO5/TcPhmYs zLpeZGZHQkwfslNG7FdejprlK//LW2OnUKNJETEBQUpnUzdLWLADV253gATcFXwTBwzo gZ3Z+khtyGoy+CV0fGninSoBTsM38ywHYbd+Toluw+HFtgOf4KcDnGYPZgS+9O4E343M zpwiPA65HcfUeCn49Vnt/XtGZKD/t/9+wzuYQ+WDlrGzJQNaV4x/b+4mlC1ecVhbdda+ ge06P8YHfgr2GTUiQTzKDYgRMaEzSIpTYqRmKynjuyl96nx2oFPZCJ1lv68jHlFtSPbs 1XWg== X-Gm-Message-State: APjAAAW9Ity7qyUTh5l4Vtn8QzaAH71lxuOY14Ri4zIUgE0SH7Hah3+v eIY6JFwvnU5Q9abx6vebAqDhQgsT9aI= X-Received: by 2002:a17:902:244:: with SMTP id 62mr42104077plc.243.1567625496164; Wed, 04 Sep 2019 12:31:36 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id f6sm18999174pga.50.2019.09.04.12.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:31:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 12:30:17 -0700 Message-Id: <20190904193059.26202-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904193059.26202-1-richard.henderson@linaro.org> References: <20190904193059.26202-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::643 Subject: [Qemu-devel] [PATCH v4 27/69] target/arm: Convert MOVW, MOVT 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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate.c | 89 ++++++++++++++++-------------------------- target/arm/a32.decode | 6 +++ target/arm/t32.decode | 9 +++++ 3 files changed, 48 insertions(+), 56 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 5b9b303467..b7d26f7cc8 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7870,6 +7870,34 @@ static bool trans_ADR(DisasContext *s, arg_ri *a) return true; } +static bool trans_MOVW(DisasContext *s, arg_MOVW *a) +{ + TCGv_i32 tmp; + + if (!ENABLE_ARCH_6T2) { + return false; + } + + tmp = tcg_const_i32(a->imm); + store_reg(s, a->rd, tmp); + return true; +} + +static bool trans_MOVT(DisasContext *s, arg_MOVW *a) +{ + TCGv_i32 tmp; + + if (!ENABLE_ARCH_6T2) { + return false; + } + + tmp = load_reg(s, a->rd); + tcg_gen_ext16u_i32(tmp, tmp); + tcg_gen_ori_i32(tmp, tmp, a->imm << 16); + store_reg(s, a->rd, tmp); + return true; +} + /* * Multiply and multiply accumulate */ @@ -9762,7 +9790,7 @@ static bool trans_UDIV(DisasContext *s, arg_rrr *a) static void disas_arm_insn(DisasContext *s, unsigned int insn) { - unsigned int cond, val, op1, i, rn, rd; + unsigned int cond, val, op1, i, rn; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 addr; @@ -10011,26 +10039,8 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) /* fall back to legacy decoder */ if ((insn & 0x0f900000) == 0x03000000) { - if ((insn & (1 << 21)) == 0) { - ARCH(6T2); - rd = (insn >> 12) & 0xf; - val = ((insn >> 4) & 0xf000) | (insn & 0xfff); - if ((insn & (1 << 22)) == 0) { - /* MOVW */ - tmp = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp, val); - } else { - /* MOVT */ - tmp = load_reg(s, rd); - tcg_gen_ext16u_i32(tmp, tmp); - tcg_gen_ori_i32(tmp, tmp, val << 16); - } - store_reg(s, rd, tmp); - } else { - /* MSR (immediate) and hints */ - /* All done in decodetree. Illegal ops already signalled. */ - g_assert_not_reached(); - } + /* All done in decodetree. Illegal ops reach here. */ + goto illegal_op; } else if ((insn & 0x0f900000) == 0x01000000 && (insn & 0x00000090) != 0x00000090) { /* miscellaneous instructions */ @@ -10765,42 +10775,9 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) /* * 0b1111_0xxx_xxxx_0xxx_xxxx_xxxx * - Data-processing (modified immediate, plain binary immediate) + * All in decodetree. */ - if (insn & (1 << 25)) { - /* - * 0b1111_0x1x_xxxx_0xxx_xxxx_xxxx - * - Data-processing (plain binary immediate) - */ - if (insn & (1 << 24)) { - /* Bitfield/Saturate, in decodetree */ - goto illegal_op; - } else { - imm = ((insn & 0x04000000) >> 15) - | ((insn & 0x7000) >> 4) | (insn & 0xff); - if (insn & (1 << 22)) { - /* 16-bit immediate. */ - imm |= (insn >> 4) & 0xf000; - if (insn & (1 << 23)) { - /* movt */ - tmp = load_reg(s, rd); - tcg_gen_ext16u_i32(tmp, tmp); - tcg_gen_ori_i32(tmp, tmp, imm << 16); - } else { - /* movw */ - tmp = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp, imm); - } - store_reg(s, rd, tmp); - } else { - /* Add/sub 12-bit immediate, in decodetree */ - goto illegal_op; - } - } - } else { - /* Data-processing (modified immediate) */ - /* All done in decodetree. Reach here for illegal ops. */ - goto illegal_op; - } + goto illegal_op; } break; case 12: diff --git a/target/arm/a32.decode b/target/arm/a32.decode index d7a333b90b..341882e637 100644 --- a/target/arm/a32.decode +++ b/target/arm/a32.decode @@ -73,6 +73,12 @@ MOV_rxri .... 000 1101 . 0000 .... ..... .. 0 .... @s_rxr_shi BIC_rrri .... 000 1110 . .... .... ..... .. 0 .... @s_rrr_shi MVN_rxri .... 000 1111 . 0000 .... ..... .. 0 .... @s_rxr_shi +%imm16 16:4 0:12 +@mov16 ---- .... .... .... rd:4 ............ &ri imm=%imm16 + +MOVW .... 0011 0000 .... .... ............ @mov16 +MOVT .... 0011 0100 .... .... ............ @mov16 + # Data-processing (register-shifted register) @s_rrr_shr ---- ... .... s:1 rn:4 rd:4 rs:4 . shty:2 . rm:4 \ diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 677acb698d..f315fde0f4 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -150,6 +150,15 @@ RSB_rri 1111 0.0 1110 . .... 0 ... .... ........ @s_rri_rot SUB_rri 1111 0.1 0101 0 .... 0 ... .... ........ @s0_rri_12 } +# Move Wide + +%imm16_26_16_12_0 16:4 26:1 12:3 0:8 +@mov16 .... .... .... .... .... rd:4 .... .... \ + &ri imm=%imm16_26_16_12_0 + +MOVW 1111 0.10 0100 .... 0 ... .... ........ @mov16 +MOVT 1111 0.10 1100 .... 0 ... .... ........ @mov16 + # Saturate, bitfield @sat .... .... .. sh:1 . rn:4 . ... rd:4 .. . satimm:5 \