From patchwork Wed Jun 5 17:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 801629 Delivered-To: patch@linaro.org Received: by 2002:adf:cf0e:0:b0:35b:5a80:51b4 with SMTP id o14csp551412wrj; Wed, 5 Jun 2024 10:27:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVoPZMsJhVwmQOMMwidrjZquoILy/AMcl3JYbOK/+ItlCJYtvREIEt1cHbL0tZtFSrAoAFTYqz50YIqckcNWgFN X-Google-Smtp-Source: AGHT+IE/7IE6pbYOpVMyb/zY5d3v1bZOZeF5Ygu4CFjg4jKvf/RFJyQgJQ4sEY4SD0mnlZQls42M X-Received: by 2002:a05:6359:4c1d:b0:19b:85f9:53f with SMTP id e5c5f4694b2df-19c66eaf2e5mr390375655d.2.1717608449272; Wed, 05 Jun 2024 10:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717608449; cv=none; d=google.com; s=arc-20160816; b=wkHqF6ZbTTColmpHIwkYPUNNU/cN56v5XS6DTz9xdVi4DQeVUuIqe+IrtmnWjUCe5T ODktlSsoifCebp3gbRaieFXBNQp7FGmPi9VFMu853xvh+RL9N7AMgFvIqQr7Ir0y1U09 +23rPp9/Tzc5+1jLzql5HJmDqF/B2vyM3wDop/ao+X/2IjKSP6Wu4im7CRS446qaC9Vc dytiCW4XwIaoQHlsPX+j1laZG00RZAfUYCF9RfNjuYxNnsbxcHPBjXMM+3zXZUpTMy8Y +0/TvYcCh6/D98r3XmlCWi++W8LODaeq4tmocDhDgBW7P77VsMCRVtLwCWLaKUtkc/bE BGnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KZeHEsoR9DNVGyATdmd+Zd8qaYj7z+UBk+cUU+SO+Fg=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=fYtz6ZqpBkJM5lNX+86D0bQni5YvbPbfPG4yBXbZWJnOsLkqbCEtk7OGxmhYi1UzwP 0QkyzVg9daGVRJFRF2LbTXkG0qbqVDXGXTvhpRbxCs1pbUS7RVFlI2RrzzdnX7pewmK+ dHQrakVYUxKxgDQmfcK6Aqg1IuVYtjauEkBiHS891IzxJz8BI1XxPCH2pTL/85hLPgee Kwzik/qQhsgBEvKih+BPa+QgJ9kUwTYuvB5AhH+kg3Mf3VgBF6JBQ3R3DhF7NII5TXT6 UelAfK5523QXfutC2nkHMwSbgVqaLbxshxhPpLg7KKB/qFm+FPvfPBDJeVsaI30R+jr6 gI/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mf6UFrLg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b42be7dsi133580096d6.510.2024.06.05.10.27.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 10:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mf6UFrLg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEuM6-00063t-0R; Wed, 05 Jun 2024 13:23:22 -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 1sEuM4-000618-5E for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:20 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEuM1-0003sU-UZ for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:19 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-6c4f3e0e3d2so29696a12.1 for ; Wed, 05 Jun 2024 10:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717608196; x=1718212996; darn=nongnu.org; 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=KZeHEsoR9DNVGyATdmd+Zd8qaYj7z+UBk+cUU+SO+Fg=; b=Mf6UFrLgIPMWcAH/q1isDCfVxoliYGOQwh7gBn3wPaYrGrtpz//+8sycAUoAy6HeC+ spWRe9jYsh00aUVdVIm3QQKFmTWs/DXQ+lYe48qfQnqV7d7VHJEBQVjrmc0mveS+pgBt cFCjqIqgkqS7obV/QUwmB8rIW8rYD2VpZPxENk4qznbUvicQHMcePJwv0q6pagKS3o+/ 6iS3xzGdsNyeicUzVNYdfDtJkbl7BI4LM5UYb68enG5JtcVDSe0EWdjpDdNbH6h/zXDW sURifiV3sprJqzDeAWmv/5D4n4kGeBX4xEdlHZ0HAYVNboYS4STwBZ2kZoafY8t7MNzm aR4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717608196; x=1718212996; 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=KZeHEsoR9DNVGyATdmd+Zd8qaYj7z+UBk+cUU+SO+Fg=; b=xU/0oVkFBXUs6csVA+3vr9b2ZlK+nhyJYOXCPU2uADST1uWgK9Wop3Ydb2/V8hp+Yq CaDck3uXTGQWoqHtp6yACrU1knVT/sOpK1tpUejsIguFXf8tG3Abq5rC/b+LyHPdH2pQ bBjJk4iqIuXLiWIOj/V1el7rAB0dFNRmD5CFC9v0pjwye8YoIjRcTpceb7isVUpVTgVq lUkKNSR0Yo5vsFazCwtsA7gBQytRPYUwqFr842Pf58Y31W0rOLwak4QVfIH6O/EDZJjz mBLlC1EWlHyjLw9xI5k+7py43MTeflW5dRiLpNY47kHO7SsHfwRAnW2qHcCZQB+/1V+i kxtw== X-Gm-Message-State: AOJu0YzV9T713amvur5rzKoNJZKIrEB3NmkS2vIjepn5QBuWJhUPR+Bj gikiPBwIw6/zvOIjYVdYISSbuaynYaYVrLqP55r4/oY/MNjaHacUyzzSfZAHmyKI85N7HJintt3 Y X-Received: by 2002:a17:90a:f412:b0:2c1:e3c6:3b90 with SMTP id 98e67ed59e1d1-2c27db68d40mr3325080a91.46.1717608196547; Wed, 05 Jun 2024 10:23:16 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28066d511sm1720915a91.9.2024.06.05.10.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 10:23:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 23/38] target/sparc: Implement LZCNT Date: Wed, 5 Jun 2024 10:22:38 -0700 Message-Id: <20240605172253.356302-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605172253.356302-1-richard.henderson@linaro.org> References: <20240605172253.356302-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 1 + target/sparc/translate.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index fec055910e..4766964893 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -389,6 +389,7 @@ FCMPEq 10 000 cc:2 110101 ..... 0 0101 0111 ..... \ ADDXC 10 ..... 110110 ..... 0 0001 0001 ..... @r_r_r ADDXCcc 10 ..... 110110 ..... 0 0001 0011 ..... @r_r_r + LZCNT 10 ..... 110110 00000 0 0001 0111 ..... @r_r2 ALIGNADDR 10 ..... 110110 ..... 0 0001 1000 ..... @r_r_r ALIGNADDRL 10 ..... 110110 ..... 0 0001 1010 ..... @r_r_r diff --git a/target/sparc/translate.c b/target/sparc/translate.c index c40992df96..a12cc9f796 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -658,6 +658,11 @@ static void gen_op_popc(TCGv dst, TCGv src1, TCGv src2) tcg_gen_ctpop_tl(dst, src2); } +static void gen_op_lzcnt(TCGv dst, TCGv src) +{ + tcg_gen_clzi_tl(dst, src, TARGET_LONG_BITS); +} + #ifndef TARGET_SPARC64 static void gen_helper_array8(TCGv dst, TCGv src1, TCGv src2) { @@ -3873,6 +3878,19 @@ TRANS(EDGE16LN, VIS2, gen_edge, a, 16, 0, 1) TRANS(EDGE32N, VIS2, gen_edge, a, 32, 0, 0) TRANS(EDGE32LN, VIS2, gen_edge, a, 32, 0, 1) +static bool do_rr(DisasContext *dc, arg_r_r *a, + void (*func)(TCGv, TCGv)) +{ + TCGv dst = gen_dest_gpr(dc, a->rd); + TCGv src = gen_load_gpr(dc, a->rs); + + func(dst, src); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); +} + +TRANS(LZCNT, VIS3, do_rr, a, gen_op_lzcnt) + static bool do_rrr(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv, TCGv, TCGv)) {