OSDN Git Service

* df-problems.c (df_set_note): Avoid C++ keywords.
[pf3gnuchains/gcc-fork.git] / gcc / tree-gimple.h
1 /* Functions to analyze and validate GIMPLE trees.
2    Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
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 3, 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 COPYING3.  If not see
19 <http://www.gnu.org/licenses/>.  */
20
21 #ifndef _TREE_SIMPLE_H
22 #define _TREE_SIMPLE_H 1
23
24
25 #include "tree-iterator.h"
26
27 extern tree create_tmp_var_raw (tree, const char *);
28 extern tree create_tmp_var_name (const char *);
29 extern tree create_tmp_var (tree, const char *);
30 extern tree get_initialized_tmp_var (tree, tree *, tree *);
31 extern tree get_formal_tmp_var (tree, tree *);
32
33 extern void declare_vars (tree, tree, bool);
34
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
41 typedef bool (*gimple_predicate)(tree);
42
43 /* Returns true iff T is a valid GIMPLE statement.  */
44 extern bool is_gimple_stmt (tree);
45
46 /* Returns true iff TYPE is a valid type for a scalar register variable.  */
47 extern bool is_gimple_reg_type (tree);
48 /* Returns true iff T is a scalar register variable.  */
49 extern bool is_gimple_reg (tree);
50 /* Returns true if T is a GIMPLE temporary variable, false otherwise.  */
51 extern bool is_gimple_formal_tmp_var (tree);
52 /* Returns true if T is a GIMPLE temporary register variable.  */
53 extern bool is_gimple_formal_tmp_reg (tree);
54 /* Returns true iff T is any sort of variable.  */
55 extern bool is_gimple_variable (tree);
56 /* Returns true iff T is any sort of symbol.  */
57 extern bool is_gimple_id (tree);
58 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable).  */
59 extern bool is_gimple_min_lval (tree);
60 /* Returns true iff T is something whose address can be taken.  */
61 extern bool is_gimple_addressable (tree);
62 /* Returns true iff T is any valid GIMPLE lvalue.  */
63 extern bool is_gimple_lvalue (tree);
64
65 /* Returns true iff T is a GIMPLE address.  */
66 bool is_gimple_address (const_tree);
67 /* Returns true iff T is a GIMPLE invariant address.  */
68 bool is_gimple_invariant_address (const_tree);
69 /* Returns true iff T is a valid GIMPLE constant.  */
70 bool is_gimple_constant (const_tree);
71 /* Returns true iff T is a GIMPLE restricted function invariant.  */
72 extern bool is_gimple_min_invariant (const_tree);
73 /* Returns true iff T is a GIMPLE rvalue.  */
74 extern bool is_gimple_val (tree);
75 /* Returns true iff T is a GIMPLE asm statement input.  */
76 extern bool is_gimple_asm_val (tree);
77 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
78    GIMPLE temporary, a renamed user variable, or something else,
79    respectively.  */
80 extern bool is_gimple_formal_tmp_rhs (tree);
81 extern bool is_gimple_reg_rhs (tree);
82 extern bool is_gimple_mem_rhs (tree);
83 /* Returns the appropriate one of the above three predicates for the LHS
84    T.  */
85 extern gimple_predicate rhs_predicate_for (tree);
86
87 /* Returns true iff T is a valid if-statement condition.  */
88 extern bool is_gimple_condexpr (tree);
89
90 /* Returns true iff T is a type conversion.  */
91 extern bool is_gimple_cast (tree);
92 /* Returns true iff T is a variable that does not need to live in memory.  */
93 extern bool is_gimple_non_addressable (tree t);
94
95 /* Returns true iff T is a valid call address expression.  */
96 extern bool is_gimple_call_addr (tree);
97 /* If T makes a function call, returns the CALL_EXPR operand.  */
98 extern tree get_call_expr_in (tree t);
99 /* Returns true iff T contains a CALL_EXPR not suitable for inlining.  */
100 #define CALL_STMT_CANNOT_INLINE_P(T) \
101   CALL_CANNOT_INLINE_P (get_call_expr_in (T))
102
103 extern void recalculate_side_effects (tree);
104
105 /* FIXME we should deduce this from the predicate.  */
106 typedef enum fallback_t {
107   fb_none = 0,
108   fb_rvalue = 1,
109   fb_lvalue = 2,
110   fb_mayfail = 4,
111   fb_either= fb_rvalue | fb_lvalue
112 } fallback_t;
113
114 enum gimplify_status {
115   GS_ERROR      = -2,   /* Something Bad Seen.  */
116   GS_UNHANDLED  = -1,   /* A langhook result for "I dunno".  */
117   GS_OK         = 0,    /* We did something, maybe more to do.  */
118   GS_ALL_DONE   = 1     /* The expression is fully gimplified.  */
119 };
120
121 struct gimplify_ctx
122 {
123   struct gimplify_ctx *prev_context;
124
125   tree current_bind_expr;
126   tree temps;
127   tree conditional_cleanups;
128   tree exit_label;
129   tree return_temp;
130   
131   VEC(tree,heap) *case_labels;
132   /* The formal temporary table.  Should this be persistent?  */
133   htab_t temp_htab;
134
135   int conditions;
136   bool save_stack;
137   bool into_ssa;
138   bool allow_rhs_cond_expr;
139 };
140
141 extern enum gimplify_status gimplify_expr (tree *, tree *, tree *,
142                                            bool (*) (tree), fallback_t);
143 extern void gimplify_type_sizes (tree, tree *);
144 extern void gimplify_one_sizepos (tree *, tree *);
145 extern void gimplify_stmt (tree *);
146 extern void gimplify_to_stmt_list (tree *);
147 extern void gimplify_body (tree *, tree, bool);
148 extern void push_gimplify_context (struct gimplify_ctx *);
149 extern void pop_gimplify_context (tree);
150 extern void gimplify_and_add (tree, tree *);
151
152 /* Miscellaneous helpers.  */
153 extern void gimple_add_tmp_var (tree);
154 extern tree gimple_current_bind_expr (void);
155 extern tree voidify_wrapper_expr (tree, tree);
156 extern tree gimple_build_eh_filter (tree, tree, tree);
157 extern tree build_and_jump (tree *);
158 extern tree alloc_stmt_list (void);
159 extern void free_stmt_list (tree);
160 extern tree force_labels_r (tree *, int *, void *);
161 extern enum gimplify_status gimplify_va_arg_expr (tree *, tree *, tree *);
162 struct gimplify_omp_ctx;
163 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
164 extern tree gimple_boolify (tree);
165 extern tree canonicalize_cond_expr_cond (tree);
166
167 /* In omp-low.c.  */
168 extern void diagnose_omp_structured_block_errors (tree);
169 extern tree omp_reduction_init (tree, tree);
170
171 /* In tree-nested.c.  */
172 extern void lower_nested_functions (tree);
173 extern void insert_field_into_struct (tree, tree);
174
175 /* Convenience routines to walk all statements of a gimple function.
176    The difference between these walkers and the generic walk_tree is
177    that walk_stmt provides context information to the callback
178    routine to know whether it is currently on the LHS or RHS of an
179    assignment (IS_LHS) or contexts where only GIMPLE values are
180    allowed (VAL_ONLY).
181    
182    This is useful in walkers that need to re-write sub-expressions
183    inside statements while making sure the result is still in GIMPLE
184    form.
185
186    Note that this is useful exclusively before the code is converted
187    into SSA form.  Once the program is in SSA form, the standard
188    operand interface should be used to analyze/modify statements.  */
189
190 struct walk_stmt_info
191 {
192   /* For each statement, we invoke CALLBACK via walk_tree.  The passed
193      data is a walk_stmt_info structure.  */
194   walk_tree_fn callback;
195
196   /* Points to the current statement being walked.  */
197   tree_stmt_iterator tsi;
198   
199   /* Additional data that CALLBACK may want to carry through the
200      recursion.  */
201   void *info;
202
203   /* Indicates whether the *TP being examined may be replaced 
204      with something that matches is_gimple_val (if true) or something
205      slightly more complicated (if false).  "Something" technically 
206      means the common subset of is_gimple_lvalue and is_gimple_rhs, 
207      but we never try to form anything more complicated than that, so
208      we don't bother checking.
209
210      Also note that CALLBACK should update this flag while walking the
211      sub-expressions of a statement.  For instance, when walking the
212      statement 'foo (&var)', the flag VAL_ONLY will initially be set
213      to true, however, when walking &var, the operand of that
214      ADDR_EXPR does not need to be a GIMPLE value.  */
215   bool val_only;
216
217   /* True if we are currently walking the LHS of an assignment.  */
218   bool is_lhs;
219
220   /* Optional.  Set to true by CALLBACK if it made any changes.  */
221   bool changed;
222
223   /* True if we're interested in seeing BIND_EXPRs.  */
224   bool want_bind_expr;
225
226   /* True if we're interested in seeing RETURN_EXPRs.  */
227   bool want_return_expr;
228
229   /* True if we're interested in location information.  */
230   bool want_locations;
231 };
232
233 void walk_stmts (struct walk_stmt_info *, tree *);
234
235 #endif /* _TREE_SIMPLE_H  */