From patchwork Tue Jun 29 18:54: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: 468348 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5259099jao; Tue, 29 Jun 2021 12:39:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgS2LsOYmrfD5CuXCrfosRiysTKyfVnJoAlS/brq1eqx9LNXczCWpG7BMIomOP9St4Dbod X-Received: by 2002:a5b:f0a:: with SMTP id x10mr39793459ybr.447.1624995567028; Tue, 29 Jun 2021 12:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624995567; cv=none; d=google.com; s=arc-20160816; b=swVANsRGIEEG30Qo2yv9a/330LOuoOyk/7bmkqNvtF0maolHYmOwmGoZbptrbbGZHZ uoCd/C7ewoOX0ViXsFL9HDMvDNNPGdPdtynj2X5cpudl5pWyjE5UwlkVijy3qEP+2+lG 9TGdc9yfG1moC5v2UX3zJ64rKCHGLWoFzQslQrdLpHAP1j/BEeroaDzEfoLbA3fbEPnm hQHeljMWVdqTfWFYSJfUVoyBpnd9+je3F7Ko/3Wc7FjGa0XTdMSdpUSTYfp7T/NG9ii1 FzREKQJD78xusANwhNYOzmw040JTelx4YmKXpnPfikkcYKdEBcE8oB7OkXSqCMJbCfuX bSsA== 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=EyQCDwDgRWzCroWmFskZhXSC5DiDrzI7vK1qoZHizTf1Wh+LG3l9EDLEOPHYQY+1s0 0U/Od1o7IEctjjEi2hKSLCOnmvCajm9pPQrEQ51OiB7O0eGhiY/k3A7zp7qWq69tBZLJ V8JyW8N6w4emdVVjqb+iCIfpaiaP6wRdCf3H/bSAgMz31+pAj3isTj+UYigibjhIMnVi dQBlcBc1YZBdRChSgKjqH57KXKAcbeC9zibRedrZYi1s9KoUwixeAzTW3ZSOZ21QSeet a0t0TAPaBOpGCfWhjGnKqz0xLCfOK6bFgXyN925OG14MT3JJxHTbrDA6Oj7rjL21qZit JKCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HrFkohaV; 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 f2si15356898ybi.353.2021.06.29.12.39.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jun 2021 12:39:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HrFkohaV; 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]:54590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyJZu-0006n8-Fk for patch@linaro.org; Tue, 29 Jun 2021 15:39:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyItT-00008f-7N for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:55:35 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:33519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyItD-0000xi-Ns for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:55:34 -0400 Received: by mail-pl1-x62d.google.com with SMTP id f11so69800plg.0 for ; Tue, 29 Jun 2021 11:55:19 -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=HrFkohaVYQ29xSYF4JQatHrvGdRzjAQzHsAkiObJMajF0mVSUX3EXDNPDOixiRZK24 sbz0P00epzQAUPRDnzxlyq/5GFr7zx7TNCYJFoX5ibNRSUjNjTanJFibBy4F1luOLDTI nbGNNjLKxVvzMaW0xnXhYt+qdq4KH3SVccv5yn8eZMNJlH+PQVGz1acDXg9a1rT/P5V2 vfYWvU3Rj4iJELL5ktBsY07ArR1W1gx8Y8NpcafPyFvw6sQvUM18NTnMZEaoxm0aQ5KQ ewDKCcP6Z6BcBxtmyNLguPcaRGtGlPSf8IyuSAW1sxqYwOFKgKcTkYGkF5ZGfqJJXj5B 5Bhw== 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=XBypyUM5Bv8g8ADo0bAnR9HH/IvYNL73cwS2C/jP40xcCpbYOCEPm9ejP2jKpoM2xf S9vzFYCPYWQ6f0Qg4yyXZyjAkwexg7kvNCDpX8BoZdQqQXSeIBPSGhM1QCIYalNCvMT9 9VjvhYxSn5+cOhEMRetCiiU/KrAy4bt1n2Tj4MYuTvM0y625CxAZFx9pz2sN63OUEioe sKXsly2OzqfTAZgl4lHitskJzycmU/mFLUU/UKwGV/zeRoFQuas6oGwTE/7BXHFn9+DL 0Tzd6M1PkoqBdyZLQZotVJrWo4fTUDcPqNID6QgSm4b+IcvLNkcH7R+N9XiVDYqPg9Gr Cs+w== X-Gm-Message-State: AOAM530jWx1qika6Z4DYliMW0gJp6S2msUXhFohOCoAi7/t+olJTXtPb 9uCPl1VBHo/0zKHgktU7kQ5VGZg15iPSAw== X-Received: by 2002:a17:902:249:b029:121:b9eb:a513 with SMTP id 67-20020a1709020249b0290121b9eba513mr29176665plc.6.1624992918425; Tue, 29 Jun 2021 11:55:18 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id j2sm18811253pfb.53.2021.06.29.11.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 11:55:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/63] tcg/i386: Support bswap flags Date: Tue, 29 Jun 2021 11:54:28 -0700 Message-Id: <20210629185455.3131172-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210629185455.3131172-1-richard.henderson@linaro.org> References: <20210629185455.3131172-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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):