aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/avr/avr-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/avr/avr-log.c')
-rw-r--r--gcc/config/avr/avr-log.c86
1 files changed, 77 insertions, 9 deletions
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, "<BUILTIN-LOCATION");
+ fprintf (file, "<BUILTIN-LOCATION>");
else if (UNKNOWN_LOCATION == loc)
fprintf (file, "<UNKNOWN-LOCATION>");
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");
}
}