From patchwork Tue Apr 23 15:38:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 162716 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3929359jan; Tue, 23 Apr 2019 08:39:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkLE5ILejBNY3f7qDWsVVd+/nkwXRb8wnPhQKZTXYeyootbe6YuiwfBEoIZrc5S9cIx9XL X-Received: by 2002:adf:fc8f:: with SMTP id g15mr17391678wrr.113.1556033976526; Tue, 23 Apr 2019 08:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556033976; cv=none; d=google.com; s=arc-20160816; b=CXIX6Ywv1kQvLSbx632dk0HIbFYuNH5LK6UJ0EyFRuPC8a96AR4VoPav4sPsYVvTLz YJya0BiscfABHpNoBM3LuD2cJ5BdmVWs0C6ShLGt5alJhoFwdnPheR7p74axiYTuKbWI tmBoQnl6cnjH6Mdo3i0/GQzbFcdHt2RhaevAR/fxyNxI9wg7Ulowg20McP/G8f2XYxBg 93BYbAb5FF7NpYxNQvpCdEXA/nI7we/LhN+GDivdFK1UNg8UEoqM3tsUpWXoKyXbCGck //5ARtSl+R9Oku5dKVHvDKST7Cb/VpGunr8iWxenO7xt4eopw8Wc2kFyw6SHKhaHgVQK I/Iw== 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=57LLTjI1nQcm9nBGSTBf3sb093E20lD7cyEUFj3ghB4=; b=EV0W+vlK2R5fcWxyycpK2ENVpo3IW6ixc5VEp6BGXVPKG1+YAcyzJIAUedjFYrp899 lCXCwM2vL69fEBVF/QsJV4Vgsi1GFCF9zE/gZvwtHiR8KamAsMNlPa2j0fJHPl/gsVhb 31ASNlOG7NoUgwRskm/B51FRA9Ayg8qPO+C03owFYWL7p7WIelgUarHF+96izPSE53Z6 6YSMl88u8TrbDBsHwowRpEB1xo1EezQXgcvFE1CEPxxoOdlly30a9YKJJEIMWWOL5Rnt jd2G1xEcn8RhzNc3EjGNKmTdOzrp5agt/SdTEvzCh0foW8HQBGtVn/PQklxADsuYATH4 10CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qNuvcvhN; 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 r11si2449996wrv.274.2019.04.23.08.39.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 23 Apr 2019 08:39:36 -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=qNuvcvhN; 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 ([127.0.0.1]:55526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIxWB-0001EC-FN for patch@linaro.org; Tue, 23 Apr 2019 11:39:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIxVi-0001BV-9X for qemu-devel@nongnu.org; Tue, 23 Apr 2019 11:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIxVh-0006zj-9P for qemu-devel@nongnu.org; Tue, 23 Apr 2019 11:39:06 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:38149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIxVh-0006z8-2q for qemu-devel@nongnu.org; Tue, 23 Apr 2019 11:39:05 -0400 Received: by mail-pf1-x444.google.com with SMTP id 10so7684970pfo.5 for ; Tue, 23 Apr 2019 08:39:05 -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=57LLTjI1nQcm9nBGSTBf3sb093E20lD7cyEUFj3ghB4=; b=qNuvcvhNnhZbx/yd/VUCDX//HI1BfjWUrDj+M8bOpioUZDA2dP4FCuMIXWb1iqxM7E GOcPJ5Q5fwbChkuX2/cNpOz5jiH9+eX/rO4D8ScTiq6fvT3CHu5L1Af3Rns6s9j5BqB1 Sk1ThWAiXdtl5leI85xLIch9DmbWPrCf4IoH9KQz+NnvGup6TmbOBesQnOen+gepWpKJ scH4Q/PYbkYZdb1ux8brs0g55QZCHxTY5MylEGwa4ZuOUMoCdoXUxEs4SxuIzb08mGAo wohYa3gQjP9H7xQj0LVp7V2lIBiU3nMsIK7cGwsWC75TaYt26LapEYEulSijB7i/iEfC IaUg== 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=57LLTjI1nQcm9nBGSTBf3sb093E20lD7cyEUFj3ghB4=; b=mRq/WDcS02Qfbuw+xcrwuYNQu5Rb6vS9ZbuoHlAhDYnMqZJg9P0FTZvjIoEGlMS7qD CaY78cN0kQrpcs13ZO3Dpf0HjtIBzFwTZfzkLZqwP1D/WFT3Xinkn9THmotH433xYDHy qd1wU+JeH3G7BQ4JyK+qGdYCRT0uOqT4//49N8BvGU6BJPt8TYK6lhFaiPaXD7an5Cxp q8q+sVZsIEYavu1SwC4lxOyYHC5ThHj53NWPdRlsWOLE+nK7t27muBSPEWW/EDflO0s6 WCgimJeYW7EXgjU37OzHqjSNedRIRiHqJQ/zUceGOKsB9nd+0wWX3AwhXumztfhqqF9A i48A== X-Gm-Message-State: APjAAAUtkSN8F6AHAv0Lf4sj//HY8CtWvUhPphSpP1CDF7unRvh+k83a M3qPQpAaSaIxEGD0t6ayvGCgysjy9Pk= X-Received: by 2002:a63:e048:: with SMTP id n8mr25323272pgj.41.1556033943708; Tue, 23 Apr 2019 08:39:03 -0700 (PDT) Received: from localhost.localdomain (97-113-179-147.tukw.qwest.net. [97.113.179.147]) by smtp.gmail.com with ESMTPSA id c25sm24366591pfo.69.2019.04.23.08.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 08:39:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 23 Apr 2019 08:38:52 -0700 Message-Id: <20190423153853.19790-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190423153853.19790-1-richard.henderson@linaro.org> References: <20190423153853.19790-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::444 Subject: [Qemu-devel] [PATCH v2 6/7] tcg/ppc: Allow the constant pool to overflow at 32k 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: alistair23@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no point in coding for a 2GB offset when the max TB size is already limited to 64k. If we further restrict to 32k then we can eliminate the extra ADDIS instruction. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.inc.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index c0923ced4f..36b4791707 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -529,7 +529,6 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { tcg_insn_unit *target; - tcg_insn_unit old; value += addend; target = (tcg_insn_unit *)value; @@ -540,22 +539,16 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, case R_PPC_REL24: return reloc_pc24(code_ptr, target); case R_PPC_ADDR16: - /* We are abusing this relocation type. This points to a pair - of insns, addis + load. If the displacement is small, we - can nop out the addis. */ - if (value == (int16_t)value) { - code_ptr[0] = NOP; - old = deposit32(code_ptr[1], 0, 16, value); - code_ptr[1] = deposit32(old, 16, 5, TCG_REG_TB); - } else { - int16_t lo = value; - int hi = value - lo; - if (hi + lo != value) { - return false; - } - code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); - code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); + /* + * We are (slightly) abusing this relocation type. In particular, + * assert that the low 2 bits are zero, and do not modify them. + * That way we can use this with LD et al that have opcode bits + * in the low 2 bits of the insn. + */ + if ((value & 3) || value != (int16_t)value) { + return false; } + *code_ptr = (*code_ptr & ~0xfffc) | (value & 0xfffc); break; default: g_assert_not_reached(); @@ -701,8 +694,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, -(intptr_t)s->code_gen_ptr); - tcg_out32(s, ADDIS | TAI(ret, TCG_REG_TB, 0)); - tcg_out32(s, LD | TAI(ret, ret, 0)); + tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; }