From patchwork Thu May 25 18:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 685604 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp500593wrt; Thu, 25 May 2023 11:11:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4c6BvUvDPmtrkhNMBWqVI1Oi8g0qwieL0ONWlSXVik9KbTDl+hBj9GfEPXSQlp0NzHU7d9 X-Received: by 2002:ad4:5cc1:0:b0:625:aa49:9ab7 with SMTP id iu1-20020ad45cc1000000b00625aa499ab7mr2766589qvb.59.1685038270189; Thu, 25 May 2023 11:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685038270; cv=none; d=google.com; s=arc-20160816; b=zhFkrfVhNgwT7FXBfy3Rdy80bggODJIt4Rw5DAP//P/HB6mnqKLykpWCPA/VP9rDcJ 9/YKrxpxcQTc6WM9O7zBrvlv5OUdSxhcLSn0s55AWjEiq1ngCb3DKotPC/GF86TEBc5n yaFK6rCUEedAA+JxV6dShYGz3FWiR3Njy8XgoYS2oJTpX0Hgg0IjwoG9U6IitBKxYpnd SwZ6IIn+JmRJ7ZDlL9XjQnaUbCRv9jOQUkoS9PUxJlHuNGLv581LP3wnzARAGnOQCsa8 9cqz7HmpL+b9FwXo8SDJ2JmpztJA3JixpmU3ZvXPgcYvFjOTxidRu7blbpJ8eczjQ3Ue EpQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=JkJM07os441xnhiCov37oQdW7RqmLahmG3kxZWD6nFlYaV2NHBenGFvVh/ZD0A7m0n DvFs9h03BVIa+fdvIdSMS+GT1eVz/Dh2w981hQysEucKvILCzQ8PDTW47Wkk+5ogzXOn L4ZAJmC11x2VJm6m7Vu1EshEAteS4pGuwxDN8Mayfu02IKCkhIp9yUG+WGJl2DyT19CT rpZeSdwSioNa9F32iGqvcu6rsI7RT+rhC2t0A+oyom3fT+ysa4CRqVbgIMpIM5v6MLxp zy4MGKcuRQUVNAqWFoU9qAoWkM7EXhDMBZT8MkVxOKYRitMInb3a6kfL1VAFyAvlKUrv gw7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bb+O+iSL; 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=pass (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 8-20020a0562140dc800b005346e124cf5si714604qvt.20.2023.05.25.11.11.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 May 2023 11:11:10 -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=pass header.i=@linaro.org header.s=google header.b=Bb+O+iSL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQF-0008Mx-OI; Thu, 25 May 2023 14:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQD-0008Lc-6n for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:45 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQB-0005rF-J2 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:44 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-53033a0b473so1364197a12.0 for ; Thu, 25 May 2023 11:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038243; x=1687630243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=Bb+O+iSLpgjlJp3GYJDrZevUyefyLq/4xoLwxTZhDRKie7cOcZxK7Hq1ylice+q23W Ar/JboIJLzvMtL+bU/nJjCL/yY0cFUhMIskUzKORf0r0OL5kv3akn/532cGJqZc1tkzj Nd5LQiTLYhySBnkhlBfTjDoM5Fwa3wX8VPBPGICfR/JYO5YSOw/neLTGvSJZ45Hmci3Q PbhPg0VD0RG4oEw2lXGxyVxnzpT4tGL04M59iMjVrvmNt3x9rIgVaC992qFxA5oEXAnF Bddn8MUqc11yW+ke5gnZhN6pUTNtrDd+39UTrdNKOYRyWHlO7P6bxjFO6gRG7e/pjYw1 KQ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038243; x=1687630243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=NU12K22YYmc7wScwMgMjdkbR51/yYOqrec+RwyEgFqrJBVr8VNSZ54LjCOpkmXku9a O257dVZnnV4rjcHc5cJKo3jrj8qn3zpjTXMWZ7ZZJ7bq7302JqI8VixH+eQywKhYIu2w yjAEPds2qJOeVVPLZh+j2nxOn0DhYycKRH+SoaR86URe+zK3rBXb13uvWDd2xMzSe9L+ v4ICa8Pa7TjQLk3gG77lcz3C8DiPqoXKImLzBfBanE2dgf8+cKyZABNyqaaVz2kl1nX5 pPE5LaqgfSoxwVzdwXl5uuAT2l6EEi6iUfPkC/A7NISuu30e3+RFlgnMUkrvRI3hARdk 1FWw== X-Gm-Message-State: AC+VfDzmF7FbPn9N0ydn0dVasi9MvGdY7mSpgTKkCN/f2YK7bf0Fjias dhnf0cE5fLGrT4fB6d95rRo19TQtiLMcd0IySUM= X-Received: by 2002:a17:903:41ca:b0:1a6:abac:9cc with SMTP id u10-20020a17090341ca00b001a6abac09ccmr2709569ple.66.1685038242777; Thu, 25 May 2023 11:10:42 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/23] tcg/mips: Split out tcg_out_movi_two Date: Thu, 25 May 2023 11:10:19 -0700 Message-Id: <20230525181036.1559435-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Emit all 32-bit signed constants, which can be loaded in two insns. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index bbff510c46..7a19f8db1d 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -527,6 +527,22 @@ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) return false; } +static bool tcg_out_movi_two(TCGContext *s, TCGReg ret, tcg_target_long arg) +{ + /* + * All signed 32-bit constants are loadable with two immediates, + * and everything else requires more work. + */ + if (arg == (int32_t)arg) { + if (!tcg_out_movi_one(s, ret, arg)) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); + } + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -534,21 +550,18 @@ static void tcg_out_movi(TCGContext *s, TCGType type, arg = (int32_t)arg; } - if (tcg_out_movi_one(s, ret, arg)) { + /* Load all 32-bit constants. */ + if (tcg_out_movi_two(s, ret, arg)) { return; } - if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { - tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); + if (arg & 0xffff0000ull) { + tcg_out_dsll(s, ret, ret, 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); + tcg_out_dsll(s, ret, ret, 16); } else { - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } + tcg_out_dsll(s, ret, ret, 32); } if (arg & 0xffff) { tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff);