From patchwork Sat Jan 8 06:36:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 530704 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp1002425imp; Sat, 8 Jan 2022 00:08:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYFUCFiTadDa8uWW47ku+fBKMeGjxR1bHqcr6FNQFsqo76xs1C1CBbe8tignrUl86jdPW8 X-Received: by 2002:a25:c691:: with SMTP id k139mr8412459ybf.327.1641629322404; Sat, 08 Jan 2022 00:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641629322; cv=none; d=google.com; s=arc-20160816; b=NQkjcwrVoweu++jRM0BbwUKBRxh/A6NmOLSdL+l3DSjwpaQeeW6Pjm/NQ/aeiIObZP m7/bBPpGDKnclrUJIrwTodKRoEnfWwt6DYJIPKUoJzY+i5W4fAcJajllKgwN79Fb6ufd 1vCoKDWxqo7VR+JDOAIlFXGVUKfRk72p/nIqvqWn7YZPRbb5ZXzpRYOFenoXKJ7ZQ7/v Gs9ZvfQZb21w1bbkCebgKWe7wwd1o8ifUvzPJzk+5h8lSHvJ34J+SJe07fnwazGwmFY2 eSpDfpVddxdgPm9v7M4P3KfsLDINCbHL2032OJut0hT7yIEMwjxHJ7Y6TYzs08MIG6GY RKKA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gNW3zpumLFHPqplHLKc2ywbGSNXOgU1ULWv67Fdx+a8=; b=u3VeBgTEnKxMX+mL0d+eMO6u7xSrBpi6Lowcl/RM8IFtfAFDQyMxHMJ6j8pw2skpvE LUFMwPHpVz8HX7QO6jJEnKoYWDeSISr3Kf1p3d5Tq7B8AK6/tlLKIDSgwY8GE3ufjk9k H8NY0+8rCmbVNWldY7x0iv7l467ndGVLopmvbniOy7zflB3MeDyzX5QrZA1BnAdATGCD AjWEJ2CUpir+kBD1wNWxj00eyCWy5S6YD/IYv88jOS5/Vhs9iCQgP63JuCms2U7DV3jd lJhAB1bvXL4FIJHlnxT/Lfrc+7oOLgICC6EgeKS5KqEQ5VCDnxsq1xBN35FXOIyXe7Uj LTFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="p4eo/abB"; 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 w2si901760ybu.273.2022.01.08.00.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Jan 2022 00:08:42 -0800 (PST) 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="p4eo/abB"; 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]:46004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n66mH-00052I-TR for patch@linaro.org; Sat, 08 Jan 2022 03:08:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n65Lf-0005iA-6H for qemu-devel@nongnu.org; Sat, 08 Jan 2022 01:37:09 -0500 Received: from [2607:f8b0:4864:20::435] (port=44990 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n65Lc-00048y-Pc for qemu-devel@nongnu.org; Sat, 08 Jan 2022 01:37:06 -0500 Received: by mail-pf1-x435.google.com with SMTP id t187so7048725pfb.11 for ; Fri, 07 Jan 2022 22:36:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=gNW3zpumLFHPqplHLKc2ywbGSNXOgU1ULWv67Fdx+a8=; b=p4eo/abBIlFS/qYjuGZmUf+oWl+obovIUlhDoS+TpyKGYvFl+mFMDV1B0+cPMQKtHr m38uHQ0PJ3PFviUpF+8koW5cswglxq/iJdXyjHefnK+jfT5wx+XsWzo5BZHTLTbXL5oJ Ad/m3zQRXhZwkEvGMI3/OmpZe4RJw9iw6tgmn50k0AunoUHLD3q/ZYtrbWLw1Wa49MDX YRD4OgUvr2ixticbw/3qWCxvTFtwg+Wk3CFQr8dyz4Xb0Q+qzMtbgMTdgnYeJDCKKuvZ bgOi3T/rANnXkcPmooCNLVRGBfOVzWPo7oPgPuzhut78Zq7AjrX5gHdhGBJxix7FtiB4 X+1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gNW3zpumLFHPqplHLKc2ywbGSNXOgU1ULWv67Fdx+a8=; b=FcML4AyQNqFwwf9GMe1wHhj8v8/35x4aGFgQyQkodQ3FTZSNvwoz9C56lRwIa6xh+j ABVpulsP71XFAm3+U2Pq+JgPsZdKJNxFgRwR/wSDstbJMlyOfVGKkbpBLE+gLBlo+/Qh XUCq+ds+a9P/CTS0DkgR5MDbhRRm3He0WjllvJgOUEF4c5Lc2SNtdqWyDo6TfYbzBhiV ASmUcWNzPbgNzdaRatfVhKV3DvvdzVK/YNcdyDdsvCbABhdpzi9lR40n+qjmJ1B7FM/Q D+dFh0LI0LDkMCjznoKXjDlaASCS4lOZ1KUNLzlwsroY6W/mqrrDQEr1zXUBG+JYZ6ov Z+1g== X-Gm-Message-State: AOAM5308Ud7kdwYR4O23rT0HiK0Vib0QkNmzcL/n5vkJ5j1JARZTkskr IsyIP6PhVjaROsQajbAUIh7EzSy53GmOoQ== X-Received: by 2002:a65:6aa7:: with SMTP id x7mr21572871pgu.273.1641623818644; Fri, 07 Jan 2022 22:36:58 -0800 (PST) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id z4sm840954pfh.215.2022.01.07.22.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 22:36:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 08/12] tcg/mips: Split out tcg_out_movi_two Date: Fri, 7 Jan 2022 22:36:40 -0800 Message-Id: <20220108063644.478043-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220108063644.478043-1-richard.henderson@linaro.org> References: <20220108063644.478043-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 8741fdd49c..142583b613 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -541,6 +541,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) { @@ -548,21 +564,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);