From c4175212fd31a963ea6af74a1ed1c843f06de78b Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 15 May 2018 14:53:48 -0400 Subject: [PATCH 49/83] Move enum to optinfo.h --- gcc/optimization-records.cc | 24 ++---------------------- gcc/optimization-records.h | 10 ---------- gcc/optinfo.cc | 30 +++++++++++++++++++++++++----- gcc/optinfo.h | 28 ++++++++++++++++++++-------- gcc/profile.c | 4 ++-- gcc/tree-vect-loop.c | 2 +- gcc/tree-vectorizer.h | 8 ++++---- 7 files changed, 54 insertions(+), 52 deletions(-) diff --git a/gcc/optimization-records.cc b/gcc/optimization-records.cc index 3505a4c..11cc065 100644 --- a/gcc/optimization-records.cc +++ b/gcc/optimization-records.cc @@ -134,26 +134,6 @@ optimization_records_finish () /* FIXME. */ -const char * -opt_record_kind_to_string (enum opt_record_kind kind) -{ - switch (kind) - { - default: - gcc_unreachable (); - case OPT_RECORD_SUCCESS: - return "success"; - case OPT_RECORD_FAILURE: - return "failure"; - case OPT_RECORD_REMARK: - return "remark"; - case OPT_RECORD_SCOPE: - return "scope"; - } -} - -/* FIXME. */ - bool optimization_records_enabled_p () { @@ -176,7 +156,7 @@ optimization_records_maybe_record_optinfo (const optinfo *optinfo) obj->set ("impl_location", impl_location_to_json (optinfo->get_impl_location ())); - const char *kind_str = opt_record_kind_to_string (optinfo->get_kind ()); + const char *kind_str = optinfo_kind_to_string (optinfo->get_kind ()); obj->set ("kind", new json::string (kind_str)); json::array *message = new json::array (); obj->set ("message", message); @@ -284,7 +264,7 @@ optimization_records_maybe_record_optinfo (const optinfo *optinfo) scopes[scopes.length () - 1]->append (obj); /* Potentially push the scope. */ - if (optinfo->get_kind () == OPT_RECORD_SCOPE) + if (optinfo->get_kind () == OPTINFO_KIND_SCOPE) { json::array *children = new json::array (); obj->set ("children", children); diff --git a/gcc/optimization-records.h b/gcc/optimization-records.h index 6477501..18c67d5 100644 --- a/gcc/optimization-records.h +++ b/gcc/optimization-records.h @@ -29,16 +29,6 @@ class optinfo; extern void optimization_records_start (); extern void optimization_records_finish (); -enum opt_record_kind -{ - OPT_RECORD_SUCCESS, - OPT_RECORD_FAILURE, - OPT_RECORD_REMARK, - OPT_RECORD_SCOPE -}; - -extern const char *opt_record_kind_to_string (enum opt_record_kind kind); - // FIXME: maybe make this inline? extern bool optimization_records_enabled_p (); diff --git a/gcc/optinfo.cc b/gcc/optinfo.cc index bb4e999..be2e48b 100644 --- a/gcc/optinfo.cc +++ b/gcc/optinfo.cc @@ -76,6 +76,26 @@ optinfo_location::optinfo_location (struct loop *loop) } } +/* FIXME. */ + +const char * +optinfo_kind_to_string (enum optinfo_kind kind) +{ + switch (kind) + { + default: + gcc_unreachable (); + case OPTINFO_KIND_SUCCESS: + return "success"; + case OPTINFO_KIND_FAILURE: + return "failure"; + case OPTINFO_KIND_REMARK: + return "remark"; + case OPTINFO_KIND_SCOPE: + return "scope"; + } +} + /* optinfo's dtor. */ optinfo::~optinfo () @@ -190,14 +210,14 @@ optinfo::emit_via_fopt_info () const { default: gcc_unreachable (); - case OPT_RECORD_SUCCESS: + case OPTINFO_KIND_SUCCESS: flags = MSG_OPTIMIZED_LOCATIONS; break; - case OPT_RECORD_FAILURE: + case OPTINFO_KIND_FAILURE: flags = MSG_MISSED_OPTIMIZATION; break; - case OPT_RECORD_REMARK: - case OPT_RECORD_SCOPE: + case OPTINFO_KIND_REMARK: + case OPTINFO_KIND_SCOPE: flags = MSG_NOTE; break; } @@ -239,7 +259,7 @@ optinfo::emit_via_fopt_info () const /* pending_optinfo's ctor. */ pending_optinfo::pending_optinfo (const location &impl_location, - enum opt_record_kind kind, + enum optinfo_kind kind, optinfo_location loc) : m_optinfo (new optinfo (impl_location, kind, loc)) { diff --git a/gcc/optinfo.h b/gcc/optinfo.h index d29dcf5..8bc3fa9 100644 --- a/gcc/optinfo.h +++ b/gcc/optinfo.h @@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see #define GCC_OPTINFO_H #include "unique-ptr.h" -#include "optimization-records.h" /* FIXME: this is flexible, but probably inefficient. */ @@ -204,19 +203,32 @@ struct location /* FIXME. */ +enum optinfo_kind +{ + OPTINFO_KIND_SUCCESS, + OPTINFO_KIND_FAILURE, + OPTINFO_KIND_REMARK, + OPTINFO_KIND_SCOPE +}; + +/* FIXME. */ +extern const char *optinfo_kind_to_string (enum optinfo_kind kind); + +/* FIXME. */ + class optinfo { friend class pending_optinfo; public: optinfo (const location &impl_location, - enum opt_record_kind kind, + enum optinfo_kind kind, optinfo_location loc) : m_impl_location (impl_location), m_kind (kind), m_loc (loc), m_items () {} ~optinfo (); location get_impl_location () const { return m_impl_location; } - enum opt_record_kind get_kind () const { return m_kind; } + enum optinfo_kind get_kind () const { return m_kind; } optinfo_location get_location () const { return m_loc; } unsigned int num_items () const { return m_items.length (); } const optinfo_item *get_item (unsigned int i) const { return m_items[i]; } @@ -229,7 +241,7 @@ class optinfo private: location m_impl_location; - enum opt_record_kind m_kind; + enum optinfo_kind m_kind; optinfo_location m_loc; auto_vec m_items; }; @@ -262,7 +274,7 @@ class pending_optinfo { public: pending_optinfo (const location &impl_location, - enum opt_record_kind kind, + enum optinfo_kind kind, optinfo_location loc); pending_optinfo& operator<< (const char *); @@ -293,12 +305,12 @@ class pending_optinfo /* Emit that a successful optimization happened at LOC. */ #define OPTINFO_SUCCESS(LOC)\ - OPTINFO(OPT_RECORD_SUCCESS, (LOC)) + OPTINFO(OPTINFO_KIND_SUCCESS, (LOC)) /* Emit a remark relating to an optimization at LOC. */ #define OPTINFO_REMARK(LOC)\ - OPTINFO(OPT_RECORD_REMARK, (LOC)) + OPTINFO(OPTINFO_KIND_REMARK, (LOC)) extern void push_optinfo_scope (); extern void pop_optinfo_scope (); @@ -318,7 +330,7 @@ class optinfo_scope { if (optinfo_enabled_p ()) { - pending_optinfo (impl_location, OPT_RECORD_SCOPE, loc) + pending_optinfo (impl_location, OPTINFO_KIND_SCOPE, loc) << optinfo_printf ("=== %s ===", name); push_optinfo_scope (); } diff --git a/gcc/profile.c b/gcc/profile.c index fc8e5aa..725b6ca 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -1356,12 +1356,12 @@ branch_prob (void) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple *stmt = gsi_stmt (gsi); - OPTINFO (OPT_RECORD_REMARK, stmt) + OPTINFO (OPTINFO_KIND_REMARK, stmt) << "test remark"; #if 0 remark (gimple_location (stmt), 0, "test remark; execution count=%li", stmt->bb->count.to_gcov_type ()); - maybe_record_optimization (OPT_RECORD_REMARK, stmt, "test remark"); + maybe_record_optimization (OPTINFO_KIND_REMARK, stmt, "test remark"); #endif #if 0 /* Expected number of executions: calculated in profile.c. */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 9fcc7d6..b0cf33c 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -166,7 +166,7 @@ bool optinfo_enabled_p () pending_optinfo emit_optinfo_at_vect_location (const location &impl_location, - enum opt_record_kind kind) + enum optinfo_kind kind) { return pending_optinfo (impl_location, kind, vect_location_thing); } diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 206f0f3..4b7e946 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1391,22 +1391,22 @@ extern optinfo_location vect_location_thing; extern pending_optinfo emit_optinfo_at_vect_location (const location &impl_location, - enum opt_record_kind kind); + enum optinfo_kind kind); /* Emit that a successful optimization happened at the vect location. */ #define OPTINFO_VECT_SUCCESS \ - (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPT_RECORD_SUCCESS)) + (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_SUCCESS)) /* Emit that a failed optimization happened at the vect location. */ #define OPTINFO_VECT_FAILURE \ - (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPT_RECORD_FAILURE)) + (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_FAILURE)) /* Emit a remark relating to an optimization at the vect location. */ #define OPTINFO_VECT_REMARK \ - (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPT_RECORD_REMARK)) + (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_REMARK)) /* FIXME. */ -- 1.8.5.3