diff options
Diffstat (limited to 'gcc/profile-count.c')
-rw-r--r-- | gcc/profile-count.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/gcc/profile-count.c b/gcc/profile-count.c index 8c58f86..4f0bac0 100644 --- a/gcc/profile-count.c +++ b/gcc/profile-count.c @@ -33,34 +33,57 @@ along with GCC; see the file COPYING3. If not see #include "wide-int.h" #include "sreal.h" +/* Names from profile_quality enum values. */ + +const char *profile_quality_names[] = +{ + "uninitialized", + "guessed_local", + "guessed_global0", + "guessed_global0adjusted", + "guessed", + "afdo", + "adjusted", + "precise" +}; + /* Get a string describing QUALITY. */ const char * profile_quality_as_string (enum profile_quality quality) { - switch (quality) - { - default: - gcc_unreachable (); - case profile_uninitialized: - return "uninitialized"; - case profile_guessed_local: - return "guessed_local"; - case profile_guessed_global0: - return "guessed_global0"; - case profile_guessed_global0adjusted: - return "guessed_global0adjusted"; - case profile_guessed: - return "guessed"; - case profile_afdo: - return "afdo"; - case profile_adjusted: - return "adjusted"; - case profile_precise: - return "precise"; - } + return profile_quality_names[quality]; +} + +/* Parse VALUE as profile quality and return true when a valid QUALITY. */ + +bool +parse_profile_quality (const char *value, profile_quality *quality) +{ + for (unsigned i = 0; i < ARRAY_SIZE (profile_quality_names); i++) + if (strcmp (profile_quality_names[i], value) == 0) + { + *quality = (profile_quality)i; + return true; + } + + return false; } +/* Display names from profile_quality enum values. */ + +const char *profile_quality_display_names[] = +{ + NULL, + "estimated locally", + "estimated locally, globally 0", + "estimated locally, globally 0 adjusted", + "adjusted", + "auto FDO", + "guessed", + "precise" +}; + /* Dump THIS to F. */ void @@ -69,23 +92,8 @@ profile_count::dump (FILE *f) const if (!initialized_p ()) fprintf (f, "uninitialized"); else - { - fprintf (f, "%" PRId64, m_val); - if (m_quality == profile_guessed_local) - fprintf (f, " (estimated locally)"); - else if (m_quality == profile_guessed_global0) - fprintf (f, " (estimated locally, globally 0)"); - else if (m_quality == profile_guessed_global0adjusted) - fprintf (f, " (estimated locally, globally 0 adjusted)"); - else if (m_quality == profile_adjusted) - fprintf (f, " (adjusted)"); - else if (m_quality == profile_afdo) - fprintf (f, " (auto FDO)"); - else if (m_quality == profile_guessed) - fprintf (f, " (guessed)"); - else if (m_quality == profile_precise) - fprintf (f, " (precise)"); - } + fprintf (f, "%" PRId64 " (%s)", m_val, + profile_quality_display_names[m_quality]); } /* Dump THIS to stderr. */ @@ -362,7 +370,7 @@ profile_count::combine_with_ipa_count (profile_count ipa) Conversions back and forth are used to read the coverage and get it into internal representation. */ profile_count -profile_count::from_gcov_type (gcov_type v) +profile_count::from_gcov_type (gcov_type v, profile_quality quality) { profile_count ret; gcc_checking_assert (v >= 0); @@ -371,7 +379,7 @@ profile_count::from_gcov_type (gcov_type v) "Capping gcov count %" PRId64 " to max_count %" PRId64 "\n", (int64_t) v, (int64_t) max_count); ret.m_val = MIN (v, (gcov_type)max_count); - ret.m_quality = profile_precise; + ret.m_quality = quality; return ret; } |