From patchwork Mon Jun 14 08:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459766 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3082996jae; Mon, 14 Jun 2021 01:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuqTJym3Vw9KLrnx2zYBCvY+lXvUAJR+meykMQcjzMnFHENWBQ39rRL+3DPIRBBKHdXEr/ X-Received: by 2002:a25:74c6:: with SMTP id p189mr23100149ybc.84.1623660093056; Mon, 14 Jun 2021 01:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660093; cv=none; d=google.com; s=arc-20160816; b=hMz2Wo60QDVDmL27Oq0iE1X6FHrCa+We/gufdAJrAGowd3y3HxK0b9UeuVQq3ZTP1r mWW2fKsMn8R+EaQatN/6I0NDJh6+pXyFVaUAAGKRTJS92Kz+wNezGHkEftHLcqGaLA9a hQ+nCItsEs7xz0oovtAmRKupEWwVOODZCzooOWL0jLEEBgeY7P02i07LzvfTa91GaJQa 4P8knYs5ihtQVxpBQAUO49JFpUiLZDSLcBXzVN2rTvbrPuXLnS+eeh4fJS3GMggIphZ5 KFbWO3FACnXHpXT5AROcv4AX2rFhGSCO0760jWudNvegHUcyWblCANFST5dXi5S7onZV prjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=iqNyuQcVQISsWNDc33MXpnTn2txRGHf9DOqpB2Sl+J8=; b=Toe1QAAg4Lxf/530zdPbL1dXi9rO2AeAuKA12AOFUtAK7pI6ZH9cdRhqc1kmIV2PlX Rzgo0irlPgNgchr8yhx1+L2tSfxZK/Mx31nLUz7Zoa8tCyRjW79Vt1kBu0QzVq2/jqfY oSfKJyZEPoVuHtgfxRIwdAGjRZsIPimv5rk4gt/J279JD7aLr41Zx/6lUq661SuvRM0N JbaAz9Ob7/LeDaLbOIZc2hIa4Daq8KBtTO0pz8+QkxltM8EHwIK+syAxbons0ArghncG CQFW/HOQzmLdyMfZZWuX9Jt5tSftkModuEZCfnEdYCTon0AQgcZY4ySYINUZihXbGFSI /5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xEXUF6qS; 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 c66si12676531ybf.369.2021.06.14.01.41.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:41:33 -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=xEXUF6qS; 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]:46974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiA0-0007vb-GI for patch@linaro.org; Mon, 14 Jun 2021 04:41:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6h-000249-Bn for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:07 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:42785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6d-0003Tx-MD for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:07 -0400 Received: by mail-pf1-x431.google.com with SMTP id s14so10005628pfd.9 for ; Mon, 14 Jun 2021 01:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=iqNyuQcVQISsWNDc33MXpnTn2txRGHf9DOqpB2Sl+J8=; b=xEXUF6qSou5HkYhjhFaDapam0OTmKI8ofnVuhucNEO3T8fo/wvK/uYxWzPF0TWZvC7 9DUGXYwfRTQ2xDP87ZwLNZLd6/TzaUKUV47RqPkDjCKS2FbA+Yxk502TezGSG+15bOhE AUQdvOhA8JI8kcCXyWn/U4RXoONpkwMKMWLnjzNpPs4EuyyZYlTAnpbmUsX4WdEQzDSt zZnZmVJXCpqOJ11GtptZQqmxqPZmvqTZDqMw6QPyoIqrDTLbErgW5cDIXofUm85p0dMv RihygSafGqAX8xGZVeEg/Hnb4ehbR6SJ1dQGw00dr6aPcGtXjk6UzZzeLSPBmqzaR8oV 4EfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iqNyuQcVQISsWNDc33MXpnTn2txRGHf9DOqpB2Sl+J8=; b=hC6af4aWKJaFsfnae4wdRTt4HnuqMT79M6gihnKuJtdirpi4MQzaVABYxoWPgbodvc A0DwRY7oK5fZ+NQwcSqtIJAZz/1HMu8ACPdpmCZZRUUOUfy7HtYsDQd31oAXI+m4L0pr Kh53CymHGgQus32nQv9qJDmeNDsKCnGYKmy9xuIeYquPPD31D9WRv0vDcmARdqiCIz35 Z3FhAlo/QlBSFdLxC+TPEuLSqWk+fzRSRmiK7qGTt+BGjVzMJkv7fKs+OHv66hgaHCaN uwfZkw5GdU7WMg4o41Pth9j/VDl0ExmivC0JUpkbcOANAcCJ5dpnwYb4LcJedSfxvTTK YjnA== X-Gm-Message-State: AOAM533aQqGJYcawPJDzt75pcEhxdtrr8hpbrPQIItkJPzcqTT8dfL6g OOFCqmtSWeKVv1sOK+tz9ISEQongrAKtNg== X-Received: by 2002:a63:e205:: with SMTP id q5mr15993024pgh.404.1623659882195; Mon, 14 Jun 2021 01:38:02 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/28] tcg: Add flags argument to bswap opcodes Date: Mon, 14 Jun 2021 01:37:33 -0700 Message-Id: <20210614083800.1166166-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will eventually simplify front-end usage, and will allow backends to unset TCG_TARGET_HAS_MEMORY_BSWAP without loss of optimization. The argument is added during expansion, not currently exposed to the front end translators. Non-zero values are not yet supported by any backends. Signed-off-by: Richard Henderson --- include/tcg/tcg-opc.h | 10 +++++----- include/tcg/tcg.h | 12 ++++++++++++ tcg/tcg-op.c | 13 ++++++++----- tcg/README | 18 ++++++++++-------- 4 files changed, 35 insertions(+), 18 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index bbb0884af8..fddcc42cbd 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -96,8 +96,8 @@ DEF(ext8s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8s_i32)) DEF(ext16s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16s_i32)) DEF(ext8u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8u_i32)) DEF(ext16u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16u_i32)) -DEF(bswap16_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap16_i32)) -DEF(bswap32_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap32_i32)) +DEF(bswap16_i32, 1, 1, 1, IMPL(TCG_TARGET_HAS_bswap16_i32)) +DEF(bswap32_i32, 1, 1, 1, IMPL(TCG_TARGET_HAS_bswap32_i32)) DEF(not_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_not_i32)) DEF(neg_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_neg_i32)) DEF(andc_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_andc_i32)) @@ -165,9 +165,9 @@ DEF(ext32s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32s_i64)) DEF(ext8u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8u_i64)) DEF(ext16u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16u_i64)) DEF(ext32u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32u_i64)) -DEF(bswap16_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap16_i64)) -DEF(bswap32_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap32_i64)) -DEF(bswap64_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap64_i64)) +DEF(bswap16_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap16_i64)) +DEF(bswap32_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap32_i64)) +DEF(bswap64_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap64_i64)) DEF(not_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_not_i64)) DEF(neg_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_neg_i64)) DEF(andc_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_andc_i64)) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 064dab383b..7a060e532d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -430,6 +430,18 @@ typedef enum { TCG_COND_GTU = 8 | 4 | 0 | 1, } TCGCond; +/* + * Flags for the bswap opcodes. + * If IZ, the input is zero-extended, otherwise unknown. + * If OZ or OS, the output is zero- or sign-extended respectively, + * otherwise the high bits are undefined. + */ +enum { + TCG_BSWAP_IZ = 1, + TCG_BSWAP_OZ = 2, + TCG_BSWAP_OS = 4, +}; + /* Invert the sense of the comparison. */ static inline TCGCond tcg_invert_cond(TCGCond c) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index dcc2ed0bbc..dc65577e2f 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1005,7 +1005,8 @@ void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg) void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) { if (TCG_TARGET_HAS_bswap16_i32) { - tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg); + tcg_gen_op3i_i32(INDEX_op_bswap16_i32, ret, arg, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); } else { TCGv_i32 t0 = tcg_temp_new_i32(); @@ -1020,7 +1021,7 @@ void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) { if (TCG_TARGET_HAS_bswap32_i32) { - tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg); + tcg_gen_op3i_i32(INDEX_op_bswap32_i32, ret, arg, 0); } else { TCGv_i32 t0 = tcg_temp_new_i32(); TCGv_i32 t1 = tcg_temp_new_i32(); @@ -1661,7 +1662,8 @@ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg)); tcg_gen_movi_i32(TCGV_HIGH(ret), 0); } else if (TCG_TARGET_HAS_bswap16_i64) { - tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg); + tcg_gen_op3i_i64(INDEX_op_bswap16_i64, ret, arg, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); } else { TCGv_i64 t0 = tcg_temp_new_i64(); @@ -1680,7 +1682,8 @@ void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg)); tcg_gen_movi_i32(TCGV_HIGH(ret), 0); } else if (TCG_TARGET_HAS_bswap32_i64) { - tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg); + tcg_gen_op3i_i64(INDEX_op_bswap32_i64, ret, arg, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); } else { TCGv_i64 t0 = tcg_temp_new_i64(); TCGv_i64 t1 = tcg_temp_new_i64(); @@ -1717,7 +1720,7 @@ void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); } else if (TCG_TARGET_HAS_bswap64_i64) { - tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg); + tcg_gen_op3i_i64(INDEX_op_bswap64_i64, ret, arg, 0); } else { TCGv_i64 t0 = tcg_temp_new_i64(); TCGv_i64 t1 = tcg_temp_new_i64(); diff --git a/tcg/README b/tcg/README index 8510d823e3..19fbf6ca52 100644 --- a/tcg/README +++ b/tcg/README @@ -295,19 +295,21 @@ ext32u_i64 t0, t1 8, 16 or 32 bit sign/zero extension (both operands must have the same type) -* bswap16_i32/i64 t0, t1 +* bswap16_i32/i64 t0, t1, flags -16 bit byte swap on a 32/64 bit value. It assumes that the two/six high order -bytes are set to zero. +16 bit byte swap on a 32/64 bit value. The flags values control how +the input and output sign- or zero-extension is treated. -* bswap32_i32/i64 t0, t1 +* bswap32_i32/i64 t0, t1, flags -32 bit byte swap on a 32/64 bit value. With a 64 bit value, it assumes that -the four high order bytes are set to zero. +32 bit byte swap on a 32/64 bit value. For 32-bit value, the flags +are ignored; for a 64-bit value the flags values control how the +input and output sign- or zero-extension is treated. -* bswap64_i64 t0, t1 +* bswap64_i64 t0, t1, flags -64 bit byte swap +64 bit byte swap. The flags are ignored -- the argument is present +for consistency with the smaller bswaps. * discard_i32/i64 t0 From patchwork Mon Jun 14 08:37:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459770 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3084200jae; Mon, 14 Jun 2021 01:43:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW3c24oe+TcWIrkLQOIze9fP9xMtF+I2JJ4edKv9MyBTdd8wN+91zBBng+YCoHupkzqh1u X-Received: by 2002:a92:cf0a:: with SMTP id c10mr13322920ilo.97.1623660226042; Mon, 14 Jun 2021 01:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660226; cv=none; d=google.com; s=arc-20160816; b=TTWo5nswB51gBCPjd/RUkqcPiNJQpRXxPp977OV5nQbMgXwkicJ7oDnZLWFlagXSFD jYNf6quJpDaNFdDBVqxY5lDIBdJONYKLG7rT5hklx2T8VeFu2S6lrWqyxp0/FUF+wi6I 37uQY74yO7ss9fyuAqs7YR1U/fvtqGf6FXyTxfjWf2FJkiTjHqD+sTpvAR8wYPD2LFvm 5YWpa/yDSM/iHlxecjp3vSf/aDvWr+JxUJrsScrOyDoGLLCnfCiqcnqjGAho1gP72QRq cd5vbYBoMiDVQY1mJVtR/Mx3Ca+ppFKq8ZsJwckPnGFMa8wBNi09WvFhLcF6KIww7nGs lrDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=4DK6YQsyP2TgsSpoYuX8S0y+YBX8JV6DUGLMLbaWI8M=; b=wFQBDmXfnI0YKDyYW+soiikNuvoDLXMF+YGaxHNkHSBp4H2gVRrnv9mlDlnw/uIN4A +D9xgsgsnrrVrtmZ7o9PSHGzpQlWuyt//0vBWIMglVHMv391sawk8kC4XmWdBOk6ptwY aVk5wOgU4fehJn9EEPLpdBc1AKioe2jCgS/Q08kQRu5IWs6wSBExxa/y7O6laBGKcfV0 LxjNwnamB0uGozyiUbVnccXdl/fucImYcTH2vKfiOgfM/StBFw4JEzQwS1eU8kLDRg6J gYym1OkD7TcmSBo/tXd88JtrzBUgZmeXGBkumTQDl9hEASJitYFsgPjePBNCS9ruCv8F ZUuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NMUo5BkX; 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 17si15100509ilg.11.2021.06.14.01.43.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:43:46 -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=NMUo5BkX; 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]:55566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiC9-00059g-G7 for patch@linaro.org; Mon, 14 Jun 2021 04:43:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6i-000254-8y for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:08 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:34407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6e-0003Ub-7i for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:07 -0400 Received: by mail-pf1-x42f.google.com with SMTP id g6so10024594pfq.1 for ; Mon, 14 Jun 2021 01:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4DK6YQsyP2TgsSpoYuX8S0y+YBX8JV6DUGLMLbaWI8M=; b=NMUo5BkXtMOLjG7doIxADaXldMtayo93V6KOKIndFS6FHxdLAUUH4Ev2GE+DkUJurT FD5vABkRLGmeTLMzkIsvvA5P24mHYcFDQHkqA0evcxHooGdR5DEn/rIBWtiCfrwdGYcE k3Xgmj97tbkwdUaXvZeQ9ntCFen8DCZKi14fQHFIqYjX4v8QT2UJEBls62v8yPI2VGuN Xcj3OuXztXZMJSxWhAANBplbD3ay5kWK6F6pSLnCcKmRUA4PddqIwxkfrde/bW+fcY3O SQjieZPqz+uah6oUGkC4fG9D+gQ0pK0K6qco3kh1i3udtBe1Xqy0HiBYLL1HzNuuwn4w OraQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4DK6YQsyP2TgsSpoYuX8S0y+YBX8JV6DUGLMLbaWI8M=; b=MiRaVouaTePSeP4fZBtECDSUMrqCTARfEeQs7V5r96xLLkqTZ2UNXrElfBfhIqzgid mIrkeFaq/Yg8Ka4vAOvfR9h3CCj7v4Acgfg2Y3MZ0ueRWKiE1Mieb0ovL93Tj19f4djD P0eE80p7CF3vqpN+E6wyjbxU3XRo73Ge6INOkOnyQXzfSn9n1rt4ulWsHoDty8tx9I69 ib2b7YEV3OsgTY/E3NsuOaUZe4Tch747MNf3OZA64oppvrqRMh5bpLbgffv3wA/ljBK5 8t9fwYw2PnlvFGeuvPdKWJAKGtVmT5nyTqopF9lPLpp656hRCLV3ec/zGqJWplV4IJFD xs8A== X-Gm-Message-State: AOAM532VF6SJ5YnQunNA2kITCsFuwVMS/qRJEmxaT6ivVKuM17ojyy6e Bdy1xdQSM41lsVHB7eyOHGYoYtKMBw9juw== X-Received: by 2002:a65:520a:: with SMTP id o10mr16194565pgp.172.1623659882819; Mon, 14 Jun 2021 01:38:02 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 02/28] tcg/i386: Support bswap flags Date: Mon, 14 Jun 2021 01:37:34 -0700 Message-Id: <20210614083800.1166166-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Retain the current rorw bswap16 expansion for the zero-in/zero-out case. Otherwise, perform a wider bswap plus a right-shift or extend. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 34113388ef..98d924b91a 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2421,10 +2421,28 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; OP_32_64(bswap16): - tcg_out_rolw_8(s, a0); + if (a2 & TCG_BSWAP_OS) { + /* Output must be sign-extended. */ + if (rexw) { + tcg_out_bswap64(s, a0); + tcg_out_shifti(s, SHIFT_SAR + rexw, a0, 48); + } else { + tcg_out_bswap32(s, a0); + tcg_out_shifti(s, SHIFT_SAR, a0, 16); + } + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + /* Output must be zero-extended, but input isn't. */ + tcg_out_bswap32(s, a0); + tcg_out_shifti(s, SHIFT_SHR, a0, 16); + } else { + tcg_out_rolw_8(s, a0); + } break; OP_32_64(bswap32): tcg_out_bswap32(s, a0); + if (rexw && (a2 & TCG_BSWAP_OS)) { + tcg_out_ext32s(s, a0, a0); + } break; OP_32_64(neg): From patchwork Mon Jun 14 08:37:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459764 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3081844jae; Mon, 14 Jun 2021 01:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxrR/EzUuds8dTSU5JqEVRDuANRXr83yc4YscVnDnEr2IO0E5fkOAzfjyssVU+7u7alBVk X-Received: by 2002:a25:bec6:: with SMTP id k6mr24331829ybm.187.1623659960001; Mon, 14 Jun 2021 01:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623659959; cv=none; d=google.com; s=arc-20160816; b=pGLfnGSUKsgVsMYAEG0Ovc/bUWTik3tei3On2cgcgSAMcsrHsrzJOP2ZOX60fbEAfm Txvut5ACnqbpqTwZHWYbUWPPs6N7qdhrepTnVz96QtNCg2s3AhdYqTjtcieDReoGHQcC q5GgfTioEFf2CDAtR0luirn6BUxidjI1TJrkbuiNEdTZ6E2rrhs6q+Vb4nhDpqM1kT70 EWYeKzAo6lIEWDX4cAFpCa4Y8ZpwNqYlksHxuExD+Si2HnHxKTGcd8T+QXINtm2+WG20 An9Bq261G+m3o1+PAUiQD6tcy7URTV7tMrlmCl5Z9Z1f0wYuksR+wrGduOfO4BQCz/os bSGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=czDgvGtAgl/3pReno00NuxkKPkp4f3cviydaeOt2DuE=; b=bvnmXByrtwwtuGEkbVvL/mKKCha7xhzm4+DZjBN5IYTQgTFyheI3o1m92ORRoGWElU DjMlDReZVILdhUcIAp/zZM7BCH3KMudtTxcR6JWdpz9Vss5dDo4TJlx6y+UR6l+j2NT3 1Mp1jCc8KZNpn8pYfGArjYvGgSu08jtE0O6ljREzdix1RQGr3sQZhfsvdInaj+JeAnxO 4ThXYWhHOPFdp+QY1BUjhXEfsszB8kqEyps9ubxqQq9lQbcdNhStJLjBq5nz4oqw51Bk nFbK4xy2aEjQUH9/VWaIUOiXd9hPT+XYJgZU8lHQIO2tzndGhueClsYeWKXzi9zzBIfa /xYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmJdjpiQ; 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 h39si15629993ybi.337.2021.06.14.01.39.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:39:19 -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=AmJdjpiQ; 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]:38446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsi7r-00027h-Dg for patch@linaro.org; Mon, 14 Jun 2021 04:39:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6i-00025E-B7 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:08 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:53099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6f-0003Uz-Vh for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:08 -0400 Received: by mail-pj1-x102e.google.com with SMTP id h16so9287434pjv.2 for ; Mon, 14 Jun 2021 01:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=czDgvGtAgl/3pReno00NuxkKPkp4f3cviydaeOt2DuE=; b=AmJdjpiQE/03GbrJ97n12EmYqIvppOd6KUP90GSOEioPT7yOtYGzndiFUVSlJRxXXI 41QRlDKMt91a9RBWqOd7mNx+qhVM+7G3oGUaj3KqNNROvAy5Uw2czc6NEJS/hhP+tlpW lMOApwIegXuRi+CQgHmtF+SHPIfXakjWvaVfsaVKmN2s906OT2ALXvItH9LmuALVdsoL POMSrN4C2fUI8N8EdWTCA3H81dgucE9Ia+8+pzEHnBBY9ZVYZWVuRVyv9xT1Gk+nzUMa tpfw7bfQ/JZdiqmrzAs64f8qDKOBTsE/frlXRDDM7y2SkHNFHQffcrqsNxszw0cLFj2u wCZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=czDgvGtAgl/3pReno00NuxkKPkp4f3cviydaeOt2DuE=; b=ZP1d4PHWQ9L37t9gkkc7Kd/AUYroyfXQZA3z5soigBi8nJGzRMwZl//fBDm5gWF99D N3nZOgqrKaOQcSaK63iDMdq+w1oLnK3BixneZaxXxGl8ftcSSB26OmqtCcWCuKurB09L Si7SPhqht8y9oM9memol4bEJDqZ3HweYyfUQWLxfPZQc2UC5/U13Kf/jLdVgGxBiwrBg UIPX34qoEfr9jxm0FpilyUpxXDTIQ9/otw4wDZ5s2Yap5yZHrEcVPJlVIk4H9VxBgWWz wqn6SBMMyjZ2MomauRF1PxRHhQ4rqYeGgR0MLE9L/XYRuJM1I3fFH8dPpLoTLMrNkG6l iXaQ== X-Gm-Message-State: AOAM532JGzDkA/QSaATrGGuo9gh1sp03TkmAidmjef1qe47Ml82X5A9z zDpqajs6JTF9oPUZWkyyyf41FeMQASBcQw== X-Received: by 2002:a17:902:e843:b029:109:4dbc:d4ed with SMTP id t3-20020a170902e843b02901094dbcd4edmr15772954plg.74.1623659883598; Mon, 14 Jun 2021 01:38:03 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 03/28] tcg/aarch64: Support bswap flags Date: Mon, 14 Jun 2021 01:37:35 -0700 Message-Id: <20210614083800.1166166-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 27cde314a9..f72218b036 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2187,12 +2187,24 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_rev64(s, a0, a1); break; case INDEX_op_bswap32_i64: + tcg_out_rev32(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_sxt(s, TCG_TYPE_I64, MO_32, a0, a0); + } + break; case INDEX_op_bswap32_i32: tcg_out_rev32(s, a0, a1); break; case INDEX_op_bswap16_i64: case INDEX_op_bswap16_i32: tcg_out_rev16(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + /* Output must be sign-extended. */ + tcg_out_sxt(s, ext, MO_16, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + /* Output must be zero-extended, but input isn't. */ + tcg_out_uxt(s, MO_16, a0, a0); + } break; case INDEX_op_ext8s_i64: From patchwork Mon Jun 14 08:37:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459774 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3086363jae; Mon, 14 Jun 2021 01:46:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsyNC18LKAFFFK8chciV57GRw30DucCzdzLc64BWwqpMPDXHDlpFEuNSVMzkS0zax1gqxI X-Received: by 2002:a25:2c45:: with SMTP id s66mr20902476ybs.13.1623660396331; Mon, 14 Jun 2021 01:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660396; cv=none; d=google.com; s=arc-20160816; b=VnySFIdfK4DbjocRWVm3pGUNd8d1ZA57dA+GpLWsT4xvWu1Wbzzhwie04E+jQRf0/w UFqmLl01DQhoPn6ex0dAxE1wFnUllfPFXT2P0Wd9wRmeZUch57PDw8fCdC1raabQh6E0 wVhxRLEPpHDJmrOIKZ5b8JQyEjg0+3IVERp1Pv+Y/YRDbXGKVvoX6A+b3zRKBv0+na8M MhYBU9n5fKgPLrQ7hVIbfV/ylEbWtDoOu4FeZQg++TUSBDeMPGT6xVUDED6nWL65XIXN +RYdiocjVIcsxEocTZaX2aBd40FQYciZ89iegmrIHnYlC1804vCIoO7QJ78zmn11n64g G+KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=sO8Vuhh9GE568nvDdU8zL4gGQtwmUCpxM4YL6VHIofw=; b=BqbIsQ5ff3a7m60HJ5bnNrTShFrszy9/e7B26KV3kB2L4bX2KZPt1O4LikQSxI4SeN PlFCDybOP2Kk1w2sPEX4Uq7/K1gNXfpBL38IV7rrXlY+FFN4wQhUwzvXhByvnxAZPYE7 vdkVh1c7cshGr1/Nlmd6OOwS0IPrU9HbkKpkzdt027oNKeHIkWASSXV7J/7sJfk/EMYP Y3jC9b4xm3o1IohDFblZO33pMPV158nYIlv8zv5MGpw2qGsdKWl3POUXNxawyGko+0QI brTVieoSHhBgZeovBZat/p3UV1DAKcxur6IwuOV5FKNR2WCfuVMu194SOQ5adgmRMr1i s6nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jHnphA4v; 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 o128si14330681ybg.67.2021.06.14.01.46.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:46:36 -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=jHnphA4v; 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]:35848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiEt-0002QT-MG for patch@linaro.org; Mon, 14 Jun 2021 04:46:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6k-00026Z-4C for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:11 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:44622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6f-0003VJ-Vv for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:09 -0400 Received: by mail-pf1-x42f.google.com with SMTP id u18so9997718pfk.11 for ; Mon, 14 Jun 2021 01:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sO8Vuhh9GE568nvDdU8zL4gGQtwmUCpxM4YL6VHIofw=; b=jHnphA4vSdjeXtz8hrAycxppoiADzwNcC9BM4APG+HtOAysw5XUECXZViCZ8+rCZH/ SFtPzkNqIROpHQ0FM19kJQ3FEhsGxLNrP0zvxYoVYtRqmSi4y/jO0Bff/U6wo0G2r4r+ yn+SITeswH4eFPNMD9bUK2C/vr3VI7oCxOFCH7QaFGcxxoW0zwTp+Espgbd5wcs+R7V3 a2HEQ8vbxmal38XdGXgGPeCVdzImXUT8JPulETMaeRV+8St+7Bzr+K0QG3rwjjq7ZYpc L0c0f1jfFZE5UmjYlNy8cQL6nlrtXs6QkEXg7tohKSFLoVVI1K1eG8bUnZvJxEujx6Xy Uuiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sO8Vuhh9GE568nvDdU8zL4gGQtwmUCpxM4YL6VHIofw=; b=jdWlZ9HG2GQ3g5uveKoFQMzkj0tOgBDEg+ClcOrBpS7gITAMFkqzuFal5Q4RAigUaD Z5WROhoGwZfJZaBnazmcmNZ0jhWcGk4zr6TzV6xEiH8PeWc/Il2fWLffl4y+yDuCvN5a AhsTNYJkc8oeIK5a1oMGlpkdllaqOWNl3ww89CU/YKxVfgeNPC4LmG9oL6AScHk/KPDU X6PYUKIQSHg4/bvJ8h9xxdwdMOwQzbRI2oHlkntS8Y0I8O0NmfVHIZRyAkBiiU/qhvzE MX5QMWIM/HFFMIYMea8jkcw04m+qWswpe2uj/dHY28X8ftdCvGWQGhqVq15epbF7yKLy sXhg== X-Gm-Message-State: AOAM533bmX5/iA42DA3Zhpa32h8Ph+VNXq2A6mexwfUVq0xwDhT5Wmqh AV/sCOu9GWBPb9DZDFOGNuFzUg6XiFntcw== X-Received: by 2002:a63:5203:: with SMTP id g3mr16128997pgb.247.1623659884069; Mon, 14 Jun 2021 01:38:04 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 04/28] tcg/arm: Support bswap flags Date: Mon, 14 Jun 2021 01:37:36 -0700 Message-Id: <20210614083800.1166166-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Combine the three bswap16 routines, and differentiate via the flags. Use the correct flags combination from the load/store routines, and pass along the constant parameter from tcg_out_op. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 78 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 40 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 5157143246..9824e215be 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1013,50 +1013,44 @@ static inline void tcg_out_ext16u(TCGContext *s, int cond, } } -static inline void tcg_out_bswap16s(TCGContext *s, int cond, int rd, int rn) +static void tcg_out_bswap16(TCGContext *s, int cond, int rd, int rn, int flags) { if (use_armv6_instructions) { - /* revsh */ - tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, rn, SHIFT_IMM_LSL(24)); - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_ASR(16)); - tcg_out_dat_reg(s, cond, ARITH_ORR, - rd, TCG_REG_TMP, rn, SHIFT_IMM_LSR(8)); - } -} + if (flags & TCG_BSWAP_OS) { + /* revsh */ + tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); + return; + } -static inline void tcg_out_bswap16(TCGContext *s, int cond, int rd, int rn) -{ - if (use_armv6_instructions) { /* rev16 */ tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, rn, SHIFT_IMM_LSL(24)); - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSR(16)); - tcg_out_dat_reg(s, cond, ARITH_ORR, - rd, TCG_REG_TMP, rn, SHIFT_IMM_LSR(8)); + if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + /* uxth */ + tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd); + } + return; } -} -/* swap the two low bytes assuming that the two high input bytes and the - two high output bit can hold any value. */ -static inline void tcg_out_bswap16st(TCGContext *s, int cond, int rd, int rn) -{ - if (use_armv6_instructions) { - /* rev16 */ - tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8)); + /* Move the high byte down and isolate it. */ + /* rn=xxAB -> tmp=0xxA -> tmp=000A */ + tcg_out_dat_reg(s, cond, ARITH_MOV, TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8)); + if (!(flags & TCG_BSWAP_IZ)) { tcg_out_dat_imm(s, cond, ARITH_AND, TCG_REG_TMP, TCG_REG_TMP, 0xff); + } + + /* Move the low byte up and extend it. */ + if (!(flags & (TCG_BSWAP_OS | TCG_BSWAP_OZ))) { + /* No output extension: rd=xABA */ tcg_out_dat_reg(s, cond, ARITH_ORR, rd, TCG_REG_TMP, rn, SHIFT_IMM_LSL(8)); + return; } + + /* rn=xxAB -> rd=B000 -> rd=ssBA */ + tcg_out_dat_reg(s, cond, ARITH_MOV, rd, 0, rn, SHIFT_IMM_LSL(24)); + tcg_out_dat_reg(s, cond, ARITH_ORR, rd, TCG_REG_TMP, rd, + flags & TCG_BSWAP_OS + ? SHIFT_IMM_ASR(16) : SHIFT_IMM_LSR(16)); } static inline void tcg_out_bswap32(TCGContext *s, int cond, int rd, int rn) @@ -1705,13 +1699,15 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, case MO_UW: tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend); if (bswap) { - tcg_out_bswap16(s, COND_AL, datalo, datalo); + tcg_out_bswap16(s, COND_AL, datalo, datalo, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); } break; case MO_SW: if (bswap) { tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend); - tcg_out_bswap16s(s, COND_AL, datalo, datalo); + tcg_out_bswap16(s, COND_AL, datalo, datalo, + TCG_BSWAP_IZ | TCG_BSWAP_OS); } else { tcg_out_ld16s_r(s, COND_AL, datalo, addrlo, addend); } @@ -1766,13 +1762,15 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, case MO_UW: tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0); if (bswap) { - tcg_out_bswap16(s, COND_AL, datalo, datalo); + tcg_out_bswap16(s, COND_AL, datalo, datalo, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); } break; case MO_SW: if (bswap) { tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0); - tcg_out_bswap16s(s, COND_AL, datalo, datalo); + tcg_out_bswap16(s, COND_AL, datalo, datalo, + TCG_BSWAP_IZ | TCG_BSWAP_OS); } else { tcg_out_ld16s_8(s, COND_AL, datalo, addrlo, 0); } @@ -1862,7 +1860,7 @@ static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, MemOp opc, break; case MO_16: if (bswap) { - tcg_out_bswap16st(s, cond, TCG_REG_R0, datalo); + tcg_out_bswap16(s, cond, TCG_REG_R0, datalo, 0); tcg_out_st16_r(s, cond, TCG_REG_R0, addrlo, addend); } else { tcg_out_st16_r(s, cond, datalo, addrlo, addend); @@ -1907,7 +1905,7 @@ static inline void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, break; case MO_16: if (bswap) { - tcg_out_bswap16st(s, COND_AL, TCG_REG_R0, datalo); + tcg_out_bswap16(s, COND_AL, TCG_REG_R0, datalo, 0); tcg_out_st16_8(s, COND_AL, TCG_REG_R0, addrlo, 0); } else { tcg_out_st16_8(s, COND_AL, datalo, addrlo, 0); @@ -2245,7 +2243,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_bswap16_i32: - tcg_out_bswap16(s, COND_AL, args[0], args[1]); + tcg_out_bswap16(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_bswap32_i32: tcg_out_bswap32(s, COND_AL, args[0], args[1]); From patchwork Mon Jun 14 08:37:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459779 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3088519jae; Mon, 14 Jun 2021 01:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4zMoH7dVgsmN2vAVn2WxVzLUgsOpfoLDgLCnw5DUF0ctgYXBJnS96uvNTKJ9GSrywJDgU X-Received: by 2002:a92:cc01:: with SMTP id s1mr13066458ilp.227.1623660640791; Mon, 14 Jun 2021 01:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660640; cv=none; d=google.com; s=arc-20160816; b=WWpHHT+vNQ1ymOmrU6C7/ROpDdifqt2Ef51ICDPCJJPMmCD9GlQ/aYhcrBut3ulE+t jwBpvreLNKeqRNkYOy0/HWiY8w+05MunSrvaIEWI45x/S0cVT+a6jCNzR/v9n1AqODgF iT+tC/46Il58pZhMuKvyT9axzCcm7rFwpo1pPfmjUUBcV7uiQXq3QZ+1JAlQV7Eskgro RM9TES/rBil4gSOaRBHodduV8tizy3+sWr8ZDfvGbAkE1xHrNQjQiwhVBVcaedvSSKI7 XfmOgyT3wEwmrgy1Jj7obreX6/LhH5jHkYOay90EetjneEVZd38FWilrx2QXs6t1Sjh5 MwAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=WhSFZreDO53AzLKGFi8wjggrqQhc1QnKvAfjWIRryI8=; b=AsYSRU4yUbPdZFzwA6zY1ojW2wTLXsRefdI3knkRtPm0naL/p1/DbHErdriKCK1bI2 XN3vkGR5ImiyL01wfNF6xBNzVSjEikGWX7A29aKvMF4Az5o4/eikRaargB9iBZQKyYe2 bgox3iY8kfrLdcWmBLyO9+KiAz1J8c79mwbgXkgYH3h4hFQplYFw1YX5nFSwkfQPgVje itwCEny59E8FXT+TayKc3sUq/lIcaCwHulpBXBZ1PJYAWJMBMI2sYpjnI23OdjcfmV9r zhcuWIxQTX1nNZxg/C5OyLnE3svE0c9FwOZdjCkZYAtRAshfzRrV4gPSvDJn1mcGE33t +4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RgLOPHr4; 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 h13si15275450iop.97.2021.06.14.01.50.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:50:40 -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=RgLOPHr4; 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]:44488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiIp-0008AD-VC for patch@linaro.org; Mon, 14 Jun 2021 04:50:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6n-000285-G1 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:13 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:37410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6f-0003Vf-Vj for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:13 -0400 Received: by mail-pl1-x631.google.com with SMTP id h12so6158798plf.4 for ; Mon, 14 Jun 2021 01:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WhSFZreDO53AzLKGFi8wjggrqQhc1QnKvAfjWIRryI8=; b=RgLOPHr4ymADW1P+bAuhcZbbNx5dsctX6D2MMCCWJ+aTw2/X9uLDi+SnGMMHmhpPj1 iSK9dwNUxQP0t0H8Wjh1TqFZVJ8inCDbiTFnhkYTDq4IlQHDZ0aSrl15mFKrdR3S9A5v z+pZwUcAniXmEgVcgGmp+eo1sGC7zwXHwFAbNzf4u4r5Qz3lf8drptd8XGG9grVyWRdo fwxN1EOeskeHhb5FN6sU+/B6k2joO95FOd5POyMycWgMjWbbK7gGU4UTDlcrSZcG3taq oAPvltcB8NVN03v2/xWDi7HCJWE+t8tOjEjwlBtYn2kBsUFzq85Pm1wecKGMIWnZgR6T vrug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WhSFZreDO53AzLKGFi8wjggrqQhc1QnKvAfjWIRryI8=; b=IYXF3N77zgSxNt66Rb/dAJbpmpAY6fzOIiuUqtQYcDEqRCA5BzMbOoTaZBVMkk3FJV 2m6iFX/avwDvNt6BdlJjYbgEan89Yjen+2qpdabbOmH2wBBfT7kA65IL8Mx+CA/11kF5 hFnO88sF4BuzppkZvz9baEq9cKWrgrsZu5Pza0msghYaNnky9AfXFAsLpl/LfCAdz6Rx he6ikEwP/VfQ9RBcNqaZed4Rf1iqx9iRAurXip56J0+OcP7Pbw5QRsepiTDdjISNpqs9 IiTLHDgaEJlGSEB78BWrUAnMBp1hlmN5pzXZQfaG95CONz+a4e8Hs9OprAsWFEIsarDM MkQw== X-Gm-Message-State: AOAM530i0mOXAjZqz8R52+XI8y25yEyFntQERqiSvcUHtyCv2ghxOwwr aXAg8sLXYSiWBuju3B3LDpTcUbTR5QPBug== X-Received: by 2002:a17:902:e747:b029:114:af78:1776 with SMTP id p7-20020a170902e747b0290114af781776mr15981671plf.2.1623659884496; Mon, 14 Jun 2021 01:38:04 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/28] tcg/ppc: Split out tcg_out_ext{8,16,32}s Date: Mon, 14 Jun 2021 01:37:37 -0700 Message-Id: <20210614083800.1166166-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will shortly require these in other context; make the expansion as clear as possible. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 795701442b..aa35ff8250 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -738,6 +738,21 @@ static inline void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, tcg_out32(s, op | RA(ra) | RS(rs) | SH(sh) | MB(mb) | ME(me)); } +static inline void tcg_out_ext8s(TCGContext *s, TCGReg dst, TCGReg src) +{ + tcg_out32(s, EXTSB | RA(dst) | RS(src)); +} + +static inline void tcg_out_ext16s(TCGContext *s, TCGReg dst, TCGReg src) +{ + tcg_out32(s, EXTSH | RA(dst) | RS(src)); +} + +static inline void tcg_out_ext32s(TCGContext *s, TCGReg dst, TCGReg src) +{ + tcg_out32(s, EXTSW | RA(dst) | RS(src)); +} + static inline void tcg_out_ext32u(TCGContext *s, TCGReg dst, TCGReg src) { tcg_out_rld(s, RLDICL, dst, src, 0, 32); @@ -2322,7 +2337,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const int const_args[TCG_MAX_OP_ARGS]) { TCGArg a0, a1, a2; - int c; switch (opc) { case INDEX_op_exit_tb: @@ -2390,7 +2404,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_ld8s_i32: case INDEX_op_ld8s_i64: tcg_out_mem_long(s, LBZ, LBZX, args[0], args[1], args[2]); - tcg_out32(s, EXTSB | RS(args[0]) | RA(args[0])); + tcg_out_ext8s(s, args[0], args[0]); break; case INDEX_op_ld16u_i32: case INDEX_op_ld16u_i64: @@ -2728,18 +2742,15 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: - c = EXTSB; - goto gen_ext; + tcg_out_ext8s(s, args[0], args[1]); + break; case INDEX_op_ext16s_i32: case INDEX_op_ext16s_i64: - c = EXTSH; - goto gen_ext; + tcg_out_ext16s(s, args[0], args[1]); + break; case INDEX_op_ext_i32_i64: case INDEX_op_ext32s_i64: - c = EXTSW; - goto gen_ext; - gen_ext: - tcg_out32(s, c | RS(args[1]) | RA(args[0])); + tcg_out_ext32s(s, args[0], args[1]); break; case INDEX_op_extu_i32_i64: tcg_out_ext32u(s, args[0], args[1]); From patchwork Mon Jun 14 08:37:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459768 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3083287jae; Mon, 14 Jun 2021 01:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/KSZdZb4UfBxKz4tWcraQygsX/ussTYyKYeA3c8Fb6dwhahh2ENJuBq4ewVY9aW6kNIIi X-Received: by 2002:a25:ba10:: with SMTP id t16mr22601098ybg.87.1623660121920; Mon, 14 Jun 2021 01:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660121; cv=none; d=google.com; s=arc-20160816; b=MkSH9StWZ2Ogg7NzpRbErBRzLtuW7QFhuabo5iOkAMJFQ6KqpegJFvDHonrUwhZ3O2 NLldYbifafVrd7CRlx274a5D6c/DZLbZyN3MXGIJoDJHSYnkMOjwwifxgIYkgPvr0OW6 hvqfTYe2XZ0F6Bbnp+sqvGUTbpNsBTi2DLc1VPueq9K09/NVvJEuj5RzMsO4DG3SFdFL lVV6P9myBQZ33Akc/l+omWd+1O52q+rx11D1TIcHTWdrLblLBaKgyU0G22RMXNYzPa4w p2b3VmkNjymIXhrEn6aCG6PxV/9WY5PzJobmgNGydyNjDUzla7q4t7oGwIvDnrdBkOZQ W/Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=9falKtlgXRX7iCDYqgvSVBqx7lbth/xVIEcKWW9LxMo=; b=zJRuKbVWKQAsl9aXAvfur+cCUagXWFC4MJgekuwMhM3qsAGvBVoxgd67c8PYlUyngl JmBKA+vyzAIobMbT8hg30rVchXwPowy0L+zcOxW+oFAxgp+gdX2LckIW2Uwp8fBac3le 2ZTMm4UxcN+Klc6GC7GFV8x2xbbDG5XFhnedVLIBzqDMaJQ3pLsBjDQSLnIV5kasKAXV z/tbR892ZgfIsn6hPlvjZ9kk67OvGvCkdJQI4SpLOxeisKJk6ioLdkUFipyH24Ak7fiT wRNgl8Bqt8Sr5LzqaALXM3TUpxfjCVj9eb4BS58EB/D5uq+60nlnHKhQ5sINIJu+cNsM g6Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nXTRdb8K; 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 e10si13842070ybj.190.2021.06.14.01.42.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:42:01 -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=nXTRdb8K; 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]:47134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiAT-00081I-4z for patch@linaro.org; Mon, 14 Jun 2021 04:42:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6j-00025b-4G for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:09 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:43629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6g-0003W2-Aj for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:08 -0400 Received: by mail-pf1-x431.google.com with SMTP id a127so4191603pfa.10 for ; Mon, 14 Jun 2021 01:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9falKtlgXRX7iCDYqgvSVBqx7lbth/xVIEcKWW9LxMo=; b=nXTRdb8KXaAuAeJmMgNjW1OUc5p0SwNP6e0IGPHJLZK0UMcOqqvrPPBJe7bx0uBnRc jDTsqpTixrFLqCXohxD7jgj4BsaAY3xXVkIzmLh5UXOLzfv9ETMxIGYjgVjmRompm1wC 0sJwDoQTIqgvRg3gmhH0+FvE9k9WYsQ3tcUzx2zaAnmI2ZwA9KI2S6rbBGfL/yHgNNUX rT6TyhabjUfoROy1s6Sd8KZEJs5rqraMhJJXTyzdjTkRXvHKLUo1WmVydeyB7Eg2uEz3 nnPWM4lZ9AgHlCxe2qG5PNciZf6Qo7Xprw9k5zEq8BVXYZADrXtPt20bURa0HvIzz243 fRAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9falKtlgXRX7iCDYqgvSVBqx7lbth/xVIEcKWW9LxMo=; b=eB4mnREex/O2/xNK2Rql3BX7UOPxbSAV5gM+za9KoxMyIdkdpl8yLoMdlHxL0U5Hc2 SF4MHrKR6eP0KfdNSDkWiFl5QyIfQcHKXVHlYGos3ofgDYA3QStKdXKSHnoaGpJdF+4w vMBoWpWQkPRzzbCukn6h4AowJFgpnNFyU0koV5BKflm46XLYM6SIAcOXznvu7I/K+xV6 Vkm8aA/JISsCLUwNV+icOXDZi2deq/rwt5kQ4GiPS4d9XJxFocnR3rxez4MZL3+jWmh3 A2DW2TkSOSiR07qPtH47G40OGXapUdYDPIFkIDpUgtcD3ayqAjrNWjXMMAUeSZ4eIRr7 8tvg== X-Gm-Message-State: AOAM533apUiBKusWkhGTeggjK7TwzgwdNef/XHEbVmq51+s2DeX9IE95 m5VPmtJfBhDjfXsSzwX+k08I0ZoeH7VdNQ== X-Received: by 2002:a63:2f05:: with SMTP id v5mr15883826pgv.449.1623659885043; Mon, 14 Jun 2021 01:38:05 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 06/28] tcg/ppc: Split out tcg_out_sari{32,64} Date: Mon, 14 Jun 2021 01:37:38 -0700 Message-Id: <20210614083800.1166166-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will shortly require sari in other context; split out both for cleanliness sake. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index aa35ff8250..b49204f707 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -768,6 +768,11 @@ static inline void tcg_out_shli64(TCGContext *s, TCGReg dst, TCGReg src, int c) tcg_out_rld(s, RLDICR, dst, src, c, 63 - c); } +static inline void tcg_out_sari32(TCGContext *s, TCGReg dst, TCGReg src, int c) +{ + tcg_out32(s, SRAWI | RA(dst) | RS(src) | SH(c)); +} + static inline void tcg_out_shri32(TCGContext *s, TCGReg dst, TCGReg src, int c) { tcg_out_rlw(s, RLWINM, dst, src, 32 - c, c, 31); @@ -778,6 +783,11 @@ static inline void tcg_out_shri64(TCGContext *s, TCGReg dst, TCGReg src, int c) tcg_out_rld(s, RLDICL, dst, src, 64 - c, c); } +static inline void tcg_out_sari64(TCGContext *s, TCGReg dst, TCGReg src, int c) +{ + tcg_out32(s, SRADI | RA(dst) | RS(src) | SH(c & 0x1f) | ((c >> 4) & 2)); +} + /* Emit a move into ret of arg, if it can be done in one insn. */ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) { @@ -2602,7 +2612,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_sar_i32: if (const_args[2]) { /* Limit immediate shift count lest we create an illegal insn. */ - tcg_out32(s, SRAWI | RS(args[1]) | RA(args[0]) | SH(args[2] & 31)); + tcg_out_sari32(s, args[0], args[1], args[2] & 31); } else { tcg_out32(s, SRAW | SAB(args[1], args[0], args[2])); } @@ -2690,8 +2700,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_sar_i64: if (const_args[2]) { - int sh = SH(args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1); - tcg_out32(s, SRADI | RA(args[0]) | RS(args[1]) | sh); + tcg_out_sari64(s, args[0], args[1], args[2]); } else { tcg_out32(s, SRAD | SAB(args[1], args[0], args[2])); } From patchwork Mon Jun 14 08:37:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459772 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3084654jae; Mon, 14 Jun 2021 01:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLv3cHoU/0pN2TaXM+IqeQ0MRzWB/zbsYhvxsztCfyqU+udmwEy/5Ep30hCHGJsmrFEX0n X-Received: by 2002:a25:f605:: with SMTP id t5mr22643870ybd.44.1623660273929; Mon, 14 Jun 2021 01:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660273; cv=none; d=google.com; s=arc-20160816; b=ftyl2wcEulfMdARjk3RplyX91BsVQdbAPOTGrZq1Qrdl/L5idXkBk4I5rthENOAU52 gyvhMt5D7sbdBi9OXddi06Nd692eB7J37+Frpzr9b7nVCun/wboOgmfxyjniaVT1wFSO G7O3iN4fpYVJR/vFWyxdanFoTKeDfMLtWREKdjVKoU5GUSc9IQsxABb6EkYhSYAHa4jm OJG0kj7N8jqLJd7pAI5D8rL7lqfQTiQ53HDeddRSKcloZc2PXUlRnhuyar3Ir8i+Qfj3 kf75+tCs8ZECSjG2txjtAgK9hmOLUODdiM39miH+X/SKiW+gK+J/VD8VOv+Vv70megZa rJMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=uRhDpsCgqOd1p886I9GT4fpJ+sw3ON5Rsi01SuZid6zxDcuEFCyaK0V52vHee4YRXi PlzJLw0on98ZmSyYL4HUJafZv9SlzkTe4px2H28yEiGstqIqhvMZiZzOsGzpQUQdZ7AF GxlosOBnBhKawdHwpy+6y65DHLd7AAGPkq2YZdi7xtpRJUxAodwHSWBsgpdOTplsHkpL BW6EswG25WJ1YzhlMBH4kEu9rnKEkrTad9nUtltaVKVeZaghWGtk5XOSDqXUbOH1rGSR KaVbnH8JQ9YPGFv+Micvg7vD7c5iMrMnDhmIxDes77orlauoqQkzup+uHQZrDD1UaDDY OJ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e6NRlOWj; 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 g18si14453240ybe.146.2021.06.14.01.44.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:44:33 -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=e6NRlOWj; 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]:59074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiCv-0007Rq-7B for patch@linaro.org; Mon, 14 Jun 2021 04:44:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6r-0002Cc-I4 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:18 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:38423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6h-0003WA-7H for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:17 -0400 Received: by mail-pj1-x1030.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so9600594pjz.3 for ; Mon, 14 Jun 2021 01:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=e6NRlOWjJEoa0MCTC1H93fuvJ6hi19fzTMbTZa2kn6d/HnTvIyTvyLTzZcvOz8yArs FjLFTblo0JGUi7kg06Z5oKOFGDWeSWqBVHrzsY+Kwaq+PU8KkYoIK06epYL7/CrEBfOF fZFGG6oCv1IwujY8O+8fxrgNCN+Nl9fgfnT+xfOhINbBdx2juPGdl/Vn+EaBsFff0Fe0 Av4hluWFpawitsq5OlUwQC019bHUT4QV+jjKuj6B+pp/ANIJtYul1Gg7z2yL8SOrdwRk xGvUDmZhYssnW4I0gjFRIyrtLuuMcqm4oLnR/QmeekbKTTsXAUr6aiMK7suJNK5pjYu5 8R2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=TbWF0I/VQPn8me2KqLElhsj2MUGSoTavL2FNQ+gdnupdWmEAritReLJPP42xX27BQp ZQDHDohgZP27QjhfHVLnuTfrEOOAlA9K0kBUzUl1FDzwUfyNZleMczmZrn0gy5RRV+m1 zN/2HnHwcY/cDvOVp10ROC0lFfFG8c8nu0Vu3oR2TdVbzIrmUlFOX1gX3ptpp+UalYV+ NX4hj+UPd7wTLQsASG+8UQwEfJYmOP15DBXlOTFws8+ORXpfs5IVEp8gMRYsxHzwF2Z9 uiMx/zbJdh00fetE4s/QAbnz4wSiNhF22seShSgkyg9H2PXZLNpgS7GPOkBtcdriXIgn bPjw== X-Gm-Message-State: AOAM531JoDWUQJbWneNRkR9zvPq9K0U5r5T4bdNCYxraKS8A0xtXoqE6 FfLKMejq7JEB1eozNJUxBk5kFq45vR+jcw== X-Received: by 2002:a17:90b:4f83:: with SMTP id qe3mr22611280pjb.32.1623659885654; Mon, 14 Jun 2021 01:38:05 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/28] tcg/ppc: Split out tcg_out_bswap16 Date: Mon, 14 Jun 2021 01:37:39 -0700 Message-Id: <20210614083800.1166166-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" With the use of a suitable temporary, we can use the same algorithm when src overlaps dst. The result is the same number of instructions either way. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b49204f707..64c24382a8 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -788,6 +788,16 @@ static inline void tcg_out_sari64(TCGContext *s, TCGReg dst, TCGReg src, int c) tcg_out32(s, SRADI | RA(dst) | RS(src) | SH(c & 0x1f) | ((c >> 4) & 2)); } +static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src) +{ + TCGReg tmp = dst == src ? TCG_REG_R0 : dst; + + /* src = abcd */ + tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); /* tmp = 000c */ + tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); /* tmp = 00dc */ + tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); +} + /* Emit a move into ret of arg, if it can be done in one insn. */ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) { @@ -2779,21 +2789,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: - a0 = args[0], a1 = args[1]; - /* a1 = abcd */ - if (a0 != a1) { - /* a0 = (a1 r<< 24) & 0xff # 000c */ - tcg_out_rlw(s, RLWINM, a0, a1, 24, 24, 31); - /* a0 = (a0 & ~0xff00) | (a1 r<< 8) & 0xff00 # 00dc */ - tcg_out_rlw(s, RLWIMI, a0, a1, 8, 16, 23); - } else { - /* r0 = (a1 r<< 8) & 0xff00 # 00d0 */ - tcg_out_rlw(s, RLWINM, TCG_REG_R0, a1, 8, 16, 23); - /* a0 = (a1 r<< 24) & 0xff # 000c */ - tcg_out_rlw(s, RLWINM, a0, a1, 24, 24, 31); - /* a0 = a0 | r0 # 00dc */ - tcg_out32(s, OR | SAB(TCG_REG_R0, a0, a0)); - } + tcg_out_bswap16(s, args[0], args[1]); break; case INDEX_op_bswap32_i32: From patchwork Mon Jun 14 08:37:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459765 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3083003jae; Mon, 14 Jun 2021 01:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW8rd1Yu7iAicHVqU/odx8p5+9RA1BaFw48qncBqjGXcnQE9kuyo+pV8gceSboDkBLc0fw X-Received: by 2002:a25:2388:: with SMTP id j130mr23191172ybj.222.1623660093552; Mon, 14 Jun 2021 01:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660093; cv=none; d=google.com; s=arc-20160816; b=xL/6NvCI0P2xBscozFs5M4C+RWo09QV5wrEAMN7bPU7nIdNbClLH8UkjFnFNmvhIRs h+YCE+ItDQiqHnSeKUyByAYcfg1FfX6XN7Ceg140uOTJCObhpWonzrn7FAblCANH7PYk RJ5v5K2qXT0HHgL3oGskYSlLzr+Pz6dk/PtY0xvoqUoFOD/nUSMaKLNc3c2MoDiaeN9e S5tJt/nOsvg5tV8pzTzwBHRlDtidsjTIi4LbtXarKavJ30QaKlCit14wkvW3XbulIYP9 4utiVlp2hNOqvO02RK0ioRQ0gnczs1QJykkavi0SoxxvJ6Fr99YBCdijcm23ygCxpuAl Uu9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=3XaCQaiofWlp2RkjtaKGiOMhxyWGMuQ5bASRK7Oic+8=; b=fFRYFpzD/Ri4P3C0FUTwmi68op7rujcZYPfNV3yOkaQNfTSQ2scSnVyxIFUEI+eND0 P+WLx/wc03Mill7i7S7bTwpzR4+y1ymxl4etiFL4g9dQ1DCprRArF/JPqhIqYna/gV3g 4LBTO2F/b3GZozLBAqrcBiW4rWt5zIu+KdBkNQqsihWYBHg/2GevtS5ScCHRT1huwc1r pH7iXdrEZ0HHhIyGnWKW+vpwVT2fe3APXaGWRtL8aNp5/Ch6mW1V9IiVf8zvBtmcV6wV ilP74S9z5dIdGV153lmvVHT3LrtOWbML4kstcAj1JNWpE9+pQwrVtB7T6Xea2izMaiwc e7Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TSrXbgYl; 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 n18si17814137ybh.384.2021.06.14.01.41.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:41:33 -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=TSrXbgYl; 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]:44458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiA0-0006Ga-SZ for patch@linaro.org; Mon, 14 Jun 2021 04:41:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6p-0002BA-JV for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:17 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:35545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6h-0003Wt-PN for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:15 -0400 Received: by mail-pf1-x42f.google.com with SMTP id h12so10032568pfe.2 for ; Mon, 14 Jun 2021 01:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3XaCQaiofWlp2RkjtaKGiOMhxyWGMuQ5bASRK7Oic+8=; b=TSrXbgYl29YXvO1rY1NUkuYqiIZ1xZ+9zhmuY0tIXqFD0yFbxckrOj5V523Q7d2zVb hI5nyyL+QeZphmfhtX4n2lKnCQIdPmiyek6taHqIKihFYnvZK9dpvvUoZhRko63DQOxo PWDTno1V8Fmi5/RufSPM3SEVRoCd1cpA7+k8YDrXczwALV/GCh6WfI3gbLjY8G0/UhrU CFBuGGOCkh3CwMgC0rZgDP8JKBK67Ic9KCeSW9+pFIAt+364a9ZrrJjwzRr7glnLd7Iu zG7I6aF9KP+aUR/Y2LP9Jr8yj1gvEmzgCH6A3MFANJt99kLBGbqxWNS+LVoGwesqxOW4 K/OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3XaCQaiofWlp2RkjtaKGiOMhxyWGMuQ5bASRK7Oic+8=; b=tEwzjz96DbIVARIKYXnxzgBeWdKV7LKTbBZ/03XG7SKSks0H19BdqzCjpfT31gOJ9Y dO7RXf974SuobsmmvoJMY5yF1+l8iWuuuPoUcxpH7ICvrbqPSa/s7kHx9Uiq4Eiku88t FRiHw4e2h1pHAVzyg0EcFGWjqZHWVzQUJcysa3JNh17KgqQRLVwzh+1Ufo7S862n/RZi p6QCuttmmC3Wlpyi8xqyaZA9Y2tjf3RozLju7JgAPTd7K5KZ8el0EahyNF+Bnek2IK0V TDuIOIaf455f26ZeehF53v4NYK4fm5GfUC8tYAmb/+wewdJt5KTZpaIMGtqXZwPdC946 j4pw== X-Gm-Message-State: AOAM533DvgDydvEPn+cBGlgDvVSg4NBY3X9ruTdU8VcQsdaEBOhBE0uP +BIJMOotM8v/qk1VQWRwgIY5Blnq97VcQA== X-Received: by 2002:a62:3344:0:b029:24c:735c:4546 with SMTP id z65-20020a6233440000b029024c735c4546mr21067512pfz.1.1623659886479; Mon, 14 Jun 2021 01:38:06 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 08/28] tcg/ppc: Split out tcg_out_bswap32 Date: Mon, 14 Jun 2021 01:37:40 -0700 Message-Id: <20210614083800.1166166-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 64c24382a8..f0e42e4b88 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -798,6 +798,17 @@ static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src) tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); } +static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src) +{ + TCGReg tmp = dst == src ? TCG_REG_R0 : dst; + + /* Stolen from gcc's builtin_bswap32. src = abcd */ + tcg_out_rlw(s, RLWINM, tmp, src, 8, 0, 31); /* tmp = bcda */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 0, 7); /* tmp = dcda */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23); /* tmp = dcba */ + tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); +} + /* Emit a move into ret of arg, if it can be done in one insn. */ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) { @@ -2791,24 +2802,9 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_bswap16_i64: tcg_out_bswap16(s, args[0], args[1]); break; - case INDEX_op_bswap32_i32: case INDEX_op_bswap32_i64: - /* Stolen from gcc's builtin_bswap32 */ - a1 = args[1]; - a0 = args[0] == a1 ? TCG_REG_R0 : args[0]; - - /* a1 = args[1] # abcd */ - /* a0 = rotate_left (a1, 8) # bcda */ - tcg_out_rlw(s, RLWINM, a0, a1, 8, 0, 31); - /* a0 = (a0 & ~0xff000000) | ((a1 r<< 24) & 0xff000000) # dcda */ - tcg_out_rlw(s, RLWIMI, a0, a1, 24, 0, 7); - /* a0 = (a0 & ~0x0000ff00) | ((a1 r<< 24) & 0x0000ff00) # dcba */ - tcg_out_rlw(s, RLWIMI, a0, a1, 24, 16, 23); - - if (a0 == TCG_REG_R0) { - tcg_out_mov(s, TCG_TYPE_REG, args[0], a0); - } + tcg_out_bswap32(s, args[0], args[1]); break; case INDEX_op_bswap64_i64: From patchwork Mon Jun 14 08:37:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459783 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3089937jae; Mon, 14 Jun 2021 01:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvhDk9hwOjT4zZNDWJIJ8kccVpzzl77sn9ZdDef349QqgP1aDUvCfgM5E1aZZ97hTvigMT X-Received: by 2002:a25:7ec4:: with SMTP id z187mr22464845ybc.136.1623660772975; Mon, 14 Jun 2021 01:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660772; cv=none; d=google.com; s=arc-20160816; b=O0g4qflsue9FD1CuaigTDUo5zou7URCQLC6qCpNbw4YLGKJJIKmDu+p4fKuplP6mDf vgWG6htYAyDfH8nXvm5j4mBw5INY9OabN7B5SHt+BgQKIJxrp/eYtoddiV3sncZQU00O nD/9k24TCgPoKl7fWEP1JTTdfIqdqjmITT0uIEj5QA04SGaRSKFqMDjYwK+DRn3uqNnp Kh6BzoOVhsMSIsgQTjcJP+6x8cED0UkLY37bTexAY4GJa/FN6d/QW26PtfR6FFuOn/pS yJQqNHoGaatHhsaNRALGLsfEr5bclEIWdye1wAsGXPD7lW/dl3dTOv1ea3ngYCbo5HbT 5aVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=efhM15NF3CwbPhiaHPmRN5qTN9aiv7TZSEdl+6oiGJA=; b=f2cyUvn8bxd33vTVybe4/nLhC8kLnwNjeyi2kLh5o3Gs7xGbbbThRb7qlj4dCbS9CG hwP0OMfb6oMrhYvaNIc+1g4+tluQ6QWVdbG/psjofigg9bzyRCSlHTdUr0X6T285DBii uga++wEzAEomVICqI3US0Pdwh3drI+e5vgIBmfQfQt6KtakS1KSIyPnnNFwkVsxGG02O 49TMMuUTZCsuMTaN/UjAr51XhzBN2iCWMBTsfWEV9Dal/hwikcekDYVVEifM2RNggdPZ qM7yh/ZShtiSpkA0EtMem/DMSIQY5aUe8fujTxalev1/N2s2lMj4xZXNlLZ3Xrd6eEX7 w9cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7qvuFfn; 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 g22si7259022ybj.448.2021.06.14.01.52.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:52:52 -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=O7qvuFfn; 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]:53078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiKy-0005Tr-EP for patch@linaro.org; Mon, 14 Jun 2021 04:52:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6s-0002Du-LV for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:18 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:54218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6i-0003Xw-CP for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:18 -0400 Received: by mail-pj1-x102e.google.com with SMTP id ei4so9286940pjb.3 for ; Mon, 14 Jun 2021 01:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=efhM15NF3CwbPhiaHPmRN5qTN9aiv7TZSEdl+6oiGJA=; b=O7qvuFfny6UZxSJSSIpgm/I0oEcDflN5S+g1lMvMwEy6KIhLmkCEbiaye/AMto0d9q 38w4hXKO5sAkY8YKTOYweFVljZlQX+rZU5LPzZBYrvikBAZkKqkrHbeOyXkB5J/p1T31 1Oa0WlZQLSBVTFNSEBUslIKx9bPtyDZklvinFwNSAU2N9BM1GK6jgm2nGFO26xKa77Bk BcpxF+mkJYKxhHo2HPzcWd+7JC+OimFxb6x7y9q4Z5GMnlQwe9TVeM+gGAsPCF9WELwY AOBqcy7tDExTGiFYRKoHQNDVNgWnoLcN6EjujrO0NDkaWqADa25GjMDzh0wyh5xq9nNa e3pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=efhM15NF3CwbPhiaHPmRN5qTN9aiv7TZSEdl+6oiGJA=; b=jGEoYlPK9j1aT3CkIQXKIXhkj2Lf/9KEZ8ra3WM18YfBqX5a9axjmhV/9yZa494SGh liXP8BCb291mEj+OmnkqQGzdgCB4WlcnQSu4OCU00noYHvntzvp2t3i6mtqlsidpYn5V 95ULWcxpZdj/D3z3B96Fs3rL1PH7h+UPzp1ra5XrSFKSQu7AjG0L1Eifyc8o2vgjOiXD gm4+xd5L0il9caqH9RnH9SwEdzyN72wFCX18108L2d6QxX8F+O3I/Hjdbx9SvS1DDW8p hL06RKIOhmhG/Tu8+YVLQu235pTM+ktGEPChMFeOWOFJnGtMOa8t9P54Lw0eI3U3Ti6p 3HOg== X-Gm-Message-State: AOAM530I/Nc+OgW2IaQYZ1aBYQn3bakk1nZsrnm+VVTxzY1gVc53ZnQi 6glwVUzNbtFa3VY9glPCfID2NPHA2VTTrw== X-Received: by 2002:a17:90b:393:: with SMTP id ga19mr17665224pjb.182.1623659887072; Mon, 14 Jun 2021 01:38:07 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 09/28] tcg/ppc: Split out tcg_out_bswap64 Date: Mon, 14 Jun 2021 01:37:41 -0700 Message-Id: <20210614083800.1166166-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 51 +++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 30 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index f0e42e4b88..690c77b4da 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -809,6 +809,26 @@ static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src) tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); } +static void tcg_out_bswap64(TCGContext *s, TCGReg dst, TCGReg src) +{ + TCGReg t0 = dst == src ? TCG_REG_R0 : dst; + TCGReg t1 = dst == src ? dst : TCG_REG_R0; + + /* src = abcd efgh */ + tcg_out_rlw(s, RLWINM, t0, src, 8, 0, 31); /* t0 = 0000 fghe */ + tcg_out_rlw(s, RLWIMI, t0, src, 24, 0, 7); /* t0 = 0000 hghe */ + tcg_out_rlw(s, RLWIMI, t0, src, 24, 16, 23); /* t0 = 0000 hgfe */ + + tcg_out_rld(s, RLDICL, t0, t0, 32, 0); /* t0 = hgfe 0000 */ + tcg_out_rld(s, RLDICL, t1, src, 32, 0); /* t1 = efgh abcd */ + + tcg_out_rlw(s, RLWIMI, t0, t1, 8, 0, 31); /* t0 = hgfe bcda */ + tcg_out_rlw(s, RLWIMI, t0, t1, 24, 0, 7); /* t0 = hgfe dcda */ + tcg_out_rlw(s, RLWIMI, t0, t1, 24, 16, 23); /* t0 = hgfe dcba */ + + tcg_out_mov(s, TCG_TYPE_REG, dst, t0); +} + /* Emit a move into ret of arg, if it can be done in one insn. */ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) { @@ -2806,37 +2826,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_bswap32_i64: tcg_out_bswap32(s, args[0], args[1]); break; - case INDEX_op_bswap64_i64: - a0 = args[0], a1 = args[1], a2 = TCG_REG_R0; - if (a0 == a1) { - a0 = TCG_REG_R0; - a2 = a1; - } - - /* a1 = # abcd efgh */ - /* a0 = rl32(a1, 8) # 0000 fghe */ - tcg_out_rlw(s, RLWINM, a0, a1, 8, 0, 31); - /* a0 = dep(a0, rl32(a1, 24), 0xff000000) # 0000 hghe */ - tcg_out_rlw(s, RLWIMI, a0, a1, 24, 0, 7); - /* a0 = dep(a0, rl32(a1, 24), 0x0000ff00) # 0000 hgfe */ - tcg_out_rlw(s, RLWIMI, a0, a1, 24, 16, 23); - - /* a0 = rl64(a0, 32) # hgfe 0000 */ - /* a2 = rl64(a1, 32) # efgh abcd */ - tcg_out_rld(s, RLDICL, a0, a0, 32, 0); - tcg_out_rld(s, RLDICL, a2, a1, 32, 0); - - /* a0 = dep(a0, rl32(a2, 8), 0xffffffff) # hgfe bcda */ - tcg_out_rlw(s, RLWIMI, a0, a2, 8, 0, 31); - /* a0 = dep(a0, rl32(a2, 24), 0xff000000) # hgfe dcda */ - tcg_out_rlw(s, RLWIMI, a0, a2, 24, 0, 7); - /* a0 = dep(a0, rl32(a2, 24), 0x0000ff00) # hgfe dcba */ - tcg_out_rlw(s, RLWIMI, a0, a2, 24, 16, 23); - - if (a0 == 0) { - tcg_out_mov(s, TCG_TYPE_REG, args[0], a0); - } + tcg_out_bswap64(s, args[0], args[1]); break; case INDEX_op_deposit_i32: From patchwork Mon Jun 14 08:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459769 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3083843jae; Mon, 14 Jun 2021 01:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoLYcaa7zIWUZKrACna92Vywq25PaPHlce8sfAOluQZcum186C9NVwiYPHLXZfIkBUOYEI X-Received: by 2002:a25:e749:: with SMTP id e70mr21703295ybh.423.1623660187741; Mon, 14 Jun 2021 01:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660187; cv=none; d=google.com; s=arc-20160816; b=N3MFMjWYX5Nyj9ezmrqC4VzAHSM5Qn7EWyh2N3osVYzNptn6r5mxQVGNKKk8duQPv0 XQ581Nvu/AaMgXxZXAlbNdYwPapZMmwPbU9sHajJwfLt9gaV/pflPECdkzi7YLZ6AqAG bXyXrhoJXxuwhZUrhbWI17/vcEJbN8nFvoYIY/sNwWDojGGaFNEKMvipLcZtr8GaNI+a lB7L68Fe5+steet4uUee0nWAcLDWXaMnEpCPOUCoLHCElE5o9wruaYIxEto5CJXWn3pw eVKvaPcEVLkAmYQfZNNExbyzIH2rma76g8lhXNVt2UJYe4dKaqMmmzr4I4+ww7nb387I Cbfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=W1aURk4AJbewcgeEluJrf0o5H8N61Ouoo0K7e9Jqy7w=; b=Sw1sa97S65o8zDvn0C7mEDOWwTLLtvy6qD3iWmdNZbwH/C4/vifnzUMqy+OAMbS8gQ 4BqkPGL1JQfeUUA6MMzdosctXjd5oqvT5NPz6GK3EmlXwcN4x465OqbN9vzetFSRygGl GZVMVp+F0xHkkBNergxKBhGhlLA2snK4rLgvIiuBw4ufzhONVmdgBGGaDFFQFltA/U8H YgcSng47oBDutGvjrb6i19LrThglMm/k3L8AoJvZUuOiZ5iV1Toiy6QbeYVvVIXfj4y2 YcxSFT9BshdT4rsDS4yyUvvPOmTGEEJUNJZgADX0GgxrJa8z2BlbHW9jqkK+kHWBnsWm TPFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXvZtjCf; 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 q80si14501292ybq.397.2021.06.14.01.43.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:43:07 -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=KXvZtjCf; 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]:53026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiBX-0003Vm-5H for patch@linaro.org; Mon, 14 Jun 2021 04:43:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6t-0002GG-O6 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:19 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:44826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6i-0003Yw-Vc for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:19 -0400 Received: by mail-pl1-x62f.google.com with SMTP id b12so6150998plg.11 for ; Mon, 14 Jun 2021 01:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W1aURk4AJbewcgeEluJrf0o5H8N61Ouoo0K7e9Jqy7w=; b=KXvZtjCfUhlAa4vzah3XrBukd2wIUlzFCFPjgSRC1uTyVwKWxEG6930xOcjbec1ANr wLDT5f8pgApPc0QieRufNiLFIB4j20x8v//GJe++0pUeeuvtj5x0ywwm3PT6ODXVtmSL iByo1yjo8fuPeLFwmWEVRRhT0AmWtsM9tWTeHsnj4CKjlnXawlUYV+TBeWFPOOxzRUuU kvYkU12V0J/Oea6yJAP+dM6mgUAKGyzJlQJ2YUZwg03Flkz/1FE+5FN6fi53mI078ALE zD2aB4F/5h8HknwFrxY8lj3braV/kD5mFcbM+fWkPq67OXlGbVj0h03AkWWku8+NamGc OyIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W1aURk4AJbewcgeEluJrf0o5H8N61Ouoo0K7e9Jqy7w=; b=qIShkWlQmm7hb9A6i4cSxf0XEyX4pVysl5TR8jvyy5Dj2OeDHRvILfk9IB+O1MXDHv v65+58Vyiu+/OCH7vNCsM2GSdpkoQ8Q4MuhcF+QqcPGgZ2QaJ2oKVsVCn/lMX8zhuh/y mcgWVf9cViuz+tpNL7/H6dX2Itaf5xeRiLbbPYzm22l9BpKSOnEEaJOzLEDbVw4euqGi u61SAc1eOONQ01YKRbxVLlrVzSkXCvWSC6go402OgJTJc5dLR3Llu3fZIAMr1USA8VPR oz09XFRjSDcRTlkczGrb9sEHaLK3Xv9RM2Aj3D5T+yIrl7ym55ReU5FeWU+RGUn0V3vO Q2VA== X-Gm-Message-State: AOAM533vQoJIgcG7lWG5a58oAEenS2EmFyhrDW/HdGjoclw/9z0f88Uo Ps1IXXDUxAOqvx2FS2FO2jCapmYvI7A+jg== X-Received: by 2002:a17:90a:2d8e:: with SMTP id p14mr17339899pjd.131.1623659887699; Mon, 14 Jun 2021 01:38:07 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 10/28] tcg/ppc: Support bswap flags Date: Mon, 14 Jun 2021 01:37:42 -0700 Message-Id: <20210614083800.1166166-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For INDEX_op_bswap32_i32, pass 0 for flags: input not zero-extended, output does not need extension within the host 64-bit register. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 690c77b4da..e868417168 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -788,25 +788,35 @@ static inline void tcg_out_sari64(TCGContext *s, TCGReg dst, TCGReg src, int c) tcg_out32(s, SRADI | RA(dst) | RS(src) | SH(c & 0x1f) | ((c >> 4) & 2)); } -static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src) +static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src, int flags) { TCGReg tmp = dst == src ? TCG_REG_R0 : dst; - /* src = abcd */ - tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); /* tmp = 000c */ - tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); /* tmp = 00dc */ - tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + /* src = xxxx abcd */ + tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); /* tmp = 0000 000c */ + tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); /* tmp = 0000 00dc */ + + if (flags & TCG_BSWAP_OS) { + tcg_out_ext16s(s, dst, tmp); + } else { + tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + } } -static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src) +static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src, int flags) { TCGReg tmp = dst == src ? TCG_REG_R0 : dst; - /* Stolen from gcc's builtin_bswap32. src = abcd */ - tcg_out_rlw(s, RLWINM, tmp, src, 8, 0, 31); /* tmp = bcda */ - tcg_out_rlw(s, RLWIMI, tmp, src, 24, 0, 7); /* tmp = dcda */ - tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23); /* tmp = dcba */ - tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + /* Stolen from gcc's builtin_bswap32. src = xxxx abcd */ + tcg_out_rlw(s, RLWINM, tmp, src, 8, 0, 31); /* tmp = 0000 bcda */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 0, 7); /* tmp = 0000 dcda */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23); /* tmp = 0000 dcba */ + + if (flags & TCG_BSWAP_OS) { + tcg_out_ext32s(s, dst, tmp); + } else { + tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + } } static void tcg_out_bswap64(TCGContext *s, TCGReg dst, TCGReg src) @@ -2820,11 +2830,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: - tcg_out_bswap16(s, args[0], args[1]); + tcg_out_bswap16(s, args[0], args[1], args[2]); break; case INDEX_op_bswap32_i32: + tcg_out_bswap32(s, args[0], args[1], 0); + break; case INDEX_op_bswap32_i64: - tcg_out_bswap32(s, args[0], args[1]); + tcg_out_bswap32(s, args[0], args[1], args[2]); break; case INDEX_op_bswap64_i64: tcg_out_bswap64(s, args[0], args[1]); From patchwork Mon Jun 14 08:37:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459776 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3087233jae; Mon, 14 Jun 2021 01:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw3Tor8+CKWoPV0CG2KvDPVWT8F0ZKmwKpajCjBSrvngCNYJEXAy69WsmtrI0TiCxG8mpd X-Received: by 2002:a5e:930d:: with SMTP id k13mr13590457iom.61.1623660482277; Mon, 14 Jun 2021 01:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660482; cv=none; d=google.com; s=arc-20160816; b=y1w2vLvHHhoaYzvTG3kIkZMbDJ+sNRgZ2xwnpu+2S7oL51oz8sINzSGhI+XMmwPnUQ rcF0K1ejKvWl2QNLMJ/CrcmYqhnDVYny71bwQtIdNPZeao/dD6sbtRFP9qMHBWoIeADk yUxU1EZ4yWKO6asux/m6ji59saLOIjgR/WnbR4IDM0sqJSlPrmH9SeuEDf4IgE2kMsds eq+zRQSvOSZO14WAubJSYdNfRQlYcg+Fqcf+Vusb6adSLZOGZ/6l8wQfU8vWyA2S7tYj SbXTF1JJV53jq/N69LNlBpGIyo+jiXO+Vd7uEsZtDkIz2XJIdpLgfbEjA3ezWDpi13Ry NuVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=zQzRjvOakCYe5ymfrsL9K6I+o9h5yKvhTAHMO1Me0hs=; b=dG+h0W5Hch/cpE1z0JbxPsg4cXiXP2+hmCi8TAPvDtmuq0SOQGueKhricLTpFdHpnO J7Fr97eHx9wfdbeRMn4WykmrJIMEBEXNkLQOLlWkESCUe8aDtaQfk2074hNafG5KzIsI bwjzbQGdrvUyFKydMJ5HaoAjHJyymmOm8GXsLEK3h70uuChuserjc18wIllKn1yG5AFO Nr0jaAbsAfBA3wp+/wuZrELpgry7aRiZjMAoogmBKHDqmwzqwm+sAtz3PnuwaiV+DS8M kF1e1+fFE0Utdz0h4xTB9hI13YOTVmDjJpRZAlWWTKhhNg8O0Nf362ouwS4OujoAEto+ i8SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AcyJl20A; 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 a2si15607997jal.44.2021.06.14.01.48.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:48: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=AcyJl20A; 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]:39494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiGH-0004qM-LJ for patch@linaro.org; Mon, 14 Jun 2021 04:48:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6u-0002HI-3u for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:20 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:37587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6j-0003Z8-O8 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:19 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so9605178pjs.2 for ; Mon, 14 Jun 2021 01:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zQzRjvOakCYe5ymfrsL9K6I+o9h5yKvhTAHMO1Me0hs=; b=AcyJl20AfC6nMQHjLHLKXQKkpEH2Ww0L2W82ZL6QjHSn5z01PHtC/LCXQRwkhJ8S13 CBqE1atndraO9Z9zInGA7jZeiMb8Xze19bwc8O7OntzCYgEu/Vi+0MfTFtwObtXNDXrP RizSbO3Du/lzkaNEwMGpKLcGNPEDiaftUhv+BJw0+9J2SitnSeh0DZATjvYwYiyk7Gq6 DjdBWQDm5NCxEZ/kQl0g5e7i2DjbEtn0VNFKbuuEK1GEcUuFDaKbryQQA8Jem1WM9y7F CiJDJX9kHf2N5MEHllgJHEilvcB/rpM79EYeLK0NPMonmQ5ZeuiPWxW4eIxGrwUFy8QZ Bn0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zQzRjvOakCYe5ymfrsL9K6I+o9h5yKvhTAHMO1Me0hs=; b=J7e4boxyav/2KISdklT5Cmb84I9EX5EOOQuPr7F/kT0oyz8T5299RDfUiyRnvp0I9R PJ8i4DFWzczStG2TXyB0q1ON4IUop8LcfxnVkOIL50Gs6RxU3qdm567E9Lykai/8//4m vPE/PRGlP2cEpTlnQ43fuetUazA9LmyeK3c+fpIOprQPwkOS4wzIw0jAx63P8s0C4iWn GrL7n2O8sxvsdsodUjdCTAIZBnDcS7m1HTd1wscUSDszOmVvYDlOalQaY51tm5WkZjMR GCDZhW7XsncHBsQh+Y2GWL7635iU9g89WCBnmrUyVoLqzUxQ3VYCWDWxMVbjaKnDJnqZ X83g== X-Gm-Message-State: AOAM533LvQtHokRGy1UOeYfaWQaClZKMDUSaqNuKHQOhQTq9ehiEMqqt 63GI64KUA5trlmDdMwc3BZKiR0IugZ/iWQ== X-Received: by 2002:a17:90b:3882:: with SMTP id mu2mr12872586pjb.170.1623659888287; Mon, 14 Jun 2021 01:38:08 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 11/28] tcg/ppc: Use power10 byte-reverse instructions Date: Mon, 14 Jun 2021 01:37:43 -0700 Message-Id: <20210614083800.1166166-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index e868417168..af87643f54 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -413,6 +413,10 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) #define SRAD XO31(794) #define SRADI XO31(413<<1) +#define BRH XO31(219) +#define BRW XO31(155) +#define BRD XO31(187) + #define TW XO31( 4) #define TRAP (TW | TO(31)) @@ -748,6 +752,11 @@ static inline void tcg_out_ext16s(TCGContext *s, TCGReg dst, TCGReg src) tcg_out32(s, EXTSH | RA(dst) | RS(src)); } +static inline void tcg_out_ext16u(TCGContext *s, TCGReg dst, TCGReg src) +{ + tcg_out32(s, ANDI | SAI(src, dst, 0xffff)); +} + static inline void tcg_out_ext32s(TCGContext *s, TCGReg dst, TCGReg src) { tcg_out32(s, EXTSW | RA(dst) | RS(src)); @@ -792,6 +801,16 @@ static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src, int flags) { TCGReg tmp = dst == src ? TCG_REG_R0 : dst; + if (have_isa_3_10) { + tcg_out32(s, BRH | RA(dst) | RS(src)); + if (flags & TCG_BSWAP_OS) { + tcg_out_ext16s(s, dst, dst); + } else if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext16u(s, dst, dst); + } + return; + } + /* src = xxxx abcd */ tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); /* tmp = 0000 000c */ tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); /* tmp = 0000 00dc */ @@ -807,6 +826,16 @@ static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src, int flags) { TCGReg tmp = dst == src ? TCG_REG_R0 : dst; + if (have_isa_3_10) { + tcg_out32(s, BRW | RA(dst) | RS(src)); + if (flags & TCG_BSWAP_OS) { + tcg_out_ext32s(s, dst, src); + } else if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext32u(s, dst, dst); + } + return; + } + /* Stolen from gcc's builtin_bswap32. src = xxxx abcd */ tcg_out_rlw(s, RLWINM, tmp, src, 8, 0, 31); /* tmp = 0000 bcda */ tcg_out_rlw(s, RLWIMI, tmp, src, 24, 0, 7); /* tmp = 0000 dcda */ @@ -824,6 +853,11 @@ static void tcg_out_bswap64(TCGContext *s, TCGReg dst, TCGReg src) TCGReg t0 = dst == src ? TCG_REG_R0 : dst; TCGReg t1 = dst == src ? dst : TCG_REG_R0; + if (have_isa_3_10) { + tcg_out32(s, BRD | RA(dst) | RS(src)); + return; + } + /* src = abcd efgh */ tcg_out_rlw(s, RLWINM, t0, src, 8, 0, 31); /* t0 = 0000 fghe */ tcg_out_rlw(s, RLWIMI, t0, src, 24, 0, 7); /* t0 = 0000 hghe */ From patchwork Mon Jun 14 08:37:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459780 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3088683jae; Mon, 14 Jun 2021 01:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRZniUbk+YxvUtoWDOShON80ZOmAgdBFdfP00imHWh7WG0L3U5QR5NM9PdaBQVCL4cbigt X-Received: by 2002:a6b:8f83:: with SMTP id r125mr13406521iod.123.1623660659889; Mon, 14 Jun 2021 01:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660659; cv=none; d=google.com; s=arc-20160816; b=zNZKSZh8qU8O9EIRSCDWc2tD3IEICFDScav5ZgHIXbzgkofODrpYRLJctCD7e5PD50 MU7d6KaGfctI9zVMCeXk4yTzK111oA1clquw1B4O6ZArA13wJ8/KGaPskSg/G4joEgy2 FILNHRQCcndPqqGdxB2xduDKruSitzC+rJTBHiazyYxFF24/sLdakD/71o2GeGA3vqqc 9dQlcKU1EniVcyz5sV092iphdFQLWQn5CtSNyajG/tjKs/Rps9jNaCYKdfJwS5X0rJZE mTFM4TUbjbTOIOeRdIkYAeUY/svxdWcy77WRMyAzQjctdM/tPNbfMpceNCuYEIXJs2z2 j+Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=9DRzzMJ2NyGbyRHOk5FDpkj407KEfEqhUdHXH7B5Y3g=; b=VrS9dn6bcBsNSuZx9XozrsMt90xAIpXIeGhMP+jSr9FfH5138KDHH9N0S0vm/pD+/Z 1yrPRHUWxncMOCLckM/Iy7D40tYXOfCiwLJG8MbNyFGm7IkgKywFoRUBiuuVb3pU7U1T /4LqWY04IzTe4uG5uCHkunCkxcBIYzh8IvK3uPX337pWXNylByR15Ozu2pYD+K30h1+h RU+0iL02uSGK0d5KKe/YKPyqU2+qjmJrVIADI62Haxses7ejjD7hNP/R1jQKhFJrc+Zb 33GK2VH3THIHy89VqQxGJkx1trzXE8XyEZ3LfGjQubFpt7R4I9Iqzxl0TEOgZ2dHBKmV jAlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RlGSYyTp; 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 k8si5304584ioj.16.2021.06.14.01.50.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:50:59 -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=RlGSYyTp; 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]:48062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiJ9-00026I-9w for patch@linaro.org; Mon, 14 Jun 2021 04:50:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6x-0002Se-CA for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:23 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:41667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6l-0003ZN-6Q for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:23 -0400 Received: by mail-pg1-x532.google.com with SMTP id l184so8051364pgd.8 for ; Mon, 14 Jun 2021 01:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9DRzzMJ2NyGbyRHOk5FDpkj407KEfEqhUdHXH7B5Y3g=; b=RlGSYyTpGaBG9fXYtoFtU+SIcEYa+xarVTkWYoGuYeZ7ZrUIlLjkyZKQF2v0r34g30 gU/FVuMXSpJAd0xXfdKfD20isrg1mScqRg0QmbTTJAUN81Gp8C8JSUrRRTd815hEpFWM 4f2kJm/62gklF4iUar8/9lxEL+j9Nkqm5hTeg3CUIosgPp9kMT7gaA2TjspHsnvUuzqM cGCz8xECypfYyP89oMbntmihvoMjAsEuXDW6NbJasKl6BUHvG8Rlp78xu/jH4fg2wBX6 DncLtRuKbS16LDvgU3w8gR52RbXHjKUnBqCWEfJhimJPygndSY1lHH/fz4jtSt6LKV6q pMBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9DRzzMJ2NyGbyRHOk5FDpkj407KEfEqhUdHXH7B5Y3g=; b=QGz4Tfk2mPnEUrtGIasRMhG6YOeyvS4u+PcskRdYDfr2H0Bw+OZITqY8doNjIVl1Qw MDDTypjyhl8Rm2TW4iKpbLOWaEVeax/fExUviq1Uc43JQCIWQhRixuL8vOFtjiki4pGC vr2LkW9cmDsDomneV8fLCuZeoDXVwHkHZOUT+k0IyrHsBHhBxNyhDd23/KflwB4Dsqip HrePgAYEcFqEppPhmu62faMOUGNSqxkhHp67BFkV1Vfca5NVKNPmQ8SWp0DF2MmZ/xNO l1PLH+km+FkAwg7RF/doGuAsjqvrvXjhJIzTKHeHQfZxVmjFlRpJu19LB+/zvwKoR0fB aLgw== X-Gm-Message-State: AOAM531mSxjGE/Pgj8BAfx/wwFG9+EnIoJ2fa2DeBZEGX53wj8M9TE9Q 75tu9RmvOXuN6LIu3SIZH7Mf4acmX+g7tA== X-Received: by 2002:a62:84d4:0:b029:2e9:c639:5452 with SMTP id k203-20020a6284d40000b02902e9c6395452mr20757757pfd.61.1623659888742; Mon, 14 Jun 2021 01:38:08 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 12/28] tcg/s390: Support bswap flags Date: Mon, 14 Jun 2021 01:37:44 -0700 Message-Id: <20210614083800.1166166-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For INDEX_op_bswap16_i64, use 64-bit instructions so that we can easily provide the extension to 64-bits. Drop the special case, previously used, where the input is already zero-extended -- the minor code size savings is not worth the complication. Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 5fe073f09a..b82cf19f09 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1951,15 +1951,37 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tgen_ext16u(s, TCG_TYPE_I32, args[0], args[1]); break; - OP_32_64(bswap16): - /* The TCG bswap definition requires bits 0-47 already be zero. - Thus we don't need the G-type insns to implement bswap16_i64. */ - tcg_out_insn(s, RRE, LRVR, args[0], args[1]); - tcg_out_sh32(s, RS_SRL, args[0], TCG_REG_NONE, 16); + case INDEX_op_bswap16_i32: + a0 = args[0], a1 = args[1], a2 = args[2]; + tcg_out_insn(s, RRE, LRVR, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_sh32(s, RS_SRA, a0, TCG_REG_NONE, 16); + } else { + tcg_out_sh32(s, RS_SRL, a0, TCG_REG_NONE, 16); + } break; - OP_32_64(bswap32): + case INDEX_op_bswap16_i64: + a0 = args[0], a1 = args[1], a2 = args[2]; + tcg_out_insn(s, RRE, LRVGR, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_sh64(s, RSY_SRAG, a0, a0, TCG_REG_NONE, 48); + } else { + tcg_out_sh64(s, RSY_SRLG, a0, a0, TCG_REG_NONE, 48); + } + break; + + case INDEX_op_bswap32_i32: tcg_out_insn(s, RRE, LRVR, args[0], args[1]); break; + case INDEX_op_bswap32_i64: + a0 = args[0], a1 = args[1], a2 = args[2]; + tcg_out_insn(s, RRE, LRVR, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tgen_ext32s(s, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tgen_ext32u(s, a0, a0); + } + break; case INDEX_op_add2_i32: if (const_args[4]) { From patchwork Mon Jun 14 08:37: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: 459767 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3083161jae; Mon, 14 Jun 2021 01:41:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXKY5gl1KT7FChatxO/k2ygnW0VnuaWQgKopG34+GguZ/u1wSw+ORGJ/Y3iWlow3Iok0pH X-Received: by 2002:a05:6638:12cd:: with SMTP id v13mr15815766jas.104.1623660107852; Mon, 14 Jun 2021 01:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660107; cv=none; d=google.com; s=arc-20160816; b=rX+4vlKQOXfcdrsOdu/sKHEP3mC8+ou8+Uo+hRpZuTcUXuA1GCSjgyBI7lK1Q+OAtn gnoz8PZNmpvLoSwAgv2ZDBoVgbCnwNw34JOM20QM2UOCJDNMKj10tcAY52v2VDlLtnoh m+dkjQd38ZYI8mBhg8H6kwC3Rp+dAE7bowAmVL4cmVsiEn5ega7c2jOkWNx4fobVjlog ftSI4tb5WDHBcutVJJmjndlD5iLgYaOpS95MJcjWZ5Eh6T8Pwm+pbgKG66fQuzOcJGAc ncfMFi0HjhoNOnvMRggoF33bNavjYKbmXbO79FXayw66RLcKDjkIGYafhvoGKfREmuof LOuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=2lV8vgJYRzkBj6vA6hwqKERA8bZrmR1z2r1Kt2NYFM8=; b=kNsN5xqtw8FyHGAQmqU1peKGDL3JOgDwU8lYrLU8RPGhV/c9+1kuRXTx+u1v2DZzr1 TfCHQRK6a7GsEVOz2Pg1x2y5jfUk2Z5nMTiN6CFJOvITum7VyB+26LJlyYzj56OMwKel 982AzARq1foKsgTLlY/rAYnjXLEfjrCYtsaQWKSorTzM3bPDgvukzcwJCOabHkZPdrnU ekqT7wcfgrtafF2nOWGdOJKUpEbbDvGFHK+cEK+eFptjDShWuvVmHMfYQxFSbDet1XHV X3O56ed+2WLkNTd5e6GEFlMp8HZpB72xcqHN+0HZylFkCSOwmzhQ0QPiPwaC6gqPT1Sn gLmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YUv8rmXQ; 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 j1si15618355ila.160.2021.06.14.01.41.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:41:47 -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=YUv8rmXQ; 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]:45694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiAF-00076B-85 for patch@linaro.org; Mon, 14 Jun 2021 04:41:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6t-0002FN-GC for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:19 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:45739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6l-0003ZV-6t for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:19 -0400 Received: by mail-pl1-x62e.google.com with SMTP id 11so6147011plk.12 for ; Mon, 14 Jun 2021 01:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2lV8vgJYRzkBj6vA6hwqKERA8bZrmR1z2r1Kt2NYFM8=; b=YUv8rmXQuk0IU0YxJOXKjhF4gjJsptl0msePKlTxWAgfPk/7sUUNWV1SxUDqDdpG8f ZSjRIq0Xze5uPCUUybMH4b64JatfHMLpQsNP4FXoTav7UllOaRTMW6eiHgq1Jg/xDkzP nx1giEFn1tfcTUiNRc5y6uyxiJYAIWqv/ei5/A6F7MQIK4W41yb53e5jexJsr/16vsrz fsscrRFH6P5qnUYbVonv8AgcBV/Kj32rVxk58v3fl3LlArQyJPw+8e2Wa4Pl3isqQR0h CTP/c7apC9wEdkgt4JZK3rqIvfAf2wtixy1WSwwCzNOXKslCEOyrQoyLM/WDL5a26+rS xfGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2lV8vgJYRzkBj6vA6hwqKERA8bZrmR1z2r1Kt2NYFM8=; b=RD77VucPXsolyEDQbPEuodCDH6IX6524Zhnq5gfzSDvJWahiPP6K1qodGkUmM1r9sg 4/bKnz2TKiAD/T0zHz0qmuveNp+/xBxqTPzTUTJipujc3/KABYKMvzZNOvzFNHtNTWhB 7k9IAPQStxosMd0X6hpu74PGOqq+/uOQUQd7ynuKNoljmZwmPfsLx9aQAk9z3/Ztgmx/ XvCfIn+sD+4GWKU/4ggwHnavR0bPGyZ9wjsUYIy0y5qn46DPWcz3XfQhyi26S1MNXevy 4Z6awmezH0Ayj9uL8or/hy/PcRFuuVDDp9vE4rBvhO08bpVUeoRmnJTA2kXTVJYX1xGY xkNA== X-Gm-Message-State: AOAM533SL+yF8MpXv5ihDtBNFxcHGzNJNM4QCROgMpmtsCwDzNVDGEXb 1QVLUzMSAYC0Bzw0WCtcp33P6quyguCPJw== X-Received: by 2002:a17:90a:ea8c:: with SMTP id h12mr21632542pjz.149.1623659889335; Mon, 14 Jun 2021 01:38:09 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 13/28] tcg/mips: Support bswap flags in tcg_out_bswap16 Date: Mon, 14 Jun 2021 01:37:45 -0700 Message-Id: <20210614083800.1166166-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Merge tcg_out_bswap16 and tcg_out_bswap16s. Use the flags in the internal uses for loads and stores. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 60 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 32 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 5944448b2a..7a5634419c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -540,39 +540,36 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } } -static inline void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg) +static void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg, int flags) { + /* ret and arg can't be register tmp0 */ + tcg_debug_assert(ret != TCG_TMP0); + tcg_debug_assert(arg != TCG_TMP0); + if (use_mips32r2_instructions) { tcg_out_opc_reg(s, OPC_WSBH, ret, 0, arg); - } else { - /* ret and arg can't be register at */ - if (ret == TCG_TMP0 || arg == TCG_TMP0) { - tcg_abort(); + if (flags & TCG_BSWAP_OS) { + tcg_out_opc_reg(s, OPC_SEH, ret, 0, ret); + } else if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xffff); } - - tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, arg, 8); - tcg_out_opc_sa(s, OPC_SLL, ret, arg, 8); - tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xff00); - tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_TMP0); + return; } -} -static inline void tcg_out_bswap16s(TCGContext *s, TCGReg ret, TCGReg arg) -{ - if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_WSBH, ret, 0, arg); - tcg_out_opc_reg(s, OPC_SEH, ret, 0, ret); - } else { - /* ret and arg can't be register at */ - if (ret == TCG_TMP0 || arg == TCG_TMP0) { - tcg_abort(); - } - - tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, arg, 8); + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, arg, 8); + if (!(flags & TCG_BSWAP_IZ)) { + tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP0, TCG_TMP0, 0x00ff); + } + if (flags & TCG_BSWAP_OS) { tcg_out_opc_sa(s, OPC_SLL, ret, arg, 24); tcg_out_opc_sa(s, OPC_SRA, ret, ret, 16); - tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_TMP0); + } else { + tcg_out_opc_sa(s, OPC_SLL, ret, arg, 8); + if (flags & TCG_BSWAP_OZ) { + tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xff00); + } } + tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_TMP0); } static void tcg_out_bswap_subr(TCGContext *s, const tcg_insn_unit *sub) @@ -1367,14 +1364,14 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, break; case MO_UW | MO_BSWAP: tcg_out_opc_imm(s, OPC_LHU, TCG_TMP1, base, 0); - tcg_out_bswap16(s, lo, TCG_TMP1); + tcg_out_bswap16(s, lo, TCG_TMP1, TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_UW: tcg_out_opc_imm(s, OPC_LHU, lo, base, 0); break; case MO_SW | MO_BSWAP: tcg_out_opc_imm(s, OPC_LHU, TCG_TMP1, base, 0); - tcg_out_bswap16s(s, lo, TCG_TMP1); + tcg_out_bswap16(s, lo, TCG_TMP1, TCG_BSWAP_IZ | TCG_BSWAP_OS); break; case MO_SW: tcg_out_opc_imm(s, OPC_LH, lo, base, 0); @@ -1514,8 +1511,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, break; case MO_16 | MO_BSWAP: - tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP1, lo, 0xffff); - tcg_out_bswap16(s, TCG_TMP1, TCG_TMP1); + tcg_out_bswap16(s, TCG_TMP1, lo, 0); lo = TCG_TMP1; /* FALLTHRU */ case MO_16: @@ -1933,10 +1929,6 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_not_i64: i1 = OPC_NOR; goto do_unary; - case INDEX_op_bswap16_i32: - case INDEX_op_bswap16_i64: - i1 = OPC_WSBH; - goto do_unary; case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: i1 = OPC_SEB; @@ -1948,6 +1940,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_reg(s, i1, a0, TCG_REG_ZERO, a1); break; + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + tcg_out_bswap16(s, a0, a1, a2); + break; case INDEX_op_bswap32_i32: tcg_out_bswap32(s, a0, a1); break; From patchwork Mon Jun 14 08:37:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459787 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3092189jae; Mon, 14 Jun 2021 01:56:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB4XNOMbfuhR3DdJEzvUY5aBhAT9hkQkIDrzKje6aG+ffWn9bvq/jujMxxawUAQB9YpOjU X-Received: by 2002:a25:2fca:: with SMTP id v193mr14213271ybv.355.1623660998084; Mon, 14 Jun 2021 01:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660998; cv=none; d=google.com; s=arc-20160816; b=HF7QeNSCPawC3vTV6AUmuGqrDYqDBu2ATcLMFN3o94iCEZnUrRrH+AsrimPVwvYlmM JMIJbBne6iekmerDAPZ5omb66lg2VTeUZqoo2GFEIxpv3jhHO+IOZeKOcJ2mvnBwpRUv XtpU9FCnUE1N4p1yIlTVqIpSge7qcLIpT5Nbs54A0UYo1cU/xI1ftOC5HpV32sWUrL3U hQPSGo2yfDhfBQnHs56onevyMrkORaHCqwagoOoJ/YskwjyLfmIHA+Bm3O4setJJn5Vw feb/hFezJeXyjQ7HagGkE0SfJOcor5g0bqCTeEKY2PpHnTRuANavgFT5c8zVtwxFgKCJ 12hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=LgKd1kr+0l/T/EU54OtdSbM7ljWVi4b0faE3cCGA0EQ=; b=l0Fyz2OvDdRvetE8T6r0Cx2zCS8fJPfWoil1XWu+OD6X3hlimhBaxp8/CZI35bmoPL +ZZaO3ID8wzhsgQgFeuZC3ZspQ6KPZfDGZMEQoXj14tBIBh+pvFV8ZWggnqpGxrx2I74 9x+FOijGvH47pz0C3IkuQ208yX3sYmNl6QeckW4ZfiXj82kfPSJvgIv735hlV1ry7pUT Yfs1lvqax2FTiG/BlDuRybOyV1zTtn2oZeqkYe/ooEiDHsiw/dzWPre90jSb65haW+hX jnbkGVwW3pgSDalYFqfZROIySndLC2jl/y15CsftY2awaqaluJoJ9CPeCDNeO083K2Fv WFgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q28oC+Q8; 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 y136si15311983ybe.130.2021.06.14.01.56.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:56:38 -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=q28oC+Q8; 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]:33422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiOb-0002iq-FH for patch@linaro.org; Mon, 14 Jun 2021 04:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6v-0002LV-CV for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:21 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:33737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6l-0003Zg-Ky for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:21 -0400 Received: by mail-pf1-x430.google.com with SMTP id p13so10045940pfw.0 for ; Mon, 14 Jun 2021 01:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LgKd1kr+0l/T/EU54OtdSbM7ljWVi4b0faE3cCGA0EQ=; b=q28oC+Q8oDgeJAJ5kz2qU/XA1uzu+NmyHnaLv6/x/1TW99+KiTUjvMK/Z2hkz5bK+s hIYqAhO7DOuN92+JGrZgfHUh1PONkJxknvqVINefP/nPffAE26clM8Wx8cgr4Gllmab+ Ijc3IDACBhVivmjiJV6axUmJpW9KOeLcu1M71htrRHLFg1CDmSy02sbzY0mDHD+kBxR2 hnxUpTkzqJj/6jFlnW5FckuHVG3QVMVKnYCQ2ZyNMv9yNQQ9nwGLBSmbuRmy6UCmJ5GS 7tmv6Ac2e+sNpvJojYkBNrPrOBxMul8rZZ+MFamFmU200It+8q2/QGQoa7Ul621RsceK CQHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LgKd1kr+0l/T/EU54OtdSbM7ljWVi4b0faE3cCGA0EQ=; b=ERjQmXFRft6ktt52VaSXpNUBL2aCaib9TD/IY+GGc0ZSmaOIrnkqNOvDgeT9FzUq7f nBWoCS4E52Oz9l01L01nzGtJD/TIq48oDdMEg9vXvv0srVuY/GNN74x/i1LNGV84wDXf sLVXpnU9e/WkN1eu2zmDzsn1Xede6gpzLH9TzwujegyCMJqb7U7dD7/XL0WAcdqvE+8b jxS4tYmeLYCGafaqUPreAtWFsQeS0zcyV1DthScxjqvo9HHJCaiGON5JG2B9M6cNiifu F8/MKCYqfp6mxNqlR9rHIEisZcaTdxCNSJuV9CJWrqJ5HJCKIx3AGFPEvNVkRuVytA/H oAFg== X-Gm-Message-State: AOAM532tNICCkxsHZi4jpkiCTU75ltidO1zYquuSYpO+Iv/fIwqWiNI5 CY3ezuyuvFvrxl/U36+lYu/aRSeFv7wvJA== X-Received: by 2002:a05:6a00:a17:b029:2f9:a2bb:e126 with SMTP id p23-20020a056a000a17b02902f9a2bbe126mr4750977pfh.30.1623659889904; Mon, 14 Jun 2021 01:38:09 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 14/28] tcg/mips: Support bswap flags in tcg_out_bswap32 Date: Mon, 14 Jun 2021 01:37:46 -0700 Message-Id: <20210614083800.1166166-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Merge tcg_out_bswap32 and tcg_out_bswap32s. Use the flags in the internal uses for loads and stores. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 7a5634419c..e3698274eb 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -578,27 +578,20 @@ static void tcg_out_bswap_subr(TCGContext *s, const tcg_insn_unit *sub) tcg_debug_assert(ok); } -static void tcg_out_bswap32(TCGContext *s, TCGReg ret, TCGReg arg) +static void tcg_out_bswap32(TCGContext *s, TCGReg ret, TCGReg arg, int flags) { if (use_mips32r2_instructions) { tcg_out_opc_reg(s, OPC_WSBH, ret, 0, arg); tcg_out_opc_sa(s, OPC_ROTR, ret, ret, 16); + if (flags & TCG_BSWAP_OZ) { + tcg_out_opc_bf(s, OPC_DEXT, ret, ret, 31, 0); + } } else { - tcg_out_bswap_subr(s, bswap32_addr); - /* delay slot -- never omit the insn, like tcg_out_mov might. */ - tcg_out_opc_reg(s, OPC_OR, TCG_TMP0, arg, TCG_REG_ZERO); - tcg_out_mov(s, TCG_TYPE_I32, ret, TCG_TMP3); - } -} - -static void tcg_out_bswap32u(TCGContext *s, TCGReg ret, TCGReg arg) -{ - if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_DSBH, ret, 0, arg); - tcg_out_opc_reg(s, OPC_DSHD, ret, 0, ret); - tcg_out_dsrl(s, ret, ret, 32); - } else { - tcg_out_bswap_subr(s, bswap32u_addr); + if (flags & TCG_BSWAP_OZ) { + tcg_out_bswap_subr(s, bswap32u_addr); + } else { + tcg_out_bswap_subr(s, bswap32_addr); + } /* delay slot -- never omit the insn, like tcg_out_mov might. */ tcg_out_opc_reg(s, OPC_OR, TCG_TMP0, arg, TCG_REG_ZERO); tcg_out_mov(s, TCG_TYPE_I32, ret, TCG_TMP3); @@ -1380,7 +1373,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, if (TCG_TARGET_REG_BITS == 64 && is_64) { if (use_mips32r2_instructions) { tcg_out_opc_imm(s, OPC_LWU, lo, base, 0); - tcg_out_bswap32u(s, lo, lo); + tcg_out_bswap32(s, lo, lo, TCG_BSWAP_IZ | TCG_BSWAP_OZ); } else { tcg_out_bswap_subr(s, bswap32u_addr); /* delay slot */ @@ -1393,7 +1386,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, case MO_SL | MO_BSWAP: if (use_mips32r2_instructions) { tcg_out_opc_imm(s, OPC_LW, lo, base, 0); - tcg_out_bswap32(s, lo, lo); + tcg_out_bswap32(s, lo, lo, 0); } else { tcg_out_bswap_subr(s, bswap32_addr); /* delay slot */ @@ -1519,7 +1512,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, break; case MO_32 | MO_BSWAP: - tcg_out_bswap32(s, TCG_TMP3, lo); + tcg_out_bswap32(s, TCG_TMP3, lo, 0); lo = TCG_TMP3; /* FALLTHRU */ case MO_32: @@ -1538,9 +1531,9 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, OPC_SW, TCG_TMP0, base, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP1, base, 4); } else { - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi); + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP3, base, 0); - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo); + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP3, base, 4); } break; @@ -1945,10 +1938,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_bswap16(s, a0, a1, a2); break; case INDEX_op_bswap32_i32: - tcg_out_bswap32(s, a0, a1); + tcg_out_bswap32(s, a0, a1, 0); break; case INDEX_op_bswap32_i64: - tcg_out_bswap32u(s, a0, a1); + tcg_out_bswap32(s, a0, a1, a2); break; case INDEX_op_bswap64_i64: tcg_out_bswap64(s, a0, a1); From patchwork Mon Jun 14 08:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459775 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3086608jae; Mon, 14 Jun 2021 01:47:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsNM31cjZg4BYg2eJAjxdfRdbOHZ0oDHjFCdZn7Fdwwll5Q25GRtqeNCcW367JY03BYR2Z X-Received: by 2002:a25:d606:: with SMTP id n6mr23177515ybg.210.1623660423323; Mon, 14 Jun 2021 01:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660423; cv=none; d=google.com; s=arc-20160816; b=pbXaSRbasy1bwqutNx/fLzCqxnl6Kg7vrzhWUxwyd0VrvdpgNn78yBx/ohDdvG/247 nID6lG90GA5HayvpnfhIMcRFpIdMdSwcvboukIGMRXrj98d2Bhsba0ByPWELhSOgND8o KGUSrOexola/irhFKhfw3P/xLCcPT77akd8uvG7O3sCUm/rJt858LtkXCik/g2Y+8VH4 34loIpO2eAt6LL+Ia6jG/svmUXXjHfK0Eqju8ZwN/7lkAcI/qkXz2vcGhUyug34hJp8Y wQ00t93lIOV/mb0FVJ3g20rfQ0DhCeNXRT/OeOuCjn6SxEpjEH3fCc7mh4TCZd5hAJdS opRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=eanNhhdSmGxxyPIStrUWyJsT/SdYtmDYp1DHF6kEh6o=; b=QvT80Q7H5dukPbv/3W4j3JnA7ObqfHLYTPjDBCf3d0dd9FIAXAPa42zabdekcPWsFS 55uWcDM66GRRJ6I9OQe7HVKjKcbxFUcShPog3Sva65o1AxGqbYYfaMHfAWZ/Fqj7xwMS lq5MYpWDjMDw2/ZMa0nyZaLUICLOtJ7qwAfiq3/sdK6U4O32P29SstV+m49cmkwXA68K 6ovMTvtC/6iiNv3e/W6nOBVWttHHO0PaSvbxgmjyCwMS6hDSv122hFwI2UrDmuaOqvuS GWDfDYJNS8RkH4MyyMtCqkP/IoZeIk4PldlXMu5kGXF7ebBVtWc849dK3nHMDhYij4zZ w/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZpsqCrsU; 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 k38si473470ybj.98.2021.06.14.01.47.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:47:03 -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=ZpsqCrsU; 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]:34662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiFK-0001dW-Pn for patch@linaro.org; Mon, 14 Jun 2021 04:47:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6v-0002Ny-W5 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:22 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:40617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6l-0003Zo-PC for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:21 -0400 Received: by mail-pj1-x1030.google.com with SMTP id mp5-20020a17090b1905b029016dd057935fso9589219pjb.5 for ; Mon, 14 Jun 2021 01:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eanNhhdSmGxxyPIStrUWyJsT/SdYtmDYp1DHF6kEh6o=; b=ZpsqCrsUF2QzCbXdnytQKEJRtleqCS2tlNtDW+dd8sLPezkdwBVGLOx/EyZ5iR37dD QDoFFoazCT/Q1qE1JmTboOkTASJe8J+2poDmwNWaN53+R/obGqKvPAEq6q4WWI/8B4Co e16ppTNepCzeebfqOvWLJTcCkw87I8emQ7Ge7gxO2OkCK6BbfhjQDkj6UuqgaAty6Ilw YG+AAsc8JiRMotFS9oXDreT5Tw+24b7jb4HGJwL8uQVf6Up3C2TiS74a7hCjGxsubg4/ d+zcMxUMkOSV2KCdpgMffdqqAR2xVOcy7n2pI6QQjAURs0llpaH5ADgOc28e87TCvTEQ pRSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eanNhhdSmGxxyPIStrUWyJsT/SdYtmDYp1DHF6kEh6o=; b=i0+s1CV0PvEIdGzOZsiLGjY1Viiu4+xlEP2NsbmGAmMhG7eS4wVGNZmCOb/baY2kVr F+ruHSzwMa0NHbxZBq3bJkIIoAyX55wZKKW12rf0C8oqcGFMDqpgPaZ7r4VR/lw9345Q 5nui/MkS7yOh19XNFfFpZF7mbUNU+BbkWKxM3cgeFqXKrQvtGTGF+tOy9tAfJmnhh+z4 EQxfeH6CQF8BpFOhSlhnnU3dLKeu0lSHCM5lCOWMz9mzbUejjp6a740UGSqa0EIW1oO9 372oJXmMn8ywNXjc/TiVCezN8xdTEPHCOJaVNwxjM6/2x/UkXa0Erhi77543nh4fGfjN I8Kw== X-Gm-Message-State: AOAM530Aemr9P/nLoBp3j4BC/KkEHziLpt80OfgS7wAAA6MMpGLsFA+f psklC0hgs8eX78D2GCO4RC5zauq7sUE4IA== X-Received: by 2002:a17:90a:fb51:: with SMTP id iq17mr17752189pjb.26.1623659890549; Mon, 14 Jun 2021 01:38:10 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 15/28] tcg/tci: Support bswap flags Date: Mon, 14 Jun 2021 01:37:47 -0700 Message-Id: <20210614083800.1166166-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The existing interpreter zero-extends, ignoring high bits. Simply add a separate sign-extension opcode if required. Ensure that the interpreter supports ext16s when bswap16 is enabled. Signed-off-by: Richard Henderson --- tcg/tci.c | 3 ++- tcg/tci/tcg-target.c.inc | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tci.c b/tcg/tci.c index d68c5a4e55..109522a865 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -733,7 +733,8 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, regs[r0] = (int8_t)regs[r1]; break; #endif -#if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 +#if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 || \ + TCG_TARGET_HAS_bswap16_i32 || TCG_TARGET_HAS_bswap16_i64 CASE_32_64(ext16s) tci_args_rr(&tb_ptr, &r0, &r1); regs[r0] = (int16_t)regs[r1]; diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 823ecd5d35..1e92688dca 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -617,6 +617,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], const int const_args[TCG_MAX_OP_ARGS]) { + TCGOpcode exts; + switch (opc) { case INDEX_op_exit_tb: tcg_out_op_p(s, opc, (void *)args[0]); @@ -710,12 +712,27 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, CASE_64(ext32u) /* Optional (TCG_TARGET_HAS_ext32u_i64). */ CASE_64(ext_i32) CASE_64(extu_i32) - CASE_32_64(bswap16) /* Optional (TCG_TARGET_HAS_bswap16_*). */ - CASE_32_64(bswap32) /* Optional (TCG_TARGET_HAS_bswap32_*). */ - CASE_64(bswap64) /* Optional (TCG_TARGET_HAS_bswap64_i64). */ + case INDEX_op_bswap32_i32: /* Optional (TCG_TARGET_HAS_bswap32_i32). */ + case INDEX_op_bswap64_i64: /* Optional (TCG_TARGET_HAS_bswap64_i64). */ tcg_out_op_rr(s, opc, args[0], args[1]); break; + case INDEX_op_bswap16_i32: /* Optional (TCG_TARGET_HAS_bswap16_i32). */ + exts = INDEX_op_ext16s_i32; + goto do_bswap; + case INDEX_op_bswap16_i64: /* Optional (TCG_TARGET_HAS_bswap16_i64). */ + exts = INDEX_op_ext16s_i64; + goto do_bswap; + case INDEX_op_bswap32_i64: /* Optional (TCG_TARGET_HAS_bswap32_i64). */ + exts = INDEX_op_ext32s_i64; + do_bswap: + /* The base tci bswaps zero-extend, and ignore high bits. */ + tcg_out_op_rr(s, opc, args[0], args[1]); + if (args[2] & TCG_BSWAP_OS) { + tcg_out_op_rr(s, exts, args[0], args[0]); + } + break; + #if TCG_TARGET_REG_BITS == 32 case INDEX_op_add2_i32: case INDEX_op_sub2_i32: From patchwork Mon Jun 14 08:37:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459771 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3084327jae; Mon, 14 Jun 2021 01:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy64R2b0NkycUz7tRO4ZY+mV+RgriChgNwYpnhHPxvTc5hYlQMpmctJ0OhpprbimbcJz+V4 X-Received: by 2002:a25:d257:: with SMTP id j84mr23613777ybg.404.1623660239095; Mon, 14 Jun 2021 01:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660239; cv=none; d=google.com; s=arc-20160816; b=Zk0Xq3YYN1OKkstwo9nuymr3epGO12lpkrIa+pvTbfxVlmXN20WM5+dt/bGc7iEqEq IezUR+AQXo62204eKPK9igejjv8pPof9yJ894/0Ycq+34jvhi9ZdBoTD9IE1dqGs4ao6 CzV/fkziSE4SSQsWpuzZEoxq4FktjTSjN16R0JHY6g95AYD+tlK7lDRCwMWEXV0olR6S Buf/vhOWsslXSRx730U93CV8t59KVFEE2F7Wa5KsaTbJVAjGP991ZnmRk8GZD+wHRK/k AT7TYI/we2yXXPSIUUD+J/QmF2L4G27RPrFgvZQxeLUfYmQSHGtWJMzBSlv3aKdMCMHr Si4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=UZkn/bCz3YGcO9TqhXoosXO7opN8+jen9eeeiO+Mw8Y=; b=AK9ZZRd/0xdlh6xVb+bns9Z2I9s7qdMwLKTTvy06YowsDsUebN9KQ79eeqb+mORN3i 9deoTWGufA6Rjp+K/jfY3WldVKhAlhuWgf2M88ocKd3lHrBql/3C7xDxqatePfCzzWB9 wXBMf2QoaLIUceBHugtYkw3AIAsza9VauW9Jvw+t82WBcLOxtUUbjZ+iNcVhSOoKtXg0 6hjr3rPj+xatSObhy/vlsdAyZsFPnqLgIYyzZYFmWLGh4CfE0H+GQ/pDed2neAc6vCz9 xQ5wq6skseB6dMOoCfQbLtTMJ3Hm1xc8wpjA5Roz42FQxew0Pwav8Y4cgwl6k77RqTkL Bfmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SSJlREGT; 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 m81si13570315ybf.257.2021.06.14.01.43.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:43:59 -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=SSJlREGT; 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]:54364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiCM-0004N1-Iw for patch@linaro.org; Mon, 14 Jun 2021 04:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6v-0002MP-LE for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:21 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:40619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6n-0003Zv-5j for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:21 -0400 Received: by mail-pj1-x1032.google.com with SMTP id mp5-20020a17090b1905b029016dd057935fso9589252pjb.5 for ; Mon, 14 Jun 2021 01:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UZkn/bCz3YGcO9TqhXoosXO7opN8+jen9eeeiO+Mw8Y=; b=SSJlREGT/yv8Er9ROaPRLix0KZGEhoeElfqmFmPuh1LkGcO0KuZvpCZFgmCnNdB2Jn Xdn2eItMpgGbK/fImwcCHnafZPSlgRuhIA7qIIVfnymNhoTCW3oAaVC0Jw0C8L/Ucdyi IW8AZU1PfheTPYJdFCPGJCo9FtAYhk5KGFtWrhhpGdrT0PiIo4B4zeUj2ImePYFYM7cz awk0xU6kmEhWDvUZBlwXa10P6ejLhrQDuj2ney61sv/5FudCRs7HW2czRlA64/ikT5TU dliyR42zN7sst2wPh2y1fKPPJKo0LfpPxBhgbygX8FevVtq9G9Z1HTwkeSe1Q5hqVRQJ ZsBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UZkn/bCz3YGcO9TqhXoosXO7opN8+jen9eeeiO+Mw8Y=; b=j2sjOsICCQKC3neNFBdMtiVBOTPkReH0XafKP9nUvIEUyYwVudjfeweDT5ElHikQ+e Esoy14CdW7i4bSFZLrBq6Vn40TipkX9tOFilLPgKCD59tm4LWYH9XlQjUU0SbkfmxlM8 Tg8xErUfmClSoddfyGCKiXwGxW6RwWgv2alVj/XuOXJ4nBQSABRhVOm/ShsjJmZnfTq6 uhN09tAPyFiGEE3t3g1qwn3PJwMPhsSg7pkKe0huznHoHqZPxx5/zVAAgCiEfkql/XSb 0edUk1ShjeCxmxVVmKZqFA4JSvvfKrYujpdmSN0rM2q3+KfZJ+gevlKVPTcgCohkU9Cf bhFQ== X-Gm-Message-State: AOAM530LcHaXeVVCCKs7HnZuArs9BekR+6vfG60I4TzlBtE1bo21ZEx/ WtpxW06T3HqnHn6KxDWxxpAg9JCFWqLOHA== X-Received: by 2002:a17:902:222:b029:11b:9cea:eea9 with SMTP id 31-20020a1709020222b029011b9ceaeea9mr3816446plc.11.1623659891130; Mon, 14 Jun 2021 01:38:11 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 16/28] tcg: Handle new bswap flags during optimize Date: Mon, 14 Jun 2021 01:37:48 -0700 Message-Id: <20210614083800.1166166-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Notice when the input is known to be zero-extended and force the TCG_BSWAP_IZ flag on. Honor the TCG_BSWAP_OS bit during constant folding. Propagate the input to the output mask. Signed-off-by: Richard Henderson --- tcg/optimize.c | 56 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/optimize.c b/tcg/optimize.c index 37c902283e..3b6983fbef 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -354,10 +354,12 @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y) return (uint16_t)x; CASE_OP_32_64(bswap16): - return bswap16(x); + x = bswap16(x); + return y & TCG_BSWAP_OS ? (int16_t)x : x; CASE_OP_32_64(bswap32): - return bswap32(x); + x = bswap32(x); + return y & TCG_BSWAP_OS ? (int32_t)x : x; case INDEX_op_bswap64_i64: return bswap64(x); @@ -1028,6 +1030,42 @@ void tcg_optimize(TCGContext *s) } break; + CASE_OP_32_64(bswap16): + mask = arg_info(op->args[1])->mask; + if (mask <= 0xffff) { + op->args[2] |= TCG_BSWAP_IZ; + } + mask = bswap16(mask); + switch (op->args[2] & (TCG_BSWAP_OZ | TCG_BSWAP_OS)) { + case TCG_BSWAP_OZ: + break; + case TCG_BSWAP_OS: + mask = (int16_t)mask; + break; + default: /* undefined high bits */ + mask |= MAKE_64BIT_MASK(16, 48); + break; + } + break; + + case INDEX_op_bswap32_i64: + mask = arg_info(op->args[1])->mask; + if (mask <= 0xffffffffu) { + op->args[2] |= TCG_BSWAP_IZ; + } + mask = bswap32(mask); + switch (op->args[2] & (TCG_BSWAP_OZ | TCG_BSWAP_OS)) { + case TCG_BSWAP_OZ: + break; + case TCG_BSWAP_OS: + mask = (int32_t)mask; + break; + default: /* undefined high bits */ + mask |= MAKE_64BIT_MASK(32, 32); + break; + } + break; + default: break; } @@ -1134,9 +1172,6 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(ext16s): CASE_OP_32_64(ext16u): CASE_OP_32_64(ctpop): - CASE_OP_32_64(bswap16): - CASE_OP_32_64(bswap32): - case INDEX_op_bswap64_i64: case INDEX_op_ext32s_i64: case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: @@ -1150,6 +1185,17 @@ void tcg_optimize(TCGContext *s) } goto do_default; + CASE_OP_32_64(bswap16): + CASE_OP_32_64(bswap32): + case INDEX_op_bswap64_i64: + if (arg_is_const(op->args[1])) { + tmp = do_constant_folding(opc, arg_info(op->args[1])->val, + op->args[2]); + tcg_opt_gen_movi(s, &temps_used, op, op->args[0], tmp); + break; + } + goto do_default; + CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(mul): From patchwork Mon Jun 14 08:37:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459778 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3088230jae; Mon, 14 Jun 2021 01:50:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdFkcx+l8FLfojGvROvJ1Ni9i01dgjzCRju/IXioZ8HbTPNdUXOEbAhVN9SirEnt0dKo4D X-Received: by 2002:a25:9942:: with SMTP id n2mr23341232ybo.230.1623660605243; Mon, 14 Jun 2021 01:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660605; cv=none; d=google.com; s=arc-20160816; b=kkgPpoTwIyg9R6SLCEUcrCZxbZpC6kTw5DkP+tphoRJYcU9wiepUnyKV0H5X3EClCN oOKIPvstl9f+88VCoYFX5Ed8HNjaRGiVI1XG8tP+euXOiApGxjPKURok+JhluH7m6eDj DL/WM3Tr31tGAy6SccumLQKA9BDKOII05QIRAJUgqCX708JZlPxCcJNndfNDp+UYdHSU LuxHVSNGNTchzdRDaguQMlQsbRGV045tHtqNqFtrNCTVqTKwewYcRtAdfAL/chXyS6gE MkNJ/HNbev1ABqOV/MC3I7grWPpxmFPOt8xBXN3QqmjwPaXi37YBeXQGfg7UOQYMPIyY xgiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=4hwXCHaT/vW/aMtR3cJ4Vr8bzsPcCgTPjrmVdwIPgV4=; b=C923oExGmY7pNyzUo6/JLVv4O4M/yWKxrRTezWQOlSItln4z+JGgiO576EnWDfNvHk B6NcUy7aVR8lF3LMz0IXCpCRVX/PQSYRrs5nJqIZVBzBfApNaLpnSpwEgknhj0oah41j 0tPWAFzCtIVbtlsCmEa5wscckb23I38RGYKKPK1Dl3RbqgEwUDEfXZhJ9zAV38+3DHfO lnwG+BRf8D1G1ploAIFHSrwSy3u4CxqTZcUVcmskZz+GB1Ca4H6NUTJzdK9gkAAtsSNl YTkXFCurdAjqURpu/znuBnKCme6tO9jdTrOBFoAyjhHrx0FMuddibp9SWb0h4bqX4jZY MFQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="cpc/6/7O"; 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 n65si14290432ybn.477.2021.06.14.01.50.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:50: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=pass header.i=@linaro.org header.s=google header.b="cpc/6/7O"; 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]:43164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiIG-0007Ia-JK for patch@linaro.org; Mon, 14 Jun 2021 04:50:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6w-0002Qr-O8 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:22 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:41789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6n-0003ao-86 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:22 -0400 Received: by mail-pl1-x636.google.com with SMTP id e1so6151761plh.8 for ; Mon, 14 Jun 2021 01:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4hwXCHaT/vW/aMtR3cJ4Vr8bzsPcCgTPjrmVdwIPgV4=; b=cpc/6/7O7brmAkDc73FOJrUFTku3lMRMK+BbT81o8hyEWz+OGii/FMVxNQ6Qg5hAAQ JSq6JpCeROUVT+19Kk2Dk3nvKgambMo2DTKxzNEpvOEAuXlQ7Q17Y3yhe6XTV4mwP6Wm VnPqy5g3xLkpjWXTBpu8fI8ADEF+wkI1zIMPmryTjTTkXQH3V99b8wDaCNg950r6MiuW m+TnT1O5b8jZZWmryKU+9RWj58YB/jqAbK+HPIOpMIYY9uXxnhjfk9tvSFTwi3pFD+4g v1tvJgZkOQ2RsKkXax9ksexo7jLBsuEks269ptKhRKNvpFO2GLK3XGo3Muug4C4qLIjJ O48A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4hwXCHaT/vW/aMtR3cJ4Vr8bzsPcCgTPjrmVdwIPgV4=; b=nmj563aEODYbImySUKMNsaemkYg4dd4pS36+3q157NDRpuDk+Eqw/3b25LW3tFsinh yGA6y2fotE68/z34vsffMhtEA/5GpyK6KZ5PNQrSM/e1PcFwVFeqXqttX2Glizcgkf+0 N5fh0Vw1b6gONihQQ1GCa3bEYoL04lwjiJMwtj5uWIMH/Lua+I/y+ivKRThm7eLwROS8 +fXshIzNjgnS+uXpMnDa2qlJuRdMI63EjqVrXY5aEArFaOxxq2CD6T5bD2+Umb0BHFeg GQ4EZ+F/FD4VpSpyci0V/DhDxrmz53/l3G4p5Z9tizD4S7x7MhbVMPV4pXblWS9f7hOc WLSQ== X-Gm-Message-State: AOAM533bHb2x1THNidusKy7HvI4lPS/m+PVFy8UgvxbGPFDx39xgki4L YcPFxn0oSsQVolgcJl6XL04W8xubLaBHNg== X-Received: by 2002:a17:90a:398f:: with SMTP id z15mr17854680pjb.183.1623659891820; Mon, 14 Jun 2021 01:38:11 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 17/28] tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64 Date: Mon, 14 Jun 2021 01:37:49 -0700 Message-Id: <20210614083800.1166166-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Implement the new semantics in the fallback expansion. Change all callers to supply the flags that keep the semantics unchanged locally. Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 8 +-- target/arm/translate-a64.c | 12 ++-- target/arm/translate.c | 2 +- target/i386/tcg/translate.c | 2 +- target/mips/tcg/mxu_translate.c | 2 +- target/s390x/translate.c | 4 +- target/sh4/translate.c | 2 +- tcg/tcg-op.c | 121 ++++++++++++++++++++++---------- 8 files changed, 99 insertions(+), 54 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index ef8a008ea7..caf6ba2149 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -330,7 +330,7 @@ void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg); -void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg); +void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags); void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); @@ -525,8 +525,8 @@ void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg); -void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg); -void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg); +void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags); +void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags); void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); @@ -1185,7 +1185,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_ext32u_tl tcg_gen_mov_i32 #define tcg_gen_ext32s_tl tcg_gen_mov_i32 #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32 -#define tcg_gen_bswap32_tl tcg_gen_bswap32_i32 +#define tcg_gen_bswap32_tl(D, S, F) tcg_gen_bswap32_i32(D, S) #define tcg_gen_bswap_tl tcg_gen_bswap32_i32 #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64 #define tcg_gen_extr_i64_tl tcg_gen_extr_i64_i32 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8713dfec17..e0785ce859 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5437,15 +5437,15 @@ static void handle_rev32(DisasContext *s, unsigned int sf, /* bswap32_i64 requires zero high word */ tcg_gen_ext32u_i64(tcg_tmp, tcg_rn); - tcg_gen_bswap32_i64(tcg_rd, tcg_tmp); + tcg_gen_bswap32_i64(tcg_rd, tcg_tmp, TCG_BSWAP_IZ | TCG_BSWAP_OZ); tcg_gen_shri_i64(tcg_tmp, tcg_rn, 32); - tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp); + tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ | TCG_BSWAP_OZ); tcg_gen_concat32_i64(tcg_rd, tcg_rd, tcg_tmp); tcg_temp_free_i64(tcg_tmp); } else { tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rn)); - tcg_gen_bswap32_i64(tcg_rd, tcg_rd); + tcg_gen_bswap32_i64(tcg_rd, tcg_rd, TCG_BSWAP_IZ | TCG_BSWAP_OZ); } } @@ -12436,10 +12436,12 @@ static void handle_rev(DisasContext *s, int opcode, bool u, read_vec_element(s, tcg_tmp, rn, i, grp_size); switch (grp_size) { case MO_16: - tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp); + tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_32: - tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp); + tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, + TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_64: tcg_gen_bswap64_i64(tcg_tmp, tcg_tmp); diff --git a/target/arm/translate.c b/target/arm/translate.c index 8e0e55c1e0..6b88163e3a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -342,7 +342,7 @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var) static void gen_revsh(TCGv_i32 dest, TCGv_i32 var) { tcg_gen_ext16u_i32(var, var); - tcg_gen_bswap16_i32(var, var); + tcg_gen_bswap16_i32(var, var, TCG_BSWAP_IZ | TCG_BSWAP_OZ); tcg_gen_ext16s_i32(dest, var); } diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index a7f5c0c8f2..e8a9dcd21a 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -7203,7 +7203,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) { gen_op_mov_v_reg(s, MO_32, s->T0, reg); tcg_gen_ext32u_tl(s->T0, s->T0); - tcg_gen_bswap32_tl(s->T0, s->T0); + tcg_gen_bswap32_tl(s->T0, s->T0, TCG_BSWAP_IZ | TCG_BSWAP_OZ); gen_op_mov_reg_v(s, MO_32, reg, s->T0); } break; diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index fb0a811af6..c12cf78df7 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -861,7 +861,7 @@ static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx) if (sel == 1) { /* S32LDDR */ - tcg_gen_bswap32_tl(t1, t1); + tcg_gen_bswap32_tl(t1, t1, TCG_BSWAP_IZ | TCG_BSWAP_OZ); } gen_store_mxu_gpr(t1, XRa); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index e243624d2a..03dab9f350 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3939,13 +3939,13 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o) static DisasJumpType op_rev16(DisasContext *s, DisasOps *o) { - tcg_gen_bswap16_i64(o->out, o->in2); + tcg_gen_bswap16_i64(o->out, o->in2, TCG_BSWAP_IZ | TCG_BSWAP_OZ); return DISAS_NEXT; } static DisasJumpType op_rev32(DisasContext *s, DisasOps *o) { - tcg_gen_bswap32_i64(o->out, o->in2); + tcg_gen_bswap32_i64(o->out, o->in2, TCG_BSWAP_IZ | TCG_BSWAP_OZ); return DISAS_NEXT; } diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 9312790623..147219759b 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -677,7 +677,7 @@ static void _decode_opc(DisasContext * ctx) { TCGv low = tcg_temp_new(); tcg_gen_ext16u_i32(low, REG(B7_4)); - tcg_gen_bswap16_i32(low, low); + tcg_gen_bswap16_i32(low, low, TCG_BSWAP_IZ | TCG_BSWAP_OZ); tcg_gen_deposit_i32(REG(B11_8), REG(B7_4), low, 0, 16); tcg_temp_free(low); } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index dc65577e2f..3763285bb0 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1001,20 +1001,35 @@ void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg) } } -/* Note: we assume the two high bytes are set to zero */ -void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) +void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags) { + /* Only one extension flag may be present. */ + tcg_debug_assert(!(flags & TCG_BSWAP_OS) || !(flags & TCG_BSWAP_OZ)); + if (TCG_TARGET_HAS_bswap16_i32) { - tcg_gen_op3i_i32(INDEX_op_bswap16_i32, ret, arg, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_op3i_i32(INDEX_op_bswap16_i32, ret, arg, flags); } else { TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); - tcg_gen_ext8u_i32(t0, arg); - tcg_gen_shli_i32(t0, t0, 8); - tcg_gen_shri_i32(ret, arg, 8); - tcg_gen_or_i32(ret, ret, t0); + tcg_gen_shri_i32(t0, arg, 8); + if (!(flags & TCG_BSWAP_IZ)) { + tcg_gen_ext8u_i32(t0, t0); + } + + if (flags & TCG_BSWAP_OS) { + tcg_gen_shli_i32(t1, t1, 24); + tcg_gen_sari_i32(t1, t1, 16); + } else if (flags & TCG_BSWAP_OZ) { + tcg_gen_ext8u_i32(t1, arg); + tcg_gen_shli_i32(t1, t1, 8); + } else { + tcg_gen_shli_i32(t1, arg, 8); + } + + tcg_gen_or_i32(ret, t0, t1); tcg_temp_free_i32(t0); + tcg_temp_free_i32(t1); } } @@ -1655,51 +1670,79 @@ void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) } } -/* Note: we assume the six high bytes are set to zero */ -void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) +void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags) { + /* Only one extension flag may be present. */ + tcg_debug_assert(!(flags & TCG_BSWAP_OS) || !(flags & TCG_BSWAP_OZ)); + if (TCG_TARGET_REG_BITS == 32) { - tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg)); - tcg_gen_movi_i32(TCGV_HIGH(ret), 0); + tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg), flags); + if (flags & TCG_BSWAP_OS) { + tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); + } else { + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); + } } else if (TCG_TARGET_HAS_bswap16_i64) { - tcg_gen_op3i_i64(INDEX_op_bswap16_i64, ret, arg, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_op3i_i64(INDEX_op_bswap16_i64, ret, arg, flags); } else { TCGv_i64 t0 = tcg_temp_new_i64(); + TCGv_i64 t1 = tcg_temp_new_i64(); - tcg_gen_ext8u_i64(t0, arg); - tcg_gen_shli_i64(t0, t0, 8); - tcg_gen_shri_i64(ret, arg, 8); - tcg_gen_or_i64(ret, ret, t0); + tcg_gen_shri_i64(t0, arg, 8); + if (!(flags & TCG_BSWAP_IZ)) { + tcg_gen_ext8u_i64(t0, t0); + } + + if (flags & TCG_BSWAP_OS) { + tcg_gen_shli_i64(t1, t1, 56); + tcg_gen_sari_i64(t1, t1, 48); + } else if (flags & TCG_BSWAP_OZ) { + tcg_gen_ext8u_i64(t1, arg); + tcg_gen_shli_i64(t1, t1, 8); + } else { + tcg_gen_shli_i64(t1, arg, 8); + } + + tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); } } -/* Note: we assume the four high bytes are set to zero */ -void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) +void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags) { + /* Only one extension flag may be present. */ + tcg_debug_assert(!(flags & TCG_BSWAP_OS) || !(flags & TCG_BSWAP_OZ)); + if (TCG_TARGET_REG_BITS == 32) { tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg)); - tcg_gen_movi_i32(TCGV_HIGH(ret), 0); + if (flags & TCG_BSWAP_OS) { + tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); + } else { + tcg_gen_movi_i32(TCGV_HIGH(ret), 0); + } } else if (TCG_TARGET_HAS_bswap32_i64) { - tcg_gen_op3i_i64(INDEX_op_bswap32_i64, ret, arg, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_op3i_i64(INDEX_op_bswap32_i64, ret, arg, flags); } else { TCGv_i64 t0 = tcg_temp_new_i64(); TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_constant_i64(0x00ff00ff); - /* arg = ....abcd */ - tcg_gen_shri_i64(t0, arg, 8); /* t0 = .....abc */ - tcg_gen_and_i64(t1, arg, t2); /* t1 = .....b.d */ - tcg_gen_and_i64(t0, t0, t2); /* t0 = .....a.c */ - tcg_gen_shli_i64(t1, t1, 8); /* t1 = ....b.d. */ - tcg_gen_or_i64(ret, t0, t1); /* ret = ....badc */ + /* arg = xxxxabcd */ + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .xxxxabc */ + tcg_gen_and_i64(t1, arg, t2); /* t1 = .....b.d */ + tcg_gen_and_i64(t0, t0, t2); /* t0 = .....a.c */ + tcg_gen_shli_i64(t1, t1, 8); /* t1 = ....b.d. */ + tcg_gen_or_i64(ret, t0, t1); /* ret = ....badc */ - tcg_gen_shli_i64(t1, ret, 48); /* t1 = dc...... */ - tcg_gen_shri_i64(t0, ret, 16); /* t0 = ......ba */ - tcg_gen_shri_i64(t1, t1, 32); /* t1 = ....dc.. */ - tcg_gen_or_i64(ret, t0, t1); /* ret = ....dcba */ + tcg_gen_shli_i64(t1, ret, 48); /* t1 = dc...... */ + tcg_gen_shri_i64(t0, ret, 16); /* t0 = ......ba */ + if (flags & TCG_BSWAP_OS) { + tcg_gen_sari_i64(t1, t1, 32); /* t1 = ssssdc.. */ + } else { + tcg_gen_shri_i64(t1, t1, 32); /* t1 = ....dc.. */ + } + tcg_gen_or_i64(ret, t0, t1); /* ret = ssssdcba */ tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); @@ -2846,7 +2889,7 @@ 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_gen_bswap16_i32(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); if (orig_memop & MO_SIGN) { tcg_gen_ext16s_i32(val, val); } @@ -2874,7 +2917,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) switch (memop & MO_SIZE) { case MO_16: tcg_gen_ext16u_i32(swap, val); - tcg_gen_bswap16_i32(swap, swap); + tcg_gen_bswap16_i32(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_32: tcg_gen_bswap32_i32(swap, val); @@ -2935,13 +2978,13 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { case MO_16: - tcg_gen_bswap16_i64(val, val); + tcg_gen_bswap16_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); if (orig_memop & MO_SIGN) { tcg_gen_ext16s_i64(val, val); } break; case MO_32: - tcg_gen_bswap32_i64(val, val); + tcg_gen_bswap32_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); if (orig_memop & MO_SIGN) { tcg_gen_ext32s_i64(val, val); } @@ -2975,11 +3018,11 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) switch (memop & MO_SIZE) { case MO_16: tcg_gen_ext16u_i64(swap, val); - tcg_gen_bswap16_i64(swap, swap); + tcg_gen_bswap16_i64(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_32: tcg_gen_ext32u_i64(swap, val); - tcg_gen_bswap32_i64(swap, swap); + tcg_gen_bswap32_i64(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); break; case MO_64: tcg_gen_bswap64_i64(swap, val); From patchwork Mon Jun 14 08:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459788 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3093574jae; Mon, 14 Jun 2021 01:59:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFqkLwaHH1PihFVsLpOB9XOHX5Z4xKVDFh7ioIvof7iR5W4vi3pfCsEzNkWJ0lZ50qvVxx X-Received: by 2002:a92:d283:: with SMTP id p3mr13137221ilp.170.1623661159411; Mon, 14 Jun 2021 01:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623661159; cv=none; d=google.com; s=arc-20160816; b=fm4dK4lsWPHm5qA/0RB6dY3JXrSeW8PZeE4aVjzOXJxrwTF05V0tbWsWHygWmFnG/9 jXeITtFPNrjOvjaRrr/WrXqqiou0Svsh3ptvXcaZSWTW+wWMa6a5lc/Rag7svIohvABI a1HLfxcTvtPL65r9CToOaA0QFAwPsIV+RGNrjjQp44ACB+a02JZKe5Sdnqw3owAH7Iq/ ojph5d5qf3+CuVt2pZE03zjEPQjDAfZa6suVt2h6PyfhPd15vUHU3nyQscqf5tTcsO9z cxeyFmNuj4ZB5F0E7B1JeUyvsPoJq+7+viZgdS32qUTTrEy8lLJ7Bjqlf93TSsKuU6Ry 5Jjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=UVKS3oIvQJqq/m46KHoZVGeIMZjC4WFobcwJ7uSJNW4=; b=Fd90OaKtA3w8fSqHvA4JA8Xumwx9CFxdcVnhbIIDQZKT6p5zxpDUdR3YpBRfvFyjt+ MfdMUjIxIyw3KJoe5TSWJlf+ovP1x15O4A09vSXeslbI1Kh2NdYAi7HHwaPCad6lI76d 8rXUi6DfDktUDxrHKxpf5R8HtnN+8L3fLp0mEZWcqshJ+a90ywWjDEbSBEWEdKYiLLxy ownKDH24nDdnNB7I5dDGcV0qkpZvtD3pTcl5DySyRuoAZtylXU8ZKh74b6uWwjuGH2R4 zxEusxJqdrpc/rWtkGv7IILOVVYg0vuTlRpey67t15qtaBerCUUWpnPvU3idNuo0ZLSE jp9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=haD5awAv; 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 a27si17115824jaq.68.2021.06.14.01.59.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:59:19 -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=haD5awAv; 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]:41616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiRC-0000ln-QS for patch@linaro.org; Mon, 14 Jun 2021 04:59:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6x-0002Rt-3c for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:23 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:37404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6o-0003c2-Ie for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:22 -0400 Received: by mail-pl1-x62a.google.com with SMTP id h12so6159007plf.4 for ; Mon, 14 Jun 2021 01:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UVKS3oIvQJqq/m46KHoZVGeIMZjC4WFobcwJ7uSJNW4=; b=haD5awAve1TkWeDf8PA/dXAj/yXjjrYaYGZ8fEWUbY0kXXQ14t/7xWqIzho3NYrzKd uKr6HZw/vO/3qTdiHmRLeN2R7REkMFoJRK1aP5k+yXZja+uXNqaCRby5fpKJKWZLn3YF EIDqBjFpily6qKlTH1MvfPkwLaL/Wmi7l32B/FWy+LVon8s2rDeVlrOyls08UudSI+JQ A+lryCwQgRqxDdHICVqgNJ6tDV/GD6I93y4jwQysuaHFhyjKiIlkp1OWLJXrvXA4zz1u kcrSAplooSI784kkMdWEq3MhZid+185Qo4i8qPrJjwSzXX3DsrG6Jgfv6CbEzBdlc5Ts 2/wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UVKS3oIvQJqq/m46KHoZVGeIMZjC4WFobcwJ7uSJNW4=; b=tODRNGyDcyB52BXAUSo/G5xzrRVe5+YSszB9C6zOQ8a17jiykMmGEVAaT4rEAB3XEj NgTBMzi2kYRWp3Xrtziv2erdKcWWVX7iencGyJ2Q9wOlHyCqO4F9qFtriMbqb1lfSl8+ VDpK3g0n+MI7nNwck0AME1Pnh/wBXgke4fNSTbv0ddxOGZjb2eHfeAOl2L+k5qvW/Iqf OJVH6LORYgmBJ9jUArlCJCDKcfyXo3CnoNgmo9P16QqAY6kWJXZnrT4llziBOjmXwuQI BfokhK6A7s4nb1/rGgXpEoKe5claA4ay4lj/EHwVlZA9OUPFdTi3aNTpamzYCETPKsPj WHNw== X-Gm-Message-State: AOAM532V3u33iO4rujMAG3h+oD6s9uoLJcSsLiGJN3Ebc099ow96YLqi tmdfcQ/BTLSmrn4//WSWDpxQBzI3pgWEfw== X-Received: by 2002:a17:90a:4503:: with SMTP id u3mr18213194pjg.210.1623659892384; Mon, 14 Jun 2021 01:38:12 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/28] tcg: Make use of bswap flags in tcg_gen_qemu_ld_* Date: Mon, 14 Jun 2021 01:37:50 -0700 Message-Id: <20210614083800.1166166-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can perform any required sign-extension via TCG_BSWAP_OS. Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 3763285bb0..702da7afb7 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); From patchwork Mon Jun 14 08:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459777 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3088097jae; Mon, 14 Jun 2021 01:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFGERW/7yKi2+QJZmtI2R2hpYh84HN8siquORr4IwJqObRrXMC1u3vIxHl1+CUusA/6JlQ X-Received: by 2002:a25:b70c:: with SMTP id t12mr24512870ybj.196.1623660590640; Mon, 14 Jun 2021 01:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660590; cv=none; d=google.com; s=arc-20160816; b=gOp5bbo0Yk/OXgJBnqJRZgLkBgnwa0sI/rnmpTUBAt3NT2VbCHvtlVY93hjPiNVRzs wxWi7cMF9Bjuo2hKCYtbiVV1LqKaPzumzbu6QxbkBUmcsVX8ga6ZoNGAsKAIfSi659VD l0QltTDowcTwfChkLMNhtyciJsmhJVL6xGHvDkPQ4t1yAjg6jgLzbOrPkafBYpueqIot 0bcuvINJ7q6f+LhZ+Y2AsCiaTSHNvUf41ZZsWtjlj600zrJLk/Lr1/c8Wngc5agTpeRh 9GgfQv4tfs91wJ5tiHijswn+wMOwQm2CF1aJxsIgHK1eiV2HmI9yO55yMRbzvx7+fCSa 4xIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=g2DFsQ9t433IY1mkuvqi2WafpHFJU1Gt4g42MrkG5qo=; b=rAYh6FXDJncrYeJ4wkAvhQYxlvi5UAN48bjofLSoCKj/5chQWG7Ip9S0pKA8PufOTs cmIAH4Z/6J3uZXJ8Vf2n41FUfPLv7BZX06UCzaRJdBQenc/+AYeaBoX2lscJdYL3K+MF kF0xbyXzgUDCuHk923txFE56Ae0QPtw+Gn+FyB5B/xmDLdkuHmAT+f8bkK3uSi4KDF6Q Nc+ZrHGFkKxvWJqqjKj4v3RfO/djKVoCvwFYKLzFBw/RKA2MA158AWUqw0QOx8ngaf3/ rBf2nkGTI2gtn8QqSvSdWirwqbJ4+aKdUebhegdHTffCUIhd4GfeVb/QEYx8o+TgCLEs Ie1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p4qNBABV; 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 x11si18694789ybi.445.2021.06.14.01.49.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:49:50 -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=p4qNBABV; 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]:41968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiI2-0006Vr-0t for patch@linaro.org; Mon, 14 Jun 2021 04:49:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6z-0002ZI-80 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:25 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:51776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6o-0003cI-Nr for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: by mail-pj1-x1030.google.com with SMTP id k5so9290007pjj.1 for ; Mon, 14 Jun 2021 01:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=g2DFsQ9t433IY1mkuvqi2WafpHFJU1Gt4g42MrkG5qo=; b=p4qNBABVLziCoaM19gFNyEfMX9hF9sPnK/Mh2pGjI80ZPA+zal2RKhId6J+rv0z5uR l3OAFyUbzQ7AyFOR5XfcCQu5BL/AHTJwjgyMiqpqUsb1IUgyGxlkDDN5fSOZ3GOASxdA OwROQcvqanK0q/1ikBahACu26T4IDA3tc6EdcKFIGcO4JVgNFpMSibIJpUwwOF977FT5 OEBDIIsWX3G8oEb61hGMIRtt20XAqyVoz2S3pW65yDjs+AfIXc4fkJjn1dFlCSrWuNo0 Fgcgo7MFQMKW6sIlda05x254o8IOIJXQgk82d4pf4dT9d3RvqO/id2JHpDs7TB+BqUa3 Wt1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g2DFsQ9t433IY1mkuvqi2WafpHFJU1Gt4g42MrkG5qo=; b=Km92Nz6PqAYCvzlST/lLwTgY3z0E14FHpvLHpWhhAF2fF4OORxuO8hV9jP4LFDuYUB 3pb0/sGmhw6vIS3/EtEmzOuea0iKQWExIfFIzwGGBVYVMdxJA1zZRwyMra/JVeN/4c4j 3BvRMaAxZ1q5HKWiJf0+7QMBNUCpy3NpJrfnJOtoz8guMeXXYstKWX+dxE+qfafVmkY5 z4e41CQf0NkPOInb6O+whO0RyTgINekt9qaiakQg9xgvdf6OOUrltWWZltyf/oSYpC3F 4MDUcM7I54s27LcAnXl5bwsSAlaBPieZeFbz8PD/bGBHZeYJJdpskch/Y6TITTratHwS 0lsQ== X-Gm-Message-State: AOAM533ueXG6QQ2P8JwP/i7kfNgte8iBBaa+IEoWqPk1f8miGw4uw/Ks uka42/APp/VWzYUdHGWeXbJd5rM37FIllA== X-Received: by 2002:a17:90b:18d:: with SMTP id t13mr22654673pjs.191.1623659892812; Mon, 14 Jun 2021 01:38:12 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 19/28] tcg: Make use of bswap flags in tcg_gen_qemu_st_* Date: Mon, 14 Jun 2021 01:37:51 -0700 Message-Id: <20210614083800.1166166-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" By removing TCG_BSWAP_IZ we indicate that the input is not zero-extended, and thus can remove an explicit extend. By removing TCG_BSWAP_OZ, we allow the implementation to leave high bits set, which will be ignored by the store. Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 702da7afb7..5dbcd1b0cf 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2915,8 +2915,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) swap = tcg_temp_new_i32(); switch (memop & MO_SIZE) { case MO_16: - tcg_gen_ext16u_i32(swap, val); - tcg_gen_bswap16_i32(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap16_i32(swap, val, 0); break; case MO_32: tcg_gen_bswap32_i32(swap, val); @@ -3013,12 +3012,10 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) swap = tcg_temp_new_i64(); switch (memop & MO_SIZE) { case MO_16: - tcg_gen_ext16u_i64(swap, val); - tcg_gen_bswap16_i64(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap16_i64(swap, val, 0); break; case MO_32: - tcg_gen_ext32u_i64(swap, val); - tcg_gen_bswap32_i64(swap, swap, TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap32_i64(swap, val, 0); break; case MO_64: tcg_gen_bswap64_i64(swap, val); From patchwork Mon Jun 14 08:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459784 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3090807jae; Mon, 14 Jun 2021 01:54:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCu+ulYqqIjTuWS8u7dO4BUlkCEMiNnk4EI6YbipP3tpnAInhto/0nTzZxu8Y9dV9n1Fx9 X-Received: by 2002:a05:6902:100e:: with SMTP id w14mr928871ybt.232.1623660851018; Mon, 14 Jun 2021 01:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660851; cv=none; d=google.com; s=arc-20160816; b=VGXW7DcSsod7Ac3bq5ERTtV6IPMO4gR3L7jhp5uuGIcTMhE1O2z+ud9qzo3NEM0n02 g4W0V67heSper4smQGfw3NHeyS9gmONgI/9VygMeXL97II/6fLa6JoA/s3fgS/Upbfrm J0jUqqfEawuSgON2yw+jVI14xmmkbcXVpb58EqofJbLOkhOAbYmHL60CnPi1IZ2FiWSe Ius9RLKf4WTTgYbur7BXEb95mBtBCqagHHSpxz3eRXzlnyrLL1KyPUdsYA2ARe1v6S7N 7oVX4nRvyBtbzsQNaituM+6yKGak8I2mBm5w1vbsRLUnAYIgDvxvHflqTty4lkK+ARSR ZoIQ== 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=u6MGt+Q30W0DPkO3zn0zAr3wVy2EgLq+Mej76ef0rEM=; b=m+uItqHXxPP1NBJjkLSumSa/EFa3BvpNPjVlEBO+0FYeNvv78O7blJy976AW3w26I5 knTzhHlmxFvF6NA9HpGuCj0grLaTp8KyKZCeRzNVlQyr3Wgj270pO/HKBLxKP6N+HbWd eTgGnBSHyKbEq9Al7kTovAbAOZ7QJ7ZXO3T6QdZUo1iVItufbc2tDtKck3upNmWZH1Vv UCe1Qyzwbi4gwAyW8lvjO8w3ea6XFhquRbKpXN1VJydPub7aX0tBjvMfTba5RiIC9Kog jSKM2p/RIU8nPATJ7MEqfLids+ng5R7lXdWTsrBoVAySqvZtVZzhn5Mc0vvJQgNlRtpG liug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SzYiMDuW; 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 t10si8926189ybc.431.2021.06.14.01.54.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:54:11 -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=SzYiMDuW; 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]:56748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiME-0007tK-FE for patch@linaro.org; Mon, 14 Jun 2021 04:54:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6y-0002XX-Oh for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:41780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6o-0003ct-OQ for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: by mail-pl1-x62c.google.com with SMTP id e1so6151794plh.8 for ; Mon, 14 Jun 2021 01:38:14 -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=u6MGt+Q30W0DPkO3zn0zAr3wVy2EgLq+Mej76ef0rEM=; b=SzYiMDuWQ9M/iRz/zbb54S69iYKXEYw9D1aFyKYxn9Y6uvsSYiPsAbh6fW2DyeZEFY EK8K/+BdU+eroAIrRwqPnufs/320D5jX0IfkE4MOP3dL/Cn6Jfsc7a5dRTOSNl9V4qjg oOy+QF2TSG8HtCvu5flahGjGBh4oXMQkCFqpG9rLwdD9kJ6B6DH8qDXoxUC05bKewj64 04fiFpzeqK5zDD1FL8gHvF2fGMjpG0Tmsff3MVhw7drwAeOAUdB5qvFe1HAoPkJN8okt u8QCF9m87nbb3X2DY3oC5c7cOqCuNEQwvgN2q691CN8TK8YkVa95AD8+bIvMa+lLHHNP ulQQ== 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=u6MGt+Q30W0DPkO3zn0zAr3wVy2EgLq+Mej76ef0rEM=; b=TaCEBSUASvhh95Lz92D7dFre+XAta6IBEpG88y+pMyIO8jCvubqwOgnD9VsX7CJYLx 66irBnxrLiC34WIGRy7W6Dm28iuFg5pl5M9kY2gQwqKNLvmHzz1f+rQ2oxx5j0TDaODd Jn0SHrpmfrT1ziFJUO2HKIjfes/KeK+3smJOjXvjbKa5CAv3R1IdCkCjgf8wPr8LE3h+ Fu77ys0EvuQKwXqTN2WCtoZTVwy6qJEKi/QBqld8JmcIQt38TSCjQPbr+0SRpyTjfTHU ZqrwY6J0yymtK8y1aPqZnWHRW1DiVdmmVxUMZI3EDleJ/lnglemgwVLmAVD1shsc18Ov RM7A== X-Gm-Message-State: AOAM532H6v1KtaRBZPn7ltXhUrtcUN9erjUqPZSOP5YHDGqrOcwxa8fN oqI3nGNouAMZDsTmxqE7GbZRJjMGqOElMQ== X-Received: by 2002:a17:902:c20d:b029:110:483c:b965 with SMTP id 13-20020a170902c20db0290110483cb965mr15756500pll.77.1623659893429; Mon, 14 Jun 2021 01:38:13 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 20/28] target/arm: Improve REV32 Date: Mon, 14 Jun 2021 01:37:52 -0700 Message-Id: <20210614083800.1166166-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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" For the sf version, we are performing two 32-bit bswaps in either half of the register. This is equivalent to performing one 64-bit bswap followed by a rotate. For the non-sf version, we can remove TCG_BSWAP_IZ and the preceding zero-extension. Cc: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e0785ce859..ea9d2d4647 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5430,22 +5430,13 @@ static void handle_rev32(DisasContext *s, unsigned int sf, unsigned int rn, unsigned int rd) { TCGv_i64 tcg_rd = cpu_reg(s, rd); + TCGv_i64 tcg_rn = cpu_reg(s, rn); if (sf) { - TCGv_i64 tcg_tmp = tcg_temp_new_i64(); - TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf); - - /* bswap32_i64 requires zero high word */ - tcg_gen_ext32u_i64(tcg_tmp, tcg_rn); - tcg_gen_bswap32_i64(tcg_rd, tcg_tmp, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - tcg_gen_shri_i64(tcg_tmp, tcg_rn, 32); - tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - tcg_gen_concat32_i64(tcg_rd, tcg_rd, tcg_tmp); - - tcg_temp_free_i64(tcg_tmp); + tcg_gen_bswap64_i64(tcg_rd, tcg_rn); + tcg_gen_rotri_i64(tcg_rd, tcg_rd, 32); } else { - tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rn)); - tcg_gen_bswap32_i64(tcg_rd, tcg_rd, TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap32_i64(tcg_rd, tcg_rn, TCG_BSWAP_OZ); } } From patchwork Mon Jun 14 08:37:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459789 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3096933jae; Mon, 14 Jun 2021 02:04:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXR3rCQpP5G4jcQwSjFIHRCHEO++YaGgcXuc4NelhtESiBaMjxD2XHq52iXl57V+1bhmbI X-Received: by 2002:a92:c14d:: with SMTP id b13mr13088818ilh.135.1623661440016; Mon, 14 Jun 2021 02:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623661440; cv=none; d=google.com; s=arc-20160816; b=VAiOaxBoDGl9Ek9hqXkCNnVrMX8Soe9e2DTaexIKRNRD++w3Qgy4KBeo9eQgqLwJsi TOY6d0u8srwnecdfybE+oh5xBKJtDkd+FAOhycIAPCls+CApIKq7QiLXF6u69g5zUXd5 fNcxX073/FW7J5eubU+128dNBJMDT7Gd8GZoM2xcvPdfPoa09mCiWzB5wXrjEGnvx+83 bAIT1ILRpzK/oWi4Bd0Qm6wmO59g0E6VDr2Pgb4naO6WoUE+EkErbePFAqCTy00137Om 3nwDFfoqF1oV195D57I1/Lm18tR3v2VyqRgNBQIqau5EjzSGHS9rS6ZFqKuQ2fXHUwNB Uaog== 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=0M95dsVn9R89EVHrqMHORQgU6sVSBYjtS/DenInu1AA=; b=NsaiioDcqA3WwRdF3J+GlmhdeGOSVYekU74Xb9iQCA00imf65CbbF1m3Z+zcQj+6tJ GjELrE4QG/vDNmzNcg6xrtXprJl1SgU3w4CDIgPRJK3po3+cndxdislTgcR1FRx+PQsT g8KycR60JL5FV4yVWiBgiispxs+Zm5wNDGbP3tRQcGdctOCXIa6xLzOlIGdogcSl/SNn tlnad+FeiZ8QwFP7EJp6e6eAxgdNjdJ4rJR/w0aanqduxFbjbgue1fo9NEfrgcRD1JZr i2zqqF8kyjFZ9f/a6p6Cfd9RAOhBtdgAIMfkP0vivYrvrIOIcqXRZVvRs78HuRLw9ot0 Z5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ABFC97Te; 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 y5si16080116jan.79.2021.06.14.02.03.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 02:04:00 -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=ABFC97Te; 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]:48104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiVj-0005EW-Dh for patch@linaro.org; Mon, 14 Jun 2021 05:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6y-0002XF-Ms for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:36355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6p-0003cx-Ai for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: by mail-pj1-x102b.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so4435554pjn.1 for ; Mon, 14 Jun 2021 01:38:14 -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=0M95dsVn9R89EVHrqMHORQgU6sVSBYjtS/DenInu1AA=; b=ABFC97TeYrSNLzDWhf9F4JZITwr7a0xO9nEMFujV6cGxJB6iPvvjxUkGkuvWa8CbLT yfMOZgiA7S2DFBa3hBudDkja/CopWUBHN4nU0uPAXmyz384let5+XHj/Z+ZjKu7Fu9Ze 1pPi/s5+iaMeywiNSF3A3dWHsP/AoOtECu1S07Doug78bb/udN5B4TACjZceYhbURYYE h7inVr+LT2kz31YsWDetZM4WGnnMbbAPi0KHS+yhqzdBMrNq9wicprSjGOEMRxnZ6C8y ByXZ4DqJf7Hjhq2KJJH2EEiD6Alcqa2DoWVXF+brfo1w/kakuM7kxDKTEORyu75yYwVo 0Vdg== 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=0M95dsVn9R89EVHrqMHORQgU6sVSBYjtS/DenInu1AA=; b=CUb/lqI0pMDnC1T+w8vL9RLQBjJaWEVQkNI1ESrbWoi8hzYOSfMDgD0OqAKdCFJFSi ZpFDmCn4fqp/Ij5YMo6saw8VNj/MzhraTaJceSxTZCTYpVjVHQXo1CoJnATNaIWwY1Az fBq5sStA17onL6e83mdmAzKG2n0NqZ6Hd5XCoV97rcOXQpEeSsaFUnAeq/I8lewvjsLE iGPgMGadsK7d5UvyyQLg9D/s/8jRy7dmBqfYVviBtGqBf2WfoIRM6ZZm1Rn0l/zVH7Iu BAHDN8ikR9h169mEA2PoinJ+a1O7LvJW10iLXHJcP22BnlH2jofYiKsXLAoS2dh4oVfb hjVQ== X-Gm-Message-State: AOAM531bce/3JLkJ2PzTFnoEo7Phyt3vWWVEkRS7b0QwqF0lUOmXntI3 sEWMzerGsg4aPK2xA7TulpISqB55jIvl5A== X-Received: by 2002:a17:90b:789:: with SMTP id l9mr21719415pjz.25.1623659894063; Mon, 14 Jun 2021 01:38:14 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 21/28] target/arm: Improve vector REV Date: Mon, 14 Jun 2021 01:37:53 -0700 Message-Id: <20210614083800.1166166-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: -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 eliminate the requirement for a zero-extended output, because the following store will ignore any garbage high bits. Cc: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ea9d2d4647..e12387e19c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -12427,12 +12427,10 @@ static void handle_rev(DisasContext *s, int opcode, bool u, read_vec_element(s, tcg_tmp, rn, i, grp_size); switch (grp_size) { case MO_16: - tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ); break; case MO_32: - tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ); break; case MO_64: tcg_gen_bswap64_i64(tcg_tmp, tcg_tmp); From patchwork Mon Jun 14 08:37:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459791 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3099929jae; Mon, 14 Jun 2021 02:08:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJZ8clbiTBwOZm47fI24DPHh8DspYb8sngOSiQ/TIZlC8N1aRJzZedhkFFmm7oWbH43rkp X-Received: by 2002:a05:6e02:cd1:: with SMTP id c17mr13291159ilj.210.1623661707562; Mon, 14 Jun 2021 02:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623661707; cv=none; d=google.com; s=arc-20160816; b=paRP8pCxkfLtzHM41qmAjMZSezgolUBWHhG+kJYZDXiCUrP2RuOgt7hik/ZhJlmbVZ WekMydvPrmFZhHMvYlie4gXu0aXftsanLXH4eSvw9XqqB3QgHPmuKyo+NSC+MdYbQqpX 1NwP33JhyT92C5qGxk4ASW9TU3fic20egL4jbtt71tS0ppKvGykeBx5ZWOikw5tSF157 3pU8R/s/6Gb2/XHfJ2+/qaAfH2esGfqwJzSeP+537cMkJ8CEMHE9RCBuIfzTtEATucTT 3Tc4S4JTT9DMpy/puRBNPeXNV+XFwhYM9y5vljbkt90wsS5bO4rQiIx8CTlS+vEGg8et kYYQ== 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=9pPwNgd+FhwESG7b/TarUMGEShi9vbglIUO+o/J97nY=; b=ZrX+0frZRZB3ZFAN49q+TaUvfcHmkiisyuRteZ5/rviqgei1zA54Gl2m/4jAVcQihZ pgkZy9MbOjRnEw/y4GXFKFQLzxmcT84Yh+vAYy2Fvu2CkE3qL73epqeSCvggbjCOucNu Q+WIjAhCHvQRHxJswZPharxmwoIs4M+7koGHVsXztHIavinOvLKgF50e6AKHGVdT7S3r OhORpa0LB/sJF/hCZxm041P2lh6MpfjSM4KHG397JxUHrfPHmb6NDdViR+pcVkFzjwI0 8I4hOQeAdTF0VXOvxcmRPgRuG+RYJO5455ijHE4mHHbpQm2K0PsufFZYoBTFMj3PtgWr CESQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RYWZ6ppt; 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 p19si16028897jal.78.2021.06.14.02.08.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 02:08:27 -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=RYWZ6ppt; 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]:34378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsia3-0006iy-1T for patch@linaro.org; Mon, 14 Jun 2021 05:08:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi70-0002er-Ox for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:26 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:54214) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6q-0003d3-Bm for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:26 -0400 Received: by mail-pj1-x1029.google.com with SMTP id ei4so9287141pjb.3 for ; Mon, 14 Jun 2021 01:38:15 -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=9pPwNgd+FhwESG7b/TarUMGEShi9vbglIUO+o/J97nY=; b=RYWZ6pptEGzMOaI53mfq7NTrcI2qI7z98tlgRCTqsZj6IWA49N+OLKfPoIiwTGHV8E GZMor8a5jP83+2oS9hDlFN/uc/MrsBFjOOLxhFiEaCxohNMpVi/hsW6c3v9yw1dOohbo CIo2sYSBqb6EvF94qck+5VLX/nyiZSlxNM+XqqoMqkISeh5hPfAeYveZHSX1cEd5Saof gf0FCA4JHk4IHC1lhjucFDTfjjI5G7sj5vbc6iYRpyDwVdbDRy+oifZnVaWDlz4wdaK2 /kOiDcHQ4FsrVNV4g5hJr6iyamOrHLeK0IiVKhmUqjicqHHib0YFyteilLsTjgGS+6ql Wqjw== 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=9pPwNgd+FhwESG7b/TarUMGEShi9vbglIUO+o/J97nY=; b=ZYoRrg3lRpIBoCxCwxYKrq+UwZM013c4/M48sh7RSOfU0euFKxiv8LKLfUgF+nXpEk vbDW8bl8XGYtwGHdASVDxhL4kKPxhrYbVUyia/P1FXV18htaw6QIZz/IjQKTrSlqqzYr G3DETUYaRfwLWVe3ukzYRvpX5Pu42lqaK3Yzohx4xDOiEgTB/RHSQSNx2rzglhdMH0r4 DwJjA6KVa11ERM5akQRiGCZb8kgihLdoJSQKfp6KUoIm3+b2JZIe+ffTUydSq+0zmfkF a/7U59MPMcOpkVwEuUNxAh/A7GAE+zAppFLqBhhcb0GmYAank35k3TAQLaRlTJLUsgF+ 4XZg== X-Gm-Message-State: AOAM530AsUw1DmlNEB+DESWsFXv/8LzfZldhZjv6TuBBTKTGM+a4GpJU /4gV7nAlDzBc1ynxVO6z1H3U71hGDHtZIg== X-Received: by 2002:a17:902:ceca:b029:112:b67b:fe4f with SMTP id d10-20020a170902cecab0290112b67bfe4fmr15773235plg.32.1623659894674; Mon, 14 Jun 2021 01:38:14 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 22/28] target/arm: Improve REVSH Date: Mon, 14 Jun 2021 01:37:54 -0700 Message-Id: <20210614083800.1166166-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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" The new bswap flags can implement the semantics exactly. Cc: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/target/arm/translate.c b/target/arm/translate.c index 6b88163e3a..46d95d75ae 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -341,9 +341,7 @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var) /* Byteswap low halfword and sign extend. */ static void gen_revsh(TCGv_i32 dest, TCGv_i32 var) { - tcg_gen_ext16u_i32(var, var); - tcg_gen_bswap16_i32(var, var, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - tcg_gen_ext16s_i32(dest, var); + tcg_gen_bswap16_i32(var, var, TCG_BSWAP_OS); } /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. From patchwork Mon Jun 14 08:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459773 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3085606jae; Mon, 14 Jun 2021 01:45:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu4mPGF+kZUY/qa86B4i6I8jBR8wpWPXDcbdW26NUAci3Sq49WqmdRd94ZcvGkdD1DNsCg X-Received: by 2002:a05:6638:1382:: with SMTP id w2mr15674350jad.36.1623660346604; Mon, 14 Jun 2021 01:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660346; cv=none; d=google.com; s=arc-20160816; b=BvzOJcg8jOzw0Wprp/88IAS/7VjfDPrYKKypg7vddCFJi8T1sYqrGfBrv0Gw/1y7ij MBkJAx4w/XBulSaQOW1JAp/WBx4jrANVI8afgUoHWUUlrEbnMKW/UxahXsqmpiOdEGH7 xgffsF6tx9AleQ2G1UXZmwdiBwG6vuWiR2v8RIJZmeMJS7nSRlert3UHaPZF3d/JhPJ5 7cgMv/AHa8pSgo6BnYjF9XxtyjkIru+QT9Q2fQjkFW1h7jjYCAAfWemgq7HAbP14+qEb dHVd4QEDqVCjKDII54xskYwSzPb9SA6RB0+m5YZgtbz+h7pejNFvS2m7UVe35f31pRml MZTQ== 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=/cj6AHfD4MCylW24pA885ZQ85JIZz19VyVMXS+bbqyw=; b=jovcJRPCGMRBOYjSGrZhbYr+B62Ig9rEx/YKhTxdA+3dPkQjzDTswMTZ0bqZY4FRsa D6tAKnJJkr2peuW3bhpv6xGqE4NZ7TAj6giaDh8tTeUP/WIkc65N9dREvZfYhn9UW92+ BvL9WdJL5L59dKQWHuqyzcEUQlxXOw2AypOkl2jD5ftMFsZx7AYi++zRDL/58RyuJ/Ga yMXteeM/UhBDo9Hz9Kbtj8ABM5uKINPnCwJMul66241311ee08GyxFGsMFFWP4WFNtDJ YJIJ9uVEPPDgv1IJ2vRzBedRD01EmpmMs28htzoMTOUzwIpWbPU7mWcyOnMosehgxBIX RO1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YTEBO+1A; 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 y5si16050934jan.79.2021.06.14.01.45.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:45:46 -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=YTEBO+1A; 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]:33306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiE6-0000fN-2S for patch@linaro.org; Mon, 14 Jun 2021 04:45:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6y-0002YD-Uz for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:44629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6r-0003dA-84 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:24 -0400 Received: by mail-pf1-x435.google.com with SMTP id u18so9998054pfk.11 for ; Mon, 14 Jun 2021 01:38:16 -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=/cj6AHfD4MCylW24pA885ZQ85JIZz19VyVMXS+bbqyw=; b=YTEBO+1AN83WnP1zP1vnjRN61xfVa6buJ6Rg0vRzWKGZ5swwkuw4NahIyD+AES8j2u 5okQJjbYcG6IfxMtN5vxu/yBWtQe4u09lFHjkRLJOnPtwm/no4/4DQZjCkr8NZCBaTnB IGcLPMsZmyXtgyf5XZk9WRDJmwLj8HSZnWwflS5G27ncYbXYt+nsg0KIY3twE6f1MyVg evNgr8BOy2TiSncAP2BuWqnAJ6OJg7kBwd9wDC+Eg0h6syqEP6bPa6ZfM+OTIQl4MfXE t0CNs7OMMl9uycPOol3WFxHkeG3WwYzns+7xBQEEcKnKDUoQzN9ZjqJqlbMvxainykro vnPw== 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=/cj6AHfD4MCylW24pA885ZQ85JIZz19VyVMXS+bbqyw=; b=dUAbg2V2VLi3h/uok5fVyi1RPFNmKHraORK/sHo7JBCMZtx7m4gwWnrM7z8x2ltXG6 d+KWj/8mGuyOASCpa295KOsz7wXWhFsOWr4KnqNGhwfrFdVd5zKUv3Y/NWE2HibhQWbL RrmZGWew5rd824bVU+L1w8d2xmtj9MLg2OWh32R3W2udZbyM9DW1FwC7ilYi9BfvuZmP NAn6SENRZ7k+uQWBHuvwZ99HNdrvbQ4iWU3RsfWEbAqRP0J8UEz1jmSPDhh96Oypttee QJt3glOXDtWfvTEpdY4BCALEuJDD4Im67fIfBv4f5u0/vgF9JyMaK0vzRWuh9HB8oH3k tNrw== X-Gm-Message-State: AOAM5300w9q5lqOx3T8FC1sTjW13FEj8HIc0YJGFy1ML/ajgV8EpRKYt Wr8bR3wuoFIMfbaGK3WnDcKsq/xM1LZxWA== X-Received: by 2002:a63:5645:: with SMTP id g5mr16064027pgm.442.1623659895300; Mon, 14 Jun 2021 01:38:15 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 23/28] target/i386: Improve bswap translation Date: Mon, 14 Jun 2021 01:37:55 -0700 Message-Id: <20210614083800.1166166-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: -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: Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a break instead of an ifdefed else. There's no need to move the values through s->T0. Remove TCG_BSWAP_IZ and the preceding zero-extension. Cc: Paolo Bonzini Cc: Eduardo Habkost Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index e8a9dcd21a..b21873ed23 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -7195,17 +7195,11 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) reg = (b & 7) | REX_B(s); #ifdef TARGET_X86_64 if (dflag == MO_64) { - gen_op_mov_v_reg(s, MO_64, s->T0, reg); - tcg_gen_bswap64_i64(s->T0, s->T0); - gen_op_mov_reg_v(s, MO_64, reg, s->T0); - } else -#endif - { - gen_op_mov_v_reg(s, MO_32, s->T0, reg); - tcg_gen_ext32u_tl(s->T0, s->T0); - tcg_gen_bswap32_tl(s->T0, s->T0, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - gen_op_mov_reg_v(s, MO_32, reg, s->T0); + tcg_gen_bswap64_i64(cpu_regs[reg], cpu_regs[reg]); + break; } +#endif + tcg_gen_bswap32_tl(cpu_regs[reg], cpu_regs[reg], TCG_BSWAP_OZ); break; case 0xd6: /* salc */ if (CODE64(s)) From patchwork Mon Jun 14 08:37:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459782 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3089941jae; Mon, 14 Jun 2021 01:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT/Nl3nQTQOO3um1D/6PLNoiZKWWZwsbGDvxegaNCvVf/EU+NfIgcPxqqsLZSWKJwfuE/D X-Received: by 2002:a25:770f:: with SMTP id s15mr12932833ybc.104.1623660773151; Mon, 14 Jun 2021 01:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660773; cv=none; d=google.com; s=arc-20160816; b=pg+Drda+iKSmUdXVpDXyUHGIZaO/KJ8XnHE2r58rNiZKwDZXvv/Ty+bLzmDOYpNfUB NzgM0TAzeOwBHf9UbqkKQmbKjrYPnxGTgdlpsB3qc5Q60yjQL5+VFikaBTseilzMPHuw 3lkImy/JZJj7ArZ561+hY/99hfRLVd7oNrEMXSlHOwjmvis+VmGb0Cw5h+N1ArW2kG4E XbJeFpfX31lcOdrfogZdvhyegbGWOIRYt9egrEHLe/Q5FePYkapbu/T+qzVPHL86I8Ni 339/sO9Kh84jYLT2Zx2BRLdmP6L4IMPu02AqBqS6SFVLqv9tiAypO9N/xV5FGOqFJQfo aclQ== 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=T7BJEd3GAshXT7gnjM3Wy8Serp0Ny2cG7uiwPGDYDAQ=; b=EgQCTOBrnrH8GHuEwqreWG62cZ7hA2LU2OuE2Ha8Lbr9zmaZt4PtSvdNVyTt/yw8li RE2BsYS4kd3HnmvINi3dh36ldlEgNVbyQb4eqg3pbitbFuP8TvUlAB77Xz0emqX+lvCa tLx23zewWbZ5ydwFhNDuCrl2wNw+0QVYEUCGFiQ/Ez0MLtfni7CIUWD0GkEZ5iA3mUnt pSd2Wh7YUnAVofccMD4ZQZlrHeMoDmS1aYYJiLQZ4cEyBtljtN3n5reVHdr1k9yOcIT5 qxk0w8hBTWj05/xfTetK6zDR4QYB+P4rb0GlzMTmBYEPq3N15jWwpLX4KlVAiAGcGypT XrjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gDQUzFhV; 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 72si12510930ybf.422.2021.06.14.01.52.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:52:53 -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=gDQUzFhV; 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]:50608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiKy-0003t9-G8 for patch@linaro.org; Mon, 14 Jun 2021 04:52:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6z-0002bx-UE for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:25 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:35335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6r-0003dF-8c for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:25 -0400 Received: by mail-pl1-x62f.google.com with SMTP id x19so6162041pln.2 for ; Mon, 14 Jun 2021 01:38:16 -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=T7BJEd3GAshXT7gnjM3Wy8Serp0Ny2cG7uiwPGDYDAQ=; b=gDQUzFhVCqTkO67z878SfPpWgFohfEH9yt9rHm+bXIE07OT3Fb/LhDdlPOxx4z3eqA GiXtLUYK3r6/bDpzchEHVJ+OY+SMXfw9P5Xh0nrnpvq8uMLnz1ZKC1lTl9PCPVDSu+HA 2HU2gY+Yt9cGIo38L/ECxS8UYFQLQD9sdkCdyaWRJbLs+gMLvOyugMQ6ISNg2yIshXVd Tgmg2vOfe1TibzvH6NnN9VxI2BuH7lrCu057TAww3Qpeu8/hnJ4FtiL4s3LYFRAHAEMQ UuOlkUPRiYBYJA8zbJUrxTAIV+QvezUA0R6OZJJfW1us9+JMFj9ZA4CtViqP11DK3MeI oBaA== 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=T7BJEd3GAshXT7gnjM3Wy8Serp0Ny2cG7uiwPGDYDAQ=; b=a82UxxKOkR+vvRG9f229uMz2U/+B747FK5svqO1OcEqRIFKU/XKzXvgHR8P6iPDxbS ZEw2iKNAKMLFDJgHBJAQ00HZOsv6vnvbotMlp/U3YrVXKd60lbulusd/nTQGs3/SpjMo vTYJOao/XDsTDMrd7rAsek6g8uInvRj2RQSPoyOsHF+tRi3ochhOOG2KteIjFuEp+fzC FyFxIIDezP8Xc2eAhbFO/bzrrLV2xAUoaMwu7AQdE/e1n9TOuhLwj5lecgaAawuXfOuE mK3DpsTEIxs7CIvH7JsU//lwuFIXOy/9CVoQDhKDsxCFhjfItSxTKbGlLZlU1yIdS3n9 8yNA== X-Gm-Message-State: AOAM532WFOPuH/TULZKuvNwUI8/bxOdgeVDFpdWBfO0cM57b82kjP1id 9bJcc50RR8kxAlS9H9a4Nu3IX1YGszgoVg== X-Received: by 2002:a17:90a:e654:: with SMTP id ep20mr17611003pjb.168.1623659895736; Mon, 14 Jun 2021 01:38:15 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 24/28] target/sh4: Improve swap.b translation Date: Mon, 14 Jun 2021 01:37:56 -0700 Message-Id: <20210614083800.1166166-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: Yoshinori Sato Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Remove TCG_BSWAP_IZ and the preceding zero-extension. Cc: Yoshinori Sato Signed-off-by: Richard Henderson --- target/sh4/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 147219759b..f45515952f 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -676,8 +676,7 @@ static void _decode_opc(DisasContext * ctx) case 0x6008: /* swap.b Rm,Rn */ { TCGv low = tcg_temp_new(); - tcg_gen_ext16u_i32(low, REG(B7_4)); - tcg_gen_bswap16_i32(low, low, TCG_BSWAP_IZ | TCG_BSWAP_OZ); + tcg_gen_bswap16_i32(low, REG(B7_4), 0); tcg_gen_deposit_i32(REG(B11_8), REG(B7_4), low, 0, 16); tcg_temp_free(low); } From patchwork Mon Jun 14 08:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459790 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3098474jae; Mon, 14 Jun 2021 02:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwthJIjvgmxSdBrcorZhVkTf2MQ6kIvhG37Lb8DSSqzbgd9foGQhuyUCw2udaG43O8zh5xq X-Received: by 2002:a05:6638:12cd:: with SMTP id v13mr15878525jas.104.1623661574111; Mon, 14 Jun 2021 02:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623661574; cv=none; d=google.com; s=arc-20160816; b=FEOm5yeQEvbzkr8SlXUeKMfKRg6mBHSmSbVnShknkY+KqT7jonvtmh/qinYj9LXw8z AsP/oKvkdzmJYTkzTbFGAVYy9qcoATanH6IRPsSOTHMYdLn0tFCev3gUWfoBeYQHdsKm ZzBbTAQzOkRUW2OQT5xbiLF3h+tk70Tfl7AO/6hXrKR3Qd0sDlhy5o6IklF6UmOCBf0E 3l08iBZ18CrZ0zJe7ukBopPwhtQ/hNnucZ4VZfpJOGsVpnp90BnGvEC6M9D0Cg2mxDyD wSbe3za0k+RP8oYqYVXgW1WzdLWxF+/PnUBBIhiAcnuK/XJ+Wz+A48G3+9jrjdRAcaR7 /jjQ== 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=TjMHnJXoUnjhGFE1iA2UhvGhUmi66dGkfV7HJSIAp70=; b=CKa/H2GXaglLul9/RYR6ZXgvTPxyTshs8qV5e6BAaTzzbAZIWDWMnVYD5jcg7CoQBS qhzazfQJ4A2EsifdsmA7Sg3bcBrKSrO/1bVbJy6k00kHh7RHFQlRbUu7/NL656JgbGkX QT5AIEFLAAhXVX01iEMWJ75L9zVGtKEgNjKPzPOddZay82D4wpNTCoB+kJSlqcsPVC3v i8q1uL3UWE6Y5l1r93PavkdoxkIKO+2VkFUFLlTbcmcMBQFIKGFQwODIIXyvThMrrKkW ysgdR5cQZ0f1/Tkvd49jphqFzewTDnRuuefToW7F9qR/xExDuD7KH3HtBmaJEyLGBsR1 H9PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yuFyrMFq; 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 h1si15827904ioq.17.2021.06.14.02.06.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 02:06:14 -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=yuFyrMFq; 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]:54238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiXt-000157-Hd for patch@linaro.org; Mon, 14 Jun 2021 05:06:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi70-0002cv-5C for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:26 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:38637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6s-0003dO-Bv for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:25 -0400 Received: by mail-pf1-x42d.google.com with SMTP id z26so10014636pfj.5 for ; Mon, 14 Jun 2021 01:38:17 -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=TjMHnJXoUnjhGFE1iA2UhvGhUmi66dGkfV7HJSIAp70=; b=yuFyrMFqG83oKNU44BBMjHzz5MtkKdKVejfaZK+VAYise1c7PiWJnImMwp3Irjui+u gtkUHvAdAws0hbUmoV1zUcyhDrPszZJ2N4gk8WOKPY3luw+Evjq7JvRZ3d6zl9ceR0LU DevtJu2nTKlYDz+2WITyv63dYvg+Ucsaw/inuO8VRwrBPDPBoJ58pm+unGX4qwNzBxL/ vROOrDjRVO4XjDl5JO5pJevb6Q5oqTnOC2JlqWY4WEqD3SJv9aXUb7+Ukr6zLXkSyiU/ fSzEqC6h+ePm5TmjPnHBPh3m6o6eRYBjl0uG68HXYPOm/PB9K1XvaWIvnlMXEVc0bTQT B+7Q== 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=TjMHnJXoUnjhGFE1iA2UhvGhUmi66dGkfV7HJSIAp70=; b=f4Ct/UYE8INlRduItMZFk8ByfImmKDI0bxOS7s8QfqtW1qBR6deDzWdKa6Abq42QDA 5c2nadHYVFhoVE6jJ2MPpszzCn4RFan9EzzwbgVCJf93zGtYJ8h0Z8OfOoswsiRUL2eW PaWVzYJO9zxRDNcsj8FQ4BocQmhJOfbGyykGkmx9vww2wJRcl0+RBLRaAeIbL2pKZ6DE G35atjfeBxAajfYacmNK1CWf65WXffAEmAPHfeBHbE/E/G9pum9ArtsraRsOu4+2pqgB Lj6/eBrEtDBJeDNVNM/dJ6aknU3ULmjgu4QIgNnn8ElwAk0LOLkBQBd6eVlyVyScyrkN gZlg== X-Gm-Message-State: AOAM532HiLBEbN75HIZv2097S/wB2pGpgznZUOwVPhcFGO5OppMUUoHZ 9CE0virAbRr7e8m+wTvc90krVbZHVFdQvw== X-Received: by 2002:a63:6284:: with SMTP id w126mr16056140pgb.284.1623659896329; Mon, 14 Jun 2021 01:38:16 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 25/28] target/mips: Fix gen_mxu_s32ldd_s32lddr Date: Mon, 14 Jun 2021 01:37:57 -0700 Message-Id: <20210614083800.1166166-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There were two bugs here: (1) the required endianness was not present in the MemOp, and (2) we were not providing a zero-extended input to the bswap as semantics required. The best fix is to fold the bswap into the memory operation, producing the desired result directly. Cc: Philippe Mathieu-Daudé Cc: Jiaxun Yang Signed-off-by: Richard Henderson --- target/mips/tcg/mxu_translate.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) -- 2.25.1 Acked-by: Philippe Mathieu-Daudé diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index c12cf78df7..f4356432c7 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -857,12 +857,8 @@ static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx) tcg_gen_ori_tl(t1, t1, 0xFFFFF000); } tcg_gen_add_tl(t1, t0, t1); - tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, MO_SL); + tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, MO_TESL ^ (sel * MO_BSWAP)); - if (sel == 1) { - /* S32LDDR */ - tcg_gen_bswap32_tl(t1, t1, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - } gen_store_mxu_gpr(t1, XRa); tcg_temp_free(t0); From patchwork Mon Jun 14 08:37:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459786 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3092052jae; Mon, 14 Jun 2021 01:56:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy8nf/MQCmEbYsirtHyPvcNB05qcprl55OgoLAVUdcXvln58oyTxSdZBE/9S4Rb+11/hnD X-Received: by 2002:a25:ba92:: with SMTP id s18mr24966971ybg.438.1623660983769; Mon, 14 Jun 2021 01:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660983; cv=none; d=google.com; s=arc-20160816; b=wCyVv2tjeuKzvCPmr0oIa5Xai8yIzebskvqheshPeKBQfvDzcKz3f9Y0KBd9o0+qrg KoLPQgFZhs+EEOr/2pkFLiqjcHVAqTi3ETN0XZiwyEfr0egd/2WHtjWbBKwpdZ0a2qSl q//3kZlZnC9eWkhT10sr33GOg46oknIjffDwYA1RIUkaopDZJRkmXpPbPi9u4/ma3/vb 3OYtk/d8P0wR6LLTKKNsfsubYTdakgTBOIgxPHS0GXW+4ajcNRb+WRx/o4CKL31KnN9L 4PtRVw5y59b8xRqWPX2MIK9CXMXQ6bNq5Ohl9mJSHop9moSIiDKmFw0sE7BujUwWHxzy 8/PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=7/2JikIbqrctKsBzlUf7eFp9owHQMZjeoHnQlm4T8zE=; b=PBK3AeMc93sX62D7S2ihLK/fJdq77+5FgfkBCAJOXyZze/IMkPhGSbz2RRAHIRQ1tp pH6CnQwELz+2wRv+X/bHKYyNwmzjpgc6mCzr8hP/pXCHa/2aUuta3uxkb8qXlEeXzl+J dTKsTQI+9bWB62BzNCi6D2neZOc+pbkMvMQTqZD/8E1CqYbKj3VyjcksUyGJqPkmjc3v 78efBv9KZzw6b9eo4nMCuDx+xyoyjr2+KquNw16LQp5WKnMURdFP47pswhW14Gp0F1+s hiKuqlh8oQv1qMus7hnstAB/CdN8NA3fOuRQO8dhZ1i9nvfKug5sW7OASriZBwc1yg+b U9gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TElHqeJr; 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 x11si18713119ybi.445.2021.06.14.01.56.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:56:23 -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=TElHqeJr; 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]:60636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiON-00023S-5g for patch@linaro.org; Mon, 14 Jun 2021 04:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi74-0002qZ-LP for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:30 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:37586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6s-0003e3-CA for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:30 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so9605451pjs.2 for ; Mon, 14 Jun 2021 01:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7/2JikIbqrctKsBzlUf7eFp9owHQMZjeoHnQlm4T8zE=; b=TElHqeJr4n1Mh3ddq+vc/zfAX6nCi/4KTXWpxPinlr3JIgldVwB3Z8+kSGVFgs7Ho7 ZGUTiIAy/gWUf3MjRmCR6mudRfTuPppmvhO8iC46v5oxBKRqTPhqc5ynXEOGf+AOfzWd UZfhOhYDgbRow+ahGrfZ9fK2YsNAq5QUs6icW7a6HQ6m7hWWGE4Tw6/Ow9lfQN+F+Dlj 8snZzETrGPBLGzE2XjyNl3/4UCesrq2Ot+vL2xZUTcWPw59Mfk0acr2ZvarWO0clOzdG ZFoUzWBeH1qAjZAluCinyurQks9a9SS8fNhoy4J3DJCYGoVxz0h1swmKLwTMUbhIDPp/ HjWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7/2JikIbqrctKsBzlUf7eFp9owHQMZjeoHnQlm4T8zE=; b=LcxMjIRXjG4AA4QsTG3d51i/m5/O5cp8hs5i31Z7MjzPWixYzhmQ/hVG5Z76fVYyWn wmmrXzgivlc2iyy5ek9pqtVgFUqE+KBgjzPcMAkrG1juBn4KilsFgjr0i8tu6yz5O5tE a2/kBbeJcjvpSJmcbPwQPqa2wNU4NGOQeWprjHxFNGmdg8Q5sM8NjtvbXwTp8fsglUXF kw+/QZTtnW305pswItUthTgb3gdH/iqwu9ZFfLkYrYE4cSV1hvhvi0rByPjanER9ZcqP svKg5OBgkavSX5SPxn3nNEeBBCtdwpW/kjRKI9kl/tXI5hzkU1w2hEmUsYP1eBPe8isc uWRw== X-Gm-Message-State: AOAM533qGW/F+TdJGmiW6leg4xqBVpv6+KeBbQQaLS6+pAINvH2l2LlC 9Kh6AgYID7kC+3DFbG/sL2Zzp9Hdc4LxQg== X-Received: by 2002:a17:90a:7bc3:: with SMTP id d3mr12105068pjl.212.1623659896932; Mon, 14 Jun 2021 01:38:16 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 26/28] tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP Date: Mon, 14 Jun 2021 01:37:58 -0700 Message-Id: <20210614083800.1166166-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that the middle-end can replicate the same tricks as tcg/arm used for optimizing bswap for signed loads and for stores, do not pretend to have these memory ops in the backend. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 214 ++++++++++++++------------------------- 2 files changed, 77 insertions(+), 139 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 57fd0c0c74..95fcef33bc 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -174,7 +174,7 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_cmpsel_vec 0 #define TCG_TARGET_DEFAULT_MO (0) -#define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_HAS_MEMORY_BSWAP 0 /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 9824e215be..35753c9e46 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1366,34 +1366,38 @@ static void tcg_out_vldst(TCGContext *s, ARMInsn insn, /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ -static void * const qemu_ld_helpers[16] = { +static void * const qemu_ld_helpers[8] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, - - [MO_LEUW] = helper_le_lduw_mmu, - [MO_LEUL] = helper_le_ldul_mmu, - [MO_LEQ] = helper_le_ldq_mmu, - [MO_LESW] = helper_le_ldsw_mmu, - [MO_LESL] = helper_le_ldul_mmu, - - [MO_BEUW] = helper_be_lduw_mmu, - [MO_BEUL] = helper_be_ldul_mmu, - [MO_BEQ] = helper_be_ldq_mmu, - [MO_BESW] = helper_be_ldsw_mmu, - [MO_BESL] = helper_be_ldul_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_UW] = helper_be_lduw_mmu, + [MO_UL] = helper_be_ldul_mmu, + [MO_Q] = helper_be_ldq_mmu, + [MO_SW] = helper_be_ldsw_mmu, + [MO_SL] = helper_be_ldul_mmu, +#else + [MO_UW] = helper_le_lduw_mmu, + [MO_UL] = helper_le_ldul_mmu, + [MO_Q] = helper_le_ldq_mmu, + [MO_SW] = helper_le_ldsw_mmu, + [MO_SL] = helper_le_ldul_mmu, +#endif }; /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, int mmu_idx, uintptr_t ra) */ -static void * const qemu_st_helpers[16] = { - [MO_UB] = helper_ret_stb_mmu, - [MO_LEUW] = helper_le_stw_mmu, - [MO_LEUL] = helper_le_stl_mmu, - [MO_LEQ] = helper_le_stq_mmu, - [MO_BEUW] = helper_be_stw_mmu, - [MO_BEUL] = helper_be_stl_mmu, - [MO_BEQ] = helper_be_stq_mmu, +static void * const qemu_st_helpers[4] = { + [MO_8] = helper_ret_stb_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_16] = helper_be_stw_mmu, + [MO_32] = helper_be_stl_mmu, + [MO_64] = helper_be_stq_mmu, +#else + [MO_16] = helper_le_stw_mmu, + [MO_32] = helper_le_stl_mmu, + [MO_64] = helper_le_stq_mmu, +#endif }; /* Helper routines for marshalling helper function arguments into @@ -1598,9 +1602,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) icache usage. For pre-armv6, use the signed helpers since we do not have a single insn sign-extend. */ if (use_armv6_instructions) { - func = qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]; + func = qemu_ld_helpers[opc & MO_SIZE]; } else { - func = qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]; + func = qemu_ld_helpers[opc & MO_SSIZE]; if (opc & MO_SIGN) { opc = MO_UL; } @@ -1678,7 +1682,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) argreg = tcg_out_arg_reg32(s, argreg, TCG_REG_R14); /* Tail-call to the helper, which will return to the fast path. */ - tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & MO_SIZE]); return true; } #endif /* SOFTMMU */ @@ -1687,7 +1691,8 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addend) { - MemOp bswap = opc & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SSIZE) { case MO_UB: @@ -1698,51 +1703,30 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, break; case MO_UW: tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend); - if (bswap) { - tcg_out_bswap16(s, COND_AL, datalo, datalo, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); - } break; case MO_SW: - if (bswap) { - tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend); - tcg_out_bswap16(s, COND_AL, datalo, datalo, - TCG_BSWAP_IZ | TCG_BSWAP_OS); - } else { - tcg_out_ld16s_r(s, COND_AL, datalo, addrlo, addend); - } + tcg_out_ld16s_r(s, COND_AL, datalo, addrlo, addend); break; case MO_UL: - default: tcg_out_ld32_r(s, COND_AL, datalo, addrlo, addend); - if (bswap) { - tcg_out_bswap32(s, COND_AL, datalo, datalo); - } break; case MO_Q: - { - TCGReg dl = (bswap ? datahi : datalo); - TCGReg dh = (bswap ? datalo : datahi); - - /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions - && (dl & 1) == 0 && dh == dl + 1) { - tcg_out_ldrd_r(s, COND_AL, dl, addrlo, addend); - } else if (dl != addend) { - tcg_out_ld32_rwb(s, COND_AL, dl, addend, addrlo); - tcg_out_ld32_12(s, COND_AL, dh, addend, 4); - } else { - tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_TMP, - addend, addrlo, SHIFT_IMM_LSL(0)); - tcg_out_ld32_12(s, COND_AL, dl, TCG_REG_TMP, 0); - tcg_out_ld32_12(s, COND_AL, dh, TCG_REG_TMP, 4); - } - if (bswap) { - tcg_out_bswap32(s, COND_AL, dl, dl); - tcg_out_bswap32(s, COND_AL, dh, dh); - } + /* Avoid ldrd for user-only emulation, to handle unaligned. */ + if (USING_SOFTMMU && use_armv6_instructions + && (datalo & 1) == 0 && datahi == datalo + 1) { + tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); + } else if (datalo != addend) { + tcg_out_ld32_rwb(s, COND_AL, datalo, addend, addrlo); + tcg_out_ld32_12(s, COND_AL, datahi, addend, 4); + } else { + tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_TMP, + addend, addrlo, SHIFT_IMM_LSL(0)); + tcg_out_ld32_12(s, COND_AL, datalo, TCG_REG_TMP, 0); + tcg_out_ld32_12(s, COND_AL, datahi, TCG_REG_TMP, 4); } break; + default: + g_assert_not_reached(); } } @@ -1750,7 +1734,8 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, TCGReg datahi, TCGReg addrlo) { - MemOp bswap = opc & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SSIZE) { case MO_UB: @@ -1761,49 +1746,28 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, break; case MO_UW: tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0); - if (bswap) { - tcg_out_bswap16(s, COND_AL, datalo, datalo, - TCG_BSWAP_IZ | TCG_BSWAP_OZ); - } break; case MO_SW: - if (bswap) { - tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0); - tcg_out_bswap16(s, COND_AL, datalo, datalo, - TCG_BSWAP_IZ | TCG_BSWAP_OS); - } else { - tcg_out_ld16s_8(s, COND_AL, datalo, addrlo, 0); - } + tcg_out_ld16s_8(s, COND_AL, datalo, addrlo, 0); break; case MO_UL: - default: tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); - if (bswap) { - tcg_out_bswap32(s, COND_AL, datalo, datalo); - } break; case MO_Q: - { - TCGReg dl = (bswap ? datahi : datalo); - TCGReg dh = (bswap ? datalo : datahi); - - /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions - && (dl & 1) == 0 && dh == dl + 1) { - tcg_out_ldrd_8(s, COND_AL, dl, addrlo, 0); - } else if (dl == addrlo) { - tcg_out_ld32_12(s, COND_AL, dh, addrlo, bswap ? 0 : 4); - tcg_out_ld32_12(s, COND_AL, dl, addrlo, bswap ? 4 : 0); - } else { - tcg_out_ld32_12(s, COND_AL, dl, addrlo, bswap ? 4 : 0); - tcg_out_ld32_12(s, COND_AL, dh, addrlo, bswap ? 0 : 4); - } - if (bswap) { - tcg_out_bswap32(s, COND_AL, dl, dl); - tcg_out_bswap32(s, COND_AL, dh, dh); - } + /* Avoid ldrd for user-only emulation, to handle unaligned. */ + if (USING_SOFTMMU && use_armv6_instructions + && (datalo & 1) == 0 && datahi == datalo + 1) { + tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); + } else if (datalo == addrlo) { + tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4); + tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); + } else { + tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); + tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4); } break; + default: + g_assert_not_reached(); } } @@ -1852,44 +1816,31 @@ static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, MemOp opc, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addend) { - MemOp bswap = opc & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SIZE) { case MO_8: tcg_out_st8_r(s, cond, datalo, addrlo, addend); break; case MO_16: - if (bswap) { - tcg_out_bswap16(s, cond, TCG_REG_R0, datalo, 0); - tcg_out_st16_r(s, cond, TCG_REG_R0, addrlo, addend); - } else { - tcg_out_st16_r(s, cond, datalo, addrlo, addend); - } + tcg_out_st16_r(s, cond, datalo, addrlo, addend); break; case MO_32: - default: - if (bswap) { - tcg_out_bswap32(s, cond, TCG_REG_R0, datalo); - tcg_out_st32_r(s, cond, TCG_REG_R0, addrlo, addend); - } else { - tcg_out_st32_r(s, cond, datalo, addrlo, addend); - } + tcg_out_st32_r(s, cond, datalo, addrlo, addend); break; case MO_64: /* Avoid strd for user-only emulation, to handle unaligned. */ - if (bswap) { - tcg_out_bswap32(s, cond, TCG_REG_R0, datahi); - tcg_out_st32_rwb(s, cond, TCG_REG_R0, addend, addrlo); - tcg_out_bswap32(s, cond, TCG_REG_R0, datalo); - tcg_out_st32_12(s, cond, TCG_REG_R0, addend, 4); - } else if (USING_SOFTMMU && use_armv6_instructions - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (USING_SOFTMMU && use_armv6_instructions + && (datalo & 1) == 0 && datahi == datalo + 1) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); } else { tcg_out_st32_rwb(s, cond, datalo, addend, addrlo); tcg_out_st32_12(s, cond, datahi, addend, 4); } break; + default: + g_assert_not_reached(); } } @@ -1897,44 +1848,31 @@ static inline void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, TCGReg datahi, TCGReg addrlo) { - MemOp bswap = opc & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SIZE) { case MO_8: tcg_out_st8_12(s, COND_AL, datalo, addrlo, 0); break; case MO_16: - if (bswap) { - tcg_out_bswap16(s, COND_AL, TCG_REG_R0, datalo, 0); - tcg_out_st16_8(s, COND_AL, TCG_REG_R0, addrlo, 0); - } else { - tcg_out_st16_8(s, COND_AL, datalo, addrlo, 0); - } + tcg_out_st16_8(s, COND_AL, datalo, addrlo, 0); break; case MO_32: - default: - if (bswap) { - tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datalo); - tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 0); - } else { - tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); - } + tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); break; case MO_64: /* Avoid strd for user-only emulation, to handle unaligned. */ - if (bswap) { - tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datahi); - tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 0); - tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datalo); - tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 4); - } else if (USING_SOFTMMU && use_armv6_instructions - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (USING_SOFTMMU && use_armv6_instructions + && (datalo & 1) == 0 && datahi == datalo + 1) { tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); } else { tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); tcg_out_st32_12(s, COND_AL, datahi, addrlo, 4); } break; + default: + g_assert_not_reached(); } } From patchwork Mon Jun 14 08:37:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459781 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3089813jae; Mon, 14 Jun 2021 01:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEwFCZjwSjSIOkzBWHzkZBxZM5F/UetCyDJDhebK9VwOZGtYZyN4/WC6/XvcvsfoNofRo/ X-Received: by 2002:a25:bb08:: with SMTP id z8mr24027596ybg.188.1623660760882; Mon, 14 Jun 2021 01:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660760; cv=none; d=google.com; s=arc-20160816; b=v0xU2SbR7Agm5h2AO2AAUybCqlnwLIfRZShnmmHCSpZDVDZ0S5N88r1bhrolJmS3GX 53Iy945EvZWyfhidJ1HQy7U2dt6NLaDKRwwTke8Xa8CQ4WgWe4yPO8u7aIPtxKteP+jm +/GrVD1HmI4Pi2tdPVL+0Au1/I8OgcnXEfEURw+WDxPO+o92wjICJb+HU18YwnIreN0y Gn3beVBDjOuJwzPQ17QdUfU1AjG5c6T29wD3Oe8RKHJUGyHXVbqbS09y0cGO0IQSekfn M2uDkfm68O3LvelDntyLwi3hPzUo30pjzbJJdcyiAS/sM/io5FfEgRtwYlWSVK8l02EY 7o4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=yJFKTLwdQ6BKW9i364z8Kx1sZ3PNnLVCKyVccYD/P/o=; b=rt3sEfHoPa7FyPEgKel5y2Snl4W3kqK8YiSWNsBx1GHPJYohSorehZjRnkzLdsZgsU cJwkNOd2oZPqG8bEUyy7hse8g/bXY2IzgVmxdhxcpUOJxSNH6X4Vsprxz4Ji+t2vgRrY DY6yF6m2hs59ykC5yMhsWU8U3fZ9skDHKoQYegQQqt+7g56ng9Juu/9pvYmXGT4K9INJ DoHiFs0/pNvAiQrOqzDCrITMBUcXRZLc51kmvOgORNLw2+xitBxolqTbl/CD6GYyUmsS uVGiMlgkEsuaAtj8NBJD1AtEQvTfBj99Et/zizpgU9xm6vDGzXWvWH0JSUhSXGhPzYnx gZug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3DO8LE6; 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 l185si16224962ybc.261.2021.06.14.01.52.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:52:40 -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=d3DO8LE6; 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]:51894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiKm-0004iR-7j for patch@linaro.org; Mon, 14 Jun 2021 04:52:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi71-0002gG-8P for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:27 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:34409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6t-0003e6-5m for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:26 -0400 Received: by mail-pf1-x42f.google.com with SMTP id g6so10025050pfq.1 for ; Mon, 14 Jun 2021 01:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yJFKTLwdQ6BKW9i364z8Kx1sZ3PNnLVCKyVccYD/P/o=; b=d3DO8LE6gNUKHbMYSpYa/FNmgIK7nQMVZtfl8bMj4De/jAoW7t0k6voDr21+5+CW9W Yl1jdVqfXoP7O8Sl7k+r/eGORBJ6f5Wlfo6rJUl0RXprTfnrIPYf2tBs7vwR16TORzyG EuuXGQ+mzo2vWbjVox9wPUP9x1sdukWl39W+HMxqw/v4sAtHxVIQwiwQ5yarWMAJAnBA xOPi4qParp1JGIVpQmVUuhmmqqwuakhrrFhvnG9UN7oiFFE4RWflyhfU0Kc5Q03afs5A aQJUSziL3Ax/3DEsr8WIYDcs00XXak9sPFhJWD5Q0C8p6gq31gxUDj1p7uVt2r1WyP6x T8wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yJFKTLwdQ6BKW9i364z8Kx1sZ3PNnLVCKyVccYD/P/o=; b=lg6BDEGtaMsePPv6hhRA1OuL5zHkoYafhi9xu7r0ZXRrLDpe3t4W/bXDL3M7gn6b3o 5PmQE6+uiykoMLAKmLIArkX1TD9RCjXBGvor722YyxDtiUJIgqMrWgpl9XEJnXICJxCl 53MvBXqq3R+8JYuSdWT20687FySSwaU9WAHDTBc+v1TLce7wj7f5671MxHObLHJmu8+x JwhfDq0/lDnKrwpqFAkARJfcyyBxNekKhx0w52Ksie1QqNNYVlzl+TbZHkYnaAa95Uil vMRx/JcTH6kaTNwgFStgr+zWYn1CatOLX428BmOSuF5QNuOK0vvSxeIZS3mMxygvvOZK vVVA== X-Gm-Message-State: AOAM531paQERZxQGgh/wtmfxTvXFK+KuDoaR0u4hJUyi+PkJ2X8PSwXk iv5dTaik9ciGL5jpVwQCoRcotGSa5vKnZw== X-Received: by 2002:a63:1163:: with SMTP id 35mr16335660pgr.400.1623659897527; Mon, 14 Jun 2021 01:38:17 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 27/28] tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP Date: Mon, 14 Jun 2021 01:37:59 -0700 Message-Id: <20210614083800.1166166-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The memory bswap support in the aarch64 backend merely dates from a time when it was required. There is nothing special about the backend support that could not have been provided by the middle-end even prior to the introduction of the bswap flags. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.c.inc | 87 +++++++++++++----------------------- 2 files changed, 32 insertions(+), 57 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index ef55f7c185..551baf8da3 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -148,7 +148,7 @@ typedef enum { #define TCG_TARGET_HAS_cmpsel_vec 0 #define TCG_TARGET_DEFAULT_MO (0) -#define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_HAS_MEMORY_BSWAP 0 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index f72218b036..55eb98d0b1 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1557,28 +1557,34 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * TCGMemOpIdx oi, uintptr_t ra) */ -static void * const qemu_ld_helpers[16] = { - [MO_UB] = helper_ret_ldub_mmu, - [MO_LEUW] = helper_le_lduw_mmu, - [MO_LEUL] = helper_le_ldul_mmu, - [MO_LEQ] = helper_le_ldq_mmu, - [MO_BEUW] = helper_be_lduw_mmu, - [MO_BEUL] = helper_be_ldul_mmu, - [MO_BEQ] = helper_be_ldq_mmu, +static void * const qemu_ld_helpers[4] = { + [MO_8] = helper_ret_ldub_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_16] = helper_be_lduw_mmu, + [MO_32] = helper_be_ldul_mmu, + [MO_64] = helper_be_ldq_mmu, +#else + [MO_16] = helper_le_lduw_mmu, + [MO_32] = helper_le_ldul_mmu, + [MO_64] = helper_le_ldq_mmu, +#endif }; /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, TCGMemOpIdx oi, * uintptr_t ra) */ -static void * const qemu_st_helpers[16] = { - [MO_UB] = helper_ret_stb_mmu, - [MO_LEUW] = helper_le_stw_mmu, - [MO_LEUL] = helper_le_stl_mmu, - [MO_LEQ] = helper_le_stq_mmu, - [MO_BEUW] = helper_be_stw_mmu, - [MO_BEUL] = helper_be_stl_mmu, - [MO_BEQ] = helper_be_stq_mmu, +static void * const qemu_st_helpers[4] = { + [MO_8] = helper_ret_stb_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_16] = helper_be_stw_mmu, + [MO_32] = helper_be_stl_mmu, + [MO_64] = helper_be_stq_mmu, +#else + [MO_16] = helper_le_stw_mmu, + [MO_32] = helper_le_stl_mmu, + [MO_64] = helper_le_stq_mmu, +#endif }; static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) @@ -1602,7 +1608,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, oi); tcg_out_adr(s, TCG_REG_X3, lb->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); if (opc & MO_SIGN) { tcg_out_sxt(s, lb->type, size, lb->datalo_reg, TCG_REG_X0); } else { @@ -1628,7 +1634,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_mov(s, size == MO_64, TCG_REG_X2, lb->datalo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, oi); tcg_out_adr(s, TCG_REG_X4, lb->raddr); - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); tcg_out_goto(s, lb->raddr); return true; } @@ -1724,7 +1730,8 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, TCGReg data_r, TCGReg addr_r, TCGType otype, TCGReg off_r) { - const MemOp bswap = memop & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((memop & MO_BSWAP) == 0); switch (memop & MO_SSIZE) { case MO_UB: @@ -1736,40 +1743,19 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, break; case MO_UW: tcg_out_ldst_r(s, I3312_LDRH, data_r, addr_r, otype, off_r); - if (bswap) { - tcg_out_rev16(s, data_r, data_r); - } break; case MO_SW: - if (bswap) { - tcg_out_ldst_r(s, I3312_LDRH, data_r, addr_r, otype, off_r); - tcg_out_rev16(s, data_r, data_r); - tcg_out_sxt(s, ext, MO_16, data_r, data_r); - } else { - tcg_out_ldst_r(s, (ext ? I3312_LDRSHX : I3312_LDRSHW), - data_r, addr_r, otype, off_r); - } + tcg_out_ldst_r(s, (ext ? I3312_LDRSHX : I3312_LDRSHW), + data_r, addr_r, otype, off_r); break; case MO_UL: tcg_out_ldst_r(s, I3312_LDRW, data_r, addr_r, otype, off_r); - if (bswap) { - tcg_out_rev32(s, data_r, data_r); - } break; case MO_SL: - if (bswap) { - tcg_out_ldst_r(s, I3312_LDRW, data_r, addr_r, otype, off_r); - tcg_out_rev32(s, data_r, data_r); - tcg_out_sxt(s, TCG_TYPE_I64, MO_32, data_r, data_r); - } else { - tcg_out_ldst_r(s, I3312_LDRSWX, data_r, addr_r, otype, off_r); - } + tcg_out_ldst_r(s, I3312_LDRSWX, data_r, addr_r, otype, off_r); break; case MO_Q: tcg_out_ldst_r(s, I3312_LDRX, data_r, addr_r, otype, off_r); - if (bswap) { - tcg_out_rev64(s, data_r, data_r); - } break; default: tcg_abort(); @@ -1780,31 +1766,20 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop, TCGReg data_r, TCGReg addr_r, TCGType otype, TCGReg off_r) { - const MemOp bswap = memop & MO_BSWAP; + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((memop & MO_BSWAP) == 0); switch (memop & MO_SIZE) { case MO_8: tcg_out_ldst_r(s, I3312_STRB, data_r, addr_r, otype, off_r); break; case MO_16: - if (bswap && data_r != TCG_REG_XZR) { - tcg_out_rev16(s, TCG_REG_TMP, data_r); - data_r = TCG_REG_TMP; - } tcg_out_ldst_r(s, I3312_STRH, data_r, addr_r, otype, off_r); break; case MO_32: - if (bswap && data_r != TCG_REG_XZR) { - tcg_out_rev32(s, TCG_REG_TMP, data_r); - data_r = TCG_REG_TMP; - } tcg_out_ldst_r(s, I3312_STRW, data_r, addr_r, otype, off_r); break; case MO_64: - if (bswap && data_r != TCG_REG_XZR) { - tcg_out_rev64(s, TCG_REG_TMP, data_r); - data_r = TCG_REG_TMP; - } tcg_out_ldst_r(s, I3312_STRX, data_r, addr_r, otype, off_r); break; default: From patchwork Mon Jun 14 08:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 459785 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3091392jae; Mon, 14 Jun 2021 01:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQrmtUEdjRkWBdHZrTafh9PRbx6CZ3tIOYgwoxLz4mPmN/HU7dBaj+CUO9EH/pfHPKM1kO X-Received: by 2002:a25:354:: with SMTP id 81mr22984406ybd.134.1623660907124; Mon, 14 Jun 2021 01:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660907; cv=none; d=google.com; s=arc-20160816; b=ELnGbyKZQO8BSVcKp8Lt/caVMGYSjx+cMDraoWRmnkulwhEO0lNSKGzM55NnEBc4gq lXrPQq7cKdN3fdclTLgGY6i6a6lexj+h2hnn0m8lFnPeMN5fYy5iA/FqFxLNcaVaFh7b cKINbwzgjQRyU5m4GuvZWWqPSLizikzRhMONHHJLHPg5W9h1pUP6bFZo1vXiVRbWOzoJ UR+wu5KgqDPBUI0sqd4VkXArmUG2FspwH+EKEkelgOUs7uIRqRdFi5zBhY8kqWhNzIuh qvhBNqOzh1Rx0QT2ukvMAMQyPRSlBfsHOB/ujXkRnRUoa+lK7VpfyiD0UJ64tD+EvPIU 19ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=ujtnjSEKjc/8E8rHyRJKp/40jerX6TctpTGbnCUlGKA=; b=sjBHEPXW+XSiQUlUbDsU2GdW+Svka9ycRE6KD2YslW99DZ3B/hjhTGJzwS9CnshhFm 0IwX6+SDFp3F07ptn1//DTUMPcjHPV0HetHQMa3G4gkQfb7wZgIW4sfm5XkBFtulovp8 BDhdk6Wt329pKOZO1L6jdckaybFMc1lB9/HnKImh7WP2pAT7WR4+Qc56i5lelw6Nd15Q b45fTMfm1YoBxABa9VwlXzwEgGdLxmJ8qTZ35vLB1LXoj4Aep6JYPAyGa8xwhWKE39iD +ozd6AaweaPeSZ1IBQCFsnq2wCTdUZ9IwVyMVNce3z9kkZb1Vf3L0EEq7w8L6pdTxSDh RcbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zc3MQSgb; 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 p131si13925543ybc.217.2021.06.14.01.55.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jun 2021 01:55:07 -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=zc3MQSgb; 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]:59028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiN8-0000yr-Ge for patch@linaro.org; Mon, 14 Jun 2021 04:55:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi73-0002nT-Kg for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:29 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:38632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6t-0003eG-ET for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:29 -0400 Received: by mail-pg1-x52e.google.com with SMTP id t17so8058927pga.5 for ; Mon, 14 Jun 2021 01:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ujtnjSEKjc/8E8rHyRJKp/40jerX6TctpTGbnCUlGKA=; b=zc3MQSgb8EYYdRAhQzvwdVFL82MWfYNvZglaUd/90IiGYKPqzJ4UMJeOvbGmWJE2aW v+K8CHFXJqmvYdOo7eLpIHhA+b/LmHKj2AsEp8UgvYtSRB54izdF6KIOQICijMZg2Fni CKxpQs8xi7trWHdXtp/hM6FajJ6W2eTc8dnW8y5lBAaLmvxPy+72ZdfIcpti4j9B5Big L2zjVzgkhuJKqTp2Q8oGNDqIrnGSdNJpbAF9gOwPDjmMBwodzAyzCEOtfgTGkVTRZdRX u8iXe2PXU77WzjkurZauyoSiZCzBPuTOjiTxoZ8ljNDJ/zCg7VEAhB/bVdFkjfD0TUdh yJSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ujtnjSEKjc/8E8rHyRJKp/40jerX6TctpTGbnCUlGKA=; b=kpmhAlH1e2BSYWqRq75A7e/MDf6qp/0kcVHO2QBn3qY0oTqHzcTjsIbwHsXKbSNVMo 5GbHG2E77wY1KeL0/HxGyzIgqRigNME6k+vbde9AIBE+MC+G0dweS20e9qzrrB6qJp94 HnoQMyGS3tBGm1PD+jLAt0mFNINFS5cRTGpYizKowb05ADEVfPXM9VMJFwUleJ2wqwhA yaJo0mp9v8aS90BNNe7C2OIeFgJyIEOYuFJcw2WlIk/mPTN40slW/oSi4dyHzADoUYLN no4Rf1/Hdmz3iviib/NS1E2lxAOYhYztNTzdXXV7PUKvKENP/FIe45U5/JTvBfJaA6a1 XDQQ== X-Gm-Message-State: AOAM5312KmFf1FeZ4m5b6splFtuttKPSY+S8wb7BBhHmoXUqEWe/fdHR pWTYpEFMV0EnuFqJjjjpCwUKxTtTcWF1Mw== X-Received: by 2002:a65:63d2:: with SMTP id n18mr16011207pgv.447.1623659898145; Mon, 14 Jun 2021 01:38:18 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 28/28] tcg/riscv: Remove MO_BSWAP handling Date: Mon, 14 Jun 2021 01:38:00 -0700 Message-Id: <20210614083800.1166166-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" TCG_TARGET_HAS_MEMORY_BSWAP is already unset for this backend, which means that MO_BSWAP be handled by the middle-end and will never be seen by the backend. Thus the indexes used with qemu_{ld,st}_helpers will always be zero. Tidy the comments and asserts in tcg_out_qemu_{ld,st}_direct. It is not that we do not handle bswap "yet", but never will. Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 64 ++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 31 deletions(-) -- 2.25.1 Acked-by: Alistair Francis diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index da7eecafc5..c16f96b401 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -852,37 +852,43 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * TCGMemOpIdx oi, uintptr_t ra) */ -static void * const qemu_ld_helpers[16] = { - [MO_UB] = helper_ret_ldub_mmu, - [MO_SB] = helper_ret_ldsb_mmu, - [MO_LEUW] = helper_le_lduw_mmu, - [MO_LESW] = helper_le_ldsw_mmu, - [MO_LEUL] = helper_le_ldul_mmu, +static void * const qemu_ld_helpers[8] = { + [MO_UB] = helper_ret_ldub_mmu, + [MO_SB] = helper_ret_ldsb_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_UW] = helper_be_lduw_mmu, + [MO_SW] = helper_be_ldsw_mmu, + [MO_UL] = helper_be_ldul_mmu, #if TCG_TARGET_REG_BITS == 64 - [MO_LESL] = helper_le_ldsl_mmu, + [MO_SL] = helper_be_ldsl_mmu, #endif - [MO_LEQ] = helper_le_ldq_mmu, - [MO_BEUW] = helper_be_lduw_mmu, - [MO_BESW] = helper_be_ldsw_mmu, - [MO_BEUL] = helper_be_ldul_mmu, + [MO_Q] = helper_be_ldq_mmu, +#else + [MO_UW] = helper_le_lduw_mmu, + [MO_SW] = helper_le_ldsw_mmu, + [MO_UL] = helper_le_ldul_mmu, #if TCG_TARGET_REG_BITS == 64 - [MO_BESL] = helper_be_ldsl_mmu, + [MO_SL] = helper_le_ldsl_mmu, +#endif + [MO_Q] = helper_le_ldq_mmu, #endif - [MO_BEQ] = helper_be_ldq_mmu, }; /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, TCGMemOpIdx oi, * uintptr_t ra) */ -static void * const qemu_st_helpers[16] = { - [MO_UB] = helper_ret_stb_mmu, - [MO_LEUW] = helper_le_stw_mmu, - [MO_LEUL] = helper_le_stl_mmu, - [MO_LEQ] = helper_le_stq_mmu, - [MO_BEUW] = helper_be_stw_mmu, - [MO_BEUL] = helper_be_stl_mmu, - [MO_BEQ] = helper_be_stq_mmu, +static void * const qemu_st_helpers[4] = { + [MO_8] = helper_ret_stb_mmu, +#ifdef HOST_WORDS_BIGENDIAN + [MO_16] = helper_be_stw_mmu, + [MO_32] = helper_be_stl_mmu, + [MO_64] = helper_be_stq_mmu, +#else + [MO_16] = helper_le_stw_mmu, + [MO_32] = helper_le_stl_mmu, + [MO_64] = helper_le_stq_mmu, +#endif }; /* We don't support oversize guests */ @@ -997,7 +1003,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a2, oi); tcg_out_movi(s, TCG_TYPE_PTR, a3, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + tcg_out_call(s, qemu_ld_helpers[opc & MO_SSIZE]); tcg_out_mov(s, (opc & MO_SIZE) == MO_64, l->datalo_reg, a0); tcg_out_goto(s, l->raddr); @@ -1042,7 +1048,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a3, oi); tcg_out_movi(s, TCG_TYPE_PTR, a4, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); tcg_out_goto(s, l->raddr); return true; @@ -1052,10 +1058,8 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, bool is_64) { - const MemOp bswap = opc & MO_BSWAP; - - /* We don't yet handle byteswapping, assert */ - g_assert(!bswap); + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & (MO_SSIZE)) { case MO_UB: @@ -1139,10 +1143,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc) { - const MemOp bswap = opc & MO_BSWAP; - - /* We don't yet handle byteswapping, assert */ - g_assert(!bswap); + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & (MO_SSIZE)) { case MO_8: