From patchwork Thu Jan 28 08:23:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 372543 Delivered-To: patch@linaro.org Received: by 2002:a17:906:24d5:0:0:0:0 with SMTP id f21csp653041ejb; Thu, 28 Jan 2021 00:37:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSGn7/cuwOYd3uCtTWf1XDaIFg4w3VJ+MT5AIxPKbNUu0FZ1hoPQsr4j50nJ4ZD/I6uoJe X-Received: by 2002:a25:af8c:: with SMTP id g12mr22799086ybh.33.1611823046161; Thu, 28 Jan 2021 00:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611823046; cv=none; d=google.com; s=arc-20160816; b=L8TFq9bwMM3sbf5HkrXgz5ilkv3SpIkrg15XJu1Cs9jmuvdO94Xa3nmeKyJ3+rZqvr YggH90rzveUpdHTADeom/CJqahicJH3OK+jpvKBsE1z9eN/xFyawvQ7gGTzkw5MiGYzX CURHHShcI+WaHUfxIdIkAbMOQGA3tMtFQsNjl4hSA9PqnMkv1mOPASehhafoJXeP3VfJ i77b5Ly5oVFFf5Szz40F2+FKUcS2WXee14IorRUqoLJ+i2O6Vqg3Q6Y2YYmrig070ad4 Y1CV5q9cDxUW8b5T65VBjigD7OZPlXeEJAl/k6NYJCNQRiaI6UMYEGEmmEkewTiSpwZ+ esZQ== 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=xJrZEGVQR1/tg7o98CXOJgjBnTA9yUqVpyK8VFJm0nw=; b=LuSAbVHGjUl0b3rIS89LGE75khIeKBFDFTgy0Rfu9VSw3QGzUFF+K87Ew/D1YmAwEs qDrDORPcruhsPJOlokm3ks9tl1jmMzE515hTel4ub4V4gRua/E9GINfpXYO8u4BCPsCA R+0P9ysTDuzh6QAnSaEvclZmV5XZCFFNJBf4+f6n6T59Zwsgmd+imBYBEH/wJacnvbTY 4AcQRCX7utDHDFVXmNF68QhhbkpGKCjalsLspW6n50tcmwa4FgI6kyGtPOhrYIhj/+G0 XNBrSeB/SvOVYr7a4iJlklLbK4YtKBPcGCcLRio9y23hdW1sMdwEqzpQ3nXZzDxdWh3L T8tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="St/YIEY6"; 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 i127si5075411ybg.81.2021.01.28.00.37.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 00:37:26 -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="St/YIEY6"; 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]:35444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l52nt-0003ER-Je for patch@linaro.org; Thu, 28 Jan 2021 03:37:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l52b8-0006NA-M5 for qemu-devel@nongnu.org; Thu, 28 Jan 2021 03:24:14 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:41085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l52b5-0005np-Ic for qemu-devel@nongnu.org; Thu, 28 Jan 2021 03:24:14 -0500 Received: by mail-pg1-x52c.google.com with SMTP id i7so3791579pgc.8 for ; Thu, 28 Jan 2021 00:24:10 -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=xJrZEGVQR1/tg7o98CXOJgjBnTA9yUqVpyK8VFJm0nw=; b=St/YIEY64oz16NQj+W+1F1ozUtMerKJxAo7Wv0b41VnWCxXja7/FnDall2Nu2nSauy jfEWTPPLvxnzELaJwSizrgSnB6jr1ZnL3l9Z2yoHbVml+g9PYuFx/i0uS8xgjZzYbEPe 5zsH6+4NbYG8K6YiZsybzXuIGnvvkiOFbu9NlsQnQBbQafemWWxvMsRevEseNR8AL6zD w3Q+vzxYFXxx3/VjQ1o+fbSTdlFn1fpjWfmYUBckq03nPdGkXy22wF/IY0uUOy0n1LKL S1fZDJ1Inik/IrwV56kKGQ3R3B3gQu9YmWzHcvUUPnm17wb88oHofjkgXq3pTZdxX5tu NB/Q== 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=xJrZEGVQR1/tg7o98CXOJgjBnTA9yUqVpyK8VFJm0nw=; b=LKWtFI1PszM5vs1e6PDpGgDLYkJSYhptkY0sGTWNeZ8JFbN0Y0Q7PtSSMzER/lXoXZ f5mRZJvfC1nDi4KrTZKOMCuqcdqmlit7jwy7YMxxeWEll2JqOZJQWaPN08oRkrCzLd8e JiUTKQXXoxL6gy94fH2HIPjL/PKz8BnyFB/Gx69igLB709L8dOaK0ITCaYVQ/pxstrhJ VehH2MPzbLZFJdhfyqvImBfhrfALWsC83/mdzC77ZsBpEZwVIL8zJilY2DrM9+vxaRqo Q64pwBEA7b3cZ/1dyYJCtZ2tzZMMncwnkAWXaS3Z1VBC35FGSBZgQxbDLMB742CnPSk+ rKrg== X-Gm-Message-State: AOAM531UM+2go4ztrMns6kj12o1tO0UkGJ5m2lNJytduOsChlXym9rP1 Bfk0K+EYGHtIqtxMluZl9grF1fmIsinJ6TqP X-Received: by 2002:aa7:8497:0:b029:1bf:47c6:523a with SMTP id u23-20020aa784970000b02901bf47c6523amr15004245pfn.0.1611822249897; Thu, 28 Jan 2021 00:24:09 -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 s24sm4658292pfd.118.2021.01.28.00.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 00:24:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 22/23] tcg/tci: Implement 64-bit division Date: Wed, 27 Jan 2021 22:23:30 -1000 Message-Id: <20210128082331.196801-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128082331.196801-1-richard.henderson@linaro.org> References: <20210128082331.196801-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 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 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. Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 4 ++-- tcg/tci.c | 28 ++++++++++++++++++++++------ tcg/tci/tcg-target.c.inc | 12 ++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) -- 2.25.1 Reviewed-by: Stefan Weil Reviewed-by: Alex Bennée 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 32931ea611..0065c854a4 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -889,14 +889,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 842807ff2e..8c0e77a0be 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -146,12 +146,10 @@ static const TCGTargetOpDef tcg_target_op_defs[] = { { INDEX_op_add_i64, { R, RI, RI } }, { INDEX_op_sub_i64, { R, RI, RI } }, { INDEX_op_mul_i64, { R, RI, RI } }, -#if TCG_TARGET_HAS_div_i64 { INDEX_op_div_i64, { R, R, R } }, { INDEX_op_divu_i64, { R, R, R } }, { INDEX_op_rem_i64, { R, R, R } }, { INDEX_op_remu_i64, { R, R, R } }, -#endif { INDEX_op_and_i64, { R, RI, RI } }, #if TCG_TARGET_HAS_andc_i64 { INDEX_op_andc_i64, { R, RI, RI } }, @@ -678,6 +676,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]); @@ -691,12 +693,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]);