From patchwork Fri Jul 26 17:50:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 169910 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp363667ilk; Fri, 26 Jul 2019 11:01:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK8uyPSWWZmySEejaySM4LiklTa6l9ylxkCuAgRKNZJYwJbYiDs4YlNFhR7nKp7zr38kEq X-Received: by 2002:a37:8081:: with SMTP id b123mr63863797qkd.62.1564164079991; Fri, 26 Jul 2019 11:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564164079; cv=none; d=google.com; s=arc-20160816; b=VAjFydYpSqNE5bcSWVHVVGbRXxsqr8X92Xvm1KN1jwCTkMrfCxtF3ayxDN0YF3+a/+ M/LxcI4KY0es82S30GId7TatJ2JplriqWFlCuytwRJ5ap44FkRW0Gbvd2n7FVRyih/Le d84yFwHXndvDT703cEwflLp67eHBnfSFrx+ZAcw6zkgpMe8G+L1wuAt5l9eH330XMBk7 Y2/YuF5mzfgcM2+7FdqkkXEaIHcuvz60qWXo3by03rly6AsRH3vaceYKV6OjhRaRLf22 IrW5z2m5rNQRtujZTDAjb/xeHhRjnBGoi7hkKb9mfd9Wtlvk+PVI1tLOKdET31Y+fJ5f DSEg== 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=3dOWwe1vKbsdIWS0nSZCwW1yYPHjDGBihHkemS/ZoSY=; b=w9G42/qt3JkfOTf99jmDkLYrfVsARZshx+lOVhU7J5Olk3UGmR21VwR7Vtl+/8B6Qm N887Pu6UPuI2Yj947xgFVMshVolN6UzKzC5BVo+eanrR7ayEOBqez74whABFXvMSYX+P 9Kz/m3R2vpAcTN4Mz4Dbkd/9ig9eON39XnxV6SNLriwKc+uhRMjLDh4isCUiWXx2Bo4d oFTRmp5y0bESnb5IQJDYy5n5bpB7ZuzDSDgO30imno0pm9Bc7YjylhO3TTKFJ0N41k8p VfXK0U9VhkLO0IOs6PPyqbe/fw07WMqjIshhfevRvG0DM9BN9jNs/Nni5nc9X2B/Q5wg iV/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dyjxBfl6; 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 z20si34849766qtb.360.2019.07.26.11.01.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 11:01:19 -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=dyjxBfl6; 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]:42592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hr4Wt-0002xm-1K for patch@linaro.org; Fri, 26 Jul 2019 14:01:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59558) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hr4Nt-0007K9-3w for qemu-devel@nongnu.org; Fri, 26 Jul 2019 13:52:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hr4Nr-0001IO-IQ for qemu-devel@nongnu.org; Fri, 26 Jul 2019 13:52:00 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:35665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hr4Nn-00018s-Iu for qemu-devel@nongnu.org; Fri, 26 Jul 2019 13:51:57 -0400 Received: by mail-pf1-x42b.google.com with SMTP id u14so24878698pfn.2 for ; Fri, 26 Jul 2019 10:51:52 -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=3dOWwe1vKbsdIWS0nSZCwW1yYPHjDGBihHkemS/ZoSY=; b=dyjxBfl6BToPNY6VUCaToZdn+s3aAJ3ikTyADQR8Az2DKnYBVnzU2dQphCMsyF9HG/ r0Z9VBcJ5us5CMliebrRm1mSwNgv25a+PiwxJD3uostHSQCLPEKqk3SHbX0wGx188awC W4Du//iD6wHfG4KEhfBsK9bijFmA7SYGsG4znsMUEaG0STRCRroeH7ayMz/nD7GQ64Cw 7mmypMsmAQfjwo46JrX8LU6DR3ojdQ+fDiC5P0z7E/Rcl13GQWkKAWue+OK8N4amtoye 4j4V3eIG4ka4mnct1ctgZVybj8rCZ0f0Gsf7DbCNT5xgzjOusEs5SFiy4gQCvMCnglAj cZGw== 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=3dOWwe1vKbsdIWS0nSZCwW1yYPHjDGBihHkemS/ZoSY=; b=ZAxXVh5NFuOlDZt3B8w8EOXTLbA/3Cuql2a8ZySNJZTHkZN0KxatHjq0OA352kKXrU wlPxfceAsmJ4oV5/Vj1Sr+sOiUpdIOFo+bacnFwA2BzMqHMCkNvwef+3kynaieAlBiQe 9Az5LWrms6mXEjthNZHw/3ORCBYizvNFaUQWYlu3veCfopWUSpqSFpCJBLWg9patvoQb Put/IBCYSjtTsYij+YYqRYT9lIsOWUg/cIvBV/iXEoio7teJDBcWxkwuYDscLhvKpNQh iwat5Z/SCdQxdKCD/11LqfRiz/LPJgtrlCty3Xf2aZBJrbL4jd8co1+4wfbn3Z8oNDCh 1+OQ== X-Gm-Message-State: APjAAAUGg1IxNJ43OIlaYYaFMPDXNGDnicUx8GCFfn3lP5orLGcGUmb8 ORvgskz0hv/mHPeHNED+CknRNwKkt10= X-Received: by 2002:a17:90a:37ac:: with SMTP id v41mr94950125pjb.6.1564163510598; Fri, 26 Jul 2019 10:51:50 -0700 (PDT) Received: from localhost.localdomain (97-126-117-207.tukw.qwest.net. [97.126.117.207]) by smtp.gmail.com with ESMTPSA id o24sm104287919pfp.135.2019.07.26.10.51.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 10:51:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 26 Jul 2019 10:50:29 -0700 Message-Id: <20190726175032.6769-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726175032.6769-1-richard.henderson@linaro.org> References: <20190726175032.6769-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::42b Subject: [Qemu-devel] [PATCH 64/67] 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, alex.bennee@linaro.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 diff --git a/target/arm/translate.c b/target/arm/translate.c index 480515a0a9..a8db6e9280 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10055,6 +10055,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], s->pc_read + (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->pc | 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->pc | 1); + gen_bx(s, tmp); + return true; +} + static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) { TCGv_i32 addr, tmp; @@ -10639,10 +10677,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; } @@ -10661,53 +10695,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->pc | 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->pc | 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], s->pc_read + uoffset); - } - break; + /* branches, in decodetree */ + goto illegal_op; } return; illegal_op: diff --git a/target/arm/t16.decode b/target/arm/t16.decode index 457f2f4178..105218882a 100644 --- a/target/arm/t16.decode +++ b/target/arm/t16.decode @@ -274,3 +274,6 @@ LDM 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