From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038313; cv=none; d=zohomail.com; s=zohoarc; b=e08sks7dtdhzkDqCOTi2PsFDe/v75mMdpK8NbBHpbPgVGwZJ8kb5k09w9vOVRUHQVT+xKViy7RwtIekhCo0eHa2LJIE7hFbWLw/K/J3nTuWGCQqDofbg6d54qqHWZCwtMDTQEbufiRXNy14c2HQ3jbHi4KvnICYu8vRJYZ+9y5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038313; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8ZDJh+YnFUCknSRFGXVYE0jRPMbbTzyNWKw2JHeS1ag=; b=Fqa/xvvSZoenLTbVfVY0aqs6HwoFxCN3P8ynkjvsJVWl2y13btzHI07svIkGhGqdDwVR0OAjS4lIQdIOlMf8HgiNZWm2JKbkQE28wRH//DwsNdprwFcXCLGau/Bg1VIZljf4NyJ6KuvCj9ytrXZFt40KJNzkaRuUWA2VNY+h1VI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038313157893.0939950733847; Thu, 25 May 2023 11:11:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQC-0008LD-4e; Thu, 25 May 2023 14:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQA-0008KK-C4 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQ8-0005qn-MZ for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ae54b623c2so16879305ad.3 for ; Thu, 25 May 2023 11:10:40 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038238; x=1687630238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8ZDJh+YnFUCknSRFGXVYE0jRPMbbTzyNWKw2JHeS1ag=; b=Nl2HW8jUkETIgYamiCxDmE40ZQgscvzyTP9DVZm2vud0T8/CnnqK8LQnGr2mJuoKDf UiRNREb4AYiW7v77jpeN6mSbCpylXW/IX8jUjQqfECchJuof2/CpnMtPAwj1Q+CNGx9Z /6R0vqWf7jDq5lChlu4WXtSL5n7v6GwSaKbIZYQ4K7sfemRW4jBBHWE/F6Vx7QXEqz3v fuHuGmi/YCmyT5zbrnERuQoPCOc5fqLTcB2sELyICGeKMbicrk7kLe7TXZALHsKYTgPQ OpTEsGYZsO6jXgnaUWhLJ42T/On98+PuddYWG0yLyVCunIXiHGm6CiKJX35OIYgMsMZ+ NvyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038238; x=1687630238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ZDJh+YnFUCknSRFGXVYE0jRPMbbTzyNWKw2JHeS1ag=; b=WBEExABVALsTZDWIkvtrw7MPMGs9Q3iG8OOP0NgFhkPfEjU4ctSIS9xw/pZmhD/d3K nukqm/CqBc2NjxM9ZjszZIiEbl+BCA6gv7vUXQ5uclp/5fGz9gzPZEvkX7f6lZ4gb+yl RzqQBJMKHMFEmXH0011ZdsYjJZ9jvaRsS0Ve0++SWfRJjKlN6SiaIk3zLGJxkkSd8kDc Sa09g/RnRoASt/khv1/DEBhJmDdGfT7n1Pf2UlgmdKjnnYWXBu4Hw05kI4QehBW0knfT AIcl/WWjkQhtXP1l69gVOPIEiD8YBcuIb+23zxAbfGwTP9/GT+iqpTNklR+yWnxO2xa8 b/IQ== X-Gm-Message-State: AC+VfDwWgKprxgxe8/cMVmJgBWaKjORrBL647OpZFxpE0gkRNFTyTvrz RkOGbtHMg9hJrt/L9VNukNGAVubmxfdZpnvqJr4= X-Google-Smtp-Source: ACHHUZ5vuhQQR58t8W9l/57LO5zRTbxAyJKCwt+WBUax06QUeisMsp2LDItcP69ybk4bDf5UD0DRuA== X-Received: by 2002:a17:902:ab8e:b0:1af:e295:ad56 with SMTP id f14-20020a170902ab8e00b001afe295ad56mr2309323plr.49.1685038238531; Thu, 25 May 2023 11:10:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/23] tcg/mips: Move TCG_AREG0 to S8 Date: Thu, 25 May 2023 11:10:14 -0700 Message-Id: <20230525181036.1559435-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038315204100003 No functional change; just moving the saved reserved regs to the end. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 +- tcg/mips/tcg-target.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 7277a117ef..46b63e59cc 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -76,7 +76,7 @@ typedef enum { TCG_REG_RA, =20 TCG_REG_CALL_STACK =3D TCG_REG_SP, - TCG_AREG0 =3D TCG_REG_S0, + TCG_AREG0 =3D TCG_REG_S8, } TCGReg; =20 /* used for function call generation */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index ef146b193c..ee6c2eb872 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2183,7 +2183,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) } =20 static const int tcg_target_callee_save_regs[] =3D { - TCG_REG_S0, /* used for the global env (TCG_AREG0) */ + TCG_REG_S0, TCG_REG_S1, TCG_REG_S2, TCG_REG_S3, @@ -2191,7 +2191,7 @@ static const int tcg_target_callee_save_regs[] =3D { TCG_REG_S5, TCG_REG_S6, TCG_REG_S7, - TCG_REG_S8, + TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ }; =20 --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038340; cv=none; d=zohomail.com; s=zohoarc; b=S60jfBpa7ycUKrfsAwBPuYT6StaqPRQLyrflmaGvwJfpdH6TGABbDsTCTm45Ouy5EhecqTw4hQe7DOUUQlpFBG2USr7w5El1bT5kARwjet7q/2TSXY80zF3m1qmyzo3c014cn9oYAscEZTlOqbL2jwo72yMNGEMREFx8NQ/dw0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pa1EeTfFR0ENE9IkClE4tlmnlEbqM1UBLr9L+Mye/pg=; b=CXErfOjWHiAkihQjIef1CeZxknx6G3l+PcGXWjJbZ2FwtVy0fDqkckDDKo2DZJwf69A4ur/+l5OA0BrhvxZTt8Uxj52/D5y7sTWQQVBM8ri4H6IVUp8HZ0WLcuTu9CeSoB34Slnl5LniHjTonoToUjwZBTF+T3CfOMmHRN3so1A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038340669107.91045356658242; Thu, 25 May 2023 11:12:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQC-0008LF-M2; Thu, 25 May 2023 14:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQA-0008KW-Gj for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQ8-0005r0-Ur for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5289cf35eeaso959762a12.1 for ; Thu, 25 May 2023 11:10:40 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038239; x=1687630239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pa1EeTfFR0ENE9IkClE4tlmnlEbqM1UBLr9L+Mye/pg=; b=oGcymjk6WjCFadaPZ0SMB39eqAIxQoBHewHSDNpmsXP8k3+mSKgCA1MZcxhAompG0y 86zunIWzuFXf2HepMuV8tD0XAh+wb22MQ8QUfkQdFxm9QsgcCHTzA2qrb3Jt5hli/zsW NYLiv+IPgXNMJJIvSpjycmUBt2ePl6tNb72dHvuPGZ4o39ch4zHEmm4LqwbgXvGN2nsF VX/MJDr6w1h/9XNbmvDzkuOm3MS0ZIJHwWZoT7YvJykzK1p4O9KVXpZ3xIs6sGDlaA2l KFtrJsabjhV81CvoJ/CI8ZFxRpZsrUNV/mK1Nw29WRGwgmhRtoFc8o6TDl16FPPLgVaU EFlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038239; x=1687630239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pa1EeTfFR0ENE9IkClE4tlmnlEbqM1UBLr9L+Mye/pg=; b=ZhhGphtrmuqWjmT0g9nKxrh+RKDWdr8oaGj8UPbAaB1ze8hz9NJoun01etmnMnMI/w dbUfKRotioq0b0fhE/P2SHS2WKS/ImNSQSOCowqohBaGgAmqMaMquYN9Xhp1DBzFotc0 4ShdYsLIF0BhbU4DuWHtYSjJmRfHBglU2Nmu8M/sn68ECLQ6QykDCuLm9nQfzlbEWkcq P/jShVWy3mcdutFZ4RdK4m0poIOysyS5yI3E0JRfUNU2AHEjuNZbDLp0Gv9n9Kjx4Uyg v/c8UsAKce0Znx9ZC3aUv6yH17+fUubvDP4oYcUQI61sVLCJAA+Pl054xUCJlrM9eIay T7WQ== X-Gm-Message-State: AC+VfDzcvk6AL2V7Nevg8ntH6W4w+q1CJIGDgasMo/bsoPqEwW4eQorj /ozh+kGVTl8iY7HTOFEu/DSwITzdpS9mtHlcqJg= X-Google-Smtp-Source: ACHHUZ5Z8GQySCiEvl51j0YwNO7+ttm9NCnFVwS3OeaX2euAw0+7wlXbISQ0SEV+NqiG+EgjcbXi5Q== X-Received: by 2002:a17:902:f551:b0:1a1:cb18:7f99 with SMTP id h17-20020a170902f55100b001a1cb187f99mr2321729plf.30.1685038239382; Thu, 25 May 2023 11:10:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/23] tcg/mips: Move TCG_GUEST_BASE_REG to S7 Date: Thu, 25 May 2023 11:10:15 -0700 Message-Id: <20230525181036.1559435-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038341448100001 No functional change; just moving the saved reserved regs to the end. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index ee6c2eb872..f322891797 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -86,7 +86,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET= _NB_REGS] =3D { #define TCG_TMP3 TCG_REG_T7 =20 #ifndef CONFIG_SOFTMMU -#define TCG_GUEST_BASE_REG TCG_REG_S1 +#define TCG_GUEST_BASE_REG TCG_REG_S7 #endif =20 /* check if we really need so many registers :P */ @@ -2190,7 +2190,7 @@ static const int tcg_target_callee_save_regs[] =3D { TCG_REG_S4, TCG_REG_S5, TCG_REG_S6, - TCG_REG_S7, + TCG_REG_S7, /* used for guest_base */ TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ }; --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038328; cv=none; d=zohomail.com; s=zohoarc; b=ONo3kgGvHv98qplT6EFn3Q52HXwfPrO1oVj25GF1O1GxYtKzcV0ctx/luvV4PIiDNEG3rDPnkpEQm7yHS7nhwQp20Q+Pl3bTpLW0XPp45ypCeptChHs6cA0BhOtxWOEEDCuOc/UhMfokiq9/tFXJIjnuwPJrudRpolJwxm5bev4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038328; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GEPJWGV9qjZFqAWTKDf53jYOVNIumZGIjC2oht8GWBQ=; b=TsW7vgbONxtl2kDTFgp7Kkc5+S7vwlh9kefv+yIv39IeqAQE0LkpJM+FLUMH3RBe2rJC9ziDVwwP8b13tWxNxxXZga56w+L/tjT9XMu38J+Zj8Dc71M7xY0WWSqsvIlxEbeEQ8iLBXLyHd33A8t6qzfexvOwAUrcxXDxzqrJA9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038328347894.4473228389959; Thu, 25 May 2023 11:12:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQC-0008LE-8G; Thu, 25 May 2023 14:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQA-0008L2-Ug for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQ9-0005rF-D6 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:42 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-53033a0b473so1364170a12.0 for ; Thu, 25 May 2023 11:10:40 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038240; x=1687630240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GEPJWGV9qjZFqAWTKDf53jYOVNIumZGIjC2oht8GWBQ=; b=MDwVezQKJS3JEjoHU9ug+4DozLugbY3dI7gO7RC3TBiAFtopjKRgqfZX3oJN5zo8Fe uVnnhlnGib8vNpSiED6ISoDRgGzMqUANI1xccjBPbBiCLK20dxOYaD0I9QxeQTF8K63h yOughAh/ZUoopgO6Lpol+Gr1lhNgOTKuePbjqLzTIa+/9YTYwiVrv6Cb85GFan/mmqx1 zdG8ST6YGNpD4vQsan3rseyLdb1KVD92BPq+SbjHFc2qu5RNdHxphPwjKBsK0DzCUieA UwNW1zD9QJZg0jyfZn9Vt9fO13WYTEnekLvJrVW5TPSXSk7tjUKO831ltjo261tWq9Zn Ib8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038240; x=1687630240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GEPJWGV9qjZFqAWTKDf53jYOVNIumZGIjC2oht8GWBQ=; b=iVpQlPqOYJCmsRbk+POqwb20EFpFd5IMx41ttdTcvI2PRnUQSlVzY3d+KXW7vpatvG fn9b7JCBpISQgrsiFoExRgkXXO9i0IZ805WQWban6cIeTXwXL/0THbD9Tlxrwptei4L4 /im2dVzO5Z53NaGrJIqXPMZZre5pUFEqNmppopdBAwB2sjKEQIKheWcFHIp2q5SHjgnn 4ITpMhyiewj3/jWKBuoqa5F5jULob60jD/1WDIJH6tduV60Kifj037whtgmP8BxdAwe5 L9zB+yUKRvcQEGyePmXj0GYqPxpS62B2sr09jtgFhwyxYAtPze3rfY1oBp5b32vbmLLW 88ng== X-Gm-Message-State: AC+VfDzE2jRNua9RrI3wIYmeGc8iyXEg6YoW34LioLczkZKm5zysjcCJ frs/5vOCO58lPDGrkVIYlj9wM+UnFC3w7denyKU= X-Google-Smtp-Source: ACHHUZ6OW4QTf8tP26bv7OAJvQtKpXCHob8M6d67fkS0GfCsPDMd+GKdL0gezleQ/zleBHPMpsAmOw== X-Received: by 2002:a17:903:41ca:b0:1a6:abac:9cc with SMTP id u10-20020a17090341ca00b001a6abac09ccmr2709438ple.66.1685038240135; Thu, 25 May 2023 11:10:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/23] tcg/mips: Unify TCG_GUEST_BASE_REG tests Date: Thu, 25 May 2023 11:10:16 -0700 Message-Id: <20230525181036.1559435-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038329452100001 Content-Type: text/plain; charset="utf-8" In tcg_out_qemu_ld/st, we already check for guest_base matching int16_t. Mirror that when setting up TCG_GUEST_BASE_REG in the prologue. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index f322891797..ccb3a1cd9a 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2312,7 +2312,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) } =20 #ifndef CONFIG_SOFTMMU - if (guest_base) { + if (guest_base !=3D (int16_t)guest_base) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038304; cv=none; d=zohomail.com; s=zohoarc; b=lHzC/J1+yJOQvjMPhREAWzXKoJ1sk0IwQ3c8sIx9NyQoHoRFnW2IXFGdrKZ78VqzL99muK9KtQepLjXGdrV6rAPdtJWra+Rld1rSqu5IaKyFDvqynNM+pwwK1W16U2VEXx4RrXYVnrtWtwWx5DH1cEcB+cSORdI8T86bL98mUuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038304; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=12R31Su0c3PpVt2JGtk5+3C3Tp4oGsKrL1eCkXeZ4Bk=; b=Uhs1JfBEFATsqD0Cdab33pr4DmQ2LmcZO/ygzg+dTKGVv8Yo4KkAlrmAmi02g0A4Lt8tKjuw4Y1Lf3E/FHwCXdorOYm9bKws1vQIqhTjplJLgESTSw2YoaPTLJE8GTcPP4XvU+vxQiqGTMz9QXP80UJwT+5+/RWiCoRnBX86bJ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038304815967.2696048675813; Thu, 25 May 2023 11:11:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQE-0008MU-3p; Thu, 25 May 2023 14:10:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQC-0008LO-TQ for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:44 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQB-0005rh-5y for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:44 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae54b623c2so16879635ad.3 for ; Thu, 25 May 2023 11:10:42 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038241; x=1687630241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=12R31Su0c3PpVt2JGtk5+3C3Tp4oGsKrL1eCkXeZ4Bk=; b=uPUDEvA7F6qt9DC3vKmZD9ITUUai/2JjR+uJ/jdBQSGPNpZi599B1p5+rVsBRNTLVo ySvXVqKTSYxs/ci54V0hx/IHisv9OsBigfIH/O0kUmcIkIaGWKRgg6XW7XklMSYwynNO umk0Usll5g01EtPplqmUVLr+AuFp9t2Uh2iAMkqgU6tEvJTAEdUQn4hnXOOf5my0dSQq u+ntzW2iuC2NSQBOkGGxaeys8wgFx+oDf5x0pPT0t/8X/m/9YbJIJS/kM0RJI30X/0bB AJC5i4BzSiYAcn1CFp1XfO7yGcuPOdhlB1pNjwxEjIzo66lARowzMFoucdFOLCTZEj4K a2Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038241; x=1687630241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=12R31Su0c3PpVt2JGtk5+3C3Tp4oGsKrL1eCkXeZ4Bk=; b=W7nRUs4BlJFl7Dc2+Y+vqMeFWzE7ipq7xAhHtNDXxI2TBxm7jWoV+Zkyyq1PDqQ6m4 O8DaILnvY07cwGbXzSIyLuU1SXktCkCmu+/Pgg5w4JQdtql9A+waroicmxQ6IP3PbuUT ZWm9EN4JxAqpL0Nw5ZAi+FWll18Yf7IRYDXUJLMIERS4/ANjOu/QOVDyhcwJikpdmbjx ZTUTmppI9jJKPOmDpgF6UnzhD8oi2FpBfHxiJHrj3nyn/INBgA6OyZ6bbb6wgg/bFoCR iMy9nmjbdS2TROT2vH3CRHTLF4EKs0cR0SRpxzIaTtEZpz65xobYw+z95Slj0gIBq2BR NTfw== X-Gm-Message-State: AC+VfDwQmNe8NGSqEOCw9ek0qMOO3enqzSrjhqL3Vmv4f2zCIsFIpgFt RDo7vIrFJ4O1ZXc2k9NbNYsrFQCuW5NCLUbHxK4= X-Google-Smtp-Source: ACHHUZ6jPUv9SCGKInzDRmOhVvVR3EVJEDBC4uh1ehTbRLTqb1RCUG85lSc2bCaGPd51lxcE9z24sg== X-Received: by 2002:a17:902:714c:b0:1aa:ee36:40a5 with SMTP id u12-20020a170902714c00b001aaee3640a5mr2296681plm.34.1685038241046; Thu, 25 May 2023 11:10:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/23] tcg/mips: Create and use TCG_REG_TB Date: Thu, 25 May 2023 11:10:17 -0700 Message-Id: <20230525181036.1559435-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038306354100003 Content-Type: text/plain; charset="utf-8" This vastly reduces the size of code generated for 64-bit addresses. The code for exit_tb, for instance, where we load a (tagged) pointer to the current TB, goes from 0x400aa9725c: li v0,64 0x400aa97260: dsll v0,v0,0x10 0x400aa97264: ori v0,v0,0xaa9 0x400aa97268: dsll v0,v0,0x10 0x400aa9726c: j 0x400aa9703c 0x400aa97270: ori v0,v0,0x7083 to 0x400aa97240: j 0x400aa97040 0x400aa97244: daddiu v0,s6,-189 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 69 +++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index ccb3a1cd9a..6f03b44ac0 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -88,6 +88,11 @@ static const char * const tcg_target_reg_names[TCG_TARGE= T_NB_REGS] =3D { #ifndef CONFIG_SOFTMMU #define TCG_GUEST_BASE_REG TCG_REG_S7 #endif +#if TCG_TARGET_REG_BITS =3D=3D 64 +#define TCG_REG_TB TCG_REG_S6 +#else +#define TCG_REG_TB (qemu_build_not_reached(), TCG_REG_ZERO) +#endif =20 /* check if we really need so many registers :P */ static const int tcg_target_reg_alloc_order[] =3D { @@ -1547,27 +1552,61 @@ static void tcg_out_clz(TCGContext *s, MIPSInsn opc= v2, MIPSInsn opcv6, =20 static void tcg_out_exit_tb(TCGContext *s, uintptr_t a0) { - TCGReg b0 =3D TCG_REG_ZERO; + TCGReg base =3D TCG_REG_ZERO; + int16_t lo =3D 0; =20 - if (a0 & ~0xffff) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_V0, a0 & ~0xffff); - b0 =3D TCG_REG_V0; + if (a0) { + intptr_t ofs; + if (TCG_TARGET_REG_BITS =3D=3D 64) { + ofs =3D tcg_tbrel_diff(s, (void *)a0); + lo =3D ofs; + if (ofs =3D=3D lo) { + base =3D TCG_REG_TB; + } else { + base =3D TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + tcg_out_opc_reg(s, ALIAS_PADD, base, base, TCG_REG_TB); + } + } else { + ofs =3D a0; + lo =3D ofs; + base =3D TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + } } if (!tcg_out_opc_jmp(s, OPC_J, tb_ret_addr)) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (uintptr_t)tb_ret_addr); tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); } - tcg_out_opc_imm(s, OPC_ORI, TCG_REG_V0, b0, a0 & 0xffff); + /* delay slot */ + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_REG_V0, base, lo); } =20 static void tcg_out_goto_tb(TCGContext *s, int which) { + intptr_t ofs =3D get_jmp_target_addr(s, which); + TCGReg base, dest; + /* indirect jump method */ - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, - get_jmp_target_addr(s, which)); - tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); + if (TCG_TARGET_REG_BITS =3D=3D 64) { + dest =3D TCG_REG_TB; + base =3D TCG_REG_TB; + ofs =3D tcg_tbrel_diff(s, (void *)ofs); + } else { + dest =3D TCG_TMP0; + base =3D TCG_REG_ZERO; + } + tcg_out_ld(s, TCG_TYPE_PTR, dest, base, ofs); + tcg_out_opc_reg(s, OPC_JR, 0, dest, 0); + /* delay slot */ tcg_out_nop(s); + set_jmp_reset_offset(s, which); + if (TCG_TARGET_REG_BITS =3D=3D 64) { + /* For the unlinked case, need to reset TCG_REG_TB. */ + tcg_out_ldst(s, ALIAS_PADDI, TCG_REG_TB, TCG_REG_TB, + -tcg_current_code_size(s)); + } } =20 void tb_target_set_jmp_target(const TranslationBlock *tb, int n, @@ -1598,7 +1637,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_goto_ptr: /* jmp to the given host address (could be epilogue) */ tcg_out_opc_reg(s, OPC_JR, 0, a0, 0); - tcg_out_nop(s); + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, a0); + } else { + tcg_out_nop(s); + } break; case INDEX_op_br: tcg_out_brcond(s, TCG_COND_EQ, TCG_REG_ZERO, TCG_REG_ZERO, @@ -2189,7 +2232,7 @@ static const int tcg_target_callee_save_regs[] =3D { TCG_REG_S3, TCG_REG_S4, TCG_REG_S5, - TCG_REG_S6, + TCG_REG_S6, /* used for the tb base (TCG_REG_TB) */ TCG_REG_S7, /* used for guest_base */ TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ @@ -2317,6 +2360,9 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs= [1]); + } =20 /* Call generated code */ tcg_out_opc_reg(s, OPC_JR, 0, tcg_target_call_iarg_regs[1], 0); @@ -2498,6 +2544,9 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_RA); /* return address = */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer = */ + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TB); /* tc->tc_ptr */ + } } =20 typedef struct { --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038288; cv=none; d=zohomail.com; s=zohoarc; b=aOcQOQmKgl9WIOWUEEBODEdUCA7slPsyxWC4QFrSNJGlLNH7R5HEZaI5Hcf/VZe5Py+SftDLy/CubcyBniXhK18crlweepXUQD6vGxVMAEYXTFriBvmS9hZu34Ft7bh++4UMN2/ptCXPqqZyinRM3f3RRjiXgNLLB+X1T8Fo2+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038288; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/FUzpLs9aS0xZGs3D7oQgohBF0T77jPZ8ssH36+mnmc=; b=DJufJAec3NS5GEqhep3QLMQGEwCto9cXmcTry2XXCY5i5ZT2sdT9jDEjoBALZle6NjxtHvyf4YIqFi3GoKUuil/WINK25Ivk3AIvfFvZMdefhfyB7lq4FiwhQ3SfoezWsLRDfFvXQGUN4Fh2BUaPzGd/wMorWSpbt0ZXzmhvNdc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038288680623.9121865019328; Thu, 25 May 2023 11:11:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQF-0008NY-Jc; Thu, 25 May 2023 14:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQE-0008MV-9D for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:46 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQC-0005s4-Lo for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:46 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ae557aaf1dso16287715ad.2 for ; Thu, 25 May 2023 11:10:42 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038242; x=1687630242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/FUzpLs9aS0xZGs3D7oQgohBF0T77jPZ8ssH36+mnmc=; b=Nt/44HrWO+tj5qfdoKz2JxGUqeh2uVFDYfVf785bjDSC17JBhJPbFj8IyxyP37acLn jflgbwaUXENA+7SrNFGvy27oEEYroZ7LnGyrYi9epOR/Ga267JRP9ER11v9DiQqOPbZf 3ncMxEu+hCpTq12blUTRqnsQ1X6T5h0oPQS2yvmHbCjNc/CyTBMKTtAo9bK3K+01sAHr H1Yu96ktqwaYp7zZYOSG793hzk1fOTt3YLw8rSMDa7qOIgHpqUUUeYXNkpf6O5CEfUgC U6qAr6r9ejDA9CKR9yF1dZKEY+b45a6WzYNaUWVbvGNr75PU9Us19U3NfLcnFUWchj4M 8i7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038242; x=1687630242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/FUzpLs9aS0xZGs3D7oQgohBF0T77jPZ8ssH36+mnmc=; b=jdWMcq0wuRO3CS9FfM7e7w861arG7IYNATm80y+0vhXoiD7PoN6fYoNNm8r1IVb5Q1 r2DHlK6I0rcZhgsHDd2yavAof+qxnYaORUDFd4x6xYkAc770dN0qu6GOFfYSbbH0NHMY Jz0FkU/wgoLO/ykhsAnwXGMtEI96xyRrdsE6QPXx6JL5KJTc+GRjzufpOYpihNabHGyK Zi+RM4anp5oZbeJwz9Hcyltk25KUh+MlzWezIZjSWiVLIAD5n6DjF6yNadiXiVfAUISW sJlbIJda/Frgjytx/AJhkeILlFrmLoSdVG1jkZ8i3wLzyIblyyiEu2maU+a7X6VdLoB6 7+mw== X-Gm-Message-State: AC+VfDxKzEITpx6VOAVeWTtDUGlw9Ej/VSn7XF+mVCrTbUAcyR5gA9Nh EV3qVXtkkRKaTS5wIsV3UnVsAxZ9bHHV2lUnazw= X-Google-Smtp-Source: ACHHUZ40EXjUlL/HZSaRgiWsZVxAe+F8pVQWH14AmCxBS/JpUPvJMnzzH7URVpp0WqfiSbQznmgkmQ== X-Received: by 2002:a17:902:e887:b0:1ae:8e80:ba89 with SMTP id w7-20020a170902e88700b001ae8e80ba89mr2969602plg.0.1685038242029; Thu, 25 May 2023 11:10:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 05/23] tcg/mips: Split out tcg_out_movi_one Date: Thu, 25 May 2023 11:10:18 -0700 Message-Id: <20230525181036.1559435-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038290101100003 Emit all constants that can be loaded in exactly one insn. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 6f03b44ac0..bbff510c46 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -510,20 +510,34 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, = TCGReg ret, TCGReg arg) return true; } =20 +static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long ar= g) +{ + if (arg =3D=3D (int16_t)arg) { + tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg =3D=3D (uint16_t)arg) { + tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg =3D=3D (int32_t)arg && (arg & 0xffff) =3D=3D 0) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; } - if (arg =3D=3D (int16_t)arg) { - tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); - return; - } - if (arg =3D=3D (uint16_t)arg) { - tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + + if (tcg_out_movi_one(s, ret, arg)) { return; } + if (TCG_TARGET_REG_BITS =3D=3D 32 || arg =3D=3D (int32_t)arg) { tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); } else { --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038270; cv=none; d=zohomail.com; s=zohoarc; b=N1Dr4nkxM4DJvGjk+ihT/ppXU++RboLDuYT3Za73rzYKYfvkpqqSZcn76BN77J+TKJnrQTe+OhAhK7GgE3tIGJ9jkO14gqsAWfkXHJfrYMcWDjJEIszEiJRSyeSLdJXpMNh1jZ+YMbtETIlw9v2nRSeKCgnRIxw8Hiv0xg4LfTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038270; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=LlrIbIjtzd0cQRQhyr0HWMBdm43qKSSWZpgbNyhpTp8xV3Gir5R4OBRoSjvSCjDAWWPelHY3QB6S/Pgdy/oShcI8e6aosMdbWjErbG8tiFZkcCiP89KqhDSe96F2rkrOiUuwX+PEY1MNfgin+CltQBed55P0f1sZslWumferf7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038270509777.3885498680206; Thu, 25 May 2023 11:11:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQF-0008Mx-OI; Thu, 25 May 2023 14:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQD-0008Lc-6n for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:45 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQB-0005rF-J2 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:44 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-53033a0b473so1364197a12.0 for ; Thu, 25 May 2023 11:10:43 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038243; x=1687630243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=Bb+O+iSLpgjlJp3GYJDrZevUyefyLq/4xoLwxTZhDRKie7cOcZxK7Hq1ylice+q23W Ar/JboIJLzvMtL+bU/nJjCL/yY0cFUhMIskUzKORf0r0OL5kv3akn/532cGJqZc1tkzj Nd5LQiTLYhySBnkhlBfTjDoM5Fwa3wX8VPBPGICfR/JYO5YSOw/neLTGvSJZ45Hmci3Q PbhPg0VD0RG4oEw2lXGxyVxnzpT4tGL04M59iMjVrvmNt3x9rIgVaC992qFxA5oEXAnF Bddn8MUqc11yW+ke5gnZhN6pUTNtrDd+39UTrdNKOYRyWHlO7P6bxjFO6gRG7e/pjYw1 KQ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038243; x=1687630243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PjVO4EwG0pWR82jvmleP9L75H2ptZyzCcmmMncc3rzw=; b=NU12K22YYmc7wScwMgMjdkbR51/yYOqrec+RwyEgFqrJBVr8VNSZ54LjCOpkmXku9a O257dVZnnV4rjcHc5cJKo3jrj8qn3zpjTXMWZ7ZZJ7bq7302JqI8VixH+eQywKhYIu2w yjAEPds2qJOeVVPLZh+j2nxOn0DhYycKRH+SoaR86URe+zK3rBXb13uvWDd2xMzSe9L+ v4ICa8Pa7TjQLk3gG77lcz3C8DiPqoXKImLzBfBanE2dgf8+cKyZABNyqaaVz2kl1nX5 pPE5LaqgfSoxwVzdwXl5uuAT2l6EEi6iUfPkC/A7NISuu30e3+RFlgnMUkrvRI3hARdk 1FWw== X-Gm-Message-State: AC+VfDzmF7FbPn9N0ydn0dVasi9MvGdY7mSpgTKkCN/f2YK7bf0Fjias dhnf0cE5fLGrT4fB6d95rRo19TQtiLMcd0IySUM= X-Google-Smtp-Source: ACHHUZ4rCOoLY/32piupkQjNRxgJRNcdl4mnAt0i0EG+RGq5Y4eeP23tQRH4pNK0CGzg5qog4hj+mQ== X-Received: by 2002:a17:903:41ca:b0:1a6:abac:9cc with SMTP id u10-20020a17090341ca00b001a6abac09ccmr2709569ple.66.1685038242777; Thu, 25 May 2023 11:10:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/23] tcg/mips: Split out tcg_out_movi_two Date: Thu, 25 May 2023 11:10:19 -0700 Message-Id: <20230525181036.1559435-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038272183100003 Content-Type: text/plain; charset="utf-8" Emit all 32-bit signed constants, which can be loaded in two insns. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index bbff510c46..7a19f8db1d 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -527,6 +527,22 @@ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret= , tcg_target_long arg) return false; } =20 +static bool tcg_out_movi_two(TCGContext *s, TCGReg ret, tcg_target_long ar= g) +{ + /* + * All signed 32-bit constants are loadable with two immediates, + * and everything else requires more work. + */ + if (arg =3D=3D (int32_t)arg) { + if (!tcg_out_movi_one(s, ret, arg)) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); + } + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -534,21 +550,18 @@ static void tcg_out_movi(TCGContext *s, TCGType type, arg =3D (int32_t)arg; } =20 - if (tcg_out_movi_one(s, ret, arg)) { + /* Load all 32-bit constants. */ + if (tcg_out_movi_two(s, ret, arg)) { return; } =20 - if (TCG_TARGET_REG_BITS =3D=3D 32 || arg =3D=3D (int32_t)arg) { - tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); + if (arg & 0xffff0000ull) { + tcg_out_dsll(s, ret, ret, 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); + tcg_out_dsll(s, ret, ret, 16); } else { - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } + tcg_out_dsll(s, ret, ret, 32); } if (arg & 0xffff) { tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038351; cv=none; d=zohomail.com; s=zohoarc; b=YBFycHwTuPrqWf/RM0iBS4m6SEJd5Ygs5rp45TIubBgtNuj7Xp8V+uaBBE+Xx5P1fvFwrk8EcTvOOIJGnStLqERts4ZwskUmCHLGu0u5s4XQOMYzOLR8d9jJ9TwtxqW3FgkhzTlZeFGHH+ZBIwH8P47v2rRmV0SN761a5D0+nnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038351; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+8VDPsv39XWgsAsG2YjKrkOuz6vMVoOvqu3SdlzPZ+I=; b=c0O19uXvVOpFDrr6j58u8rV6JWwJOkaPMfDWvVbHpPp2E4LoZPxchl9qXqwK9KgWsbq02QxJWoWPDrGcg/tVohJUumglzsama43/Jic0yblEtHivHaemcMhN8D4nWxh1B2I4DTfhjXiYU0OQUpVAwJThLQUVoz26SQEQRKQYINY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038351724548.41336631927; Thu, 25 May 2023 11:12:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQG-0008Ns-AW; Thu, 25 May 2023 14:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQF-0008NE-0l for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:47 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQD-0005sZ-7F for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:46 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5341737d7aeso1703157a12.2 for ; Thu, 25 May 2023 11:10:44 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038244; x=1687630244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+8VDPsv39XWgsAsG2YjKrkOuz6vMVoOvqu3SdlzPZ+I=; b=DOeM9uvSbjEGLIHWnmvWg9WMVXylB1lmys4cwKnXTyM5Q+7SDjSfi/dAkBllqCSLvS MHBSapKA+ao911IRO7lBPqlqGIyOGdzcuLGwyxGrdCe0AHSICfoz359iKQ+RUXMLjump thshcH+P60aLsy9K3Xu+EITPYZ+dKKwl1QFQ/YwBP/yJyOgSu4lYUZMOnbMRPGaxZL04 +bYvEmgZL5llAa++okpPKnfvcYH/FbQq1oURTWp2l1RVujxpOLa5n+e8BZ0zReoZSM2W JEEZkXSCecXDPTAnqNHa0HakNrIzpau0iNtVpaokOx+0MliwBsyXJw0yOwnaD0BMD49w zfJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038244; x=1687630244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8VDPsv39XWgsAsG2YjKrkOuz6vMVoOvqu3SdlzPZ+I=; b=FfkTXugG1OXxy7wHBEsX9rv/9rxw+pbQXiOrbrOPTvcp1Y25ow7+tDLGd2ii2p5gK2 xqdQ/nZ0dcc3a5fiIamjl6iYiNjkI3achNVRofwt5vg6j7UobDHwkDbnYcKTLQi1isSm fVwOJiFifl+ThfQnoKbMNIEqYoBuxzxWwu/gg4PYFSf6bVQIVWcoCUFynW3ewH8txePY b+79+KQkEZctuWbQeBwYTNPw8JsHoZCLpDD6o5bMVofK15cLuYx18QjxlSnc6AZioCwf AuVCVmVJ7SnITch6cEyxh6FiG334YXXWrQxHDMUrd1F/BXrhXYYQ+ElAo6DE0O2ivWaT 3vDA== X-Gm-Message-State: AC+VfDyi7iYIHCuhBdI+GOM/7ooYBAxLOm2MUyXvOvIgMmFc9Aw72Fdu KaGBH4HoE4OsgfXGA4QLaG8PRqSchQsGHfIxxmo= X-Google-Smtp-Source: ACHHUZ5Eqz1w5ypxRi25yGGb6qPhuIKD1QFSXPoQBM1V6L3qZhmlPkVQFEcNFPORozJNSNI+SYT7sQ== X-Received: by 2002:a17:903:10c:b0:1af:beae:c0b with SMTP id y12-20020a170903010c00b001afbeae0c0bmr2366740plc.22.1685038243702; Thu, 25 May 2023 11:10:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/23] tcg/mips: Use the constant pool for 64-bit constants Date: Thu, 25 May 2023 11:10:20 -0700 Message-Id: <20230525181036.1559435-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038353541100006 Content-Type: text/plain; charset="utf-8" During normal processing, the constant pool is accessible via TCG_REG_TB. During the prologue, it is accessible via TCG_REG_T9. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 1 + tcg/mips/tcg-target.c.inc | 65 +++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 46b63e59cc..8fbb6c6507 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -208,5 +208,6 @@ extern bool use_mips32r2_instructions; =20 #define TCG_TARGET_DEFAULT_MO 0 #define TCG_TARGET_NEED_LDST_LABELS +#define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 7a19f8db1d..3b840ecc4c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -25,6 +25,7 @@ */ =20 #include "../tcg-ldst.c.inc" +#include "../tcg-pool.c.inc" =20 #if HOST_BIG_ENDIAN # define MIPS_BE 1 @@ -168,9 +169,18 @@ static bool reloc_pc16(tcg_insn_unit *src_rw, const tc= g_insn_unit *target) static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_debug_assert(type =3D=3D R_MIPS_PC16); - tcg_debug_assert(addend =3D=3D 0); - return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + value +=3D addend; + switch (type) { + case R_MIPS_PC16: + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + case R_MIPS_16: + if (value !=3D (int16_t)value) { + return false; + } + *code_ptr =3D deposit32(*code_ptr, 0, 16, value); + return true; + } + g_assert_not_reached(); } =20 #define TCG_CT_CONST_ZERO 0x100 @@ -486,6 +496,11 @@ static void tcg_out_nop(TCGContext *s) tcg_out32(s, 0); } =20 +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + memset(p, 0, count * sizeof(tcg_insn_unit)); +} + static void tcg_out_dsll(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSLL, OPC_DSLL32, rd, rt, sa); @@ -543,8 +558,15 @@ static bool tcg_out_movi_two(TCGContext *s, TCGReg ret= , tcg_target_long arg) return false; } =20 -static void tcg_out_movi(TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long arg) +static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) +{ + new_pool_label(s, arg, R_MIPS_16, s->code_ptr, tcg_tbrel_diff(s, NULL)= ); + tcg_out_opc_imm(s, OPC_LD, ret, tbreg, 0); +} + +static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) { if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; @@ -554,18 +576,17 @@ static void tcg_out_movi(TCGContext *s, TCGType type, if (tcg_out_movi_two(s, ret, arg)) { return; } + assert(TCG_TARGET_REG_BITS =3D=3D 64); =20 - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } - if (arg & 0xffff) { - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); - } + /* Otherwise, put 64-bit constants into the constant pool. */ + tcg_out_movi_pool(s, ret, arg, tbreg); +} + +static void tcg_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) +{ + TCGReg tbreg =3D TCG_TARGET_REG_BITS =3D=3D 64 ? TCG_REG_TB : 0; + tcg_out_movi_int(s, type, ret, arg, tbreg); } =20 static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg rd, TCGReg r= s) @@ -2383,10 +2404,20 @@ static void tcg_target_qemu_prologue(TCGContext *s) =20 #ifndef CONFIG_SOFTMMU if (guest_base !=3D (int16_t)guest_base) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); + /* + * The function call abi for n32 and n64 will have loaded $25 (t9) + * with the address of the prologue, so we can use that instead + * of TCG_REG_TB. + */ +#if TCG_TARGET_REG_BITS =3D=3D 64 && !defined(__mips_abicalls) +# error "Unknown mips abi" +#endif + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, + TCG_TARGET_REG_BITS =3D=3D 64 ? TCG_REG_T9 : 0); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs= [1]); } --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038279; cv=none; d=zohomail.com; s=zohoarc; b=g5lqD3+/czaYerf9+YTjr3eVVOOwSTD66OKOPnNobaGdwGm5WtXf9V+smEge9OQc2cR2Sfny6lbkI2ncAtyR4HSeqOJVIPA5irkAno5bMVPo1XIZ3wXV2elsSUKARQQL6wPfgBBdMK/CV4ndo5/snH+0Adz8fysAw/jcIXTayQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038279; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PneTciLLHvR8ijTIsGWmXOZ1ZAuNdvQTSQFoTklUNzc=; b=Rr5A0veOgJwrvN5Pu51wAwCX8p37obAg6kFcyD8oHVi4loOR+EgY13LakVhPvchv4Zu7IbuYQLgIelZ5pMuxwLEcscs7okJTu3/LwNEhhOS6wT6Qb8DEmGmUKRY76svxjKQ2rtFWStfM96Gl9qBPsgyHU/7t3skk7bU4eXLhdPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038279379740.5833548011459; Thu, 25 May 2023 11:11:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQI-0008P4-G9; Thu, 25 May 2023 14:10:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQG-0008Nr-9N for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:48 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQE-0005su-8k for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:48 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-64d293746e0so40495b3a.2 for ; Thu, 25 May 2023 11:10:45 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038244; x=1687630244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PneTciLLHvR8ijTIsGWmXOZ1ZAuNdvQTSQFoTklUNzc=; b=FdcTBW64RRUoynap/2/OVZIWKalrZ8cMUCcZGE46XN1GJrDRcdkxy0whF5o0u87tbu wEf0vD2x9+s4VP1bQyMVZPrgK0f+LsYCzfB8SnFqnTPl7xBoBYu1VBjXOmPTM7nJXebg 5gRHRqljVlno4aa9xJB3hpQPx9bP+prF5yHLi6JlciAZMrggzLw04dMqnGGq2pehiPrb Wkd0GymtxCxJgUF+IxqIWGaCFbwzlhRBvxlkQ7JyHrgccQQeTZGYrrzx3MX4GV8zEJBz FHdk71hBMGYsYDYH3UBBYlmxFPxKvf90qdPlTPsf8mDAGRzHUbmjnLChMO4A3eS74FUB TiQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038244; x=1687630244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PneTciLLHvR8ijTIsGWmXOZ1ZAuNdvQTSQFoTklUNzc=; b=Kui87z/ERDT64DqQw8Ob4JkdHNh3Ok+89/0KvIEFkEJRARfs2D8qvtD634dYDWY35P XPAOUQlSFcVRDRG3H5YMBV5l0XbToQFS/bVlzQ8685LzKKbrhn2Xd40kBkkGHZAPCLCW EoeBaVtQiZrjRlE6DBR4QsnnghBZUxRaKb5c0Q86D/Fzwe+gk7GAEcive7o59lxrheEd H5OdOsB7VFVNBrSnYSeEbcHddvWbT3+DB5O3+uphWHmj1wTKwjti38B/Lvy81NfKF3rZ GrPJy4bfQtnOYJyFj9lf5B8QakvYu0+qNiJK/X0hTi2iOZNwFr3ggbUfGFn0j+Ge0u8w spAw== X-Gm-Message-State: AC+VfDynbco2FLRbMpoAE80+PmFV5ZBmOGEVXT0NdPe4YiLVQxrWNvch P/KYTeuNf5+MCaMVOcblwNWef3vx4xON6y2zdlU= X-Google-Smtp-Source: ACHHUZ6H+OKXX6BG0lFm3QYm6gGwMsAmbYQq6sfcepSpXpZIoqIuxqi7KeSpNdN6eQKZmOMsOsGRfw== X-Received: by 2002:a05:6a20:938d:b0:107:35ed:28a7 with SMTP id x13-20020a056a20938d00b0010735ed28a7mr25292829pzh.8.1685038244638; Thu, 25 May 2023 11:10:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/23] tcg/mips: Aggressively use the constant pool for n64 calls Date: Thu, 25 May 2023 11:10:21 -0700 Message-Id: <20230525181036.1559435-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038280225100001 Content-Type: text/plain; charset="utf-8" Repeated calls to a single helper are common -- especially the ones for softmmu memory access. Prefer the constant pool to longer sequences to increase sharing. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 3b840ecc4c..068deab8c9 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1101,9 +1101,19 @@ static void tcg_out_movcond(TCGContext *s, TCGCond c= ond, TCGReg ret, =20 static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { - /* Note that the ABI requires the called function's address to be - loaded into T9, even if a direct branch is in range. */ - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + /* + * Note that __mips_abicalls requires the called function's address + * to be loaded into $25 (t9), even if a direct branch is in range. + * + * For n64, always drop the pointer into the constant pool. + * We can re-use helper addresses often and do not want any + * of the longer sequences tcg_out_movi may try. + */ + if (sizeof(uintptr_t) =3D=3D 8) { + tcg_out_movi_pool(s, TCG_REG_T9, (uintptr_t)arg, TCG_REG_TB); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + } =20 /* But do try a direct branch, allowing the cpu better insn prefetch. = */ if (tail) { --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038264; cv=none; d=zohomail.com; s=zohoarc; b=QMfj9qTbAn5WCrcT9wFDIPSCvlbwDd2lFVgf+qoosoPKGQdBTxTyY13MFFcH93/wGP2dnmTFicYenp0Bj95Zi9cgSfncvv6go9BawDNs7qVEX6u8ed2wyt0R+bw8q+DbwciHoSBaLATmcP9o/OHafgte9Uisrwt75uA0YCHnIJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038264; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hePU+jHoG6kbWcw7O0XVS7iVuAJda7LKF/UytOuYzmY=; b=fgn/dx6JeVAZr54Od4splPmH2TexL5bxDaSrfapGa4VMeS2qGOdANunmryxzAjyjwKcuQqjL4gPSGovlzBYNjkk4MJ+7MznZ+SY4XvZBex8x3p6KQIAfvj8CZASMYtkwmQxdiHn+HE7gqHrdcBMm8apIfvswVxf6OyG389IccDg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038264070993.6370635086923; Thu, 25 May 2023 11:11:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQI-0008Pc-Te; Thu, 25 May 2023 14:10:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQG-0008Nu-CJ for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:48 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQE-0005t8-JO for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:48 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-64d426e63baso66029b3a.0 for ; Thu, 25 May 2023 11:10:46 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038245; x=1687630245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hePU+jHoG6kbWcw7O0XVS7iVuAJda7LKF/UytOuYzmY=; b=BsstyhHCniZz6TbuzNW+mM8wqS/4qEPzQb0vi2uIV8dNbc2mfdHC0KSuq3HhjA6B3o MwXWDZEmxPLwyzlaid4YUMRhWy+1AOOJ0y0Sgz0GxSWe4c4YWaQRgcTQX5f9xWsrn7pv QRFBPu5mU/oG3I/nbhh2L//KVAWOtmwkHsAvnA994s53lOUHFhXB4ykjhBU89GrmC15i m3O9d1QqlsroxckXbFAw6Yz6Deu9boHJ6pF1zhTM68pPeZl16cByC9HBQdLLqalY+/UA uocv3c7T3UJg4HVyGMnjMzLJlkzk9Mu+YG+fvtHTDBjI3zO8WsitIWU1OcVk6U0Coqnv nC3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038245; x=1687630245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hePU+jHoG6kbWcw7O0XVS7iVuAJda7LKF/UytOuYzmY=; b=S/LC+TQDsYO008ynfnLVDBpRYW3TDBuAhO5GrNo1ikasX6EXg7EhKPkOVC20Qx8OnJ ZvepcAqN3VIFB+aO+K8xaVVYq8HyI64mf8+rDOJyIOSkeua2RevcW3XPA7O9PWUZE9Un hj3O5zLa2YQ0oyw63kUqZ/8ohoVr37K82V+C+TDrf4Hhm6ZWvzOhnLY6oOHpDNsAsynL vRGE9Wm+6P5iSawNUVEq0nTQ5iXhRBUbPMp9n8SEImThFvw/w9Vi5zgbW1DqFQI5PXqW GqR8A4kiH000i1qklxM+QiFi2Jn+u52goTtZSufLmeHJxV3UG6+EH5c/yGMNgN4yjnh4 uw4Q== X-Gm-Message-State: AC+VfDyypr1TemgWzSBlP4xEPnIomE9N9XEPJmX8Dj6E77ktIZnqnhlR 9fOfnytCiJbA++oXy0rM++hT06tLPBI98pvjer4= X-Google-Smtp-Source: ACHHUZ4b/i8fM6BxdrVYIifcto4tEVemUKGs22gAOM/RLoXcbFln2u+Uxc7iCrWRcnPumlbUMt7jbA== X-Received: by 2002:a05:6a20:a12a:b0:104:b7b4:e044 with SMTP id q42-20020a056a20a12a00b00104b7b4e044mr22471041pzk.48.1685038245320; Thu, 25 May 2023 11:10:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/23] tcg/mips: Try tb-relative addresses in tcg_out_movi Date: Thu, 25 May 2023 11:10:22 -0700 Message-Id: <20230525181036.1559435-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038265336100001 Content-Type: text/plain; charset="utf-8" These addresses are often loaded by the qemu_ld/st slow path, for loading the retaddr value. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 068deab8c9..9fab424ecc 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -568,6 +568,8 @@ static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { + tcg_target_long tmp; + if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; } @@ -578,6 +580,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, } assert(TCG_TARGET_REG_BITS =3D=3D 64); =20 + /* Load addresses within 2GB of TB with 1 or 3 insns. */ + tmp =3D tcg_tbrel_diff(s, (void *)arg); + if (tmp =3D=3D (int16_t)tmp) { + tcg_out_opc_imm(s, OPC_DADDIU, ret, tbreg, tmp); + return; + } + if (tcg_out_movi_two(s, ret, tmp)) { + tcg_out_opc_reg(s, OPC_DADDU, ret, ret, tbreg); + return; + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038315; cv=none; d=zohomail.com; s=zohoarc; b=n0OiSIUbq/yMDp4sB+P6NNitFRLDWe60SewJPa0G8CtdDHz+IurGt+xup78Ekn4VlNSNX0k0ITzxYit6dvmsu83/m4UCaQSzdmOVvra1bZO5xnXBMa/XUFidVlTRdN25+RyKdgj3YsVxg0rrBjMEHp+ChVTnbgiQ717/DIhXyeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038315; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mZHgKT7Em8u8wS7a0495i+fKR6g+xWDjFn9ZPfkhSxA=; b=DHxVY70NY3Ya3smk7NEd1m9BC967EHKQ5hhxNS6ri88QzhdqI8N76XAYdY51oxPu2bX7KmDtBYpSVd+rWDqFevstV23cacQuRSz4RXhy7+Yu63objuI+VO9ghzMbsKLl3bYRYSrmg58HlkYbT6ErOgFOeDsDQt4Jzk9eqfusmm8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038315482350.9252059767797; Thu, 25 May 2023 11:11:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQJ-0008Pk-Ak; Thu, 25 May 2023 14:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQH-0008OF-5s for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:49 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQF-0005tc-FD for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:48 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ae50da739dso12485065ad.1 for ; Thu, 25 May 2023 11:10:47 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038246; x=1687630246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mZHgKT7Em8u8wS7a0495i+fKR6g+xWDjFn9ZPfkhSxA=; b=s4XaNTJwR0n5IbxiEU2xtRRiRkxnVsEhcAjYn8e1ErdXp1uz+5W/+Zct37NM8sfyid BKaQDPsJ83PB6wds6lup0ufYwSwgaUHzCq9GVKGEEjTLzk+bXHeHaEB6kYzoqwPdqN5s QpMQR9jzrX0arnPv4ozqCfMSO9ac/1ehevCdsP2D6LaDGNyc3mugG3BZKtgZzTCXcSFI fYEP2IPofdqDjYzDFYtGTZfqk+xiKZp+WDADu7VyfVprwRijzQMvru80NMQq5qsv9AuB 7nJkItV9Bw8vQ2DIDecc94jYVIQLpl62Ik3jeHJOR1+8ilM5KhM4SM8qW5bwzkrw4S7M LF3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038246; x=1687630246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mZHgKT7Em8u8wS7a0495i+fKR6g+xWDjFn9ZPfkhSxA=; b=Ulhxk9Yfx4CO/SiwZoIsJzKtIxxIa1D/5EjXfYrSSaDhMFlv3jJAFKfJlctpE2fdlM 0I50fqTYkuz9iZQChQUYro0ksZIRTuzrQbXtEK49UMvP0hBf9P4sm3lGQpBMYS/7ePre +g12XZAvGKDmSm0PtvkYSTHpbCGJWijiudLBa0uAvm+TfdusrM0tIrq3qWBhkHAymop2 jp5wQ6Tzt1Z8zOa4xRMOzWGZ8VE6qHG9SX7t0BGhtuvp9DjAu2XjzrPieCAE1eqf084r tkAEQuYRUWbwQuFua8mDzLdLWb483YqNDYA0jtWJlm86anDgGnN+lVeMl4+oVmV3tp4W HfPw== X-Gm-Message-State: AC+VfDzoRHKlP8F0ESKGBQIsjA7MZDYHpSkzD39GvSr35Cj1W0fySxje S54Xef5SuRTqSKLc9STIfNRhr3XHuRB2iq0+1PA= X-Google-Smtp-Source: ACHHUZ6426yrE36gFbgY4mDTXcAMug5pmPd6raEWTztKEcOUXEKSdQ4OT+zFhbXnLk3EdNeeHoiHkg== X-Received: by 2002:a17:902:d4ca:b0:1b0:440:7f5f with SMTP id o10-20020a170902d4ca00b001b004407f5fmr1305295plg.49.1685038246220; Thu, 25 May 2023 11:10:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/23] tcg/mips: Try three insns with shift and add in tcg_out_movi Date: Thu, 25 May 2023 11:10:23 -0700 Message-Id: <20230525181036.1559435-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038316379100009 Content-Type: text/plain; charset="utf-8" These sequences are inexpensive to test. Maxing out at three insns results in the same space as a load plus the constant pool entry. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 9fab424ecc..b86a0679af 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -569,6 +569,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { tcg_target_long tmp; + int sh, lo; =20 if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; @@ -591,6 +592,49 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, return; } =20 + /* + * Load bitmasks with a right-shift. This is good for things + * like 0x0fff_ffff_ffff_fff0: ADDUI r,0,0xff00 + DSRL r,r,4. + * or similarly using LUI. For this to work, bit 31 must be set. + */ + if (arg > 0 && (int32_t)arg < 0) { + sh =3D clz64(arg); + if (tcg_out_movi_one(s, ret, arg << sh)) { + tcg_out_dsrl(s, ret, ret, sh); + return; + } + } + + /* + * Load slightly larger constants using left-shift. + * Limit this sequence to 3 insns to avoid too much expansion. + */ + sh =3D ctz64(arg); + if (sh && tcg_out_movi_two(s, ret, arg >> sh)) { + tcg_out_dsll(s, ret, ret, sh); + return; + } + + /* + * Load slightly larger constants using left-shift and add/or. + * Prefer addi with a negative immediate when that would produce + * a larger shift. For this to work, bits 15 and 16 must be set. + */ + lo =3D arg & 0xffff; + if (lo) { + if ((arg & 0x18000) =3D=3D 0x18000) { + lo =3D (int16_t)arg; + } + tmp =3D arg - lo; + sh =3D ctz64(tmp); + tmp >>=3D sh; + if (tcg_out_movi_one(s, ret, tmp)) { + tcg_out_dsll(s, ret, ret, sh); + tcg_out_opc_imm(s, lo < 0 ? OPC_DADDIU : OPC_ORI, ret, ret, lo= ); + return; + } + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038369; cv=none; d=zohomail.com; s=zohoarc; b=XHgzq21ie9ZbYIJfS0F5764djAMjpR1bttmxgYDGZq+FAvmrEXAfmY0/iV8p4OKmPwcmULYAHm4lnV8QxKjAomB/HGcmI+aseKXXKoWRqSzuUgD8EDfBs/UiTwckx+Oc5ne7Onqng24LYkdR+XkCNk0cvo1hol6EH3BxqWANTzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038369; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4eRrB/YLKSQzVfKVxSy8PAe4EeBLzt+yH82sZfIehHU=; b=b+zdnuONcYCubaDp/W01xvoWwDoNilJgmpi+lluLOS2zeDrEXH4BJcGbOeyqtijN40ujCWODYqnwm5HC7aIa5DNdzvM9aNmQiBXK9gKvHmk4CRxlvIjHu9PUgmfwHrOe9xf9m+lyW2id4lvY04qhXpNaeLuQySF/6uj7LfEuLhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168503836973016.283898855474376; Thu, 25 May 2023 11:12:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQK-0008QJ-4B; Thu, 25 May 2023 14:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQH-0008Ou-VA for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:50 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQG-0005tz-E3 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:49 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae454844edso12664085ad.1 for ; Thu, 25 May 2023 11:10:48 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038247; x=1687630247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4eRrB/YLKSQzVfKVxSy8PAe4EeBLzt+yH82sZfIehHU=; b=hiHFQeRtHzJ7a42LoGLjs3aq9gwpnOLYamUKZ7l0Vvxxv5+e4HKzWEq3LsIJRUO/Ej /DjNVb1bencKDN2SbuBLluJQ76XPhAIiP3GqEOnLcQI4usMndiY4P3kh8WGWAUI8QEY/ hQkjLs1aZB8mPwEh1TawxNAJzsGgxbXdk/cpQsfNdgkkQdO8v6n6cmln8oA3mq3V372i Dbmv5BcBfIqD0wyPqQYPUdmgWpKlWNlLPZeWKZypQ2nvugYGZVtb+kDwq7jKkWDtatnP CBEjOiHGoxYzIrcrYLJkIxrqREs7Wll+x9MZQP8gPDi0um0FhuRlQC/a/og9t+muXjiy VrAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038247; x=1687630247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4eRrB/YLKSQzVfKVxSy8PAe4EeBLzt+yH82sZfIehHU=; b=PHrw4i6qvqxfW2vB7YQYVZYK5tRXono1m4aaSyScQGeGR+6S9fqd9q6VBlUB7sTr/w n3GickOzGK1VeDri+00Pg2gjzkyuuApjfaW4Vzf6iP9dM+8G36YzO9YWf+VOy1EfKfrJ o9t7ZyhJpyLVOmc9wkdn61XfQTGhwl+2NTj73WR3xKpZXYWLqt4GJwp5zG4w4mzvZgL3 dhpctsq8SRyme+jCafYjgHBmnt3bbo/Jnc7bNbWL2Gy9ac9Y5XIrGTLjpMNgE28AhhTJ mKIYQlwzYrpErol4gK6+WV6q2nqppfYizFFQ3eue/oHYRJuQDIXFlsDMZJ8GT+abNaL9 1eZg== X-Gm-Message-State: AC+VfDz6bIzjdX7jrQiuJnfd11UsOHliIVP+1pgTdTRwMWBLPF5GHCo9 ZrIgj+Dxv9T4MObMviaZMAN9u5L0S+cDByG5lKs= X-Google-Smtp-Source: ACHHUZ5PFU4klIEnJzFFqkTEyR+IsdBc7n3SifFbDAbBMSpQx1mk1+VHuzeH69TUyF710rybanOPTQ== X-Received: by 2002:a17:902:c94e:b0:1af:e999:a070 with SMTP id i14-20020a170902c94e00b001afe999a070mr3130658pla.14.1685038247166; Thu, 25 May 2023 11:10:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/23] tcg/mips: Use qemu_build_not_reached for LO/HI_OFF Date: Thu, 25 May 2023 11:10:24 -0700 Message-Id: <20230525181036.1559435-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038370691100002 Content-Type: text/plain; charset="utf-8" The new(ish) macro produces a compile-time error instead of a link-time error. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index b86a0679af..fd92cc30ca 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -37,11 +37,9 @@ # define LO_OFF (MIPS_BE * 4) # define HI_OFF (4 - LO_OFF) #else -/* To assert at compile-time that these values are never used - for TCG_TARGET_REG_BITS =3D=3D 64. */ -int link_error(void); -# define LO_OFF link_error() -# define HI_OFF link_error() +/* Assert at compile-time that these values are never used for 64-bit. */ +# define LO_OFF ({ qemu_build_not_reached(); 0; }) +# define HI_OFF ({ qemu_build_not_reached(); 0; }) #endif =20 #ifdef CONFIG_DEBUG_TCG --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038476; cv=none; d=zohomail.com; s=zohoarc; b=fJpG+MEA5POuvFhEauyvc3BjcjgD+iDwv1bfx35MZFVi265dk9G8CefwUMdtU5qaIZOhvhCcEWxf1//HEZdtphT9nrHWA4MCW/CS+bDHosaODpNrNAUbku7qku3N0R1/CwnHE/eaQU0Ww+wokIfc5koWQIgXRDEARHlZE3s2L10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LAz6IQhwfHAIXCDgKk50JRYG1wGTuelZa2J+mZizWjY=; b=jffPywhKFa9nfn/NWm6q4p+Ejm6O/QCRlRQl6DWSnnX2mrODRjE5Gn/YKJf/S3jZsREprgIpmtVU0TL99gy+etX5Ta8gy9qhHnxLQ+987ssraL2671WaOB+hd5n+ZCS7KhDF5R/K9zRMQUaa6EaQ44cpcDtgFY0bz59w7AKxAps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038476040741.1524667038069; Thu, 25 May 2023 11:14:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQK-0008QU-CX; Thu, 25 May 2023 14:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQJ-0008Pn-Aq for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:51 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQH-0005uY-Fa for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:51 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-64d3491609fso25807b3a.3 for ; Thu, 25 May 2023 11:10:49 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038248; x=1687630248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LAz6IQhwfHAIXCDgKk50JRYG1wGTuelZa2J+mZizWjY=; b=QIcTSAUgbVq8fq/+X13tQczgg82DEln/Axf15QUdb+agdlqDgyG8X61uniiTJ/TXtN k8Ro0f4RUCpHo2wJS4Y2fNrYDrv0Id66Np/JFdQZ+O7WBzquwqo6xw+H5KdGSwSyBDX+ rEqBsyNoIc2Ym36OVq1YZSizAEJykD4qRuX8bmLX7hW56cVEbm6FNPIpKHeS8s3dW9eK dwtrm2H2ouvV0wpybKV9MbggnzTJ9qWHsEwvoEoJmfhgO0c69fbgOruGUDrgUFzoDeGu cOSnixTa3vh5inuvt/0CF3Vvmk+y+RFvdFxk15/tMkw0FCdDWnCIeBRM1Y2dx+j3egZf IH6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038248; x=1687630248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LAz6IQhwfHAIXCDgKk50JRYG1wGTuelZa2J+mZizWjY=; b=S//xHShRBVMlHjIkr1l3H+AWbhtjxC2HhD5u/kJ1EUi+Md/k43UQ91NWydCGVtUwP8 8HyXDAIdgS3/YYG9IV3UYWZ8moLtFWz1iMwJOGbxhWC0hHkmfRtftzbg1mYRmM2nBi9D 2C36VYAF28YrrPjSz6JA2fwUL5FMFpNKYlCHAFN5DRPqP0ExMWAlkA5ODEnuHfuUKrtQ yQp2hKtVnQPnNhgNe3cQUGoJep+kk7WVVxCVscraQ9BdOwD3Gzw3QwWkft4X8jCvywBR fSAwoe33vEiztr6uVhDvldHrrLvmlzmrRhH9r5RlH/iwKXMxLVYRJduIJ6I94e+umhoJ CiUA== X-Gm-Message-State: AC+VfDxPl1n8AhnNBLlkmfXvnaZBs2CBAaxtV5fmcEVDkH2V7nYcVtZw /mTOW/AYgWGqKOBHRFxndUt+zuu+FFRXN/De7VE= X-Google-Smtp-Source: ACHHUZ4jEezLxKURL5vpsJ+rjm/cUOmmBOtMO7d2p5/2QtGVDCbKJmEef4xFUDjXUMIpU5u7epFu+w== X-Received: by 2002:a05:6a21:339f:b0:10b:3b4d:8c16 with SMTP id yy31-20020a056a21339f00b0010b3b4d8c16mr18854025pzb.38.1685038248080; Thu, 25 May 2023 11:10:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 12/23] tcg/mips: Replace MIPS_BE with HOST_BIG_ENDIAN Date: Thu, 25 May 2023 11:10:25 -0700 Message-Id: <20230525181036.1559435-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038476434100001 Since e03b56863d2b, which replaced HOST_WORDS_BIGENDIAN with HOST_BIG_ENDIAN, there is no need to define a second symbol which is [0,1]. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 46 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index fd92cc30ca..3274d9aace 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -27,14 +27,8 @@ #include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" =20 -#if HOST_BIG_ENDIAN -# define MIPS_BE 1 -#else -# define MIPS_BE 0 -#endif - #if TCG_TARGET_REG_BITS =3D=3D 32 -# define LO_OFF (MIPS_BE * 4) +# define LO_OFF (HOST_BIG_ENDIAN * 4) # define HI_OFF (4 - LO_OFF) #else /* Assert at compile-time that these values are never used for 64-bit. */ @@ -1439,7 +1433,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, /* Prefer to load from offset 0 first, but allow for overlap. */ if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_out_opc_imm(s, OPC_LD, lo, base, 0); - } else if (MIPS_BE ? hi !=3D base : lo =3D=3D base) { + } else if (HOST_BIG_ENDIAN ? hi !=3D base : lo =3D=3D base) { tcg_out_opc_imm(s, OPC_LW, hi, base, HI_OFF); tcg_out_opc_imm(s, OPC_LW, lo, base, LO_OFF); } else { @@ -1455,10 +1449,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg lo, TCGReg hi, static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, TCGType type) { - const MIPSInsn lw1 =3D MIPS_BE ? OPC_LWL : OPC_LWR; - const MIPSInsn lw2 =3D MIPS_BE ? OPC_LWR : OPC_LWL; - const MIPSInsn ld1 =3D MIPS_BE ? OPC_LDL : OPC_LDR; - const MIPSInsn ld2 =3D MIPS_BE ? OPC_LDR : OPC_LDL; + const MIPSInsn lw1 =3D HOST_BIG_ENDIAN ? OPC_LWL : OPC_LWR; + const MIPSInsn lw2 =3D HOST_BIG_ENDIAN ? OPC_LWR : OPC_LWL; + const MIPSInsn ld1 =3D HOST_BIG_ENDIAN ? OPC_LDL : OPC_LDR; + const MIPSInsn ld2 =3D HOST_BIG_ENDIAN ? OPC_LDR : OPC_LDL; bool sgn =3D opc & MO_SIGN; =20 switch (opc & MO_SIZE) { @@ -1497,10 +1491,10 @@ static void tcg_out_qemu_ld_unalign(TCGContext *s, = TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, ld1, lo, base, 0); tcg_out_opc_imm(s, ld2, lo, base, 7); } else { - tcg_out_opc_imm(s, lw1, MIPS_BE ? hi : lo, base, 0 + 0); - tcg_out_opc_imm(s, lw2, MIPS_BE ? hi : lo, base, 0 + 3); - tcg_out_opc_imm(s, lw1, MIPS_BE ? lo : hi, base, 4 + 0); - tcg_out_opc_imm(s, lw2, MIPS_BE ? lo : hi, base, 4 + 3); + tcg_out_opc_imm(s, lw1, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 0= ); + tcg_out_opc_imm(s, lw2, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 3= ); + tcg_out_opc_imm(s, lw1, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 0= ); + tcg_out_opc_imm(s, lw2, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 3= ); } break; =20 @@ -1550,8 +1544,8 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_out_opc_imm(s, OPC_SD, lo, base, 0); } else { - tcg_out_opc_imm(s, OPC_SW, MIPS_BE ? hi : lo, base, 0); - tcg_out_opc_imm(s, OPC_SW, MIPS_BE ? lo : hi, base, 4); + tcg_out_opc_imm(s, OPC_SW, HOST_BIG_ENDIAN ? hi : lo, base, 0); + tcg_out_opc_imm(s, OPC_SW, HOST_BIG_ENDIAN ? lo : hi, base, 4); } break; default: @@ -1562,10 +1556,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, T= CGReg lo, TCGReg hi, static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc) { - const MIPSInsn sw1 =3D MIPS_BE ? OPC_SWL : OPC_SWR; - const MIPSInsn sw2 =3D MIPS_BE ? OPC_SWR : OPC_SWL; - const MIPSInsn sd1 =3D MIPS_BE ? OPC_SDL : OPC_SDR; - const MIPSInsn sd2 =3D MIPS_BE ? OPC_SDR : OPC_SDL; + const MIPSInsn sw1 =3D HOST_BIG_ENDIAN ? OPC_SWL : OPC_SWR; + const MIPSInsn sw2 =3D HOST_BIG_ENDIAN ? OPC_SWR : OPC_SWL; + const MIPSInsn sd1 =3D HOST_BIG_ENDIAN ? OPC_SDL : OPC_SDR; + const MIPSInsn sd2 =3D HOST_BIG_ENDIAN ? OPC_SDR : OPC_SDL; =20 switch (opc & MO_SIZE) { case MO_16: @@ -1584,10 +1578,10 @@ static void tcg_out_qemu_st_unalign(TCGContext *s, = TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, sd1, lo, base, 0); tcg_out_opc_imm(s, sd2, lo, base, 7); } else { - tcg_out_opc_imm(s, sw1, MIPS_BE ? hi : lo, base, 0 + 0); - tcg_out_opc_imm(s, sw2, MIPS_BE ? hi : lo, base, 0 + 3); - tcg_out_opc_imm(s, sw1, MIPS_BE ? lo : hi, base, 4 + 0); - tcg_out_opc_imm(s, sw2, MIPS_BE ? lo : hi, base, 4 + 3); + tcg_out_opc_imm(s, sw1, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 0= ); + tcg_out_opc_imm(s, sw2, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 3= ); + tcg_out_opc_imm(s, sw1, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 0= ); + tcg_out_opc_imm(s, sw2, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 3= ); } break; =20 --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038352; cv=none; d=zohomail.com; s=zohoarc; b=EkVIDQUQlf/OPOvK+iAmsySSCjMYO4hPIFh68g4kqKXk5Yu+Sc7XHVGD27yvGF6aSxBrxxYpf0xckdJ8uMZw2QBDIbcXSpOuWTxV0EWzokeyiErHqGOjq0dX/ja5CctMosffRRm3Obl2ipLV9u6wV7J5LQTYblx1W14HBUa6m3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038352; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vXxyVLt0ER4eun7TxoIx5PWj+GpTU+EF5Iw3Swj2Sbk=; b=U2/SdCQ4EFPKj+L46SWXpZmfYTrgmqjVE7+2ca+tEELVGhJxyI7rQKo5uwRCGHuvKABH2wjRJfRwcuVEuJGGuPL2/AlnWk1CAEvhC1qkgwjERNGMQ7T+9/e3AS1vmcoxPqSA7O6sxOLelCUytz5W6rG00dX1ORNuDfyng0ca5Go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038352189780.987167951983; Thu, 25 May 2023 11:12:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQL-0008RS-U3; Thu, 25 May 2023 14:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQK-0008QV-F9 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:52 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQI-0005vE-Rq for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:52 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ae85b71141so16380915ad.0 for ; Thu, 25 May 2023 11:10:50 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038249; x=1687630249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXxyVLt0ER4eun7TxoIx5PWj+GpTU+EF5Iw3Swj2Sbk=; b=SdE2Cbw9RCIzeHIs77RN4iWNlfkVnKCrHYo66S3InosFfwUJcjy0Z9QZKkVjkF/vlg m28lxwvwWY1v3gx41qBXOfRsIs9yQF1FN2YncFVr/Tr6fHq1gajZlmEBsKHVmSQd2qMV g1IliB8eR+iuvGEP1s7AxBlSwgND8RVYs85yEdhMuS6CRfs2enEfbsuvUZymItI3du1l Qst0RGAV+dJISG1VWQtdQ59Nb0sk/xSxCBF6y+028flqEm3J2jXcc3xoj4jtoKz46qRY 9UhOXySUjEv4YzLiV/PDastZCwniCUxWwcXrle9KBzEtRWnHVYItWzR+96An+5DJnj+9 R6vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038249; x=1687630249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vXxyVLt0ER4eun7TxoIx5PWj+GpTU+EF5Iw3Swj2Sbk=; b=QggovhB8SWwXK5q9YoG14icZRPdeaBx5KkR4c52XcqJj78S5H4BxtivXbpNuqRZN6g pDMchf5j5kCb5+H2LUhiG5HWT+0muGFQRGO/Tx8I7IxxT+tLWI4jdcH8Wo8CFo620EE7 HXK8wUtvz5hJ/2CaOZn+uEUD7GU4AKwUjVtIBsIRyObSpRlR5irF5Yg73mvgXMhoR5nA 4cIsBmJ7Urr/ZitE5ueSsQCkqxqPiK9jnEFjOu8ncfqRbkSHprURa08Aj19b954KbAz3 DDFT7vFmwSMJwaaxpPcQySjYvmfZ3u+DCOKNN4iU2Q6wpSHsXqaGtwqq1EOn5N3nMbT4 PErA== X-Gm-Message-State: AC+VfDwNXTxeFeE7H0FYp+3lIir7ux9A9+bnX/b1f0c1FH3F7LE+rh43 Oy49ac0UwKEioPtnI7Qpx/OuJ/JPH+SmCZlWgxQ= X-Google-Smtp-Source: ACHHUZ4p+GlNBKCEHFjsNShiv4Iz3Y6/Sc3WdTTe+p5Grao9OrHP90w2t2DNlWE6ahi59408jpeU5Q== X-Received: by 2002:a17:902:8ec3:b0:1a0:7156:f8d1 with SMTP id x3-20020a1709028ec300b001a07156f8d1mr2552485plo.19.1685038248832; Thu, 25 May 2023 11:10:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 13/23] disas/riscv: Decode czero.{eqz,nez} Date: Thu, 25 May 2023 11:10:26 -0700 Message-Id: <20230525181036.1559435-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038352696100003 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- disas/riscv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/disas/riscv.c b/disas/riscv.c index e61bda5674..d597161d46 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -962,6 +962,8 @@ typedef enum { rv_op_cm_mvsa01 =3D 786, rv_op_cm_jt =3D 787, rv_op_cm_jalt =3D 788, + rv_op_czero_eqz =3D 789, + rv_op_czero_nez =3D 790, } rv_op; =20 /* structures */ @@ -2119,6 +2121,8 @@ const rv_opcode_data opcode_data[] =3D { { "cm.mvsa01", rv_codec_zcmp_cm_mv, rv_fmt_rd_rs2, NULL, 0, 0, 0 }, { "cm.jt", rv_codec_zcmt_jt, rv_fmt_zcmt_index, NULL, 0 }, { "cm.jalt", rv_codec_zcmt_jt, rv_fmt_zcmt_index, NULL, 0 }, + { "czero.eqz", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "czero.nez", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, }; =20 /* CSR names */ @@ -2914,6 +2918,8 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa= isa) case 45: op =3D rv_op_minu; break; case 46: op =3D rv_op_max; break; case 47: op =3D rv_op_maxu; break; + case 075: op =3D rv_op_czero_eqz; break; + case 077: op =3D rv_op_czero_nez; break; case 130: op =3D rv_op_sh1add; break; case 132: op =3D rv_op_sh2add; break; case 134: op =3D rv_op_sh3add; break; --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038499; cv=none; d=zohomail.com; s=zohoarc; b=BZGdH2EPKtkdR9h/pOcMAxIt5gSmq1xMSLP6H0WcMSr844yEpFUXHiYZxyz3NliB6jRidvh5kQidZWHNoM0R3ZzTjGj50q7zJrSSS6HF3BVvA/OsFjhpQSZsbZX8yZqhDYTJGmOEJzK3gfewvGFqvskcSenAWbrCzEbAyb9YXFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038499; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CWc5YT/KR4CLh9CR8/cWdv0j+LXdzlJlSOOvnC6xd4U=; b=iA9Zq4ndJspvaNu6DFVe58aRHnDkE+dQHvhRHjzFPe+bvOZ9bHdeF2HLQy6Bg2bTo+6mfeGXm9DOT7odyIgD5MOsYCQxFT4e4X20va7j2GBZ2GZHP+5lAGM8VyqT6wRgNkdgf3FvX8YOvCfsivT9XNZHbox3GYZxwAzsANCO0vk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038499043730.8437918133656; Thu, 25 May 2023 11:14:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQN-0008SG-74; Thu, 25 May 2023 14:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQL-0008RH-Me for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:53 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQJ-0005w2-Tv for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:53 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae74ab3089so12554945ad.0 for ; Thu, 25 May 2023 11:10:50 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038249; x=1687630249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CWc5YT/KR4CLh9CR8/cWdv0j+LXdzlJlSOOvnC6xd4U=; b=wJSU917tGWHxS0CbewUrqLXMGsvhmpURabiEwjUpGsjSjGT4+Ihh68yilDg+4Q8pkT wCcLRKqqMcduIy2kSCAV7fN60ogk56/5psPVAl1f7sp5tugUHKvif2LIex+Zh3TF9Rbx MCpaTs95Ez2ZTdHlazIRQUJUXxG0BFyEx4ohsM9UKvBg0mxFryELggLbigR0FrDuIphl 3huu2RjC2T0r/AIcZCMDq1Bc9YL739YNRbwlWPVwewR9dV1Gg+0wgK22gV1ppMUdwP2l vjLGh56aoLyj5DdK5zmP9TwdpPy4rI9Fg26N8gjMZI7yFcYwKIkw4MWn5v/GVbDBQD/z qM0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038249; x=1687630249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CWc5YT/KR4CLh9CR8/cWdv0j+LXdzlJlSOOvnC6xd4U=; b=adBxaEx1QW+2tO7yK8ZntCBGWj6uLlK9VGSMS7GML4c+D/tX5lFLVvU0W1yL8+mFFJ Jy8RFXbfiXSpKJBymvWR/Zu3n2q14O00nuBGQ3mWtp5tDQnmFsNxCABcXJqKu/6Q7tSn jorrPMl6fhMeLBOM0unjU7suOzDqO8NT4rZISG6pDlrdLGTSTE/UQz4ZSWWb2Mwz38UY Za7z3QTqxI6gQhvFSj5nja5WlQoezZFTP2FVehsXt2iQPqYG5VSEK8GhhJs+CHfl9L9B qPXAzBJf76aiHTk1V2x1aZoOwI+PFGqiGLKF9dHJd2b6HJmgmAmztMJ259lKH8FR+GPU C08A== X-Gm-Message-State: AC+VfDzyI1MVYRhuIU3Fcb3kkY8pwIFTY808CbcO+xs0Hc1PISybalhC Ah8y5YCpHHMJh2f1cZylbV+RRP8kJVocWJgU2II= X-Google-Smtp-Source: ACHHUZ4o/iQRlqA+nGxxFi7rZK5XIlL+bHIjC7d1QWQdwgWwevn3X1S/wPHkS3h05G1fW10Ruj33Tg== X-Received: by 2002:a17:902:d48a:b0:1ac:8db3:d4e5 with SMTP id c10-20020a170902d48a00b001ac8db3d4e5mr2645611plg.69.1685038249590; Thu, 25 May 2023 11:10:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 14/23] tcg/riscv: Probe for Zba, Zbb, Zicond extensions Date: Thu, 25 May 2023 11:10:27 -0700 Message-Id: <20230525181036.1559435-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038499807100001 Content-Type: text/plain; charset="utf-8" Define a useful subset of the extensions. Probe for them via compiler pre-processor feature macros and SIGILL. Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 6 +++ tcg/riscv/tcg-target.c.inc | 96 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 494c986b49..863ac8ba2f 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -90,6 +90,12 @@ typedef enum { #define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL =20 +#if defined(__riscv_arch_test) && defined(__riscv_zbb) +# define have_zbb true +#else +extern bool have_zbb; +#endif + /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 #define TCG_TARGET_HAS_div_i32 1 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index ff6334980f..eb3e2e9eb0 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -113,6 +113,20 @@ static const int tcg_target_call_iarg_regs[] =3D { TCG_REG_A7, }; =20 +#ifndef have_zbb +bool have_zbb; +#endif +#if defined(__riscv_arch_test) && defined(__riscv_zba) +# define have_zba true +#else +static bool have_zba; +#endif +#if defined(__riscv_arch_test) && defined(__riscv_zicond) +# define have_zicond true +#else +static bool have_zicond; +#endif + static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) { tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); @@ -234,6 +248,34 @@ typedef enum { =20 OPC_FENCE =3D 0x0000000f, OPC_NOP =3D OPC_ADDI, /* nop =3D addi r0,r0,0 */ + + /* Zba: Bit manipulation extension, address generation */ + OPC_ADD_UW =3D 0x0800003b, + + /* Zbb: Bit manipulation extension, basic bit manipulaton */ + OPC_ANDN =3D 0x40007033, + OPC_CLZ =3D 0x60001013, + OPC_CLZW =3D 0x6000101b, + OPC_CPOP =3D 0x60201013, + OPC_CPOPW =3D 0x6020101b, + OPC_CTZ =3D 0x60101013, + OPC_CTZW =3D 0x6010101b, + OPC_ORN =3D 0x40006033, + OPC_REV8 =3D 0x6b805013, + OPC_ROL =3D 0x60001033, + OPC_ROLW =3D 0x6000103b, + OPC_ROR =3D 0x60005033, + OPC_RORW =3D 0x6000503b, + OPC_RORI =3D 0x60005013, + OPC_RORIW =3D 0x6000501b, + OPC_SEXT_B =3D 0x60401013, + OPC_SEXT_H =3D 0x60501013, + OPC_XNOR =3D 0x40004033, + OPC_ZEXT_H =3D 0x0800403b, + + /* Zicond: integer conditional operations */ + OPC_CZERO_EQZ =3D 0x0e005033, + OPC_CZERO_NEZ =3D 0x0e007033, } RISCVInsn; =20 /* @@ -1619,8 +1661,62 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_RA, 0); } =20 +static volatile sig_atomic_t got_sigill; + +static void sigill_handler(int signo, siginfo_t *si, void *data) +{ + /* Skip the faulty instruction */ + ucontext_t *uc =3D (ucontext_t *)data; + uc->uc_mcontext.__gregs[REG_PC] +=3D 4; + + got_sigill =3D 1; +} + +static void tcg_target_detect_isa(void) +{ +#if !defined(have_zba) || !defined(have_zbb) || !defined(have_zicond) + /* + * TODO: It is expected that this will be determinable via + * linux riscv_hwprobe syscall, not yet merged. + * In the meantime, test via sigill. + */ + + struct sigaction sa_old, sa_new; + + memset(&sa_new, 0, sizeof(sa_new)); + sa_new.sa_flags =3D SA_SIGINFO; + sa_new.sa_sigaction =3D sigill_handler; + sigaction(SIGILL, &sa_new, &sa_old); + +#ifndef have_zba + /* Probe for Zba: add.uw zero,zero,zero. */ + got_sigill =3D 0; + asm volatile(".insn r 0x3b, 0, 0x04, zero, zero, zero" : : : "memory"); + have_zba =3D !got_sigill; +#endif + +#ifndef have_zbb + /* Probe for Zba: andn zero,zero,zero. */ + got_sigill =3D 0; + asm volatile(".insn r 0x33, 7, 0x20, zero, zero, zero" : : : "memory"); + have_zbb =3D !got_sigill; +#endif + +#ifndef have_zicond + /* Probe for Zicond: czero.eqz zero,zero,zero. */ + got_sigill =3D 0; + asm volatile(".insn r 0x33, 5, 0x07, zero, zero, zero" : : : "memory"); + have_zicond =3D !got_sigill; +#endif + + sigaction(SIGILL, &sa_old, NULL); +#endif +} + static void tcg_target_init(TCGContext *s) { + tcg_target_detect_isa(); + tcg_target_available_regs[TCG_TYPE_I32] =3D 0xffffffff; tcg_target_available_regs[TCG_TYPE_I64] =3D 0xffffffff; =20 --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038485; cv=none; d=zohomail.com; s=zohoarc; b=Xfg7hvhuxNydTuSsmTLoThP5r6c2LNFi5uY6tFx6vOYLNNFkqQqTnQBkHhKMfHhVtdFnsBa6Qp8MzOk5sRBSIudHNYPhFuzuIjSkYakRt36wtuqDEOw1HFzGjXlP4g9rfISBLEn0I0dQ1j3R5g2JkiS+g7E9Z5Un5VmMnsjkDwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038485; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kiv3PTsHfvHgxd1CsgFYSohQOglr+ZxIFeD2jueV4Ok=; b=WXwPlYlWQHCGHigvSp57kK4Ja4S1p7+1JufViKyCVvEATLjNqVmeYqCPUPx4ekOMMOQXW18+3+EI7ZI9gKDWtOSUOr4szgHk8Uipm4saV1dvVCAbhXyHjpzgB60isXzlOvjcpMZMX0Wye5+9fbmhLfQBZHhZhUDIZtzpC3kjjuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168503848595275.9500320882164; Thu, 25 May 2023 11:14:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQM-0008Re-GI; Thu, 25 May 2023 14:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQL-0008RG-KH for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQJ-0005we-Q5 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ae615d5018so13632805ad.1 for ; Thu, 25 May 2023 11:10:51 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038250; x=1687630250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Kiv3PTsHfvHgxd1CsgFYSohQOglr+ZxIFeD2jueV4Ok=; b=I0Dk1GXsSbT7SESanBSS4NaIm6OzKO33BC3Lr2h0iEEZrJPiNPX9iSzNF8Hl+1XTQT TXRZQRkWxhOrS2aJd+Tlq9QAgl3nIrA5n0DxuerSEoZVaR4KOlg6eKIeSe2bSpubq7l8 2hfresCNQNajpC7LsIhs0nPCaIrqx6QiHJ6bBIx8uGZWPRi0pAoE+kNfJjC3eSXer291 7FJZpqnyiUanQxrmPGjnYZtQHddIaidOYlDxwavhDY5haowzEofqBdo0Y1IKZxd5aL30 cGQosHbSRo60sPSC0+1jtdg7IZ4vP7bbQNP/A/o+nAApQgRq1pWXVV6+4X7CA9ReGryT FZfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038250; x=1687630250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kiv3PTsHfvHgxd1CsgFYSohQOglr+ZxIFeD2jueV4Ok=; b=FngYtDzCd19jo0qXOAvHHKwObBcA3m5/sNhWfWYBBh5uz8Hd2iHzehnciLrXFLcInR JtB5uYifFOr3Zyk+9m35JPr2ddoOFHLRtPN2GWQrl+/YOJm1PlwdCXtBJE0sPExM5YYR rwfr62iCQVg6nUV9ey2CWf+m3nom7il8Jz56T/8RUnrk4unTfidvxaOKwm89xXfkBa/m x0CWUvLYMCnJeMhkT1OSp9o8NACEMVEi9PwrOzIHNbyQWXdBhsYlRrlMBtaQYIJhMBq8 wjYu30uAwds0VIOtWDqc5Ba87kuJRMXHbj4WUb0BkHbp7NLvrsy+0O0RgKB/GFUhYTVB vZvA== X-Gm-Message-State: AC+VfDwzFzeZA0X+xZGqpgpcLyQbQWREtLiSLiobZbFR1s7jt56+hKU0 5znl7ssJ65A42iwGrtBmfYr15X1sCkIQg+xJexA= X-Google-Smtp-Source: ACHHUZ6g63OzlZzWddC+kbe4qmk36QEnH7Rz2Up92xCLDzjyhEP1GTpB9QiETCcir+IkMpS1VOJ4oQ== X-Received: by 2002:a17:902:e54d:b0:1af:babd:7b6d with SMTP id n13-20020a170902e54d00b001afbabd7b6dmr2858918plf.52.1685038250511; Thu, 25 May 2023 11:10:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 15/23] tcg/riscv: Support ANDN, ORN, XNOR from Zbb Date: Thu, 25 May 2023 11:10:28 -0700 Message-Id: <20230525181036.1559435-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038487668100001 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target-con-set.h | 1 + tcg/riscv/tcg-target-con-str.h | 1 + tcg/riscv/tcg-target.h | 12 +++++----- tcg/riscv/tcg-target.c.inc | 41 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/tcg/riscv/tcg-target-con-set.h b/tcg/riscv/tcg-target-con-set.h index d88888d3ac..1a33ece98f 100644 --- a/tcg/riscv/tcg-target-con-set.h +++ b/tcg/riscv/tcg-target-con-set.h @@ -15,6 +15,7 @@ C_O0_I2(rZ, rZ) C_O1_I1(r, r) C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) +C_O1_I2(r, r, rJ) C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) C_O2_I4(r, r, rZ, rZ, rM, rM) diff --git a/tcg/riscv/tcg-target-con-str.h b/tcg/riscv/tcg-target-con-str.h index 6f1cfb976c..d5c419dff1 100644 --- a/tcg/riscv/tcg-target-con-str.h +++ b/tcg/riscv/tcg-target-con-str.h @@ -15,6 +15,7 @@ REGS('r', ALL_GENERAL_REGS) * CONST(letter, TCG_CT_CONST_* bit set) */ CONST('I', TCG_CT_CONST_S12) +CONST('J', TCG_CT_CONST_J12) CONST('N', TCG_CT_CONST_N12) CONST('M', TCG_CT_CONST_M12) CONST('Z', TCG_CT_CONST_ZERO) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 863ac8ba2f..9f58d46208 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -120,9 +120,9 @@ extern bool have_zbb; #define TCG_TARGET_HAS_bswap32_i32 0 #define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_neg_i32 1 -#define TCG_TARGET_HAS_andc_i32 0 -#define TCG_TARGET_HAS_orc_i32 0 -#define TCG_TARGET_HAS_eqv_i32 0 +#define TCG_TARGET_HAS_andc_i32 have_zbb +#define TCG_TARGET_HAS_orc_i32 have_zbb +#define TCG_TARGET_HAS_eqv_i32 have_zbb #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_nor_i32 0 #define TCG_TARGET_HAS_clz_i32 0 @@ -154,9 +154,9 @@ extern bool have_zbb; #define TCG_TARGET_HAS_bswap64_i64 0 #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 1 -#define TCG_TARGET_HAS_andc_i64 0 -#define TCG_TARGET_HAS_orc_i64 0 -#define TCG_TARGET_HAS_eqv_i64 0 +#define TCG_TARGET_HAS_andc_i64 have_zbb +#define TCG_TARGET_HAS_orc_i64 have_zbb +#define TCG_TARGET_HAS_eqv_i64 have_zbb #define TCG_TARGET_HAS_nand_i64 0 #define TCG_TARGET_HAS_nor_i64 0 #define TCG_TARGET_HAS_clz_i64 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index eb3e2e9eb0..edfe4c8f8d 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -138,6 +138,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKin= d kind, int slot) #define TCG_CT_CONST_S12 0x200 #define TCG_CT_CONST_N12 0x400 #define TCG_CT_CONST_M12 0x800 +#define TCG_CT_CONST_J12 0x1000 =20 #define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 32) =20 @@ -174,6 +175,13 @@ static bool tcg_target_const_match(int64_t val, TCGTyp= e type, int ct) if ((ct & TCG_CT_CONST_M12) && val >=3D -0x7ff && val <=3D 0x7ff) { return 1; } + /* + * Inverse of sign extended from 12 bits: ~[-0x800, 0x7ff]. + * Used to map ANDN back to ANDI, etc. + */ + if ((ct & TCG_CT_CONST_J12) && ~val >=3D -0x800 && ~val <=3D 0x7ff) { + return 1; + } return 0; } =20 @@ -1305,6 +1313,31 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; =20 + case INDEX_op_andc_i32: + case INDEX_op_andc_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ANDI, a0, a1, ~a2); + } else { + tcg_out_opc_reg(s, OPC_ANDN, a0, a1, a2); + } + break; + case INDEX_op_orc_i32: + case INDEX_op_orc_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ORI, a0, a1, ~a2); + } else { + tcg_out_opc_reg(s, OPC_ORN, a0, a1, a2); + } + break; + case INDEX_op_eqv_i32: + case INDEX_op_eqv_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_XORI, a0, a1, ~a2); + } else { + tcg_out_opc_reg(s, OPC_XNOR, a0, a1, a2); + } + break; + case INDEX_op_not_i32: case INDEX_op_not_i64: tcg_out_opc_imm(s, OPC_XORI, a0, a1, -1); @@ -1539,6 +1572,14 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) case INDEX_op_xor_i64: return C_O1_I2(r, r, rI); =20 + case INDEX_op_andc_i32: + case INDEX_op_andc_i64: + case INDEX_op_orc_i32: + case INDEX_op_orc_i64: + case INDEX_op_eqv_i32: + case INDEX_op_eqv_i64: + return C_O1_I2(r, r, rJ); + case INDEX_op_sub_i32: case INDEX_op_sub_i64: return C_O1_I2(r, rZ, rN); --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038283; cv=none; d=zohomail.com; s=zohoarc; b=fXa9UBCWXfk6GASPWzyg/fI0ENj8EBhYWGK/OuCmRnDBka1eTYIjpEnCwz58L+nAUSZd0C5kkOMYisK7/WtpajzM1F1pvAhTSWdGpJTN/d4R4zdyh8PkuHVPyUnGUWW8hN4ql9J9EVIDXtNo4ZfAj3WmZ2xapmKq3n8lSbZrFPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038283; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2HzbBgDnZuyuhsCwWOOWXMwV0vq7jpkLgIfNcztp/e8=; b=Th5iIFSr+9EidgEnIFYqXmhyEAlYdNCqO7fMBUQ1yuX6wtlBLi3zwzrjm/xk9AmGUPk9E4Olgajdfgry4WBeMZFsxrq58HL6ctzHj8/I0pTpiRu/uCOpJuYb3qf/DQaX1Djc+XQs5mHmlkGZHjmH/Zr4Sl/rjaAtC9tDPD3w6IU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038283572898.5141301114701; Thu, 25 May 2023 11:11:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQO-0008Sy-7h; Thu, 25 May 2023 14:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQM-0008RY-94 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:54 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQK-0005xU-LZ for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:54 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ae452c2777so148465ad.0 for ; Thu, 25 May 2023 11:10:52 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038251; x=1687630251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2HzbBgDnZuyuhsCwWOOWXMwV0vq7jpkLgIfNcztp/e8=; b=l48/yNCUvYyle7p7nqC5egUaP7kcI08KzHXlugz/fqZcK1lNeuPHuqI5kXy/ZfmawJ 4PfWF/Ka3uF4ng5yah/fs101yIxx3A3UoXaDZkwlIRchtCxeOARE0oRf6O62TK6b6oSo EM8iENDCkAZYuUHsguJQ0HFrJYsyOsG5VbbV+f3g2aTMfYY0hRzHp77rlnrSZxJvMz3s Mazovd9D4wXVO5NAC1s7A+lA226uoe22lZmjDKh1AKUDmzLhJ4kIA1+jvGwAg1cdfPW9 HHmttDMs0UvyQ+wcKud0aBFfezI8ZqVKWiG+Kd+JRFSPD1D58W694xKTJwjcEGcxEC+i Uj1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038251; x=1687630251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2HzbBgDnZuyuhsCwWOOWXMwV0vq7jpkLgIfNcztp/e8=; b=Mdn1RmEg274xo7CDtaRAH7w2v/2wKHFhipf78XyX7cq+x0YypVHBd2a5RVfi7y8pNe NdYKY3flmUdUFym27QckX8rtf/m7F+rHbEn3nUZF+ssqr52MqxOgChduHkqpJAm023Wn 5i1hUlcSaQgC0XNTwG3JQeJ2RXl2JpGbUSsVOmLmo9h8HYtNq2ltybiE4EE0Aa53mddG 6ZPNZZEIIpUTO/d8VcaOqLq9gK0aZ1F3oT6xPSZlQ7oe+VZl6iO03UGmnEHOlmtFBm9n 3jOCYbeyG0FNVNzKhNOCzqgUCzwbrVOGgZ+vkHGhuRsCPlirG0OvKaoCerbxj9oRvYrV YuaQ== X-Gm-Message-State: AC+VfDyihvm9fkpTfFQyDuAq0ZF68C1ux2C84Ig1bTcOZdyTLur/5tNg EB4mt29/5/5K1MgiYyOh5+kcglO51KixQouAYgE= X-Google-Smtp-Source: ACHHUZ4Z9aKO9PhuRzx+HKtgcJTCyCCggaDt7UQqOchrZr5SoVBaPxjktbz7R8l7CCjjtOPJa7Ytnw== X-Received: by 2002:a17:903:44c:b0:1ae:4dda:c2e with SMTP id iw12-20020a170903044c00b001ae4dda0c2emr2591059plb.13.1685038251449; Thu, 25 May 2023 11:10:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 16/23] tcg/riscv: Support ADD.UW, SEXT.B, SEXT.H, ZEXT.H from Zba+Zbb Date: Thu, 25 May 2023 11:10:29 -0700 Message-Id: <20230525181036.1559435-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038285297100003 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index edfe4c8f8d..297119817b 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -593,26 +593,42 @@ static void tcg_out_ext8u(TCGContext *s, TCGReg ret, = TCGReg arg) =20 static void tcg_out_ext16u(TCGContext *s, TCGReg ret, TCGReg arg) { - tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); - tcg_out_opc_imm(s, OPC_SRLIW, ret, ret, 16); + if (have_zbb) { + tcg_out_opc_reg(s, OPC_ZEXT_H, ret, arg, TCG_REG_ZERO); + } else { + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); + tcg_out_opc_imm(s, OPC_SRLIW, ret, ret, 16); + } } =20 static void tcg_out_ext32u(TCGContext *s, TCGReg ret, TCGReg arg) { - tcg_out_opc_imm(s, OPC_SLLI, ret, arg, 32); - tcg_out_opc_imm(s, OPC_SRLI, ret, ret, 32); + if (have_zba) { + tcg_out_opc_reg(s, OPC_ADD_UW, ret, arg, TCG_REG_ZERO); + } else { + tcg_out_opc_imm(s, OPC_SLLI, ret, arg, 32); + tcg_out_opc_imm(s, OPC_SRLI, ret, ret, 32); + } } =20 static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg ret, TCGReg = arg) { - tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 24); - tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 24); + if (have_zbb) { + tcg_out_opc_imm(s, OPC_SEXT_B, ret, arg, 0); + } else { + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 24); + tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 24); + } } =20 static void tcg_out_ext16s(TCGContext *s, TCGType type, TCGReg ret, TCGReg= arg) { - tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); - tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 16); + if (have_zbb) { + tcg_out_opc_imm(s, OPC_SEXT_H, ret, arg, 0); + } else { + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); + tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 16); + } } =20 static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038328; cv=none; d=zohomail.com; s=zohoarc; b=CPRLBVs9Yj03LNDQkKw8qWFYkX43t/e7VaAAcCHX1WjzU002VezKHknDVR6+4rXyDDWSIuA+xO0Lb+HnO2AcEFbLuPmwvTbgUwl5dfthAfua30/jyOMD0nWYjfXSkwTbzcpruSj9dyI8nBR8yzKOANJdo22XxOA+/Hfhhjj8PME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038328; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=gD01zJT45/ekS1LFfGx+SAZ1cRYlTWgFnPjdXf6W5i5JDkHsSNUZpY1JJpiPxakEpmAeIO8rQ4yCZM7Kz3mNz7sdzeUbhatgWm1gXB4EPMhmail2s4xN7Flc71yPWMP+dGgOZs625/pzk9mgsxlI5n086hzj1yRa12EK+TemOUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038328714868.799041170426; Thu, 25 May 2023 11:12:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQQ-0008Vj-Rr; Thu, 25 May 2023 14:10:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQN-0008SH-7q for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:55 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQL-0005y6-IC for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:55 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae452c2777so148545ad.0 for ; Thu, 25 May 2023 11:10:53 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038252; x=1687630252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=SxI2lNtAAhjrfGAF5nGJP7WLiG2XOKloesvx9sNYPQQhvoECYofn2Hs1RgLAif0a3Q hxm7yuIjNsIO6DQPOVUg3NbPmSdEJBHU+uAnj4Vw4M2fh1sUfKL7DtJUHWim5SvfPubW xDT/8I86IgtE+G5ga7MnFpGBWwbCGkR9d2MZShuYQZvjmwSuLF8APah0e1KEtBOZQI8C Ua+fq2EDPSp0nyhE8ARzRXH73Qok254yaG7UJH2B0YJJDzuee7n7oSwsPNUPRSr4s3Ll YYu25eyEOzsqZ7nw5MH4NHgDf5Nsyu1lZUoY35BCEu3JFihl8fns1N7A2ts+ywcru9rf 5tGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038252; x=1687630252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=Rukke6rHWx2T9VpYJGDMkPhmOVPH8JP8S/B+q7T5ISnh//4frhaRWSkPJ1V5veFLLk E0KQLDXmOhNedg52zIsiZsonJ1zBr81EZAYGLxrtEcTVieuEobSzVPTo8wTjfKMZHww5 0Nc1nxapJZBFDKZZu0OvtdHduCYpaZKgBi5wQkG74MCuwmL3UEVRstwh4OaqHBcj/yh3 V2RYwqglNKgIa8HRLoJKU77zQU0CMP8c4Sdx4wVJxvpPfnD6kQR/LelAzKutDjEUaCAH uk6bkdIT/q7+7CMfBetIKLTphNzkNnPsTRDu+NAWc5fDp0KdCcpq6JimpJSqW6txD2NM Evwg== X-Gm-Message-State: AC+VfDzF0IS9sXIgOpxSTiVY4hhu1LaQ0VRLPT4CmbFiWmmv7Usa2CEO NaGo+5npUwnsZXdfRc+RM261kYwZ1c9X1Kleuzc= X-Google-Smtp-Source: ACHHUZ732+QNnD52cGUpFEdDcsXb/uq1zDhqcGHOJZuQv/YrYpmNEBD/rJXkKTDgwgnZno4aAPBvxA== X-Received: by 2002:a17:903:44c:b0:1ae:4dda:c2e with SMTP id iw12-20020a170903044c00b001ae4dda0c2emr2591094plb.13.1685038252174; Thu, 25 May 2023 11:10:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 17/23] tcg/riscv: Use ADD.UW for guest address generation Date: Thu, 25 May 2023 11:10:30 -0700 Message-Id: <20230525181036.1559435-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038330426100003 Content-Type: text/plain; charset="utf-8" The instruction is a combined zero-extend and add. Use it for exactly that. Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 297119817b..2fdd450da3 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1038,14 +1038,18 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, TCGReg *pbase, tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); =20 /* TLB Hit - translate address using addend. */ - addr_adj =3D addr_reg; - if (TARGET_LONG_BITS =3D=3D 32) { - addr_adj =3D TCG_REG_TMP0; - tcg_out_ext32u(s, addr_adj, addr_reg); + if (TARGET_LONG_BITS =3D=3D 64) { + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, addr_reg, TCG_REG_TMP2); + } else if (have_zba) { + tcg_out_opc_reg(s, OPC_ADD_UW, TCG_REG_TMP0, addr_reg, TCG_REG_TMP= 2); + } else { + tcg_out_ext32u(s, TCG_REG_TMP0, addr_reg); + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP0, TCG_REG_TM= P2); } - tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addr_adj); *pbase =3D TCG_REG_TMP0; #else + TCGReg base; + if (a_mask) { ldst =3D new_ldst_label(s); ldst->is_ld =3D is_ld; @@ -1060,14 +1064,21 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, TCGReg *pbase, tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP1, TCG_REG_ZERO, 0); } =20 - TCGReg base =3D addr_reg; - if (TARGET_LONG_BITS =3D=3D 32) { - tcg_out_ext32u(s, TCG_REG_TMP0, base); - base =3D TCG_REG_TMP0; - } if (guest_base !=3D 0) { - tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_GUEST_BASE_REG, base= ); base =3D TCG_REG_TMP0; + if (TARGET_LONG_BITS =3D=3D 64) { + tcg_out_opc_reg(s, OPC_ADD, base, addr_reg, TCG_GUEST_BASE_REG= ); + } else if (have_zba) { + tcg_out_opc_reg(s, OPC_ADD_UW, base, addr_reg, TCG_GUEST_BASE_= REG); + } else { + tcg_out_ext32u(s, base, addr_reg); + tcg_out_opc_reg(s, OPC_ADD, base, base, TCG_GUEST_BASE_REG); + } + } else if (TARGET_LONG_BITS =3D=3D 64) { + base =3D addr_reg; + } else { + base =3D TCG_REG_TMP0; + tcg_out_ext32u(s, base, addr_reg); } *pbase =3D base; #endif --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038488; cv=none; d=zohomail.com; s=zohoarc; b=mCmno24/R3A9ywVmlwAXevxG4OGQdQxwiehqmfZKaXfjCb6bUKNUkouY1XIjB/qe7EY2fteVti/Yk/0tQah1ejhBmWg71lbQvOVzncHdaKgMKbg/7fGBRQNbH1OH8+oDDv2VTA6/J8/O5DRJtzpicNC2Q5vr1ar4ewbXlFPPHZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038488; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l1HPhkHQuFzsHgTzLhVx0No3GK62rrEnumKuXLdYldA=; b=aaBucBj4mTKCdR3MPq7Ud02TWVw6F6hiQqB3mr5jACtOUNMgr3QXg/aSKJuMEMdJCZ7/zGLC8V1jvyqJDafLXXCiAO+zaTF1MZo0D/nGPfF4JiK64A6+s5m96zVrOMWSr+JQNXD5Y8eeUZTj1aIhcxCH67NT4EEiRWx4pKxPag0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038488763752.1083887242773; Thu, 25 May 2023 11:14:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQR-00005R-KO; Thu, 25 May 2023 14:10:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQO-0008Sc-0I for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:56 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQM-0005yc-CL for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:55 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-53404873a19so1355122a12.3 for ; Thu, 25 May 2023 11:10:53 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038253; x=1687630253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l1HPhkHQuFzsHgTzLhVx0No3GK62rrEnumKuXLdYldA=; b=n1pyR+Rcc+LzxIY9nwKOexB7/xbEjbU9y0OTsFNUT3s3mJQ5o4Catl4UBWySCzmYq+ Qj8BEe/p7WZ45FGBsvIXUff8rVfrqT4Cvz1Y4Pak4t9fW/wwlOz+lQa217AcpLFABhI4 o7nevBWM1WnzXNCZsS1kbUVtaAkMtSR52v3ELAtSNjlcQP/IM0+pQL9T4//8D2xB4EN8 qNtPtE2RZHBsqb6RtvttB4KH/5VNKbcL4axulvu+BwQFN+AgLj4skYPRzU7dorQuUxsm JjsqAD61M/cP4giOJe2h04QQ7IeG56zSGxAQzqAg9Yx5mFwnZ9oPbR2r1dInxLFv+fmd cMBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038253; x=1687630253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l1HPhkHQuFzsHgTzLhVx0No3GK62rrEnumKuXLdYldA=; b=gmYCvdxcfswa7U/hmPrj/n4csLmfVa07JuHSb6ftaVGZDR+RJkZwksMLMGImtYQt/0 NRIgjzxOwSPQT7rpsjtSukWEdeY/tebYCKPXq2axTkZjpHVLGOm3L1LoLEaPFcq05VHe iaJSwcHUEQ7eZDx1JjLRK3TnGXdqMucusicXrH7lyzKLPd7pcMvZGRjnN1Hdoaw+/BVh ZQTPeW29Rb6spOh26zb+4GkjujIPYeyQFuleC7uDWbwEYtkhdVvADQv2ZIW9/0GoGegj cWZJTW4eNKJ1dos7NqhBqjS80+eDSKhAfRyf4Dogm81NUT/Uchp1okCi5xcQxeixVfQ0 djzA== X-Gm-Message-State: AC+VfDz2ZMLvGXCaew6KceW3XY/W5TabbW1xgy02E16jbk11szYHJ1dG en0y6Fdwqei/LsXTRIUx85SJYrc0HhsmgxWCUj4= X-Google-Smtp-Source: ACHHUZ4r/SgFzlMwha6dNKybd9FIaW9dgQIsHB3tr8QnFX6rDVL4i9LxyqmCG8FA5iEui6lsaK3q8g== X-Received: by 2002:a17:902:b586:b0:1ad:e198:c4fc with SMTP id a6-20020a170902b58600b001ade198c4fcmr2351237pls.54.1685038252895; Thu, 25 May 2023 11:10:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 18/23] tcg/riscv: Support rotates from Zbb Date: Thu, 25 May 2023 11:10:31 -0700 Message-Id: <20230525181036.1559435-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038489953100001 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 4 ++-- tcg/riscv/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 9f58d46208..317d385924 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -101,7 +101,7 @@ extern bool have_zbb; #define TCG_TARGET_HAS_div_i32 1 #define TCG_TARGET_HAS_rem_i32 1 #define TCG_TARGET_HAS_div2_i32 0 -#define TCG_TARGET_HAS_rot_i32 0 +#define TCG_TARGET_HAS_rot_i32 have_zbb #define TCG_TARGET_HAS_deposit_i32 0 #define TCG_TARGET_HAS_extract_i32 0 #define TCG_TARGET_HAS_sextract_i32 0 @@ -136,7 +136,7 @@ extern bool have_zbb; #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_div2_i64 0 -#define TCG_TARGET_HAS_rot_i64 0 +#define TCG_TARGET_HAS_rot_i64 have_zbb #define TCG_TARGET_HAS_deposit_i64 0 #define TCG_TARGET_HAS_extract_i64 0 #define TCG_TARGET_HAS_sextract_i64 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 2fdd450da3..cc96425413 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1457,6 +1457,36 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; =20 + case INDEX_op_rotl_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_RORIW, a0, a1, -a2 & 0x1f); + } else { + tcg_out_opc_reg(s, OPC_ROLW, a0, a1, a2); + } + break; + case INDEX_op_rotl_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_RORI, a0, a1, -a2 & 0x3f); + } else { + tcg_out_opc_reg(s, OPC_ROL, a0, a1, a2); + } + break; + + case INDEX_op_rotr_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_RORIW, a0, a1, a2 & 0x1f); + } else { + tcg_out_opc_reg(s, OPC_RORW, a0, a1, a2); + } + break; + case INDEX_op_rotr_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_RORI, a0, a1, a2 & 0x3f); + } else { + tcg_out_opc_reg(s, OPC_ROR, a0, a1, a2); + } + break; + case INDEX_op_add2_i32: tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], const_args[4], const_args[5], false, true); @@ -1632,9 +1662,13 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) case INDEX_op_shl_i32: case INDEX_op_shr_i32: case INDEX_op_sar_i32: + case INDEX_op_rotl_i32: + case INDEX_op_rotr_i32: case INDEX_op_shl_i64: case INDEX_op_shr_i64: case INDEX_op_sar_i64: + case INDEX_op_rotl_i64: + case INDEX_op_rotr_i64: return C_O1_I2(r, r, ri); =20 case INDEX_op_brcond_i32: --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038501; cv=none; d=zohomail.com; s=zohoarc; b=AvUTc58hecL4a4GbWVwnyDai9qDcccDy/uYfYoSRo9EwEeFf3qMfFqX0TKyJXJjh28StriabddqKMxMJgkahkcgJ+SZkuW0n1rQVxJ0dJF2JKiRIobHpfTgtQQm6S025DtGiU5qDhdHjNke6+jkV95U18d3TwcJPbUXfAiFW0dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038501; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KNuVE5/hYtEnyIruKa1nN0D/wZFDLkSC2ujquVv/MBE=; b=kLZ8DuYAOH5jzuZTXUDxvL+knGAwpdrslV/KZQme7yjgGHmzm36Nro4TPe3HDtFABCuvCdTS2EeLjNFh7AywLFwd0qSN+RUQHHXHWYHXudLFiAfssV9OBnMh39w8fVP5GOlg5FMfqG7vbyPawEgsh45H5b3/LziOqKgBhdPNYvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038501120586.4772542949148; Thu, 25 May 2023 11:15:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQW-0000Be-3n; Thu, 25 May 2023 14:11:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQU-00008T-Lm for qemu-devel@nongnu.org; Thu, 25 May 2023 14:11:02 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQM-0005zJ-ST for qemu-devel@nongnu.org; Thu, 25 May 2023 14:11:02 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae3ed1b08eso16977345ad.0 for ; Thu, 25 May 2023 11:10:54 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038253; x=1687630253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KNuVE5/hYtEnyIruKa1nN0D/wZFDLkSC2ujquVv/MBE=; b=WgNCveAuDMeH+ZCblNaCfiYsdMjLdPerljTmhlXc471YglK8fEYXbsSV67JPDHE/ew ywKPDg1zg/lI9XWtyigCUHBckF1sIrvdBdH1dxvoxvHoaRToSCQGY+zSQZL2UoVZQctC vkGaHNQgzhUxlrRWHiQ93CAKUn3n8fKWj6Ydg7FQsQyysBlDeAty/L+mDqUwebbqv8Ba mbFWVKMHYc6eLrDRA3FewsUou2zxt355i1I0Eiy4B6CgJdIfs0snafecQAeVdBc9S9d5 a/B9Eer3cRGORolrP+0MAihjDKibVhSpD4enQCY1qFG7G/Qsm0QuDxyg83nRSeu8OiWb ZuxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038253; x=1687630253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KNuVE5/hYtEnyIruKa1nN0D/wZFDLkSC2ujquVv/MBE=; b=DC81K6SIZst9YdzsyuOWKEmpAzABaUPrFR+gnGttlANtkuSXv3B1/o1ja01JGgqx9g iCSLUfuZRbhpfDI9DQfeXgwLVEgP+WtxMSk+eAC3cK6dOP1cBO3gqZZyZKEb8IMu8yES KRlHSTNZvaXxOXBYmZCdfEVubo3fT9P4vwflUlbKwW5RS8mq5E2+KOZKhIwodyKzlY6Y aA826VuqQIrnerOIvDw2nt3to5Rn4dam8Rvq5KCIHH97ohGjajIkquUC+Q80fYcNCQyc EV0WYZxNk/G/tY+PhWuxF/o9PuxFCs8z5xK/9Ucb9HAfKLA4viP0JnNENGSDg+uC5y3x DZUw== X-Gm-Message-State: AC+VfDxx302Z8czxtuf0qd6Wd34WfXfWjVjl8HEYEvWFotgXxFrSLfqQ 9lXQGXgIU2/+Fa1pInRgVyS+Pszep9TF7/doa+E= X-Google-Smtp-Source: ACHHUZ49Go9U9ZmvFxCDJCBz+t2EiVs8uQk0EcCdwclb4M5lho4L+tYux5+DCCgz42qk1ZMS07pv0w== X-Received: by 2002:a17:902:714c:b0:1aa:ee36:40a5 with SMTP id u12-20020a170902714c00b001aaee3640a5mr2297042plm.34.1685038253643; Thu, 25 May 2023 11:10:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 19/23] tcg/riscv: Support REV8 from Zbb Date: Thu, 25 May 2023 11:10:32 -0700 Message-Id: <20230525181036.1559435-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038501760100006 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 10 +++++----- tcg/riscv/tcg-target.c.inc | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 317d385924..8e327afc3a 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -116,8 +116,8 @@ extern bool have_zbb; #define TCG_TARGET_HAS_ext16s_i32 1 #define TCG_TARGET_HAS_ext8u_i32 1 #define TCG_TARGET_HAS_ext16u_i32 1 -#define TCG_TARGET_HAS_bswap16_i32 0 -#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_bswap16_i32 have_zbb +#define TCG_TARGET_HAS_bswap32_i32 have_zbb #define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_neg_i32 1 #define TCG_TARGET_HAS_andc_i32 have_zbb @@ -149,9 +149,9 @@ extern bool have_zbb; #define TCG_TARGET_HAS_ext8u_i64 1 #define TCG_TARGET_HAS_ext16u_i64 1 #define TCG_TARGET_HAS_ext32u_i64 1 -#define TCG_TARGET_HAS_bswap16_i64 0 -#define TCG_TARGET_HAS_bswap32_i64 0 -#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_bswap16_i64 have_zbb +#define TCG_TARGET_HAS_bswap32_i64 have_zbb +#define TCG_TARGET_HAS_bswap64_i64 have_zbb #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 1 #define TCG_TARGET_HAS_andc_i64 have_zbb diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index cc96425413..cb4afb4733 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1487,6 +1487,30 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; =20 + case INDEX_op_bswap64_i64: + tcg_out_opc_imm(s, OPC_REV8, a0, a1, 0); + break; + case INDEX_op_bswap32_i32: + a2 =3D 0; + /* fall through */ + case INDEX_op_bswap32_i64: + tcg_out_opc_imm(s, OPC_REV8, a0, a1, 0); + if (a2 & TCG_BSWAP_OZ) { + tcg_out_opc_imm(s, OPC_SRLI, a0, a0, 32); + } else { + tcg_out_opc_imm(s, OPC_SRAI, a0, a0, 32); + } + break; + case INDEX_op_bswap16_i64: + case INDEX_op_bswap16_i32: + tcg_out_opc_imm(s, OPC_REV8, a0, a1, 0); + if (a2 & TCG_BSWAP_OZ) { + tcg_out_opc_imm(s, OPC_SRLI, a0, a0, 48); + } else { + tcg_out_opc_imm(s, OPC_SRAI, a0, a0, 48); + } + break; + case INDEX_op_add2_i32: tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], const_args[4], const_args[5], false, true); @@ -1608,6 +1632,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: case INDEX_op_ext_i32_i64: + case INDEX_op_bswap16_i32: + case INDEX_op_bswap32_i32: + case INDEX_op_bswap16_i64: + case INDEX_op_bswap32_i64: + case INDEX_op_bswap64_i64: return C_O1_I1(r, r); =20 case INDEX_op_st8_i32: --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038500; cv=none; d=zohomail.com; s=zohoarc; b=XwQZkHU1fBbLD4N9cGUTgxK1YczEr9VhCV4tPEjYLP4q5DDemT8CV97RKZLDwEacTXai69cT20n8uEzeJKZEBm0L7fRFp/lEYZqYuxQVXdo+V9k64lDOpFoc/CKLQ9liLmTb82BRKlkYvN+kCqDcsLhDxePcum29GNbj/aiFAh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038500; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f+yUsbKoScoR37tEqHJpwp6atQ/4Z4oAuy6m32A5GM4=; b=PSXTu0JEORuUswrPWlNLjhaH89jkpvXgRbw++5QcaMHg17V365ZqQ57JMnYRvQrgnfe3/RrFelRfJ7fwNeGdAOvNgR+Fltpo0gee2D1JocRKORT/FxhhOatPrsKgvXFtcapbn9k1JFr8y3KqgDheqSqKZIICgfqW/EcYSAZzyF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038500523332.71214803978717; Thu, 25 May 2023 11:15:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQR-00005d-QU; Thu, 25 May 2023 14:10:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQP-0008TO-EG for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:57 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQN-0005rF-Ln for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:57 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-53033a0b473so1364294a12.0 for ; Thu, 25 May 2023 11:10:54 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038254; x=1687630254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f+yUsbKoScoR37tEqHJpwp6atQ/4Z4oAuy6m32A5GM4=; b=Zbc2vaAwsmPV4bGiNBw6DMQespxAYcHW5mky08e1k990DvNzMLtBE1G3p3DHRX0thj 1akq6aEmIrSbTDPqHHivXK1SxjkQ+iCt4b1NkNl/q36m/GtMTTw1YGaYoVnos7shBDHb 6OJhPMVWzfw9MecHkhWMIlqsPMcStw1asJPXZYitJHofbIxtg7VJjMjpcHGhwP4u7dmi rMJdsS7VnnqpW41qqmD3y6ylFNrIQQIgFvCBFkG6ATpsOc8P9xatcxEDSa/1x0uUn1q9 XQVKZyIWsMegU5xWY0mFpHcocFcP0ha833fmua82FvzAAKatknKzqhstnysP4UtatrXY p6hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038254; x=1687630254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f+yUsbKoScoR37tEqHJpwp6atQ/4Z4oAuy6m32A5GM4=; b=JpfxtgOJwkWaZdiV2F3Ksb0hL8dZ3FtqXvqzOT5F+Hh0205uHaiS0L8TkuZh9aOXpH QcLCSFg14J26x4WcGglXDsbYUMmyq3+bUHgUDL6agHZY1ZyYAX17MkWkVhhnI815Nok9 w7k8HOkNiIfqvvFgWrrEnPY5xNcI689/7xEHkcHeXX9eR4+wf3ChGgTLyH7QPRtyCiWI JDR92WztXWEZmuQVo9olidsQcO9JeRrKkiPQoGMpfvtMZ8m3As2RfpgCpgX1VJ3cM19J 1+JxakwETaDD8KLXhfJ4Enl/X0v3nPWjxOlCnwkxHZ2xVB+PLhZnHbOKh780HI2OBpd6 xceA== X-Gm-Message-State: AC+VfDznYl3ixmSoOk3p3PoJo8ui22Y0hi1S39wor68wRLyNGd8OY2TH aFo6eJRZEumunq4GSmavwHmK9AoWWRXXFpHzkZQ= X-Google-Smtp-Source: ACHHUZ4MOQVB0YcS34HxUCHpIU71i0iv2359GK636X0eHDebunGcpY/GfIWKsB88z4aymoHoGRZ8Mg== X-Received: by 2002:a17:902:d48e:b0:1af:f4f5:6fa3 with SMTP id c14-20020a170902d48e00b001aff4f56fa3mr2734890plg.55.1685038254388; Thu, 25 May 2023 11:10:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 20/23] tcg/riscv: Support CPOP from Zbb Date: Thu, 25 May 2023 11:10:33 -0700 Message-Id: <20230525181036.1559435-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038502298100009 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 4 ++-- tcg/riscv/tcg-target.c.inc | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 8e327afc3a..e0b23006c4 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -127,7 +127,7 @@ extern bool have_zbb; #define TCG_TARGET_HAS_nor_i32 0 #define TCG_TARGET_HAS_clz_i32 0 #define TCG_TARGET_HAS_ctz_i32 0 -#define TCG_TARGET_HAS_ctpop_i32 0 +#define TCG_TARGET_HAS_ctpop_i32 have_zbb #define TCG_TARGET_HAS_brcond2 1 #define TCG_TARGET_HAS_setcond2 1 #define TCG_TARGET_HAS_qemu_st8_i32 0 @@ -161,7 +161,7 @@ extern bool have_zbb; #define TCG_TARGET_HAS_nor_i64 0 #define TCG_TARGET_HAS_clz_i64 0 #define TCG_TARGET_HAS_ctz_i64 0 -#define TCG_TARGET_HAS_ctpop_i64 0 +#define TCG_TARGET_HAS_ctpop_i64 have_zbb #define TCG_TARGET_HAS_add2_i64 1 #define TCG_TARGET_HAS_sub2_i64 1 #define TCG_TARGET_HAS_mulu2_i64 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index cb4afb4733..05ea9fead8 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1511,6 +1511,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; =20 + case INDEX_op_ctpop_i32: + tcg_out_opc_imm(s, OPC_CPOPW, a0, a1, 0); + break; + case INDEX_op_ctpop_i64: + tcg_out_opc_imm(s, OPC_CPOP, a0, a1, 0); + break; + case INDEX_op_add2_i32: tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], const_args[4], const_args[5], false, true); @@ -1637,6 +1644,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_bswap16_i64: case INDEX_op_bswap32_i64: case INDEX_op_bswap64_i64: + case INDEX_op_ctpop_i32: + case INDEX_op_ctpop_i64: return C_O1_I1(r, r); =20 case INDEX_op_st8_i32: --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038449; cv=none; d=zohomail.com; s=zohoarc; b=VydBaR90GqgcifRa3vYRtdWwGZaIOcRivkvL2NmE0QLjiUfCFUHx/CUOgnzmi62Ytn1so43x+l9eQs6VbGyfQJvhd33NFOBIc5PU+H4t68+dFyRlcBwF1s1JIzzF+MLQzjhLiw2WD8ZrxJuk7Jdj6m0lG7a53Bqrfd/qm38eGzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038449; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XhELp8moK7/6JDjvycSVE/PjyFSTn3Ab+xYUGXGPpO8=; b=VjJksqhaTL3oFBy7hiem4FmP5/V3FDkiAbc+MZrQKUCVAnwTXep43k0NAmeBm0F+HN2ZAQhd9du3eJnRUPw8SdhRYK5dZQM9wjHU2S7VNfDp74snBLufVb+uAQXVatu88RwG1AJc80iNyck2hwDxr01YK2ntkzOL/+k4MuB7MpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038449890398.96039190239424; Thu, 25 May 2023 11:14:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQS-00005v-9S; Thu, 25 May 2023 14:11:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQQ-0008Vh-O9 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:58 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQO-00060L-N9 for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:58 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-53404873a19so1355143a12.3 for ; Thu, 25 May 2023 11:10:56 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038255; x=1687630255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XhELp8moK7/6JDjvycSVE/PjyFSTn3Ab+xYUGXGPpO8=; b=qhPIRdOfFbixwzgipsFtVCcHvKe19QUFXB0KyOtTxcgUCP36GL/Ur5XG4o6QO+xFbY VVnzXtzTURtTx+8CLvg68iuvmzXVMTHtYhSw3XxAeFJIkYkF1GJyssW9/E/+QPygfWk0 x05hl1J1qzPsnUxeQhLoI1azM1wM2cYFKudYQcrjkJ6XRzyOh67q5QLf700wAbAIIXn7 hTobevW7AYux1qsB4NzT8F6bT9pt9ZX1pcig9clPSZ6NOoZ06LoL5XD52tnbQdsJU1vB CqPXG6YOpf4wXeTYha2xJ2b34x00MV71jcwOHDGps6BqLNmruzYESKGHByibtC+tpUAx 2H/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038255; x=1687630255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XhELp8moK7/6JDjvycSVE/PjyFSTn3Ab+xYUGXGPpO8=; b=N4J9pQbVqImSLjKiA5Fmv+Gw8XbfuZsHwbypGiJnThJArJcjlRl/xq/si30VKDu66H g4GKPaXvVPrdJb8ctKQzx/XMYcM9Z07lHIPSdojuX8hRy/ESZ9YsXozd23iYKxGF8VQ+ 9RZ5tBdNv5KZpQqMlVt7rbVbxZsgjjTqvefiR7wmR2s+X6dSDvz/E6cc+pRypxMtZ8Pb EQfsdHztwMD2EuH7ckn/7yuLgl9/m8JcbTo4LhIyk26E3ofB3E+O+iUugqxnT6cSjfId UOojGpkXj4i4mZo+UTOIkF6VadMEMfrYdMVbvqi8uqKW0WSWnE7Lcu4eRIk+nzYRHE1v LIBw== X-Gm-Message-State: AC+VfDxF2BvP+ip51AvyX3113DHQLa75GzYesW81cDEVujgzPwDTfNhc FJVAB1i9H42mj04REmD2urweXL9ZxV+PAyWOEhA= X-Google-Smtp-Source: ACHHUZ4gcplA52XXa1oyOtJa5lLs0nmOf0BFxHKtmGMvcBvLukddPkxYEp/OWyZwBPdRmc5rtYzHMg== X-Received: by 2002:a17:903:2445:b0:1b0:31a:5f91 with SMTP id l5-20020a170903244500b001b0031a5f91mr1339517pls.67.1685038255142; Thu, 25 May 2023 11:10:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 21/23] tcg/riscv: Improve setcond expansion Date: Thu, 25 May 2023 11:10:34 -0700 Message-Id: <20230525181036.1559435-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038451682100003 Content-Type: text/plain; charset="utf-8" Split out a helper function, tcg_out_setcond_int, which does not always produce the complete boolean result, but returns a set of flags to do so. Based on 21af16198425, the same improvement for loongarch64. Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 05ea9fead8..db328ddc2d 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -812,50 +812,128 @@ static void tcg_out_brcond(TCGContext *s, TCGCond co= nd, TCGReg arg1, tcg_out_opc_branch(s, op, arg1, arg2, 0); } =20 -static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, - TCGReg arg1, TCGReg arg2) +#define SETCOND_INV TCG_TARGET_NB_REGS +#define SETCOND_NEZ (SETCOND_INV << 1) +#define SETCOND_FLAGS (SETCOND_INV | SETCOND_NEZ) + +static int tcg_out_setcond_int(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg arg1, tcg_target_long arg2, bool c2) { + int flags =3D 0; + switch (cond) { - case TCG_COND_EQ: - tcg_out_opc_reg(s, OPC_SUB, ret, arg1, arg2); - tcg_out_opc_imm(s, OPC_SLTIU, ret, ret, 1); - break; - case TCG_COND_NE: - tcg_out_opc_reg(s, OPC_SUB, ret, arg1, arg2); - tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, ret); - break; - case TCG_COND_LT: - tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2); - break; - case TCG_COND_GE: - tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2); - tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); - break; - case TCG_COND_LE: - tcg_out_opc_reg(s, OPC_SLT, ret, arg2, arg1); - tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); - break; - case TCG_COND_GT: - tcg_out_opc_reg(s, OPC_SLT, ret, arg2, arg1); - break; - case TCG_COND_LTU: - tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2); - break; - case TCG_COND_GEU: - tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2); - tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); - break; - case TCG_COND_LEU: - tcg_out_opc_reg(s, OPC_SLTU, ret, arg2, arg1); - tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); - break; - case TCG_COND_GTU: - tcg_out_opc_reg(s, OPC_SLTU, ret, arg2, arg1); + case TCG_COND_EQ: /* -> NE */ + case TCG_COND_GE: /* -> LT */ + case TCG_COND_GEU: /* -> LTU */ + case TCG_COND_GT: /* -> LE */ + case TCG_COND_GTU: /* -> LEU */ + cond =3D tcg_invert_cond(cond); + flags ^=3D SETCOND_INV; break; default: - g_assert_not_reached(); - break; - } + break; + } + + switch (cond) { + case TCG_COND_LE: + case TCG_COND_LEU: + /* + * If we have a constant input, the most efficient way to implement + * LE is by adding 1 and using LT. Watch out for wrap around for = LEU. + * We don't need to care for this for LE because the constant input + * is constrained to signed 12-bit, and 0x800 is representable in = the + * temporary register. + */ + if (c2) { + if (cond =3D=3D TCG_COND_LEU) { + /* unsigned <=3D -1 is true */ + if (arg2 =3D=3D -1) { + tcg_out_movi(s, TCG_TYPE_REG, ret, !(flags & SETCOND_I= NV)); + return ret; + } + cond =3D TCG_COND_LTU; + } else { + cond =3D TCG_COND_LT; + } + tcg_debug_assert(arg2 <=3D 0x7ff); + if (++arg2 =3D=3D 0x800) { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP0, arg2); + arg2 =3D TCG_REG_TMP0; + c2 =3D false; + } + } else { + TCGReg tmp =3D arg2; + arg2 =3D arg1; + arg1 =3D tmp; + cond =3D tcg_swap_cond(cond); /* LE -> GE */ + cond =3D tcg_invert_cond(cond); /* GE -> LT */ + flags ^=3D SETCOND_INV; + } + break; + default: + break; + } + + switch (cond) { + case TCG_COND_NE: + flags |=3D SETCOND_NEZ; + if (!c2) { + tcg_out_opc_reg(s, OPC_XOR, ret, arg1, arg2); + } else if (arg2 =3D=3D 0) { + ret =3D arg1; + } else { + tcg_out_opc_imm(s, OPC_XORI, ret, arg1, arg2); + } + break; + + case TCG_COND_LT: + if (c2) { + tcg_out_opc_imm(s, OPC_SLTI, ret, arg1, arg2); + } else { + tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2); + } + break; + + case TCG_COND_LTU: + if (c2) { + tcg_out_opc_imm(s, OPC_SLTIU, ret, arg1, arg2); + } else { + tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2); + } + break; + + default: + g_assert_not_reached(); + } + + return ret | flags; +} + +static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg arg1, tcg_target_long arg2, bool c2) +{ + int tmpflags =3D tcg_out_setcond_int(s, cond, ret, arg1, arg2, c2); + + if (tmpflags !=3D ret) { + TCGReg tmp =3D tmpflags & ~SETCOND_FLAGS; + + switch (tmpflags & SETCOND_FLAGS) { + case SETCOND_INV: + /* Intermediate result is boolean: simply invert. */ + tcg_out_opc_imm(s, OPC_XORI, ret, tmp, 1); + break; + case SETCOND_NEZ: + /* Intermediate result is zero/non-zero: test !=3D 0. */ + tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, tmp); + break; + case SETCOND_NEZ | SETCOND_INV: + /* Intermediate result is zero/non-zero: test =3D=3D 0. */ + tcg_out_opc_imm(s, OPC_SLTIU, ret, tmp, 1); + break; + default: + g_assert_not_reached(); + } + } } =20 static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) @@ -1542,7 +1620,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, =20 case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: - tcg_out_setcond(s, args[3], a0, a1, a2); + tcg_out_setcond(s, args[3], a0, a1, a2, c2); break; =20 case INDEX_op_qemu_ld_a32_i32: @@ -1665,6 +1743,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_and_i64: case INDEX_op_or_i64: case INDEX_op_xor_i64: + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: return C_O1_I2(r, r, rI); =20 case INDEX_op_andc_i32: @@ -1686,7 +1766,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_divu_i32: case INDEX_op_rem_i32: case INDEX_op_remu_i32: - case INDEX_op_setcond_i32: case INDEX_op_mul_i64: case INDEX_op_mulsh_i64: case INDEX_op_muluh_i64: @@ -1694,7 +1773,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_divu_i64: case INDEX_op_rem_i64: case INDEX_op_remu_i64: - case INDEX_op_setcond_i64: return C_O1_I2(r, rZ, rZ); =20 case INDEX_op_shl_i32: --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038313; cv=none; d=zohomail.com; s=zohoarc; b=f6E3Eq85oTsZu3hsoirNj/ewJ8Zlr5SWyHXSCa0u2ryrqY3PrXXr7SIC8lPsH6h70YoGjxIpDVJ+hr/HM+atOleCWwt+0Da5xQ/FNUOwTAcx18Hb/iFgzyuVBYVma4Etey+e3LvlYh1SgLIUwfRoRth8YD6+Ifbq6AcgmgEf2vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pcX79UtOjLA+j+Do1pHI/f4UsYp0/Pzd6kIdjo/mVKc=; b=Xu/HSY54p++xcl5D41Tt8iHl38bJsv0KwZersjn7o3tUIhwAYtREMb1SFz76fk4SRi0DgsUdKkFzEbvekreHKxdphCVQA1nFDRUHE/LuD6B7g9OvHbr+83N1NCksGYrfk7b5r3sVluouGz7jk/S+xfk+/o+UBX42ytfmfgvzQGg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16850383132901018.6568656243917; Thu, 25 May 2023 11:11:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQT-000074-EU; Thu, 25 May 2023 14:11:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQS-00005u-7y for qemu-devel@nongnu.org; Thu, 25 May 2023 14:11:00 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQP-00061Y-6C for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:59 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae4c5e12edso13604345ad.3 for ; Thu, 25 May 2023 11:10:56 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038256; x=1687630256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pcX79UtOjLA+j+Do1pHI/f4UsYp0/Pzd6kIdjo/mVKc=; b=SPqfw04eo8JnTY59N90VWgr8Xsa2AxBLbPJRMWntGzedq/kOTbXqbpXCJLOExH1m0k 1fezEEEKR0thd+pk7YWdbj7SpIPYKIF/58wHsu60bqb4qeSNwkcRib70U2tHc/EHDHm2 fbUMSdf54yGZeO7VenAFk+xWzgHnDBXo6zrjAissZVt2V+YNgG/gtI+i2Ri0VFokzVRY bw6GRt8qv7Xwa75X3+PybE/idKj5jNymOBFtKwFlqVAgyBKjU321zwy9h1nju4Wj97zw bj4qMRecXZXPHIWHvAVKNIobVaxMk82k7UgCTRiBUAkCEKUxaXQ4SI2eQgIDAQ3YW11A BuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038256; x=1687630256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pcX79UtOjLA+j+Do1pHI/f4UsYp0/Pzd6kIdjo/mVKc=; b=dMqEH+RxNb0ctmqwTtqpsRnlBP5cGIDO4qCzn7lJyE8lWMFqYtjCmBk4HQdGfyyWnO rpulbKU3e4lySGZaKKs00cymEb3uQBPOf+6oGJdiRjDHfTRJEpm3N0QXkXzimvtLJZ1x 9mpzRWo9h8IHmJXhoLFDz1QOFW4GtdgTcjFx4WZpEfqDzSv9dq42an5inDiv0dkYB17j 02NPM6LAlsUECxq/p2nWPZ/4GiYy6HEXsH1RhdUxQ18Oj0KFxIOHipGPz2QY12JZPEWu gEhNA7nur/+HFeKqH5H7EjAgRS73f7SvqYEsfRXz2e+5geLaUYvx833fCaeMAPGOn1Qt WKoA== X-Gm-Message-State: AC+VfDwuTIbzFjU8VChdSWFzKbtwo1m5EQQrntirEwt0cSHvBgCwjMvO 8jqbugjXfY6bEP2cjIrrk0KT2nPQxngzAhOMePg= X-Google-Smtp-Source: ACHHUZ7IWX3BgNgc1jmydcAJ4Y9QzxfQtbUwqakMOwjHxDQDC/Q4WqGEgd4KVi7xLful1ZtzbFg16g== X-Received: by 2002:a17:902:ecc9:b0:1af:db10:333b with SMTP id a9-20020a170902ecc900b001afdb10333bmr3159220plh.59.1685038255970; Thu, 25 May 2023 11:10:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 22/23] tcg/riscv: Implement movcond Date: Thu, 25 May 2023 11:10:35 -0700 Message-Id: <20230525181036.1559435-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038315456100007 Content-Type: text/plain; charset="utf-8" Implement with and without Zicond. Without Zicond, we were letting the middle-end expand to a 5 insn sequence; better to use a branch over a single insn. Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target-con-set.h | 1 + tcg/riscv/tcg-target.h | 4 +- tcg/riscv/tcg-target.c.inc | 139 ++++++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+), 3 deletions(-) diff --git a/tcg/riscv/tcg-target-con-set.h b/tcg/riscv/tcg-target-con-set.h index 1a33ece98f..a5cadd303f 100644 --- a/tcg/riscv/tcg-target-con-set.h +++ b/tcg/riscv/tcg-target-con-set.h @@ -18,4 +18,5 @@ C_O1_I2(r, r, rI) C_O1_I2(r, r, rJ) C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) +C_O1_I4(r, r, rI, rM, rM) C_O2_I4(r, r, rZ, rZ, rM, rM) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index e0b23006c4..e9e84be9a5 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -97,7 +97,7 @@ extern bool have_zbb; #endif =20 /* optional instructions */ -#define TCG_TARGET_HAS_movcond_i32 0 +#define TCG_TARGET_HAS_movcond_i32 1 #define TCG_TARGET_HAS_div_i32 1 #define TCG_TARGET_HAS_rem_i32 1 #define TCG_TARGET_HAS_div2_i32 0 @@ -132,7 +132,7 @@ extern bool have_zbb; #define TCG_TARGET_HAS_setcond2 1 #define TCG_TARGET_HAS_qemu_st8_i32 0 =20 -#define TCG_TARGET_HAS_movcond_i64 0 +#define TCG_TARGET_HAS_movcond_i64 1 #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_div2_i64 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index db328ddc2d..811b84d152 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -169,7 +169,7 @@ static bool tcg_target_const_match(int64_t val, TCGType= type, int ct) } /* * Sign extended from 12 bits, +/- matching: [-0x7ff, 0x7ff]. - * Used by addsub2, which may need the negative operation, + * Used by addsub2 and movcond, which may need the negative value, * and requires the modified constant to be representable. */ if ((ct & TCG_CT_CONST_M12) && val >=3D -0x7ff && val <=3D 0x7ff) { @@ -936,6 +936,133 @@ static void tcg_out_setcond(TCGContext *s, TCGCond co= nd, TCGReg ret, } } =20 +static void tcg_out_movcond_zicond(TCGContext *s, TCGReg ret, TCGReg test_= ne, + int val1, bool c_val1, + int val2, bool c_val2) +{ + if (val1 =3D=3D 0) { + if (c_val2) { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP1, val2); + val2 =3D TCG_REG_TMP1; + } + tcg_out_opc_reg(s, OPC_CZERO_NEZ, ret, val2, test_ne); + return; + } + + if (val2 =3D=3D 0) { + if (c_val1) { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP1, val1); + val1 =3D TCG_REG_TMP1; + } + tcg_out_opc_reg(s, OPC_CZERO_EQZ, ret, val1, test_ne); + return; + } + + if (c_val2) { + if (c_val1) { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP1, val1 - val2); + } else { + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_TMP1, val1, -val2); + } + tcg_out_opc_reg(s, OPC_CZERO_EQZ, ret, TCG_REG_TMP1, test_ne); + tcg_out_opc_imm(s, OPC_ADDI, ret, ret, val2); + return; + } + + if (c_val1) { + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_TMP1, val2, -val1); + tcg_out_opc_reg(s, OPC_CZERO_NEZ, ret, TCG_REG_TMP1, test_ne); + tcg_out_opc_imm(s, OPC_ADDI, ret, ret, val1); + return; + } + + tcg_out_opc_reg(s, OPC_CZERO_NEZ, TCG_REG_TMP1, val2, test_ne); + tcg_out_opc_reg(s, OPC_CZERO_EQZ, TCG_REG_TMP0, val1, test_ne); + tcg_out_opc_reg(s, OPC_OR, ret, TCG_REG_TMP0, TCG_REG_TMP1); +} + +static void tcg_out_movcond_br1(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg cmp1, TCGReg cmp2, + int val, bool c_val) +{ + RISCVInsn op; + int disp =3D 8; + + tcg_debug_assert((unsigned)cond < ARRAY_SIZE(tcg_brcond_to_riscv)); + op =3D tcg_brcond_to_riscv[cond].op; + tcg_debug_assert(op !=3D 0); + + if (tcg_brcond_to_riscv[cond].swap) { + tcg_out_opc_branch(s, op, cmp2, cmp1, disp); + } else { + tcg_out_opc_branch(s, op, cmp1, cmp2, disp); + } + if (c_val) { + tcg_out_opc_imm(s, OPC_ADDI, ret, TCG_REG_ZERO, val); + } else { + tcg_out_opc_imm(s, OPC_ADDI, ret, val, 0); + } +} + +static void tcg_out_movcond_br2(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg cmp1, TCGReg cmp2, + int val1, bool c_val1, + int val2, bool c_val2) +{ + TCGReg tmp; + + /* TCG optimizer reorders to prefer ret matching val2. */ + if (!c_val2 && ret =3D=3D val2) { + cond =3D tcg_invert_cond(cond); + tcg_out_movcond_br1(s, cond, ret, cmp1, cmp2, val1, c_val1); + return; + } + + if (!c_val1 && ret =3D=3D val1) { + tcg_out_movcond_br1(s, cond, ret, cmp1, cmp2, val2, c_val2); + return; + } + + tmp =3D (ret =3D=3D cmp1 || ret =3D=3D cmp2 ? TCG_REG_TMP1 : ret); + if (c_val1) { + tcg_out_movi(s, TCG_TYPE_REG, tmp, val1); + } else { + tcg_out_mov(s, TCG_TYPE_REG, tmp, val1); + } + tcg_out_movcond_br1(s, cond, tmp, cmp1, cmp2, val2, c_val2); + tcg_out_mov(s, TCG_TYPE_REG, ret, tmp); +} + +static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg cmp1, int cmp2, bool c_cmp2, + TCGReg val1, bool c_val1, + TCGReg val2, bool c_val2) +{ + int tmpflags; + TCGReg t; + + if (!have_zicond && (!c_cmp2 || cmp2 =3D=3D 0)) { + tcg_out_movcond_br2(s, cond, ret, cmp1, cmp2, + val1, c_val1, val2, c_val2); + return; + } + + tmpflags =3D tcg_out_setcond_int(s, cond, TCG_REG_TMP0, cmp1, cmp2, c_= cmp2); + t =3D tmpflags & ~SETCOND_FLAGS; + + if (have_zicond) { + if (tmpflags & SETCOND_INV) { + tcg_out_movcond_zicond(s, ret, t, val2, c_val2, val1, c_val1); + } else { + tcg_out_movcond_zicond(s, ret, t, val1, c_val1, val2, c_val2); + } + } else { + cond =3D tmpflags & SETCOND_INV ? TCG_COND_EQ : TCG_COND_NE; + tcg_out_movcond_br2(s, cond, ret, t, TCG_REG_ZERO, + val1, c_val1, val2, c_val2); + } +} + static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { TCGReg link =3D tail ? TCG_REG_ZERO : TCG_REG_RA; @@ -1623,6 +1750,12 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_setcond(s, args[3], a0, a1, a2, c2); break; =20 + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + tcg_out_movcond(s, args[5], a0, a1, a2, c2, + args[3], const_args[3], args[4], const_args[4]); + break; + case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: tcg_out_qemu_ld(s, a0, a1, a2, TCG_TYPE_I32); @@ -1791,6 +1924,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) case INDEX_op_brcond_i64: return C_O0_I2(rZ, rZ); =20 + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + return C_O1_I4(r, r, rI, rM, rM); + case INDEX_op_add2_i32: case INDEX_op_add2_i64: case INDEX_op_sub2_i32: --=20 2.34.1 From nobody Sat Apr 20 10:55:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1685038444; cv=none; d=zohomail.com; s=zohoarc; b=E+8v49QfXxazVUVBNbbyO6IJ5rUE/FFsRrcpbBQ3Arxa4KRF+W2QkSQ3FGkTU9TaAtAOirblm0FkZSWtZyO6YQU821EunIFwLT6d8Nd4d0PqZZiW+bmIcenAAOWW3O9GHOPyes6ylRIvtaSj5zImReOXHPETOCxP/w8TKOUhCI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685038444; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IhXY6OVrpQp4Lm/To99lZW68y4mFxyvdIBwjvdoCrKQ=; b=VFWuvw6R4mb1MKHOG/uLRl7xEmDC4zkZjuc749bwek4HZoYprNggqO396K+7ICP/YmJteRhkyB+nqkJzrJWPQHaXq631qnpZeZjc4q1Fi6xXvURjiuMsMeuo/xBxJNpAcFXQLet8DVDMvPNtmztgkJU1wjRah64XE3OL1JfsP/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685038444839332.2883456354631; Thu, 25 May 2023 11:14:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQU-00008S-Hq; Thu, 25 May 2023 14:11:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQT-00006v-7M for qemu-devel@nongnu.org; Thu, 25 May 2023 14:11:01 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQR-00062d-3F for qemu-devel@nongnu.org; Thu, 25 May 2023 14:11:00 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ae507af2e5so12955ad.1 for ; Thu, 25 May 2023 11:10:58 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038257; x=1687630257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IhXY6OVrpQp4Lm/To99lZW68y4mFxyvdIBwjvdoCrKQ=; b=WGvMhMVeBV1UA9sYkaEKFKjQDD4J4M45OX5YRc4cyHwb2bPXeZMskbOLUidOQoPya8 2nEx/1QC0yr9CIFbhdO1YBlCPp5x62bS452yGvtDuc70KKqDhDoyY+Sao0NHcKme5+fP M9UJ08ebb/OSJobiqCwt6iPQuhiyj4p3QsMWODjXioCX3NU38TFmaXEoWBPZCcAGMJ4P aP/+1WmTA3AZ55ip0l1ax/6snVZfDZMmIM8tKfrxPtJIR2GTKG0pBbG9qTpn8V2qVGrD 4dG2UXoDGIhn0d4ZDNXgr0VTLaDSZGqJsnE9Gqr6Fz/LBAUFjRmyvVip4vuKOT24tfmE NzMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038257; x=1687630257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IhXY6OVrpQp4Lm/To99lZW68y4mFxyvdIBwjvdoCrKQ=; b=SldL+JPqLKr9S+BpxyhwIkHBG1QwVDK9W/ZQsGVDSGV1AVPrIjxS6IhQN89Bt8axgw M+cDlcbrBlEIq6SfHwRANOmKpNRIXHLy6D7uNN1py7rDLgWZ2xSrQbdtx/JgFeKautJ9 KouTAh5wBFTIjeygtaY4sRaGJXttC8e2za0XdJWvF0hS636NxKToJo8E2a6a8C6rUtE4 dCdhpRIElAxbAMEncZcXH2dUog0hx02G1kusOKgzcZUjgQPSxlJpTMY3VTb2qYKokDFT CDgKcKM3pe9pEEv08DWj2YX/pJG0+oOwdkeC/BVtsqtVAiWSbZhZODfrtciboWvXTBOk /Qlg== X-Gm-Message-State: AC+VfDzfRnGk7KL/z/JPSXqhz+RHT+XXIoqjiBqvclTA5UCgonnzPTIl GAWIWHzzlWIwQVgRfMdO8pROUJ78gcwm+vXd0+8= X-Google-Smtp-Source: ACHHUZ7JHzYtcRdp35aBXr6EcsSDIHTZy2dvAti7bDz2s01b5vGS3PL7bUygTj146MtYsmdoZD6XDw== X-Received: by 2002:a17:902:d483:b0:1af:ac49:e048 with SMTP id c3-20020a170902d48300b001afac49e048mr2874148plg.25.1685038256785; Thu, 25 May 2023 11:10:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 23/23] tcg/riscv: Support CTZ, CLZ from Zbb Date: Thu, 25 May 2023 11:10:36 -0700 Message-Id: <20230525181036.1559435-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1685038446253100003 Content-Type: text/plain; charset="utf-8" Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target-con-set.h | 1 + tcg/riscv/tcg-target.h | 8 ++++---- tcg/riscv/tcg-target.c.inc | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tcg/riscv/tcg-target-con-set.h b/tcg/riscv/tcg-target-con-set.h index a5cadd303f..aac5ceee2b 100644 --- a/tcg/riscv/tcg-target-con-set.h +++ b/tcg/riscv/tcg-target-con-set.h @@ -18,5 +18,6 @@ C_O1_I2(r, r, rI) C_O1_I2(r, r, rJ) C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) +C_N1_I2(r, r, rM) C_O1_I4(r, r, rI, rM, rM) C_O2_I4(r, r, rZ, rZ, rM, rM) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index e9e84be9a5..62fe61af7b 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -125,8 +125,8 @@ extern bool have_zbb; #define TCG_TARGET_HAS_eqv_i32 have_zbb #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_nor_i32 0 -#define TCG_TARGET_HAS_clz_i32 0 -#define TCG_TARGET_HAS_ctz_i32 0 +#define TCG_TARGET_HAS_clz_i32 have_zbb +#define TCG_TARGET_HAS_ctz_i32 have_zbb #define TCG_TARGET_HAS_ctpop_i32 have_zbb #define TCG_TARGET_HAS_brcond2 1 #define TCG_TARGET_HAS_setcond2 1 @@ -159,8 +159,8 @@ extern bool have_zbb; #define TCG_TARGET_HAS_eqv_i64 have_zbb #define TCG_TARGET_HAS_nand_i64 0 #define TCG_TARGET_HAS_nor_i64 0 -#define TCG_TARGET_HAS_clz_i64 0 -#define TCG_TARGET_HAS_ctz_i64 0 +#define TCG_TARGET_HAS_clz_i64 have_zbb +#define TCG_TARGET_HAS_ctz_i64 have_zbb #define TCG_TARGET_HAS_ctpop_i64 have_zbb #define TCG_TARGET_HAS_add2_i64 1 #define TCG_TARGET_HAS_sub2_i64 1 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 811b84d152..c0257124fa 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1063,6 +1063,22 @@ static void tcg_out_movcond(TCGContext *s, TCGCond c= ond, TCGReg ret, } } =20 +static void tcg_out_cltz(TCGContext *s, TCGType type, RISCVInsn insn, + TCGReg ret, TCGReg src1, int src2, bool c_src2) +{ + tcg_out_opc_imm(s, insn, ret, src1, 0); + + if (!c_src2 || src2 !=3D (type =3D=3D TCG_TYPE_I32 ? 32 : 64)) { + /* + * The requested zero result does not match the insn, so adjust. + * Note that constraints put 'ret' in a new register, so the + * computation above did not clobber either 'src1' or 'src2'. + */ + tcg_out_movcond(s, TCG_COND_EQ, ret, src1, 0, true, + src2, c_src2, ret, false); + } +} + static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { TCGReg link =3D tail ? TCG_REG_ZERO : TCG_REG_RA; @@ -1723,6 +1739,19 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_imm(s, OPC_CPOP, a0, a1, 0); break; =20 + case INDEX_op_clz_i32: + tcg_out_cltz(s, TCG_TYPE_I32, OPC_CLZW, a0, a1, a2, c2); + break; + case INDEX_op_clz_i64: + tcg_out_cltz(s, TCG_TYPE_I64, OPC_CLZ, a0, a1, a2, c2); + break; + case INDEX_op_ctz_i32: + tcg_out_cltz(s, TCG_TYPE_I32, OPC_CTZW, a0, a1, a2, c2); + break; + case INDEX_op_ctz_i64: + tcg_out_cltz(s, TCG_TYPE_I64, OPC_CTZ, a0, a1, a2, c2); + break; + case INDEX_op_add2_i32: tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], const_args[4], const_args[5], false, true); @@ -1920,6 +1949,12 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) case INDEX_op_rotr_i64: return C_O1_I2(r, r, ri); =20 + case INDEX_op_clz_i32: + case INDEX_op_clz_i64: + case INDEX_op_ctz_i32: + case INDEX_op_ctz_i64: + return C_N1_I2(r, r, rM); + case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: return C_O0_I2(rZ, rZ); --=20 2.34.1