00001 /* Functions to analyze and validate GIMPLE trees. 00002 Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. 00003 Contributed by Diego Novillo <dnovillo@redhat.com> 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 GCC is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to 00019 the Free Software Foundation, 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. */ 00021 00022 #ifndef _TREE_SIMPLE_H 00023 #define _TREE_SIMPLE_H 1 00024 00025 00026 #include "tree-iterator.h" 00027 00028 extern tree create_tmp_var_raw (tree, const char *); 00029 extern tree create_tmp_var_name (const char *); 00030 extern tree create_tmp_var (tree, const char *); 00031 extern tree get_initialized_tmp_var (tree, tree *, tree *); 00032 extern tree get_formal_tmp_var (tree, tree *); 00033 00034 extern void declare_vars (tree, tree, bool); 00035 00036 extern void annotate_all_with_locus (tree *, location_t); 00037 00038 /* Validation of GIMPLE expressions. Note that these predicates only check 00039 the basic form of the expression, they don't recurse to make sure that 00040 underlying nodes are also of the right form. */ 00041 00042 typedef bool (*gimple_predicate)(tree); 00043 00044 /* Returns true iff T is a valid GIMPLE statement. */ 00045 extern bool is_gimple_stmt (tree); 00046 00047 /* Returns true iff TYPE is a valid type for a scalar register variable. */ 00048 extern bool is_gimple_reg_type (tree); 00049 /* Returns true iff T is a scalar register variable. */ 00050 extern bool is_gimple_reg (tree); 00051 /* Returns true if T is a GIMPLE temporary variable, false otherwise. */ 00052 extern bool is_gimple_formal_tmp_var (tree); 00053 /* Returns true if T is a GIMPLE temporary register variable. */ 00054 extern bool is_gimple_formal_tmp_reg (tree); 00055 /* Returns true iff T is any sort of variable. */ 00056 extern bool is_gimple_variable (tree); 00057 /* Returns true iff T is any sort of symbol. */ 00058 extern bool is_gimple_id (tree); 00059 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */ 00060 extern bool is_gimple_min_lval (tree); 00061 /* Returns true iff T is something whose address can be taken. */ 00062 extern bool is_gimple_addressable (tree); 00063 /* Returns true iff T is any valid GIMPLE lvalue. */ 00064 extern bool is_gimple_lvalue (tree); 00065 00066 /* Returns true iff T is a GIMPLE restricted function invariant. */ 00067 extern bool is_gimple_min_invariant (tree); 00068 /* Returns true iff T is a GIMPLE rvalue. */ 00069 extern bool is_gimple_val (tree); 00070 /* Returns true iff T is a GIMPLE asm statement input. */ 00071 extern bool is_gimple_asm_val (tree); 00072 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a 00073 GIMPLE temporary, a renamed user variable, or something else, 00074 respectively. */ 00075 extern bool is_gimple_formal_tmp_rhs (tree); 00076 extern bool is_gimple_reg_rhs (tree); 00077 extern bool is_gimple_mem_rhs (tree); 00078 /* Returns the appropriate one of the above three predicates for the LHS 00079 T. */ 00080 extern gimple_predicate rhs_predicate_for (tree); 00081 00082 /* Returns true iff T is a valid if-statement condition. */ 00083 extern bool is_gimple_condexpr (tree); 00084 00085 /* Returns true iff T is a type conversion. */ 00086 extern bool is_gimple_cast (tree); 00087 /* Returns true iff T is a variable that does not need to live in memory. */ 00088 extern bool is_gimple_non_addressable (tree t); 00089 00090 /* Returns true iff T is a valid call address expression. */ 00091 extern bool is_gimple_call_addr (tree); 00092 /* If T makes a function call, returns the CALL_EXPR operand. */ 00093 extern tree get_call_expr_in (tree t); 00094 00095 extern void recalculate_side_effects (tree); 00096 00097 /* FIXME we should deduce this from the predicate. */ 00098 typedef enum fallback_t { 00099 fb_none = 0, 00100 fb_rvalue = 1, 00101 fb_lvalue = 2, 00102 fb_mayfail = 4, 00103 fb_either= fb_rvalue | fb_lvalue 00104 } fallback_t; 00105 00106 enum gimplify_status { 00107 GS_ERROR = -2, /* Something Bad Seen. */ 00108 GS_UNHANDLED = -1, /* A langhook result for "I dunno". */ 00109 GS_OK = 0, /* We did something, maybe more to do. */ 00110 GS_ALL_DONE = 1 /* The expression is fully gimplified. */ 00111 }; 00112 00113 extern enum gimplify_status gimplify_expr (tree *, tree *, tree *, 00114 bool (*) (tree), fallback_t); 00115 extern void gimplify_type_sizes (tree, tree *); 00116 extern void gimplify_one_sizepos (tree *, tree *); 00117 extern void gimplify_stmt (tree *); 00118 extern void gimplify_to_stmt_list (tree *); 00119 extern void gimplify_body (tree *, tree, bool); 00120 extern void push_gimplify_context (void); 00121 extern void pop_gimplify_context (tree); 00122 extern void gimplify_and_add (tree, tree *); 00123 00124 /* Miscellaneous helpers. */ 00125 extern void gimple_add_tmp_var (tree); 00126 extern tree gimple_current_bind_expr (void); 00127 extern tree voidify_wrapper_expr (tree, tree); 00128 extern tree gimple_build_eh_filter (tree, tree, tree); 00129 extern tree build_and_jump (tree *); 00130 extern tree alloc_stmt_list (void); 00131 extern void free_stmt_list (tree); 00132 extern tree force_labels_r (tree *, int *, void *); 00133 extern enum gimplify_status gimplify_va_arg_expr (tree *, tree *, tree *); 00134 struct gimplify_omp_ctx; 00135 extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree); 00136 extern tree gimple_boolify (tree); 00137 00138 /* In omp-low.c. */ 00139 extern void diagnose_omp_structured_block_errors (tree); 00140 extern tree omp_reduction_init (tree, tree); 00141 00142 /* In tree-nested.c. */ 00143 extern void lower_nested_functions (tree); 00144 extern void insert_field_into_struct (tree, tree); 00145 00146 /* Convenience routines to walk all statements of a gimple function. 00147 The difference between these walkers and the generic walk_tree is 00148 that walk_stmt provides context information to the callback 00149 routine to know whether it is currently on the LHS or RHS of an 00150 assignment (IS_LHS) or contexts where only GIMPLE values are 00151 allowed (VAL_ONLY). 00152 00153 This is useful in walkers that need to re-write sub-expressions 00154 inside statements while making sure the result is still in GIMPLE 00155 form. 00156 00157 Note that this is useful exclusively before the code is converted 00158 into SSA form. Once the program is in SSA form, the standard 00159 operand interface should be used to analyze/modify statements. */ 00160 00161 struct walk_stmt_info 00162 { 00163 /* For each statement, we invoke CALLBACK via walk_tree. The passed 00164 data is a walk_stmt_info structure. */ 00165 walk_tree_fn callback; 00166 00167 /* Points to the current statement being walked. */ 00168 tree_stmt_iterator tsi; 00169 00170 /* Additional data that CALLBACK may want to carry through the 00171 recursion. */ 00172 void *info; 00173 00174 /* Indicates whether the *TP being examined may be replaced 00175 with something that matches is_gimple_val (if true) or something 00176 slightly more complicated (if false). "Something" technically 00177 means the common subset of is_gimple_lvalue and is_gimple_rhs, 00178 but we never try to form anything more complicated than that, so 00179 we don't bother checking. 00180 00181 Also note that CALLBACK should update this flag while walking the 00182 sub-expressions of a statement. For instance, when walking the 00183 statement 'foo (&var)', the flag VAL_ONLY will initially be set 00184 to true, however, when walking &var, the operand of that 00185 ADDR_EXPR does not need to be a GIMPLE value. */ 00186 bool val_only; 00187 00188 /* True if we are currently walking the LHS of an assignment. */ 00189 bool is_lhs; 00190 00191 /* Optional. Set to true by CALLBACK if it made any changes. */ 00192 bool changed; 00193 00194 /* True if we're interested in seeing BIND_EXPRs. */ 00195 bool want_bind_expr; 00196 00197 /* True if we're interested in seeing RETURN_EXPRs. */ 00198 bool want_return_expr; 00199 00200 /* True if we're interested in location information. */ 00201 bool want_locations; 00202 }; 00203 00204 void walk_stmts (struct walk_stmt_info *, tree *); 00205 00206 #endif /* _TREE_SIMPLE_H */
1.5.6