From ef794b006e890cdf5f0e10af35495d8a373f5d17 Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Fri, 25 Nov 2011 10:46:10 +0000 Subject: PR target/50566 * config/avr/avr-protos.h (avr_log_t): Add field .builtin. * config/avr/avr-log.c (avr_log_set_avr_log): Initialize it. Don't bypass TARGET_ALL_DEBUG. Print self-info with ?. (avr_log_vadump): Support %D and %X to print double_int. (avr_double_int_pop_digit): New static function. (avr_dump_double_int_hex): New static function. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@181718 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 ++++++ gcc/config/avr/avr-log.c | 86 ++++++++++++++++++++++++++++++++++++++++----- gcc/config/avr/avr-protos.h | 1 + 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ee9c2b96704..9091465a3b4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-11-25 Georg-Johann Lay + + PR target/50566 + * config/avr/avr-protos.h (avr_log_t): Add field .builtin. + * config/avr/avr-log.c (avr_log_set_avr_log): Initialize it. + Don't bypass TARGET_ALL_DEBUG. Print self-info with ?. + (avr_log_vadump): Support %D and %X to print double_int. + (avr_double_int_pop_digit): New static function. + (avr_dump_double_int_hex): New static function. + 2011-11-24 Enkovich Ilya PR target/51287 diff --git a/gcc/config/avr/avr-log.c b/gcc/config/avr/avr-log.c index 2f6b0aa6519..3c4bccfa282 100644 --- a/gcc/config/avr/avr-log.c +++ b/gcc/config/avr/avr-log.c @@ -49,6 +49,8 @@ C: enum rtx_code m: enum machine_mode R: enum reg_class + D: double_int (signed decimal) + X: double_int (unsigned hex) L: insn list H: location_t @@ -82,9 +84,9 @@ static void avr_log_vadump (FILE*, const char*, va_list); /* As we have no variadic macros, avr_edump maps to a call to avr_log_set_caller_e which saves __FUNCTION__ to avr_log_caller and - returns a function pointer to avr_log_fdump_e. avr_fdump_e + returns a function pointer to avr_log_fdump_e. avr_log_fdump_e gets the printf-like arguments and calls avr_log_vadump, the - worker function. avr_fdump works the same way. */ + worker function. avr_fdump works the same way. */ /* Provide avr_log_fdump_e/f so that avr_log_set_caller_e/_f can return their address. */ @@ -135,6 +137,49 @@ avr_log_set_caller_f (const char *caller) return avr_log_fdump_f; } + +/* Copy-paste from double-int.c:double_int_split_digit (it's static there). + Splits last digit of *CST (taken as unsigned) in BASE and returns it. */ + +static unsigned +avr_double_int_pop_digit (double_int *cst, unsigned base) +{ + unsigned HOST_WIDE_INT resl, reml; + HOST_WIDE_INT resh, remh; + + div_and_round_double (FLOOR_DIV_EXPR, true, cst->low, cst->high, base, 0, + &resl, &resh, &reml, &remh); + cst->high = resh; + cst->low = resl; + + return reml; +} + + +/* Dump VAL as hex value to FILE. */ + +static void +avr_dump_double_int_hex (FILE *file, double_int val) +{ + unsigned digit[4]; + + digit[0] = avr_double_int_pop_digit (&val, 1 << 16); + digit[1] = avr_double_int_pop_digit (&val, 1 << 16); + digit[2] = avr_double_int_pop_digit (&val, 1 << 16); + digit[3] = avr_double_int_pop_digit (&val, 1 << 16); + + fprintf (file, "0x"); + + if (digit[3] | digit[2]) + fprintf (file, "%04x%04x", digit[3], digit[2]); + + if (digit[3] | digit[2] | digit[1] | digit[0]) + fprintf (file, "%04x%04x", digit[1], digit[0]); + else + fprintf (file, "0"); +} + + /* Worker function implementing the %-codes and forwarding to respective print/dump function. */ @@ -189,6 +234,14 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap) fprintf (file, "%d", va_arg (ap, int)); break; + case 'D': + dump_double_int (file, va_arg (ap, double_int), false); + break; + + case 'X': + avr_dump_double_int_hex (file, va_arg (ap, double_int)); + break; + case 'x': fprintf (file, "%x", va_arg (ap, int)); break; @@ -251,7 +304,7 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap) location_t loc = va_arg (ap, location_t); if (BUILTINS_LOCATION == loc) - fprintf (file, ""); else if (UNKNOWN_LOCATION == loc) fprintf (file, ""); else @@ -306,21 +359,33 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap) void avr_log_set_avr_log (void) { - if (avr_log_details) + bool all = TARGET_ALL_DEBUG != 0; + + if (all || avr_log_details) { /* Adding , at beginning and end of string makes searching easier. */ char *str = (char*) alloca (3 + strlen (avr_log_details)); + bool info; str[0] = ','; strcat (stpcpy (str+1, avr_log_details), ","); - -#define SET_DUMP_DETAIL(S) \ - avr_log.S = (TARGET_ALL_DEBUG \ - || NULL != strstr (str, "," #S ",") \ - || NULL != strstr (str, ",all,")) + + all |= NULL != strstr (str, ",all,"); + info = NULL != strstr (str, ",?,"); + + if (info) + fprintf (stderr, "\n-mlog="); + +#define SET_DUMP_DETAIL(S) \ + do { \ + avr_log.S = (all || NULL != strstr (str, "," #S ",")); \ + if (info) \ + fprintf (stderr, #S ","); \ + } while (0) SET_DUMP_DETAIL (address_cost); + SET_DUMP_DETAIL (builtin); SET_DUMP_DETAIL (constraints); SET_DUMP_DETAIL (legitimate_address_p); SET_DUMP_DETAIL (legitimize_address); @@ -329,5 +394,8 @@ avr_log_set_avr_log (void) SET_DUMP_DETAIL (rtx_costs); #undef SET_DUMP_DETAIL + + if (info) + fprintf (stderr, "?\n\n"); } } diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index 22b1548ed66..c5ed5f0df04 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -142,6 +142,7 @@ extern void avr_log_set_avr_log (void); typedef struct { unsigned address_cost :1; + unsigned builtin :1; unsigned constraints :1; unsigned legitimate_address_p :1; unsigned legitimize_address :1; -- cgit v1.2.3