From patchwork Tue Feb 8 07:17:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540745 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp295194imo; Mon, 7 Feb 2022 23:59:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZMOpRN38YmgcakF4FaG6Ra8TK9UaGKLEyMtEvKXvmT3w/q7MtVhAYSArXKDLE4iDYeNDC X-Received: by 2002:a37:a78e:: with SMTP id q136mr1996027qke.206.1644307185503; Mon, 07 Feb 2022 23:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644307185; cv=none; d=google.com; s=arc-20160816; b=wb2dSVQomVz/OeE+dnNHyeYJLo69hXOFAM14LvRvYqQH3TJ/kvfJCY515fHX79ioUF 7Ql5LiFmvkrXFkzdYeCXzzANHE5v8Lun+pho6AFjdl1hIHQ7DFZDFp2tZU722Ft7A+Es iR9DQpyxixnucjlGkE/TeM6d2gF+h6frsywJrFg0UcDkCY7Mx5DFB0/lgx27+npAUPS7 J5ISlsoBmPJcvOv6Wc4Et+PduFzzUJYLeniaN4D8wNWNVGFeR/IbNRfPonn2r/qRz9l6 i+zDqmHsSGi94G22q8zuq4F6Q01UWe3UPtH0kdAYVdZrXAl+L+RhhiZ4LK8+i6599r0d +Izg== 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=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=YQpKlwX5XQWwGDCBcuSTLmE9ZLpSxIiDaa8FQ3v7vq/sa65CqtmltUvDms2JwJqMA1 zo7rZkVQv1DSoO5bB+ZRVNsj7w5WtBPfqYzo1sRM8P4h1fiElveAYPu5tE7GE0nlZOXo /u223rH+lFQBLkiREcLmFSgPrzK87O0nSvPPF/C2MkKW3fKczoo9R4uU58ds9LM3YAvg InnEevGDzampEUOkogNUBN4vSG7yBnt3flcDfveQrf1UgmLdgaX0hVBNpSDcP+1iAREL GV8Xhj3RuzOfabuFDDBe/UJGooNg+UFL8zjdqmzS/A+sUnitvcHQtTgdwl1VoVMDNK6J 3xYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gmYbOyHn; 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 u3si2764752qvs.576.2022.02.07.23.59.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Feb 2022 23:59:45 -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=pass header.i=@linaro.org header.s=google header.b=gmYbOyHn; 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]:42430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLPc-0000sj-Nq for patch@linaro.org; Tue, 08 Feb 2022 02:59:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKke-0000ON-B9 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:26 -0500 Received: from [2607:f8b0:4864:20::102b] (port=37443 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkb-00018A-Av for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:22 -0500 Received: by mail-pj1-x102b.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so1317089pjl.2 for ; Mon, 07 Feb 2022 23:17:20 -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=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=gmYbOyHnRRx25PqbtkoldsWGj829upddaG0l7dqxwlvXsg+T6IxD9Yv/R8r+7IlAP1 4jRt0juUpwoJtaLKj6THF/6QZUp0YHDm4hUuXV9rzfl/CSQqQxpIpWC1NZr/nGk3HKwr 8YPt7BEtviv3xnJYkkcjgdTqhtB0kZavxSHTH662tTHQI6Ix1QmHwR6d/9DyN3PzjRGN Ctfa5yWOf/NlLp8YrRC9HnZcCZhTi8eZlDHXSLliZV0qjVcpXGkyhzR+KeXBzecL/p1r PsNh8WnLBVGvHuQYT1oHjv+iq4QvtyzhXiJo+GeuvPeM8Asun73x2dokIcGx5/EasENu hfLw== 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=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=Jb78veqw5OQOJa/CkVa4MEHNtxUaChKNidM17uZ9weaiwjboJ61kvPQYD2VLwhRFd6 msB758iNkMNa/saO/E+wz1NV5fCr8KcllTcVHYDe76J1m5dmFvGgOgF+MasCLVuKfP9W X3JMOuA4gjs7ZECVc8O7K62NivbGgfqnU5Ivdnj2QRkM6lPcy3V1I+gF1DlV8UeBS0A7 1G3wx2pdPrcglkH87DHb3sRnOJfJcWE/tiR6uBedZ/tIyDpilaSXekvYsTeVkeRUAOOV 8sGmItFjBuqwtOLKOn/ndEGmizjqmsNczGHzEbrYcgdLZHhkszF8W9Ofi8IpSE5mpH7V w/HQ== X-Gm-Message-State: AOAM533lle2/WIUGje7yPPOfUVY46hv1KAvystVDxaK/w8upmdWwoXpL jKNLehG+hRRU3BfPdp7sHIFT4nT5Y9pJzw== X-Received: by 2002:a17:902:eccc:: with SMTP id a12mr3371454plh.140.1644304639970; Mon, 07 Feb 2022 23:17:19 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 2/8] tcg/sparc: Split out tcg_out_movi_imm32 Date: Tue, 8 Feb 2022 18:17:04 +1100 Message-Id: <20220208071710.320122-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Handle 32-bit constants with a separate function, so that tcg_out_movi_int does not need to recurse. This slightly rearranges the order of tests for small constants, but produces the same output. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/sparc/tcg-target.c.inc | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 82a7c684b6..576903e0d8 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -413,15 +413,30 @@ static void tcg_out_movi_imm13(TCGContext *s, TCGReg ret, int32_t arg) tcg_out_arithi(s, ret, TCG_REG_G0, arg, ARITH_OR); } +static void tcg_out_movi_imm32(TCGContext *s, TCGReg ret, int32_t arg) +{ + if (check_fit_i32(arg, 13)) { + /* A 13-bit constant sign-extended to 64-bits. */ + tcg_out_movi_imm13(s, ret, arg); + } else { + /* A 32-bit constant zero-extended to 64 bits. */ + tcg_out_sethi(s, ret, arg); + if (arg & 0x3ff) { + tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); + } + } +} + static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, bool in_prologue) { tcg_target_long hi, lo = (int32_t)arg; tcg_target_long test, lsb; - /* Make sure we test 32-bit constants for imm13 properly. */ - if (type == TCG_TYPE_I32) { - arg = lo; + /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ + if (type == TCG_TYPE_I32 || arg == (uint32_t)arg) { + tcg_out_movi_imm32(s, ret, arg); + return; } /* A 13-bit constant sign-extended to 64-bits. */ @@ -439,15 +454,6 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } } - /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ - if (type == TCG_TYPE_I32 || arg == (uint32_t)arg) { - tcg_out_sethi(s, ret, arg); - if (arg & 0x3ff) { - tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); - } - return; - } - /* A 32-bit constant sign-extended to 64-bits. */ if (arg == lo) { tcg_out_sethi(s, ret, ~arg); @@ -471,13 +477,13 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, /* A 64-bit constant decomposed into 2 32-bit pieces. */ if (check_fit_i32(lo, 13)) { hi = (arg - lo) >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); + tcg_out_movi_imm32(s, ret, hi); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arithi(s, ret, ret, lo, ARITH_ADD); } else { hi = arg >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T2, lo); + tcg_out_movi_imm32(s, ret, hi); + tcg_out_movi_imm32(s, TCG_REG_T2, lo); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); }