gimple-match.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Gimple simplify definitions.
  2. Copyright (C) 2011-2018 Free Software Foundation, Inc.
  3. Contributed by Richard Guenther <rguenther@suse.de>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. 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_GIMPLE_MATCH_H
  17. #define GCC_GIMPLE_MATCH_H
  18. /* Helper to transparently allow tree codes and builtin function codes
  19. exist in one storage entity. */
  20. class code_helper
  21. {
  22. public:
  23. code_helper () {}
  24. code_helper (tree_code code) : rep ((int) code) {}
  25. code_helper (combined_fn fn) : rep (-(int) fn) {}
  26. operator tree_code () const { return (tree_code) rep; }
  27. operator combined_fn () const { return (combined_fn) -rep; }
  28. bool is_tree_code () const { return rep > 0; }
  29. bool is_fn_code () const { return rep < 0; }
  30. int get_rep () const { return rep; }
  31. private:
  32. int rep;
  33. };
  34. /* Return whether OPS[0] with CODE is a non-expression result and
  35. a gimple value. */
  36. inline bool
  37. gimple_simplified_result_is_gimple_val (code_helper code, tree *ops)
  38. {
  39. return (code.is_tree_code ()
  40. && (TREE_CODE_LENGTH ((tree_code) code) == 0
  41. || ((tree_code) code) == ADDR_EXPR)
  42. && is_gimple_val (ops[0]));
  43. }
  44. extern tree (*mprts_hook) (code_helper, tree, tree *);
  45. bool gimple_simplify (gimple *, code_helper *, tree *, gimple_seq *,
  46. tree (*)(tree), tree (*)(tree));
  47. bool gimple_resimplify1 (gimple_seq *, code_helper *, tree, tree *,
  48. tree (*)(tree));
  49. bool gimple_resimplify2 (gimple_seq *, code_helper *, tree, tree *,
  50. tree (*)(tree));
  51. bool gimple_resimplify3 (gimple_seq *, code_helper *, tree, tree *,
  52. tree (*)(tree));
  53. tree maybe_push_res_to_seq (code_helper, tree, tree *,
  54. gimple_seq *, tree res = NULL_TREE);
  55. void maybe_build_generic_op (enum tree_code, tree, tree *);
  56. #endif /* GCC_GIMPLE_MATCH_H */