From patchwork Fri Feb 11 01:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 541771 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2719404imo; Thu, 10 Feb 2022 18:06:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS3p2171QqRxQUY36u8/uYi/VLl5NNjLhrjxNvZUXPsacZE75mv60M1AmxD9D5AfBpycqn X-Received: by 2002:a5b:5c3:: with SMTP id w3mr9874715ybp.761.1644545169770; Thu, 10 Feb 2022 18:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644545169; cv=none; d=google.com; s=arc-20160816; b=P5UhSLpeUoK2GwFZtvvhPpkFEneRw2d5gQmABHuFG1bKaPZay812TUWCxtlR0Qrdet BfeI5H5VazAOjhSJ0XGzO6w5X6kPTFj46ssN9LZqeZ2Mc/5TAb2oO2FZsa+pHjLXPHcI dPu8NF+umEbs/5nW0da+MVg1Nylq6NEA3aqwsjXcLoKSBRcB8TY6gpSSzr1UscM5mi/R 34ZFtNaERp1v5KW8nqJEcab33O/MYyIVZnUmuFgwW3wwr/INKamQZkbPrz8bYNuxuFOa HYwOT8ETsNopc+nyBGTIJrdQu9nXT1Xon0Q1kp3MBGpQdZ10RDZUHgupoXhUSlRglcDe cIDQ== 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=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=Qxdvjs26JxfQVeyoWnN7FFyskudeYabCnNPCMYcngqkVn3yRAi+Uix4VkWRPPbXrJH 8N4xaQlpDlDUJgWqYKeEnoDQtuyuTA38X5X9zOWMCcifQpznRBhYHGIe2fSvY3wU64gv so0sPH4AV/vEq6QS9T0ea6Mz8dM35ysQzm0AVxbEWDJr/5NMCkuB9t48pA+Is5I1FXHw fAFqPkuNAsn0TLNcy9MIEJIdCsHU/nLZOeYO9+B4Rnlw+kondJMhzO+lRUl+tSQzK9Dv wYc47nSp5LOklu7wVznBAaBYWB4ddTPMu7EgYlO8rAJtshoVRiYep37AaSbDt+12Hy4B YCug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B9GCi5TH; 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 n127si15756918ybb.454.2022.02.10.18.06.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Feb 2022 18:06:09 -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=B9GCi5TH; 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]:52020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILK5-0005KG-2h for patch@linaro.org; Thu, 10 Feb 2022 21:06:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo6-0005Uh-Ik for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: from [2607:f8b0:4864:20::102a] (port=50721 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnz-0007TV-Ca for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: by mail-pj1-x102a.google.com with SMTP id m7so6793928pjk.0 for ; Thu, 10 Feb 2022 17:32:44 -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=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=B9GCi5THLac5y9J1TUd45HvlxD2Tr6LPbXYWHjkP7XcyBp/c5v65PAiTv6TzZkcjki EVoLQKrSUc1kAmdT3l37lHOSmlZs55+UP73wVFaxDCjICLVUy/WEJVF8WAoK1EBMivj6 N28tfiX7ceE1tDeKi3y035mT2YQCNicam1IP+pPU5InUSxoO+h2jMTIRj+yG8ktfYBPc usG8Nxv/11Y3MWkFYB5+MqcUoPeOFRElvfodR7cUX36Rg/slYIyra9A6BT5UVQ30W7Od GjnwZj1pa3ZoYPbuGguqg1kENvG0wADtPq5vqWvTQNKCRZlYxAB9YYTL+KzksbWgmOoG XZBQ== 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=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=ns8/y3tg9JNEc6mLYonyCoR4fraRvY6UcISTx/HwyNiLbCAGRg+VoZy8Ps8nsg7EOI pu3+xa7TC+GL78Mzo6Q6Vr17WRDkwiRlSTIaPc8/a1Swuw3uYzbVkcm99nbEK0KZMXrf f3wICZBuDw33vCU2eGwaxaPw/nw60Abf48yyNoP26p2vikTbzPacfkmCjOshTZUGS4jy Lz6AJrvd6gDWXBGgMBVbQ6SAYmNzdMp34VZDkVfMbVLi2LnE2AlyOdVbnJfwNTEkW9Jo fdNEnCLh3Lrt04dXj12tDPA9bqYX413misfDO+oETRqWSp9OLB2k8I7zuE0NO1jOPZkX OQ9Q== X-Gm-Message-State: AOAM531pqzyLkLw8r1QzPkC26pnGaMwDzxI9fto47ScdYSHFokLY4lGr wDKNu9L0puKtkNlw74GPaYRLApjFzoy+/w4H X-Received: by 2002:a17:902:8609:: with SMTP id f9mr9949638plo.80.1644543163026; Thu, 10 Feb 2022 17:32:43 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/34] tcg/sparc: Split out tcg_out_movi_imm32 Date: Fri, 11 Feb 2022 12:30:52 +1100 Message-Id: <20220211013059.17994-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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 8d5992ef29..2f7c8dcb0a 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); }