aboutsummaryrefslogtreecommitdiffstats
path: root/tcg
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-22 16:08:32 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-22 16:08:32 +0000
commit4dc81f2822187f4503d4bdb76785cafa5b28db0b (patch)
tree4c8aa7252d9372bd43a2b40f99724a5a86c38c1d /tcg
parent39cf05d32217f624e4b2e70cde2b5d4a1e841c89 (diff)
debug output: write helper names
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4529 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tcg')
-rw-r--r--tcg/tcg.c48
-rw-r--r--tcg/tcg.h2
2 files changed, 35 insertions, 15 deletions
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 34618b1c0..4e3094b7c 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -516,22 +516,11 @@ void tcg_register_helper(void *func, const char *name)
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 @@ char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGv arg)
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 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile)
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 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile)
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]);
diff --git a/tcg/tcg.h b/tcg/tcg.h
index feed50e15..1c9b5f122 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -192,7 +192,7 @@ typedef struct TCGTemp {
} TCGTemp;
typedef struct TCGHelperInfo {
- void *func;
+ tcg_target_ulong func;
const char *name;
} TCGHelperInfo;