1/* Data and Control Flow Analysis for Trees. 2 Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc. 3 Contributed by Diego Novillo <dnovillo@redhat.com> 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GCC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to 19the Free Software Foundation, 51 Franklin Street, Fifth Floor, 20Boston, MA 02110-1301, USA. */ 21 22#ifndef _TREE_FLOW_H 23#define _TREE_FLOW_H 1 24 25#include "bitmap.h" 26#include "hard-reg-set.h" 27#include "basic-block.h" 28#include "hashtab.h" 29#include "tree-gimple.h" 30#include "tree-ssa-operands.h" 31#include "cgraph.h" 32#include "ipa-reference.h" 33 34/* Forward declare structures for the garbage collector GTY markers. */ 35#ifndef GCC_BASIC_BLOCK_H 36struct edge_def; 37typedef struct edge_def *edge; 38struct basic_block_def; 39typedef struct basic_block_def *basic_block; 40#endif 41 42/* True if the code is in ssa form. */ 43extern bool in_ssa_p; 44 45typedef struct 46{ 47 htab_t htab; 48 PTR *slot; 49 PTR *limit; 50} htab_iterator; 51 52/* Iterate through the elements of hashtable HTAB, using htab_iterator ITER, 53 storing each element in RESULT, which is of type TYPE. */ 54#define FOR_EACH_HTAB_ELEMENT(HTAB, RESULT, TYPE, ITER) \ 55 for (RESULT = (TYPE) first_htab_element (&(ITER), (HTAB)); \ 56 !end_htab_p (&(ITER)); \ 57 RESULT = (TYPE) next_htab_element (&(ITER))) 58 59/*--------------------------------------------------------------------------- 60 Attributes for SSA_NAMEs. 61 62 NOTE: These structures are stored in struct tree_ssa_name 63 but are only used by the tree optimizers, so it makes better sense 64 to declare them here to avoid recompiling unrelated files when 65 making changes. 66---------------------------------------------------------------------------*/ 67 68/* Aliasing information for SSA_NAMEs representing pointer variables. */ 69struct ptr_info_def GTY(()) 70{ 71 /* Nonzero if points-to analysis couldn't determine where this pointer 72 is pointing to. */ 73 unsigned int pt_anything : 1; 74 75 /* Nonzero if the value of this pointer escapes the current function. */ 76 unsigned int value_escapes_p : 1; 77 78 /* Nonzero if this pointer is dereferenced. */ 79 unsigned int is_dereferenced : 1; 80 81 /* Nonzero if this pointer points to a global variable. */ 82 unsigned int pt_global_mem : 1; 83 84 /* Nonzero if this pointer points to NULL. */ 85 unsigned int pt_null : 1; 86 87 /* Set of variables that this pointer may point to. */ 88 bitmap pt_vars; 89 90 /* If this pointer has been dereferenced, and points-to information is 91 more precise than type-based aliasing, indirect references to this 92 pointer will be represented by this memory tag, instead of the type 93 tag computed by TBAA. */ 94 tree name_mem_tag; 95}; 96 97 98/*--------------------------------------------------------------------------- 99 Tree annotations stored in tree_common.ann 100---------------------------------------------------------------------------*/ 101enum tree_ann_type { TREE_ANN_COMMON, VAR_ANN, STMT_ANN }; 102 103struct tree_ann_common_d GTY(()) 104{ 105 /* Annotation type. */ 106 enum tree_ann_type type; 107 108 /* Auxiliary info specific to a pass. At all times, this 109 should either point to valid data or be NULL. */ 110 PTR GTY ((skip (""))) aux; 111 112 /* The value handle for this expression. Used by GVN-PRE. */ 113 tree GTY((skip)) value_handle; 114}; 115 116/* It is advantageous to avoid things like life analysis for variables which 117 do not need PHI nodes. This enum describes whether or not a particular 118 variable may need a PHI node. */ 119 120enum need_phi_state { 121 /* This is the default. If we are still in this state after finding 122 all the definition and use sites, then we will assume the variable 123 needs PHI nodes. This is probably an overly conservative assumption. */ 124 NEED_PHI_STATE_UNKNOWN, 125 126 /* This state indicates that we have seen one or more sets of the 127 variable in a single basic block and that the sets dominate all 128 uses seen so far. If after finding all definition and use sites 129 we are still in this state, then the variable does not need any 130 PHI nodes. */ 131 NEED_PHI_STATE_NO, 132 133 /* This state indicates that we have either seen multiple definitions of 134 the variable in multiple blocks, or that we encountered a use in a 135 block that was not dominated by the block containing the set(s) of 136 this variable. This variable is assumed to need PHI nodes. */ 137 NEED_PHI_STATE_MAYBE 138}; 139 140 141/* When computing aliasing information, we represent the memory pointed-to 142 by pointers with artificial variables called "memory tags" (MT). There 143 are two kinds of tags: type and name. Type tags (TMT) are used in 144 type-based alias analysis, they represent all the pointed-to locations 145 and variables of the same alias set class. Name tags (NMT) are used in 146 flow-sensitive points-to alias analysis, they represent the variables 147 and memory locations pointed-to by a specific SSA_NAME pointer. */ 148enum mem_tag_kind { 149 /* This variable is not a memory tag. */ 150 NOT_A_TAG, 151 152 /* This variable is a type memory tag (TMT). */ 153 TYPE_TAG, 154 155 /* This variable is a name memory tag (NMT). */ 156 NAME_TAG, 157 158 /* This variable represents a structure field. */ 159 STRUCT_FIELD 160}; 161 162struct subvar; 163typedef struct subvar *subvar_t; 164 165/* This structure represents a fake sub-variable for a structure field. */ 166struct subvar GTY(()) 167{ 168 /* Fake variable. */ 169 tree var; 170 171 /* Offset inside structure. */ 172 unsigned HOST_WIDE_INT offset; 173 174 /* Size of the field. */ 175 unsigned HOST_WIDE_INT size; 176 177 /* Next subvar for this structure. */ 178 subvar_t next; 179}; 180 181struct var_ann_d GTY(()) 182{ 183 struct tree_ann_common_d common; 184 185 /* Used by the out of SSA pass to determine whether this variable has 186 been seen yet or not. */ 187 unsigned out_of_ssa_tag : 1; 188 189 /* Used when building root_var structures in tree_ssa_live.[ch]. */ 190 unsigned root_var_processed : 1; 191 192 /* If nonzero, this variable is a memory tag. */ 193 ENUM_BITFIELD (mem_tag_kind) mem_tag_kind : 2; 194 195 /* Nonzero if this variable is an alias tag that represents references to 196 other variables (i.e., this variable appears in the MAY_ALIASES array 197 of other variables). */ 198 unsigned is_alias_tag : 1; 199 200 /* Nonzero if this variable was used after SSA optimizations were 201 applied. We set this when translating out of SSA form. */ 202 unsigned used : 1; 203 204 /* This field indicates whether or not the variable may need PHI nodes. 205 See the enum's definition for more detailed information about the 206 states. */ 207 ENUM_BITFIELD (need_phi_state) need_phi_state : 2; 208 209 /* Used during operand processing to determine if this variable is already 210 in the vuse list. */ 211 unsigned in_vuse_list : 1; 212 213 /* Used during operand processing to determine if this variable is already 214 in the v_may_def list. */ 215 unsigned in_v_may_def_list : 1; 216 217 /* An artificial variable representing the memory location pointed-to by 218 all the pointers that TBAA (type-based alias analysis) considers 219 to be aliased. If the variable is not a pointer or if it is never 220 dereferenced, this must be NULL. */ 221 tree type_mem_tag; 222 223 /* Variables that may alias this variable. */ 224 varray_type may_aliases; 225 226 /* Used when going out of SSA form to indicate which partition this 227 variable represents storage for. */ 228 unsigned partition; 229 230 /* Used by the root-var object in tree-ssa-live.[ch]. */ 231 unsigned root_index; 232 233 /* Default definition for this symbol. If this field is not NULL, it 234 means that the first reference to this variable in the function is a 235 USE or a VUSE. In those cases, the SSA renamer creates an SSA name 236 for this variable with an empty defining statement. */ 237 tree default_def; 238 239 /* During into-ssa and the dominator optimizer, this field holds the 240 current version of this variable (an SSA_NAME). */ 241 tree current_def; 242 243 /* Pointer to the structure that contains the sets of global 244 variables modified by function calls. This field is only used 245 for FUNCTION_DECLs. */ 246 ipa_reference_vars_info_t GTY ((skip)) reference_vars_info; 247 248 /* If this variable is a structure, this fields holds a list of 249 symbols representing each of the fields of the structure. */ 250 subvar_t subvars; 251}; 252 253 254typedef struct immediate_use_iterator_d 255{ 256 ssa_use_operand_t *imm_use; 257 ssa_use_operand_t *end_p; 258 ssa_use_operand_t iter_node; 259} imm_use_iterator; 260 261 262/* Use this iterator when simply looking at stmts. Adding, deleting or 263 modifying stmts will cause this iterator to malfunction. */ 264 265#define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR) \ 266 for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR)); \ 267 !end_readonly_imm_use_p (&(ITER)); \ 268 (DEST) = next_readonly_imm_use (&(ITER))) 269 270 271#define FOR_EACH_IMM_USE_SAFE(DEST, ITER, SSAVAR) \ 272 for ((DEST) = first_safe_imm_use (&(ITER), (SSAVAR)); \ 273 !end_safe_imm_use_p (&(ITER)); \ 274 (DEST) = next_safe_imm_use (&(ITER))) 275 276#define BREAK_FROM_SAFE_IMM_USE(ITER) \ 277 { \ 278 end_safe_imm_use_traverse (&(ITER)); \ 279 break; \ 280 } 281 282struct stmt_ann_d GTY(()) 283{ 284 struct tree_ann_common_d common; 285 286 /* Nonzero if the statement has been modified (meaning that the operands 287 need to be scanned again). */ 288 unsigned modified : 1; 289 290 /* Nonzero if the statement makes aliased loads. */ 291 unsigned makes_aliased_loads : 1; 292 293 /* Nonzero if the statement makes aliased stores. */ 294 unsigned makes_aliased_stores : 1; 295 296 /* Nonzero if the statement makes references to volatile storage. */ 297 unsigned has_volatile_ops : 1; 298 299 /* Nonzero if the statement makes a function call that may clobber global 300 and local addressable variables. */ 301 unsigned makes_clobbering_call : 1; 302 303 /* Basic block that contains this statement. */ 304 basic_block bb; 305 306 /* Operand cache for stmt. */ 307 struct stmt_operands_d GTY ((skip (""))) operands; 308 309 /* Set of variables that have had their address taken in the statement. */ 310 bitmap addresses_taken; 311 312 /* Unique identifier for this statement. These ID's are to be created 313 by each pass on an as-needed basis in any order convenient for the 314 pass which needs statement UIDs. */ 315 unsigned int uid; 316 317 /* Linked list of histograms for value-based profiling. This is really a 318 struct histogram_value*. We use void* to avoid having to export that 319 everywhere, and to avoid having to put it in GC memory. */ 320 321 void * GTY ((skip (""))) histograms; 322}; 323 324union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)"))) 325{ 326 struct tree_ann_common_d GTY((tag ("TREE_ANN_COMMON"))) common; 327 struct var_ann_d GTY((tag ("VAR_ANN"))) decl; 328 struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt; 329}; 330 331extern GTY(()) VEC(tree,gc) *modified_noreturn_calls; 332 333typedef union tree_ann_d *tree_ann_t; 334typedef struct var_ann_d *var_ann_t; 335typedef struct stmt_ann_d *stmt_ann_t; 336 337static inline tree_ann_t tree_ann (tree); 338static inline tree_ann_t get_tree_ann (tree); 339static inline var_ann_t var_ann (tree); 340static inline var_ann_t get_var_ann (tree); 341static inline stmt_ann_t stmt_ann (tree); 342static inline stmt_ann_t get_stmt_ann (tree); 343static inline enum tree_ann_type ann_type (tree_ann_t); 344static inline basic_block bb_for_stmt (tree); 345extern void set_bb_for_stmt (tree, basic_block); 346static inline bool noreturn_call_p (tree); 347static inline void update_stmt (tree); 348static inline bool stmt_modified_p (tree); 349static inline varray_type may_aliases (tree); 350static inline int get_lineno (tree); 351static inline const char *get_filename (tree); 352static inline bool is_exec_stmt (tree); 353static inline bool is_label_stmt (tree); 354static inline bitmap addresses_taken (tree); 355static inline void set_default_def (tree, tree); 356static inline tree default_def (tree); 357 358/*--------------------------------------------------------------------------- 359 Structure representing predictions in tree level. 360---------------------------------------------------------------------------*/ 361struct edge_prediction GTY((chain_next ("%h.next"))) 362{ 363 struct edge_prediction *next; 364 edge edge; 365 enum br_predictor predictor; 366 int probability; 367}; 368 369/* Accessors for basic block annotations. */ 370static inline tree phi_nodes (basic_block); 371static inline void set_phi_nodes (basic_block, tree); 372 373/*--------------------------------------------------------------------------- 374 Global declarations 375---------------------------------------------------------------------------*/ 376struct int_tree_map GTY(()) 377{ 378 379 unsigned int uid; 380 tree to; 381}; 382 383extern unsigned int int_tree_map_hash (const void *); 384extern int int_tree_map_eq (const void *, const void *); 385 386typedef struct 387{ 388 htab_iterator hti; 389} referenced_var_iterator; 390 391 392/* This macro loops over all the referenced vars, one at a time, putting the 393 current var in VAR. Note: You are not allowed to add referenced variables 394 to the hashtable while using this macro. Doing so may cause it to behave 395 erratically. */ 396 397#define FOR_EACH_REFERENCED_VAR(VAR, ITER) \ 398 for ((VAR) = first_referenced_var (&(ITER)); \ 399 !end_referenced_vars_p (&(ITER)); \ 400 (VAR) = next_referenced_var (&(ITER))) 401 402 403typedef struct 404{ 405 int i; 406} safe_referenced_var_iterator; 407 408/* This macro loops over all the referenced vars, one at a time, putting the 409 current var in VAR. You are allowed to add referenced variables during the 410 execution of this macro, however, the macro will not iterate over them. It 411 requires a temporary vector of trees, VEC, whose lifetime is controlled by 412 the caller. The purpose of the vector is to temporarily store the 413 referenced_variables hashtable so that adding referenced variables does not 414 affect the hashtable. */ 415 416#define FOR_EACH_REFERENCED_VAR_SAFE(VAR, VEC, ITER) \ 417 for ((ITER).i = 0, fill_referenced_var_vec (&(VEC)); \ 418 VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \ 419 (ITER).i++) 420 421/* Array of all variables referenced in the function. */ 422extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars; 423 424extern tree referenced_var_lookup (unsigned int); 425extern tree referenced_var_lookup_if_exists (unsigned int); 426#define num_referenced_vars htab_elements (referenced_vars) 427#define referenced_var(i) referenced_var_lookup (i) 428 429/* Array of all SSA_NAMEs used in the function. */ 430extern GTY(()) VEC(tree,gc) *ssa_names; 431 432#define num_ssa_names (VEC_length (tree, ssa_names)) 433#define ssa_name(i) (VEC_index (tree, ssa_names, (i))) 434 435/* Artificial variable used to model the effects of function calls. */ 436extern GTY(()) tree global_var; 437 438/* Call clobbered variables in the function. If bit I is set, then 439 REFERENCED_VARS (I) is call-clobbered. */ 440extern bitmap call_clobbered_vars; 441 442/* Addressable variables in the function. If bit I is set, then 443 REFERENCED_VARS (I) has had its address taken. */ 444extern bitmap addressable_vars; 445 446/* 'true' after aliases have been computed (see compute_may_aliases). */ 447extern bool aliases_computed_p; 448 449/* Macros for showing usage statistics. */ 450#define SCALE(x) ((unsigned long) ((x) < 1024*10 \ 451 ? (x) \ 452 : ((x) < 1024*1024*10 \ 453 ? (x) / 1024 \ 454 : (x) / (1024*1024)))) 455 456#define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M')) 457 458#define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y)) 459 460/*--------------------------------------------------------------------------- 461 Block iterators 462---------------------------------------------------------------------------*/ 463 464typedef struct { 465 tree_stmt_iterator tsi; 466 basic_block bb; 467} block_stmt_iterator; 468 469static inline block_stmt_iterator bsi_start (basic_block); 470static inline block_stmt_iterator bsi_last (basic_block); 471static inline block_stmt_iterator bsi_after_labels (basic_block); 472block_stmt_iterator bsi_for_stmt (tree); 473static inline bool bsi_end_p (block_stmt_iterator); 474static inline void bsi_next (block_stmt_iterator *); 475static inline void bsi_prev (block_stmt_iterator *); 476static inline tree bsi_stmt (block_stmt_iterator); 477static inline tree * bsi_stmt_ptr (block_stmt_iterator); 478 479extern void bsi_remove (block_stmt_iterator *); 480extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *); 481extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *); 482extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block); 483 484enum bsi_iterator_update 485{ 486 /* Note that these are intentionally in the same order as TSI_FOO. They 487 mean exactly the same as their TSI_* counterparts. */ 488 BSI_NEW_STMT, 489 BSI_SAME_STMT, 490 BSI_CHAIN_START, 491 BSI_CHAIN_END, 492 BSI_CONTINUE_LINKING 493}; 494 495extern void bsi_insert_before (block_stmt_iterator *, tree, 496 enum bsi_iterator_update); 497extern void bsi_insert_after (block_stmt_iterator *, tree, 498 enum bsi_iterator_update); 499 500extern void bsi_replace (const block_stmt_iterator *, tree, bool); 501 502/*--------------------------------------------------------------------------- 503 Function prototypes 504---------------------------------------------------------------------------*/ 505/* In tree-cfg.c */ 506 507/* Location to track pending stmt for edge insertion. */ 508#define PENDING_STMT(e) ((e)->insns.t) 509 510extern void delete_tree_cfg_annotations (void); 511extern void disband_implicit_edges (void); 512extern bool stmt_ends_bb_p (tree); 513extern bool is_ctrl_stmt (tree); 514extern bool is_ctrl_altering_stmt (tree); 515extern bool computed_goto_p (tree); 516extern bool simple_goto_p (tree); 517extern basic_block single_noncomplex_succ (basic_block bb); 518extern void tree_dump_bb (basic_block, FILE *, int); 519extern void debug_tree_bb (basic_block); 520extern basic_block debug_tree_bb_n (int); 521extern void dump_tree_cfg (FILE *, int); 522extern void debug_tree_cfg (int); 523extern void dump_cfg_stats (FILE *); 524extern void debug_cfg_stats (void); 525extern void debug_loop_ir (void); 526extern void print_loop_ir (FILE *); 527extern void cleanup_dead_labels (void); 528extern void group_case_labels (void); 529extern tree first_stmt (basic_block); 530extern tree last_stmt (basic_block); 531extern tree *last_stmt_ptr (basic_block); 532extern tree last_and_only_stmt (basic_block); 533extern edge find_taken_edge (basic_block, tree); 534extern basic_block label_to_block_fn (struct function *, tree); 535#define label_to_block(t) (label_to_block_fn (cfun, t)) 536extern void bsi_insert_on_edge (edge, tree); 537extern basic_block bsi_insert_on_edge_immediate (edge, tree); 538extern void bsi_commit_one_edge_insert (edge, basic_block *); 539extern void bsi_commit_edge_inserts (void); 540extern void notice_special_calls (tree); 541extern void clear_special_calls (void); 542extern void verify_stmts (void); 543extern tree tree_block_label (basic_block); 544extern void extract_true_false_edges_from_block (basic_block, edge *, edge *); 545extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned, 546 basic_block *); 547extern void add_phi_args_after_copy_bb (basic_block); 548extern void add_phi_args_after_copy (basic_block *, unsigned); 549extern bool tree_purge_dead_eh_edges (basic_block); 550extern bool tree_purge_all_dead_eh_edges (bitmap); 551extern tree gimplify_val (block_stmt_iterator *, tree, tree); 552extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code, 553 tree, tree); 554extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code, 555 tree, tree, tree); 556extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code, 557 tree, tree, tree, tree); 558extern void init_empty_tree_cfg (void); 559extern void fold_cond_expr_cond (void); 560extern void replace_uses_by (tree, tree); 561extern void start_recording_case_labels (void); 562extern void end_recording_case_labels (void); 563 564/* In tree-cfgcleanup.c */ 565extern bool cleanup_tree_cfg (void); 566extern void cleanup_tree_cfg_loop (void); 567 568/* In tree-pretty-print.c. */ 569extern void dump_generic_bb (FILE *, basic_block, int, int); 570 571/* In tree-dfa.c */ 572extern var_ann_t create_var_ann (tree); 573extern stmt_ann_t create_stmt_ann (tree); 574extern tree_ann_t create_tree_ann (tree); 575extern void dump_dfa_stats (FILE *); 576extern void debug_dfa_stats (void); 577extern void debug_referenced_vars (void); 578extern void dump_referenced_vars (FILE *); 579extern void dump_variable (FILE *, tree); 580extern void debug_variable (tree); 581extern void dump_subvars_for (FILE *, tree); 582extern void debug_subvars_for (tree); 583extern tree get_virtual_var (tree); 584extern void add_referenced_tmp_var (tree); 585extern void mark_new_vars_to_rename (tree); 586extern void find_new_referenced_vars (tree *); 587 588extern tree make_rename_temp (tree, const char *); 589 590/* In tree-phinodes.c */ 591extern void reserve_phi_args_for_new_edge (basic_block); 592extern tree create_phi_node (tree, basic_block); 593extern void add_phi_arg (tree, tree, edge); 594extern void remove_phi_args (edge); 595extern void remove_phi_node (tree, tree); 596extern tree phi_reverse (tree); 597 598/* In gimple-low.c */ 599extern void record_vars (tree); 600extern bool block_may_fallthru (tree block); 601 602/* In tree-ssa-alias.c */ 603extern void dump_may_aliases_for (FILE *, tree); 604extern void debug_may_aliases_for (tree); 605extern void dump_alias_info (FILE *); 606extern void debug_alias_info (void); 607extern void dump_points_to_info (FILE *); 608extern void debug_points_to_info (void); 609extern void dump_points_to_info_for (FILE *, tree); 610extern void debug_points_to_info_for (tree); 611extern bool may_be_aliased (tree); 612extern bool is_aliased_with (tree, tree); 613extern bool may_aliases_intersect (tree, tree); 614extern struct ptr_info_def *get_ptr_info (tree); 615extern void add_type_alias (tree, tree); 616extern void new_type_alias (tree, tree); 617extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *, bool *); 618static inline subvar_t get_subvars_for_var (tree); 619static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT); 620static inline bool ref_contains_array_ref (tree); 621static inline bool array_ref_contains_indirect_ref (tree); 622extern tree okay_component_ref_for_subvars (tree, unsigned HOST_WIDE_INT *, 623 unsigned HOST_WIDE_INT *); 624static inline bool var_can_have_subvars (tree); 625static inline bool overlap_subvar (unsigned HOST_WIDE_INT, 626 unsigned HOST_WIDE_INT, 627 subvar_t, bool *); 628 629/* Call-back function for walk_use_def_chains(). At each reaching 630 definition, a function with this prototype is called. */ 631typedef bool (*walk_use_def_chains_fn) (tree, tree, void *); 632 633 634/* In tree-ssa.c */ 635extern void init_tree_ssa (void); 636extern edge ssa_redirect_edge (edge, basic_block); 637extern void flush_pending_stmts (edge); 638extern bool tree_ssa_useless_type_conversion (tree); 639extern bool tree_ssa_useless_type_conversion_1 (tree, tree); 640extern void verify_ssa (bool); 641extern void delete_tree_ssa (void); 642extern void register_new_def (tree, VEC(tree,heap) **); 643extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool); 644extern bool stmt_references_memory_p (tree); 645 646/* In tree-into-ssa.c */ 647void update_ssa (unsigned); 648void delete_update_ssa (void); 649void register_new_name_mapping (tree, tree); 650tree create_new_def_for (tree, tree, def_operand_p); 651bool need_ssa_update_p (void); 652bool name_registered_for_update_p (tree); 653bitmap ssa_names_to_replace (void); 654void release_ssa_name_after_update_ssa (tree name); 655void compute_global_livein (bitmap, bitmap); 656tree duplicate_ssa_name (tree, tree); 657void mark_sym_for_renaming (tree); 658void mark_set_for_renaming (bitmap); 659tree get_current_def (tree); 660void set_current_def (tree, tree); 661 662/* In tree-ssa-ccp.c */ 663bool fold_stmt (tree *); 664bool fold_stmt_inplace (tree); 665tree widen_bitfield (tree, tree, tree); 666 667/* In tree-vrp.c */ 668tree vrp_evaluate_conditional (tree, bool); 669void simplify_stmt_using_ranges (tree); 670 671/* In tree-ssa-dom.c */ 672extern void dump_dominator_optimization_stats (FILE *); 673extern void debug_dominator_optimization_stats (void); 674int loop_depth_of_name (tree); 675 676/* In tree-ssa-copy.c */ 677extern void merge_alias_info (tree, tree); 678extern void propagate_value (use_operand_p, tree); 679extern void propagate_tree_value (tree *, tree); 680extern void replace_exp (use_operand_p, tree); 681extern bool may_propagate_copy (tree, tree); 682extern bool may_propagate_copy_into_asm (tree); 683 684/* Description of number of iterations of a loop. All the expressions inside 685 the structure can be evaluated at the end of the loop's preheader 686 (and due to ssa form, also anywhere inside the body of the loop). */ 687 688struct tree_niter_desc 689{ 690 tree assumptions; /* The boolean expression. If this expression evaluates 691 to false, then the other fields in this structure 692 should not be used; there is no guarantee that they 693 will be correct. */ 694 tree may_be_zero; /* The boolean expression. If it evaluates to true, 695 the loop will exit in the first iteration (i.e. 696 its latch will not be executed), even if the niter 697 field says otherwise. */ 698 tree niter; /* The expression giving the number of iterations of 699 a loop (provided that assumptions == true and 700 may_be_zero == false), more precisely the number 701 of executions of the latch of the loop. */ 702 tree additional_info; /* The boolean expression. Sometimes we use additional 703 knowledge to simplify the other expressions 704 contained in this structure (for example the 705 knowledge about value ranges of operands on entry to 706 the loop). If this is a case, conjunction of such 707 condition is stored in this field, so that we do not 708 lose the information: for example if may_be_zero 709 is (n <= 0) and niter is (unsigned) n, we know 710 that the number of iterations is at most 711 MAX_SIGNED_INT. However if the (n <= 0) assumption 712 is eliminated (by looking at the guard on entry of 713 the loop), then the information would be lost. */ 714}; 715 716/* In tree-vectorizer.c */ 717void vectorize_loops (struct loops *); 718 719/* In tree-ssa-phiopt.c */ 720bool empty_block_p (basic_block); 721 722/* In tree-ssa-loop*.c */ 723 724void tree_ssa_lim (struct loops *); 725void tree_ssa_unswitch_loops (struct loops *); 726void canonicalize_induction_variables (struct loops *); 727void tree_unroll_loops_completely (struct loops *, bool); 728void remove_empty_loops (struct loops *); 729void tree_ssa_iv_optimize (struct loops *); 730 731bool number_of_iterations_exit (struct loop *, edge, 732 struct tree_niter_desc *niter, bool); 733tree find_loop_niter (struct loop *, edge *); 734tree loop_niter_by_eval (struct loop *, edge); 735tree find_loop_niter_by_eval (struct loop *, edge *); 736void estimate_numbers_of_iterations (struct loops *); 737bool scev_probably_wraps_p (tree, tree, tree, struct loop *, bool); 738bool convert_affine_scev (struct loop *, tree, tree *, tree *, tree, bool); 739 740bool nowrap_type_p (tree); 741enum ev_direction {EV_DIR_GROWS, EV_DIR_DECREASES, EV_DIR_UNKNOWN}; 742enum ev_direction scev_direction (tree); 743 744void free_numbers_of_iterations_estimates (struct loops *); 745void free_numbers_of_iterations_estimates_loop (struct loop *); 746void rewrite_into_loop_closed_ssa (bitmap, unsigned); 747void verify_loop_closed_ssa (void); 748void loop_commit_inserts (void); 749bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *); 750void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool, 751 tree *, tree *); 752void split_loop_exit_edge (edge); 753void compute_phi_arg_on_exit (edge, tree, tree); 754unsigned force_expr_to_var_cost (tree); 755basic_block bsi_insert_on_edge_immediate_loop (edge, tree); 756void standard_iv_increment_position (struct loop *, block_stmt_iterator *, 757 bool *); 758basic_block ip_end_pos (struct loop *); 759basic_block ip_normal_pos (struct loop *); 760bool tree_duplicate_loop_to_header_edge (struct loop *, edge, struct loops *, 761 unsigned int, sbitmap, 762 edge, edge *, 763 unsigned int *, int); 764struct loop *tree_ssa_loop_version (struct loops *, struct loop *, tree, 765 basic_block *); 766tree expand_simple_operations (tree); 767void substitute_in_loop_info (struct loop *, tree, tree); 768edge single_dom_exit (struct loop *); 769bool contains_abnormal_ssa_name_p (tree); 770 771/* In tree-ssa-loop-im.c */ 772/* The possibilities of statement movement. */ 773 774enum move_pos 775 { 776 MOVE_IMPOSSIBLE, /* No movement -- side effect expression. */ 777 MOVE_PRESERVE_EXECUTION, /* Must not cause the non-executed statement 778 become executed -- memory accesses, ... */ 779 MOVE_POSSIBLE /* Unlimited movement. */ 780 }; 781extern enum move_pos movement_possibility (tree); 782 783/* In tree-flow-inline.h */ 784static inline bool is_call_clobbered (tree); 785static inline void mark_call_clobbered (tree); 786static inline void set_is_used (tree); 787static inline bool unmodifiable_var_p (tree); 788 789/* In tree-eh.c */ 790extern void make_eh_edges (tree); 791extern bool tree_could_trap_p (tree); 792extern bool tree_could_throw_p (tree); 793extern bool tree_can_throw_internal (tree); 794extern bool tree_can_throw_external (tree); 795extern int lookup_stmt_eh_region (tree); 796extern void add_stmt_to_eh_region (tree, int); 797extern bool remove_stmt_from_eh_region (tree); 798extern bool maybe_clean_or_replace_eh_stmt (tree, tree); 799 800/* In tree-ssa-pre.c */ 801void add_to_value (tree, tree); 802void debug_value_expressions (tree); 803void print_value_expressions (FILE *, tree); 804 805 806/* In tree-vn.c */ 807bool expressions_equal_p (tree, tree); 808tree get_value_handle (tree); 809hashval_t vn_compute (tree, hashval_t, tree); 810tree vn_lookup_or_add (tree, tree); 811void vn_add (tree, tree, tree); 812tree vn_lookup (tree, tree); 813void vn_init (void); 814void vn_delete (void); 815 816/* In tree-ssa-sink.c */ 817bool is_hidden_global_store (tree); 818 819/* In tree-sra.c */ 820void insert_edge_copies (tree, basic_block); 821void sra_insert_before (block_stmt_iterator *, tree); 822void sra_insert_after (block_stmt_iterator *, tree); 823void sra_init_cache (void); 824bool sra_type_can_be_decomposed_p (tree); 825 826/* In tree-loop-linear.c */ 827extern void linear_transform_loops (struct loops *); 828 829/* In tree-ssa-loop-ivopts.c */ 830bool expr_invariant_in_loop_p (struct loop *, tree); 831bool multiplier_allowed_in_address_p (HOST_WIDE_INT); 832unsigned multiply_by_cost (HOST_WIDE_INT, enum machine_mode); 833 834/* In tree-ssa-threadupdate.c. */ 835extern bool thread_through_all_blocks (bitmap); 836 837/* In gimplify.c */ 838tree force_gimple_operand (tree, tree *, bool, tree); 839tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree); 840 841/* In tree-ssa-structalias.c */ 842bool find_what_p_points_to (tree); 843 844/* In tree-ssa-address.c */ 845 846/* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements 847 to make things simpler; this is sufficient in most cases. */ 848 849#define MAX_AFF_ELTS 8 850 851struct affine_tree_combination 852{ 853 /* Type of the result of the combination. */ 854 tree type; 855 856 /* Mask modulo that the operations are performed. */ 857 unsigned HOST_WIDE_INT mask; 858 859 /* Constant offset. */ 860 unsigned HOST_WIDE_INT offset; 861 862 /* Number of elements of the combination. */ 863 unsigned n; 864 865 /* Elements and their coefficients. */ 866 tree elts[MAX_AFF_ELTS]; 867 unsigned HOST_WIDE_INT coefs[MAX_AFF_ELTS]; 868 869 /* Remainder of the expression. */ 870 tree rest; 871}; 872 873/* Description of a memory address. */ 874 875struct mem_address 876{ 877 tree symbol, base, index, step, offset; 878}; 879 880tree create_mem_ref (block_stmt_iterator *, tree, 881 struct affine_tree_combination *); 882rtx addr_for_mem_ref (struct mem_address *, bool); 883void get_address_description (tree, struct mem_address *); 884tree maybe_fold_tmr (tree); 885/* This structure is simply used during pushing fields onto the fieldstack 886 to track the offset of the field, since bitpos_of_field gives it relative 887 to its immediate containing type, and we want it relative to the ultimate 888 containing object. */ 889 890struct fieldoff 891{ 892 tree field; 893 HOST_WIDE_INT offset; 894}; 895typedef struct fieldoff fieldoff_s; 896 897DEF_VEC_O(fieldoff_s); 898DEF_VEC_ALLOC_O(fieldoff_s,heap); 899int push_fields_onto_fieldstack (tree, VEC(fieldoff_s,heap) **, 900 HOST_WIDE_INT, bool *); 901void sort_fieldstack (VEC(fieldoff_s,heap) *); 902 903void init_alias_heapvars (void); 904void delete_alias_heapvars (void); 905 906#include "tree-flow-inline.h" 907 908#endif /* _TREE_FLOW_H */ 909