From patchwork Tue Apr 15 19:24:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 881382 Delivered-To: patch@linaro.org Received: by 2002:adf:f902:0:b0:38f:210b:807b with SMTP id b2csp646646wrr; Tue, 15 Apr 2025 13:30:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUsk2sZl0+H46piyRgnDYxVPhPELjFfe1Bwcz9Lwev+r2faSnnYNFV84qvIY95Fs6cJuj2OQQ==@linaro.org X-Google-Smtp-Source: AGHT+IE5Im8rAG+CicVm/8+R1FrL1hfwGDf49P1Dlstlpaa8zIZvV1W6gqMrD7+1SpmbESovLWPQ X-Received: by 2002:a05:620a:25c9:b0:7c7:a602:66ee with SMTP id af79cd13be357-7c914197cf4mr114606585a.10.1744749049809; Tue, 15 Apr 2025 13:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744749049; cv=none; d=google.com; s=arc-20240605; b=hh4XUZrvUJAA3qqlOeC4PhFRBjTcnwUw1RWCpYlM/nZ5qEP3fiyJ4s8ZLdtloYcgLO /lj3/NtvbS+KUskclAqSfsQSoFOeBobkx0lpZK2FgxQUSClr/DFb5xqudEbmiukjRUOF Lg2FfujeKAs56y1VIfcwrYRkp+vKI6hyJPcQ7cBJezhVgNrK97KHJqdpo2Oy/dnD4MCT ZpJqgKDu8yjsU9a1EpDAUKeGQ0IUo5XrA1yQsblIZnwpo6BK1z+VajAZffNclKSp7aoZ uNsf3y+yj34R7Sc+3WRNaaVfiWL15NIfh3ZyXiPrtDGbEn4HTrRdmGileuIS4bcfWEgl PT0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:to:from :dkim-signature; bh=OrOn7+9TJsicowllHagkEdKj6M8MrpZcFBUpXgzh/J4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=iv1L2WsBMZffrjcOkflMN4X1orddnuG0Hy5bYe7jKjqncv67sZS9DtKjM8GkFtdYd8 omJPog90D/PkYuQNC2w3AHNYF7B7JBe+pyobcpWtqlSeP3GZlAQ8Hxzu2wOFVGjXR9mi QpN1whfTtFPqfxdHwM7rcnGYobnByD00XtOdqiY0Fkm1gAAK1p5as1+aqruJmAVDD5Q1 t6kjGOd0zrEPbHZ0aaLDnJcaxKz71H6hwa8iRlKb79fDEU5BzEWls6X3EyF6JmKJzCqZ cwwePLUM6xHjlpRAT3+3dS5iK8nzJTUKJNCnN/vTyY9Ia8nqPtrD4Ym59SNQ8MdsVarr NB0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DBcpYTdt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c7a894c90dsi1144934885a.33.2025.04.15.13.30.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Apr 2025 13:30:49 -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=DBcpYTdt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u4mvV-0000XH-Sa; Tue, 15 Apr 2025 16:30:38 -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 1u4mv7-00009v-C6 for qemu-devel@nongnu.org; Tue, 15 Apr 2025 16:30:18 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u4muL-0007mS-Ft for qemu-devel@nongnu.org; Tue, 15 Apr 2025 16:30:12 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-224019ad9edso80009965ad.1 for ; Tue, 15 Apr 2025 13:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1744748963; x=1745353763; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OrOn7+9TJsicowllHagkEdKj6M8MrpZcFBUpXgzh/J4=; b=DBcpYTdt2qPw/bzc3Dnteiarugl5+i+NXD9uhmwc6n0AKY19XjhXTMdSpSi/5JgkID Qs4ccn4z56VoUzUzyOBYo9NXNlpRs0HNOyy4xaqu5PVa213Oj132QxkUUbLvNNQIELSF 53VjvrWZgAUVgHMBtZS8b+GkTal66SJ6l7rxx6Vy9HVeS6sWFnheWzJwYWdGnBBUpwaZ tG6+QfqmA+BBTu7gEM1p0ZVqy/dji5lvRn/SBz6SofqtkAstwypy9w2BWJsLE/icLF1e Cqb9hHDh3YdINlvwRqVOg272xe/EauaMK3t2IGexfw+3HUS4rfzunLvNceDZPioGvz3I PGYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744748963; x=1745353763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OrOn7+9TJsicowllHagkEdKj6M8MrpZcFBUpXgzh/J4=; b=lRZcs0XvQCrynUScxwNxorMQoScoOFwa8jwBA731CpaQLg3xxCfgpdiMbg1Xdmn9CX krYj/LU+72EGqAmEdVCl8PqYVuMo51aFxahKPns7yCRSDfRRPB0BbVo8u4laiXlIgMdF dWc7NOn3JtWNyxstdaRzqn+UsOD6ixlW9mt7A8iJm/CnP/fK9BZl78DyCboqdDBIfWLy v8C2JC2m4lIvIcknpRENrgC+1yZjJ3wxPcwYRpClQQWon1Dc+tzNAThYf2UZpXuK4dzz UUP/sqvcJ9YiF/+YEZWXrR45XQrGcGVM07KgabWBSZQjRllGaXpmkO1/PYS8OPgHtZRB 39bA== X-Gm-Message-State: AOJu0Yyp2HPi8RM0FJWN6JY4mNSNY+MBK7qUaMac4MUYs/YfyKvRIkse RZ3ss20p6XZt8CVQz6owb8nySX22cC8L7Xvr2MUtuFYMCL6IjWb8+RKCBtuj6T8ecYh/U2aDd6t Z X-Gm-Gg: ASbGncu0/+d//yVkZjdq85pqt8yfv+gHppYmZW3/R+dpTtR+ziVedHllcABuE7nterV ZZGI0QMqICXrdIcn8s/SdeoOYnLClXPSf8yjHbvTV9umdD03nhXj+fpmmdGF1AmfGEUo+Ipk76R Mq5sO/tQI9A7LEdRMP4wb2DWyccpXn3HxT2Q4X6kzJCSUMKZSrSiwrP4WZ8upf3YrWEWtjVjWzU RGJVrzRrLLfT9sxsiH8VejBYBfHSw6FwjgQNTzswtBSmws0yVRwpPX2FaKl7moXgylYmHjbWbQV oGk9jizT7SvgwZm+4Rhus9sqwxA8WhpP2aNKPpHUWeydSiYqSFyWukMSbNpuivtnuQp2REBb4sA = X-Received: by 2002:a17:903:41c3:b0:227:e74a:a057 with SMTP id d9443c01a7336-22c31ab0f8emr5530125ad.44.1744745568641; Tue, 15 Apr 2025 12:32:48 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7ccbd5esm122062355ad.248.2025.04.15.12.32.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Apr 2025 12:32:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 109/163] tcg/mips: Drop support for add2/sub2 Date: Tue, 15 Apr 2025 12:24:20 -0700 Message-ID: <20250415192515.232910-110-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250415192515.232910-1-richard.henderson@linaro.org> References: <20250415192515.232910-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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.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 We now produce exactly the same code via generic expansion. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/mips/tcg-target-con-set.h | 1 - tcg/mips/tcg-target-con-str.h | 1 - tcg/mips/tcg-target-has.h | 7 ++-- tcg/mips/tcg-target.c.inc | 67 +---------------------------------- 4 files changed, 3 insertions(+), 73 deletions(-) diff --git a/tcg/mips/tcg-target-con-set.h b/tcg/mips/tcg-target-con-set.h index 4e09c9a400..5304691dc1 100644 --- a/tcg/mips/tcg-target-con-set.h +++ b/tcg/mips/tcg-target-con-set.h @@ -28,4 +28,3 @@ C_O1_I4(r, r, rz, rz, rz) C_O1_I4(r, r, r, rz, rz) C_O2_I1(r, r, r) C_O2_I2(r, r, r, r) -C_O2_I4(r, r, rz, rz, rN, rN) diff --git a/tcg/mips/tcg-target-con-str.h b/tcg/mips/tcg-target-con-str.h index dfe2b156df..db2b225e4a 100644 --- a/tcg/mips/tcg-target-con-str.h +++ b/tcg/mips/tcg-target-con-str.h @@ -17,5 +17,4 @@ REGS('r', ALL_GENERAL_REGS) CONST('I', TCG_CT_CONST_U16) CONST('J', TCG_CT_CONST_S16) CONST('K', TCG_CT_CONST_P2M1) -CONST('N', TCG_CT_CONST_N16) CONST('W', TCG_CT_CONST_WSZ) diff --git a/tcg/mips/tcg-target-has.h b/tcg/mips/tcg-target-has.h index 9f6fa194b9..9d86906bf3 100644 --- a/tcg/mips/tcg-target-has.h +++ b/tcg/mips/tcg-target-has.h @@ -39,18 +39,15 @@ extern bool use_mips32r2_instructions; #endif /* optional instructions */ - -#if TCG_TARGET_REG_BITS == 64 #define TCG_TARGET_HAS_add2_i32 0 #define TCG_TARGET_HAS_sub2_i32 0 + +#if TCG_TARGET_REG_BITS == 64 #define TCG_TARGET_HAS_extr_i64_i32 1 #define TCG_TARGET_HAS_add2_i64 0 #define TCG_TARGET_HAS_sub2_i64 0 #define TCG_TARGET_HAS_ext32s_i64 1 #define TCG_TARGET_HAS_ext32u_i64 1 -#else -#define TCG_TARGET_HAS_add2_i32 1 -#define TCG_TARGET_HAS_sub2_i32 1 #endif /* optional instructions detected at runtime */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 7fae1c51e9..e69781b871 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -187,8 +187,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, #define TCG_CT_CONST_U16 0x100 /* Unsigned 16-bit: 0 - 0xffff. */ #define TCG_CT_CONST_S16 0x200 /* Signed 16-bit: -32768 - 32767 */ #define TCG_CT_CONST_P2M1 0x400 /* Power of 2 minus 1. */ -#define TCG_CT_CONST_N16 0x800 /* "Negatable" 16-bit: -32767 - 32767 */ -#define TCG_CT_CONST_WSZ 0x1000 /* word size */ +#define TCG_CT_CONST_WSZ 0x800 /* word size */ #define ALL_GENERAL_REGS 0xffffffffu @@ -207,8 +206,6 @@ static bool tcg_target_const_match(int64_t val, int ct, return 1; } else if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { return 1; - } else if ((ct & TCG_CT_CONST_N16) && val >= -32767 && val <= 32767) { - return 1; } else if ((ct & TCG_CT_CONST_P2M1) && use_mips32r2_instructions && is_p2m1(val)) { return 1; @@ -765,55 +762,6 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } -static void tcg_out_addsub2(TCGContext *s, TCGReg rl, TCGReg rh, TCGReg al, - TCGReg ah, TCGArg bl, TCGArg bh, bool cbl, - bool cbh, bool is_sub) -{ - TCGReg th = TCG_TMP1; - - /* If we have a negative constant such that negating it would - make the high part zero, we can (usually) eliminate one insn. */ - if (cbl && cbh && bh == -1 && bl != 0) { - bl = -bl; - bh = 0; - is_sub = !is_sub; - } - - /* By operating on the high part first, we get to use the final - carry operation to move back from the temporary. */ - if (!cbh) { - tcg_out_opc_reg(s, (is_sub ? OPC_SUBU : OPC_ADDU), th, ah, bh); - } else if (bh != 0 || ah == rl) { - tcg_out_opc_imm(s, OPC_ADDIU, th, ah, (is_sub ? -bh : bh)); - } else { - th = ah; - } - - /* Note that tcg optimization should eliminate the bl == 0 case. */ - if (is_sub) { - if (cbl) { - tcg_out_opc_imm(s, OPC_SLTIU, TCG_TMP0, al, bl); - tcg_out_opc_imm(s, OPC_ADDIU, rl, al, -bl); - } else { - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, al, bl); - tcg_out_opc_reg(s, OPC_SUBU, rl, al, bl); - } - tcg_out_opc_reg(s, OPC_SUBU, rh, th, TCG_TMP0); - } else { - if (cbl) { - tcg_out_opc_imm(s, OPC_ADDIU, rl, al, bl); - tcg_out_opc_imm(s, OPC_SLTIU, TCG_TMP0, rl, bl); - } else if (rl == al && rl == bl) { - tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, al, TCG_TARGET_REG_BITS - 1); - tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); - } else { - tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, rl, (rl == bl ? al : bl)); - } - tcg_out_opc_reg(s, OPC_ADDU, rh, th, TCG_TMP0); - } -} - #define SETCOND_INV TCG_TARGET_NB_REGS #define SETCOND_NEZ (SETCOND_INV << 1) #define SETCOND_FLAGS (SETCOND_INV | SETCOND_NEZ) @@ -2370,15 +2318,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGType type, } break; - case INDEX_op_add2_i32: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], false); - break; - case INDEX_op_sub2_i32: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], true); - break; - case INDEX_op_mb: tcg_out_mb(s, a0); break; @@ -2420,10 +2359,6 @@ tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags) case INDEX_op_st_i64: return C_O0_I2(rz, r); - case INDEX_op_add2_i32: - case INDEX_op_sub2_i32: - return C_O2_I4(r, r, rz, rz, rN, rN); - case INDEX_op_qemu_ld_i32: return C_O1_I1(r, r); case INDEX_op_qemu_st_i32: