From patchwork Tue Mar 12 14:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 779754 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2057127wrt; Tue, 12 Mar 2024 07:42:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWptNTV7yn4V3p/Yyq0Sh9MfGdaC/K4HcGJsRi9IIBhJHNY95bgZ875aDkHX9Q61YKbIUIkuLiM3sgDI8yclFRM X-Google-Smtp-Source: AGHT+IFD8bdCodaWgVSxYWTaVcFpq79d4Mbxhj88K+eq6nd2VwD8kyHi8lSMyreMzmQQwHR1T1LO X-Received: by 2002:a05:622a:5c7:b0:42e:d04a:4c85 with SMTP id d7-20020a05622a05c700b0042ed04a4c85mr14202916qtb.66.1710254569052; Tue, 12 Mar 2024 07:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710254569; cv=none; d=google.com; s=arc-20160816; b=UXMvI7Y2NwaN3ieAgiPIRYzGaYw2q0iSJudzzc1je9+sHHEZYnISr0nIqaQz9YJzE2 5GvfTIqFJJj2/LefPCBQyTYhbbbelCixjPniAOCBW1jnlt8cj1pCyBG1z7vktxbzDMk0 1CAb5oLblfqxWx1wcousXOvqUVm43wKVKmhk/9+w3Wco/mZulH1GIt1QvAcsrWIQ34ZY S3q26m9KFqAoSL/A3nvHF4aEgg53t/dXYKFiahXTGxfhOjDUGyDMrFC3T/jWUTborJYh Eif/yOMDIcluJ8mXOg48gnG7QJXbgYbU/PS6AOnZGwjUR1nXHg06UXLij08EvgEBEIRf jubg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=cbxM+ZYIVDOiIr29L7EmXNz1akvOYPBrfp8Zc64o4J8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=CtA+q7Lgkov7V0oOwFIo8gsl5AKv/tJ/hU+P0Mgw2gFoEi0T+2LV1LGD4jK3KdmN26 iwoLq14f4RMvSqsQuCDuTaWuxS5pc1oH46AtNMfGZAjs8sHv5pzbobq4HZspQQ1ku9kz hP7m4cJubGBUx1PjgJnR8H01UrGXklwv5dRP1NRxB8MzV65RauQFn32cVT8TrjASc43E P2xcZW7WTaQyYJe/qtQ72C0h2EUVIAyhiZdXtFzi6jhP+iyUw8s0VSEeNCfVEaaED/Vg 3WyWzk+aVvWY7146gTXQGN5o0pAicgL1G8VMCNj/kDNK0KtUpP9Yh+gZX6J1bbiG5xNE md9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dO15TNi4; 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 g7-20020ac87f47000000b0042f0b0c906fsi7921517qtk.376.2024.03.12.07.42.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 07:42: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=dO15TNi4; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk3Hz-0003dJ-Ic; Tue, 12 Mar 2024 10:39:35 -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 1rk3Ha-0003Xc-Lq for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:39:12 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk3HQ-0007kw-ON for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:39:09 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-29bf998872fso1478053a91.3 for ; Tue, 12 Mar 2024 07:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710254339; x=1710859139; 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=cbxM+ZYIVDOiIr29L7EmXNz1akvOYPBrfp8Zc64o4J8=; b=dO15TNi4nnD1mBGQ4DFuKHxFjX/FqPlp/UoKZxNvviGoiOrpZJonfHQZA+05HVMei1 9V8SL0NczT2A52mvslN7xuUplbjVLUyYa38o221nk/GqEtfjHm8ZeVWEJBJKBP6W0eHx KHoyLr+fWP8sitC5ICeaCdm2XAee5L/r0Kzf1aMAdJQacLmG9TESprPt2+W/Lo+bgfav uQxpZ1re8sXmQ5Gvfz2sDIL8P4x7QnUYPn7Wq+vJS/F1VsZCsdDqa2LOsW0D8vbn4UMA wtGYNG63Ji2o2ZES0kgG7KaF/Ud/uEj9LBKbMo1eScalWGijtCeZSIPhzQoS3UREZFbq iK5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710254339; x=1710859139; 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=cbxM+ZYIVDOiIr29L7EmXNz1akvOYPBrfp8Zc64o4J8=; b=UEgJCd4Wq1dPQcjlvH0W18Mnt9wmeOi3kvPw2qK86eZ/hG0Ky6nhFr6AnVnopcx6UR 9N0FC55WmrP/s8KWam8ZfN+Q4/sV7Z6jIaqc5J5AXJa/diubmVHwHgtwe/paMPLE74P7 qTDeTRPzBXpZAdlr1mwbBYaWGVO15YrPlbqJJwnoHDBowl64Dh3fAXCZGVi2pKcML6rX sHsYZeg1ABpOxyTQe6YHuyZpTJkDzkWiQIOMCjJWW9AlO14VLnZAY1jfeasdosAR4ieK zn18Zuu7DxuGEkbrE/K3BCTq5LLkcaZ2bDJDTe3EgSIJRx/3D9Ov9ED9c8k10J8AupUa +XQA== X-Gm-Message-State: AOJu0Ywc/FMKZOCrhBPnySSWIdGgRYxdPl2u3LFFAVnzPz9wTOIiIU7n hZSwK95PBd+KXY+P8MRA3gr8+AmFt5ZZIIBegD3DBA4fyKfiQayOYW6R7XlOYhxuIqNem/t2KOC u X-Received: by 2002:a17:90a:c406:b0:29b:b3fa:b7ac with SMTP id i6-20020a17090ac40600b0029bb3fab7acmr6922906pjt.10.1710254338788; Tue, 12 Mar 2024 07:38:58 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id jx15-20020a17090b46cf00b0029baa0b1a6csm7492214pjb.24.2024.03.12.07.38.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:38:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 11/15] tcg/riscv: Do not accept immediate operands for sub Date: Tue, 12 Mar 2024 04:38:35 -1000 Message-Id: <20240312143839.136408-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312143839.136408-1-richard.henderson@linaro.org> References: <20240312143839.136408-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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, T_SCC_BODY_TEXT_LINE=-0.01 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 The transformations to neg and add immediate are now done generically and need not be handled by the backend. Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target-con-set.h | 2 +- tcg/riscv/tcg-target-con-str.h | 1 - tcg/riscv/tcg-target.c.inc | 24 ++++-------------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/tcg/riscv/tcg-target-con-set.h b/tcg/riscv/tcg-target-con-set.h index 0f72281a08..13a383aeb1 100644 --- a/tcg/riscv/tcg-target-con-set.h +++ b/tcg/riscv/tcg-target-con-set.h @@ -13,9 +13,9 @@ C_O0_I1(r) C_O0_I2(rZ, r) C_O0_I2(rZ, rZ) C_O1_I1(r, r) +C_O1_I2(r, r, r) C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) -C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) C_N1_I2(r, r, rM) C_O1_I4(r, r, rI, rM, rM) diff --git a/tcg/riscv/tcg-target-con-str.h b/tcg/riscv/tcg-target-con-str.h index 6f1cfb976c..a8d57c0e37 100644 --- a/tcg/riscv/tcg-target-con-str.h +++ b/tcg/riscv/tcg-target-con-str.h @@ -15,6 +15,5 @@ REGS('r', ALL_GENERAL_REGS) * CONST(letter, TCG_CT_CONST_* bit set) */ CONST('I', TCG_CT_CONST_S12) -CONST('N', TCG_CT_CONST_N12) CONST('M', TCG_CT_CONST_M12) CONST('Z', TCG_CT_CONST_ZERO) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 2b889486e4..6b28f2f85d 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -136,8 +136,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define TCG_CT_CONST_ZERO 0x100 #define TCG_CT_CONST_S12 0x200 -#define TCG_CT_CONST_N12 0x400 -#define TCG_CT_CONST_M12 0x800 +#define TCG_CT_CONST_M12 0x400 #define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 32) @@ -160,13 +159,6 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_S12) && val >= -0x800 && val <= 0x7ff) { return 1; } - /* - * Sign extended from 12 bits, negated: [-0x7ff, 0x800]. - * Used for subtraction, where a constant must be handled by ADDI. - */ - if ((ct & TCG_CT_CONST_N12) && val >= -0x7ff && val <= 0x800) { - return 1; - } /* * Sign extended from 12 bits, +/- matching: [-0x7ff, 0x7ff]. * Used by addsub2 and movcond, which may need the negative value, @@ -1559,18 +1551,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_sub_i32: - if (c2) { - tcg_out_opc_imm(s, OPC_ADDIW, a0, a1, -a2); - } else { - tcg_out_opc_reg(s, OPC_SUBW, a0, a1, a2); - } + tcg_out_opc_reg(s, OPC_SUBW, a0, a1, a2); break; case INDEX_op_sub_i64: - if (c2) { - tcg_out_opc_imm(s, OPC_ADDI, a0, a1, -a2); - } else { - tcg_out_opc_reg(s, OPC_SUB, a0, a1, a2); - } + tcg_out_opc_reg(s, OPC_SUB, a0, a1, a2); break; case INDEX_op_and_i32: @@ -1945,7 +1929,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sub_i32: case INDEX_op_sub_i64: - return C_O1_I2(r, rZ, rN); + return C_O1_I2(r, r, r); case INDEX_op_andc_i32: case INDEX_op_andc_i64: