PR ipa/pr67600
[platform/upstream/gcc.git] / gcc / bitmap.h
index 3f9bbf3..3715855 100644 (file)
@@ -86,7 +86,7 @@ along with GCC; see the file COPYING3.  If not see
      * set_disjuction          : bitmap_xor_comp / bitmap_xor_comp_into
      * set_compare             : bitmap_equal_p
 
-   Some operations on 3 sets that occur frequently in in data flow problems
+   Some operations on 3 sets that occur frequently in data flow problems
    are also implemented:
 
      * A | (B & C)             : bitmap_ior_and_into
@@ -127,10 +127,65 @@ along with GCC; see the file COPYING3.  If not see
    bad for persistent sets, so persistent sets should be allocated on an
    obstack whenever possible.  */
 
-#include "hashtab.h"
-#include "statistics.h"
 #include "obstack.h"
 
+/* Bitmap memory usage.  */
+struct bitmap_usage: public mem_usage
+{
+  /* Default contructor.  */
+  bitmap_usage (): m_nsearches (0), m_search_iter (0) {}
+  /* Constructor.  */
+  bitmap_usage (size_t allocated, size_t times, size_t peak,
+            uint64_t nsearches, uint64_t search_iter)
+    : mem_usage (allocated, times, peak),
+    m_nsearches (nsearches), m_search_iter (search_iter) {}
+
+  /* Sum the usage with SECOND usage.  */
+  bitmap_usage
+  operator+ (const bitmap_usage &second)
+  {
+    return bitmap_usage (m_allocated + second.m_allocated,
+                            m_times + second.m_times,
+                            m_peak + second.m_peak,
+                            m_nsearches + second.m_nsearches,
+                            m_search_iter + second.m_search_iter);
+  }
+
+  /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
+  inline void
+  dump (mem_location *loc, mem_usage &total) const
+  {
+    char *location_string = loc->to_string ();
+
+    fprintf (stderr, "%-48s %10li:%5.1f%%%10li%10li:%5.1f%%%12li%12li%10s\n",
+            location_string,
+            (long)m_allocated, get_percent (m_allocated, total.m_allocated),
+            (long)m_peak, (long)m_times,
+            get_percent (m_times, total.m_times),
+            (long)m_nsearches, (long)m_search_iter,
+            loc->m_ggc ? "ggc" : "heap");
+
+    free (location_string);
+  }
+
+  /* Dump header with NAME.  */
+  static inline void
+  dump_header (const char *name)
+  {
+    fprintf (stderr, "%-48s %11s%16s%17s%12s%12s%10s\n", name, "Leak", "Peak",
+            "Times", "N searches", "Search iter", "Type");
+    print_dash_line ();
+  }
+
+  /* Number search operations.  */
+  uint64_t m_nsearches;
+  /* Number of search iterations.  */
+  uint64_t m_search_iter;
+};
+
+/* Bitmap memory description.  */
+extern mem_alloc_description<bitmap_usage> bitmap_mem_desc;
+
 /* Fundamental storage type for bitmap.  */
 
 typedef unsigned long BITMAP_WORD;