From patchwork Tue Jun 29 18:54:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 468371 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5270104jao; Tue, 29 Jun 2021 12:58:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8HH4POW51Isg0/Gt37nd9WmH33doPA+yd3FjfqP/QqXN1L67IXUY6JgFsTmXJHJC3lGDh X-Received: by 2002:a25:cccb:: with SMTP id l194mr38341565ybf.310.1624996685648; Tue, 29 Jun 2021 12:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624996685; cv=none; d=google.com; s=arc-20160816; b=NJ5hmG4RmPQpuDvNL5ifpKNeloIuwyW7Zd4+SxJx/INS5v9JodF/JpzmMkHionZkxV wvXditcyXV6ZpwOgzct8NbZdnktQRKx13he9A4xvRY0Yuje/j0RJ3Zs3zgv12FLPwJC4 +fR3b/P9bXpazOnG+vaFVsGGm8KEduGQAnA/Aaz5sWDx5zH55x2RuHifFzT+7j5J4eJ4 kBD9yvTSXIpW44rYaQdeX90oGj+x/Rn2Y3eTdxjH+sqIlwAUSx9MI/U8qE79MEdEE6Z/ EzEZk/DUPWJzAqyf1Zgvk8bVDRBfe/YVyBNCU5sXMPhapF8GmLkiiklYyvk+ozcuJbbq Vmcw== 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=eqcIH7qyxMLCC/xbyp4OcZdnc1e2Y1iNmkzCM4CoVhg=; b=EYxmpdZyi4y7lcnCd/Y2+zfxbzWoPXLMoud0YKwCQcTLTA/1IVLmJPpHCGYa4HNUeR nl6x+jyD/mQLKfcJCJxAirYEDVNsR9WRoIqm3G9oQcQKyB7txRSQFg/V7MjR99TvlcK3 rkKBFD2jZ8kT407w53cbXplY5/MtdzMwqR7NXSNdujC+odKl9vYFcTV1zRlVr/GMWpyc CPtWIKKwJ+fab7PFbe+WmRbG7Q2q9E9l1FRAHIYBgMU20nuByC+TUB44vcr0dhIz6Jql 7AxudduDn9DiiFivBBIUQAcZjnj/Tl03BTJT54m/rOYJdei+UEhKK05RG6mAOfJTlpYz YgyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WlBo8Bo8; 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 c127si20083932yba.286.2021.06.29.12.58.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jun 2021 12:58:05 -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=fail header.i=@linaro.org header.s=google header.b=WlBo8Bo8; 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]:56438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyJrx-0004e4-58 for patch@linaro.org; Tue, 29 Jun 2021 15:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyIwf-0004AC-Jk for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:58:53 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:35575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyIwM-00030x-PP for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:58:52 -0400 Received: by mail-pj1-x1033.google.com with SMTP id pf4-20020a17090b1d84b029016f6699c3f2so2609222pjb.0 for ; Tue, 29 Jun 2021 11:58:33 -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=eqcIH7qyxMLCC/xbyp4OcZdnc1e2Y1iNmkzCM4CoVhg=; b=WlBo8Bo8YXuU9RjQWy4jkn+1reyL52IKjAopoye4YTadviBhzeYh4LO4s6YtmyeziD JC1WM6aixncYYqDhWUDAQ4EZnt9i3nJ9foXgfpeit2tAZp8piX0UlCNSSlwhy8EJLwdC QThbiPv6F0RwO/TFnsTGqBYDsx5q0FIs9AqQsSXuEfk9AYrXX/9YAAeVvwenpQvmuf4p p0jKgsoPDYovtc7XP8genmR8FlB+fgV3CY0mBWWe3uOJPmV/6aOnkLn3/+hL8M9O6ZX5 omqI80fv/H8L1Vk1VM3xGIkR3XZVkDj1ap4F/gUFNKT+0vHEHwI0yAtoFwl9wh9CVyuS ZuJA== 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=eqcIH7qyxMLCC/xbyp4OcZdnc1e2Y1iNmkzCM4CoVhg=; b=Eze5nQajjO3hqG05LrNUlZxQ2ThdX5XBTP2vvMK6a4sp5zG+DaNB/hV7x7pHVxmchz vH8Z/7y3OaqCFo/PFnOaFs79PYbf8Un2DhslraN2AoyuiR/B414BQSTMFhnLlGvOMZjA xQ5q9UAFlRtJsX2rJzrlYJw4aphMaoT7pqLhfKHGRowrNoRY9EKyXi7POvep2E1hhLVB /QcA7Z+SztwesFj4YpShDrH7PAKb356iqtZT35yH2o3hNOVjtzs6wUJh0dizx/iQtUL5 222v0bI4aRFrWPLDuxeSvAJ3cgUtk6GJLF9BsLTXqmVZvninR0qNz2J7AGJgnQ3jYyTS fbzA== X-Gm-Message-State: AOAM533uVu6tKduSjI3a/P8Zy5Ud8hFDIcGF4RawQ6YJL9wvYDAG8S3v VBoxoI2RnBQro9pr9QMqgC3zhm74G1F7YA== X-Received: by 2002:a17:902:bd03:b029:11c:d504:c1ce with SMTP id p3-20020a170902bd03b029011cd504c1cemr28841666pls.7.1624993112813; Tue, 29 Jun 2021 11:58:32 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 21sm18002849pfh.103.2021.06.29.11.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 11:58:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 53/63] tcg: Make use of bswap flags in tcg_gen_qemu_ld_* Date: Tue, 29 Jun 2021 11:54:45 -0700 Message-Id: <20210629185455.3131172-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210629185455.3131172-1-richard.henderson@linaro.org> References: <20210629185455.3131172-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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=unavailable 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 , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= 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: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 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);