From nobody Wed Apr 9 03:45:56 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=1736237404; cv=none; d=zohomail.com; s=zohoarc; b=Zle9W1Agk00Nkk1UFm+7YqTmGDhJJCpQrHTByDxeOW+0EY1Ekf3lHaLWu7rdDYVsTNyXd9gq6FpFzuyvfHKgNVdoAYn33Ix+vLflGba5S2m+MTP6/mERmK5m4XBMrfz3GgLRE3nbtLUJGrzhCSeIlOrq4ZMyZfcTd8GL5VVl1as= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736237404; h=Content-Transfer-Encoding:Cc:Cc: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; bh=V/upWeWsUBhss5tIqMVlirNrJHo2C7weecIBvqVONlc=; b=RL2tJzcI+a34Ku+7crT9haTNPZ6D61SFqq6lKQo2oU9zuXwNwMVDyXXVZ9w+0zUlgv+oTK4Wkk4vtVh+d7PALGizwXUv8y3pcC2+Nf5UF3al09FWykCLr1hrEShk+g97gPTjca1sojefH1/D6/Ips+Xh1b7U9t8AZ5LbNdi9UmY= 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 17362374041934.364211128151851; Tue, 7 Jan 2025 00:10:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tV4Xi-0001D3-Gq; Tue, 07 Jan 2025 03:02:26 -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 1tV4X1-0000Ie-1n for qemu-devel@nongnu.org; Tue, 07 Jan 2025 03:01:44 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tV4Wx-0002wT-4v for qemu-devel@nongnu.org; Tue, 07 Jan 2025 03:01:41 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2161eb95317so228133135ad.1 for ; Tue, 07 Jan 2025 00:01:38 -0800 (PST) Received: from stoup.. (76-14-228-138.or.wavecable.com. [76.14.228.138]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc96eb12sm306765995ad.87.2025.01.07.00.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 00:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736236897; x=1736841697; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V/upWeWsUBhss5tIqMVlirNrJHo2C7weecIBvqVONlc=; b=RuJ2OlTSKI+R4Mc8iSESKGrwMtZPtpLymHPOyc9CGPO5maAKnbPgu6PVs0ToGhS89w u4RzlEg5309qA+ekCdp5FJBFHo4udvBRXCcIMaVJWkv2ojNs2mEuMrqchQHb7G21JXHL miLdSsilJvobsoIegGApew+iEZJ2Cyg0WLmTz5G7Pob/h+dYb16sRh7lOuwsYQko8ObG N0nppTGUnGEnLTjn7qVHFFNRdXMNYEg/qmooyjkrxudaCppfg5ttIakVykVQr452WWyL EhFK89PT1DJbPEbKyHDdkj4NyP+GZfPV7Y37dU3vthFrtpoNbm1BJHO7VnOSUuoUb4X+ VMmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736236897; x=1736841697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V/upWeWsUBhss5tIqMVlirNrJHo2C7weecIBvqVONlc=; b=I+HlsQ0iIF0uEoTpH3qd1McgWVYwna6njLmGcH8kukh6AS5gZexOxBMELFQP8SQ6di m8u7s/A249HgphM3TmjhAVMYWXsq6h97K5xIfOmBDPlytXW88UEIYuVlaQ2tbTcVtqbp xX/nEwnjY3wePvzfnfX6RpS7javnnb/14DsbG2w2o6JtF/lf8MSNUTjvZMAS00KUNSHQ 2BE9TEkBa4HlUKXzLGeT+0yNRnsDEh14zIVwwCE2RpZf9idJB/jQ7CFKP2p7+BcwuxT8 q9kckt5hL0WycFrqaxE4el7fav4zf2YZeQzCqHJznsh+5t2uYdakHFLEIWEJxN98UJsS l1UA== X-Gm-Message-State: AOJu0YxYwhoKhIIR4XGt+/c0o5PSz/Cerg9HP8Xh7jFWrPscmxJ4ang2 NmfjZR9aMtkLKQBQVmjd2LIoSHWJnkGkeviK/X9Bt7sRdhYvySDqiVLivGDeUU54QNJKy1zUCYk 8 X-Gm-Gg: ASbGncuItXrgebCjDxGP8bJdP8i/CMLQPDgMDgEBlHWtgsXLDhIHc+LtUBsKB4U5cEX BkuBewA//ZrYZrtCOILo+oTlWl/waSy0hPz6/FbRQEhO39Z0Ph1c4EpiAemM7q0TyQQllIZMsu6 7mO4Y5P5vxS50ysy5q0QJmNSkNBlpCtMpdeM5w1adnS3JWVvRygh3Jr5BXInl8d6qUZa4MLhH5T Z9ssDIyoO5+Y0TsAEPzX2ouWFjDxgckvnqhREeYGTxHEQPQRzNHmkvT6MMB2WqfLJgSF/+auKiu QScoM9chkV9kcrvm/Q== X-Google-Smtp-Source: AGHT+IGNdlTlkMPGyYJJv7PhF5+24un6V5lXhJ8IpLGz06p6cDnch+lBklmHbFAwruGQlX2RhN+Hwg== X-Received: by 2002:a17:903:32cb:b0:216:46f4:7e5a with SMTP id d9443c01a7336-219e6f144d3mr848980865ad.45.1736236897298; Tue, 07 Jan 2025 00:01:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pierrick.bouvier@linaro.org Subject: [PATCH v2 22/81] tcg: Reorg process_op_defs Date: Tue, 7 Jan 2025 00:00:13 -0800 Message-ID: <20250107080112.1175095-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107080112.1175095-1-richard.henderson@linaro.org> References: <20250107080112.1175095-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: 1736237405496116600 Content-Type: text/plain; charset="utf-8" Process each TCGConstraintSetIndex first. Allocate TCGArgConstraint arrays based on those. Only afterward process the TCGOpcodes and share those TCGArgConstraint arrays. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/tcg/tcg.h | 7 +- tcg/tcg.c | 272 +++++++++++++++++++++++----------------------- 2 files changed, 136 insertions(+), 143 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 4406fc6be0..ee9718d2bb 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -714,17 +714,12 @@ typedef struct TCGOpDef { const char *name; uint8_t nb_oargs, nb_iargs, nb_cargs, nb_args; uint8_t flags; - TCGArgConstraint *args_ct; + const TCGArgConstraint *args_ct; } TCGOpDef; =20 extern TCGOpDef tcg_op_defs[]; extern const size_t tcg_op_defs_max; =20 -typedef struct TCGTargetOpDef { - TCGOpcode op; - const char *args_ct_str[TCG_MAX_OP_ARGS]; -} TCGTargetOpDef; - /* * tcg_op_supported: * Query if @op, for @type and @flags, is supported by the host diff --git a/tcg/tcg.c b/tcg/tcg.c index 915a181596..d5ab0abe9d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -887,31 +887,35 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode); =20 /* Put all of the constraint sets into an array, indexed by the enum. */ =20 -#define C_O0_I1(I1) { .args_ct_str =3D { #I1 } }, -#define C_O0_I2(I1, I2) { .args_ct_str =3D { #I1, #I2 } }, -#define C_O0_I3(I1, I2, I3) { .args_ct_str =3D { #I1, #I2, #I3= } }, -#define C_O0_I4(I1, I2, I3, I4) { .args_ct_str =3D { #I1, #I2, #I3= , #I4 } }, +typedef struct TCGConstraintSet { + uint8_t nb_oargs, nb_iargs; + const char *args_ct_str[TCG_MAX_OP_ARGS]; +} TCGConstraintSet; =20 -#define C_O1_I1(O1, I1) { .args_ct_str =3D { #O1, #I1 } }, -#define C_O1_I2(O1, I1, I2) { .args_ct_str =3D { #O1, #I1, #I2= } }, -#define C_O1_I3(O1, I1, I2, I3) { .args_ct_str =3D { #O1, #I1, #I2= , #I3 } }, -#define C_O1_I4(O1, I1, I2, I3, I4) { .args_ct_str =3D { #O1, #I1, #I2= , #I3, #I4 } }, +#define C_O0_I1(I1) { 0, 1, { #I1 } }, +#define C_O0_I2(I1, I2) { 0, 2, { #I1, #I2 } }, +#define C_O0_I3(I1, I2, I3) { 0, 3, { #I1, #I2, #I3 } }, +#define C_O0_I4(I1, I2, I3, I4) { 0, 4, { #I1, #I2, #I3, #I4 } }, =20 -#define C_N1_I2(O1, I1, I2) { .args_ct_str =3D { "&" #O1, #I1,= #I2 } }, -#define C_N1O1_I1(O1, O2, I1) { .args_ct_str =3D { "&" #O1, #O2,= #I1 } }, -#define C_N2_I1(O1, O2, I1) { .args_ct_str =3D { "&" #O1, "&" = #O2, #I1 } }, +#define C_O1_I1(O1, I1) { 1, 1, { #O1, #I1 } }, +#define C_O1_I2(O1, I1, I2) { 1, 2, { #O1, #I1, #I2 } }, +#define C_O1_I3(O1, I1, I2, I3) { 1, 3, { #O1, #I1, #I2, #I3 } }, +#define C_O1_I4(O1, I1, I2, I3, I4) { 1, 4, { #O1, #I1, #I2, #I3, #I4 = } }, =20 -#define C_O2_I1(O1, O2, I1) { .args_ct_str =3D { #O1, #O2, #I1= } }, -#define C_O2_I2(O1, O2, I1, I2) { .args_ct_str =3D { #O1, #O2, #I1= , #I2 } }, -#define C_O2_I3(O1, O2, I1, I2, I3) { .args_ct_str =3D { #O1, #O2, #I1= , #I2, #I3 } }, -#define C_O2_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str =3D { #O1, #O2, #I1= , #I2, #I3, #I4 } }, -#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str =3D { "&" #O1, #= O2, #I1, #I2, #I3, #I4 } }, +#define C_N1_I2(O1, I1, I2) { 1, 2, { "&" #O1, #I1, #I2 } }, +#define C_N1O1_I1(O1, O2, I1) { 2, 1, { "&" #O1, #O2, #I1 } }, +#define C_N2_I1(O1, O2, I1) { 2, 1, { "&" #O1, "&" #O2, #I1 } = }, =20 -static const TCGTargetOpDef constraint_sets[] =3D { +#define C_O2_I1(O1, O2, I1) { 2, 1, { #O1, #O2, #I1 } }, +#define C_O2_I2(O1, O2, I1, I2) { 2, 2, { #O1, #O2, #I1, #I2 } }, +#define C_O2_I3(O1, O2, I1, I2, I3) { 2, 3, { #O1, #O2, #I1, #I2, #I3 = } }, +#define C_O2_I4(O1, O2, I1, I2, I3, I4) { 2, 4, { #O1, #O2, #I1, #I2, #I3,= #I4 } }, +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) { 2, 4, { "&" #O1, #O2, #I1, #I= 2, #I3, #I4 } }, + +static const TCGConstraintSet constraint_sets[] =3D { #include "tcg-target-con-set.h" }; =20 - #undef C_O0_I1 #undef C_O0_I2 #undef C_O0_I3 @@ -1499,32 +1503,12 @@ static TCGTemp *tcg_global_reg_new_internal(TCGCont= ext *s, TCGType type, static void tcg_context_init(unsigned max_cpus) { TCGContext *s =3D &tcg_init_ctx; - int op, total_args, n, i; - TCGOpDef *def; - TCGArgConstraint *args_ct; + int n, i; TCGTemp *ts; =20 memset(s, 0, sizeof(*s)); s->nb_globals =3D 0; =20 - /* Count total number of arguments and allocate the corresponding - space */ - total_args =3D 0; - for(op =3D 0; op < NB_OPS; op++) { - def =3D &tcg_op_defs[op]; - n =3D def->nb_iargs + def->nb_oargs; - total_args +=3D n; - } - - args_ct =3D g_new0(TCGArgConstraint, total_args); - - for(op =3D 0; op < NB_OPS; op++) { - def =3D &tcg_op_defs[op]; - def->args_ct =3D args_ct; - n =3D def->nb_iargs + def->nb_oargs; - args_ct +=3D n; - } - init_call_layout(&info_helper_ld32_mmu); init_call_layout(&info_helper_ld64_mmu); init_call_layout(&info_helper_ld128_mmu); @@ -3132,10 +3116,12 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have= _prefs) } =20 /* we give more priority to constraints with less registers */ -static int get_constraint_priority(const TCGOpDef *def, int k) +static int get_constraint_priority(const TCGArgConstraint *arg_ct, int k) { - const TCGArgConstraint *arg_ct =3D &def->args_ct[k]; - int n =3D ctpop64(arg_ct->regs); + int n; + + arg_ct +=3D k; + n =3D ctpop64(arg_ct->regs); =20 /* * Sort constraints of a single register first, which includes output @@ -3164,10 +3150,9 @@ static int get_constraint_priority(const TCGOpDef *d= ef, int k) } =20 /* sort from highest priority to lowest */ -static void sort_constraints(TCGOpDef *def, int start, int n) +static void sort_constraints(TCGArgConstraint *a, int start, int n) { int i, j; - TCGArgConstraint *a =3D def->args_ct; =20 for (i =3D 0; i < n; i++) { a[start + i].sort_index =3D start + i; @@ -3177,8 +3162,8 @@ static void sort_constraints(TCGOpDef *def, int start= , int n) } for (i =3D 0; i < n - 1; i++) { for (j =3D i + 1; j < n; j++) { - int p1 =3D get_constraint_priority(def, a[start + i].sort_inde= x); - int p2 =3D get_constraint_priority(def, a[start + j].sort_inde= x); + int p1 =3D get_constraint_priority(a, a[start + i].sort_index); + int p2 =3D get_constraint_priority(a, a[start + j].sort_index); if (p1 < p2) { int tmp =3D a[start + i].sort_index; a[start + i].sort_index =3D a[start + j].sort_index; @@ -3188,57 +3173,39 @@ static void sort_constraints(TCGOpDef *def, int sta= rt, int n) } } =20 +static const TCGArgConstraint empty_cts[TCG_MAX_OP_ARGS]; +static TCGArgConstraint all_cts[ARRAY_SIZE(constraint_sets)][TCG_MAX_OP_AR= GS]; + static void process_op_defs(TCGContext *s) { - TCGOpcode op; - - for (op =3D 0; op < NB_OPS; op++) { - TCGOpDef *def =3D &tcg_op_defs[op]; - const TCGTargetOpDef *tdefs; + for (size_t c =3D 0; c < ARRAY_SIZE(constraint_sets); ++c) { + const TCGConstraintSet *tdefs =3D &constraint_sets[c]; + TCGArgConstraint *args_ct =3D all_cts[c]; + int nb_oargs =3D tdefs->nb_oargs; + int nb_iargs =3D tdefs->nb_iargs; + int nb_args =3D nb_oargs + nb_iargs; bool saw_alias_pair =3D false; - int i, o, i2, o2, nb_args; - TCGConstraintSetIndex con_set; =20 - if (def->flags & TCG_OPF_NOT_PRESENT) { - continue; - } - - nb_args =3D def->nb_iargs + def->nb_oargs; - if (nb_args =3D=3D 0) { - continue; - } - - /* - * Macro magic should make it impossible, but double-check that - * the array index is in range. At the same time, double-check - * that the opcode is implemented, i.e. not C_NotImplemented. - */ - con_set =3D tcg_target_op_def(op); - tcg_debug_assert(con_set >=3D 0 && con_set < ARRAY_SIZE(constraint= _sets)); - tdefs =3D &constraint_sets[con_set]; - - for (i =3D 0; i < nb_args; i++) { + for (int i =3D 0; i < nb_args; i++) { const char *ct_str =3D tdefs->args_ct_str[i]; - bool input_p =3D i >=3D def->nb_oargs; - - /* Incomplete TCGTargetOpDef entry. */ - tcg_debug_assert(ct_str !=3D NULL); + bool input_p =3D i >=3D nb_oargs; + int o; =20 switch (*ct_str) { case '0' ... '9': o =3D *ct_str - '0'; tcg_debug_assert(input_p); - tcg_debug_assert(o < def->nb_oargs); - tcg_debug_assert(def->args_ct[o].regs !=3D 0); - tcg_debug_assert(!def->args_ct[o].oalias); - def->args_ct[i] =3D def->args_ct[o]; + tcg_debug_assert(o < nb_oargs); + tcg_debug_assert(args_ct[o].regs !=3D 0); + tcg_debug_assert(!args_ct[o].oalias); + args_ct[i] =3D args_ct[o]; /* The output sets oalias. */ - def->args_ct[o].oalias =3D 1; - def->args_ct[o].alias_index =3D i; + args_ct[o].oalias =3D 1; + args_ct[o].alias_index =3D i; /* The input sets ialias. */ - def->args_ct[i].ialias =3D 1; - def->args_ct[i].alias_index =3D o; - if (def->args_ct[i].pair) { + args_ct[i].ialias =3D 1; + args_ct[i].alias_index =3D o; + if (args_ct[i].pair) { saw_alias_pair =3D true; } tcg_debug_assert(ct_str[1] =3D=3D '\0'); @@ -3246,41 +3213,41 @@ static void process_op_defs(TCGContext *s) =20 case '&': tcg_debug_assert(!input_p); - def->args_ct[i].newreg =3D true; + args_ct[i].newreg =3D true; ct_str++; break; =20 case 'p': /* plus */ /* Allocate to the register after the previous. */ - tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + tcg_debug_assert(i > (input_p ? nb_oargs : 0)); o =3D i - 1; - tcg_debug_assert(!def->args_ct[o].pair); - tcg_debug_assert(!def->args_ct[o].ct); - def->args_ct[i] =3D (TCGArgConstraint){ + tcg_debug_assert(!args_ct[o].pair); + tcg_debug_assert(!args_ct[o].ct); + args_ct[i] =3D (TCGArgConstraint){ .pair =3D 2, .pair_index =3D o, - .regs =3D def->args_ct[o].regs << 1, - .newreg =3D def->args_ct[o].newreg, + .regs =3D args_ct[o].regs << 1, + .newreg =3D args_ct[o].newreg, }; - def->args_ct[o].pair =3D 1; - def->args_ct[o].pair_index =3D i; + args_ct[o].pair =3D 1; + args_ct[o].pair_index =3D i; tcg_debug_assert(ct_str[1] =3D=3D '\0'); continue; =20 case 'm': /* minus */ /* Allocate to the register before the previous. */ - tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + tcg_debug_assert(i > (input_p ? nb_oargs : 0)); o =3D i - 1; - tcg_debug_assert(!def->args_ct[o].pair); - tcg_debug_assert(!def->args_ct[o].ct); - def->args_ct[i] =3D (TCGArgConstraint){ + tcg_debug_assert(!args_ct[o].pair); + tcg_debug_assert(!args_ct[o].ct); + args_ct[i] =3D (TCGArgConstraint){ .pair =3D 1, .pair_index =3D o, - .regs =3D def->args_ct[o].regs >> 1, - .newreg =3D def->args_ct[o].newreg, + .regs =3D args_ct[o].regs >> 1, + .newreg =3D args_ct[o].newreg, }; - def->args_ct[o].pair =3D 2; - def->args_ct[o].pair_index =3D i; + args_ct[o].pair =3D 2; + args_ct[o].pair_index =3D i; tcg_debug_assert(ct_str[1] =3D=3D '\0'); continue; } @@ -3288,16 +3255,16 @@ static void process_op_defs(TCGContext *s) do { switch (*ct_str) { case 'i': - def->args_ct[i].ct |=3D TCG_CT_CONST; + args_ct[i].ct |=3D TCG_CT_CONST; break; =20 /* Include all of the target-specific constraints. */ =20 #undef CONST #define CONST(CASE, MASK) \ - case CASE: def->args_ct[i].ct |=3D MASK; break; + case CASE: args_ct[i].ct |=3D MASK; break; #define REGS(CASE, MASK) \ - case CASE: def->args_ct[i].regs |=3D MASK; break; + case CASE: args_ct[i].regs |=3D MASK; break; =20 #include "tcg-target-con-str.h" =20 @@ -3308,15 +3275,12 @@ static void process_op_defs(TCGContext *s) case '&': case 'p': case 'm': - /* Typo in TCGTargetOpDef constraint. */ + /* Typo in TCGConstraintSet constraint. */ g_assert_not_reached(); } } while (*++ct_str !=3D '\0'); } =20 - /* TCGTargetOpDef entry with too much information? */ - tcg_debug_assert(i =3D=3D TCG_MAX_OP_ARGS || tdefs->args_ct_str[i]= =3D=3D NULL); - /* * Fix up output pairs that are aliased with inputs. * When we created the alias, we copied pair from the output. @@ -3337,51 +3301,53 @@ static void process_op_defs(TCGContext *s) * first output to pair=3D3, and the pair_index'es to match. */ if (saw_alias_pair) { - for (i =3D def->nb_oargs; i < nb_args; i++) { + for (int i =3D nb_oargs; i < nb_args; i++) { + int o, o2, i2; + /* * Since [0-9pm] must be alone in the constraint string, * the only way they can both be set is if the pair comes * from the output alias. */ - if (!def->args_ct[i].ialias) { + if (!args_ct[i].ialias) { continue; } - switch (def->args_ct[i].pair) { + switch (args_ct[i].pair) { case 0: break; case 1: - o =3D def->args_ct[i].alias_index; - o2 =3D def->args_ct[o].pair_index; - tcg_debug_assert(def->args_ct[o].pair =3D=3D 1); - tcg_debug_assert(def->args_ct[o2].pair =3D=3D 2); - if (def->args_ct[o2].oalias) { + o =3D args_ct[i].alias_index; + o2 =3D args_ct[o].pair_index; + tcg_debug_assert(args_ct[o].pair =3D=3D 1); + tcg_debug_assert(args_ct[o2].pair =3D=3D 2); + if (args_ct[o2].oalias) { /* Case 1a */ - i2 =3D def->args_ct[o2].alias_index; - tcg_debug_assert(def->args_ct[i2].pair =3D=3D 2); - def->args_ct[i2].pair_index =3D i; - def->args_ct[i].pair_index =3D i2; + i2 =3D args_ct[o2].alias_index; + tcg_debug_assert(args_ct[i2].pair =3D=3D 2); + args_ct[i2].pair_index =3D i; + args_ct[i].pair_index =3D i2; } else { /* Case 1b */ - def->args_ct[i].pair_index =3D i; + args_ct[i].pair_index =3D i; } break; case 2: - o =3D def->args_ct[i].alias_index; - o2 =3D def->args_ct[o].pair_index; - tcg_debug_assert(def->args_ct[o].pair =3D=3D 2); - tcg_debug_assert(def->args_ct[o2].pair =3D=3D 1); - if (def->args_ct[o2].oalias) { + o =3D args_ct[i].alias_index; + o2 =3D args_ct[o].pair_index; + tcg_debug_assert(args_ct[o].pair =3D=3D 2); + tcg_debug_assert(args_ct[o2].pair =3D=3D 1); + if (args_ct[o2].oalias) { /* Case 1a */ - i2 =3D def->args_ct[o2].alias_index; - tcg_debug_assert(def->args_ct[i2].pair =3D=3D 1); - def->args_ct[i2].pair_index =3D i; - def->args_ct[i].pair_index =3D i2; + i2 =3D args_ct[o2].alias_index; + tcg_debug_assert(args_ct[i2].pair =3D=3D 1); + args_ct[i2].pair_index =3D i; + args_ct[i].pair_index =3D i2; } else { /* Case 2 */ - def->args_ct[i].pair =3D 3; - def->args_ct[o2].pair =3D 3; - def->args_ct[i].pair_index =3D o2; - def->args_ct[o2].pair_index =3D i; + args_ct[i].pair =3D 3; + args_ct[o2].pair =3D 3; + args_ct[i].pair_index =3D o2; + args_ct[o2].pair_index =3D i; } break; default: @@ -3391,8 +3357,40 @@ static void process_op_defs(TCGContext *s) } =20 /* sort the constraints (XXX: this is just an heuristic) */ - sort_constraints(def, 0, def->nb_oargs); - sort_constraints(def, def->nb_oargs, def->nb_iargs); + sort_constraints(args_ct, 0, nb_oargs); + sort_constraints(args_ct, nb_oargs, nb_iargs); + } + + for (TCGOpcode op =3D 0; op < NB_OPS; op++) { + TCGOpDef *def =3D &tcg_op_defs[op]; + const TCGConstraintSet *tdefs; + TCGConstraintSetIndex con_set; + int nb_args; + + nb_args =3D def->nb_iargs + def->nb_oargs; + if (nb_args =3D=3D 0) { + continue; + } + + if (def->flags & TCG_OPF_NOT_PRESENT) { + def->args_ct =3D empty_cts; + continue; + } + + /* + * Macro magic should make it impossible, but double-check that + * the array index is in range. At the same time, double-check + * that the opcode is implemented, i.e. not C_NotImplemented. + */ + con_set =3D tcg_target_op_def(op); + tcg_debug_assert(con_set >=3D 0 && con_set < ARRAY_SIZE(constraint= _sets)); + + /* The constraint arguments must match TCGOpcode arguments. */ + tdefs =3D &constraint_sets[con_set]; + tcg_debug_assert(tdefs->nb_oargs =3D=3D def->nb_oargs); + tcg_debug_assert(tdefs->nb_iargs =3D=3D def->nb_iargs); + + def->args_ct =3D all_cts[con_set]; } } =20 --=20 2.43.0