From patchwork Mon Jun 21 23:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464622 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4671313ejk; Mon, 21 Jun 2021 16:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3s5mmdKn9Hnt+lcj/1ap6qMKf1Nv2l3YUPbSCUl5qZRqzlPGDyfYAMv3lzA3HGErR0HBk X-Received: by 2002:a05:6602:2145:: with SMTP id y5mr417776ioy.4.1624317902695; Mon, 21 Jun 2021 16:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317902; cv=none; d=google.com; s=arc-20160816; b=gSvn8C5mdK2suBPU+rB9SOUrf8V+uv2yf72BoVA/dtXKwIBNDAsUyQhdP8zx3f5zqs G+LkRwvCd0mJk3/OJrwPNaoQYmiZ4jXG7srKDOY12Xvqsttfd56UmDifZSeD2XVd5C6+ SffJ9faKzHL5V0nIDLH7GKCNJVr2lJlq72Cyi/X4/w9O4HoFgCxp1YpWigkySQf2RqV1 AVBZbeEHW621EfNl2Bq5g7LnPRQp2Wj+vkKNK98ZbaBL4ahfjpbFV3bwx3FAafJh3Rwy GEKMa6l5ah3S/9E9R2zcFDnfjRm+J5+fSy/dMLZ+DeU4mBuoZzoRZ0txMLMKkYcIu5LD 27MQ== 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=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=bHJFwUS3FfJXHqedWq5vTDlvfjQvHpMdkZ+CVZkiqqioPgrYDGCZ3KyvZjmAz1qdF/ PnR1HCYZF5stW06l+1T2dQL4ppCGjJnzRaz7Ruigmqxl4fDg9fabcTUUBUvHbbtivPqT I4BrMYQ44FcQJyJ47s9aVMYSd3tqgkakozBZb4SC+cIU1b43H1YK3SdipdSUqgnJbhkT YCryhaX5Nhuax1M6Cj32icKnlizm34KWbiWHOGwc+xKkGHPzr80Hwsw5W2OtYu788Pce VT75ZSh8AAapSURGyAzc1CsgRiMWLouZjYAh5Wnh9AXKcqDwX4m7V4cQbeqfZuKpGa/y eHNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFda8L2q; 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 i130si8572539iof.93.2021.06.21.16.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:25:02 -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=oFda8L2q; 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]:44532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTHq-0003zB-1Z for patch@linaro.org; Mon, 21 Jun 2021 19:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC8-00012M-3j for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:08 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:43978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC4-0005zv-G4 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:07 -0400 Received: by mail-pg1-x52a.google.com with SMTP id e22so9217604pgv.10 for ; Mon, 21 Jun 2021 16:19:03 -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 :mime-version:content-transfer-encoding; bh=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=oFda8L2qJhd/CqoTHlA6OVWaudHu99+9rYznhORIb/RYN56Aqf0MSjlfdfVzzAAp1f sfs+1XXW3/TMyURrP+JmUWlKwJVpGAd6LwLJk8XUHdOJuUCohzYSW4Z6N5ASLKAevYBV IVoHlfuYkBN2D6pv5vBv0qaSncaXMb+hJ9V5Ho6vGNttIWN/BA13sPq9CtUxlp8eYoYt QWLt6gykjhZ6TNYn/G71ET6/rV8HSy3iYg7YG5DqQc1jPnSOVOuNduPmNyhrf5cLqWKk 6qetOMNGgOR2+/ifK7VBdhUdVjQ4+6A89KwJwe42fTyugYoPErpwfviTlYjHZf1ncR67 53ww== 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:mime-version:content-transfer-encoding; bh=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=SPBhWxVc54/UdrLg6punqMXGZpO9g6OoooqKR2EyUQb/C72mqUwLJhPQLi0f9hLeBz jcu/SxGerfndC0LE/TC9MYPGOgoCgF2hVK33rAOTpMwPiw/w8KRcNOqb4tGQBD2S20Kc y1NODFRMn3FQc+FgNxr4JAt/bbgpOHyKXuCNWDb5yJD0MemYgdkOOAYizW8C3LokQB2G PesnrM2QKrDZN+wdrs6wqogiIUK58bWUkw1h0IIShKCWEHvGmxPKk532P45QOR9kqcXd GUSy8Lh501Mj8YaiVuqWOkGrMM5QJQ07ms+naBrfv70Q806QlGn8Xhg3eYq16ctjLrZF jsmg== X-Gm-Message-State: AOAM533+XLosn5P9tTFLldPIrYQ7TNgs7TDHct5Yi+q4KzvwF9oo4NZn sGg27q7mjwzAal7K2wWjj1cniG1jtQJyNg== X-Received: by 2002:aa7:8e18:0:b029:2ec:a754:570e with SMTP id c24-20020aa78e180000b02902eca754570emr603287pfr.38.1624317543161; Mon, 21 Jun 2021 16:19:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/29] tcg: Make use of bswap flags in tcg_gen_qemu_ld_* Date: Mon, 21 Jun 2021 16:18:39 -0700 Message-Id: <20210621231849.1871164-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can perform any required sign-extension via TCG_BSWAP_OS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 949cbf2f03..0eac2d1969 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2876,7 +2876,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { memop &= ~MO_BSWAP; - /* The bswap primitive requires zero-extended input. */ + /* The bswap primitive benefits from zero-extended input. */ if ((memop & MO_SSIZE) == MO_SW) { memop &= ~MO_SIGN; } @@ -2889,10 +2889,9 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { case MO_16: - tcg_gen_bswap16_i32(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext16s_i32(val, val); - } + tcg_gen_bswap16_i32(val, val, (orig_memop & MO_SIGN + ? TCG_BSWAP_IZ | TCG_BSWAP_OS + : TCG_BSWAP_IZ | TCG_BSWAP_OZ)); break; case MO_32: tcg_gen_bswap32_i32(val, val); @@ -2965,7 +2964,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { memop &= ~MO_BSWAP; - /* The bswap primitive requires zero-extended input. */ + /* The bswap primitive benefits from zero-extended input. */ if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) { memop &= ~MO_SIGN; } @@ -2976,18 +2975,15 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) plugin_gen_mem_callbacks(addr, info); if ((orig_memop ^ memop) & MO_BSWAP) { + int flags = (orig_memop & MO_SIGN + ? TCG_BSWAP_IZ | TCG_BSWAP_OS + : TCG_BSWAP_IZ | TCG_BSWAP_OZ); switch (orig_memop & MO_SIZE) { case MO_16: - tcg_gen_bswap16_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext16s_i64(val, val); - } + tcg_gen_bswap16_i64(val, val, flags); break; case MO_32: - tcg_gen_bswap32_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext32s_i64(val, val); - } + tcg_gen_bswap32_i64(val, val, flags); break; case MO_64: tcg_gen_bswap64_i64(val, val);