From patchwork Sat Jun 19 18:14:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463914 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp1056280jao; Sat, 19 Jun 2021 11:35:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEqaZF6rasp5oQHgzaV/ScCD6wODQeZFYWOUZYtGc1zejd/mzOTRZUV8+LO4QFWTYkur/m X-Received: by 2002:a1f:c644:: with SMTP id w65mr10306140vkf.12.1624127702058; Sat, 19 Jun 2021 11:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624127702; cv=none; d=google.com; s=arc-20160816; b=wzx5FtHG7qplbp7KvnEGTMU3A/LmKVmePCfaiyTiLk18v9vxpYiujXyTwZRQOORxq7 3I5uu2nZRCCEVpQ7qR1vZNims61eNAEH6cUvvRp9OdP/gck46M7v1UF9k7JgfAYxMf6Y VqPTiUTkz9eQ7jj1vu7bYJikSzSFeY8qe/miSlA+rUoxPJ4N62E6fXhkNu91j+SQjSt4 xV/qAqg4pvD5oyen4zEmH+E9vAK1BvFRcJIqo/WqQpcqFL4XeTgFAJcqi2GwYv6HV3vO IL/u5jMxAG83iW9qf1dPnAQjTJ53VxYSPUZXX4BPzTxEitLg6Prv6aR2uOxSr/20cbAn Uudg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+uASXuWPiHASia1640RtC4Epc/VWwyRiO4sJJNxaueo=; b=F54h2WefQZ0KbJBOV585T968W6JxnkHegUjVA0oGWqh2VQ3/N+z+dkiZ+xhMLv1h3F aYhx7WjOsx8ibi21MSuLd4DN9lXBW2dMB2mjFBt4qcIHIbYXUHIWg93CTdreWDfG2QGa rjCn2eYeWe+TGrpR8Rx0xjJ91MNBBOhkJdUEO2Csif+6T5AVJwA9u/uPhGw66gTsPmCv Jlh00ooRjaAyXTPLuxFv06LGgtUUnUgy/seCFPQ7oJiNii0CqM4h+TqBjiRs4YNHdl4F 7yu19wPaWG7nAe9jI6jxW6RcPGMs9KT1iAsxqh9ZBApWT7wuSD+obtWcGsfrdZDhEJtP nR3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MniVet8f; 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 r125si9232321vkf.32.2021.06.19.11.35.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 19 Jun 2021 11:35:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MniVet8f; 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]:32892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lufo5-0007VU-B6 for patch@linaro.org; Sat, 19 Jun 2021 14:35:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lufUt-0000uM-PQ for qemu-devel@nongnu.org; Sat, 19 Jun 2021 14:15:14 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:34714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lufUo-0002LK-46 for qemu-devel@nongnu.org; Sat, 19 Jun 2021 14:15:11 -0400 Received: by mail-pl1-x62a.google.com with SMTP id h1so6343582plt.1 for ; Sat, 19 Jun 2021 11:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+uASXuWPiHASia1640RtC4Epc/VWwyRiO4sJJNxaueo=; b=MniVet8f5OncXvUYg/tpqMwzOwgrG4PKngLNxmMN5nXhIcXZYAcfhqOHanEHyF77Au MkjtWi+90aDWmTdNPzOmvxCWCbHGkcPeMIEkVO4RHuFa4UmnaAk0ln4a1zVpiQR46MnN 51q5eJr60lOLosx5wxSzgYsv/chLLFV2URbNBdpy7WnV1Ggv3S5bHniIAx1U/QQZEeNa T7526GVuYvlVXSYje+g4T0OCTPBtPM3oJwAlac1KO5XK/EXyNqnJMpyiVOXQhYr3fifm M27g5q9v9S8EANbdRRGYxcgMOBDIIkDDa0Rk1GjWJ6wLXFFVc/9uPnzhKSBfSmecH2Ax fYgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+uASXuWPiHASia1640RtC4Epc/VWwyRiO4sJJNxaueo=; b=VoNIjndzwXn9fZJwv6XgTy8J7wgZhBhG+cHHvpqMngI5so+/+xAlxY/k6JzvZfYEac s/3zoc8pAbKS+TlqjpzzOISmUksmSQ6L5aPTnuGPuwPxvDtk1lCSoVvaLhEOIS/rIiBH Qdbav1DqYZhmb8zSoWdpFs5hNACyr/2IRehAUtnp+GU5bt1xtCntqQ5nLXzvnxnUosX2 TVw8IYqkUF2J5DFKlYZjhI2PVUMTr7oE/R5p1FgOISgiPLyl6qOm1mGmtJ1ef0sQPBSO TfCrikv6qFQ1EV/DlYFZh0WgPhotv9K+3tT+9VjGj3jKQN7ojuxjOe4QXXL2wCqE8+Fx Czmg== X-Gm-Message-State: AOAM5330dKgZxviIZrUd9sgmhbwmVnc7OkyM2YOmpCIwX16QId3HZvqZ okYVxRADEuDV6cdoAONdydwcrDjSF/n35A== X-Received: by 2002:a17:902:8d92:b029:113:91e7:89d6 with SMTP id v18-20020a1709028d92b029011391e789d6mr10278746plo.85.1624126504850; Sat, 19 Jun 2021 11:15:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id k35sm12059113pgi.21.2021.06.19.11.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Jun 2021 11:15:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/33] tcg/tci: Implement clz, ctz, ctpop Date: Sat, 19 Jun 2021 11:14:39 -0700 Message-Id: <20210619181452.877683-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210619181452.877683-1-richard.henderson@linaro.org> References: <20210619181452.877683-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 12 +++++------ tcg/tci.c | 44 ++++++++++++++++++++++++++++++++++++++++ tcg/tci/tcg-target.c.inc | 9 ++++++++ 3 files changed, 59 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index f35813bd01..5614e16857 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -76,9 +76,9 @@ #define TCG_TARGET_HAS_eqv_i32 1 #define TCG_TARGET_HAS_nand_i32 1 #define TCG_TARGET_HAS_nor_i32 1 -#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_clz_i32 1 +#define TCG_TARGET_HAS_ctz_i32 1 +#define TCG_TARGET_HAS_ctpop_i32 1 #define TCG_TARGET_HAS_neg_i32 1 #define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_orc_i32 1 @@ -113,9 +113,9 @@ #define TCG_TARGET_HAS_eqv_i64 1 #define TCG_TARGET_HAS_nand_i64 1 #define TCG_TARGET_HAS_nor_i64 1 -#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_clz_i64 1 +#define TCG_TARGET_HAS_ctz_i64 1 +#define TCG_TARGET_HAS_ctpop_i64 1 #define TCG_TARGET_HAS_neg_i64 1 #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_orc_i64 1 diff --git a/tcg/tci.c b/tcg/tci.c index 788f0235bc..adfca71c0f 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -589,6 +589,26 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, tci_args_rrr(insn, &r0, &r1, &r2); regs[r0] = (uint32_t)regs[r1] % (uint32_t)regs[r2]; break; +#if TCG_TARGET_HAS_clz_i32 + case INDEX_op_clz_i32: + tci_args_rrr(insn, &r0, &r1, &r2); + tmp32 = regs[r1]; + regs[r0] = tmp32 ? clz32(tmp32) : regs[r2]; + break; +#endif +#if TCG_TARGET_HAS_ctz_i32 + case INDEX_op_ctz_i32: + tci_args_rrr(insn, &r0, &r1, &r2); + tmp32 = regs[r1]; + regs[r0] = tmp32 ? ctz32(tmp32) : regs[r2]; + break; +#endif +#if TCG_TARGET_HAS_ctpop_i32 + case INDEX_op_ctpop_i32: + tci_args_rr(insn, &r0, &r1); + regs[r0] = ctpop32(regs[r1]); + break; +#endif /* Shift/rotate operations (32 bit). */ @@ -741,6 +761,24 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, tci_args_rrr(insn, &r0, &r1, &r2); regs[r0] = (uint64_t)regs[r1] % (uint64_t)regs[r2]; break; +#if TCG_TARGET_HAS_clz_i64 + case INDEX_op_clz_i64: + tci_args_rrr(insn, &r0, &r1, &r2); + regs[r0] = regs[r1] ? clz64(regs[r1]) : regs[r2]; + break; +#endif +#if TCG_TARGET_HAS_ctz_i64 + case INDEX_op_ctz_i64: + tci_args_rrr(insn, &r0, &r1, &r2); + regs[r0] = regs[r1] ? ctz64(regs[r1]) : regs[r2]; + break; +#endif +#if TCG_TARGET_HAS_ctpop_i64 + case INDEX_op_ctpop_i64: + tci_args_rr(insn, &r0, &r1); + regs[r0] = ctpop64(regs[r1]); + break; +#endif /* Shift/rotate operations (64 bit). */ @@ -1167,6 +1205,8 @@ int print_insn_tci(bfd_vma addr, disassemble_info *info) case INDEX_op_not_i64: case INDEX_op_neg_i32: case INDEX_op_neg_i64: + case INDEX_op_ctpop_i32: + case INDEX_op_ctpop_i64: tci_args_rr(insn, &r0, &r1); info->fprintf_func(info->stream, "%-12s %s, %s", op_name, str_r(r0), str_r(r1)); @@ -1212,6 +1252,10 @@ int print_insn_tci(bfd_vma addr, disassemble_info *info) case INDEX_op_rotl_i64: case INDEX_op_rotr_i32: case INDEX_op_rotr_i64: + case INDEX_op_clz_i32: + case INDEX_op_clz_i64: + case INDEX_op_ctz_i32: + case INDEX_op_ctz_i64: tci_args_rrr(insn, &r0, &r1, &r2); info->fprintf_func(info->stream, "%-12s %s, %s, %s", op_name, str_r(r0), str_r(r1), str_r(r2)); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 65cdc26812..69f41659be 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -67,6 +67,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_extract_i64: case INDEX_op_sextract_i32: case INDEX_op_sextract_i64: + case INDEX_op_ctpop_i32: + case INDEX_op_ctpop_i64: return C_O1_I1(r, r); case INDEX_op_st8_i32: @@ -122,6 +124,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_setcond_i64: case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: + case INDEX_op_clz_i32: + case INDEX_op_clz_i64: + case INDEX_op_ctz_i32: + case INDEX_op_ctz_i64: return C_O1_I2(r, r, r); case INDEX_op_brcond_i32: @@ -655,6 +661,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, CASE_32_64(divu) /* Optional (TCG_TARGET_HAS_div_*). */ CASE_32_64(rem) /* Optional (TCG_TARGET_HAS_div_*). */ CASE_32_64(remu) /* Optional (TCG_TARGET_HAS_div_*). */ + CASE_32_64(clz) /* Optional (TCG_TARGET_HAS_clz_*). */ + CASE_32_64(ctz) /* Optional (TCG_TARGET_HAS_ctz_*). */ tcg_out_op_rrr(s, opc, args[0], args[1], args[2]); break; @@ -703,6 +711,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, CASE_32_64(bswap16) /* Optional (TCG_TARGET_HAS_bswap16_*). */ CASE_32_64(bswap32) /* Optional (TCG_TARGET_HAS_bswap32_*). */ CASE_64(bswap64) /* Optional (TCG_TARGET_HAS_bswap64_i64). */ + CASE_32_64(ctpop) /* Optional (TCG_TARGET_HAS_ctpop_*). */ tcg_out_op_rr(s, opc, args[0], args[1]); break;