From 9eca94fcd011d190eb478dbd9ab3174c5e5510b7 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 8 Jun 2018 10:49:25 -0400
Subject: [PATCH 18/46] FIXME: convert pass properties and todos to enum flags

---
 gcc/ipa-fnsummary.c |   2 +-
 gcc/tree-pass.h     | 263 ++++++++++++++++++++++++++++++----------------------
 2 files changed, 151 insertions(+), 114 deletions(-)

diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index c99718a..50b8164 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -3567,7 +3567,7 @@ public:
       /* Early optimizations may make function unreachable.  We can not
 	 remove unreachable functions as part of the early opts pass because
 	 TODOs are run before subpasses.  Do it here.  */
-      return small_p ? TODO_remove_functions | TODO_dump_symtab : 0;
+      return small_p ? TODO_remove_functions | TODO_dump_symtab : pass_todos_t (0);
     }
 
 private:
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index af15adc..b52c72c 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -36,6 +36,151 @@ enum opt_pass_type
   IPA_PASS
 };
 
+/* Pass properties.  */
+
+enum pass_properties
+{
+  /* entire gimple grammar */
+  PROP_gimple_any = (1 << 0),
+
+  /* lowered control flow */
+  PROP_gimple_lcf = (1 << 1),
+
+  /* lowered eh */
+  PROP_gimple_leh = (1 << 2),
+
+  PROP_cfg = (1 << 3),
+  PROP_ssa = (1 << 5),
+  PROP_no_crit_edges = (1 << 6),
+  PROP_rtl = (1 << 7),
+
+  /* lowered OpenMP directives */
+  PROP_gimple_lomp = (1 << 8),
+
+  /* cfglayout mode on RTL */
+  PROP_cfglayout = (1 << 9),
+
+  /* lowered complex */
+  PROP_gimple_lcx = (1 << 10),
+
+  /* preserve loop structures */
+  PROP_loops = (1 << 11),
+
+  /* lowered vector */
+  PROP_gimple_lvec = (1 << 12),
+
+  /* no OpenMP directives */
+  PROP_gimple_eomp = (1 << 13),
+
+  /* No va_arg internal function.  */
+  PROP_gimple_lva = (1 << 14),
+
+  /* Disable canonicalization of math functions; the current choices have
+     been optimized.  */
+  PROP_gimple_opt_math = (1 << 15),
+
+  /* done omp_device_lower */
+  PROP_gimple_lomp_dev = (1 << 16),
+
+  /* RTL has insns split.  */
+  PROP_rtl_split_insns = (1 << 17),
+
+  PROP_trees = (PROP_gimple_any
+		| PROP_gimple_lcf
+		| PROP_gimple_leh
+		| PROP_gimple_lomp)
+};
+
+/* Pass properties bitmask type.  */
+DEF_ENUM_FLAGS_TYPE(enum pass_properties, pass_properties_t);
+
+/* To-do flags.  */
+enum pass_todos
+{
+  TODO_do_not_ggc_collect = (1 << 1),
+  TODO_cleanup_cfg = (1 << 5),
+  TODO_verify_il = (1 << 6),
+  TODO_dump_symtab = (1 << 7),
+  TODO_remove_functions = (1 << 8),
+  TODO_rebuild_frequencies = (1 << 9),
+
+  /* To-do flags for calls to update_ssa.  */
+
+  /* Update the SSA form inserting PHI nodes for newly exposed symbols
+     and virtual names marked for updating.  When updating real names,
+     only insert PHI nodes for a real name O_j in blocks reached by all
+     the new and old definitions for O_j.  If the iterated dominance
+     frontier for O_j is not pruned, we may end up inserting PHI nodes
+     in blocks that have one or more edges with no incoming definition
+     for O_j.  This would lead to uninitialized warnings for O_j's
+     symbol.  */
+  TODO_update_ssa = (1 << 11),
+
+  /* Update the SSA form without inserting any new PHI nodes at all.
+     This is used by passes that have either inserted all the PHI nodes
+     themselves or passes that need only to patch use-def and def-def
+     chains for virtuals (e.g., DCE).  */
+  TODO_update_ssa_no_phi = (1 << 12),
+
+  /* Insert PHI nodes everywhere they are needed.  No pruning of the
+     IDF is done.  This is used by passes that need the PHI nodes for
+     O_j even if it means that some arguments will come from the default
+     definition of O_j's symbol.
+
+     WARNING: If you need to use this flag, chances are that your pass
+     may be doing something wrong.  Inserting PHI nodes for an old name
+     where not all edges carry a new replacement may lead to silent
+     codegen errors or spurious uninitialized warnings.  */
+  TODO_update_ssa_full_phi = (1 << 13),
+
+  /* Passes that update the SSA form on their own may want to delegate
+     the updating of virtual names to the generic updater.  Since FUD
+     chains are easier to maintain, this simplifies the work they need
+     to do.  NOTE: If this flag is used, any OLD->NEW mappings for real
+     names are explicitly destroyed and only the symbols marked for
+     renaming are processed.  */
+  TODO_update_ssa_only_virtuals = (1 << 14),
+
+  /* Some passes leave unused local variables that can be removed from
+     cfun->local_decls.  This reduces the size of dump files
+     and the memory footprint for VAR_DECLs.  */
+  TODO_remove_unused_locals = (1 << 15),
+
+  /* Call df_finish at the end of the pass.  This is done after all of
+     the dumpers have been allowed to run so that they have access to
+     the instance before it is destroyed.  */
+  TODO_df_finish = (1 << 17),
+
+  /* Call df_verify at the end of the pass if checking is enabled.  */
+  TODO_df_verify = (1 << 18),
+
+  /* Internally used for the first instance of a pass.  */
+  TODO_mark_first_instance = (1 << 19),
+
+  /* Rebuild aliasing info.  */
+  TODO_rebuild_alias = (1 << 20),
+
+  /* Rebuild the addressable-vars bitmap and do register promotion.  */
+  TODO_update_address_taken = (1 << 21),
+
+  /* Rebuild the callgraph edges.  */
+  TODO_rebuild_cgraph_edges = (1 << 22),
+
+  /* Release function body and stop pass manager.  */
+  TODO_discard_function = (1 << 23),
+
+  /* Internally used in execute_function_todo().  */
+  TODO_update_ssa_any = (TODO_update_ssa
+			 | TODO_update_ssa_no_phi
+			 | TODO_update_ssa_full_phi
+			 | TODO_update_ssa_only_virtuals),
+
+  TODO_verify_all = TODO_verify_il
+};
+
+/* Pass TODOs bitmask type.  */
+DEF_ENUM_FLAGS_TYPE(enum pass_todos, pass_todos_t);
+
 /* Metadata for a pass, non-varying across all instances of a pass.  */
 struct pass_data
 {
@@ -54,13 +199,13 @@ struct pass_data
   timevar_id_t tv_id;
 
   /* Sets of properties input and output from this pass.  */
-  unsigned int properties_required;
-  unsigned int properties_provided;
-  unsigned int properties_destroyed;
+  pass_properties_t properties_required;
+  pass_properties_t properties_provided;
+  pass_properties_t properties_destroyed;
 
   /* Flags indicating common sets things to do before and after.  */
-  unsigned int todo_flags_start;
-  unsigned int todo_flags_finish;
+  pass_todos_t todo_flags_start;
+  pass_todos_t todo_flags_finish;
 };
 
 namespace gcc
@@ -203,114 +348,6 @@ protected:
   }
 };
 
-/* Pass properties.  */
-#define PROP_gimple_any		(1 << 0)	/* entire gimple grammar */
-#define PROP_gimple_lcf		(1 << 1)	/* lowered control flow */
-#define PROP_gimple_leh		(1 << 2)	/* lowered eh */
-#define PROP_cfg		(1 << 3)
-#define PROP_ssa		(1 << 5)
-#define PROP_no_crit_edges      (1 << 6)
-#define PROP_rtl		(1 << 7)
-#define PROP_gimple_lomp	(1 << 8)	/* lowered OpenMP directives */
-#define PROP_cfglayout	 	(1 << 9)	/* cfglayout mode on RTL */
-#define PROP_gimple_lcx		(1 << 10)       /* lowered complex */
-#define PROP_loops		(1 << 11)	/* preserve loop structures */
-#define PROP_gimple_lvec	(1 << 12)       /* lowered vector */
-#define PROP_gimple_eomp	(1 << 13)       /* no OpenMP directives */
-#define PROP_gimple_lva		(1 << 14)       /* No va_arg internal function.  */
-#define PROP_gimple_opt_math	(1 << 15)	/* Disable canonicalization
-						   of math functions; the
-						   current choices have
-						   been optimized.  */
-#define PROP_gimple_lomp_dev	(1 << 16)	/* done omp_device_lower */
-#define PROP_rtl_split_insns	(1 << 17)	/* RTL has insns split.  */
-
-#define PROP_trees \
-  (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_lomp)
-
-/* To-do flags.  */
-#define TODO_do_not_ggc_collect		(1 << 1)
-#define TODO_cleanup_cfg        	(1 << 5)
-#define TODO_verify_il			(1 << 6)
-#define TODO_dump_symtab		(1 << 7)
-#define TODO_remove_functions		(1 << 8)
-#define TODO_rebuild_frequencies	(1 << 9)
-
-/* To-do flags for calls to update_ssa.  */
-
-/* Update the SSA form inserting PHI nodes for newly exposed symbols
-   and virtual names marked for updating.  When updating real names,
-   only insert PHI nodes for a real name O_j in blocks reached by all
-   the new and old definitions for O_j.  If the iterated dominance
-   frontier for O_j is not pruned, we may end up inserting PHI nodes
-   in blocks that have one or more edges with no incoming definition
-   for O_j.  This would lead to uninitialized warnings for O_j's
-   symbol.  */
-#define TODO_update_ssa			(1 << 11)
-
-/* Update the SSA form without inserting any new PHI nodes at all.
-   This is used by passes that have either inserted all the PHI nodes
-   themselves or passes that need only to patch use-def and def-def
-   chains for virtuals (e.g., DCE).  */
-#define TODO_update_ssa_no_phi		(1 << 12)
-
-/* Insert PHI nodes everywhere they are needed.  No pruning of the
-   IDF is done.  This is used by passes that need the PHI nodes for
-   O_j even if it means that some arguments will come from the default
-   definition of O_j's symbol.
-
-   WARNING: If you need to use this flag, chances are that your pass
-   may be doing something wrong.  Inserting PHI nodes for an old name
-   where not all edges carry a new replacement may lead to silent
-   codegen errors or spurious uninitialized warnings.  */
-#define TODO_update_ssa_full_phi	(1 << 13)
-
-/* Passes that update the SSA form on their own may want to delegate
-   the updating of virtual names to the generic updater.  Since FUD
-   chains are easier to maintain, this simplifies the work they need
-   to do.  NOTE: If this flag is used, any OLD->NEW mappings for real
-   names are explicitly destroyed and only the symbols marked for
-   renaming are processed.  */
-#define TODO_update_ssa_only_virtuals	(1 << 14)
-
-/* Some passes leave unused local variables that can be removed from
-   cfun->local_decls.  This reduces the size of dump files
-   and the memory footprint for VAR_DECLs.  */
-#define TODO_remove_unused_locals	(1 << 15)
-
-/* Call df_finish at the end of the pass.  This is done after all of
-   the dumpers have been allowed to run so that they have access to
-   the instance before it is destroyed.  */
-#define TODO_df_finish                  (1 << 17)
-
-/* Call df_verify at the end of the pass if checking is enabled.  */
-#define TODO_df_verify                  (1 << 18)
-
-/* Internally used for the first instance of a pass.  */
-#define TODO_mark_first_instance	(1 << 19)
-
-/* Rebuild aliasing info.  */
-#define TODO_rebuild_alias              (1 << 20)
-
-/* Rebuild the addressable-vars bitmap and do register promotion.  */
-#define TODO_update_address_taken	(1 << 21)
-
-/* Rebuild the callgraph edges.  */
-#define TODO_rebuild_cgraph_edges       (1 << 22)
-
-/* Release function body and stop pass manager.  */
-#define TODO_discard_function		(1 << 23)
-
-/* Internally used in execute_function_todo().  */
-#define TODO_update_ssa_any		\
-    (TODO_update_ssa			\
-     | TODO_update_ssa_no_phi		\
-     | TODO_update_ssa_full_phi		\
-     | TODO_update_ssa_only_virtuals)
-
-#define TODO_verify_all TODO_verify_il
-
-
 /* Register pass info. */
 
 enum pass_positioning_ops
-- 
1.8.5.3

