aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-05 14:36:29 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-05 13:36:29 +0000
commit40ce7fa6dd38f8ac26d576c84f5dbe4362aa902b (patch)
tree94fa1f477283ce96ec503e9878181a2db6833334 /gcc/system.h
parent00e6775a5faa43702e96e315e7a1c22297983f2a (diff)
downloadgcc-40ce7fa6dd38f8ac26d576c84f5dbe4362aa902b.zip
gcc-40ce7fa6dd38f8ac26d576c84f5dbe4362aa902b.tar.gz
gcc-40ce7fa6dd38f8ac26d576c84f5dbe4362aa902b.tar.bz2
Come up with SIZE_AMOUNT and use it in memory statistics and sort stats.
2018-11-05 Martin Liska <mliska@suse.cz> * alloc-pool.h (struct pool_usage): Use SIZE_AMOUNT. * bitmap.h (struct bitmap_usage): Likewise. * ggc-common.c (SCALE): Remove. (LABEL): Likewise. (struct ggc_usage): Use SIZE_AMOUNT. And update compare method. * ggc-page.c (SCALE): Remove. (STAT_LABEL): Remove. (ggc_print_statistics): Use SIZE_AMOUNT. * gimple.h (SCALE): Remove. (LABEL): Likewise. * input.c (ONE_K): Remove. (ONE_M): Likewise. (SCALE): Likewise. (STAT_LABEL): Likewise. (FORMAT_AMOUNT): Likewise. (dump_line_table_statistics): Use SIZE_AMOUNT. * mem-stats.h (struct mem_usage): Likewise. * rtl.c (dump_rtx_statistics): Likewise. (rtx_alloc_counts): Change type to size_t. (rtx_alloc_sizes): Likewise. (rtx_count_cmp): New. (dump_rtx_statistics): Sort first based on counts. * tree.c (tree_nodes_cmp): New. (tree_codes_cmp): New. (dump_tree_statistics): Sort first based on counts. * system.h (ONE_K): New. (ONE_M): Likewise. (SIZE_SCALE): Likewise. (SIZE_LABEL): Likewise. (SIZE_AMOUNT): Likewise. * tree-cfg.c (dump_cfg_stats): Use SIZE_AMOUNT. * tree-dfa.c (dump_dfa_stats): Likewise. * tree-phinodes.c (phinodes_print_statistics): Likewise. * tree-ssanames.c (ssanames_print_statistics): Likewise. * tree.c (dump_tree_statistics): Likewise. * vec.c (struct vec_usage): Likewise. * trans-mem.c (tm_mangle): Enlarge buffer in order to not trigger a -Werror=format-overflow with --enable-gather-detailed-stats. From-SVN: r265800
Diffstat (limited to 'gcc/system.h')
-rw-r--r--gcc/system.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h
index 100feb5..ba32821 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1208,4 +1208,29 @@ void gcc_stablesort (void *, size_t, size_t,
#undef qsort
#define qsort(...) PP_5th (__VA_ARGS__, gcc_qsort, 3, 2, qsort, 0) (__VA_ARGS__)
+#define ONE_K 1024
+#define ONE_M (ONE_K * ONE_K)
+
+/* Display a number as an integer multiple of either:
+ - 1024, if said integer is >= to 10 K (in base 2)
+ - 1024 * 1024, if said integer is >= 10 M in (base 2)
+ */
+#define SIZE_SCALE(x) (((x) < 10 * ONE_K \
+ ? (x) \
+ : ((x) < 10 * ONE_M \
+ ? (x) / ONE_K \
+ : (x) / ONE_M)))
+
+/* For a given integer, display either:
+ - the character 'k', if the number is higher than 10 K (in base 2)
+ but strictly lower than 10 M (in base 2)
+ - the character 'M' if the number is higher than 10 M (in base2)
+ - the charcter ' ' if the number is strictly lower than 10 K */
+#define SIZE_LABEL(x) ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M'))
+
+/* Display an integer amount as multiple of 1K or 1M (in base 2).
+ Display the correct unit (either k, M, or ' ') after the amount, as
+ well. */
+#define SIZE_AMOUNT(size) SIZE_SCALE (size), SIZE_LABEL (size)
+
#endif /* ! GCC_SYSTEM_H */