]>
Commit | Line | Data |
---|---|---|
6de9cd9a | 1 | /* Functions to analyze and validate GIMPLE trees. |
25d8d27d | 2 | Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. |
6de9cd9a DN |
3 | Contributed by Diego Novillo <dnovillo@redhat.com> |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING. If not, write to | |
366ccddb KC |
19 | the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. */ | |
6de9cd9a DN |
21 | |
22 | #ifndef _TREE_SIMPLE_H | |
23 | #define _TREE_SIMPLE_H 1 | |
24 | ||
25 | ||
26 | #include "tree-iterator.h" | |
27 | ||
28 | extern tree create_tmp_var_raw (tree, const char *); | |
7e140280 | 29 | extern tree create_tmp_var_name (const char *); |
6de9cd9a | 30 | extern tree create_tmp_var (tree, const char *); |
6de9cd9a DN |
31 | extern tree get_initialized_tmp_var (tree, tree *, tree *); |
32 | extern tree get_formal_tmp_var (tree, tree *); | |
33 | extern void declare_tmp_vars (tree, tree); | |
34 | ||
6de9cd9a DN |
35 | extern void annotate_all_with_locus (tree *, location_t); |
36 | ||
37 | /* Validation of GIMPLE expressions. Note that these predicates only check | |
38 | the basic form of the expression, they don't recurse to make sure that | |
39 | underlying nodes are also of the right form. */ | |
40 | ||
0c322af3 JM |
41 | typedef bool (*gimple_predicate)(tree); |
42 | ||
6de9cd9a | 43 | /* Returns true iff T is a valid GIMPLE statement. */ |
44de5aeb | 44 | extern bool is_gimple_stmt (tree); |
6de9cd9a DN |
45 | |
46 | /* Returns true iff TYPE is a valid type for a scalar register variable. */ | |
44de5aeb | 47 | extern bool is_gimple_reg_type (tree); |
6de9cd9a | 48 | /* Returns true iff T is a scalar register variable. */ |
44de5aeb | 49 | extern bool is_gimple_reg (tree); |
14797075 | 50 | /* Returns true if T is a GIMPLE temporary variable, false otherwise. */ |
17ad5b5e | 51 | extern bool is_gimple_formal_tmp_var (tree); |
14797075 | 52 | /* Returns true if T is a GIMPLE temporary register variable. */ |
17ad5b5e | 53 | extern bool is_gimple_formal_tmp_reg (tree); |
6de9cd9a | 54 | /* Returns true iff T is any sort of variable. */ |
44de5aeb | 55 | extern bool is_gimple_variable (tree); |
688e936d RH |
56 | /* Returns true iff T is any sort of symbol. */ |
57 | extern bool is_gimple_id (tree); | |
6de9cd9a | 58 | /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */ |
44de5aeb | 59 | extern bool is_gimple_min_lval (tree); |
e847cc68 RH |
60 | /* Returns true iff T is something whose address can be taken. */ |
61 | extern bool is_gimple_addressable (tree); | |
6de9cd9a | 62 | /* Returns true iff T is any valid GIMPLE lvalue. */ |
44de5aeb | 63 | extern bool is_gimple_lvalue (tree); |
6de9cd9a DN |
64 | |
65 | /* Returns true iff T is a GIMPLE restricted function invariant. */ | |
44de5aeb | 66 | extern bool is_gimple_min_invariant (tree); |
6de9cd9a | 67 | /* Returns true iff T is a GIMPLE rvalue. */ |
44de5aeb | 68 | extern bool is_gimple_val (tree); |
e670d9e4 RH |
69 | /* Returns true iff T is a GIMPLE asm statement input. */ |
70 | extern bool is_gimple_asm_val (tree); | |
0c322af3 JM |
71 | /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a |
72 | GIMPLE temporary, a renamed user variable, or something else, | |
73 | respectively. */ | |
17ad5b5e | 74 | extern bool is_gimple_formal_tmp_rhs (tree); |
0c322af3 JM |
75 | extern bool is_gimple_reg_rhs (tree); |
76 | extern bool is_gimple_mem_rhs (tree); | |
77 | /* Returns the appropriate one of the above three predicates for the LHS | |
78 | T. */ | |
79 | extern gimple_predicate rhs_predicate_for (tree); | |
6de9cd9a DN |
80 | |
81 | /* Returns true iff T is a valid if-statement condition. */ | |
44de5aeb | 82 | extern bool is_gimple_condexpr (tree); |
6de9cd9a DN |
83 | |
84 | /* Returns true iff T is a type conversion. */ | |
44de5aeb | 85 | extern bool is_gimple_cast (tree); |
6de9cd9a | 86 | /* Returns true iff T is a variable that does not need to live in memory. */ |
44de5aeb | 87 | extern bool is_gimple_non_addressable (tree t); |
6de9cd9a | 88 | |
0f59171d | 89 | /* Returns true iff T is a valid call address expression. */ |
90051e16 | 90 | extern bool is_gimple_call_addr (tree); |
6de9cd9a | 91 | /* If T makes a function call, returns the CALL_EXPR operand. */ |
44de5aeb | 92 | extern tree get_call_expr_in (tree t); |
6de9cd9a | 93 | |
44de5aeb | 94 | extern void recalculate_side_effects (tree); |
6de9cd9a | 95 | |
6de9cd9a DN |
96 | /* FIXME we should deduce this from the predicate. */ |
97 | typedef enum fallback_t { | |
98 | fb_none = 0, | |
99 | fb_rvalue = 1, | |
100 | fb_lvalue = 2, | |
101 | fb_mayfail = 4, | |
102 | fb_either= fb_rvalue | fb_lvalue | |
103 | } fallback_t; | |
104 | ||
105 | enum gimplify_status { | |
106 | GS_ERROR = -2, /* Something Bad Seen. */ | |
107 | GS_UNHANDLED = -1, /* A langhook result for "I dunno". */ | |
108 | GS_OK = 0, /* We did something, maybe more to do. */ | |
109 | GS_ALL_DONE = 1 /* The expression is fully gimplified. */ | |
110 | }; | |
111 | ||
953ff289 DN |
112 | /* Type of parallel constructs. Used to decide what runtime function |
113 | to use for launching children threads and the gimplification | |
114 | strategy. */ | |
115 | ||
116 | enum omp_parallel_type { | |
117 | IS_NOT_PARALLEL = 0, | |
118 | ||
119 | /* Regular omp parallel */ | |
120 | IS_PARALLEL, | |
121 | ||
122 | /* Combined parallel + workshare (parallel loop and parallel | |
123 | sections). */ | |
124 | IS_COMBINED_PARALLEL | |
125 | }; | |
126 | ||
44de5aeb RK |
127 | extern enum gimplify_status gimplify_expr (tree *, tree *, tree *, |
128 | bool (*) (tree), fallback_t); | |
65355d53 | 129 | extern void gimplify_type_sizes (tree, tree *); |
44de5aeb RK |
130 | extern void gimplify_one_sizepos (tree *, tree *); |
131 | extern void gimplify_stmt (tree *); | |
132 | extern void gimplify_to_stmt_list (tree *); | |
4744afba | 133 | extern void gimplify_body (tree *, tree, bool); |
44de5aeb RK |
134 | extern void push_gimplify_context (void); |
135 | extern void pop_gimplify_context (tree); | |
136 | extern void gimplify_and_add (tree, tree *); | |
6de9cd9a DN |
137 | |
138 | /* Miscellaneous helpers. */ | |
44de5aeb RK |
139 | extern void gimple_add_tmp_var (tree); |
140 | extern tree gimple_current_bind_expr (void); | |
44de5aeb RK |
141 | extern tree voidify_wrapper_expr (tree, tree); |
142 | extern tree gimple_build_eh_filter (tree, tree, tree); | |
143 | extern tree build_and_jump (tree *); | |
144 | extern tree alloc_stmt_list (void); | |
145 | extern void free_stmt_list (tree); | |
146 | extern tree force_labels_r (tree *, int *, void *); | |
147 | extern enum gimplify_status gimplify_va_arg_expr (tree *, tree *, tree *); | |
953ff289 DN |
148 | struct gimplify_omp_ctx; |
149 | extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree); | |
150 | ||
151 | /* In omp-low.c. */ | |
152 | extern tree find_omp_clause (tree, enum tree_code); | |
153 | extern void diagnose_omp_structured_block_errors (tree); | |
154 | extern tree omp_reduction_init (tree, tree); | |
155 | enum omp_parallel_type determine_parallel_type (tree stmt); | |
6de9cd9a DN |
156 | |
157 | /* In tree-nested.c. */ | |
158 | extern void lower_nested_functions (tree); | |
953ff289 DN |
159 | extern void insert_field_into_struct (tree, tree); |
160 | ||
161 | /* Convenience routines to walk all statements of a gimple function. | |
162 | The difference between these walkers and the generic walk_tree is | |
163 | that walk_stmt provides context information to the callback | |
164 | routine to know whether it is currently on the LHS or RHS of an | |
165 | assignment (IS_LHS) or contexts where only GIMPLE values are | |
166 | allowed (VAL_ONLY). | |
167 | ||
168 | This is useful in walkers that need to re-write sub-expressions | |
169 | inside statements while making sure the result is still in GIMPLE | |
170 | form. | |
171 | ||
172 | Note that this is useful exclusively before the code is converted | |
173 | into SSA form. Once the program is in SSA form, the standard | |
174 | operand interface should be used to analyze/modify statements. */ | |
175 | ||
176 | struct walk_stmt_info | |
177 | { | |
178 | /* For each statement, we invoke CALLBACK via walk_tree. The passed | |
179 | data is a walk_stmt_info structure. */ | |
180 | walk_tree_fn callback; | |
181 | ||
182 | /* Points to the current statement being walked. */ | |
183 | tree_stmt_iterator tsi; | |
184 | ||
185 | /* Additional data that CALLBACK may want to carry through the | |
186 | recursion. */ | |
187 | void *info; | |
188 | ||
189 | /* Indicates whether the *TP being examined may be replaced | |
190 | with something that matches is_gimple_val (if true) or something | |
191 | slightly more complicated (if false). "Something" technically | |
192 | means the common subset of is_gimple_lvalue and is_gimple_rhs, | |
193 | but we never try to form anything more complicated than that, so | |
194 | we don't bother checking. | |
195 | ||
196 | Also note that CALLBACK should update this flag while walking the | |
197 | sub-expressions of a statement. For instance, when walking the | |
198 | statement 'foo (&var)', the flag VAL_ONLY will initially be set | |
199 | to true, however, when walking &var, the operand of that | |
200 | ADDR_EXPR does not need to be a GIMPLE value. */ | |
201 | bool val_only; | |
202 | ||
203 | /* True if we are currently walking the LHS of an assignment. */ | |
204 | bool is_lhs; | |
205 | ||
206 | /* Optional. Set to true by CALLBACK if it made any changes. */ | |
207 | bool changed; | |
208 | ||
209 | /* True if we're interested in seeing BIND_EXPRs. */ | |
210 | bool want_bind_expr; | |
211 | ||
212 | /* True if we're interested in seeing RETURN_EXPRs. */ | |
213 | bool want_return_expr; | |
214 | ||
215 | /* True if we're interested in location information. */ | |
216 | bool want_locations; | |
217 | }; | |
218 | ||
219 | void walk_stmts (struct walk_stmt_info *, tree *); | |
6de9cd9a DN |
220 | |
221 | #endif /* _TREE_SIMPLE_H */ |