diff mbox series

[007/nnn] poly_int: dump routines

Message ID 874lqpu7ar.fsf@linaro.org
State New
Headers show
Series [007/nnn] poly_int: dump routines | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:02 p.m. UTC
Add poly_int routines for the dumpfile.h and pretty-print.h frameworks.


2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

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.

Comments

Jeff Law Nov. 17, 2017, 3:36 a.m. UTC | #1
On 10/23/2017 11:02 AM, Richard Sandiford wrote:
> Add poly_int routines for the dumpfile.h and pretty-print.h frameworks.

> 

> 

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> 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.

OK.
jeff
diff mbox series

Patch

Index: gcc/dumpfile.h
===================================================================
--- gcc/dumpfile.h	2017-10-23 16:52:20.417686430 +0100
+++ gcc/dumpfile.h	2017-10-23 17:01:00.431554440 +0100
@@ -174,6 +174,9 @@  extern void dump_gimple_stmt (dump_flags
 extern void print_combine_total_stats (void);
 extern bool enable_rtl_dump_file (void);
 
+template<unsigned int N, typename C>
+void dump_dec (int, const poly_int<N, C> &);
+
 /* In tree-dump.c  */
 extern void dump_node (const_tree, dump_flags_t, FILE *);
 
Index: gcc/dumpfile.c
===================================================================
--- gcc/dumpfile.c	2017-10-23 16:52:20.417686430 +0100
+++ gcc/dumpfile.c	2017-10-23 17:01:00.431554440 +0100
@@ -473,6 +473,27 @@  dump_printf_loc (dump_flags_t dump_kind,
     }
 }
 
+/* Output VALUE in decimal to appropriate dump streams.  */
+
+template<unsigned int N, typename C>
+void
+dump_dec (int dump_kind, const poly_int<N, C> &value)
+{
+  STATIC_ASSERT (poly_coeff_traits<C>::signedness >= 0);
+  signop sgn = poly_coeff_traits<C>::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
Index: gcc/pretty-print.h
===================================================================
--- gcc/pretty-print.h	2017-10-23 16:52:20.417686430 +0100
+++ gcc/pretty-print.h	2017-10-23 17:01:00.431554440 +0100
@@ -328,8 +328,6 @@  #define pp_wide_int(PP, W, SGN)					\
       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) \
@@ -401,4 +399,15 @@  extern const char *identifier_to_locale
 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<unsigned int N, typename T>
+void pp_wide_integer (pretty_printer *pp, const poly_int_pod<N, T> &);
+
 #endif /* GCC_PRETTY_PRINT_H */
Index: gcc/pretty-print.c
===================================================================
--- gcc/pretty-print.c	2017-10-23 16:52:20.417686430 +0100
+++ gcc/pretty-print.c	2017-10-23 17:01:00.431554440 +0100
@@ -795,6 +795,30 @@  pp_clear_state (pretty_printer *pp)
   pp_indentation (pp) = 0;
 }
 
+/* Print X to PP in decimal.  */
+template<unsigned int N, typename T>
+void
+pp_wide_integer (pretty_printer *pp, const poly_int_pod<N, T> &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)