From 28eeb1470b804a2c0c732251df31ca6d95a768f8 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Wed, 20 Dec 2017 12:51:57 +0000 Subject: [PATCH] poly_int: dump routines 2017-12-20 Richard Sandiford Alan Hayward David Sherwood gcc/ * dumpfile.h (dump_dec): Declare. * dumpfile.c (dump_dec): New function. * pretty-print.h (pp_wide_integer): Turn into a function and declare a poly_int version. * pretty-print.c (pp_wide_integer): New function for poly_ints. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255864 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 ++++++++++ gcc/dumpfile.c | 21 +++++++++++++++++++++ gcc/dumpfile.h | 3 +++ gcc/pretty-print.c | 24 ++++++++++++++++++++++++ gcc/pretty-print.h | 13 +++++++++++-- 5 files changed, 69 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b57ea6c98d..482206640ea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,16 @@ Alan Hayward David Sherwood + * dumpfile.h (dump_dec): Declare. + * dumpfile.c (dump_dec): New function. + * pretty-print.h (pp_wide_integer): Turn into a function and + declare a poly_int version. + * pretty-print.c (pp_wide_integer): New function for poly_ints. + +2017-12-20 Richard Sandiford + Alan Hayward + David Sherwood + * doc/generic.texi (POLY_INT_CST): Document. * tree.def (POLY_INT_CST): New tree code. * treestruct.def (TS_POLY_INT_CST): New tree layout. diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index 4a59d601044..a49ff997ea4 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -473,6 +473,27 @@ dump_printf_loc (dump_flags_t dump_kind, source_location loc, } } +/* Output VALUE in decimal to appropriate dump streams. */ + +template +void +dump_dec (int dump_kind, const poly_int &value) +{ + STATIC_ASSERT (poly_coeff_traits::signedness >= 0); + signop sgn = poly_coeff_traits::signedness ? SIGNED : UNSIGNED; + if (dump_file && (dump_kind & pflags)) + print_dec (value, dump_file, sgn); + + if (alt_dump_file && (dump_kind & alt_flags)) + print_dec (value, alt_dump_file, sgn); +} + +template void dump_dec (int, const poly_uint16 &); +template void dump_dec (int, const poly_int64 &); +template void dump_dec (int, const poly_uint64 &); +template void dump_dec (int, const poly_offset_int &); +template void dump_dec (int, const poly_widest_int &); + /* Start a dump for PHASE. Store user-supplied dump flags in *FLAG_PTR. Return the number of streams opened. Set globals DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 1b4d7e7dab7..910452b8370 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -175,6 +175,9 @@ extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int); extern void print_combine_total_stats (void); extern bool enable_rtl_dump_file (void); +template +void dump_dec (int, const poly_int &); + /* In tree-dump.c */ extern void dump_node (const_tree, dump_flags_t, FILE *); diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 1fbd2fe045f..0c328d0c250 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -795,6 +795,30 @@ pp_clear_state (pretty_printer *pp) pp_indentation (pp) = 0; } +/* Print X to PP in decimal. */ +template +void +pp_wide_integer (pretty_printer *pp, const poly_int_pod &x) +{ + if (x.is_constant ()) + pp_wide_integer (pp, x.coeffs[0]); + else + { + pp_left_bracket (pp); + for (unsigned int i = 0; i < N; ++i) + { + if (i != 0) + pp_comma (pp); + pp_wide_integer (pp, x.coeffs[i]); + } + pp_right_bracket (pp); + } +} + +template void pp_wide_integer (pretty_printer *, const poly_uint16_pod &); +template void pp_wide_integer (pretty_printer *, const poly_int64_pod &); +template void pp_wide_integer (pretty_printer *, const poly_uint64_pod &); + /* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */ void pp_write_text_to_stream (pretty_printer *pp) diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index 9f6e2bb29a5..92d1d8e08d2 100644 --- a/gcc/pretty-print.h +++ b/gcc/pretty-print.h @@ -328,8 +328,6 @@ pp_get_prefix (const pretty_printer *pp) { return pp->prefix; } pp_string (PP, pp_buffer (PP)->digit_buffer); \ } \ while (0) -#define pp_wide_integer(PP, I) \ - pp_scalar (PP, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I) #define pp_pointer(PP, P) pp_scalar (PP, "%p", P) #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \ @@ -404,4 +402,15 @@ extern const char *identifier_to_locale (const char *); extern void *(*identifier_to_locale_alloc) (size_t); extern void (*identifier_to_locale_free) (void *); +/* Print I to PP in decimal. */ + +inline void +pp_wide_integer (pretty_printer *pp, HOST_WIDE_INT i) +{ + pp_scalar (pp, HOST_WIDE_INT_PRINT_DEC, i); +} + +template +void pp_wide_integer (pretty_printer *pp, const poly_int_pod &); + #endif /* GCC_PRETTY_PRINT_H */ -- 2.11.4.GIT