From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzDLJ-0006iM-Fb for qemu-devel@nongnu.org; Thu, 22 May 2008 12:08:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JzDLH-0006gH-Oi for qemu-devel@nongnu.org; Thu, 22 May 2008 12:08:37 -0400 Received: from [199.232.76.173] (port=40802 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzDLH-0006g4-GO for qemu-devel@nongnu.org; Thu, 22 May 2008 12:08:35 -0400 Received: from savannah.gnu.org ([199.232.41.3]:56002 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JzDLH-00022f-3u for qemu-devel@nongnu.org; Thu, 22 May 2008 12:08:35 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JzDLF-0003l9-OP for qemu-devel@nongnu.org; Thu, 22 May 2008 16:08:33 +0000 Received: from bellard by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JzDLF-0003l5-Dm for qemu-devel@nongnu.org; Thu, 22 May 2008 16:08:33 +0000 MIME-Version: 1.0 Errors-To: bellard Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fabrice Bellard Message-Id: Date: Thu, 22 May 2008 16:08:33 +0000 Subject: [Qemu-devel] [4529] debug output: write helper names Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4529 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4529 Author: bellard Date: 2008-05-22 16:08:32 +0000 (Thu, 22 May 2008) Log Message: ----------- debug output: write helper names Modified Paths: -------------- trunk/tcg/tcg.c trunk/tcg/tcg.h Modified: trunk/tcg/tcg.c =================================================================== --- trunk/tcg/tcg.c 2008-05-22 14:59:57 UTC (rev 4528) +++ trunk/tcg/tcg.c 2008-05-22 16:08:32 UTC (rev 4529) @@ -516,22 +516,11 @@ s->helpers = realloc(s->helpers, n * sizeof(TCGHelperInfo)); s->allocated_helpers = n; } - s->helpers[s->nb_helpers].func = func; + s->helpers[s->nb_helpers].func = (tcg_target_ulong)func; s->helpers[s->nb_helpers].name = name; s->nb_helpers++; } -const char *tcg_helper_get_name(TCGContext *s, void *func) -{ - int i; - - for(i = 0; i < s->nb_helpers; i++) { - if (s->helpers[i].func == func) - return s->helpers[i].name; - } - return NULL; -} - static inline TCGType tcg_get_base_type(TCGContext *s, TCGv arg) { return s->temps[GET_TCGV(arg)].base_type; @@ -718,6 +707,37 @@ return tcg_get_arg_str_idx(s, buf, buf_size, GET_TCGV(arg)); } +/* find helper definition (XXX: inefficient) */ +static TCGHelperInfo *tcg_find_helper(TCGContext *s, tcg_target_ulong val) +{ + int i; + for(i = 0; i < s->nb_helpers; i++) { + if (s->helpers[i].func == val) + return &s->helpers[i]; + } + return NULL; +} + +static const char *tcg_get_helper_str_idx(TCGContext *s, char *buf, int buf_size, + int idx) +{ + TCGTemp *ts; + TCGHelperInfo *th; + + ts = &s->temps[idx]; + if (ts->val_type == TEMP_VAL_CONST) { + /* find helper name (XXX: inefficient) */ + th = tcg_find_helper(s, ts->val); + if (th) { + pstrcpy(buf, buf_size, "$"); + pstrcat(buf, buf_size, th->name); + return buf; + } + } + return tcg_get_arg_str_idx(s, buf, buf_size, idx); +} + + void tcg_dump_ops(TCGContext *s, FILE *outfile) { const uint16_t *opc_ptr; @@ -735,6 +755,7 @@ fprintf(outfile, " %s ", def->name); if (c == INDEX_op_call) { TCGArg arg; + /* variable number of arguments */ arg = *args++; nb_oargs = arg >> 16; @@ -742,9 +763,8 @@ nb_cargs = def->nb_cargs; /* function name */ - /* XXX: dump helper name for call */ fprintf(outfile, "%s", - tcg_get_arg_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1])); + tcg_get_helper_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1])); /* flags */ fprintf(outfile, ",$0x%" TCG_PRIlx, args[nb_oargs + nb_iargs]); Modified: trunk/tcg/tcg.h =================================================================== --- trunk/tcg/tcg.h 2008-05-22 14:59:57 UTC (rev 4528) +++ trunk/tcg/tcg.h 2008-05-22 16:08:32 UTC (rev 4529) @@ -192,7 +192,7 @@ } TCGTemp; typedef struct TCGHelperInfo { - void *func; + tcg_target_ulong func; const char *name; } TCGHelperInfo;