From patchwork Mon Feb 15 16:17:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 45398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E7B0AB6EEB for ; Tue, 16 Feb 2010 03:18:12 +1100 (EST) Received: from localhost ([127.0.0.1]:44775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh3eC-0006ls-Ve for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 11:18:08 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh3df-0006ln-JT for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:17:35 -0500 Received: from [199.232.76.173] (port=58074 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh3de-0006lf-9z for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:17:34 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nh3db-0004N9-Oe for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:17:34 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:49607) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh3db-0004Mp-8R for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:17:31 -0500 Received: from flocke.weilnetz.de (p54ADF929.dip.t-dialin.net [84.173.249.41]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MS0a2-1NEug60R46-00TL3v; Mon, 15 Feb 2010 17:17:28 +0100 Received: from stefan by flocke.weilnetz.de with local (Exim 4.71) (envelope-from ) id 1Nh3dW-0008U8-VT; Mon, 15 Feb 2010 17:17:27 +0100 From: Stefan Weil To: QEMU Developers X-Mailer: git-send-email 1.6.6.1 X-Provags-ID: V01U2FsdGVkX19ky8McVMh+6Mj3nhd23JY9xvU/TUmWVRcW05n D+JCEhnlGP4iCaqr0dY3MJ7BjjCb8NURbpCf6bP8fpzWpTjBBO ziKnnkXkfTqKaPp7ssg7Q5wdrTFdVP//J3rhHCh7FEnIPCOrDP 1QQ== X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH] tcg: Add consistency checks for op definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When compiled with CONFIG_DEBUG_TCG, this code looks for missing, duplicate and wrong entries in the op definitions. Errors will raise an assertion at program start (all checks are done in the initial phase). The current code contains such errors, at least for i386 guest on i386 host. Signed-off-by: Stefan Weil --- tcg/tcg.c | 21 +++++++++++++++++++++ tcg/tcg.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 9949814..e6a1caf 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -981,9 +981,16 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs) op = tdefs->op; assert(op >= 0 && op < NB_OPS); def = &tcg_op_defs[op]; +#if defined(CONFIG_DEBUG_TCG) + /* Duplicate entry in op definitions? */ + assert(!def->used); + def->used = 1; +#endif nb_args = def->nb_iargs + def->nb_oargs; for(i = 0; i < nb_args; i++) { ct_str = tdefs->args_ct_str[i]; + /* Incomplete TCGTargetOpDef entry? */ + assert(ct_str != NULL); tcg_regset_clear(def->args_ct[i].u.regs); def->args_ct[i].ct = 0; if (ct_str[0] >= '0' && ct_str[0] <= '9') { @@ -1018,6 +1025,9 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs) } } + /* TCGTargetOpDef entry with too much information? */ + assert(i == TCG_MAX_OP_ARGS || tdefs->args_ct_str[i] == NULL); + /* 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); @@ -1035,6 +1045,17 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs) tdefs++; } +#if defined(CONFIG_DEBUG_TCG) + for (op = 0; op < ARRAY_SIZE(tcg_op_defs); op++) { + if (op < INDEX_op_call || op == INDEX_op_debug_insn_start) { + /* Wrong entry in op definitions? */ + assert(!tcg_op_defs[op].used); + } else { + /* Missing entry in op definitions? */ + assert(tcg_op_defs[op].used); + } + } +#endif } #ifdef USE_LIVENESS_ANALYSIS diff --git a/tcg/tcg.h b/tcg/tcg.h index b218abe..aca9f27 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -404,6 +404,9 @@ typedef struct TCGOpDef { uint16_t copy_size; TCGArgConstraint *args_ct; int *sorted_args; +#if defined(CONFIG_DEBUG_TCG) + int used; +#endif } TCGOpDef; typedef struct TCGTargetOpDef {