From patchwork Mon Aug 19 21:37:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171726 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3571656ily; Mon, 19 Aug 2019 15:31:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAZWKOqGYoK+VY5Dwcy47FD9pRFB0hR3igUpN4TN7cCZS2gs+bG3OqANvsnZFY8cuy7Ah9 X-Received: by 2002:a17:906:a89a:: with SMTP id ha26mr22557010ejb.110.1566253868697; Mon, 19 Aug 2019 15:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566253868; cv=none; d=google.com; s=arc-20160816; b=QlklJ0MtdbhD9riDCe7MPxrHw5eMjieU1Qg05Y5gA6N2nsZEykjYlYgZRXfrNrAAA/ RmrlVnT8cgGhQBHCwLUoW/1VyYrsCYhu79TNBb2bSVgJgHipCBOW59ow9yjrNy5Ubru+ op3299yINYllpzWOXZ7COLUgFLBqPrXRIQBBwar9jBrUCE5rzon1FHSQ1ipQj5SKVPZM uWIMP2ihfr37kJ3yfzeCpS6TPGquwTYztxexOUwBFoIMLmMKiR/+2D37Zb8RwlXNvsvD wZfMsch/S61gwiOILdgMvzCIZAT3IIINpmP2C5UG20xCVP6+qdDMKXjCNx3PKcWa/PDo Srpw== 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=CE2MOpYeaURMh2McMQcADxkv9nuiol4iRofGvabxWa4=; b=SBX8YNuW3MN3k88pU1UBOA7Pgob55yw7NPduH5Pyuzha5HJ/7w8sggWpg+DK6fk4yO BdH34urmzJJqbknT2hrQ5FYsAiy/LbCzjY9od/YhrsGiNJ3AXKF12cDho5u1R37TvRhw y+6uMz9uzpwyoTeea5C+bfWsS67ZNCMgKo0cLbGqj3HvMJKoGjkRcZViMC1Tg+7f5WIc QjC/ClFraOkBxvSBqw9bFoG1C35FUTsw8LLj3DOwUznHa48LBHMDZSIeOLet0wxX5LXK G83LcEko30LSFWe2L/ILqaYwcVqvPfUCwhBgAZoaH1w0lpLK2qIVzVpAQAlXGJhliCeZ AgbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bHPuMY7A; 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 z5si6432029ejp.148.2019.08.19.15.31.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 15:31:08 -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=bHPuMY7A; 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]:60090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzqB9-00075V-Gn for patch@linaro.org; Mon, 19 Aug 2019 18:31:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60207) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpN3-00038b-Kj for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:39:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzpN2-00071E-A0 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:39:21 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:43243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzpN2-0006zq-4J for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:39:20 -0400 Received: by mail-pg1-x52a.google.com with SMTP id k3so1922701pgb.10 for ; Mon, 19 Aug 2019 14:39:20 -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=CE2MOpYeaURMh2McMQcADxkv9nuiol4iRofGvabxWa4=; b=bHPuMY7AdYlyafexynlB/HZikO0mKlbdgJFNk15y7TjKMMC1G3aISNOKnFA0wi0nIx tmysV2g7ohX3GwfAYUJ3cjEBxifX7GVN/OQsfYcVW31Arh4bTxOisGwDaN9A/DVlpI4g wog512+IqdFpBhkT6qDB9n7y/sl6eFXqtYKghc429RFBY/7FRR+gF2QmBuJ1Bo5D3S3a sH/nOtI9FYsbRS+RqRTpqNKpC8dW060TwaaQSkCp9P3Q0zobi/cdkcHQC2nsolGVGH8w e5rQKR7u2JnzpGRLk8QdNQUF6vz+PWGYLQeHbw+Yaz88AQJYvdMd5jSkfI6XRwAd8hj0 BOGg== 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=CE2MOpYeaURMh2McMQcADxkv9nuiol4iRofGvabxWa4=; b=NBeEgXNiC0Jj7/oLJ0/DE6H11lUMydq6qzcHZ8/wZVXuZVcfnL0JrCF3DPgQzDf6Md 35IBKOvj6NWc2HIOryUtlFpfl8NRKLLmlXI3Vcq/w4xRy/dZK15A9vLEo1w1jHeQmgWp Fs4tOvVvXebyP+Rb6HZoWquukOveVqB5keMXVXBH8+fMku0Y0DJTjuMbjKtV6OqoKoOf KFXP+ecAQUwssQvgjJrB9YunvjB7M5ZKqnnliyRxgldeVByuDNFb8J+yR6PucBCS4Ysm lDoJCTKKVtXAT14FqmFYmeRIr4gccjnJJhJo1QrRCa5eSj9DSdn8n981XQl2PQcVKLsV GYbA== X-Gm-Message-State: APjAAAV8L3/pekr7yro5H08UxlfVE6YK/JPWAjCtflbaEKWE/Kud3EIV ZIxY6YDwl1vnT7QMGbyrjS4eRHllnHI= X-Received: by 2002:a17:90a:3465:: with SMTP id o92mr22412655pjb.20.1566250758891; Mon, 19 Aug 2019 14:39:18 -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.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 14:39:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 14:37:53 -0700 Message-Id: <20190819213755.26175-67-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::52a Subject: [Qemu-devel] [PATCH v2 66/68] target/arm: Convert T16, long branches 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 | 89 +++++++++++++++++++----------------------- target/arm/t16.decode | 3 ++ 2 files changed, 43 insertions(+), 49 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/translate.c b/target/arm/translate.c index 51b14d409f..f8997a8424 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10025,6 +10025,44 @@ static bool trans_BLX_i(DisasContext *s, arg_BLX_i *a) return true; } +static bool trans_BL_BLX_prefix(DisasContext *s, arg_BL_BLX_prefix *a) +{ + /* + * thumb_insn_is_16bit() ensures we can't get here for + * a Thumb2 CPU, so this must be a thumb1 split BL/BLX. + */ + assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); + tcg_gen_movi_i32(cpu_R[14], read_pc(s) + (a->imm << 12)); + return true; +} + +static bool trans_BL_suffix(DisasContext *s, arg_BL_suffix *a) +{ + TCGv_i32 tmp = tcg_temp_new_i32(); + + assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); + tcg_gen_addi_i32(tmp, cpu_R[14], (a->imm << 1) | 1); + tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | 1); + gen_bx(s, tmp); + return true; +} + +static bool trans_BLX_suffix(DisasContext *s, arg_BLX_suffix *a) +{ + TCGv_i32 tmp; + + assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); + if (!ENABLE_ARCH_5) { + return false; + } + tmp = tcg_temp_new_i32(); + tcg_gen_addi_i32(tmp, cpu_R[14], a->imm << 1); + tcg_gen_andi_i32(tmp, tmp, -4); + tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | 1); + gen_bx(s, tmp); + return true; +} + static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) { TCGv_i32 addr, tmp; @@ -10612,10 +10650,6 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) static void disas_thumb_insn(DisasContext *s, uint32_t insn) { - int32_t offset; - TCGv_i32 tmp; - TCGv_i32 tmp2; - if (disas_t16(s, insn)) { return; } @@ -10634,53 +10668,10 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) case 11: /* misc, in decodetree */ case 12: /* load/store multiple, in decodetree */ case 13: /* conditional branch or swi, in decodetree */ - goto illegal_op; - case 14: - if (insn & (1 << 11)) { - /* thumb_insn_is_16bit() ensures we can't get here for - * a Thumb2 CPU, so this must be a thumb1 split BL/BLX: - * 0b1110_1xxx_xxxx_xxxx : BLX suffix (or UNDEF) - */ - assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); - ARCH(5); - offset = ((insn & 0x7ff) << 1); - tmp = load_reg(s, 14); - tcg_gen_addi_i32(tmp, tmp, offset); - tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); - - tmp2 = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); - store_reg(s, 14, tmp2); - gen_bx(s, tmp); - break; - } - /* unconditional branch, in decodetree */ - goto illegal_op; - case 15: - /* thumb_insn_is_16bit() ensures we can't get here for - * a Thumb2 CPU, so this must be a thumb1 split BL/BLX. - */ - assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); - - if (insn & (1 << 11)) { - /* 0b1111_1xxx_xxxx_xxxx : BL suffix */ - offset = ((insn & 0x7ff) << 1) | 1; - tmp = load_reg(s, 14); - tcg_gen_addi_i32(tmp, tmp, offset); - - tmp2 = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); - store_reg(s, 14, tmp2); - gen_bx(s, tmp); - } else { - /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix */ - uint32_t uoffset = ((int32_t)insn << 21) >> 9; - - tcg_gen_movi_i32(cpu_R[14], read_pc(s) + uoffset); - } - break; + /* branches, in decodetree */ + goto illegal_op; } return; illegal_op: diff --git a/target/arm/t16.decode b/target/arm/t16.decode index 35a5b03118..5ee8457efb 100644 --- a/target/arm/t16.decode +++ b/target/arm/t16.decode @@ -274,3 +274,6 @@ LDM_t16 1011 110 ......... \ %imm11_0x2 0:s11 !function=times_2 B 11100 ........... &i imm=%imm11_0x2 +BLX_suffix 11101 imm:11 &i +BL_BLX_prefix 11110 imm:s11 &i +BL_suffix 11111 imm:11 &i