gcc/c-family/
[official-gcc.git] / gcc / gimplify.h
blob3f7e1b327a9661a6a9cc0500d5078944e6da1b26
1 /* Header file for gimplification.
2 Copyright (C) 2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_GIMPLIFY_H
21 #define GCC_GIMPLIFY_H
23 /* Validation of GIMPLE expressions. Note that these predicates only check
24 the basic form of the expression, they don't recurse to make sure that
25 underlying nodes are also of the right form. */
26 typedef bool (*gimple_predicate)(tree);
28 /* FIXME we should deduce this from the predicate. */
29 enum fallback {
30 fb_none = 0, /* Do not generate a temporary. */
32 fb_rvalue = 1, /* Generate an rvalue to hold the result of a
33 gimplified expression. */
35 fb_lvalue = 2, /* Generate an lvalue to hold the result of a
36 gimplified expression. */
38 fb_mayfail = 4, /* Gimplification may fail. Error issued
39 afterwards. */
40 fb_either= fb_rvalue | fb_lvalue
43 typedef int fallback_t;
45 enum gimplify_status {
46 GS_ERROR = -2, /* Something Bad Seen. */
47 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */
48 GS_OK = 0, /* We did something, maybe more to do. */
49 GS_ALL_DONE = 1 /* The expression is fully gimplified. */
51 /* Gimplify hashtable helper. */
53 struct gimplify_hasher : typed_free_remove <elt_t>
55 typedef elt_t value_type;
56 typedef elt_t compare_type;
57 static inline hashval_t hash (const value_type *);
58 static inline bool equal (const value_type *, const compare_type *);
61 struct gimplify_ctx
63 struct gimplify_ctx *prev_context;
65 vec<gimple> bind_expr_stack;
66 tree temps;
67 gimple_seq conditional_cleanups;
68 tree exit_label;
69 tree return_temp;
71 vec<tree> case_labels;
72 /* The formal temporary table. Should this be persistent? */
73 hash_table <gimplify_hasher> temp_htab;
75 int conditions;
76 bool save_stack;
77 bool into_ssa;
78 bool allow_rhs_cond_expr;
79 bool in_cleanup_point_expr;
82 extern struct gimplify_ctx *gimplify_ctxp;
83 extern void push_gimplify_context (struct gimplify_ctx *);
84 extern void pop_gimplify_context (gimple);
85 extern gimple gimple_current_bind_expr (void);
86 extern vec<gimple> gimple_bind_expr_stack (void);
87 extern void gimplify_and_add (tree, gimple_seq *);
88 extern tree get_formal_tmp_var (tree, gimple_seq *);
89 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
90 extern void declare_vars (tree, gimple, bool);
91 extern void gimple_add_tmp_var (tree);
92 extern tree unshare_expr (tree);
93 extern tree unshare_expr_without_location (tree);
94 extern tree voidify_wrapper_expr (tree, tree);
95 extern tree build_and_jump (tree *);
96 extern enum gimplify_status gimplify_self_mod_expr (tree *, gimple_seq *,
97 gimple_seq *, bool, tree);
98 extern tree gimple_boolify (tree);
99 extern gimple_predicate rhs_predicate_for (tree);
100 extern bool gimplify_stmt (tree *, gimple_seq *);
101 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
102 extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
103 bool (*) (tree), fallback_t);
105 extern void gimplify_type_sizes (tree, gimple_seq *);
106 extern void gimplify_one_sizepos (tree *, gimple_seq *);
107 extern gimple gimplify_body (tree, bool);
108 extern void gimplify_function_tree (tree);
109 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
110 gimple_seq *);
111 gimple gimplify_assign (tree, tree, gimple_seq *);
113 /* Return true if gimplify_one_sizepos doesn't need to gimplify
114 expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
115 fields). */
117 static inline bool
118 is_gimple_sizepos (tree expr)
120 /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
121 is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
122 anything if it's already a VAR_DECL. If it's a VAR_DECL from another
123 function, the gimplifier will want to replace it with a new variable,
124 but that will cause problems if this type is from outside the function.
125 It's OK to have that here. */
126 return (expr == NULL_TREE
127 || TREE_CONSTANT (expr)
128 || TREE_CODE (expr) == VAR_DECL
129 || CONTAINS_PLACEHOLDER_P (expr));
132 #endif /* GCC_GIMPLIFY_H */