From: Ulrich Drepper Date: Fri, 11 Jan 2008 06:55:16 +0000 (+0000) Subject: Optimize disassembler a bit. X-Git-Tag: elfutils-0.132~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6bc105fc2c2eb312d08db00b50f419ffbcc189f7;p=thirdparty%2Felfutils.git Optimize disassembler a bit. --- diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index d4280cbfd..4790dd122 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -1,5 +1,9 @@ 2008-01-10 Ulrich Drepper + * i386_data.h (FCT_crdb): New function. + (FCT_ccc): Use FCT_crdb. + (FCT_ddd): Likewise. + * defs/i386: Fix a few instructions with immediate arguments. * i386_disasm.c: Rewrite interface to callback functions for operands diff --git a/libcpu/i386_data.h b/libcpu/i386_data.h index 7815dbc2f..c1f2d5e73 100644 --- a/libcpu/i386_data.h +++ b/libcpu/i386_data.h @@ -537,7 +537,8 @@ FCT_ax$w (struct output_data *d) static int -FCT_ccc (struct output_data *d) +__attribute__ ((noinline)) +FCT_crdb (struct output_data *d, const char *regstr) { if (*d->prefixes & has_data16) return -1; @@ -548,8 +549,8 @@ FCT_ccc (struct output_data *d) assert (d->opoff1 / 8 == 2); assert (d->opoff1 % 8 == 2); size_t avail = d->bufsize - *bufcntp; - int needed = snprintf (&d->bufp[*bufcntp], avail, "%%cr%" PRIx32, - (uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7); + int needed = snprintf (&d->bufp[*bufcntp], avail, "%%%s%" PRIx32, + regstr, (uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7); if ((size_t) needed > avail) return needed - avail; *bufcntp += needed; @@ -558,23 +559,16 @@ FCT_ccc (struct output_data *d) static int -FCT_ddd (struct output_data *d) +FCT_ccc (struct output_data *d) { - if (*d->prefixes & has_data16) - return -1; + return FCT_crdb (d, "cr"); +} - size_t *bufcntp = d->bufcntp; - // XXX If this assert is true, use absolute offset below - assert (d->opoff1 / 8 == 2); - assert (d->opoff1 % 8 == 2); - size_t avail = d->bufsize - *bufcntp; - int needed = snprintf (&d->bufp[*bufcntp], avail, "%%db%" PRIx32, - (uint32_t) (d->data[d->opoff1 / 8] >> 3) & 7); - if ((size_t) needed > avail) - return needed - avail; - *bufcntp += needed; - return 0; +static int +FCT_ddd (struct output_data *d) +{ + return FCT_crdb (d, "db"); }