Commit 4dc81f2822187f4503d4bdb76785cafa5b28db0b
1 parent
39cf05d3
debug output: write helper names
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4529 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
35 additions
and
15 deletions
tcg/tcg.c
... | ... | @@ -516,22 +516,11 @@ void tcg_register_helper(void *func, const char *name) |
516 | 516 | s->helpers = realloc(s->helpers, n * sizeof(TCGHelperInfo)); |
517 | 517 | s->allocated_helpers = n; |
518 | 518 | } |
519 | - s->helpers[s->nb_helpers].func = func; | |
519 | + s->helpers[s->nb_helpers].func = (tcg_target_ulong)func; | |
520 | 520 | s->helpers[s->nb_helpers].name = name; |
521 | 521 | s->nb_helpers++; |
522 | 522 | } |
523 | 523 | |
524 | -const char *tcg_helper_get_name(TCGContext *s, void *func) | |
525 | -{ | |
526 | - int i; | |
527 | - | |
528 | - for(i = 0; i < s->nb_helpers; i++) { | |
529 | - if (s->helpers[i].func == func) | |
530 | - return s->helpers[i].name; | |
531 | - } | |
532 | - return NULL; | |
533 | -} | |
534 | - | |
535 | 524 | static inline TCGType tcg_get_base_type(TCGContext *s, TCGv arg) |
536 | 525 | { |
537 | 526 | 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) |
718 | 707 | return tcg_get_arg_str_idx(s, buf, buf_size, GET_TCGV(arg)); |
719 | 708 | } |
720 | 709 | |
710 | +/* find helper definition (XXX: inefficient) */ | |
711 | +static TCGHelperInfo *tcg_find_helper(TCGContext *s, tcg_target_ulong val) | |
712 | +{ | |
713 | + int i; | |
714 | + for(i = 0; i < s->nb_helpers; i++) { | |
715 | + if (s->helpers[i].func == val) | |
716 | + return &s->helpers[i]; | |
717 | + } | |
718 | + return NULL; | |
719 | +} | |
720 | + | |
721 | +static const char *tcg_get_helper_str_idx(TCGContext *s, char *buf, int buf_size, | |
722 | + int idx) | |
723 | +{ | |
724 | + TCGTemp *ts; | |
725 | + TCGHelperInfo *th; | |
726 | + | |
727 | + ts = &s->temps[idx]; | |
728 | + if (ts->val_type == TEMP_VAL_CONST) { | |
729 | + /* find helper name (XXX: inefficient) */ | |
730 | + th = tcg_find_helper(s, ts->val); | |
731 | + if (th) { | |
732 | + pstrcpy(buf, buf_size, "$"); | |
733 | + pstrcat(buf, buf_size, th->name); | |
734 | + return buf; | |
735 | + } | |
736 | + } | |
737 | + return tcg_get_arg_str_idx(s, buf, buf_size, idx); | |
738 | +} | |
739 | + | |
740 | + | |
721 | 741 | void tcg_dump_ops(TCGContext *s, FILE *outfile) |
722 | 742 | { |
723 | 743 | const uint16_t *opc_ptr; |
... | ... | @@ -735,6 +755,7 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) |
735 | 755 | fprintf(outfile, " %s ", def->name); |
736 | 756 | if (c == INDEX_op_call) { |
737 | 757 | TCGArg arg; |
758 | + | |
738 | 759 | /* variable number of arguments */ |
739 | 760 | arg = *args++; |
740 | 761 | nb_oargs = arg >> 16; |
... | ... | @@ -742,9 +763,8 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) |
742 | 763 | nb_cargs = def->nb_cargs; |
743 | 764 | |
744 | 765 | /* function name */ |
745 | - /* XXX: dump helper name for call */ | |
746 | 766 | fprintf(outfile, "%s", |
747 | - tcg_get_arg_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1])); | |
767 | + tcg_get_helper_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1])); | |
748 | 768 | /* flags */ |
749 | 769 | fprintf(outfile, ",$0x%" TCG_PRIlx, |
750 | 770 | args[nb_oargs + nb_iargs]); | ... | ... |