domwalk.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Generic dominator tree walker
  2. Copyright (C) 2003-2015 Free Software Foundation, Inc.
  3. Contributed by Diego Novillo <dnovillo@redhat.com>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GCC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_DOM_WALK_H
  17. #define GCC_DOM_WALK_H
  18. /**
  19. * This is the main class for the dominator walker. It is expected that
  20. * consumers will have a custom class inheriting from it, which will over ride
  21. * at least one of before_dom_children and after_dom_children to implement the
  22. * custom behavior.
  23. */
  24. class dom_walker
  25. {
  26. public:
  27. dom_walker (cdi_direction direction) : m_dom_direction (direction) {}
  28. /* Walk the dominator tree. */
  29. void walk (basic_block);
  30. /* Function to call before the recursive walk of the dominator children. */
  31. virtual void before_dom_children (basic_block) {}
  32. /* Function to call after the recursive walk of the dominator children. */
  33. virtual void after_dom_children (basic_block) {}
  34. private:
  35. /* This is the direction of the dominator tree we want to walk. i.e.,
  36. if it is set to CDI_DOMINATORS, then we walk the dominator tree,
  37. if it is set to CDI_POST_DOMINATORS, then we walk the post
  38. dominator tree. */
  39. const ENUM_BITFIELD (cdi_direction) m_dom_direction : 2;
  40. };
  41. #endif