From patchwork Mon Jun 21 23:18:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464615 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4667799ejk; Mon, 21 Jun 2021 16:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMHeoMr6IiD8GYKSwctfiI5Pl/z2ENQPg/4B9XqLwwTbKy7ZXTx6JmFWkLqZyMS2JMeF9h X-Received: by 2002:a67:b709:: with SMTP id h9mr20508678vsf.39.1624317589022; Mon, 21 Jun 2021 16:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317589; cv=none; d=google.com; s=arc-20160816; b=rACHmwOat6VJf5NDqTTtGWJ5KAoU4hacKTEFSznsAMjNbeOnbYAzG9slwbVNtZ5OF8 jsUYwyB5jCjR010wgt5rVMuORdaKyhjwxyqZepwSrurvrezEBjckUS7e7nmSEUh0yeQo j+tPT9geB3n46xXP+6iaCh8Ykl+p3d0kSvmg/j1Ybz4JYACHtH+ABVb+5Ljn33tS584s OMKI8pC9Gm7HpPYscdSWgwrRIexV6QnxNlyFuxJPpYIrJVRpSbG4GeXJXD6A269RCZ+f 4wm7Nkt8zdHa7SnUsmVPoeznQkCvnQY3CDA+iss3s+WQqoPCYxt+q38Azknx7dVUroeQ ORuA== 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=CbAutOTrbaMDukD44XCZIi0ihXjwdyULXrBaIAUe184=; b=pA9N4tj3Dc2/viy4JzuT/Jl5BKXH39okXXZnWyZaoNTl5a8URpwuqIyTXnmi5prNuG Ww710BYMZBSok57l+Ll7Fb4pWo8zrQBN45b0u8fhHWn5a2PXILrPGgWnJg6v+38t8YOH ywA1CXZ3EDeRMOnJQtUudZcEUxByDviPRiPIoHunAOBWCpfxBhjOkXt/YUt+tyZtkT04 Y0tYeVjHI1fb5UCHAbAzdO6EyGF6WWqowTvb8NuGcZLKRkiZ5CpOK5hPzUhFvvI56tJO tB0efiMe8lfEnseoSoRxNYL0pAfpZmZnElOjXNY4DsbrYjSEr2tmtCAEXFJAWZ50wYC7 pCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WGs4rL5c; 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 191si448954vkx.11.2021.06.21.16.19.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:19:49 -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=WGs4rL5c; 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]:55014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTCm-0000V8-9h for patch@linaro.org; Mon, 21 Jun 2021 19:19:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTBw-0000U6-MF for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:56 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:33351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBt-0005s1-4O for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:56 -0400 Received: by mail-pg1-x52a.google.com with SMTP id e20so15434614pgg.0 for ; Mon, 21 Jun 2021 16:18:52 -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=CbAutOTrbaMDukD44XCZIi0ihXjwdyULXrBaIAUe184=; b=WGs4rL5cTl+E2fsic3HohebW3YTJPh/AARqDuRc+UNO5cauOjueER8aOGKg66yD5HG 4Kow5nEqk6nRK+UCzy1zKAskSRk48q4DVe86PgUfdP6QuMT1zHdAG8zKyh74rdYQfIuO acLqg3xpGGPz7RyB2AxhdhqjfpCfrulMz40J4UgjiNIAbeTFt941H6K4kUi99KkZOmwC RBLbcvkALvVNlSaw7/BSZwX4axygtft5ohk9DEhpj6JEeCuJv6Dtgw25UiUySivC05Pt XG6lFikBt/0UDJSJE7utEPTrrZLNSkuUUNO28Nz26usCKd/l9lQPQsfmbU03gqKOeWPG Yi1w== 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=CbAutOTrbaMDukD44XCZIi0ihXjwdyULXrBaIAUe184=; b=pH0TcCTHPJnYgMJkp2Sf213UGCgmHMFiSDIKvJwckQRMyCDRnOnWvBTc9IEOlMS3uw PdGXXCAKYKZv765nkiM8yBeo1IYmW/vN9xGtJX5VkK83yoEcoqU7hLsS5XMJifuiopMW ahQUnW0ICJZQZkKxpngeLCm4f6raYKYScU8h58Fd1jxEzTG0XvxKl2tbIQ6Mixh1OymS LgzkRAN8NKBjsUIULpcis/6xmoX1AEprtuhW3/pxVCVwoj6KmYyA2qk0W1dEv7wseLDV /SKpvKPlIKcX+aJO5Iv0ZQ3gtaN1AUx9n/nNgs6vsqYCvmJ4YPIaIXQAThfsCDZQKzKI q3PA== X-Gm-Message-State: AOAM533RjOed6QgCS15lROe26zNRwTVpyWVjsBFZfPE9JG+E1jgmR723 eTG6zVGSE+L75p99ByNze/x7Vs8yzoAhZA== X-Received: by 2002:a63:609:: with SMTP id 9mr147558pgg.44.1624317531306; Mon, 21 Jun 2021 16:18:51 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/29] tcg: Add flags argument to bswap opcodes Date: Mon, 21 Jun 2021 16:18:21 -0700 Message-Id: <20210621231849.1871164-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. The backends currently only support a flags value of either TCG_BSWAP_IZ, or (TCG_BSWAP_IZ | TCG_BSWAP_OZ), since they all require zero top bytes and leave them that way. At the existing callsites we pass in (TCG_BSWAP_IZ | TCG_BSWAP_OZ), except for the flags-ignored cases of a 32-bit swap of a 32-bit value and or a 64-bit swap of a 64-bit value, where we pass 0. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/tcg/tcg-opc.h | 10 +++++----- include/tcg/tcg.h | 12 ++++++++++++ tcg/tcg-op.c | 13 ++++++++----- tcg/tcg.c | 28 ++++++++++++++++++++++++++++ tcg/README | 22 ++++++++++++++-------- 5 files changed, 67 insertions(+), 18 deletions(-) -- 2.25.1 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/tcg.c b/tcg/tcg.c index ca482c2301..c2415fa724 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1707,6 +1707,14 @@ static const char * const alignment_name[(MO_AMASK >> MO_ASHIFT) + 1] = { [MO_ALIGN_64 >> MO_ASHIFT] = "al64+", }; +static const char bswap_flag_name[][6] = { + [TCG_BSWAP_IZ] = "iz", + [TCG_BSWAP_OZ] = "oz", + [TCG_BSWAP_OS] = "os", + [TCG_BSWAP_IZ | TCG_BSWAP_OZ] = "iz,oz", + [TCG_BSWAP_IZ | TCG_BSWAP_OS] = "iz,os", +}; + static inline bool tcg_regset_single(TCGRegSet d) { return (d & (d - 1)) == 0; @@ -1837,6 +1845,26 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) i = 1; } break; + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + case INDEX_op_bswap32_i32: + case INDEX_op_bswap32_i64: + case INDEX_op_bswap64_i64: + { + TCGArg flags = op->args[k]; + const char *name = NULL; + + if (flags < ARRAY_SIZE(bswap_flag_name)) { + name = bswap_flag_name[flags]; + } + if (name) { + col += qemu_log(",%s", name); + } else { + col += qemu_log(",$0x%" TCG_PRIlx, flags); + } + i = k = 1; + } + break; default: i = 0; break; diff --git a/tcg/README b/tcg/README index 8510d823e3..c2e7762a37 100644 --- a/tcg/README +++ b/tcg/README @@ -295,19 +295,25 @@ 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 the low bits of a 32/64 bit input. +If flags & TCG_BSWAP_IZ, then t1 is known to be zero-extended from bit 15. +If flags & TCG_BSWAP_OZ, then t0 will be zero-extended from bit 15. +If flags & TCG_BSWAP_OS, then t0 will be sign-extended from bit 15. +If neither TCG_BSWAP_OZ nor TCG_BSWAP_OS are set, then the bits of +t0 above bit 15 may contain any value. -* bswap32_i32/i64 t0, t1 +* bswap32_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 64-bit value. The flags are the same as for bswap16, +except they apply from bit 31 instead of bit 15. -* bswap64_i64 t0, t1 +* bswap32_i32 t0, t1, flags +* bswap64_i64 t0, t1, flags -64 bit byte swap +32/64 bit byte swap. The flags are ignored, but still present +for consistency with the other bswap opcodes. * discard_i32/i64 t0 From patchwork Mon Jun 21 23:18:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464612 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp93171jao; Mon, 21 Jun 2021 16:19:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKr4xACS/cnF7wincvGnO4XOQ7o9jgP7t1mDC6B0DsyrzIHytPtuTREvrcK/6Wjc4wKvtc X-Received: by 2002:a67:2604:: with SMTP id m4mr19935160vsm.51.1624317552224; Mon, 21 Jun 2021 16:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317552; cv=none; d=google.com; s=arc-20160816; b=t9IogzgVFGAB1EmCOSxQWZsIygFa9iqc2/beM3GTp0BYzBOy3PjQpdvtWA41Qk8VPl 6Lvi++HlNkUygQMveDL8MPSxiD+DSoiGwlpepbYSjrpL1oQumT8Uykm85Hv8wWbk3eR2 jDwhNlfs1xH3ibP0nxAm+I9/8+4Jwhz0oCXhvmqndrye+kmD74XASBfmPiZV2dHVdXox CiZGpQoWN4q9XhTCrgVPXAcPrnFFCHWKKeiueB6Td12K8xpAel0ml9pXP3wcA4+l+fNX 0M8pVZEwjqRDbUZXHS0pni+Y0+aFns4A//cK8gfv8PXloH+ClzdlsDK7Gdtq2Mf3DrTS Nssw== 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=CHsyqcYhDcvH4VyWNUvcKr7ulIJabCuia+q5kv3FL14=; b=0c/o7HJO/TcAVZk++njRMGbT/qesvWlgYS59+QV0U04pOEDAwLWKPjeQyPer3OYjSU 67rgpGQs8J7m5jUf3e0I30anoP5ykde7VvBChJhDN2AsGN/7Nz8Zc9PgHsm7Hg2jIZ2Y p80iFnmkI8ZDVyGCxCuG/rMa1H72yMv6Mefjcgj5fSMtAvc5dq4QlWFSXShpB9ZWrCEZ nRiWAt7SZmnFbCs6PJr50jN0IgaTsyr/DYqWDO23Yuo2/kwCUNoFrgHXc+unqL1i4QnS a1GNdnWVPiv9E7WI80a4UDj/W65RQ4nwqsHnDaYLU7cGimI+kX+IICZck1pa0S70gTy1 98PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ESLGfeBc; 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 e5si396594ual.251.2021.06.21.16.19.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:19:12 -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=ESLGfeBc; 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]:55000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTCB-0000UH-Ef for patch@linaro.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTBv-0000To-3h for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:55 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBt-0005sP-1p for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:54 -0400 Received: by mail-pg1-x52c.google.com with SMTP id y14so3972154pgs.12 for ; Mon, 21 Jun 2021 16:18:52 -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=CHsyqcYhDcvH4VyWNUvcKr7ulIJabCuia+q5kv3FL14=; b=ESLGfeBc9qteQD54IAeGwWLLlWvZw1WQQDkymFDVwBsu4ORoQ4hZERoyAoX/mN0eCD 0zfax6mpGXwh/iXH7i0LYWVl5vfn1WDNiPy4KLOdE7Zs7Bx5L+SNCGpy0A4FaucXgrNp GiLHm/LgrrpBKNHQEQwgPo64kb1ciAAf+B0Bo8DN3dOp5UH4RR4tDUahcQu5WZaAJBZs 8osU0QQDSQOPSteqfxZqeuvfk8hVtZn9xx6GZlKjJflEou/suRDtUanOzdiTCFpKaQoE i8n+H+2z3EPsRcTNzf3N2Ky333ATCGKz6fMNUkqbCXhwD4TS+p+LKg3SwwsCuFmvwAw0 R44w== 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=CHsyqcYhDcvH4VyWNUvcKr7ulIJabCuia+q5kv3FL14=; b=bXcgPUPDW9ZwJ0uSiNhhp4fWdoJyWEovD/o5G+fTeBBD5tqWBsQqDOeRhDEY5/6mFu 7wFH55pPV6LyoADEMqeNTyTnFfkSozBQGJWDfDpKfxAIXX6GJ5xDdFSOlOkz+yfcSR18 Y89DjEuRu60hH4zMnlHF7sawbt3rpX1Y2y8OSW8A0jYsgvTK22wscauBZHlilLzXD0ZQ ctQrGi586gpQsVm/FOKyRndroxG7vyv9Jh9UFkHsD5pQS/11Hm/VoWRHm907AUugDgez fVkF2Pk9+B31VyUxO5Ig6OHYasLvfznNatBuV54QlJFnWqTJb0sMoSKtjXkkSCB28CLc uCsA== X-Gm-Message-State: AOAM530ds48yhBKkgd9S3Bo9KMImiBcTWx56lWrFoHWL1yglDgpAixkf KyAxl2PailFDE8WXm++B63oWN5KQIbPQHQ== X-Received: by 2002:a63:2208:: with SMTP id i8mr824350pgi.71.1624317531842; Mon, 21 Jun 2021 16:18:51 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/29] tcg/i386: Support bswap flags Date: Mon, 21 Jun 2021 16:18:22 -0700 Message-Id: <20210621231849.1871164-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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" Retain the current rorw bswap16 expansion for the zero-in/zero-out case. Otherwise, perform a wider bswap plus a right-shift or extend. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) -- 2.25.1 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 21 23:18:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464616 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4669014ejk; Mon, 21 Jun 2021 16:21:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3uC7/Y2BsFAvXC2yjsktyozHogd+TqTDGmXD86PJL7EsTA/foz24g2G/KWa+mxGMV7fHa X-Received: by 2002:a67:69c5:: with SMTP id e188mr8092972vsc.22.1624317692411; Mon, 21 Jun 2021 16:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317692; cv=none; d=google.com; s=arc-20160816; b=sjvSTkOs4Z/4GsVq54jjRqR2PblcbDX65kjdbd+oM6UPmO1pQn2Uf9fY7syg+tvuES Kb142MiwrYwqkOGF/4bK4eVSlMmczDgogSeuN384bi5d11661ipqm5Ys8XZ4xUIux3PU SOmO8IeYa2ThXX/cY8rB1Ho5U0o1GYRX6dBZR2wdlx8cNBtpx0kTpHtKsWdJq5sPtnK0 kv5qFb5Mr+4+PEG1TWfg7M2SnD5Ax73tHP8EbN2d3z9zepsj6OkBWKSxUzXdbCH9rzI0 9Ewat0ZMIY8/2TE/r4QJi3jPxAq5Wz1fE4oJgDyk5PKlG/1d4ohXg2+SjSVzXj9t97q8 Xo+Q== 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=TgPkvwGFYNi/hYwy/BPIxcT+EKYHn3/r3keK0x0OnG4=; b=ABvgTfSWP/pfYKn+DQcl2M/rgi0PLA1+Yk49PLRIfMoqeju8f/fTMrgGBYZgBk9awf sulLmpkoYCcKq6XkBtHItmLzbDFzZQq+Uo9galr1ucHyvM/KmvRYXma/WxOd6HApCwBf IqsqpjepniiDj6SHTx/n/ObHE2eCIEVb6wXLCs0fcZpRVYVwmVhwucqCTc7hWnwhZ9XV O/3PCvGcUTJDrhUYuhMiKKrqaz2dtivI/DRuN9MNj+hfYG4aBZleJ3GRFWDY4EvTLUna 1oo6bNqO+5GJViquIYCImTeCXw3FQfCXEJJltciD5018dCwIqAGgAd/yEdgpc7IzjiB0 RuNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ng4UbGz+; 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 y26si10043187vsd.240.2021.06.21.16.21.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:21:32 -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=ng4UbGz+; 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]:35248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTER-0006G1-Hm for patch@linaro.org; Mon, 21 Jun 2021 19:21:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTBy-0000W8-0G for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:58 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:40799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBu-0005t6-Q5 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:57 -0400 Received: by mail-pf1-x42c.google.com with SMTP id q192so8293775pfc.7 for ; Mon, 21 Jun 2021 16:18:54 -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=TgPkvwGFYNi/hYwy/BPIxcT+EKYHn3/r3keK0x0OnG4=; b=ng4UbGz+4bSiP3QBdO9ZCPfTrdov4DoP8s8jajACg345WFYhQ4aooioSoT1DTLo9MJ RHTAE8r7shaTQFInzCZF5h0yiFJtg3Hb2jipDDNtm1FlGIuqYquovu2if6JJ7XHO3rUP YpVhHvdY1Bvf4RcPQRgZXQZ3JE4eAj9hbfYypW8xmlRYIxWMl2ZnttkqL8uiXvZAneFj eReM96UKeki3gVXnua/Kr8oy4ztEKNSpZC83S1lPMVTyzOwZAlvqXvepsEn3vFso3hUH v4FMt4qvhAfW6I4mttt+MrI6FZmAe8C8u1VMAT5kyMewu39oYRwtfOrueu0bLXxHlcPT aQ+A== 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=TgPkvwGFYNi/hYwy/BPIxcT+EKYHn3/r3keK0x0OnG4=; b=SGx03ZyZi07wnOn42ZnUUOo+H8/ZB5GkVKc++e5pvmb2X/g69eAxYflMOYxcQm6vcP Z1felb0Ze9UF42Gu8obdoVeOKjD2qRa3HQhJ6Vi1sMmHyByP01Tul5c4nMQlxHaMxaS+ kmm5WNoUm9NdvGtq93dqNeV+a2VJ9MqiQpW/7uC6CVd22VlJZO1HgHxN3ZGiQzm3W3Ex HPxSPLoGQ4Rov9T5+OzwdjhndfFDC1Q2uOMirx+zEDHoK3rR/pe2h+icY3cqVl39zeYD wO+IAbfFVRvsMlg2kmdcOByZbpo+tCZ1VeTYKuU5vBOdqIvnKVjbY9naDrgi0gTBw/8S WtFA== X-Gm-Message-State: AOAM530uHX7/nPldh/A7/oX1k2tPFoYefoPjNhRIrPHqd68Msg6sCWEb kPWp2Pu+uofwHTxKi0UUxEAL9fkptfyUFw== X-Received: by 2002:aa7:9912:0:b029:2e9:c500:41fc with SMTP id z18-20020aa799120000b02902e9c50041fcmr627878pff.20.1624317533533; Mon, 21 Jun 2021 16:18:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/29] tcg/aarch64: Merge tcg_out_rev{16,32,64} Date: Mon, 21 Jun 2021 16:18:23 -0700 Message-Id: <20210621231849.1871164-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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" Pass in the input and output size. We currently use 3 of the 5 possible combinations; the others may be used by new tcg opcodes. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 42 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) -- 2.25.1 diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 27cde314a9..8619e54fca 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -475,9 +475,7 @@ typedef enum { /* Data-processing (1 source) instructions. */ I3507_CLZ = 0x5ac01000, I3507_RBIT = 0x5ac00000, - I3507_REV16 = 0x5ac00400, - I3507_REV32 = 0x5ac00800, - I3507_REV64 = 0x5ac00c00, + I3507_REV = 0x5ac00000, /* + size << 10 */ /* Data-processing (2 source) instructions. */ I3508_LSLV = 0x1ac02000, @@ -1417,19 +1415,11 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, } } -static inline void tcg_out_rev64(TCGContext *s, TCGReg rd, TCGReg rn) +static inline void tcg_out_rev(TCGContext *s, int ext, MemOp s_bits, + TCGReg rd, TCGReg rn) { - tcg_out_insn(s, 3507, REV64, TCG_TYPE_I64, rd, rn); -} - -static inline void tcg_out_rev32(TCGContext *s, TCGReg rd, TCGReg rn) -{ - tcg_out_insn(s, 3507, REV32, TCG_TYPE_I32, rd, rn); -} - -static inline void tcg_out_rev16(TCGContext *s, TCGReg rd, TCGReg rn) -{ - tcg_out_insn(s, 3507, REV16, TCG_TYPE_I32, rd, rn); + /* REV, REV16, REV32 */ + tcg_out_insn_3507(s, I3507_REV | (s_bits << 10), ext, rd, rn); } static inline void tcg_out_sxt(TCGContext *s, TCGType ext, MemOp s_bits, @@ -1737,13 +1727,13 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, 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); + tcg_out_rev(s, TCG_TYPE_I32, MO_16, 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_rev(s, TCG_TYPE_I32, MO_16, 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), @@ -1753,13 +1743,13 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, 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); + tcg_out_rev(s, TCG_TYPE_I32, MO_32, 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_rev(s, TCG_TYPE_I32, MO_32, 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); @@ -1768,7 +1758,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, 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); + tcg_out_rev(s, TCG_TYPE_I64, MO_64, data_r, data_r); } break; default: @@ -1788,21 +1778,21 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop, break; case MO_16: if (bswap && data_r != TCG_REG_XZR) { - tcg_out_rev16(s, TCG_REG_TMP, data_r); + tcg_out_rev(s, TCG_TYPE_I32, MO_16, 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); + tcg_out_rev(s, TCG_TYPE_I32, MO_32, 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); + tcg_out_rev(s, TCG_TYPE_I64, MO_64, TCG_REG_TMP, data_r); data_r = TCG_REG_TMP; } tcg_out_ldst_r(s, I3312_STRX, data_r, addr_r, otype, off_r); @@ -2184,15 +2174,15 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_bswap64_i64: - tcg_out_rev64(s, a0, a1); + tcg_out_rev(s, TCG_TYPE_I64, MO_64, a0, a1); break; case INDEX_op_bswap32_i64: case INDEX_op_bswap32_i32: - tcg_out_rev32(s, a0, a1); + tcg_out_rev(s, TCG_TYPE_I32, MO_32, a0, a1); break; case INDEX_op_bswap16_i64: case INDEX_op_bswap16_i32: - tcg_out_rev16(s, a0, a1); + tcg_out_rev(s, TCG_TYPE_I32, MO_16, a0, a1); break; case INDEX_op_ext8s_i64: From patchwork Mon Jun 21 23:18:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464621 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4671242ejk; Mon, 21 Jun 2021 16:24:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXKVGUgFKGB90eMTj7xWXYXVzi06BVoO0OIAilglrykVMB0gKIRq8PShTE8H7Masd7fbKc X-Received: by 2002:a92:260c:: with SMTP id n12mr490618ile.138.1624317894893; Mon, 21 Jun 2021 16:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317894; cv=none; d=google.com; s=arc-20160816; b=1GQ3sWEtttHnsXi1GzjUM4k32zVHCMnN2MbG3gvON7+gW4Ggpy5QBDx0UwUGU9Zfy4 +/bzXGPPpCb8QwFM60cjFlnmps6c2T5iXUGYjA9vzYXf+/GSRBO6qz4NyHG6kTgFoPlw OWVT8TI6ibg/s9JL4sTBoGpFC+tMnF9m1BBaPVo4bRq1BPomchPEpCiATP138+I9Uoz5 VDhGN/wkzCKZyccjmswglanuypDmoYDMHnndbpN7cTk4nhH/8Vmr+zJb6u3seAWyQsPw w23yZWuzY0E+hrCV5U4m79ND2kXMKY4rzrPRp23Sh6sahvBiPUlYJGOrvni7GLhO5kma UnRg== 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=13Q3k7x622C0VwURZHkyf+R7o121K1QECu/gh8+RjTk=; b=sFbEHdxKFM8FYF6tMufyICDfuINn6Jlo0tcUBbRNkAjuLxEBwhji2qT5iF9aYDXB46 dKT72t6wtliNfknB4bDuxI9RIPENydc+kUnyjuokhKusFfsh6Rb8Ilc4MQDn4h15jAHu hgNli9GQJZ2k+oqhlO6ezeFg89GW5UtCFRzNfmi3o9YOTYZASoZ21inwn5y8NkT16mWN daoxTFju30Pju3ogVI2qkfzen98gHyczqrhxQB0C7SM1/cCJpPwQupkbFqDrYiDLDDXc LkISzAO/iE5PEkrZ2xpNuSdgpd+D5lCWQGja3YrsuN7Z2qXSI34TWeONeIbvxGZ3hYBv h/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYCLN7Bk; 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 n5si15208859ilj.6.2021.06.21.16.24.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:24:54 -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=OYCLN7Bk; 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]:43826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTHi-0003Wh-9Q for patch@linaro.org; Mon, 21 Jun 2021 19:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC0-0000cZ-Kt for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:00 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:43976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBv-0005tU-FH for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:00 -0400 Received: by mail-pg1-x529.google.com with SMTP id e22so9217332pgv.10 for ; Mon, 21 Jun 2021 16:18:55 -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=13Q3k7x622C0VwURZHkyf+R7o121K1QECu/gh8+RjTk=; b=OYCLN7BkdIz1CcsmByB8bu1vvWt5gdOWc39g0EdagBIiH+ZZY22gdxRy88JVeYq+Fr rNC5zKgbnlH7+CgUkwY63Uxay1holAk00GMAJmbDAyblxyXLFveiobZTAwGcsmM6wC9N cpmhmWCRvgkkHJI38r5h1wY/9wFjw4YhwecvUO/XgbHc1kB47Vy1bZ8Y1mSGUWmOzmrV 6QJqgSfxmjVfYIW8TgwD1SvIXM7xVLtDQe5hmWCiEEY5gWNY5RNc0ahYw66gpgQF29eU Az6E3vOwDicxGIPhyQvY2NPEoTz9vcr382gmSkwaM1cPdfWX8CtHuoIcUxQdbr8u7NJD Rt3g== 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=13Q3k7x622C0VwURZHkyf+R7o121K1QECu/gh8+RjTk=; b=AKqJBAL0AZNDUnJtL7/GJG4LuOETRAVrUPwqPYUS7nAAbydMW2x8JTTYixFM1pLNbe HzulT0jYVonOgEteOa350ULGPctvHfVJypDE9TpjSvEk6YCKBTd1Ym/jC1kaHTCi63RI Z71Fzm9pgGVNft8B/c8Bjn4I1W854Tkgk/p0d3oJS2lNMnn5Bv3z07ozKR8tN810Zayy 9faEh0V8XZWUQABSyzD8LVF+IvRzyi2HFvnYhAzuzBiCLans4zisoTOoZtWwD99bx0In 3iuZyr1ujRAzRzaQOoEguhgstw592w3mHU5MOzrnYr44j5nHFSXapoRj4n5MboSOhEFp d1nA== X-Gm-Message-State: AOAM5338QhmN3VI0TXh0MKg5zSzPvfRDYqoKIC7ye87uksDWPIR42dLo 3czEKeah6q0UxdYPeQwT0Szk7uFQKSfftg== X-Received: by 2002:a62:3344:0:b029:28c:6f0f:cb90 with SMTP id z65-20020a6233440000b029028c6f0fcb90mr592074pfz.58.1624317534092; Mon, 21 Jun 2021 16:18:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/29] tcg/aarch64: Support bswap flags Date: Mon, 21 Jun 2021 16:18:24 -0700 Message-Id: <20210621231849.1871164-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.25.1 diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 8619e54fca..72aa7e0e74 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2177,12 +2177,24 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_rev(s, TCG_TYPE_I64, MO_64, a0, a1); break; case INDEX_op_bswap32_i64: + tcg_out_rev(s, TCG_TYPE_I32, MO_32, 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_rev(s, TCG_TYPE_I32, MO_32, a0, a1); break; case INDEX_op_bswap16_i64: case INDEX_op_bswap16_i32: tcg_out_rev(s, TCG_TYPE_I32, MO_16, 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 21 23:18:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464613 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp93243jao; Mon, 21 Jun 2021 16:19:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwhtjWdJDkTT+60QQZwfxaZyBK7QjYpgskWuaZ/dqakJhLfePoNIbaiVc0N5Vc1W9kxxLZ X-Received: by 2002:a67:ef84:: with SMTP id r4mr4484510vsp.21.1624317559326; Mon, 21 Jun 2021 16:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317559; cv=none; d=google.com; s=arc-20160816; b=Z/pOI6ffoLJHv3EQJjA3ooXM7qF+S528usn+XfHW3dRXwnlaSGB47OU1Dapw2JHFnw rDAvWz3dAg7LdAbPa/zDH7mPhcfUvuTbDGkrmyDiIWqRIyybFgnhi+dY7pEdmOL5VtTd MRyA8/n1+RrdHQIRVbUYCZgFpdSSuspMTUzTbiaR+mEsuwMYsgeVBDzt2o0ybtuTzWpw 6CTuAPJoptQeafLzKkjk2NHmNqrTsBuYm6wzZtlbazDWR5o5uLfvmqZ1LeMMqm9Ag1Ki NVnokmw2YTQVOQ12wSHqp5Zp9odfDNnByouWvh5oXNKHt95r07VC83xqvGiP/le2Ecq+ wMtA== 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=4YyQO3FbDlFClyDWmJjxOpZ7dtoBaiXSXTjpxONdiUM=; b=jddiZwjrgwzWlQxHhFPXuL2gC7Y/Vh2Rs+MYc7jbLodfDEqR1MqKaeaMmxPy1plSIk kJzedyfWLnx93s8QAF4zvhtuq34NugTyCq6m9trkTCwWqbQpWsD/vv+Ia3br/gkJ60Dm Nu0xM72TL/FovF8zzFJP9QEJ0xgqte+wO28WvL7UonxlTfG1kz+Jex1pstZ9VZWfH1tN u0XsFVY9f1uXAuUze0exqMYt0THmeRkQjbiNIGQIkEJQ1QGtFdRzDAuoxdKHj5pfJGSw 6secnhdFVzdlGetDIExZnYYVTLRZjI9rDsUW+UBIOMJTKBtoP5JOav6jG8RA8YsX7m5N 7LiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lHd8aZac; 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 d8si457482uav.239.2021.06.21.16.19.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:19: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=lHd8aZac; 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]:55424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTCI-0000mL-Dm for patch@linaro.org; Mon, 21 Jun 2021 19:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTBy-0000Wn-Cx for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:58 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:47003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBw-0005uY-2P for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:58 -0400 Received: by mail-pf1-x434.google.com with SMTP id x16so14832514pfa.13 for ; Mon, 21 Jun 2021 16:18:55 -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=4YyQO3FbDlFClyDWmJjxOpZ7dtoBaiXSXTjpxONdiUM=; b=lHd8aZactnvgKZUS9qHI+5tKNBBG26cGwkTOR1GD46LGAe217VQjoV3sAjVtdJJd3d cj38Rx9kHACe4+a78An+qIjq//4N0b38jOu3F725KI+meTY0I90Z1Uw50liBlf/TZ+J8 ehsEces6SdnR7XgEPmHAFiCo4TVf67o3tUzy2UcxvnBydCbjvKx3kpDGQsVcQwKY8nX1 V1DZR5pIvycZSzQ+jCRn9BlsQivr34f9BRxcbzQpFXmFlkCchuSgR9pojQ2XpAygkb/Q 23sFbwYAoezOxMe2Uw0fSeQ+xjTGLtLsF+i3RNrzlnWsUwfS1XeE6Gq5iu5rfsS+//iH yM3w== 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=4YyQO3FbDlFClyDWmJjxOpZ7dtoBaiXSXTjpxONdiUM=; b=dZ3WGUHljj21mZ/3jIHxQlQXPp+O3D+MsmTgJdq4FYfz7Gs3Uap1bjzxkjTP6/nqHp bgpbigmHNq98HpSMK/UBCgYD7LRPywwPmmroUb88b/UxKbAmcXBV/JRKb4M8eOJexz2w vlp905TfrZomJZKLSUxRz/SsWUh8pc4Zqh0Z02a6vFeNfXKmsSBV1DVXkAHlW+4t8S95 RaPd3ezY5sHJTurWRV1mbedi6KzWWhSjJpvitRinufZYnfmHohNTqwIjbx7o6j1QSXP0 A7oeWKPQyxAND1r4YXdK66yq10UCfHiZEiefP7ZVUJtlKt3CWJyCOy5K+qhzcIwCKgJP +Kfg== X-Gm-Message-State: AOAM531vloHEHQ4Qy/PeYEqa7v3pvFexq0VU2jmvvKr4uSRvj9pT5Aoq YHeSgrm4CsgCBkgjI/312pQAYN07/ub64g== X-Received: by 2002:a05:6a00:14c5:b029:2f9:b8ea:7ab3 with SMTP id w5-20020a056a0014c5b02902f9b8ea7ab3mr588994pfu.76.1624317534707; Mon, 21 Jun 2021 16:18:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/29] tcg/arm: Support bswap flags Date: Mon, 21 Jun 2021 16:18:25 -0700 Message-Id: <20210621231849.1871164-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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" 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 101 ++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 38 deletions(-) -- 2.25.1 diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 5157143246..73e0455511 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1013,50 +1013,71 @@ 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 { + if (flags == 0) { + /* + * For stores, no input or output extension: + * rn = xxAB + * lsr tmp, rn, #8 tmp = 0xxA + * and tmp, tmp, #0xff tmp = 000A + * orr rd, tmp, rn, lsl #8 rd = xABA + */ tcg_out_dat_reg(s, cond, ARITH_MOV, TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8)); tcg_out_dat_imm(s, cond, ARITH_AND, TCG_REG_TMP, TCG_REG_TMP, 0xff); tcg_out_dat_reg(s, cond, ARITH_ORR, rd, TCG_REG_TMP, rn, SHIFT_IMM_LSL(8)); + return; } + + /* + * Byte swap, leaving the result at the top of the register. + * We will then shift down, zero or sign-extending. + */ + if (flags & TCG_BSWAP_IZ) { + /* + * rn = 00AB + * ror tmp, rn, #8 tmp = B00A + * orr tmp, tmp, tmp, lsl #16 tmp = BA00 + */ + tcg_out_dat_reg(s, cond, ARITH_MOV, + TCG_REG_TMP, 0, rn, SHIFT_IMM_ROR(8)); + tcg_out_dat_reg(s, cond, ARITH_ORR, + TCG_REG_TMP, TCG_REG_TMP, TCG_REG_TMP, + SHIFT_IMM_LSL(16)); + } else { + /* + * rn = xxAB + * and tmp, rn, #0xff00 tmp = 00A0 + * lsl tmp, tmp, #8 tmp = 0A00 + * orr tmp, tmp, rn, lsl #24 tmp = BA00 + */ + tcg_out_dat_rI(s, cond, ARITH_AND, TCG_REG_TMP, rn, 0xff00, 1); + tcg_out_dat_reg(s, cond, ARITH_MOV, + TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSL(8)); + tcg_out_dat_reg(s, cond, ARITH_ORR, + TCG_REG_TMP, TCG_REG_TMP, rn, SHIFT_IMM_LSL(24)); + } + tcg_out_dat_reg(s, cond, ARITH_MOV, rd, 0, TCG_REG_TMP, + (flags & TCG_BSWAP_OS + ? SHIFT_IMM_ASR(8) : SHIFT_IMM_LSR(8))); } static inline void tcg_out_bswap32(TCGContext *s, int cond, int rd, int rn) @@ -1705,13 +1726,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 +1789,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 +1887,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 +1932,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 +2270,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 21 23:18:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464620 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4670889ejk; Mon, 21 Jun 2021 16:24:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQOQB+6n7DEdCJgvrYg72evrkxcWEcXRbV/pyZBBisn9EdaGt8M18bsPeNkyZkVfiK2p2G X-Received: by 2002:a05:6e02:20e4:: with SMTP id q4mr479334ilv.50.1624317856235; Mon, 21 Jun 2021 16:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317856; cv=none; d=google.com; s=arc-20160816; b=op/BxaEhuC53X5kCdFg8/uk8uSVOBTGpeFX6iMVvLtaZaremXIFc6w7PM7jUB+xNyJ cLy2wiuWt0zWRo7XkzqQcLWy4LpEcXgyfFgDtjLTjYDP6cx779oFcanIrXPw+v038/W4 0UYxjLhTqYR+qhQ/V4EcUVmy+W9KKXP4u8B8U0ZwEpk/2V4G5XePVM7jcFG5n9hOzup7 /cfypxX77ct1J5W7hlRPfT4OoC9UruAKRSdHSgRmGNVJIahFRkQuy4HhtErDFNm0UtDR CyZs3YOQLdjnSMbO94cKmoDxnXitmsPrcyXPaqu0/FJMbo7XjG+vVrOOdFeg2UxpAsmB gDkA== 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=nkUwvYz/H7E5G0Q9SrKLVPmT+1u2d8aWX4+EJ+0VG1o=; b=FWW+z5v7Ri36xMcIhMgotLXXSvqxWw41rgWyY32evDZUhWzFzh5m14Ey1x7jjHeBGf 1KiK9KLOiafwPSe0kI+Ixkgc/RALNtwzFesk46U2IQBErlMdPcguVBM7+bzoHpzIV0Jg DnDXoRaF7HP8cvm9jctfnKiYmLwl7KI8M+dwxxga28GCPHWT/aRVJjaoJGyo8AEoQExg ByaKdTunfHTVfDsYY3FlrzjcI1yg6EdJ2QcaQ/FFVFXC/6fxSOX4h796WDm2WDZPbzrZ VyLL5bacHf5aQ7nTFRhLxbrkY6RfSHehu4tEbquN6aLeaco3/rT0Z+Ugvzh/LqHiqYuo lX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TlW25Pj+; 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 i204si4561297iof.28.2021.06.21.16.24.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:24:16 -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=TlW25Pj+; 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]:43878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTH5-0003YM-GZ for patch@linaro.org; Mon, 21 Jun 2021 19:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTBz-0000Zo-Pg for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:59 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:45819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBw-0005uh-JW for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:59 -0400 Received: by mail-pf1-x42a.google.com with SMTP id k6so14835514pfk.12 for ; Mon, 21 Jun 2021 16:18:56 -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=nkUwvYz/H7E5G0Q9SrKLVPmT+1u2d8aWX4+EJ+0VG1o=; b=TlW25Pj+rrZeDYjy6WR9MNZD5M5RaDY9Ydz/ZTSwGDSNfJRWcDPuPD3F5NH7kXYgJf cYOV0xfH+QvWOx9bGizSExhxSLCmXxlQ6qOLzdUPe5FeixvrL/aSvHI7R/KHdNWPMaE8 05YGOB38laz6e6zEoR2wuI8ZBeVK+ZQwnx1OJ6yyuxu0ah7tTBZpHulrbV38GHaVhesA qPB4pVap4JxXfRrJWX8D/5Qi+IvzAOrVZUw18EM/xG6cOV3VZxDH3rcC4DboZWzSXbB6 B3s/Son7ay8i+lBWSiEiiz8NL0xbtBGVrfckCHT2rQF0wk1+sX07HnnW+cJypHN7XXsu xcGw== 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=nkUwvYz/H7E5G0Q9SrKLVPmT+1u2d8aWX4+EJ+0VG1o=; b=eYVlQG+cOGLMR4JAV8P8hoSRBEpKwRJ0EO6V2yndvE11aLZZjDFjQvD5YNaaj6Da7m L53T40Uim89MXKCw9mEimpsQT+uoeBNbMlRORtM35qcM41ITceNe6WRHHLj82sWFI0S1 oqZsFzjkrztuJOkmrUog3aphZ+kbrTzPctA8vPbq5RTQhgjGWNIy54WjYBnLcznLFNws xtebUCOiCblidN2O40pDezyYomClvGGNzg61BgSamq4VUUpFZKk8p4jrpEF005gABhwL IRcut3Mfm6s5KxsZ7RksPKDa4/yfGo2MDD+1ugpSNAS5PL95hKT4JTJy06jzK/VtNieq nAiQ== X-Gm-Message-State: AOAM531vga3LzGHjNxvDVwA8joZQDYnmkWOpziy4tTZPGuDC0OkwFaWV VVQ6kCo1EUbxqmLLhOFF1AT6qjcbsZeT9w== X-Received: by 2002:aa7:8392:0:b029:2db:4a7:d866 with SMTP id u18-20020aa783920000b02902db04a7d866mr595156pfm.66.1624317535343; Mon, 21 Jun 2021 16:18:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/29] tcg/ppc: Split out tcg_out_ext{8,16,32}s Date: Mon, 21 Jun 2021 16:18:26 -0700 Message-Id: <20210621231849.1871164-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= 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. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) -- 2.25.1 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 21 23:18:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464619 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4669933ejk; Mon, 21 Jun 2021 16:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlKsFgK6JKL5GbA3/H6SK5LPlX7Jg5AtAV6c12E9YeA/J4A2WCd4gS9MphzmXDpnc7uE4m X-Received: by 2002:ab0:7516:: with SMTP id m22mr1243035uap.66.1624317774030; Mon, 21 Jun 2021 16:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317774; cv=none; d=google.com; s=arc-20160816; b=uPj0OtWCoAhpVW3j5GVQissH5xqgEfuFrsqrsvRO0XKk5VJC4H2Jx+o7oajWOCjmat vALCmtqx91wktVYZpMfJgFE+kxdRKc3sIw2pBUHxPcO12FlPTkXhzWoFUg+JC1l9OjB2 rr4QnnZaeNJTayyCI7lt6+PFeMmE6D83hItsxwuiKylfpDAn/vp/rAmyr0ouFOlSs8Kb wnEaY3g4fwrSvst+ZDUMBZuLTge7zUodT4qNgKzmwK312xpWE5rhZi6V9j8aa9AOx0Xr JHYpV5ntQTpArjFrBBu9+bS6OVeLbpzTYqRQhdJGwcpDMIlXycK1Uqm5KuQcOhlOCxWh m0Hw== 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=fXrizxcUnvvf6PXr7Yc72AhaPXA1gSYgiDq85iqI09c=; b=rc+9Z/z327jr60XaAq6StH9isnh1F7+OW4jLn+lfKvQrVDj3zPs2sOk5F1RWw3npjM Yh5qxWTFwYfH6slqEbQmtS8YzdD7c7p+tVce4C6KTQxItHVPFsokF0us+d74SASWuexq VIKdRzKC02pqC7WBqqrII2MdvLXUg0AAKkUKLYet9q95oBgotry66cdpaomPetvUg+nL Tx7hky7t+HhDkzmVv/xFuAvT1KcBTXXz2S/uF6vzPYsI3xJz7zmvsBh6S6LYwz0eK271 c/pvDVDKkVnMZNy5uUvTG9nL9HMhp9nzbWLMxPTxJxOIkgKwg+whfwVSdYvCKsxzqBHH te4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NOzJzQ1r; 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 ay19si566283uab.78.2021.06.21.16.22.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:22:54 -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=NOzJzQ1r; 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]:38548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTFl-0008SE-BN for patch@linaro.org; Mon, 21 Jun 2021 19:22:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC3-0000ko-8H for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:03 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:44908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBx-0005us-5L for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:02 -0400 Received: by mail-pf1-x434.google.com with SMTP id u18so9489299pfk.11 for ; Mon, 21 Jun 2021 16:18:56 -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=fXrizxcUnvvf6PXr7Yc72AhaPXA1gSYgiDq85iqI09c=; b=NOzJzQ1rK4iVrOabtS+/jX4IvUkap8Wo9jTJdUqfyPg1fNfNw3f8NCIoazY1XBuq2Z OZQNhHykQ/PzFO8PSNtSCA4Ihy/mrZCTAj9B9LDpzsByV+dsw9wUZEAlCcmZl4qgEa6D AtIxlTY91NBcymHrtXgRe1tnQ6KjiD1tKKuYV5XF4jmmmujNtxhpBSXFS+wTz9/MdMlF J/z8UNA632IgXQQs5ACxOkZNn3x6NX0q92GXlZ+JLX7YSa6mtKRjIuSRm9E/9+sE6Lfu +URtWSL3T6MWGO2BYW77w7xmKCQu4SWGJ2V0/SZH4AW5BpEd47Y6YaOeUv+/lKDTDntW ez+A== 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=fXrizxcUnvvf6PXr7Yc72AhaPXA1gSYgiDq85iqI09c=; b=FFlm9NdUvJj7J11qceE/78zDv1Hm9bqzaiDFy3MzvE2yMlBqyuORwA2iHK060l99tB 6ZUVX55mTxWhSexLOMiLuMu53CCzBbfWMynPn88iAbS1YDxTJvMY0izkYvGO/eI+mi+f bfi+n4hf1K4E8Nbhu6B0HjVHP34kvLWAlfIYca52mxdtH85HJdE12FtL+QhS52G0Xeji 75rgEnk7zsrOaJ/AwGOMNE+r+fCWmNm3kPDIZQDlG0akn/IyCqEnHinbh1uLup1hvtqG k0y9ajWJZzQ4sEnOheoNKhRe3/d8yIPSvbB+CzBzor2krx0/SOWrf9d3VQcmhqGlZYHT Vbww== X-Gm-Message-State: AOAM531pn6xj5uLazDCls8ZaY1uzD5phMAV0TiIf9gmCqFeohr3rE+Db 1YlW+L4QAYBmYs6CHayTl82I+HOgbCbDxQ== X-Received: by 2002:a63:4906:: with SMTP id w6mr849139pga.212.1624317535909; Mon, 21 Jun 2021 16:18:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/29] tcg/ppc: Split out tcg_out_sari{32,64} Date: Mon, 21 Jun 2021 16:18:27 -0700 Message-Id: <20210621231849.1871164-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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 will shortly require sari in other context; split out both for cleanliness sake. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index aa35ff8250..50347182d7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -768,6 +768,12 @@ 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) +{ + /* Limit immediate shift count lest we create an illegal insn. */ + tcg_out32(s, SRAWI | RA(dst) | RS(src) | SH(c & 31)); +} + 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 +784,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) { @@ -2601,8 +2612,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; 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]); } 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 21 23:18:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464618 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4669804ejk; Mon, 21 Jun 2021 16:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ92mTxg9lPUsRdYTKUf8OLlJGKOPh1z2ZFsiOWAVA4n4raHaXdavUtJXCyFp25Y31vMk5 X-Received: by 2002:a05:6602:146:: with SMTP id v6mr393647iot.5.1624317762753; Mon, 21 Jun 2021 16:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317762; cv=none; d=google.com; s=arc-20160816; b=YZrlTFIQfFNLGqlKHldPZ+4/V+rahDoz5WE4STmJrSEXMyseY1F/YFjkaZeisXXRyD kIHHKb1Zwq0DY6ixbndaP19i3OaWU0J50brudynhmoZOWrG5FN402/yoHb1rlvFWmj4A 6p24/SiGCFR8QSQQOxZaMnDbcsrtx6AhKthaZ+mgAaOBvUCF78He9O3cvuLEhOLjk6TX vYL2I3i4n3cXHft0yyY63FcDIQtPbTaIkZ8bj80u3woadP1UTxUpxbcB5GCA+5l8PvsB QS5Lz5Ua0vHkNvUBmRhU6IJ6eAQ5UgLLitv3Fm1F5MqsTPSlknU2egvyfijn/g4yIpLl V64w== 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=+KG72/HkSkkW/EnHZzWfX4mj5faPrZ7wY+xxoD2yGxc=; b=DiPIZ4pYwMmY9dKflFyH4LIj+zXHXR63WL2GWBM9MTTs2M4co5xLX82NNvt+NbAZE6 nYXWRvwjMyAiyCUCth/5a114JSwS3rrQqv30Ku7mmuGX885WcjtFjSMxrWlILRflHKxr GR+otORNlm22r5jgj1XPL2BuuIsM/p3n7HPbbnUr6WXEoG7gg9tnkzN1VWAUTIuIDQyV LVlWymrULBAZS4BWOuFneBQDxFcnye1vpa4fq/nzJSPqyhieWr+KEVnnvT7ScSRD3B/9 2Rpdt5vRUfdh3D+H384qxIFgA5EfNWUqNi4HybhU9XVsQ9/LswoDjgGzyXiVDAOIcFL4 KvTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JlOIpEuc; 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 w14si10457676ilg.134.2021.06.21.16.22.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:22:42 -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=JlOIpEuc; 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]:35280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTFa-0006H8-4h for patch@linaro.org; Mon, 21 Jun 2021 19:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC0-0000an-2B for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:00 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:42992) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBx-0005vc-QU for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:18:59 -0400 Received: by mail-pf1-x430.google.com with SMTP id y4so7872402pfi.9 for ; Mon, 21 Jun 2021 16:18:57 -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=+KG72/HkSkkW/EnHZzWfX4mj5faPrZ7wY+xxoD2yGxc=; b=JlOIpEucQd8P4k6XJHgKOkW7/657SLlc+4BOqiEVC1UR9ucBkUJ6ks9NEynwscTfk+ kRixLLObDJrev4biIDuwDgRv394CgZigmNiWo3YJQBOekFWB7u5JChURvEDOKZTLgPFc vb8HNS8lY7AVF+uDIAl7LHPHIoaP+zbQuBGnAl3HjCRPIOIcl1OyGF0RXvNNrioNCAPS NEWFZdR9n3PXUvVj1FFzWKbdbJigx8tVU966pY1E8qBrqmEwl24Y9oFELsywSn40xNtT butmFAfmtq1O1f20A9foT1khH/Hu4OpALcyR4NZxTLmycpQBGHnfNoxw+tXFxZYzBs5u qXxQ== 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=+KG72/HkSkkW/EnHZzWfX4mj5faPrZ7wY+xxoD2yGxc=; b=EppWhKtf6KzWREn/3D8irMUV8Sv9tt8X+Cw6z291Ar5B9genphzDiZLLEUpR4n3Wb2 vvTnaMM9YLtty1mklbAz5Hqndmyv6Vpf/h7kzBq5uZzZT/7cpTu1cDCQ8RLJ78pqvTm8 Rn4WITRoQC6LMjM2HPBOhsOL7NP5Vcx7EueGtvBNXcMa2bJeTXo+naEVn+50fm4YLNFC VS6BV6ngLLeOBn+TwToiecVmkVl7v2FRznbAaZti8fssZRevsi85lGc8cVWL+vcZu7oH BF81naWqNalBGLmSabHSVnR//WHWrF/YfkvrBeQleXJHYTtXSWe3EkE2VR23qEWLwP/+ F9kg== X-Gm-Message-State: AOAM530oXdM2iNOHk5wkceZlzsM3btNAVH0w4p34d3OY5y86MCDAvUER FCC1618cAAbNcHMunU6RVe+QuNnR301D+A== X-Received: by 2002:a62:b502:0:b029:2ec:a539:e29b with SMTP id y2-20020a62b5020000b02902eca539e29bmr586046pfe.37.1624317536535; Mon, 21 Jun 2021 16:18:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/29] tcg/ppc: Split out tcg_out_bswap16 Date: Mon, 21 Jun 2021 16:18:28 -0700 Message-Id: <20210621231849.1871164-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , Cc: Peter Maydell 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 50347182d7..ad46ce32ca 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -789,6 +789,24 @@ 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; + + /* + * In the following, + * dep(a, b, m) -> (a & ~m) | (b & m) + * + * Begin with: src = xxxxabcd + */ + /* tmp = rol32(src, 24) & 0x000000ff = 0000000c */ + tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); + /* tmp = dep(tmp, rol32(src, 8), 0x0000ff00) = 000000dc */ + tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); + + 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 +2797,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 21 23:18:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464628 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4673680ejk; Mon, 21 Jun 2021 16:29:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz08rgNf46B6Q5Zp7uHWHRklBd1QeerVJnS4vSsREnZzmvjO2LzY7KUTAAbHmy4t90Agm8P X-Received: by 2002:a05:6638:cc7:: with SMTP id e7mr909167jak.40.1624318147894; Mon, 21 Jun 2021 16:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318147; cv=none; d=google.com; s=arc-20160816; b=uK+l/E5VFSzFw4UqqGOJbh22CNGeOOEp0lsTwMMNf/7l2L1yXUu3NUtc2qViPo+s2n jk0NRklQ2gQPIcpUMjSG9zbbuVINajJrpFFssSaeKzhiEU0jPOlakqbnSHKQaui3XzOp oMBeUjqc0dM1I4dhEqVAHII39I5VMmqZUnqcC9uvD9suv7Oob6g1O3/y8h7U6NnQvU9v JRG3SY9dvoIJ4LA5kNNhyZyPEwq/LXbsUL5HE96kgDjqMvzcizX77e163RsG2X4tR1Gv zP1hatr/JgsJjGfYZTwjaPQCvWAbm3uJ9g5OheZYxcNNH0etk6i5iq8RsF0M38hWSigT kiDw== 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=geg8YV4vkZJiwMubrDP+L2xIQBW7poD/N+KgWkQ7RQQ=; b=BkPkFf8+j5lbSrATcZRkGT5cazoRzbJCgsrelqy65tWMWsbHJ8reaEdngzrFBPq/ix U1ZBzr/2iWR5+gJ7l4LbdoHD+dPvXVbwGRQ/4r+UoYO/WB/5SuS4HZZV/cl5aCtbt+ar p1rYeCBRhbcAQNiM6JkmUDIR899FywF1lj7wflOlTWPHL5NKSu9JIQKCU1Bdr7A8mbUc B0TJteOn+P0s1BAk7gTb0owcWy4hiDAA15ywCqRVRgVjbiJHRHQxbDR25wcNcshKcqIH N1bhuQ1ubSSTtwrA/SkqPMbpJKhVe0+4+SMI2Vqq4pZmF8+sVm1WC53Jo9Av7r6xYhPs bFkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fwAfAAcO; 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 e3si17445813ioq.19.2021.06.21.16.29.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:29: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=fwAfAAcO; 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]:32830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTLn-0006c4-2j for patch@linaro.org; Mon, 21 Jun 2021 19:29:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC1-0000fb-J0 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:01 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:46872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBy-0005vz-FF for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:01 -0400 Received: by mail-pg1-x534.google.com with SMTP id n12so6659962pgs.13 for ; Mon, 21 Jun 2021 16:18:58 -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=geg8YV4vkZJiwMubrDP+L2xIQBW7poD/N+KgWkQ7RQQ=; b=fwAfAAcO8fHCoqYhxKl6HftvcKZ7pJw0Uy8Jy2O2U+q8PwImclLjkF+6q7Ibm4IYT4 jtxl0M2BH6QXZDXjRwxgCFVXVZlKG4iynGCzgmgg75NWVtLIJJ0DR6uss7nRAf2cKUez bJ7PuWL1+Dhnkh6u3gbNmdf35lega8db1nYOrh/5/BzM/PXvy0nE2WCbYIv1Wjw5yE81 KuASLKZojxrObcPvmQCSnhSWikoyFSJqff65Zb/QrTXA7sv/kH0C4rQosgG+VZf8Pocz oAdhdQOAUMCSxD8DU+Q6L/yFw+aTxWcCP+zpRIy91Nybf9KXahjpLNkSYri6pVygLEW7 Xkhg== 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=geg8YV4vkZJiwMubrDP+L2xIQBW7poD/N+KgWkQ7RQQ=; b=Tvn0ZaW1VsVqPHnJ2/mGJOaR3kBOutvDcUtUaQ2veRP8i1PQKXsqYNPkhasbZvC8AH an3HD3Knaip6htBXvAl2DzHKPjMrEuH7vLk4uelhFds1ggZG4pXHmSgMDbwaQiKNNhjY c1V8tt2XCG6jGXL5+3ceog7TxlVGYsSDca3MdUiC8BGGUPIZXq7b37L/BAADZgEr3EQs CvWKoJ8Zn5QvAhxtcpL8/+GjGlvAWGraMw58EqMAXhVijXpIxGa5g6fcANHxKsW0aqX2 ug55NL0iPfQgBlBcVJ7zlC6NUVdAEC/FOqNTi8SYH3sbWpihh4bJizs42vW94KpQFtaz VEcg== X-Gm-Message-State: AOAM5305HhZed05rp+ikWxOO07Euj+UNhitK1k/bV/+wyIecTq0HLKzY ASOICzYppE/VpMnRuyvM9f/l5vg+mYM1Gg== X-Received: by 2002:a63:104e:: with SMTP id 14mr814051pgq.331.1624317537148; Mon, 21 Jun 2021 16:18:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/29] tcg/ppc: Split out tcg_out_bswap32 Date: Mon, 21 Jun 2021 16:18:29 -0700 Message-Id: <20210621231849.1871164-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index ad46ce32ca..28b8671cba 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -807,6 +807,27 @@ 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. + * In the following, + * dep(a, b, m) -> (a & ~m) | (b & m) + * + * Begin with: src = xxxxabcd + */ + /* tmp = rol32(src, 8) & 0xffffffff = 0000bcda */ + tcg_out_rlw(s, RLWINM, tmp, src, 8, 0, 31); + /* tmp = dep(tmp, rol32(src, 24), 0xff000000) = 0000dcda */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 0, 7); + /* tmp = dep(tmp, rol32(src, 24), 0x0000ff00) = 0000dcba */ + tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23); + + 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) { @@ -2799,24 +2820,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 21 23:18:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464625 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4672608ejk; Mon, 21 Jun 2021 16:27:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX7rez4ocwwoYtjHI3Bx8Z9Hze5qC5VqaA1EBPMTE3yR2B9akRer5tP7esrQ9iv72r0uMC X-Received: by 2002:a05:620a:10ab:: with SMTP id h11mr1222431qkk.89.1624318037190; Mon, 21 Jun 2021 16:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318037; cv=none; d=google.com; s=arc-20160816; b=eCZffJdBZSUgdiRCY2udbTjbMxmlXelaKmS4yumOOsrIIQJ+GgA0h3/Ljss6wRp6CO KjBjHSYMRoo4yazWIgHe7iEt1wSuZXEDi//SMSEzpAWcCQa73RDM18mT9XsPlnKhm+m9 EPR1s5+G9Djig0T8HM7L7LzfEktYacJeBZumi6lLxUL1PFGRAfuYGyOd89L1RjkEzq40 cm4oOktwdBB6HY+ezSTEZTEW3PoEXg6tsCRmPlT7pFMrYawcLd4PzsxQqemxEagI4qws i+x9LAUGdwRXa0MOLIz3n9AxLYrJJseh8ywKcJJocGRmp7qpiZCf2zyqW1baQL//vFBO 3b+Q== 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=znXqyANfADmzCCKcOL9UkCkEB0KOFuEYMH60SU5HgB4=; b=U1f/wLFhTRYaLhUKVBKR9IBzkApuTNthTs81RIFMUYzB3xNzWtcoaFQYx+C84AgFK/ 7uj9ORr9C0UhTVZ0EnKtXhg4ilah1w7WkfJiNfmEaF2/MsGAyhChDeYgn6ZCUcijzE9i fD//VDv4/Gotp33ZKBm9Ek5Tg1MUzDrjlmKhOVGXTDIECiGdxq3d2kf/8IgSFDTK6wDX 1GdhBwNEQWRXCJtpK+PPjqslDv33SPfKnZHXs5eP3RhWjCaMZ/mDOHhIlVreg7lYm4z3 HD3FW7go3T5boKxtyBu2LAPAPxoDR6HQmKBVisht604+DDeYWHtWe5civ4RepGoZvYWx QhqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fonwhDTk; 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 s19si5232496qkg.144.2021.06.21.16.27.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:27:17 -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=fonwhDTk; 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]:52536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTJt-0000wH-PJ for patch@linaro.org; Mon, 21 Jun 2021 19:27:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC1-0000ed-An for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:01 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:36564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBz-0005x3-9g for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:01 -0400 Received: by mail-pf1-x431.google.com with SMTP id t8so4602497pfe.3 for ; Mon, 21 Jun 2021 16:18:58 -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=znXqyANfADmzCCKcOL9UkCkEB0KOFuEYMH60SU5HgB4=; b=fonwhDTk+cXOO72skZGVcbXqKpu5VRhs3EkKWfCAUYF2gPwGZNlIgzj0CVToDcEuwo nfRZdwt6S/BJFy8QGOsq0+zfjVtgsR/pk84P3vjCVeGLHpWV3S8H6kPVXrJDyxZSTX31 iAnrMjRfNjLJrMvqPGwQAAk1QmJqRmoRNTLdQgzhPmJodm4YXV5r872javCvhSBgjbLm qJ7eQgvMBAy8CCiiTBzIPBcJbLcOcS6jwoCyD2tTMYuVyXMLGbxHsPWx6QIilKtMz8Ry 4tLcb1D4n+QY/3gnq+HCjOLNoxvPZPXAYiYPCHe1JP6aIf4F6kSIzeu9FKmfVUcDEd6c uLRA== 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=znXqyANfADmzCCKcOL9UkCkEB0KOFuEYMH60SU5HgB4=; b=idwvpKsDtjgSUn5FHpBSR34yCvfb7NYmPj+drf6DnuXHf6K/LpZOH5hpWyS7QJtXee Blq5dgvYtoREPpihvSwWMg4gwcb3yGKtIYNijaDtcrN0fgkxSBNxYeAAj7FfBc9QMB1a 8AspGA95OIFsNwNJmXovjd2fF7gmIHaeSz4nF8WsThWzf56ToY5SFGcjZUSOx2uesN9b n3BuPZRj7wa805LMj5T74EeaDmzBAYZtagb7byK9vfjdYUmo7nxBd35+R74ZXJ21KUhb BcxnKJXZ6RQoGlkA5u4MmLWciE9Azyxbwmi8gX3qeBWBkyhGi7aD5EHXMIuemiqq+jgK Gy8w== X-Gm-Message-State: AOAM532GhIVlymZmdAY5UtEWIw7H4YSIeVvg4iLBbzEFjW+ILtM8I+41 hgYwJ/NERzeSGNzZsalQ4U+lG+mn+XiEwQ== X-Received: by 2002:a62:1c05:0:b029:305:5230:79f7 with SMTP id c5-20020a621c050000b0290305523079f7mr229638pfc.80.1624317537835; Mon, 21 Jun 2021 16:18:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/29] tcg/ppc: Split out tcg_out_bswap64 Date: Mon, 21 Jun 2021 16:18:30 -0700 Message-Id: <20210621231849.1871164-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 64 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 28b8671cba..da6d10722e 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -828,6 +828,39 @@ 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; + + /* + * In the following, + * dep(a, b, m) -> (a & ~m) | (b & m) + * + * Begin with: src = abcdefgh + */ + /* t0 = rol32(src, 8) & 0xffffffff = 0000fghe */ + tcg_out_rlw(s, RLWINM, t0, src, 8, 0, 31); + /* t0 = dep(t0, rol32(src, 24), 0xff000000) = 0000hghe */ + tcg_out_rlw(s, RLWIMI, t0, src, 24, 0, 7); + /* t0 = dep(t0, rol32(src, 24), 0x0000ff00) = 0000hgfe */ + tcg_out_rlw(s, RLWIMI, t0, src, 24, 16, 23); + + /* t0 = rol64(t0, 32) = hgfe0000 */ + tcg_out_rld(s, RLDICL, t0, t0, 32, 0); + /* t1 = rol64(src, 32) = efghabcd */ + tcg_out_rld(s, RLDICL, t1, src, 32, 0); + + /* t0 = dep(t0, rol32(t1, 24), 0xffffffff) = hgfebcda */ + tcg_out_rlw(s, RLWIMI, t0, t1, 8, 0, 31); + /* t0 = dep(t0, rol32(t1, 24), 0xff000000) = hgfedcda */ + tcg_out_rlw(s, RLWIMI, t0, t1, 24, 0, 7); + /* t0 = dep(t0, rol32(t1, 24), 0x0000ff00) = hgfedcba */ + tcg_out_rlw(s, RLWIMI, t0, t1, 24, 16, 23); + + 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) { @@ -2824,37 +2857,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 21 23:18:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464624 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4672433ejk; Mon, 21 Jun 2021 16:26:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjJigJjJ9GOHPHlEoKdGHeaTNKWSP+bK0au5Sv6SzAAh797XViSW6PC9iGRLqHowKBG8vy X-Received: by 2002:a37:620f:: with SMTP id w15mr1254171qkb.99.1624318018012; Mon, 21 Jun 2021 16:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318018; cv=none; d=google.com; s=arc-20160816; b=hJc0MwpgO0HhJVjKsvzByW3TksDGk1oppEnNQZ/iOpPmkJcBBswUyTvFOJ/8NNwEY3 vqbqv58uXKGbZnS2KpbcA0JgA2lZsAOHcoHlvFK8FriOD3pjnGyLZCf4hwzPRWr3OS7n KxekE6b3V5l0YmWJx3dVkUFq7nVSiiPiySI1DT9lNAmTNQkJ/XH2jzzX/PrhciYCurza JRgaV+FMnPYPThV2JMcUR1y0HlYoiXanokj6jxvBus2d6HKbpbKG+0O8XBwLQzZVLwH0 Zu7cfN+6chZYzmpSKcv3VeHyuhnjwuQZXqrQU0YfSY0Wfn2yjJ0d/P3TAoNm/EDSvKn6 rGxw== 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=OHRTImoqpKp6fFDt3CyDGrFLOR/qjHMTu9RJ5HP1ryg=; b=J1te3I8W9jq4L+ve05YYZk5m9ha6l/gjsdkFnukfAa8qXDxKP6oZuNW/6F5wjXexSe NMRtboCQba3kvdAkRlUYqP8DPQWtJbpzGX2GmGv2Dd8U3SJKAiHy6ptXYNzokZqi9U96 87y5t1PnZHivnQ9OsiHtdvJUT1ZNvWoBfFfFtF3xykCx30zv3PO+De8pofjR8xOh1Ezp yXMvZFd3o2zrJYYTppdJA0rO2MCKgfksyDCs7O+/MC8nMASrxYW8FsVLxNAHl5F2fALg 8BmRIq7k3ecdHIdp1kP3732z2iAZYPaX7xgvp/lRHOGiMJabjT5rKKPShHAwHHOoqXQ7 KKOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rw0/jKZ4"; 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 u7si12549100qkf.291.2021.06.21.16.26.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:26:58 -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="rw0/jKZ4"; 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]:52308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTJh-0000n2-B7 for patch@linaro.org; Mon, 21 Jun 2021 19:26:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC2-0000hp-CD for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:02 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:52066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTBz-0005x9-Qy for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:02 -0400 Received: by mail-pj1-x102d.google.com with SMTP id k5so10888233pjj.1 for ; Mon, 21 Jun 2021 16:18:59 -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=OHRTImoqpKp6fFDt3CyDGrFLOR/qjHMTu9RJ5HP1ryg=; b=rw0/jKZ4lnEG0n/qvgusIqqL2O7i31GK7S25om/r7WzoXQXECFXouBQjVSP5ycv6bg X2BHFmHzSI0LK5VGvxumVvalvgQtrqGcRdLmrz/JrRnBzCyZFgSMCXj+R1zB8ggC90hz taAsqa/EUddd6dfXFB/9k/h+k7UJ/xPFfrSdpqQ7MWz6AmXehkIUeMLpOwgNw96LQqc8 D+YiBD9gGArAhwWYOcpSA6WqqU84CXpqx2Bj93SS3x1uksEovnefOg7JClS+KeTws9J7 z3Dqh3dZvT53MlkLM7j036iuc1QoCHuQgy4VSk6snuc4NoeuEx33yG6O421SfXLpG7UB 8NVA== 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=OHRTImoqpKp6fFDt3CyDGrFLOR/qjHMTu9RJ5HP1ryg=; b=e++9nEeESVDSSU1fAFrhVGoB2gzWdwMSchB0TmXTGXUh4dUi8YsoDttsZ4ouRWeBUs B+CVFjgvfQMNRUtoAgAIelMF+BmMn9tO36KI1X3+a0s7GnKP62RQtbuGLwlK+e/ZuE6L KhN4xFiJA41M3fPd7mAUm1ydyrFx0G/3hZhJbIMQ3IfpZcSx8U6x0+NjluwZ6vxfms9v tPyx1ZW2N30AGthUqX5XrZj110+C0jk/YvUpvXlDAIJWnnKC+lfkq0tyZMtUONAUySzI M5JvuGIf8eSIgu1BI4tN6aVEFQ4vVjNNbyCPxWT0aamHNgHgj+Y0e2fBHnEphqrYBYjh hZ3A== X-Gm-Message-State: AOAM5336E55vCYv+LDLOW7JQFJfqTWznKPwIyaXH/UGHb48rOfTmXFHI 8XQpCSmf6TJ3UB1cRieXatotgPxHQonieA== X-Received: by 2002:a17:90a:c384:: with SMTP id h4mr501213pjt.134.1624317538445; Mon, 21 Jun 2021 16:18:58 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/29] tcg/ppc: Support bswap flags Date: Mon, 21 Jun 2021 16:18:31 -0700 Message-Id: <20210621231849.1871164-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index da6d10722e..33f0139519 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -789,7 +789,7 @@ 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; @@ -804,10 +804,14 @@ static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src) /* tmp = dep(tmp, rol32(src, 8), 0x0000ff00) = 000000dc */ tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); - tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + 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; @@ -825,7 +829,11 @@ static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src) /* tmp = dep(tmp, rol32(src, 24), 0x0000ff00) = 0000dcba */ tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23); - tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); + 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) @@ -2851,11 +2859,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 21 23:18:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464630 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4673919ejk; Mon, 21 Jun 2021 16:29:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHBuWy31oNYNU2Ve+WHUMloTM2b54LbOXsk01tyfyoeMwjJbjmgVCGlItRZnbiS4NoDZAk X-Received: by 2002:ae9:f106:: with SMTP id k6mr1242813qkg.274.1624318171950; Mon, 21 Jun 2021 16:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318171; cv=none; d=google.com; s=arc-20160816; b=wGRk3ZY3LRqXTGA2XReOnZvcQdzo6lKfDKGZB7yVHBfg873aoyyUsxAdWJ/yadcD2Y 0jo8ymbPhYJRBVZFA5Mb6Vw4i4U5HM6qXnqCPL/dW41PLagC7rROVMLFiPPTe+SV0bR8 1dSbdSGjePmBxs6Vvp65ZHQxAVYEj7w2RGE/vLOr6apASddQ7NJZaDonKHmxU3qMBnW+ L3XabVh5evaXjPOOLKPD8ayy0mqzShspgUn8gtF+djOHDV9lMwd7EbOkrm/84uLEA1v4 pUjypjSSCguuLPu/haFsoPIvwtU7ur2erz/XJDJbBwkDHFBsvUk9OHI4GHBp67PXxH/I WdHQ== 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=dt3e/7aSErr4Xmb/H8QqWDMz9H+5k2/wrkERlfjCrBQ=; b=U84NloIxz/UX1ZoHUxfTMoFU/KQQDOJJcnlSFocjYM7SC5u2apP+KxfxfezAZY57es BVaXXQVKoN9iw6jsEZ9JeUHrIcNXGMUwsLJyvJvbj0qmzorMHeh1ousQf4NJ5tEslLrm biJBK8giqlXtiayB+yQP/kMnbc9P/EUc95U12GPZF57oN9fyLXv2ATGCo/CcH8mqQTYY l7A7RFnXPowhBPpbrPz4QwFMWWKnTa6eKwZn+UlbKjoH59K5IdcAkew0Al3J8tQSrMfE RBJwDYPEHesLRASGP0gcw6qHQzgwCci2+JFz5zQaiiOp2TZwq38oU0RXuUWocZlaKKqt 12Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3jQ2CS7; 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 f1si3153997qvt.211.2021.06.21.16.29.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:29:31 -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=L3jQ2CS7; 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]:60792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTMB-0006QI-5h for patch@linaro.org; Mon, 21 Jun 2021 19:29:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC3-0000jo-0G for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:03 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:43986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC0-0005xP-D2 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:02 -0400 Received: by mail-pg1-x533.google.com with SMTP id e22so9217489pgv.10 for ; Mon, 21 Jun 2021 16:18:59 -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=dt3e/7aSErr4Xmb/H8QqWDMz9H+5k2/wrkERlfjCrBQ=; b=L3jQ2CS7iEqzVupuxAONnyhFwwT5PR96YEXSuU6+9ytnrVfntUSBxYp2wt0X9O1HSH 3IH3sP8l9z/Bw0p3GYmCTweI6O7Qyt7k52IcJYFUVxU9TTYgQFRDh6jk9iK2QGc2Pq/X EAJKzTsyy00D3pDJd2CLOxHJNpdjibUi3M//2DIG8zs7Viu8kLJ7szCMiwNhHloYhHUf egjV9dhmNRJs+3LGyUlTP4zBL8PXbO93a1f/n3HWhz+r4er875ZRF7dL6TyUkUbam0IU Z6jJwDic/aqPQTC7HoWGTdhrNWcLptdsrM9iKFpU8+0CuOmvIYacyBYyMeGG0XlFqx4c bEEg== 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=dt3e/7aSErr4Xmb/H8QqWDMz9H+5k2/wrkERlfjCrBQ=; b=pkATvN8V5YSDYl9Bw352Vm+aZg/MaQVSk9+kUlZkjSLqKvHTLW/FAPy2tKY2jkiEDd a2Cw/m2b1pSJfSsOCtQTu9b0dwN1Mheopi1s+YJr7PuBcYgToy0p8Q9TvMpmDAlM7OOG hS0cDsQtZ8TBoVKrWB9Yb2uiMlzAaPUwFN/o0JDyBpCyOzC0d6DSBwtOv2ZxkjSpsav8 uJvvKdavA8NTaPn9vUdgD6LdFRiToUgvDtuW9BPsckVChscLgLgHAbWHqDmPI745Jjl8 TfrBC9yd7L1E3gLtf5K7oEG7J9nvIMtcOXC9+VkpJrAJr05xaNz2kjXXHM6RdXZNwXr2 KE5g== X-Gm-Message-State: AOAM532W4RPt9YbEjlBElm9NJGKpd8SH6gP7VLB8EQz84g1F4cAR/ZfE 5Qmp+zfk69rb3jSa3iCb2IC/2pAo8oRCFw== X-Received: by 2002:a05:6a00:84d:b029:2fb:3d61:51dd with SMTP id q13-20020a056a00084db02902fb3d6151ddmr600187pfk.11.1624317539018; Mon, 21 Jun 2021 16:18:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/29] tcg/ppc: Use power10 byte-reverse instructions Date: Mon, 21 Jun 2021 16:18:32 -0700 Message-Id: <20210621231849.1871164-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 33f0139519..ea1734d6be 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)); @@ -793,6 +802,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; + } + /* * In the following, * dep(a, b, m) -> (a & ~m) | (b & m) @@ -815,6 +834,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. * In the following, @@ -841,6 +870,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; + } + /* * In the following, * dep(a, b, m) -> (a & ~m) | (b & m) From patchwork Mon Jun 21 23:18:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464627 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4673035ejk; Mon, 21 Jun 2021 16:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG6G/06TJq0hGoY3JkZlNVg5WlvYbFa/glzTbledq9r5qF3Ky/800bWZetJagy4KWBiXR6 X-Received: by 2002:a37:5cc6:: with SMTP id q189mr1230583qkb.305.1624318081946; Mon, 21 Jun 2021 16:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318081; cv=none; d=google.com; s=arc-20160816; b=tQXojRJ7cu+ReVXX2CZKruXQYEknZ+KorL7xcujr2KwPx8K7Z3bjFCrv2G7SWyJMdp lFgBSIoFgId5P/sTih3Ik8zjm+ono3uTsv9V6ql8Dytyo4pdgDOI4/vJFgVGGyeq2gpN QCBfhvS1bvunKXPDGLcazOa3qW6OXHruy5nTnDuHuqZbz9lnN5NuePEcdX2XcpWZg2Ds kQrSddBCYRsM12wJ1J5vI9Ae7ErwIQd2aU0jLfI0RAXXjrVZze/3I2Cmt7QQwO1mafXG qg0FWdRSlNWybuuqvH3CsNctsWoT6Z7VOFFvGlxsmzDI+tNbmRMumJp72GMBdfGnoiPC rQ/A== 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=XeAHGZvU+4bcBhBzpwuP6qhUMOPwqt7/gsbeGf5GSPqWcH6ue3hTikZzoj9XSj1eyB Gws8Glr/YfP5iVQE6MMzhOGI98GhdxxEZ1GShynm/zbnNNISccl8M61pzduhYRiJV5a/ vvWHKnXGBpmHXjY5BJ8hqvnxJTbJMHDdmIDz0Q/s98Ky+PiyI6MIK6z6tAtf+s6wH6cm pZWgy/uNzJQ4sQq+7ppVCcqizu/KrhbQ3gjNGhJi7N+OAU+ZmtFfebCbFLqFZdVLsF1g Pn16BNfId9wM1QTxeLLx0ofsIK70INKuVjE56hx16KyPTBpf55IHv/LEnPn+KtO2n1AH k+zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bY97JD1p; 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 v3si379786qtx.209.2021.06.21.16.28.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:28: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=bY97JD1p; 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]:55810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTKj-00036P-8l for patch@linaro.org; Mon, 21 Jun 2021 19:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC5-0000t3-Ip for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:05 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:38762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC0-0005xY-VS for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:05 -0400 Received: by mail-pg1-x531.google.com with SMTP id h4so3871034pgp.5 for ; Mon, 21 Jun 2021 16:19:00 -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=bY97JD1puj46wEnElvvfPu56cQuF0CzJyc2eCEZLioJ8TryoJ3wrrhKvJWHw4iiqai s5qFJFV7asOaSs6H5ekpbcnv9T5pGBcB7lCHOtE2+cxY/1iBJr4sU0m9Bzf+AG46TOsZ Zg+vsKM1+oguuWUcwj1woMAXxxwKTCo8e68l78SiD4n1hQ40ekuOSHdavGIL6Xq5qRDb hitYIe7YOmLlscC1OiT1ZkLCPfpLDN7qgULVv2MWTQmWbwhpoEuDtVIqA0X69nXsHWwR CnPZoCBBTmaNv1j1fT+TMWgwAYdRGzABxLPEi48Bxk5ew+K10eDSUvc6d2bFDLHM47Qi L5Cw== 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=WJO34iwqmzHUXMJtZr6GQKLVRV+jsw3Ll3rpraz0al6/Pb8asNtdmdQMwX23YBleP3 yNrqHGuPNh+SB2cFM95R3b238K0qMUO46lb1hpnFkALkEquYlIVhMHye1+mBOPci2cad AGB1j84nFid58z3pZZcFw0R2epiJgVfLjXMop0wiSxhMW1xPoB7sQ8xVm+AWWpFWZ+me SYr+p5YLw5eHx3W5MaFmq1Gz+fH/vK9l2AZEK/jI9oGz84/KQROpUMDN8AE8uPwndyAu PrImdpYQMBBR+5JtljWGzr8SRsjPQQMHJ/V2M8GGXFUdXZ2julEVzIhLVAjXf7fyvHKg XlGQ== X-Gm-Message-State: AOAM530yKhetO9KtJjoE504UhWx1DZCZt4dbn+BXTAuhOTJ3ljAKjS0u 451n5o35nbUl05mOUqSJUB3D19Q19mW78g== X-Received: by 2002:a62:164b:0:b029:300:5576:3c77 with SMTP id 72-20020a62164b0000b029030055763c77mr591672pfw.23.1624317539595; Mon, 21 Jun 2021 16:18:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:18:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/29] tcg/s390: Support bswap flags Date: Mon, 21 Jun 2021 16:18:33 -0700 Message-Id: <20210621231849.1871164-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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 21 23:18:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464632 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4675152ejk; Mon, 21 Jun 2021 16:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKa1/6r3t2Bp3yi6F0OhuloXViSmCNyLku0CIQWQH/xWQ44AvTJmyraf1icPed7gQwI+Wc X-Received: by 2002:a67:efd6:: with SMTP id s22mr20639255vsp.3.1624318285139; Mon, 21 Jun 2021 16:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318285; cv=none; d=google.com; s=arc-20160816; b=Q7aeeAtDWVOwuszlyDwDx/6cVzZaGNKLLSRfqYG5C9IvtjAX1XQ/XiyGNOBbHoWyVH 1Lz2bvq2bqY7ffmJ3N80Qqtxu9vclq6zYRreVy0dY9YUMCo8yPGG+LWRpOWh7wDjDEkk pGMFZmJXQxZac2EQtzv45Z+O3zR0KvoGX9w+TUcJ+AsRQUSfo+2JUvaDqwUIZikmEkF4 Z+z57/wKEQ3LVjQR93dXJH9qg+aGPzjGyWDMyFpXVIP/DI9rDNWWm2uDEMR5CRKfQ+Y0 XARjhZId8IbNImc2orsZpoL7T7a9ivuhr+FhLD1lv04hXiCFmv+UVkC99ZyCrZX2jLYc GSWw== 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=0qhDOP6JKRcFt0fs0yiO/PFWIOk2MHra2nPZAr9zHEfSkudgPffmXGjE8TECbpy3Kk 4OX2FXIscIE1o/v/fgXS5jr+XS7L43w4gtunGbx1VWFqWpe+YfKQ7mSKmRpM3m9/U0Y+ OUGrBpZ51MDNp4+c2eNu9Qb5q64AnJGaTfnsm5aDdn9pReXNj86Dt20ITS3PuYggrH2t Y50iUjYwAz3/O1NThRBOjwrkUFEQQrRVcpKAfSbsvoOUFKbef9774qGihVsyHlQ2iulR nmRMoTYskwyCAq8Iw2RrBCYGu6MQY/2dZhEQKHovgxOm3k7o+S1QlMZZwuULRZksuWaM q8Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pNEXcNKm; 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 i1si469199vsi.331.2021.06.21.16.31.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:31:25 -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=pNEXcNKm; 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]:41146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTO0-0003mM-Dl for patch@linaro.org; Mon, 21 Jun 2021 19:31:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC4-0000nO-1x for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:04 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:45823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC1-0005y2-Pp for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:03 -0400 Received: by mail-pf1-x42e.google.com with SMTP id k6so14835634pfk.12 for ; Mon, 21 Jun 2021 16:19:01 -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=pNEXcNKm6aptkswF3Q73rG9cI3JpXZwfoVSO8pQXypxuhKSlGyEJUoiLWQYz9+cEXx lSrN1R0LuzUxoDkqAnhSDBhXR6sar0/G3YQ75tZV1WY0gGxJ1h+e2zGLqNJwXZcgPwo+ Duw4hkTkmI/CQkR83xBmKte6cR8y8YtNnstArvi4oQVw3qg3SzvC8nnNIb4Uqf6sR+K/ 5Q6TxWLLBQywfnwJcOjiwPQdsw9pUWoNlvHuYmd1s7YM9YZYnjXZAX0StELj/ynzLIAb i7/boKvEXPPCEx0kJA0MEdQjLgF+tQc4cnsZfUFj7oEjizyZlipAoES8i0zzLggKYAuL 6PFA== 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=R3UqHE9Voj5INpA8vuLkT27R7wla6GQCShaAW3uw0V3+xwAvuQlzPRu5sJM1/xXQ7E DjFuDWly9bO7+EXDgX/h8toKl7OEOsn3Ff2JqBEDJ0gVHWgwt78aknuXQt85pLzXy1tZ ZcdgYJvd0zzA+3RoBLldbho0yltk1yexAkiv8FBg8HqfGiYqpt8IjhMMIDRMAwd1/HjH 17auZU7NatH4rDFfETUQJZekG+J0/rBV6ffCSXl7Wr1sVGwtuTh292Zo6NpqE7CtS2DG TNp/i6TxYw0jsnamQkOThrJ2wQYMVmj+EoO3VD2Plv9FPDosXq5nkGrSOKIruRwYbsvY supQ== X-Gm-Message-State: AOAM530fCzgUedJ43GIwlHVFnVKcaL9CIcANrM6jXZZOCBf3Zxvs65M5 dSKwwjMYPCQBNS3E7n6vaCYED0gFV81qDQ== X-Received: by 2002:a63:f20:: with SMTP id e32mr156047pgl.235.1624317540290; Mon, 21 Jun 2021 16:19:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/29] tcg/mips: Support bswap flags in tcg_out_bswap16 Date: Mon, 21 Jun 2021 16:18:34 -0700 Message-Id: <20210621231849.1871164-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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 21 23:18:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464635 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4676507ejk; Mon, 21 Jun 2021 16:33:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGoF3kqsRhIyByOAmpLHzHmi/eleKDaI3fCHQUFthLJyzVjsrQu8wzkJZfoLiFxvDS0Kc3 X-Received: by 2002:ac8:51ce:: with SMTP id d14mr958875qtn.171.1624318397854; Mon, 21 Jun 2021 16:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318397; cv=none; d=google.com; s=arc-20160816; b=ZaxIfwpRKf8VTKLykN0FD1WvzcED2j4sqxAxIJ8zogAPCd3816VIkgIRyI3EkMyp2u 2HqELj/SMQZNMyoc4bAs89FcAZdVBCSNVTF0mw1dVph0v49WWJMTKFhkBlV2aXh6EboF oceb9CrK/dLxnYwMsa8+xJteruwnaPYM+7if/eJKlcnXqYqP3yy9NLUxr7Y/wLF/nf2+ hbWu4HHkP5D/eFxzdzbXPcxPFpI4B58hiHpYyI9bTgtQKOykPxIaOcrgqdcGGACjm2f3 pNCeIP7FQ/LebzI9CJqepnfEMsZ3nl9Wi9lFJpqj32K1AOvBVIS6Ghzie6zQVUG3GVa8 sTfw== 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=R7vlWNJb0EvHWAgR6RBcIjajLTS1WBwQ0nnET9RwevY=; b=PUdYbfd6Z7p8unXPVOGEFuLlCN7v5lj3BaTkxLKI58P+9dg1Jrrwbu+ZDuA03AxEJ/ a16Jzi/qiO4YpsSrO3WghWDQwafJSmymrKVs/HiLYXiFy5/igfG/dPezbo1uPMAeq64+ PpyOuA2LhMVEFl1Zo0jQ64Jgg6FlKorsSoAwqwW2OZECcS/8LZmUBtfjL3rsUav70Lwm 3oVjf27YzYzH7lO+PMDUZxd4xCesOS/LelkNvby7S/16eQZR2N+Al4a2ih2OKhSALwpm L++PvHPNqkJuStcDj6fTQM13sZK+T9yMke8Vlbm/d605pBFat/jCOwQUJB5AUAuFbTM0 qt8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Oeg/eoeM"; 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 q18si357597qtx.254.2021.06.21.16.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:33:17 -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="Oeg/eoeM"; 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]:48498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTPp-0000DI-43 for patch@linaro.org; Mon, 21 Jun 2021 19:33:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC5-0000rO-5b for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:05 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:35354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC2-0005yk-7C for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:04 -0400 Received: by mail-pg1-x532.google.com with SMTP id v7so15406549pgl.2 for ; Mon, 21 Jun 2021 16:19:01 -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=R7vlWNJb0EvHWAgR6RBcIjajLTS1WBwQ0nnET9RwevY=; b=Oeg/eoeMbmnfpX5YDtCnsDREhGNKjgDwI7FWvYfBTlet3K2k44s+d/ThPEubRN0GJx YBKB7LE6Z4IrODXKjNtVHXpjfYkd+oYkuxciU1dN+80cGPO4ubAWqxI/E//xvCoDemw9 QYq9J5M5APDXQBM0ZSOlcub7qjImaS6RUxFdwQfkK2ecz93xDv3637AHbM6y5xlhksC9 zpg6JnLb8DQwrXlE1D7gUVhs64WrSx/lpUtQQogMcxiaOKOkK6ZDfb7QcK9u8Dojp9de mDAzW/5RrgSr8p0j2HyInQBaN0dB7AaYzdEbmT4AGO5FlGNXoL1oA/9MAzQ9cfGhBe8f 6XMA== 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=R7vlWNJb0EvHWAgR6RBcIjajLTS1WBwQ0nnET9RwevY=; b=DD+CdegtHKw8X0t9jIXQQDBfLbjfjpSWhNYcSAXszxxi/HY8Hx0C7YW7bREHUBnHkU nQH36yJ5EsY+DRcqOeCZCcAad9Z38Lax1tVYzf6lsY0vv/QTtmcHwq91N5LlBS7q3qxB sK2w2hCUuRN4343Ruyt5fA+gILm0w2/PiAkoS3keH/htxMLBbKVz3ykrFCf7omWa1St2 a9Ym34dJqoPl+1IDWQyDBvFxtegHtgY/mc5oV3tQIAbi9aMBE93ATQARKK8PVQsLe7xk mqf1AhJQMRVxkjzJVeUI+wpFae9nvaHfYHuGL8UZccYzN9s6YjbsJilLxAaF/8W6Y80i XpKg== X-Gm-Message-State: AOAM531qMu2DIq3trNwZLC3DKSvLf6NM9xLEtT0+KMjQjXdYkZqJ48HM kvGjwpmFb64qURDs5VwEDOhRvbuuCPwm3g== X-Received: by 2002:a05:6a00:1acd:b029:2fb:81a4:b06 with SMTP id f13-20020a056a001acdb02902fb81a40b06mr596029pfv.36.1624317540742; Mon, 21 Jun 2021 16:19:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/29] tcg/mips: Support bswap flags in tcg_out_bswap32 Date: Mon, 21 Jun 2021 16:18:35 -0700 Message-Id: <20210621231849.1871164-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. For mips32r2 bswap32 with zero-extension, standardize on WSBH+ROTR+DEXT. This is the same number of insns as the previous DSBH+DSHD+DSRL but fits in better with the flags check. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) -- 2.25.1 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 21 23:18:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464623 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4671667ejk; Mon, 21 Jun 2021 16:25:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn+osOZ9DjD7pgypKoFsx26/jwhibSkh4PPeuNQf3zfXPcux6/dog7ihypIBWw1MGDaUP/ X-Received: by 2002:a92:a304:: with SMTP id a4mr504811ili.197.1624317936904; Mon, 21 Jun 2021 16:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317936; cv=none; d=google.com; s=arc-20160816; b=QGx+rsEQSrfRMXrOpyl9iDuyTUSYe6W64TrzTxiHG8/aFar/1pDZiEPhAd7P6SiLbR 0tmupKVVrd3Lq5eLOrgw/JvHiX6LVKfzAl2eMjcCUBjSBtTDAB6fjUW5oE9Vfz6TcMAA 2UpvewCgiv0p43iAC/easilW4xYrhxhy3BRNwkenmTnlhIsuSdv8UV6RHtJA6iNNDN79 mb/8J13jC11HUANBnP7WVCjTOmf1qqvdxpgPhp1hHzkZxejVwz7UAKxq6DUm2PK3Xh1X jkG9hPg77OsBcqmDtBU64ARNXRp5IZYkYLH48rgBJkNjXk5GlfpWKkaPTDNYYnuGhA1d XtKg== 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=7EQJoFBdjdiE+zNRxauFeYkPJcHdyjHqE5CsIUBDDL8=; b=UjsfLrn/I4CtksOZh9lE1BXoA92uwdIM4ghmiFSUKyhoBMkJV/Olppnum6CjQDTHzm XVL0omZL6q7hq/Bc343NOADfovrETbbJqUBb9bx2wXC/7+26pUQhZCEWWlQ/OI+n6eLn wtjy0Gf262j/EudHS8jWCJNREsAVxpTrw6Qgg874aqjRMtDcEJh2RHI99o3hq3PqC6Pk 8+bC7KQba61O0ck1pGutFZyYCGm7uTJ3sHw/Sy4p+v1wgnTZ7TSBLkHWCYu1Ppag72yS DnJxQ6X9tvWGpPRBaoR3RTSftWu45BAJYj3oBChwE6JKFsp1/ZBku/drRDNx7As+RgX0 SSJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F3h0Atid; 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 o12si20169898jat.53.2021.06.21.16.25.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:25: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=F3h0Atid; 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]:47152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTIO-0005jd-8Q for patch@linaro.org; Mon, 21 Jun 2021 19:25:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC4-0000qH-Tu for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:04 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:53141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC2-0005zG-KZ for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:04 -0400 Received: by mail-pj1-x102c.google.com with SMTP id h16so10886229pjv.2 for ; Mon, 21 Jun 2021 16:19:02 -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=7EQJoFBdjdiE+zNRxauFeYkPJcHdyjHqE5CsIUBDDL8=; b=F3h0AtidcwQ89LR63MGIkvMPkhobY4HWIHC065KMqq6YAVUZnXQc7seWCuUZZTIhBJ CwdTIjq2jE6bR0QonKxkNO4LdPgK5iMEm7ntt9neQLiwuSV/hW+8OGrutBWY1duuzJFa eSsdmKWQy9cVTDiLc76Twjh5Jib2LEJ1s8MQvbtcNFx1HjxgKL0gVx4rdU658OiY+2Rm GACsUh7QF8IIFEpyepf8bXhiGT1KUQcdQgEh8xRQ5qnL/MlrvdvKDVBG4zCJehoHxORk dgrbNolMwO32RPgUnZooEEj5w4oJn5LTzIYEXsJ9LJEB+MKOEG48fPJm+7kkJ9GZ1U5t DUHA== 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=7EQJoFBdjdiE+zNRxauFeYkPJcHdyjHqE5CsIUBDDL8=; b=OzsiYAba/a1MmEmIBU+fjJFc8jcdnqWPUSrnOoX93s71lcRO1/kRcVIf14//s1DBQS TuX2cY2ankxIWAuU/yBfpkZvaqgEcb+3umSOlAouj7WvPrI6cjL/5u+9ahq5KBJ1BSvQ hDPn0Lxj31qakooGJpUx84IgoUsEY8+qL9VUjYR9q7bVUe5BrCFg3S0VA/5FNs5ge6DL CcgMrEGO5EUvVXC7ot0Divv/MbR5P/NeFKpbZyoPUbAo3l6khxyOeTmtb5dz7UX/7GLt FiiV3JG/pB0Hglnk+o7cS7hc8XCnjmhgiYe+4Y9fsVKTJzyBp7gSVSY78sHn1JMr1s2S /mWg== X-Gm-Message-State: AOAM531YwNVx5ycACsszkfPV12Rb2LAEIdkA46qqgx++pKmLoLkiSx4v f17mGOdabJN1+63t6n8ZUVsZE3uiIVTCRw== X-Received: by 2002:a17:90a:5401:: with SMTP id z1mr471491pjh.7.1624317541220; Mon, 21 Jun 2021 16:19:01 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/29] tcg/tci: Support bswap flags Date: Mon, 21 Jun 2021 16:18:36 -0700 Message-Id: <20210621231849.1871164-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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" 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. Reviewed-by: Philippe Mathieu-Daudé 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 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 21 23:18:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464617 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4669300ejk; Mon, 21 Jun 2021 16:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytrru33S80/XikVUw+l8UoSD4fcOjx6mIW6Q9fE1nAUiEmqPpmAY+1eteFBL4B1Pg7EPEQ X-Received: by 2002:a1f:194a:: with SMTP id 71mr17191964vkz.18.1624317717077; Mon, 21 Jun 2021 16:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317717; cv=none; d=google.com; s=arc-20160816; b=lQbObdNKQr1zwbQ4C020IGOvT8GRO2Y9NdyGNQ0KqwzDvTnz6Q5/R0oxuGwniM9f0/ V2+IMLYf+PcGuGtzK27n96As7R5xgqErxcCI9Tc8onvWDfYuJevQOpoKxSV60sQamB4s FWwmvqaPHdFudhHkDNWV66lC58BkHGL7A3Nn/NV3vkF4wYSv+i4lpmMIkUuT6LZnqeGV T+vR7DKxp6E8ncXLpnftN/9RsKps4PzHFOPX262uitKxNLkdIyx+vldso56chx4gzGHS pc4aQR6VYgmGcGRF0znGTDLbSWwaEq/JWNKsT02xOIsKppstCPfypvy25/VA1fVGvnQX 06wA== 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=DgN2RVC9T7a74NE01POCZUsNKgpvvfqPoLVvw7rnjlE=; b=vNxtVeUVHMcekOlGJ9+I9pTUL6P2LAcyAxZLrxjb2P4DN/treajQp8C3EG3gx2Bdf3 XPP+SLwJ2KtB9T3c4qyN0rhkOfgl1nCH7I9klArzkYI0714rY8RQ6NVx0KmtcCC+R2Sz +EVcPXLxrqhQpCHG5oXnE1OFncwoLnQd4D+RrECAcuofPOXLcxt978JNtLX8qAav9+du TyrdBGtmmP2d95NM48V5LMhqSNgn6cbCTu7oXRY+gcJozfiRFHTU+/juVw4XiZkblu05 dtDali3gjrpBjWao/Gr531ONSFtZRt2PMbmadNss5dRcecv9Rij2lCRjpOLRAeh4LTWB J5KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ye2+IaCh; 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 v7si14485693vsr.224.2021.06.21.16.21.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:21:57 -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=Ye2+IaCh; 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]:36026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTEq-0006kr-EU for patch@linaro.org; Mon, 21 Jun 2021 19:21:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC6-0000wd-M5 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:06 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:50718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC3-0005zW-5i for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:06 -0400 Received: by mail-pj1-x1035.google.com with SMTP id g4so10910949pjk.0 for ; Mon, 21 Jun 2021 16:19:02 -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=DgN2RVC9T7a74NE01POCZUsNKgpvvfqPoLVvw7rnjlE=; b=Ye2+IaCh4rLM6YJmP+3C8eR/l30VtUAvi5Jw8Fh87J8vPNgpSZkUNMIO4GnuqraX5x ITcGm5AQWRA9cPz6hx7j26yIbkCYqahOd795z5u7MclWcqMVFuFzzEry8UE0HNPOwcy0 ectSrKDAsdP3GrMKPINiZeTYFe6hXj8FvWeoUwBr3/Oggq5Y1TyLsBK+mHeYdRoraUg0 2LqAHL/qMtvgnWswlo7Zg8c3INZKs24jg4xSQyxcyZSHk5JnJRZjk2zDlsaFZfrGUwOF uYHQf7MFlZxY75/9C+yJStn1C3+oQKqV+29z5BcnnNEEd0emBEOifNEHvIv3d0V8WoDE EndA== 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=DgN2RVC9T7a74NE01POCZUsNKgpvvfqPoLVvw7rnjlE=; b=ASvtjwPUDSx7oYlRuoJb0Da2bG96pAyPWarL/yLVliWHeKfFa+1kX/rZPde9GfjJ5M v2VfKtR8i0/rppX4GY+VvAr7SRqQOjGpUkNgHZpYM7UWrHKh7rJEhxPr8Umg2+Wuqua0 PUa8QSKOyDIEmWBudSp3LslBB/5I/pcuBNrykM7ZiejXMAD8suGcCpYHJIoc8hRP4R2t vjGS2BIa0tOX0JtYhKCAhh/frLOetsgar7iR4YJfXzkCrHhiG0Su0FVt/x0xrLjoOeEF KH/MXPBXNIfBQodpongjMngf6gWYwVFSodke52Y5/reZM3p7kIYMhglxSbzRHHGht6SP ERFw== X-Gm-Message-State: AOAM532sydZbjt8uOieA0+/jjqEymk1qCHrb+QSJsHMvNuIJPqIPQ9cX xmQI7poPYp9VrSi4DoOm+WmJ3zUcMaB17A== X-Received: by 2002:a17:90b:33c4:: with SMTP id lk4mr642983pjb.191.1624317541901; Mon, 21 Jun 2021 16:19:01 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/29] tcg: Handle new bswap flags during optimize Date: Mon, 21 Jun 2021 16:18:37 -0700 Message-Id: <20210621231849.1871164-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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" 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/optimize.c | 56 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) -- 2.25.1 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 21 23:18:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464626 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4672771ejk; Mon, 21 Jun 2021 16:27:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw1+IR/srNtZ4n2T+ZyXTfKDNkHnuMWQStk6Ye3FoABe3iq/IOh3PYOxmJiawWUVo4r3uo X-Received: by 2002:ad4:4d92:: with SMTP id cv18mr19272131qvb.60.1624318054941; Mon, 21 Jun 2021 16:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318054; cv=none; d=google.com; s=arc-20160816; b=ntcqNKvwYtcZqZxjBenASJ20EoRbmnDKzCFCy2Vq0GvUjmLm4o3qXQKjcDBpJ+MH3K sMqvHzjvvH+0w4KTq6oLs6Xtb5yx1+6PJ1zXiSWqSVbIbITs0TkT7pSmZ5Z9Namx03y8 aGG/fKrm04IoYXnQI6d8tLiwVxY4uNWBNBMX/OMVe1rO9YiCzvWfZanaKIPrPdylkvB+ /cD1wAtcKjuays4/PtzJEY11MG/s50lL7ZxR/58qFDQ3qRRVSG9iwV9tGmLMbwxGWKyp IbUvO0vA8X2FbKh4dFypf+ntHXn88eEkqZ0cSN3J7NM4X9ULnOy0xo7GLH/QUsICiSH2 PQBA== 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=yZ8337siPDSPzXX1rARdvMMYOje6ZhNnkWMqkyMl180=; b=UCxzTrixnqL7ZulpZ1/Dlx3muN7oeBDXjTwDHoew5GSeM5mi/ZoAYp9e6/EtWnClGe h2NTtJ37m/UvktLDPZKICqg4g1XoXkq+Xkxbjkab1MyQ1L6hPr+EzhYXQhwpmSeBa5ZK orT3DKQqs6Ds9D/Y5LiqmSL+86p/fE6V1lJzRMyMf8sZjagf65aURISMlBFndzglfhK8 Nfwkjm/aIdDZE6DJ721t885IMGtqGi+NK4Hi6s7coBLupQiraLZPsrcCzrKcOfB8fv9I 78hkwtU2ktSVp0Pw95xTYIKp/DHvA2GxwBvRnf4L3UZ6yWG2jecLPbU4wxlNb5sLu1tU FChw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CtEh6QIo; 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 s2si9536372qkp.361.2021.06.21.16.27.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:27:34 -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=CtEh6QIo; 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]:53158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTKI-0001LE-4m for patch@linaro.org; Mon, 21 Jun 2021 19:27:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCA-0001D7-T9 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:10 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:43908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC3-0005zl-SV for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:10 -0400 Received: by mail-pf1-x436.google.com with SMTP id a127so4316497pfa.10 for ; Mon, 21 Jun 2021 16:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yZ8337siPDSPzXX1rARdvMMYOje6ZhNnkWMqkyMl180=; b=CtEh6QIoCcfASQrmuDzdA8+BDeZQwcYOXjPaoHI3U6WmDmjA+QHSTVqC6fPfDCY2fY URAlCis1kd8gIRy88BQEILjcYGO7rLBeLkOAR3Kw3noTrU3qtobeqkduYrIi2mgeSsPX +uQRCxg7W8XPBoyRV8croFreq15y8ALcfQ+WgCKMPCPTPHi3SM7w/O7s5GYV9T+lAKGF 8AsPeWJ4y+oTj4nWOdDWflUr/J1PBeB+qUMJw1LvuHuO99ZKWOiQwCtUwd2N2gIpvR7g iYxZFomLvcjtWQ/Qxldluf9Tiqu4P+3riZ7jvR5wQ5cBpzMEyWwyHDVR0bKs1I9WZKSy epCA== 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=yZ8337siPDSPzXX1rARdvMMYOje6ZhNnkWMqkyMl180=; b=jv3J5UJtheW34ztc7n25C7A3V0I8LZgvMbWuEURY72bsn8EDmZ6VK33sFHuNcIhV5D FtJvB8g673eE+JB3n2BNUe21WXX33X6GV8dvL/R1yMz+WXpEvYrC4ZIomfYPSYkyGnxM e76Iwq6O5Oj//mxqnyZZ+l4TyWAKA2+cReBbbRT/5ueirZR5THXWxM8yGj0cnOdhrRNm 4qdSnvtnjKChmdLADh2efqJhfNUOhEEdMvXbP9NYhYBkb8X0ai9md5edIfPYnH784JlQ ttoM0W7Andz/Ws0KPSON+ftENIs6lYuuloM/vBxGCRBIiMDBTMWEQOrJytV+pI3NYZu8 WpyA== X-Gm-Message-State: AOAM532hCOc3YVHy8OQBbw6jHcN2wpn+zNspPEFU3Qb+dxQLVRNdmOBt 5XygnJOdi00ldfuLwhjiqb6BQYW00y0lHA== X-Received: by 2002:a62:7848:0:b029:2f7:4ecc:f14 with SMTP id t69-20020a6278480000b02902f74ecc0f14mr566528pfc.77.1624317542503; Mon, 21 Jun 2021 16:19:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/29] tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64 Date: Mon, 21 Jun 2021 16:18:38 -0700 Message-Id: <20210621231849.1871164-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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 , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= 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. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé 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 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 7f74d0e81a..f2641a37ba 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); } } @@ -12453,10 +12453,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 9e2cca7707..669b0be578 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -355,7 +355,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..949cbf2f03 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, arg, 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, arg, 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 21 23:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464622 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4671313ejk; Mon, 21 Jun 2021 16:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3s5mmdKn9Hnt+lcj/1ap6qMKf1Nv2l3YUPbSCUl5qZRqzlPGDyfYAMv3lzA3HGErR0HBk X-Received: by 2002:a05:6602:2145:: with SMTP id y5mr417776ioy.4.1624317902695; Mon, 21 Jun 2021 16:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624317902; cv=none; d=google.com; s=arc-20160816; b=gSvn8C5mdK2suBPU+rB9SOUrf8V+uv2yf72BoVA/dtXKwIBNDAsUyQhdP8zx3f5zqs G+LkRwvCd0mJk3/OJrwPNaoQYmiZ4jXG7srKDOY12Xvqsttfd56UmDifZSeD2XVd5C6+ SffJ9faKzHL5V0nIDLH7GKCNJVr2lJlq72Cyi/X4/w9O4HoFgCxp1YpWigkySQf2RqV1 AVBZbeEHW621EfNl2Bq5g7LnPRQp2Wj+vkKNK98ZbaBL4ahfjpbFV3bwx3FAafJh3Rwy GEKMa6l5ah3S/9E9R2zcFDnfjRm+J5+fSy/dMLZ+DeU4mBuoZzoRZ0txMLMKkYcIu5LD 27MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=bHJFwUS3FfJXHqedWq5vTDlvfjQvHpMdkZ+CVZkiqqioPgrYDGCZ3KyvZjmAz1qdF/ PnR1HCYZF5stW06l+1T2dQL4ppCGjJnzRaz7Ruigmqxl4fDg9fabcTUUBUvHbbtivPqT I4BrMYQ44FcQJyJ47s9aVMYSd3tqgkakozBZb4SC+cIU1b43H1YK3SdipdSUqgnJbhkT YCryhaX5Nhuax1M6Cj32icKnlizm34KWbiWHOGwc+xKkGHPzr80Hwsw5W2OtYu788Pce VT75ZSh8AAapSURGyAzc1CsgRiMWLouZjYAh5Wnh9AXKcqDwX4m7V4cQbeqfZuKpGa/y eHNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFda8L2q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i130si8572539iof.93.2021.06.21.16.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFda8L2q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTHq-0003zB-1Z for patch@linaro.org; Mon, 21 Jun 2021 19:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC8-00012M-3j for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:08 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:43978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC4-0005zv-G4 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:07 -0400 Received: by mail-pg1-x52a.google.com with SMTP id e22so9217604pgv.10 for ; Mon, 21 Jun 2021 16:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=oFda8L2qJhd/CqoTHlA6OVWaudHu99+9rYznhORIb/RYN56Aqf0MSjlfdfVzzAAp1f sfs+1XXW3/TMyURrP+JmUWlKwJVpGAd6LwLJk8XUHdOJuUCohzYSW4Z6N5ASLKAevYBV IVoHlfuYkBN2D6pv5vBv0qaSncaXMb+hJ9V5Ho6vGNttIWN/BA13sPq9CtUxlp8eYoYt QWLt6gykjhZ6TNYn/G71ET6/rV8HSy3iYg7YG5DqQc1jPnSOVOuNduPmNyhrf5cLqWKk 6qetOMNGgOR2+/ifK7VBdhUdVjQ4+6A89KwJwe42fTyugYoPErpwfviTlYjHZf1ncR67 53ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u/ejmvPg+vmROgq70KH/tbjTwCCjsvsFjg17XJyJI/Y=; b=SPBhWxVc54/UdrLg6punqMXGZpO9g6OoooqKR2EyUQb/C72mqUwLJhPQLi0f9hLeBz jcu/SxGerfndC0LE/TC9MYPGOgoCgF2hVK33rAOTpMwPiw/w8KRcNOqb4tGQBD2S20Kc y1NODFRMn3FQc+FgNxr4JAt/bbgpOHyKXuCNWDb5yJD0MemYgdkOOAYizW8C3LokQB2G PesnrM2QKrDZN+wdrs6wqogiIUK58bWUkw1h0IIShKCWEHvGmxPKk532P45QOR9kqcXd GUSy8Lh501Mj8YaiVuqWOkGrMM5QJQ07ms+naBrfv70Q806QlGn8Xhg3eYq16ctjLrZF jsmg== X-Gm-Message-State: AOAM533+XLosn5P9tTFLldPIrYQ7TNgs7TDHct5Yi+q4KzvwF9oo4NZn sGg27q7mjwzAal7K2wWjj1cniG1jtQJyNg== X-Received: by 2002:aa7:8e18:0:b029:2ec:a754:570e with SMTP id c24-20020aa78e180000b02902eca754570emr603287pfr.38.1624317543161; Mon, 21 Jun 2021 16:19:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/29] tcg: Make use of bswap flags in tcg_gen_qemu_ld_* Date: Mon, 21 Jun 2021 16:18:39 -0700 Message-Id: <20210621231849.1871164-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can perform any required sign-extension via TCG_BSWAP_OS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 949cbf2f03..0eac2d1969 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2876,7 +2876,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { memop &= ~MO_BSWAP; - /* The bswap primitive requires zero-extended input. */ + /* The bswap primitive benefits from zero-extended input. */ if ((memop & MO_SSIZE) == MO_SW) { memop &= ~MO_SIGN; } @@ -2889,10 +2889,9 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { case MO_16: - tcg_gen_bswap16_i32(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext16s_i32(val, val); - } + tcg_gen_bswap16_i32(val, val, (orig_memop & MO_SIGN + ? TCG_BSWAP_IZ | TCG_BSWAP_OS + : TCG_BSWAP_IZ | TCG_BSWAP_OZ)); break; case MO_32: tcg_gen_bswap32_i32(val, val); @@ -2965,7 +2964,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { memop &= ~MO_BSWAP; - /* The bswap primitive requires zero-extended input. */ + /* The bswap primitive benefits from zero-extended input. */ if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) { memop &= ~MO_SIGN; } @@ -2976,18 +2975,15 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) plugin_gen_mem_callbacks(addr, info); if ((orig_memop ^ memop) & MO_BSWAP) { + int flags = (orig_memop & MO_SIGN + ? TCG_BSWAP_IZ | TCG_BSWAP_OS + : TCG_BSWAP_IZ | TCG_BSWAP_OZ); switch (orig_memop & MO_SIZE) { case MO_16: - tcg_gen_bswap16_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext16s_i64(val, val); - } + tcg_gen_bswap16_i64(val, val, flags); break; case MO_32: - tcg_gen_bswap32_i64(val, val, TCG_BSWAP_IZ | TCG_BSWAP_OZ); - if (orig_memop & MO_SIGN) { - tcg_gen_ext32s_i64(val, val); - } + tcg_gen_bswap32_i64(val, val, flags); break; case MO_64: tcg_gen_bswap64_i64(val, val); From patchwork Mon Jun 21 23:18: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: 464631 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4674029ejk; Mon, 21 Jun 2021 16:29:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT5BqiYW7hYKH6IwdFWnR0VHT+IgtuW82G2P5sJtzEVdcEUxfdH0WMuAGdj/e3ytVLdiqe X-Received: by 2002:a05:622a:14d:: with SMTP id v13mr975775qtw.119.1624318183912; Mon, 21 Jun 2021 16:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318183; cv=none; d=google.com; s=arc-20160816; b=NsVbDkirUwFA+CEXB3Myb40VlzgpRS0wBbFsMmr/Rcqh9o3/reydprCMvN2wP/XOCt KbK11OL4894Dzx8oESefeMt0ofv5cI1xMtSRuozSKtskA7Xao4Cf4Etvr0Kcicx0wvFL tc2qn3fV+DTu+i7fmq8opCBZ4zCxJBjptzYYk/BZVOaPMEpGnl9+eP21fZG0aJIrhjVt Vq0uD8y1xohSFvMyOPnpLAdxVu6FrYa5+tC4W8ibZEz1py2BZ9c7qTEAjZq/cFoxCOZN gbB1YIMOsDfaUItoWzbqZZzVrq9VFvN92mJu2V78epjqkY3izl3HQWelLcDCqgKE61sS 9Jbg== 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=hFW7/uteqhUz14as6VIJ+oMkuxFCaj8xI5hXiJ/YKgI=; b=ndqoIAhl9RyJM0tcAaSCzluGJL5WRPtdwhefjHzsjPJ5KiWzPf8id7Jtfty65pe642 ZqJbEBVRh70nYCgfDSDGQ0IUuiLTMRQrTFF0GctnJ0SgH2bO2hYVM1rXevwxUt7OK3JX SYnGVbFWc/QPXDtcoGzIRMQWWfgCJxFF/Cy7m3xaNs7UbwGI8Aw031+5oKCB8qm9RDVo Jlt5LPtB7g20aNk47p/e1NxKLv0L6iNLYlU5QpfBQhc/f2JPiBXuF8jK0gW0+qOHmrGR fAhjIk6233dAcoL74N3edfyOo1FMQlFWxB0gG2bHZDpTr1C+NsyqDIBBgPgIpfrtjrWf qgFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QWDYQFI0; 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 g19si327528qtu.350.2021.06.21.16.29.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:29:43 -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=QWDYQFI0; 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]:36166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTMN-0000MR-5p for patch@linaro.org; Mon, 21 Jun 2021 19:29:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC9-00016a-8P for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:44627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC4-00060Q-Vy for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x22so7868067pll.11 for ; Mon, 21 Jun 2021 16:19:04 -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=hFW7/uteqhUz14as6VIJ+oMkuxFCaj8xI5hXiJ/YKgI=; b=QWDYQFI0LBjXyfF2Ce2krLlYi+SZY3ziVkdfg0oTOOeV3UxLRi/FJNovh4TVfRdCEP 1MqXLXTz7G3qH5e1Duy2wvYoHaPJGrjJfNujfMwQKNBPosgAJRCJJS84RTwjctSUwW1w pE5rylffjwUvCZHVC3EoEkgK6GSe7Ytk9H0LKTzpMPIlhJO0yY6Wydm2A6ibXfqChNEq AHP+LJHqnmBegM2AgbpleuIFM5cz9g9tCNwUD/GzdXaVfF6SxEygW288EL2Nn0NhPs9Q 4L1/DQDoTmf02aNh+12rS2/aWlzcnqfDjyEL8UFCrWEXmdYizXg1eGnwk5D4vpCtFSeE hd6A== 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=hFW7/uteqhUz14as6VIJ+oMkuxFCaj8xI5hXiJ/YKgI=; b=S/DNEM0pqFq6DFdOxxhDa7AUZ7hoEen+EvPowUw5oZi7DsjYjnRmNRMEm9YK0OsRvT cvdEDBGyA3WTpool0N/yxCPstG7s6+axrxE7z6CZ+MvaiMoRLH9KPnWxFDHDMNnCA5st f2kljUwmpKwQAvH1jp7hZtqqDMqiraxGkhnzj688z0dhO88XR53ZDwek0GOhmtOCn6RG b4HRHDEnuFYBvdelsNJ4oH5jY2Fg/QsUm9+h0qam78cbw9fpl+MjEyREbsdNxVnTjVtu at2GsFBiNVLCIOWHnp30fVSbKf1hQFfb408HV0Ng/f8ITBnun8QRn3ZURmHsbqg1BSeP AcAw== X-Gm-Message-State: AOAM531XYMyXegu29UTDCcmudR3ELrPjiwWok9LrwIZgsEU951r0Rl2l MEnImG+IftAOBcufwIT/mBHMP8zqfCPtVA== X-Received: by 2002:a17:90a:de07:: with SMTP id m7mr675142pjv.100.1624317543688; Mon, 21 Jun 2021 16:19:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/29] tcg: Make use of bswap flags in tcg_gen_qemu_st_* Date: Mon, 21 Jun 2021 16:18:40 -0700 Message-Id: <20210621231849.1871164-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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" 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0eac2d1969..44d711c0fc 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 21 23:18:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464634 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4675884ejk; Mon, 21 Jun 2021 16:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqQUS5gVAvBfaq/gG1TDZphLneQ9yfLCXuqTSYu3SgOYSpcbnWmO2tl9rhEKLjSI8S+KfC X-Received: by 2002:a1f:ad4f:: with SMTP id w76mr15115142vke.15.1624318340766; Mon, 21 Jun 2021 16:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318340; cv=none; d=google.com; s=arc-20160816; b=ccNrwCD455gGzGz4thpIaxrUXN9PpineEONZ8OmWFZjF8NAbOB4SvXYkGDA9WQWEer zLo7L2PoidFtk4n17c9ovybrCTVvox5anrkIQd8VAb0nJlWOMiY1uVMb0dTHLeO3piV3 F+Bu5bJcgYE4paJkh6cdd02sutiA8mp5zR2uvpjawjiBUlDo7HQcY4J0uB7rl/LzLtdi zEufqdk0YFNgUCx6RDqsT2L8uVF43QTgnwskSnhzLUGZ9ttsSJ+RH5nca/hnEKNJnL95 0JQJcCZxwpm4uysh1kp2lYtIT5Nu0f652Ru1KNnWrl90FcQoVLFcXGpc6TMSNiU4C/vF UMxA== 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=jZ+vu44B3MA2rQDPHlYV5+XUBqzkPAnWuZi1J6wYDao=; b=WRtGHteri/EL7fqrEVeJyTDx1wv+HTAt0Y4uCgnwMqUygYp6l5xt56VqCF6883SRlC N9uHsiYQjxfnzU9Ht2LT7jr/Dd6e21UVfAmp2pNTHnjE+0Aa0aGue8W8b55/k+1yg1W4 Fz3Br/AmKbeY/ec8weOvTA364CfvuZPxhUDOHa0Ua9KQyCvif/TB/ELZVVMuBK/itwDs ktbdtFPotHyPWFjz9x9ZKDyY9CLq1D9SPfp8kkuAb6oCNC9K2dZyAeyGD4jCwttlFQMn b3Tf7n78r61dPjMlylOmIBLqx/tvHI5oCYAJaKw0WLJBTLzpgBiXr4OhTbTU15Csmgmj YxzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fvRUQUEx; 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 y9si526155ual.28.2021.06.21.16.32.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:32:20 -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=fvRUQUEx; 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]:42288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTOu-0004VX-3L for patch@linaro.org; Mon, 21 Jun 2021 19:32:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCB-0001Hc-U3 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:50707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC5-00061h-N6 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: by mail-pj1-x1029.google.com with SMTP id g4so10911004pjk.0 for ; Mon, 21 Jun 2021 16:19:05 -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=jZ+vu44B3MA2rQDPHlYV5+XUBqzkPAnWuZi1J6wYDao=; b=fvRUQUExehKyuom6BcYiv/jXENph20unEftdPqTkJmY+tQU7NAi6QvQ44OJK9bD80P QlpaCWgryZ2oTJawcFuHda1/S4TzN3l3GtSKlkP2ozzsPlTa0URHc9H+IbaQmWsWJQjT IAhNtqap03MdzfC40jcfD39+02U9we9dT8yspRK/y3AOCACawEQowHWLlArXb3Jw0RIl 4Ak0oBvygSjDgnFzx2Sy2Fi4gmawuux1czF+DhwL80APXqUS812D7Evow7N7vuxoyBwJ z27QSgImPDeH3pHegrb5w6zZGCBBNcHW+5tbNXq1o96L+UfUfcestqPvLMKGPTI7GhGX epAw== 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=jZ+vu44B3MA2rQDPHlYV5+XUBqzkPAnWuZi1J6wYDao=; b=qI6khg2ASkpAMCtkxycxu5eroYYxqUCm3pEFf1YaYu7dIV7feAZbJVvk9/Yjc9gemG kb2A2SvMI9aNdvuX3yoQSmbtueSQscBUUxFY/W/xoduTK5JPOy2Q8o88ZQAH15WqEavf jMwgybNktjqlLYMXUQt6tU1fRs30bwGNtOyYXsGUdjiqlqbd0vtmJMdVRsdqgIBtGZ44 ACvAwaMovanrg8ZL2VK00pcP0Z7FHj7G+AUixCaRReaB8JHL/ly9yCcWVzLd865HxtnQ wtk6ojCQ4GRPvnHN6Xg7vmfF4fwx4b5XfkF+d97Zu1DrDBBNx0qk9t5FUWvcLwRGlW9q uhQw== X-Gm-Message-State: AOAM531GPVx45YGE+Tis3ronK1NpDO7ZhdkCA8HtehxyjDze52tctAT4 laSj7JHc+moaObe4GzHFaIuDo9/t1kISFg== X-Received: by 2002:a17:90a:5408:: with SMTP id z8mr672061pjh.144.1624317544360; Mon, 21 Jun 2021 16:19:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/29] target/arm: Improve REV32 Date: Mon, 21 Jun 2021 16:18:41 -0700 Message-Id: <20210621231849.1871164-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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 , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= 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. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f2641a37ba..304fd3d370 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 21 23:18:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464633 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4675192ejk; Mon, 21 Jun 2021 16:31:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzk4Og6NwpJ/SPfD7bI97NGRizqLAiAi4nx07++i220M6ik1CyfwNXav95zCqE9SmxrDdL X-Received: by 2002:a17:907:20ed:: with SMTP id rh13mr594460ejb.137.1624318288735; Mon, 21 Jun 2021 16:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318288; cv=none; d=google.com; s=arc-20160816; b=MC1mXVACWc8Ynspq/5euGrUnSFtZyujHMKVSNvn3aFj8toGEpmv+vx8fKkNJNqOZ7b f1yYOxVu50ZcpKhEDUGHyUcJU27Y6uCRXbCR/HOKy7ZgrTykz9Aa3lm6GK11IrRJHGme +az/kGl70eGhxq/8gt/W+G9gMoFsqRUmQWcUU7U9BbJ97KfUa+s4jR9CjV6ostK6/Ffy /CgpFE8wK0xoYSIlszQH+S83xbgW6H/ez16hB2N0j1ORnPTRHlsHZqVV3Bvk/wOypB5m pxdKb7m5CklCKoEDsT8W/TtLF+oE/kle8vGm7h/Vd41lyqAGSy810Brw55jRDlHq/0H2 UQ3Q== 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=UelU97hoekIGhPpWADV+x6IGBUO6uugBAMvKK1hARaE=; b=wdwdJ7Tqwo3JMQKhf/gtfS3SbRKLhpOruLS/Lg0iW0E1223V0MYzFDwWUNf/k3XL55 0dr4jAP/NoZyfO+dz1Q8D1OT7Xk2AtTswijAP1qj0/h8mY8QkstHuPI1SwMwTKEV0m7F e9oOYJmgG6Jtocl8GThYTCIAbY9kqxXn8rqjAuFQnKdj/joKlCPzW6CGA/opLzoac7Jm oln0zhAT2aChEHLokOzjN23xekXaX1XHtsIvzbZjNqa7fxt7OGcM9dDY91zS8TLOb2Ht y/4zFBO1lAsCGGHI+7iOSQm6Y6FNYGvU+C+dWUYFxglwuEpwlo3NfxYnXB0i6ykDxgQH EXpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HoC+LvK2; 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 mm24si613888ejb.342.2021.06.21.16.31.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:31:28 -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=HoC+LvK2; 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]:41490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTO3-0003yy-QF for patch@linaro.org; Mon, 21 Jun 2021 19:31:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC8-00013r-Dc for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:08 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:34449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC6-000628-Ak for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:08 -0400 Received: by mail-pl1-x62f.google.com with SMTP id h1so9421440plt.1 for ; Mon, 21 Jun 2021 16:19:05 -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=UelU97hoekIGhPpWADV+x6IGBUO6uugBAMvKK1hARaE=; b=HoC+LvK2qtoNdNqgwWbtZ0OPJa/tz/uewc4kMNBFoF90/B2S4vqfWOr8mNp/rYztHs HkXuCjdH91or2hJpqF71a/+oqxDYBMSqO0EeqHvppjK5DSEYhEVRw3ib6hB/nA8l6EEH hzCAuX1mlPNFp+8g1yH9raF6TAvb9Z070cRFF58JZsd2kWuXP6pW/VSNckRmk/eZYMKl Bu8Z5SsfIArJRm7N4lvN8Afbvs8zhV5K+rimqPvf6fltzd6x4rZS0TumMg4vzgrO3cP5 /zProZb1td5aH5AkX2zJlcKMnzqpXZrp8gGxrspV7PGe0rYuX7VAAALvz9JR4wfCnMFd H47Q== 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=UelU97hoekIGhPpWADV+x6IGBUO6uugBAMvKK1hARaE=; b=lX6UQvJlx20saKT9472iZhwKNkSHlZzmdgJYL1ykd19sPRDjioYaA1UCS09ZQ95ohn B4vRJ8UThFRjKTaZPnNVWXTLfZRiE8w96ZnBO5Qx982gQbPKY2Dv+5y+xXVRajn/fOAS RJxWZGhCrS0SYJwnvCci14Pty1c5IRZ4ZblfALN7BaHDKActcF1sjawjjwaNTcsc0lsT bP3GR3G8+MdlkPCRsCF6a2GvacQBnFNlMGc+czi9gkbs2i02aQqAV7hm9zvjPKIAYldX 2nd7VYaMADt79ZgwK/jAtiBJMB6x01/W3KLyYh4d4yqe9Y6vk5CpmrDP8PtAQyEXM6XO mGng== X-Gm-Message-State: AOAM530fvk7Pp/ewfPzAbIKG7lnQ92YhDP834bCyYAElzI3ZRtDlmU7g JAgIZdoGckScQ/PO5/9LatRSzXBV8OAWdg== X-Received: by 2002:a17:90a:f293:: with SMTP id fs19mr619640pjb.149.1624317544935; Mon, 21 Jun 2021 16:19:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/29] target/arm: Improve vector REV Date: Mon, 21 Jun 2021 16:18:42 -0700 Message-Id: <20210621231849.1871164-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: 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. Reviewed-by: 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: Philippe Mathieu-Daudé diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 304fd3d370..1a40e49db7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -12444,12 +12444,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 21 23:18:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464637 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4678053ejk; Mon, 21 Jun 2021 16:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGTTxg+uhdYfh/krofSuadL3Rbgi1LzU5h36+XtrVA6F6Fxkh9JBB3bQgGWOLn2w2V6LkX X-Received: by 2002:a67:c09c:: with SMTP id x28mr19859125vsi.9.1624318533715; Mon, 21 Jun 2021 16:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318533; cv=none; d=google.com; s=arc-20160816; b=yZWQdW4n7OIm/j/iKk8kFDK0DyK4RkcKF0GVwGvqLOBtN2iYrEEVQXqI9zCHX3Oe1P TyLDEJExMFxlBp0hZNpZa3pIP5lOQWh1KsDzwbJY+u0tgugz8+amzDXdG9lU7Dyip4B8 ei3O0Id5qIiMX+tvPUuO/OaW7MyxyqXRQxc9y4G6YZaE3UI6sjl8HVWvVsSmaXy+bAHw Ld3FxYMF5WEyxLxS/mu5irO25HX3rkus88609FhRfUy4+MasajOYk026hckkOjOvJpv3 9k+ZY5Z7HYRDqOIJc0tsWmU2jnBBYJ7BLCEoDQJ0m0crFyletbAtauq3XPmsPp8KK/2n cYsw== 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=ziCUNw7iMfXxhXUy1AbaM+Ca/hJ3SGJZ/ldvQFuxiE8=; b=v8kXQYJpyVSZHKB18heXGYTWipinCPhiqegnwZIiXf+xUc7vbfmlO9OUneCpajr6Gm mch4LBDk178N5MdhE/tSaVdPGRA3XV+86HyQ4VbfWshg5jqfMPcoBMRpjwv0wYL/R+nW kh8Q6PFxh+Vxwth8OZsbfMv+sNIpgMzySaMAurGdIroFFX/7DCBb+Mop6jyFXxJvesdW yUvt5KSsETADU01yYPn2+95ykNZFwkjwexTSBUTLwt/rZURoRAGTyz0fK9gJ1sCae2Mi dmin4Ax2eGw+R23ze1/16YVmO0DPU401fcditmLeTlV3LVvKniMXRCtj2OMMLXIR25GY HFBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iRRLsFbU; 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 i18si559661uap.127.2021.06.21.16.35.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:35: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=iRRLsFbU; 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]:54992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTS1-0004Vw-0J for patch@linaro.org; Mon, 21 Jun 2021 19:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC9-00017h-LV for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:41484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC6-00062J-RL for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: by mail-pl1-x635.google.com with SMTP id y13so3296108plc.8 for ; Mon, 21 Jun 2021 16:19:06 -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=ziCUNw7iMfXxhXUy1AbaM+Ca/hJ3SGJZ/ldvQFuxiE8=; b=iRRLsFbU2eyy5IhuFxyKQVJigjYMFlNBjrxYCuRlOTQayTYiFeBLPrOt5XJPKvDVPR 4QF0d7ozH2LRwZurki8o1LfvFabWb8kSNM/o7xWz4cQfU8LlkpPCvV94U1z6cP25+0WO MyXHuaUWKp/isLueLqH4G/rzwW3IOGUm0PNRNdtnQro5OxD+d+imH16Syp+ZwNFv5W9E 3qPa+pfENfgpfuaPjC3sq5hzvooPwqa0bXrOm/NGpPatFlTIBKwlTnGrlXIQa4G8ntyh e4YcIwMFZxH6WiFL2mAQiiKpvPO5rpTvu6z49+SebC2/uZ1loyToZuzyV4Bmh6SqupsT b8RQ== 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=ziCUNw7iMfXxhXUy1AbaM+Ca/hJ3SGJZ/ldvQFuxiE8=; b=HQd7NrGEObl/domIWc8NNQzxIp7BFTUVVwCgcbOg1gIIJ7JjI0lx6MUgxLFofYDf2D voY3kbmhrLURaB0kEb2VVesH+Drl/lrov8GDgSeYR4NwJ7FNsW7asV81ddd2ifD0F0Fe sYhGtrldfxcUR3Lsk0A1DF0peJdVMpVzwgomoawBrOFQQ8ceBcaO8ordL+TYvFkAWKaA hs3YB0HMAMcGvRLhXDtYmYc3cXsooWOdnMfV27oSMiO02CBC7uya15N73cK6EBLmCkA+ BQ9oLNYgtXGoVn6ZojuKOYuqkJ44GaiwzDHJWpkXrSBfnB9oV5LZP+QHnycPBq5+1QY2 H5tw== X-Gm-Message-State: AOAM532QXiJvrIHCyeWgv5EeUQkoZrqdiNOTjZGRrnF2vdeGbok1IEhA gDPZn2Byf1JY5whR2/ayP0qy/mc2bhj0pQ== X-Received: by 2002:a17:902:263:b029:110:e758:2748 with SMTP id 90-20020a1709020263b0290110e7582748mr19886070plc.53.1624317545555; Mon, 21 Jun 2021 16:19:05 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/29] target/arm: Improve REVSH Date: Mon, 21 Jun 2021 16:18:43 -0700 Message-Id: <20210621231849.1871164-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The new bswap flags can implement the semantics exactly. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/translate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.25.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 669b0be578..a0c6cfa902 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -354,9 +354,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 21 23:18: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: 464636 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4676554ejk; Mon, 21 Jun 2021 16:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx29x7vkqt0kRhryR4ol0Z8yRBKMdsaXDDI8rvdZkroxB/pETF2ljVRplbnpHbXez4fFS8E X-Received: by 2002:a05:6102:364b:: with SMTP id s11mr7480492vsu.49.1624318400812; Mon, 21 Jun 2021 16:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318400; cv=none; d=google.com; s=arc-20160816; b=iDlXbYI7mfexAYHhXAjoQqhf2qu3mPAN5gRwQGIJ6DL+a0DlWO1DvGxXpkwhARQVlq cFr0afn0VQYV5oy0QPB3lznmFplD9NMuQzbU2xmpJCkCglX7h52CnvMb6UCCO+fnlqJ7 sYyIJtz1tu7EyOHOqKSAOeWBCjLmksaFzyvZEyE0HFtBBY5H5D1eMf1x3XK0BXVb0OMG 493pbI5NJ+I/4tqB9KSfZGiHnX4sB5GPsb8rtUMsawrgyJLasgQMzPDueF26UU2ZIsir RtQ9vrmrN68xX/c5uABM+HYAnq3bCJmA/CD7VHlsqaBfDDzmUkiBSzGd8RfZeC4eh/4X Ps9g== 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=uxQeR//xqY+LsX6pm6SBoWME/fdGKFQJm9ucGcJi4j0=; b=zgyijXaXTM6lSI0JIDiAD+xVvfoS+/V2qURT/MuWMrwM3lBp+Kr5hVAdpGJVX3mSyP TWg7T0aIlWmINpGMY+1OwXBLvW7rbPjUzJsYgfQ9KZopyy1j52YD8M5KqF2rveNOVMiE Fip1P6ttGu9GoPiuwUSFZK31bmohjzqfzlFzUnW92RTjXcdErFkh/RHPdyjBe1ccqY0y KJ7e+SLbvXVsCmGirAoykfwyjtq0ww3vN64ghMvOYt6cl8H4tKuBdPCH+0A8sFBGc++g KwK8u0Uq2xIZtxf2QQu3ieRcUkS8+mCPBAdk9u4MhO1oKkOwPw9+vg/hS1zZ+yG8EaWw r5KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O8S6lHvn; 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 b15si581551uas.11.2021.06.21.16.33.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:33:20 -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=O8S6lHvn; 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]:48738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTPs-0000N6-5l for patch@linaro.org; Mon, 21 Jun 2021 19:33:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTC9-00018x-V2 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:40630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC7-00062T-Em for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:09 -0400 Received: by mail-pj1-x1034.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so472513pjb.5 for ; Mon, 21 Jun 2021 16:19:07 -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=uxQeR//xqY+LsX6pm6SBoWME/fdGKFQJm9ucGcJi4j0=; b=O8S6lHvnRio7OIyE3Bc0jy4yKxcZv+B+jczpN85+BHP8JzO0LuubOKsUERIfo91m0x CRv+zdehapRUwTIfS5p0n0AqIFtuKnyhn/WWoUebO+zg9VzVqx3IDTxGhtzHJuVSJpHs mTUVR8ZebJuH4PFNl6fhKkqyWmpxB9cEcWeJyBZUusVyKbSKnyAKHM06d9m4LfI6H8Lj Xo/Vea83d19eX2E3ZSd7crEckPnD+HqpyrfSJ5LSzvthJTo3Jp++6X8tgJRcZZ8LR1iG U8uNZkSrgiY1pl+w3VXfxRFvp+JPceTqz40bykpka6MkGn7WBL7MLHfRVoWs57DugDx9 2iwQ== 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=uxQeR//xqY+LsX6pm6SBoWME/fdGKFQJm9ucGcJi4j0=; b=qkHo4bi5JDgiky3dFMns/B2nxkXISSbtevdcZZ036LvP8Kh8jwnlycSdZdf4pg4OXU a65hPex8KzsX4oKD0304uMmSSCPLK5PFhPNmFfTKzIZ2m4UOdggJX4Emayju572TMgc/ wksxjwY0zvHNMV8EHsTFinB7XjB0QKP3Wwck+YxaVXmI/yQz8wVYEYoBQzU0Ay4OrKLd M4I1tmMCkbRu+4DtDhuvOZZNvXf97FNa7pNUHUZ0gpltkvg7ecIDygUiCsnCYslGhuxN pHH9htfWsNElAwBgumJ1iBTifnqLQJLpGi5d0MDzBzn4Yx8MBJmJpPAkMseP1YdP8jj+ Mw1g== X-Gm-Message-State: AOAM532iNIuIRzByHlBW77cYaajEvPdUhCw0/cB1y6s9Q72ajzKAAQC8 NNw8njDVS0w8TQdOC43XyIOXZpoC9orAjg== X-Received: by 2002:a17:90b:4b04:: with SMTP id lx4mr684260pjb.54.1624317546186; Mon, 21 Jun 2021 16:19:06 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/29] target/i386: Improve bswap translation Date: Mon, 21 Jun 2021 16:18:44 -0700 Message-Id: <20210621231849.1871164-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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" 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) -- 2.25.1 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 21 23:18:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464638 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4678061ejk; Mon, 21 Jun 2021 16:35:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAmw8VGKNGAv2Mz8gd7urV32i55WvD/XWCHzIswDs+MszMlrksPOsRSAxIzknWi5mOIE3Y X-Received: by 2002:ab0:2118:: with SMTP id d24mr1371338ual.36.1624318534424; Mon, 21 Jun 2021 16:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318534; cv=none; d=google.com; s=arc-20160816; b=dV9VUfKNQ1R4DQdvsyM1ml/lDAzzHOLsSS5QG+xiZcQ2vvzvbcbcdvyr20wo/SB8pt B+5woVqy4W5zNzUd9GQ/hDyXIa4hsXcn0HCeihq809/AqGSMdDE1Q3DgNfq7xdwklZKx xyEmsOEh6DYto8bNbAkd7n2ZlOpfE524aOz3mEaejiI+gYlelWZqcUsGbRlzVhSBomCs 6KTALLKFy8UkuMkzcp/LUJMJuG+NBuWoo3ssEUUuW/+i6Yv1TDg8j6EJwF6mqOjQLiuK BVY7YG5VyTuRgYBVWLRjudRP5ZQQA1Xuj+5Kq4sn017gBJIkoshN42nbc4KYVa/JpgLt 7tGw== 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=EzJ1xh0bwnQkkpHhQH0S/Akj7K6Bvw2BctkCRqh+aEM=; b=Kbd/yyv6JAiKNeCMAlVR74UGQjZVDigu7KIYcT0vhppqagJd1aEr0Z/lsloi6qeTVO fjFM5yR5/wNZ9cDCSsQwmo60PwYXI8/MSsqsIvMP89hshy3VlGE2NbylThItjTHQ7JTU jPjd3+28zTU/lEPv0tiSxuiJVswO6KUq6a/aufnWiLCt1PcL/EW8zotG7+kHPm5Pkf3e llsWbr879/g+2QCLDoiJ1K3jN7KTlMg6QObw7MHKEuFFlYsFVfYnPlFGKxQfohr9A5Nd 8o3m+ZnpFGF2M9+6DRqWzykphB/pshFwWzmTw7kf/aZb3Kdq7exuZBxzfJyKxNmJXrF8 0wyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qL6sVl+M; 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 r16si570058vka.35.2021.06.21.16.35.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:35:34 -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=qL6sVl+M; 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]:55094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTS1-0004aN-Mh for patch@linaro.org; Mon, 21 Jun 2021 19:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCB-0001Dx-3Z for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:34355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC8-00062f-3c for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:10 -0400 Received: by mail-pj1-x1030.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso736222pjx.1 for ; Mon, 21 Jun 2021 16:19:07 -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=EzJ1xh0bwnQkkpHhQH0S/Akj7K6Bvw2BctkCRqh+aEM=; b=qL6sVl+MIvj9Top58LYsb6SMS0EK9uaUjfbu3KZfiHahlYRCNbpenfR8HazhgVkR6n vG6Bjoei3kkeINbDmoQPbxc7UjlH74liOpQLxFO4wzXe3RGfPIQ6fEWGhTgDmIm/x3cm B15Zj0OlHYhYXa2UdRSGUqyvsFZIhGyyqij6+WOEv3zmesLvU90mz7igJ1tI6apHOL9r qsRPo0pLyNuP19J1dvXNw3bwDzcDxsM8oFMCiYPPJRZsPHYHYEaQXxSAmSU6JvMxlZ4Z Rv+TX/HQdp3uCKm0vKMuMr6lN7TMnaoicmS49RCc4Cv09hY8t7oHoKMtXdwP7hBQGcot SUgg== 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=EzJ1xh0bwnQkkpHhQH0S/Akj7K6Bvw2BctkCRqh+aEM=; b=R8YXMSLDf60HjYcaWMr+3yuVZvNFbbgqO84nCUndqtf0yOsgCMnpj3oMwDYoBjXV78 fKT9Y7hltQsAO19yhsxQGO9rTvLLkbK2Ra6VVAfV4qTngfvsH1e0KR1kFDgEiIRtDkxE qwnuuA9KZ3LQJWAPUl+dVdNzkLr8UrdiqEeUett9TrdWDJyxa3AFHvVT8NL52wJGnykp h6kpj1hbssWkN2+D8f+lkgUJd+LIh1eYzzw2BGlGYP+MGRd8N57ep5dvsXjknwO9nD8+ 53P+qIjI/uSDGN4aKn/qcZHDDGie3OEvnlROvFg5rY7r1wqy4h+u1Lm2sjox1LF6QWJZ +ZEw== X-Gm-Message-State: AOAM532ezkAoGvuYrD47YR+FSvJiXiPFRMxIWLO9LrOAAz6ac9EnrS6d mp4LUy1V7gz7GMXPxtVE0hnci4vwIvnstw== X-Received: by 2002:a17:902:ed44:b029:11e:c5f6:9d45 with SMTP id y4-20020a170902ed44b029011ec5f69d45mr19800231plb.55.1624317546736; Mon, 21 Jun 2021 16:19:06 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 25/29] target/sh4: Improve swap.b translation Date: Mon, 21 Jun 2021 16:18:45 -0700 Message-Id: <20210621231849.1871164-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Remove TCG_BSWAP_IZ and the preceding zero-extension. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/sh4/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.25.1 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 21 23:18: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: 464629 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4673760ejk; Mon, 21 Jun 2021 16:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbRkCsb2bUHzzgngzHX/3UgvB4CmZKqN6hGtPknIC8P4vfgn8u5VrLgGq2u2AX1Tq5xa6E X-Received: by 2002:a05:6214:8ec:: with SMTP id dr12mr22554216qvb.48.1624318156357; Mon, 21 Jun 2021 16:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318156; cv=none; d=google.com; s=arc-20160816; b=rPEg54PL0Es/nG8Qb2L0PCnkvng1O//Hzf+rIcKJ15cQZsrw0QFSiI1XlYVWRSXtpS BP6m1LTP3rlzm6lpEgmwhaVutevmtLOsTHadMyEh1XwvdVCCzN3McZWCq45FxADFNIR0 DLgGw/PYwhAaEPyxRQ+dD0ioMwDepY3yT22bHFpyVC/bLdnnUxu/y5khmb2PO3v3U7oC 00PB4BgACwiY0JMzXOmFSfdYx8HkqNDILf0z3x9RBAROakKeD1NF5xoljwNUoKfFFF9E iKsLqU+al9OgjU1ujgwU7DANFL1OyZIeDyxVr1/m+DWW+hIR+GqD91Du2PxslfyEJJh+ Ixxw== 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=48z68ulW8GGIpMYTx1SRl+BJDLbN2VvaGGeLWdHXQ9E=; b=HRVJ9vCTb11taiSAV5oIJWP78AmpbotVhcoqW9PuToPBoyEQPUn8LXKtt0IzzYPYbL 1udB6TvXSXUERToS8U3i+8yM5DaexecNnGqIFjKXEF9o/66X8CL5LaZD3/8qO6Avj96U IyGPm31/A6yBiJqF3TXGofJoMFC8A5XYYP5fVLMOlOhk+LemoxA81U0SUbCekzDUgaIM ZImxsVcOtCHMyPsvZKj3MP/ar1Lt6jOnhzZaEN1pVFMO2Y1PDCwOZIM2snZl3t70UoXf VE84XvoVCu+wl17iw1v7KtlU99M7b0gqkohptK7oaNq9XXkjx/fF+/F0MBG6IGY7DDlu sk9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ik9OLGwx; 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 13si350303qtw.381.2021.06.21.16.29.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:29:16 -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=ik9OLGwx; 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]:33716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTLv-0007CT-My for patch@linaro.org; Mon, 21 Jun 2021 19:29:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCB-0001Fb-FM for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:34356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC8-00062q-LC for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:11 -0400 Received: by mail-pj1-x1031.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso736232pjx.1 for ; Mon, 21 Jun 2021 16:19:08 -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=48z68ulW8GGIpMYTx1SRl+BJDLbN2VvaGGeLWdHXQ9E=; b=ik9OLGwxhyWb7jtxZOih9jWRXRamr6sJrXfok3YGTAGuAks3ctMThGyJLyAoAyvn/E s4DhG7Z6OI5kJQ36HXO6ww3mamXv+uplBn3Rfo+p4KHRrtVk6gzvWXkNKhQwt+12gtFN DfHgSava8r1Hl4JMKzzBTCYleDzJ0TsYTdmp1ctKJyP97lSmKdzCGMbdlTy88feQQXOn ovup/pdgtO0YHmDyz2Tld6gonwdI5vXYu7VCciMRwOgYJ7lCi43cUlXMsq/cEA5+Fm+H D05i+ripmj7Xc319Rpf9VAho/zJvGLA2jS9oXD0LuSR9jNHr5Y9G0QUvIMt8SNhtef+s yC6Q== 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=48z68ulW8GGIpMYTx1SRl+BJDLbN2VvaGGeLWdHXQ9E=; b=Y5+vNMYStdXSeQUUEHpr0TEhajU3hSXsKcZt4yoqhnkl/rp2okVaIFkrt/jIEardkh PIUlqa/1xryvc7nIso4+tPJvWr5Md/gAkfv7ksYxQYodssYR/Wz9oNx4JjjTEphsy4As eus6Ejp2QVdt9J5GOUaJKOxvLwL2DAvxrzruJrmAYQXNmHzuXb8h5vGnqQaInhjiokGf 4iISu3iGVAyr1nw56ekM4e82fpauWanmRsXc8sbDZncKoToOoV6XPcnX9AqWREUeu1Vi SR8Et45PXWDVIQrPzLvOmu9Ur19VYtykROi4Jnst/3AHvKgKSAGzCQXgKW5oMJPvkWY1 DwhA== X-Gm-Message-State: AOAM5339+jHUzd/psAVN7cEBn2Md049O3fnYr6s8XDgL1oBKZYjx/fNU blJ5ybohVWxm6G5In7n0pV4UEdXk2QAFGA== X-Received: by 2002:a17:902:8207:b029:124:4f60:740e with SMTP id x7-20020a1709028207b02901244f60740emr8568522pln.56.1624317547387; Mon, 21 Jun 2021 16:19:07 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 26/29] target/mips: Fix gen_mxu_s32ldd_s32lddr Date: Mon, 21 Jun 2021 16:18:46 -0700 Message-Id: <20210621231849.1871164-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , 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. Acked-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/mips/tcg/mxu_translate.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) -- 2.25.1 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 21 23:18:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464640 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4679104ejk; Mon, 21 Jun 2021 16:37:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGtPg6sZshRN3xvxYz78FdJ+v6FvU1vkcjD0/9Xl111JvxOOpseWxN3WOB1r/EBdumVChn X-Received: by 2002:ae9:ef10:: with SMTP id d16mr1306840qkg.200.1624318634407; Mon, 21 Jun 2021 16:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318634; cv=none; d=google.com; s=arc-20160816; b=n9rtmy0Xe1gd0Isoh5YxL1mYyGnai3Px2oZWTdDrCb56dTX55wvxwTYo2/+piDquUX G7ls07a5ocqIz+ajROdjdIetUkL1aZmzGpPGKGNOHUHSxsaRQ0Sq0MCkvLjixbk3O9xm cma5jtZ4YflN8hQ1yNbP3ZGhAcvMJXdYBv2qfSaFF8WbULJEbSO+6Ag+P+PEBL0Zqmc5 fwr0nn62Bc7bZGcwL3OHtKXE/anjEM0h24rNu9JrcJzPPObCjpbpWH31jBV6y2KBxOXG ij9IYEHlqatgrvV45Zpgs9R2zLPYCFI46Mv0vLWFSIYK/edteUuf81Pn+nR8lHN0IQc+ nXCg== 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=cDgi4mUmbBNogW7MaanU634ulEKHQqUXgCKwp+rRBiM=; b=e7nvJzV9CK9vKGNyXx2g8I/si44RCQig1VSfSuTP+z2d0KYySl2dikT5e3hkUgDlv6 b4pcSstDLnOGLf8K3ymy/vq53HQIXyEHgBGA8BKim4ohoQZrxLyIeswQYaxGCA/fZBcO hvHcpXygOFjhp613nL2Rj4SQARDzhSLy2khadWTds+2h2JE6poGh2nVaWIGLuz7X2cIR wEhgAWru5rpkEPVT7Lm/oVGyLUmVpHvpergWlc3OhfkPlejIr1Y3kSGtxC+dQVfDMFhN k/M4hgs7qcoxUXOanUyZ8tVmrOANqgZ+KRR+wkkVQRA4HrvM/W0AIZLEArZY25bJEKc9 WgZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YvrUyRmA; 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 c63si12617424qkf.232.2021.06.21.16.37.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:37: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=pass header.i=@linaro.org header.s=google header.b=YvrUyRmA; 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]:59844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTTd-0007ql-OA for patch@linaro.org; Mon, 21 Jun 2021 19:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCH-0001b6-9U for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:17 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:46972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC9-00063b-Ji for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:17 -0400 Received: by mail-pl1-x62e.google.com with SMTP id c15so9327770pls.13 for ; Mon, 21 Jun 2021 16:19:09 -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=cDgi4mUmbBNogW7MaanU634ulEKHQqUXgCKwp+rRBiM=; b=YvrUyRmAWDNwiy/4/K52Kktqpffay1U9HKFkWmz4oFy+N9hngFwxtG+3Tc9Hw4UcJw Gw/AcaWL7skNGEJSnUK+qQrcrm7ISq2Icc/KaGXYnoGRfKmOQcX4ENyaewRfEvKUSiMY R/U1l6BM4Q6ZV2TO4fQojm5mbf5bMtGdyK8jJIjl198O8L42gE98NwrNiMlvm19Xr9Hm 1J0Z9TFYWfg+wfg7Aak4djUb3JDw+tIOxrFICT/umaBOyDqOMJyIh8NgQ2WAtINKovme dbx6A8o6brawMyM8s86gxaY+bV0p0os/YOd8mIjDOzHzDNGJLL+DhhkP7DfoCCI3ya48 9+Ig== 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=cDgi4mUmbBNogW7MaanU634ulEKHQqUXgCKwp+rRBiM=; b=tohmP6SUj5abljiHDUYiBKrWqsdU4fsD7CrLviuxh2FAgp0ONBMqCNrWozBQw1AOK4 3FgunIN2+l+kPlgPs234mUe+O5/RiazhYSYvxYmaSWuSRBE05Kgm0ajKtlbY4f6BsN0W JFIyblXEZh3uyKshhXvP6T8AamONiZxB8Z5prWbVsAkrBVToSC0E60JtupkdiQo1ojDt QceKi7BRJx+nQVD7HHMddzkHfh5IlNErG0HlOQkLMa8iSofnuIAQxjjbZRU5bqqMV2oe RS4nVj11nXQYP3r4oGs6hXUfVdGzxygtE56MRPqEBeec1tw1Jqp5oRGvlSzEVeWny5V1 gTnQ== X-Gm-Message-State: AOAM531+uvoBSJwSWYJ4r0t+FphFzHv4XI082mkBlyvJrTUa4L95AIxQ 4xzYo2wg23qyPxLzS/vB62nbnfwjfTRZkA== X-Received: by 2002:a17:90b:3253:: with SMTP id jy19mr683918pjb.196.1624317547999; Mon, 21 Jun 2021 16:19:07 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 27/29] tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP Date: Mon, 21 Jun 2021 16:18:47 -0700 Message-Id: <20210621231849.1871164-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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: , Cc: Peter Maydell 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. Reviewed-by: Peter Maydell 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 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 73e0455511..7a761a602e 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1393,34 +1393,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 @@ -1625,9 +1629,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; } @@ -1705,7 +1709,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 */ @@ -1714,7 +1718,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: @@ -1725,51 +1730,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(); } } @@ -1777,7 +1761,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: @@ -1788,49 +1773,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(); } } @@ -1879,44 +1843,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(); } } @@ -1924,44 +1875,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 21 23:18: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: 464639 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4679050ejk; Mon, 21 Jun 2021 16:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGrjx2N746kI8Yt3/F5tjYzoc+HG9yjQkrPnfJRm+IySTKLAuIrMcbje9/7EXM8wOqWndW X-Received: by 2002:a1f:280e:: with SMTP id o14mr17314365vko.19.1624318628291; Mon, 21 Jun 2021 16:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318628; cv=none; d=google.com; s=arc-20160816; b=Kr3vh5wYHdJgoWhaoC2T6XQcPbAOjaGjn12zPr7GOlm/zcij2d0c8vRtPY67WOhVs1 4anp3eNc2kkD6a2yDFN1veOpuB0zeCiDszitwL99ZL9rM7FeRvP1lwZDTyV2fuBpWYCl gq5CwvXSKTWkEy8oyLGC5D9+KZ/RmB8lsEyxM7FkNjQumxx2HaJeIZ+2FoxJ+0eZWqRy VaCC+lBUCaqiO6NXxpgga7zZW3bIVzW6wuEMsctBTRENnBqCI7dpka9MvzBze66xo429 CiEyaB9O9vGoB7UfnupNaneotz1sxr+SZULW20Ry+MQ4C9jHk7u1QDnt7PItQmsSJaly ihfA== 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=EydeQGxVqAw6guu1qAKY5r1uSI5ierWJDBSf5PcuhzI=; b=YQSmgdg+VpEwbuGYRd5H0sV9go+CaX5qKRzmBJJI9C4WxKGc0InGvWbwG0wb3Wh0rC bTXtPT/i+HjsOV0t8rpbmIxOnLVL8mTLicELV4oHm9qu69TMQUwdBZQ0oWKGXH24AcxF flfmg2pyVNwKtGbBGjeyiLxO3VzKp687ZCCUAzP9OMca+LB5D9/2VQEvISGeBGXl+13a wY+vkncePLfaZlKENx/3Ends6V7nh9aYsPCbjEp/7Tg5T1NPNywuT1Rff86fhsTsIG5t TfQIKtfhWhJYA+0wvJ31IV7XVhnFoPi7keiIARzDI7TdUzOxUTppFyI9qbXtQf2uh0Nh IbRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GFnxwxsn; 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 g3si2488151vsm.316.2021.06.21.16.37.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:37:08 -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=GFnxwxsn; 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]:59780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTTW-0007oQ-GO for patch@linaro.org; Mon, 21 Jun 2021 19:37:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCD-0001Kn-6L for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:13 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:44903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTC9-000642-T1 for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:12 -0400 Received: by mail-pf1-x42e.google.com with SMTP id u18so9489599pfk.11 for ; Mon, 21 Jun 2021 16:19:09 -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=EydeQGxVqAw6guu1qAKY5r1uSI5ierWJDBSf5PcuhzI=; b=GFnxwxsn27Ty6Je2H+Kmp90fwBB4wbC2LgxMuELihV0gb0skBoKaA/e00xypfCbSAf BDeoEE5t/nXuGvRjeaafQA6CwZ2pHOquOC2p+qzBr87fIVqYeKIFD15K0PKXBz2ydSeN iycrca9mCYT1nhhjuaqjPYYuNmzWYdZVUjIjRAeBvO+LT4CANryghJINWhEJD4ysdU5D gLsoZdwX1o+QAk5nySkMHXnMJ/bCns07EVmbFXv6/3pcfp4/icuhv9qILtBN3H0v6+OJ /ygj0zVsz+WrCXtJd16hXOgE822zVOtq9DPCjPOh5j6U6zIM9cBI2Iu1YAKpDNfMS4ZS L+dw== 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=EydeQGxVqAw6guu1qAKY5r1uSI5ierWJDBSf5PcuhzI=; b=TSeD6zXWIQ750kyeRsEllVbigIi0fAhdh2HP05/hKRxMfoYorux3OkdXdgzIUymyTt CkJr/R8EY7w+ruW2bs0qPZ2Aqj1CsQ4KSGMTbSLjK3IYj7CSQTnRyIEjjuWCWRgs/PNQ cuCzO6M3BjYPE84CVDoOGTyRsZb/jAadBhKlIp5pB4yP02Ksh4tLxwysfdX9hOmPc23y fvIwMu3NWUQF20e9tqz0iJ5MODV0joBNqrcPyaLbuuOUaEFrztkyHn7oyDVVS1Yi1p1n P8rhFOzFERAn4Ej/hqfV3p3ts+OEqYM7kydAu+y/u26vUQwkEa5KIjRxokh6r3THTqte 0Bog== X-Gm-Message-State: AOAM531TQBSuATRVF0yYG3JmprryyN1jy5jAplR5XFzx+77HNQzHVup9 UgF6Zhlb2jSL0t4lda2LOuXlP/hrq9hMIA== X-Received: by 2002:a63:5d52:: with SMTP id o18mr836684pgm.440.1624317548625; Mon, 21 Jun 2021 16:19:08 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 28/29] tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP Date: Mon, 21 Jun 2021 16:18:48 -0700 Message-Id: <20210621231849.1871164-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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 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. Reviewed-by: Peter Maydell 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 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 72aa7e0e74..5924977b42 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1547,28 +1547,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) @@ -1592,7 +1598,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 { @@ -1618,7 +1624,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; } @@ -1714,7 +1720,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: @@ -1726,40 +1733,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_rev(s, TCG_TYPE_I32, MO_16, 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_rev(s, TCG_TYPE_I32, MO_16, 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_rev(s, TCG_TYPE_I32, MO_32, 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_rev(s, TCG_TYPE_I32, MO_32, 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_rev(s, TCG_TYPE_I64, MO_64, data_r, data_r); - } break; default: tcg_abort(); @@ -1770,31 +1756,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_rev(s, TCG_TYPE_I32, MO_16, 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_rev(s, TCG_TYPE_I32, MO_32, 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_rev(s, TCG_TYPE_I64, MO_64, 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 21 23:18:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 464641 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4680987ejk; Mon, 21 Jun 2021 16:40:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr+v6EXnxowbxrm5tmA3vZlV60fdFsf44yLOzQ2YOA43bB1KgYC203ZbBwoGg0c8ZQe2dO X-Received: by 2002:a05:6e02:ea9:: with SMTP id u9mr527523ilj.96.1624318807431; Mon, 21 Jun 2021 16:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624318807; cv=none; d=google.com; s=arc-20160816; b=MYeukA36fXOmsr9X2/J/H+INBYmK1c3b45V61WPcOZK7P3SExGZLcJ33GtgEqdmPU+ V3ql6R+r8nPDFXcDVR/S/GFRZzIGsuYaGb0gw+DDz9/wVI/xow8LOnDHQ5o7FDujFayB v/KF70m/Vh4C4W/8uXmGz3VDYiGpco7zEXahWn/ai0Uzkh10VQAT/T1Rkao50RIcLSJ5 cI/I4hdEvMVHnhBhdpf6Y4kDhL39GkQsGgrco5JP44UW1z72wlpyCDEThrCz9baQiA73 dpl2s4uVar14O3bJnmTWiehEWUOvdj2NK63iMMbkJoCphpLXQEWPVGxWha0rH+4BTpDf b31A== 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=gGg4VMcdZ5rhfpaP9NuMbgcNxZ47zeyC7JQnFmoSmmk=; b=QSKf9ndHGc1OXSWtezpvLrL4UQwNHY6dZrJCRJ80rdiXkcUpr+wocXoQBzZqnrm3zS m4mzlww9E4JEdaTVvKXEYlWr9NHdkt7Y463cosCiz2swatlQniGW3TtFvi8Qti25yydv uKKBpaw6b2rgkegeHbXolGel7DBRo2WeJuwip09x/adVC7Hpqao+nlZ6N5SQ6puQ0SNG lXCe7Ad9bu2mYfinyaDfozvfXVStYZWfdEaBUsqa/Ly+4csZEk+6/Zc13IfBfVZ4Zb+m NmhaVOEGNTHltwqzQSuzdCNjbXzXI2Z8lZZe1ayZuD/7v422JNdIGMOfpCGethnskIsc mRKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rE1mPB+O; 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 w16si22080063jaq.100.2021.06.21.16.40.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 16:40: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=rE1mPB+O; 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]:35788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvTWQ-0002EI-NL for patch@linaro.org; Mon, 21 Jun 2021 19:40:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvTCE-0001Pj-GB for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:14 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:35741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvTCA-000654-HN for qemu-devel@nongnu.org; Mon, 21 Jun 2021 19:19:14 -0400 Received: by mail-pf1-x42a.google.com with SMTP id t32so3515920pfg.2 for ; Mon, 21 Jun 2021 16:19:10 -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=gGg4VMcdZ5rhfpaP9NuMbgcNxZ47zeyC7JQnFmoSmmk=; b=rE1mPB+O0FysM7myJdsr5EkFossAGea9wvyGlPGKcUtS0Etx/wPba7W6+PzxRbRLbq 9yXpfdK0zRNb7Q9d2b1ffNTBH6qdsVUGvFaX5qNodO+fG1r8YHTWzB2SkshVIMO6yw8O lrMv2VWmc3qHZuFJ1YKgtn0QWahhDsI3HlKEsFLjVaI9d8qAsG4a0qbOc7IK/4wKyE3h iuMP8QEjqBeYBkeJnz6+8k969y3iYruWAzt8c5mHQEYZbTqtspP0+XW+lMIsbKHl4KdF u+iW5tsgm2m97HFQLTsuz31/XSr4Ifa5+lAGA3uAn4QJpjpSZBnlDF4JSDtHiI17pjBW /kkg== 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=gGg4VMcdZ5rhfpaP9NuMbgcNxZ47zeyC7JQnFmoSmmk=; b=fNxm0lgr+EhjG13jGo4/34oDdkdNZtZJnuxoG78xjRYQ3CTY7rtolPDtLHg8ODT9f2 KiEnSVvna+2Q7w4Lv894RtuW/WW21FJJVmRta1zUwiCEWCyQA8EZyYvgMiTswuQBEcob tMLSIX6xOjoDquz/aOpYXa7hiTqzLY5eOxApE4zDMsFu+SYt7nO6B8+kMNAmZd4ab1ph lmnyCos/1PVLpWfUtAjMaVJ2KXDvXO84MZwH+lwWRzf8XE74aJNIZfY2MhCUk9nFmcAy 23szw07FRmZY3KGqubXC2f7u7bftAQJJXp2Jpv4XKIxEtAMvotjBimEo0N2kpUQb/vmf enZg== X-Gm-Message-State: AOAM532/FqMiOcH/UgZI+BQjofWcs511bxkJnwhiF8M21MT9dCstkdmx Tp5ZclAyonlSVapUj+usMZMF2ua7v6LqkQ== X-Received: by 2002:a62:1c86:0:b029:2fe:b583:6418 with SMTP id c128-20020a621c860000b02902feb5836418mr585783pfc.23.1624317549331; Mon, 21 Jun 2021 16:19:09 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 135sm14429952pgf.20.2021.06.21.16.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:19:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 29/29] tcg/riscv: Remove MO_BSWAP handling Date: Mon, 21 Jun 2021 16:18:49 -0700 Message-Id: <20210621231849.1871164-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621231849.1871164-1-richard.henderson@linaro.org> References: <20210621231849.1871164-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: Alistair Francis 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. Acked-by: Alistair Francis Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 64 ++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 31 deletions(-) -- 2.25.1 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: