From patchwork Fri Feb 5 22:56:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 377024 Delivered-To: patch@linaro.org Received: by 2002:a17:906:48d2:0:0:0:0 with SMTP id d18csp2587898ejt; Fri, 5 Feb 2021 15:23:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkBXVg7VSNNOC+7FRXIr9tebTlOgltDwCLTk5s+4u9icOg4HdA5iBk7LRDWvtCI5AVf3X8 X-Received: by 2002:a25:a267:: with SMTP id b94mr9836673ybi.277.1612567387740; Fri, 05 Feb 2021 15:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612567387; cv=none; d=google.com; s=arc-20160816; b=lrKxX41EZtBtEMZBsYtGJ2s9pO0hGgosaVe0/ySUSFPOqB+Qyq14l5wvj6CXtYZXUd dOycjuCSdZA2YY7yVnaaJ5AhWS1EiFWCOhwZb6Tqq7YdcgGllgyFWJzSY72UdvitSTEr xqKokUKasZ7pge28eC0Z0tM+iIXM+J+dbE+K8Kjh9ipcAOmrnwcwAG9r6jVXf6ioZyoU cu0xjCmQz/k97XVj7qprY19B6+wE3zJUDLQawWuPdUSA/p/eKPCZvCODPCfwjIG8E/BI BBxAzaTFABnYePOmM+YMKnYqAO8kfJiWlFEZKGj+rMTtl3w1xEtP+1WwJK0JL94sC5ED lV/w== 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=xz2LQRM33FAo2MInlQJYn6eMdfP+THvNB1Br5y3ooK+mp9U1T8f27bSA2gysOfPtcU MzkRGSNkMZHEz9rOtJeZbt+o8ItCfPRcVdrZv4tMx3Cirx4XuLmQUeVr2ocWcpH4VLHG D1oeNdshvEYSMNj7fUXk+9U6I/EI+Ajvo1HQQdP4BD2YNjeEX1v0CNH2jvgEfsB7bzXF c70YA4/5/2yH4ebUayikcrxzgeqC3xFjqOB0QUJWdYWhbXXTLYI6oNiVQZJRQgf/CkAX AYi8PN+KGbBtKgXlSO8oYBf2q8Gg33+raO8E6qy+NS76oe2T9/4b/nGM3e8hXFpMt9Y9 PeAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EsitVyKX; 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 y9si10806540ybn.264.2021.02.05.15.23.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Feb 2021 15:23:07 -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=EsitVyKX; 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]:36286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8ARP-0002gN-3O for patch@linaro.org; Fri, 05 Feb 2021 18:23:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8A36-0002WC-CR for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:58:00 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8A2m-0003Tj-Ov for qemu-devel@nongnu.org; Fri, 05 Feb 2021 17:57:57 -0500 Received: by mail-pg1-x52a.google.com with SMTP id o21so4168351pgn.12 for ; Fri, 05 Feb 2021 14:57:39 -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=EsitVyKX3VGFveBg5/yDPX41MvH3ZaYKnmTZuSqDyHDb7cYREGMybY0cIsX9zwnU10 aMGskTnad8JqBLciHj4u/HvuttQhaHrl/vEuKHU3DODDEqxrlWvMrpBtHXvuFldfd3ox 77xLiqaZtWpuDs0p6fA7+3MirmdPCqrRH6sXui4JVo3vEpn2PQpWrHvr1BP7dxU4FQ4m mlu+96u6fZWwZIGPF843pM06BaD2H8CfwTxzlt/cOxhpcIWVYwfq87AMz1UUmxo+ddM0 ooGxieZkthkOp4lOxifOAErZ1GvEk13QRk35u3f30hKGQa4aOrlrmnahPaeJW8TM06tk 86pA== 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=I3n71WO+OxJsHzAWCasY3gh7rKHbcFzhroZpdSNh/MZvaypnPPgnvEHSMlUMPF7gB3 JDGLd78zGs0xq2dkEHI38u0Ei1ZBMBDJRZYt5JTDDiKQhBsS3cu6o1n1XfdhNHlpVGIO 2UCUCVC92VrTxvpZllCfk6WlEK64rvleCAs8iACy2JGvP/ETXTzCWyGCtRvmzjT4HTyy A+cFQNLNf4S+emuU53lnaU+ptokFGBCoSfZXO6UJcIU1aD+81EiQ5Wh+RohSDgH9zocF 1URQY7+en9kTSZPxBTkvD3HC7ewz47K8exdeyZC/J0F9q3exNlXmAcmkNH/39F+pPhso EP2g== X-Gm-Message-State: AOAM5302mgmETETx3/XTt4kW+w8ViRCcfbWKEoDsuisNt6YKtfpXv3r/ 5M1qWb+RiB6gZHDojGbWdtptDS0Lr8KqXR8v X-Received: by 2002:a63:3747:: with SMTP id g7mr6327466pgn.376.1612565858610; Fri, 05 Feb 2021 14:57:38 -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 c23sm12155149pgc.72.2021.02.05.14.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:57:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/46] tcg/tci: Implement 64-bit division Date: Fri, 5 Feb 2021 12:56:28 -1000 Message-Id: <20210205225650.1330794-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210205225650.1330794-1-richard.henderson@linaro.org> References: <20210205225650.1330794-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 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?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]);