gimplify.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Header file for gimplification.
  2. Copyright (C) 2013-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_GIMPLIFY_H
  16. #define GCC_GIMPLIFY_H
  17. /* Validation of GIMPLE expressions. Note that these predicates only check
  18. the basic form of the expression, they don't recurse to make sure that
  19. underlying nodes are also of the right form. */
  20. typedef bool (*gimple_predicate)(tree);
  21. /* FIXME we should deduce this from the predicate. */
  22. enum fallback {
  23. fb_none = 0, /* Do not generate a temporary. */
  24. fb_rvalue = 1, /* Generate an rvalue to hold the result of a
  25. gimplified expression. */
  26. fb_lvalue = 2, /* Generate an lvalue to hold the result of a
  27. gimplified expression. */
  28. fb_mayfail = 4, /* Gimplification may fail. Error issued
  29. afterwards. */
  30. fb_either= fb_rvalue | fb_lvalue
  31. };
  32. typedef int fallback_t;
  33. enum gimplify_status {
  34. GS_ERROR = -2, /* Something Bad Seen. */
  35. GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
  36. GS_OK = 0, /* We did something, maybe more to do. */
  37. GS_ALL_DONE = 1 /* The expression is fully gimplified. */
  38. };
  39. extern void free_gimplify_stack (void);
  40. extern void push_gimplify_context (bool in_ssa = false,
  41. bool rhs_cond_ok = false);
  42. extern void pop_gimplify_context (gimple);
  43. extern gbind *gimple_current_bind_expr (void);
  44. extern vec<gbind *> gimple_bind_expr_stack (void);
  45. extern void gimplify_and_add (tree, gimple_seq *);
  46. extern tree get_formal_tmp_var (tree, gimple_seq *);
  47. extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
  48. extern void declare_vars (tree, gimple, bool);
  49. extern void gimple_add_tmp_var (tree);
  50. extern void gimple_add_tmp_var_fn (struct function *, tree);
  51. extern tree unshare_expr (tree);
  52. extern tree unshare_expr_without_location (tree);
  53. extern tree voidify_wrapper_expr (tree, tree);
  54. extern tree build_and_jump (tree *);
  55. extern enum gimplify_status gimplify_self_mod_expr (tree *, gimple_seq *,
  56. gimple_seq *, bool, tree);
  57. extern tree gimple_boolify (tree);
  58. extern gimple_predicate rhs_predicate_for (tree);
  59. extern bool gimplify_stmt (tree *, gimple_seq *);
  60. extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
  61. extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
  62. bool (*) (tree), fallback_t);
  63. extern void gimplify_type_sizes (tree, gimple_seq *);
  64. extern void gimplify_one_sizepos (tree *, gimple_seq *);
  65. extern gbind *gimplify_body (tree, bool);
  66. extern enum gimplify_status gimplify_arg (tree *, gimple_seq *, location_t);
  67. extern void gimplify_function_tree (tree);
  68. extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
  69. gimple_seq *);
  70. gimple gimplify_assign (tree, tree, gimple_seq *);
  71. /* Return true if gimplify_one_sizepos doesn't need to gimplify
  72. expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
  73. fields). */
  74. static inline bool
  75. is_gimple_sizepos (tree expr)
  76. {
  77. /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
  78. is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
  79. anything if it's already a VAR_DECL. If it's a VAR_DECL from another
  80. function, the gimplifier will want to replace it with a new variable,
  81. but that will cause problems if this type is from outside the function.
  82. It's OK to have that here. */
  83. return (expr == NULL_TREE
  84. || TREE_CONSTANT (expr)
  85. || TREE_CODE (expr) == VAR_DECL
  86. || CONTAINS_PLACEHOLDER_P (expr));
  87. }
  88. #endif /* GCC_GIMPLIFY_H */