From patchwork Thu Feb 4 01:44:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 376155 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp835972jah; Wed, 3 Feb 2021 17:56:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJymbQDjy+K14dpiJ2Jbwk2jaNzpirmki6tESVJlUbCK2Er+mWwOaoUQUoAe2ICXt7Ko+cv+ X-Received: by 2002:a25:384e:: with SMTP id f75mr8642324yba.358.1612403806355; Wed, 03 Feb 2021 17:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612403806; cv=none; d=google.com; s=arc-20160816; b=A9OvcI6Ch1pxr1fSmEPHmMNDNtYeS4sdbjyiExJrmbeLy1OD8uDsPCDZ2PRm7q+G+e LjpgGHBNs0Av+8A0MxQa5Gq39QZuEnxZ3tjSode11OBgCTTSSmZiUkpG3SJDzmrzQipJ YrqrIMC5pPZ6cjk0IvpS0mPwHyZIud0w5L0YlRJfkPg2L/+yS5st7DwxbyB4VKTK+t7G 8B4jBcgR/gI8kBQRauT4IPkwiNUMr0eIk0+yFcpCqwX96gcrJxJ3/zJGEFSaWuVPZUy9 z/Ls1bO9vG2HkwCGfDM0XIPeTTJi8wOcH4F9T3/wi11xx72saUfLXpR+FgdPHRaAiHct jH1w== 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=nPG7Xcmlwk2vyC0De6Qy+WTUFdq1vGPN65ZNzO4h0N8=; b=npmCi0gJtF+wWo4qgZQI4V60pSwpyeOTokWT/y7Aex2neJcdQB83KI7/1CPZSG5bv8 ltTt+0UpWOugA5AdSYWKgGbggpVJnXE7XqMMUGxswgI1fKdCM24IZlP2wEwgbvldAU2r oh2xtti92XXU8I5f7H1tPrj2nm0oXAgVrxvo2NyGcHEOs4i07FY8DlADSgiSDCz9Wkdq GR2P4DagIoj5luNvAHTds1zDrHuCE4PTaei/SIuu67cjfLoCJq1EfGhBqvBZRnpbHStW 1/XNymuhlw8IBWQ28qM7lTGvTe/SsiME7glT3IwFWHBV2MbNO+RJ5naLku0fph4hH0zO dVrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e22Jbndu; 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 s6si4147963ybc.233.2021.02.03.17.56.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Feb 2021 17:56:46 -0800 (PST) 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=e22Jbndu; 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]:59346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Tsz-0000Vt-Qj for patch@linaro.org; Wed, 03 Feb 2021 20:56:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Tij-00059z-Ka for qemu-devel@nongnu.org; Wed, 03 Feb 2021 20:46:11 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:35044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7TiZ-0003qb-LL for qemu-devel@nongnu.org; Wed, 03 Feb 2021 20:46:07 -0500 Received: by mail-pf1-x434.google.com with SMTP id w14so1083861pfi.2 for ; Wed, 03 Feb 2021 17:45:58 -0800 (PST) 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=nPG7Xcmlwk2vyC0De6Qy+WTUFdq1vGPN65ZNzO4h0N8=; b=e22JbnducbnrgrRCACzwQIkeItCT0UJ7+xsgYFcc+vBheGLKBNa4rEok3A0svO/XZS m9Ud3MqcDsGKdcOZog+LE1YLkjojxk9tJkvsz030bLgDfdH7klFgDen4URedo6WSTVhv 3Hl/Qy0o7XMJcJAvtInwJh54Hc8TgYvff5TIOtfxPWKgEixA9zHn6oWidXgnVtjmNB3o +eHe40D/XE6dmFU2CcTYFCL0+JqS0ErglNc0+kIYsdhPe767HrTDnzDzGkMT3YI41RUy ytdnSnQJ4R+H0T0ZZFbGG7G83BmJ2T868SuNgGnUdP9+SIDgZDW2nuzVxOhlqw0f2jKj P/SQ== 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=nPG7Xcmlwk2vyC0De6Qy+WTUFdq1vGPN65ZNzO4h0N8=; b=BW1Wb3QDF8RyEhYWSPiG2ZLykFbJK/9dKuY+m7qfkRwZCgzW3XCvmRzcOVeFvQKswA H/TDV0t7kKZEHbNundBBwVui2Cv5a1LlFWkSrQYUar+VCKip3hrk76SwRtm2Sd9rucSt zaDAcsyokzCgmlcKROHoAIV4a8qgJ5PE320XYbA7OQygFpq1IpfpPAVnrFrbnh5B8pb1 XKoWESLsrTEffcFGOdABvCUaNkCbKQj32srpkZi7VrWKoZYwzTvcn7GPLa3gnws0vlR7 Kwb4fEyk4SmGgl/srAUg+rpb73elk8YRYREzBPO2zcnIVrYJAhyPMBdv+G/v4tGiM4Ww 6dfw== X-Gm-Message-State: AOAM5323cS5dNI0pn9EGPtWlrqavk+z8en6MXrJ9sTcIjAvq2vvc8ZCw akLhD9NqTgf7IAhxCo0yxDrp+sSgFwVSl3Fk X-Received: by 2002:a63:d855:: with SMTP id k21mr6414313pgj.399.1612403157494; Wed, 03 Feb 2021 17:45:57 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id q132sm3835462pfq.171.2021.02.03.17.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 17:45:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/93] tcg/tci: Implement 64-bit division Date: Wed, 3 Feb 2021 15:44:00 -1000 Message-Id: <20210204014509.882821-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204014509.882821-1-richard.henderson@linaro.org> References: <20210204014509.882821-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sw@weilnetz.de, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Trivially implemented like other arithmetic. Tested via check-tcg and the ppc64 target. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 4 ++-- tcg/tci.c | 28 ++++++++++++++++++++++------ tcg/tci/tcg-target.c.inc | 10 ++++------ 3 files changed, 28 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index bb784e018e..7fc349a3de 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -100,8 +100,8 @@ #define TCG_TARGET_HAS_extract_i64 0 #define TCG_TARGET_HAS_sextract_i64 0 #define TCG_TARGET_HAS_extract2_i64 0 -#define TCG_TARGET_HAS_div_i64 0 -#define TCG_TARGET_HAS_rem_i64 0 +#define TCG_TARGET_HAS_div_i64 1 +#define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_ext8s_i64 1 #define TCG_TARGET_HAS_ext16s_i64 1 #define TCG_TARGET_HAS_ext32s_i64 1 diff --git a/tcg/tci.c b/tcg/tci.c index 25329345cf..5c84a1c979 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -894,14 +894,30 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, t2 = tci_read_ri64(regs, &tb_ptr); tci_write_reg(regs, t0, t1 * t2); break; -#if TCG_TARGET_HAS_div_i64 case INDEX_op_div_i64: - case INDEX_op_divu_i64: - case INDEX_op_rem_i64: - case INDEX_op_remu_i64: - TODO(); + t0 = *tb_ptr++; + t1 = tci_read_ri64(regs, &tb_ptr); + t2 = tci_read_ri64(regs, &tb_ptr); + tci_write_reg(regs, t0, (int64_t)t1 / (int64_t)t2); + break; + case INDEX_op_divu_i64: + t0 = *tb_ptr++; + t1 = tci_read_ri64(regs, &tb_ptr); + t2 = tci_read_ri64(regs, &tb_ptr); + tci_write_reg(regs, t0, (uint64_t)t1 / (uint64_t)t2); + break; + case INDEX_op_rem_i64: + t0 = *tb_ptr++; + t1 = tci_read_ri64(regs, &tb_ptr); + t2 = tci_read_ri64(regs, &tb_ptr); + tci_write_reg(regs, t0, (int64_t)t1 % (int64_t)t2); + break; + case INDEX_op_remu_i64: + t0 = *tb_ptr++; + t1 = tci_read_ri64(regs, &tb_ptr); + t2 = tci_read_ri64(regs, &tb_ptr); + tci_write_reg(regs, t0, (uint64_t)t1 % (uint64_t)t2); break; -#endif case INDEX_op_and_i64: t0 = *tb_ptr++; t1 = tci_read_ri64(regs, &tb_ptr); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 6dc5bac2f3..3327ce3072 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -577,6 +577,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, case INDEX_op_sar_i64: case INDEX_op_rotl_i64: /* Optional (TCG_TARGET_HAS_rot_i64). */ case INDEX_op_rotr_i64: /* Optional (TCG_TARGET_HAS_rot_i64). */ + case INDEX_op_div_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ + case INDEX_op_divu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ + case INDEX_op_rem_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ + case INDEX_op_remu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ tcg_out_r(s, args[0]); tcg_out_ri64(s, const_args[1], args[1]); tcg_out_ri64(s, const_args[2], args[2]); @@ -590,12 +594,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, tcg_debug_assert(args[4] <= UINT8_MAX); tcg_out8(s, args[4]); break; - case INDEX_op_div_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ - case INDEX_op_divu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ - case INDEX_op_rem_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ - case INDEX_op_remu_i64: /* Optional (TCG_TARGET_HAS_div_i64). */ - TODO(); - break; case INDEX_op_brcond_i64: tcg_out_r(s, args[0]); tcg_out_ri64(s, const_args[1], args[1]);