From nobody Fri Apr 4 21:50:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1739747477; cv=none; d=zohomail.com; s=zohoarc; b=RJn1xO3LD5Gm1tKpFEP8Oe4KLBVe1M5R+b14aW3KfhKL2aA/S6z7Cm3HogqeNjIj3Bub/sKo5fLMszzlbVWxXcEP+Dj+74tBJzrGPWzbqCJrm46Kha9Wo6IGdLdtaZspQPKeobDfnZI3TRjUF4TvONcxh6x/HGkfVQ9TWdURdRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739747477; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=b0p2g4sOl26LPe67Sxq813mAyPE6hn7JbCwtsVy2quc=; b=WxdgmTK2emop0mkClnXfCqzd8pMnm7GE2MK6ATxHy91CNyOaJcin/XFFHtTvZiTy/4lezNX1zvJ1b8njAvtkMBjqoOD0h99bxsTIa9It2LoM2B1GvyhPLm4p4Kz1mBqM0dUWZtkF5WJXbohB3i8S9jpETT6RzfnHKnU229yI+0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739747476953446.7653138023501; Sun, 16 Feb 2025 15:11:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjnmH-0005Tq-6t; Sun, 16 Feb 2025 18:10:21 -0500 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 1tjnmF-0005TV-N5 for qemu-devel@nongnu.org; Sun, 16 Feb 2025 18:10:19 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tjnmC-0005Br-9P for qemu-devel@nongnu.org; Sun, 16 Feb 2025 18:10:18 -0500 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2fc4418c0b9so1517147a91.0 for ; Sun, 16 Feb 2025 15:10:15 -0800 (PST) Received: from stoup.. (71-212-39-66.tukw.qwest.net. [71.212.39.66]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d5596115sm60198415ad.258.2025.02.16.15.10.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 15:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739747414; x=1740352214; 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=b0p2g4sOl26LPe67Sxq813mAyPE6hn7JbCwtsVy2quc=; b=lcc51JGUTJOvWqa3GxGVxWoBMb9+Mr3JDuV0qfFY4TKIwwl4Q1iXghAI/3xdLKOc4i 2Bqh6dKBFlz34J67hkpVwWSQmPzlmTpMP1mxI1sXUMVbRfeFaTqRNiF/UnIDkWqBRHM5 c0XCqFlhTDxvPc/pRusADBWZ5oYw5flObk8RoLvgi6ydRT8LrK0XFufXIQJ2mHFV6X14 /ttNNY+5WgpUy6fYanjvuT5XgUq8KPUmSTmNaPx2lySIMvHFZbzTqYveITUFUrVyVz5v GI58+f5lJXNrYQ3MTWAxtRkxUX4YncNztTkWGk/wt7OcZQSDsVYrVIOh/P6xkckd6+0a 6A3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739747414; x=1740352214; 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=b0p2g4sOl26LPe67Sxq813mAyPE6hn7JbCwtsVy2quc=; b=g3dQxjUA9m7kfznhX39p6rZfD04xMWO4YTRfgONq583N4bwJEG0rNBv/42SpbuUZIV IMVgmjnQQSx2IaeFL6jYkkRHc+WkDSr7wqJy0JuDh8UXfYIbUHpy+0JQxEGOYRPfWfKd 3+t3bCt/j5rLL9vi8/K0IPWRhLSk6TGzSxXkazMuKyewyTAg/yS8ewHg7Y+sAyA5a1o0 4nONfb+zaXjr5eYWuXSppyMF7TY2z7vGHYcZPZReTHfyVi0S8VtrQGkBBBVeMUgITRGo pViLQrQcnzoazQgWOIxVcAEB/N5XeqGhOM1ZaWLjvohs0RiVeUBAyXtKHUesrrIF6q3K 2DNg== X-Gm-Message-State: AOJu0YzS/v7kr94s7zAmzFX8IGze1+OPBat8UYs3RZX2aQOA3Y0HI5zs QliL8dkqdT47uEFefmTu33tq0ODUvYHuY8s6ThQpIjPZtFWbYklWEjcH4wjMlXL8nIYI0Tnpjbo 0 X-Gm-Gg: ASbGnctKmEFjMUa+F1I3BogJm21Wqk7knxfqQGQS1u/dBEhUl+dHtw+HyQ6ihAEc20B MTfHXMzE4dTU6pnsYTDwBIa9dF3VccWYZ4n2ybAiPERAdY97Dw2sCPgA2oivAYeA0CWhZnWp1Cb i/cDGOzMUonfmNueqrgGqfcqHHD7AbABY7Q0aoS6bIg1uuQiKKctJeafYhj4uVb3Tf50UkSPAT5 KkGwFoeFmyBhO+zbxlo6SgFR/NftZ7V8FinRJHCoGPXz35bDFhIWQuC3tLB2Og7OdXAzJ5TcHiO cTmAA+n4aocV+m3Hf/rXkOH2zAm6nbGMOk7/b+LTIAPUYas= X-Google-Smtp-Source: AGHT+IGil22Ru8l9FJ89HRgwgFL9YeYJQZ/y4ygQ62YhSFH1C5D5A130HUEZZIM2Sji8ubrTa0CBvw== X-Received: by 2002:a17:90b:3842:b0:2ee:5bc9:75b5 with SMTP id 98e67ed59e1d1-2fc40d13ea8mr12254712a91.4.1739747414410; Sun, 16 Feb 2025 15:10:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 001/162] tcg: Add all_outop[] Date: Sun, 16 Feb 2025 15:07:30 -0800 Message-ID: <20250216231012.2808572-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250216231012.2808572-1-richard.henderson@linaro.org> References: <20250216231012.2808572-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1739747479029019100 Content-Type: text/plain; charset="utf-8" Add infrastructure for more consolidated output of opcodes. The base structure allows for constraints to be either static or dynamic, and for the existence of those constraints to replace TCG_TARGET_HAS_* and the bulk of tcg_op_supported. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index e8950df2ad..96c29536b6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -861,6 +861,7 @@ static int tcg_out_pool_finalize(TCGContext *s) #define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1,= I2, I3, I4), =20 typedef enum { + C_Dynamic =3D -2, C_NotImplemented =3D -1, #include "tcg-target-con-set.h" } TCGConstraintSetIndex; @@ -954,6 +955,29 @@ static const TCGConstraintSet constraint_sets[] =3D { #define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I= 3, I4) #define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1,= I2, I3, I4) =20 +/* + * TCGOutOp is the base class for a set of structures that describe how + * to generate code for a given TCGOpcode. + * + * @static_constraint: + * C_NotImplemented: The TCGOpcode is not supported by the backend. + * C_Dynamic: Use @dynamic_constraint to select a constraint set + * based on any of @type, @flags, or host isa. + * Otherwise: The register allocation constrains for the TCGOpcod= e. + * + * Subclasses of TCGOutOp will define a set of output routines that may + * be used. Such routines will often be selected by the set of registers + * and constants that come out of register allocation. The set of + * routines that are provided will guide the set of constraints that are + * legal. In particular, assume that tcg_optimize() has done its job in + * swapping commutative operands and folding operations for which all + * operands are constant. + */ +typedef struct TCGOutOp { + TCGConstraintSetIndex static_constraint; + TCGConstraintSetIndex (*dynamic_constraint)(TCGType type, unsigned fla= gs); +} TCGOutOp; + #include "tcg-target.c.inc" =20 #ifndef CONFIG_TCG_INTERPRETER @@ -963,6 +987,10 @@ QEMU_BUILD_BUG_ON((int)(offsetof(CPUNegativeOffsetStat= e, tlb.f[0]) - < MIN_TLB_MASK_TABLE_OFS); #endif =20 +/* Register allocation descriptions for every TCGOpcode. */ +static const TCGOutOp * const all_outop[NB_OPS] =3D { +}; + /* * All TCG threads except the parent (i.e. the one that called tcg_context= _init * and registered the target's TCG globals) must register with this functi= on @@ -2416,8 +2444,32 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, un= signed flags) return has_type && TCG_TARGET_HAS_cmpsel_vec; =20 default: - tcg_debug_assert(op > INDEX_op_last_generic && op < NB_OPS); + if (op < INDEX_op_last_generic) { + const TCGOutOp *outop; + TCGConstraintSetIndex con_set; + + if (!has_type) { + return false; + } + + outop =3D all_outop[op]; + tcg_debug_assert(outop !=3D NULL); + + con_set =3D outop->static_constraint; + if (con_set =3D=3D C_Dynamic) { + con_set =3D outop->dynamic_constraint(type, flags); + } + if (con_set >=3D 0) { + return true; + } + tcg_debug_assert(con_set =3D=3D C_NotImplemented); + return false; + } + tcg_debug_assert(op < NB_OPS); return true; + + case INDEX_op_last_generic: + g_assert_not_reached(); } } =20 @@ -3335,19 +3387,27 @@ static void process_constraint_sets(void) =20 static const TCGArgConstraint *opcode_args_ct(const TCGOp *op) { - const TCGOpDef *def =3D &tcg_op_defs[op->opc]; + TCGOpcode opc =3D op->opc; + TCGType type =3D TCGOP_TYPE(op); + unsigned flags =3D TCGOP_FLAGS(op); + const TCGOpDef *def =3D &tcg_op_defs[opc]; + const TCGOutOp *outop =3D all_outop[opc]; TCGConstraintSetIndex con_set; =20 -#ifdef CONFIG_DEBUG_TCG - assert(tcg_op_supported(op->opc, TCGOP_TYPE(op), TCGOP_FLAGS(op))); -#endif - if (def->flags & TCG_OPF_NOT_PRESENT) { return empty_cts; } =20 - con_set =3D tcg_target_op_def(op->opc, TCGOP_TYPE(op), TCGOP_FLAGS(op)= ); - tcg_debug_assert(con_set >=3D 0 && con_set < ARRAY_SIZE(constraint_set= s)); + if (outop) { + con_set =3D outop->static_constraint; + if (con_set =3D=3D C_Dynamic) { + con_set =3D outop->dynamic_constraint(type, flags); + } + } else { + con_set =3D tcg_target_op_def(opc, type, flags); + } + tcg_debug_assert(con_set >=3D 0); + tcg_debug_assert(con_set < ARRAY_SIZE(constraint_sets)); =20 /* The constraint arguments must match TCGOpcode arguments. */ tcg_debug_assert(constraint_sets[con_set].nb_oargs =3D=3D def->nb_oarg= s); --=20 2.43.0