void
verify_item (const location &loc,
const optinfo_item *item,
- enum optinfo_item_kind expected_kind,
+ enum optinfo_item::kind expected_kind,
location_t expected_location,
const char *expected_text);
#define ASSERT_IS_TEXT(ITEM, EXPECTED_TEXT) \
SELFTEST_BEGIN_STMT \
- verify_item (SELFTEST_LOCATION, (ITEM), OPTINFO_ITEM_KIND_TEXT, \
+ verify_item (SELFTEST_LOCATION, (ITEM), optinfo_item::kind::text, \
UNKNOWN_LOCATION, (EXPECTED_TEXT)); \
SELFTEST_END_STMT
#define ASSERT_IS_TREE(ITEM, EXPECTED_LOCATION, EXPECTED_TEXT) \
SELFTEST_BEGIN_STMT \
- verify_item (SELFTEST_LOCATION, (ITEM), OPTINFO_ITEM_KIND_TREE, \
+ verify_item (SELFTEST_LOCATION, (ITEM), optinfo_item::kind::tree, \
(EXPECTED_LOCATION), (EXPECTED_TEXT)); \
SELFTEST_END_STMT
#define ASSERT_IS_GIMPLE(ITEM, EXPECTED_LOCATION, EXPECTED_TEXT) \
SELFTEST_BEGIN_STMT \
- verify_item (SELFTEST_LOCATION, (ITEM), OPTINFO_ITEM_KIND_GIMPLE, \
+ verify_item (SELFTEST_LOCATION, (ITEM), optinfo_item::kind::gimple, \
(EXPECTED_LOCATION), (EXPECTED_TEXT)); \
SELFTEST_END_STMT
#define ASSERT_IS_SYMTAB_NODE(ITEM, EXPECTED_LOCATION, EXPECTED_TEXT) \
SELFTEST_BEGIN_STMT \
- verify_item (SELFTEST_LOCATION, (ITEM), OPTINFO_ITEM_KIND_SYMTAB_NODE, \
+ verify_item (SELFTEST_LOCATION, (ITEM), optinfo_item::kind::symtab_node, \
(EXPECTED_LOCATION), (EXPECTED_TEXT)); \
SELFTEST_END_STMT
pp_gimple_stmt_1 (&pp, stmt, spc, dump_flags);
pp_newline (&pp);
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_GIMPLE,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::gimple,
gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
return item;
pp_needs_newline (&pp) = true;
pp_gimple_stmt_1 (&pp, stmt, spc, dump_flags);
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_GIMPLE,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::gimple,
gimple_location (stmt),
xstrdup (pp_formatted_text (&pp)));
return item;
if (EXPR_HAS_LOCATION (node))
loc = EXPR_LOCATION (node);
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TREE, loc,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::tree, loc,
xstrdup (pp_formatted_text (&pp)));
return item;
}
make_item_for_dump_symtab_node (symtab_node *node)
{
location_t loc = DECL_SOURCE_LOCATION (node->decl);
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_SYMTAB_NODE, loc,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::symtab_node, loc,
xstrdup (node->dump_name ()));
return item;
}
return;
char *formatted_text = xstrdup (pp_formatted_text (pp));
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::text,
+ UNKNOWN_LOCATION,
formatted_text);
pp->emit_item (std::move (item), m_optinfo);
}
auto item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
+ = std::make_unique<optinfo_item> (optinfo_item::kind::text,
+ UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
return item;
}
pretty_printer pp;
pp_printf (&pp, "%s %s %s", "===", name, "===");
pp_newline (&pp);
- std::unique_ptr<optinfo_item> item
- = std::make_unique<optinfo_item> (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
+ auto item
+ = std::make_unique<optinfo_item> (optinfo_item::kind::text,
+ UNKNOWN_LOCATION,
xstrdup (pp_formatted_text (&pp)));
emit_item (*item.get (), MSG_NOTE);
optinfo &info
= begin_next_optinfo (dump_metadata_t (MSG_NOTE, impl_location),
user_location);
- info.m_kind = OPTINFO_KIND_SCOPE;
+ info.m_kind = optinfo::kind::scope;
info.add_item (std::move (item));
end_any_optinfo ();
}
end_any_optinfo ();
gcc_assert (m_pending == NULL);
dump_location_t loc (user_loc, metadata.get_impl_location ());
- m_pending = new optinfo (loc, OPTINFO_KIND_NOTE, current_pass);
+ m_pending = new optinfo (loc, optinfo::kind::note, current_pass);
m_pending->handle_dump_file_kind (metadata.get_dump_flags ());
return *m_pending;
}
void
verify_item (const location &loc,
const optinfo_item *item,
- enum optinfo_item_kind expected_kind,
+ enum optinfo_item::kind expected_kind,
location_t expected_location,
const char *expected_text)
{
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 1);
ASSERT_IS_TEXT (info->get_item (0), "int: 42 str: foo");
ASSERT_IMPL_LOCATION_EQ (info->get_impl_location (),
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 2);
ASSERT_IS_TEXT (info->get_item (0), "tree: ");
ASSERT_IS_TREE (info->get_item (1), UNKNOWN_LOCATION, "0");
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 2);
ASSERT_IS_TEXT (info->get_item (0), "gimple: ");
ASSERT_IS_GIMPLE (info->get_item (1), stmt_loc, "return;");
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 2);
ASSERT_IS_TEXT (info->get_item (0), "gimple: ");
ASSERT_IS_GIMPLE (info->get_item (1), stmt_loc, "return;\n");
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 2);
ASSERT_IS_TEXT (info->get_item (0), "node: ");
ASSERT_IS_SYMTAB_NODE (info->get_item (1), decl_loc, "test_decl/1");
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 8);
ASSERT_IS_TEXT (info->get_item (0), "before ");
ASSERT_IS_TREE (info->get_item (1), UNKNOWN_LOCATION, "0");
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
ASSERT_EQ (info->get_location_t (), stmt_loc);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 2);
ASSERT_IS_TEXT (info->get_item (0), "test of tree: ");
ASSERT_IS_TREE (info->get_item (1), UNKNOWN_LOCATION, "0");
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
ASSERT_EQ (info->get_location_t (), stmt_loc);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 1);
ASSERT_IS_TREE (info->get_item (0), UNKNOWN_LOCATION, "1");
ASSERT_IMPL_LOCATION_EQ (info->get_impl_location (),
{
optinfo *info = tmp.get_pending_optinfo ();
ASSERT_TRUE (info != NULL);
- ASSERT_EQ (info->get_kind (), OPTINFO_KIND_NOTE);
+ ASSERT_EQ (info->get_kind (), optinfo::kind::note);
ASSERT_EQ (info->num_items (), 1);
ASSERT_IS_SYMTAB_NODE (info->get_item (0), decl_loc, "test_decl/1");
ASSERT_IMPL_LOCATION_EQ (info->get_impl_location (),
temp_dump_context tmp (true, true, MSG_ALL_KINDS);
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, "test");
ASSERT_EQ (tmp.get_pending_optinfo ()->get_kind (),
- OPTINFO_KIND_SUCCESS);
+ optinfo::kind::success);
}
/* MSG_MISSED_OPTIMIZATION. */
temp_dump_context tmp (true, true, MSG_ALL_KINDS);
dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, "test");
ASSERT_EQ (tmp.get_pending_optinfo ()->get_kind (),
- OPTINFO_KIND_FAILURE);
+ optinfo::kind::failure);
}
}
/* optinfo_item's ctor. Takes ownership of TEXT. */
-optinfo_item::optinfo_item (enum optinfo_item_kind kind, location_t location,
+optinfo_item::optinfo_item (enum kind kind_, location_t location,
char *text)
-: m_kind (kind), m_location (location), m_text (text)
+: m_kind (kind_), m_location (location), m_text (text)
{
}
/* Get a string from KIND. */
const char *
-optinfo_kind_to_string (enum optinfo_kind kind)
+optinfo::kind_to_string (enum kind kind_)
{
- switch (kind)
+ switch (kind_)
{
default:
gcc_unreachable ();
- case OPTINFO_KIND_SUCCESS:
+ case kind::success:
return "success";
- case OPTINFO_KIND_FAILURE:
+ case kind::failure:
return "failure";
- case OPTINFO_KIND_NOTE:
+ case kind::note:
return "note";
- case OPTINFO_KIND_SCOPE:
+ case kind::scope:
return "scope";
}
}
/* Get MSG_* flags corresponding to KIND. */
-static dump_flags_t
-optinfo_kind_to_dump_flag (enum optinfo_kind kind)
+dump_flags_t
+optinfo::kind_to_dump_flag (enum kind kind_)
{
- switch (kind)
+ switch (kind_)
{
default:
gcc_unreachable ();
- case OPTINFO_KIND_SUCCESS:
+ case kind::success:
return MSG_OPTIMIZED_LOCATIONS;
- case OPTINFO_KIND_FAILURE:
+ case kind::failure:
return MSG_MISSED_OPTIMIZATION;
- case OPTINFO_KIND_NOTE:
- case OPTINFO_KIND_SCOPE:
+ case kind::note:
+ case kind::scope:
return MSG_NOTE;
}
}
void
optinfo::emit_for_opt_problem () const
{
- dump_flags_t dump_kind = optinfo_kind_to_dump_flag (get_kind ());
+ dump_flags_t dump_kind = kind_to_dump_flag (get_kind ());
dump_kind |= MSG_PRIORITY_REEMITTED;
/* Re-emit to "immediate" destinations, without creating a new optinfo. */
optinfo::handle_dump_file_kind (dump_flags_t dump_kind)
{
/* Any optinfo for a "scope" should have been emitted separately. */
- gcc_assert (m_kind != OPTINFO_KIND_SCOPE);
+ gcc_assert (m_kind != kind::scope);
if (dump_kind & MSG_OPTIMIZED_LOCATIONS)
- m_kind = OPTINFO_KIND_SUCCESS;
+ m_kind = kind::success;
else if (dump_kind & MSG_MISSED_OPTIMIZATION)
- m_kind = OPTINFO_KIND_FAILURE;
+ m_kind = kind::failure;
else if (dump_kind & MSG_NOTE)
- m_kind = OPTINFO_KIND_NOTE;
+ m_kind = kind::note;
}
/* Return true if any of the active optinfo destinations make use
extern bool optinfo_wants_inlining_info_p ();
-/* The various kinds of optinfo. */
-
-enum optinfo_kind
-{
- OPTINFO_KIND_SUCCESS,
- OPTINFO_KIND_FAILURE,
- OPTINFO_KIND_NOTE,
- OPTINFO_KIND_SCOPE
-};
-
-extern const char *optinfo_kind_to_string (enum optinfo_kind kind);
-
class dump_context;
/* A bundle of information describing part of an optimization. */
friend class dump_context;
public:
+ /* The various kinds of optinfo. */
+ enum class kind
+ {
+ success,
+ failure,
+ note,
+ scope
+ };
+
optinfo (const dump_location_t &loc,
- enum optinfo_kind kind,
+ enum kind kind_,
opt_pass *pass)
- : m_loc (loc), m_kind (kind), m_pass (pass), m_items ()
+ : m_loc (loc), m_kind (kind_), m_pass (pass), m_items ()
{}
~optinfo ();
const dump_impl_location_t &
get_impl_location () const { return m_loc.get_impl_location (); }
- enum optinfo_kind get_kind () const { return m_kind; }
+ enum kind get_kind () const { return m_kind; }
opt_pass *get_pass () const { return m_pass; }
unsigned int num_items () const { return m_items.length (); }
const optinfo_item *get_item (unsigned int i) const { return m_items[i]; }
void emit_for_opt_problem () const;
+ static const char *kind_to_string (enum kind k);
+ static dump_flags_t kind_to_dump_flag (enum kind k);
+
private:
/* Pre-canned ways of manipulating the optinfo, for use by friend class
dump_context. */
private:
dump_location_t m_loc;
- enum optinfo_kind m_kind;
+ enum kind m_kind;
opt_pass *m_pass;
auto_vec <optinfo_item *> m_items;
};
-/* An enum for discriminating between different kinds of optinfo_item. */
-
-enum optinfo_item_kind
-{
- OPTINFO_ITEM_KIND_TEXT,
- OPTINFO_ITEM_KIND_TREE,
- OPTINFO_ITEM_KIND_GIMPLE,
- OPTINFO_ITEM_KIND_SYMTAB_NODE
-};
-
/* An item within an optinfo. */
class optinfo_item
{
public:
- optinfo_item (enum optinfo_item_kind kind, location_t location,
+ /* An enum for discriminating between different kinds of optinfo_item. */
+ enum class kind
+ {
+ text,
+ tree,
+ gimple,
+ symtab_node
+ };
+
+ optinfo_item (enum kind kind_, location_t location,
char *text);
~optinfo_item ();
- enum optinfo_item_kind get_kind () const { return m_kind; }
+ enum kind get_kind () const { return m_kind; }
location_t get_location () const { return m_location; }
const char *get_text () const { return m_text; }
private:
/* Metadata (e.g. for optimization records). */
- enum optinfo_item_kind m_kind;
+ enum kind m_kind;
location_t m_location;
/* The textual form of the item, owned by the item. */