From patchwork Mon Jun 19 18:18:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9797149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F3504600C5 for ; Mon, 19 Jun 2017 18:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAAE928459 for ; Mon, 19 Jun 2017 18:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF3F128464; Mon, 19 Jun 2017 18:25:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6CDCD28459 for ; Mon, 19 Jun 2017 18:25:14 +0000 (UTC) Received: from localhost ([::1]:43848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN1MP-0004Yx-Fp for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Jun 2017 14:25:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dN1GG-0008OZ-1z for qemu-devel@nongnu.org; Mon, 19 Jun 2017 14:18:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dN1GF-0002GW-62 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 14:18:52 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:34758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dN1GE-0002FC-W8 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 14:18:51 -0400 Received: by mail-pg0-x241.google.com with SMTP id j186so17439647pge.1 for ; Mon, 19 Jun 2017 11:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=CR+HQBXWwwo3jOjl2EJ5uSCBnAkmH/RpZW4hX9VtpBc=; b=rh4F9iDgZGaqYkmb/UNUWl61UN9BGdq87FDk+2rqHCZcXVuJ+/zJVB+rJnzLjijSrh KAXLsdyJBL6P8C4AyoBqCC80sVGPoz9G3BXuYASVLawNXsIMMiLsqyqb5usvnGYoO+8f 2Md0Dc747GThL29M3e9crdSTuj3tvPeN8t8Zx2g/azfOx9sDhEFN0iG/Up/DulCeOfNh dBgrnuqtDyj23X/F4hpXqvt9Yz20vEgcIBR0sTO09VtFRtnXxUjj9fTHSRoRwB/UF1oW TzSNg9tcZlXUcI4sQnthAPj6yOkzIZPeU6/LFPnrpZSEyWPHu3IvAW3RboEt/JkpduFB 6ndw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=CR+HQBXWwwo3jOjl2EJ5uSCBnAkmH/RpZW4hX9VtpBc=; b=hppL2hOTMsfcKJ4lG1EX9U+RC+wRfff8PGkAvYp0LBIfaEsdhMsP1qMf1sxQC2WXjQ 21OHeYPyNi8TTqF+aG3lDNSgHW99k5zo0XXl/2AJr4Av/8hyu5V1V57O4mjTxWzLjoJR a/qlW0FEngOMLTTJWF/QdBouVq6BIkhPu0urOIYyPrn/rP6h5LKO9KgGrAmeuvLS7oiZ qOfG8Dy9kU8hM2XDg2vyUpt+dgnxkbOTKbJKJE+HicawVLsBN6gHnrPUFDHNLa9y1GV9 BPYevMnYsLLAGbXAajE+UaZrCr/8eANaBu1nECpAxeysUr9DOAuLWzwhcWIeKsvTlvzc SJww== X-Gm-Message-State: AKS2vOz33GNzdRp4WeZUT386m0t0J5VQiph7pvlQG0rnaciegeJ2gGD+ SWX2w3VJ1lyASpTbswU= X-Received: by 10.101.70.129 with SMTP id h1mr27681645pgr.50.1497896329975; Mon, 19 Jun 2017 11:18:49 -0700 (PDT) Received: from pike.twiddle.net (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id e63sm22917171pfb.18.2017.06.19.11.18.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 11:18:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Jun 2017 11:18:34 -0700 Message-Id: <20170619181839.25249-8-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170619181839.25249-1-rth@twiddle.net> References: <20170619181839.25249-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PULL 07/12] tcg/arm: Try pc-relative addresses for movi 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.inc.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index fce382f..42370e5 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -418,23 +418,37 @@ static inline void tcg_out_dat_imm(TCGContext *s, static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg) { - int rot, opc, rn; - - /* For armv7, make sure not to use movw+movt when mov/mvn would do. - Speed things up by only checking when movt would be required. - Prior to armv7, have one go at fully rotated immediates before - doing the decomposition thing below. */ - if (!use_armv7_instructions || (arg & 0xffff0000)) { - rot = encode_imm(arg); + int rot, opc, rn, diff; + + /* Check a single MOV/MVN before anything else. */ + rot = encode_imm(arg); + if (rot >= 0) { + tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0, + rotl(arg, rot) | (rot << 7)); + return; + } + rot = encode_imm(~arg); + if (rot >= 0) { + tcg_out_dat_imm(s, cond, ARITH_MVN, rd, 0, + rotl(~arg, rot) | (rot << 7)); + return; + } + + /* Check for a pc-relative address. This will usually be the TB, + or within the TB, which is immediately before the code block. */ + diff = arg - ((intptr_t)s->code_ptr + 8); + if (diff >= 0) { + rot = encode_imm(diff); if (rot >= 0) { - tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0, - rotl(arg, rot) | (rot << 7)); + tcg_out_dat_imm(s, cond, ARITH_ADD, rd, TCG_REG_PC, + rotl(diff, rot) | (rot << 7)); return; } - rot = encode_imm(~arg); + } else { + rot = encode_imm(-diff); if (rot >= 0) { - tcg_out_dat_imm(s, cond, ARITH_MVN, rd, 0, - rotl(~arg, rot) | (rot << 7)); + tcg_out_dat_imm(s, cond, ARITH_SUB, rd, TCG_REG_PC, + rotl(-diff, rot) | (rot << 7)); return; } }