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 /* Mask of reasons this pointer's value escapes the function */ 97 unsigned int escape_mask; 98}; 99 100 101/*--------------------------------------------------------------------------- 102 Tree annotations stored in tree_common.ann 103---------------------------------------------------------------------------*/ 104enum tree_ann_type { TREE_ANN_COMMON, VAR_ANN, FUNCTION_ANN, STMT_ANN }; 105 106struct tree_ann_common_d GTY(()) 107{ 108 /* Annotation type. */ 109 enum tree_ann_type type; 110 111 /* Auxiliary info specific to a pass. At all times, this 112 should either point to valid data or be NULL. */ 113 PTR GTY ((skip (""))) aux; 114 115 /* The value handle for this expression. Used by GVN-PRE. */ 116 tree GTY((skip)) value_handle; 117}; 118 119/* It is advantageous to avoid things like life analysis for variables which 120 do not need PHI nodes. This enum describes whether or not a particular 121 variable may need a PHI node. */ 122 123enum need_phi_state { 124 /* This is the default. If we are still in this state after finding 125 all the definition and use sites, then we will assume the variable 126 needs PHI nodes. This is probably an overly conservative assumption. */ 127 NEED_PHI_STATE_UNKNOWN, 128 129 /* This state indicates that we have seen one or more sets of the 130 variable in a single basic block and that the sets dominate all 131 uses seen so far. If after finding all definition and use sites 132 we are still in this state, then the variable does not need any 133 PHI nodes. */ 134 NEED_PHI_STATE_NO, 135 136 /* This state indicates that we have either seen multiple definitions of 137 the variable in multiple blocks, or that we encountered a use in a 138 block that was not dominated by the block containing the set(s) of 139 this variable. This variable is assumed to need PHI nodes. */ 140 NEED_PHI_STATE_MAYBE 141}; 142 143struct subvar; 144typedef struct subvar *subvar_t; 145 146/* This structure represents a fake sub-variable for a structure field. */ 147struct subvar GTY(()) 148{ 149 /* Fake variable. */ 150 tree var; 151 152 /* Next subvar for this structure. */ 153 subvar_t next; 154}; 155 156struct var_ann_d GTY(()) 157{ 158 struct tree_ann_common_d common; 159 160 /* Used by the out of SSA pass to determine whether this variable has 161 been seen yet or not. */ 162 unsigned out_of_ssa_tag : 1; 163 164 /* Used when building root_var structures in tree_ssa_live.[ch]. */ 165 unsigned root_var_processed : 1; 166 167 /* Nonzero if this variable is in the alias set of another variable. */ 168 unsigned is_aliased : 1; 169 170 /* Nonzero if this variable was used after SSA optimizations were 171 applied. We set this when translating out of SSA form. */ 172 unsigned used : 1; 173 174 /* This field indicates whether or not the variable may need PHI nodes. 175 See the enum's definition for more detailed information about the 176 states. */ 177 ENUM_BITFIELD (need_phi_state) need_phi_state : 2; 178 179 /* Used during operand processing to determine if this variable is already 180 in the vuse list. */ 181 unsigned in_vuse_list : 1; 182 183 /* Used during operand processing to determine if this variable is already 184 in the v_may_def list. */ 185 unsigned in_v_may_def_list : 1; 186 187 /* An artificial variable representing the memory location pointed-to by 188 all the pointer symbols that flow-insensitive alias analysis 189 (mostly type-based) considers to be aliased. If the variable is 190 not a pointer or if it is never dereferenced, this must be NULL. */ 191 tree symbol_mem_tag; 192 193 /* Variables that may alias this variable. */ 194 VEC(tree, gc) *may_aliases; 195 196 /* Used when going out of SSA form to indicate which partition this 197 variable represents storage for. */ 198 unsigned partition; 199 200 /* Used by the root-var object in tree-ssa-live.[ch]. */ 201 unsigned root_index; 202 203 /* During into-ssa and the dominator optimizer, this field holds the 204 current version of this variable (an SSA_NAME). */ 205 tree current_def; 206 207 /* If this variable is a structure, this fields holds a list of 208 symbols representing each of the fields of the structure. */ 209 subvar_t subvars; 210 211 /* Mask of values saying the reasons why this variable has escaped 212 the function. */ 213 unsigned int escape_mask; 214}; 215 216struct function_ann_d GTY(()) 217{ 218 struct tree_ann_common_d common; 219 220 /* Pointer to the structure that contains the sets of global 221 variables modified by function calls. This field is only used 222 for FUNCTION_DECLs. */ 223 ipa_reference_vars_info_t GTY ((skip)) reference_vars_info; 224}; 225 226typedef struct immediate_use_iterator_d 227{ 228 /* This is the current use the iterator is processing. */ 229 ssa_use_operand_t *imm_use; 230 /* This marks the last use in the list (use node from SSA_NAME) */ 231 ssa_use_operand_t *end_p; 232 /* This node is inserted and used to mark the end of the uses for a stmt. */ 233 ssa_use_operand_t iter_node; 234 /* This is the next ssa_name to visit. IMM_USE may get removed before 235 the next one is traversed to, so it must be cached early. */ 236 ssa_use_operand_t *next_imm_name; 237} imm_use_iterator; 238 239 240/* Use this iterator when simply looking at stmts. Adding, deleting or 241 modifying stmts will cause this iterator to malfunction. */ 242 243#define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR) \ 244 for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR)); \ 245 !end_readonly_imm_use_p (&(ITER)); \ 246 (DEST) = next_readonly_imm_use (&(ITER))) 247 248/* Use this iterator to visit each stmt which has a use of SSAVAR. */ 249 250#define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR) \ 251 for ((STMT) = first_imm_use_stmt (&(ITER), (SSAVAR)); \ 252 !end_imm_use_stmt_p (&(ITER)); \ 253 (STMT) = next_imm_use_stmt (&(ITER))) 254 255/* Use this to terminate the FOR_EACH_IMM_USE_STMT loop early. Failure to 256 do so will result in leaving a iterator marker node in the immediate 257 use list, and nothing good will come from that. */ 258#define BREAK_FROM_IMM_USE_STMT(ITER) \ 259 { \ 260 end_imm_use_stmt_traverse (&(ITER)); \ 261 break; \ 262 } 263 264 265/* Use this iterator in combination with FOR_EACH_IMM_USE_STMT to 266 get access to each occurrence of ssavar on the stmt returned by 267 that iterator.. for instance: 268 269 FOR_EACH_IMM_USE_STMT (stmt, iter, var) 270 { 271 FOR_EACH_IMM_USE_ON_STMT (use_p, iter) 272 { 273 SET_USE (use_p) = blah; 274 } 275 update_stmt (stmt); 276 } */ 277 278#define FOR_EACH_IMM_USE_ON_STMT(DEST, ITER) \ 279 for ((DEST) = first_imm_use_on_stmt (&(ITER)); \ 280 !end_imm_use_on_stmt_p (&(ITER)); \ 281 (DEST) = next_imm_use_on_stmt (&(ITER))) 282 283 284 285struct stmt_ann_d GTY(()) 286{ 287 struct tree_ann_common_d common; 288 289 /* Nonzero if the statement has been modified (meaning that the operands 290 need to be scanned again). */ 291 unsigned modified : 1; 292 293 /* Nonzero if the statement makes references to volatile storage. */ 294 unsigned has_volatile_ops : 1; 295 296 /* Nonzero if the statement makes a function call that may clobber global 297 and local addressable variables. */ 298 unsigned makes_clobbering_call : 1; 299 300 /* Basic block that contains this statement. */ 301 basic_block bb; 302 303 /* Operand cache for stmt. */ 304 struct stmt_operands_d GTY ((skip (""))) operands; 305 306 /* Set of variables that have had their address taken in the statement. */ 307 bitmap addresses_taken; 308 309 /* Unique identifier for this statement. These ID's are to be created 310 by each pass on an as-needed basis in any order convenient for the 311 pass which needs statement UIDs. */ 312 unsigned int uid; 313 314 /* Linked list of histograms for value-based profiling. This is really a 315 struct histogram_value*. We use void* to avoid having to export that 316 everywhere, and to avoid having to put it in GC memory. */ 317 318 void * GTY ((skip (""))) histograms; 319}; 320 321union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)"))) 322{ 323 struct tree_ann_common_d GTY((tag ("TREE_ANN_COMMON"))) common; 324 struct var_ann_d GTY((tag ("VAR_ANN"))) vdecl; 325 struct function_ann_d GTY((tag ("FUNCTION_ANN"))) fdecl; 326 struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt; 327}; 328 329extern GTY(()) VEC(tree,gc) *modified_noreturn_calls; 330 331typedef union tree_ann_d *tree_ann_t; 332typedef struct var_ann_d *var_ann_t; 333typedef struct function_ann_d *function_ann_t; 334typedef struct stmt_ann_d *stmt_ann_t; 335typedef struct tree_ann_common_d *tree_ann_common_t; 336 337static inline tree_ann_common_t tree_common_ann (tree); 338static inline tree_ann_common_t get_tree_common_ann (tree); 339static inline var_ann_t var_ann (tree); 340static inline var_ann_t get_var_ann (tree); 341static inline function_ann_t function_ann (tree); 342static inline function_ann_t get_function_ann (tree); 343static inline stmt_ann_t stmt_ann (tree); 344static inline stmt_ann_t get_stmt_ann (tree); 345static inline enum tree_ann_type ann_type (tree_ann_t); 346static inline basic_block bb_for_stmt (tree); 347extern void set_bb_for_stmt (tree, basic_block); 348static inline bool noreturn_call_p (tree); 349static inline void update_stmt (tree); 350static inline bool stmt_modified_p (tree); 351static inline VEC(tree, gc) *may_aliases (tree); 352static inline int get_lineno (tree); 353static inline const char *get_filename (tree); 354static inline bool is_exec_stmt (tree); 355static inline bool is_label_stmt (tree); 356static inline bitmap addresses_taken (tree); 357 358/*--------------------------------------------------------------------------- 359 Structure representing predictions in tree level. 360---------------------------------------------------------------------------*/ 361struct edge_prediction GTY((chain_next ("%h.ep_next"))) 362{ 363 struct edge_prediction *ep_next; 364 edge ep_edge; 365 enum br_predictor ep_predictor; 366 int ep_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 424/* Default defs for undefined symbols. */ 425extern GTY((param_is (struct int_tree_map))) htab_t default_defs; 426 427extern tree referenced_var_lookup (unsigned int); 428extern bool referenced_var_check_and_insert (tree); 429#define num_referenced_vars htab_elements (referenced_vars) 430#define referenced_var(i) referenced_var_lookup (i) 431 432/* Array of all SSA_NAMEs used in the function. */ 433extern GTY(()) VEC(tree,gc) *ssa_names; 434 435#define num_ssa_names (VEC_length (tree, ssa_names)) 436#define ssa_name(i) (VEC_index (tree, ssa_names, (i))) 437 438/* Artificial variable used to model the effects of function calls. */ 439extern GTY(()) tree global_var; 440 441/* Artificial variable used to model the effects of nonlocal 442 variables. */ 443extern GTY(()) tree nonlocal_all; 444 445/* Call clobbered variables in the function. If bit I is set, then 446 REFERENCED_VARS (I) is call-clobbered. */ 447extern bitmap call_clobbered_vars; 448 449/* Addressable variables in the function. If bit I is set, then 450 REFERENCED_VARS (I) has had its address taken. */ 451extern bitmap addressable_vars; 452 453/* 'true' after aliases have been computed (see compute_may_aliases). */ 454extern bool aliases_computed_p; 455 456/* Macros for showing usage statistics. */ 457#define SCALE(x) ((unsigned long) ((x) < 1024*10 \ 458 ? (x) \ 459 : ((x) < 1024*1024*10 \ 460 ? (x) / 1024 \ 461 : (x) / (1024*1024)))) 462 463#define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M')) 464 465#define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y)) 466 467/*--------------------------------------------------------------------------- 468 Block iterators 469---------------------------------------------------------------------------*/ 470 471typedef struct { 472 tree_stmt_iterator tsi; 473 basic_block bb; 474} block_stmt_iterator; 475 476static inline block_stmt_iterator bsi_start (basic_block); 477static inline block_stmt_iterator bsi_last (basic_block); 478static inline block_stmt_iterator bsi_after_labels (basic_block); 479block_stmt_iterator bsi_for_stmt (tree); 480static inline bool bsi_end_p (block_stmt_iterator); 481static inline void bsi_next (block_stmt_iterator *); 482static inline void bsi_prev (block_stmt_iterator *); 483static inline tree bsi_stmt (block_stmt_iterator); 484static inline tree * bsi_stmt_ptr (block_stmt_iterator); 485 486extern void bsi_remove (block_stmt_iterator *, bool); 487extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *); 488extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *); 489extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block); 490 491enum bsi_iterator_update 492{ 493 /* Note that these are intentionally in the same order as TSI_FOO. They 494 mean exactly the same as their TSI_* counterparts. */ 495 BSI_NEW_STMT, 496 BSI_SAME_STMT, 497 BSI_CHAIN_START, 498 BSI_CHAIN_END, 499 BSI_CONTINUE_LINKING 500}; 501 502extern void bsi_insert_before (block_stmt_iterator *, tree, 503 enum bsi_iterator_update); 504extern void bsi_insert_after (block_stmt_iterator *, tree, 505 enum bsi_iterator_update); 506 507extern void bsi_replace (const block_stmt_iterator *, tree, bool); 508 509/*--------------------------------------------------------------------------- 510 OpenMP Region Tree 511---------------------------------------------------------------------------*/ 512 513/* Parallel region information. Every parallel and workshare 514 directive is enclosed between two markers, the OMP_* directive 515 and a corresponding OMP_RETURN statement. */ 516 517struct omp_region 518{ 519 /* The enclosing region. */ 520 struct omp_region *outer; 521 522 /* First child region. */ 523 struct omp_region *inner; 524 525 /* Next peer region. */ 526 struct omp_region *next; 527 528 /* Block containing the omp directive as its last stmt. */ 529 basic_block entry; 530 531 /* Block containing the OMP_RETURN as its last stmt. */ 532 basic_block exit; 533 534 /* Block containing the OMP_CONTINUE as its last stmt. */ 535 basic_block cont; 536 537 /* If this is a combined parallel+workshare region, this is a list 538 of additional arguments needed by the combined parallel+workshare 539 library call. */ 540 tree ws_args; 541 542 /* The code for the omp directive of this region. */ 543 enum tree_code type; 544 545 /* Schedule kind, only used for OMP_FOR type regions. */ 546 enum omp_clause_schedule_kind sched_kind; 547 548 /* True if this is a combined parallel+workshare region. */ 549 bool is_combined_parallel; 550}; 551 552extern struct omp_region *root_omp_region; 553extern struct omp_region *new_omp_region (basic_block, enum tree_code, 554 struct omp_region *); 555extern void free_omp_regions (void); 556 557/*--------------------------------------------------------------------------- 558 Function prototypes 559---------------------------------------------------------------------------*/ 560/* In tree-cfg.c */ 561 562/* Location to track pending stmt for edge insertion. */ 563#define PENDING_STMT(e) ((e)->insns.t) 564 565extern void delete_tree_cfg_annotations (void); 566extern void disband_implicit_edges (void); 567extern bool stmt_ends_bb_p (tree); 568extern bool is_ctrl_stmt (tree); 569extern bool is_ctrl_altering_stmt (tree); 570extern bool computed_goto_p (tree); 571extern bool simple_goto_p (tree); 572extern bool tree_can_make_abnormal_goto (tree); 573extern basic_block single_noncomplex_succ (basic_block bb); 574extern void tree_dump_bb (basic_block, FILE *, int); 575extern void debug_tree_bb (basic_block); 576extern basic_block debug_tree_bb_n (int); 577extern void dump_tree_cfg (FILE *, int); 578extern void debug_tree_cfg (int); 579extern void dump_cfg_stats (FILE *); 580extern void debug_cfg_stats (void); 581extern void debug_loop_ir (void); 582extern void print_loop_ir (FILE *); 583extern void cleanup_dead_labels (void); 584extern void group_case_labels (void); 585extern tree first_stmt (basic_block); 586extern tree last_stmt (basic_block); 587extern tree *last_stmt_ptr (basic_block); 588extern tree last_and_only_stmt (basic_block); 589extern edge find_taken_edge (basic_block, tree); 590extern basic_block label_to_block_fn (struct function *, tree); 591#define label_to_block(t) (label_to_block_fn (cfun, t)) 592extern void bsi_insert_on_edge (edge, tree); 593extern basic_block bsi_insert_on_edge_immediate (edge, tree); 594extern void bsi_commit_one_edge_insert (edge, basic_block *); 595extern void bsi_commit_edge_inserts (void); 596extern void notice_special_calls (tree); 597extern void clear_special_calls (void); 598extern void verify_stmts (void); 599extern tree tree_block_label (basic_block); 600extern void extract_true_false_edges_from_block (basic_block, edge *, edge *); 601extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned, 602 basic_block *); 603extern void add_phi_args_after_copy_bb (basic_block); 604extern void add_phi_args_after_copy (basic_block *, unsigned); 605extern bool tree_purge_dead_abnormal_call_edges (basic_block); 606extern bool tree_purge_dead_eh_edges (basic_block); 607extern bool tree_purge_all_dead_eh_edges (bitmap); 608extern tree gimplify_val (block_stmt_iterator *, tree, tree); 609extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code, 610 tree, tree); 611extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code, 612 tree, tree, tree); 613extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code, 614 tree, tree, tree, tree); 615extern void init_empty_tree_cfg (void); 616extern void fold_cond_expr_cond (void); 617extern void make_abnormal_goto_edges (basic_block, bool); 618extern void replace_uses_by (tree, tree); 619extern void start_recording_case_labels (void); 620extern void end_recording_case_labels (void); 621extern basic_block move_sese_region_to_fn (struct function *, basic_block, 622 basic_block); 623 624/* In tree-cfgcleanup.c */ 625extern bool cleanup_tree_cfg (void); 626extern void cleanup_tree_cfg_loop (void); 627 628/* In tree-pretty-print.c. */ 629extern void dump_generic_bb (FILE *, basic_block, int, int); 630 631/* In tree-dfa.c */ 632extern var_ann_t create_var_ann (tree); 633extern function_ann_t create_function_ann (tree); 634extern stmt_ann_t create_stmt_ann (tree); 635extern tree_ann_common_t create_tree_common_ann (tree); 636extern void dump_dfa_stats (FILE *); 637extern void debug_dfa_stats (void); 638extern void debug_referenced_vars (void); 639extern void dump_referenced_vars (FILE *); 640extern void dump_variable (FILE *, tree); 641extern void debug_variable (tree); 642extern void dump_subvars_for (FILE *, tree); 643extern void debug_subvars_for (tree); 644extern tree get_virtual_var (tree); 645extern void add_referenced_var (tree); 646extern void mark_new_vars_to_rename (tree); 647extern void find_new_referenced_vars (tree *); 648 649extern tree make_rename_temp (tree, const char *); 650extern void set_default_def (tree, tree); 651extern tree default_def (tree); 652extern tree default_def_fn (struct function *, tree); 653 654/* In tree-phinodes.c */ 655extern void reserve_phi_args_for_new_edge (basic_block); 656extern tree create_phi_node (tree, basic_block); 657extern void add_phi_arg (tree, tree, edge); 658extern void remove_phi_args (edge); 659extern void remove_phi_node (tree, tree); 660extern tree phi_reverse (tree); 661 662/* In gimple-low.c */ 663extern void record_vars_into (tree, tree); 664extern void record_vars (tree); 665extern bool block_may_fallthru (tree); 666 667/* In tree-ssa-alias.c */ 668extern void dump_may_aliases_for (FILE *, tree); 669extern void debug_may_aliases_for (tree); 670extern void dump_alias_info (FILE *); 671extern void debug_alias_info (void); 672extern void dump_points_to_info (FILE *); 673extern void debug_points_to_info (void); 674extern void dump_points_to_info_for (FILE *, tree); 675extern void debug_points_to_info_for (tree); 676extern bool may_be_aliased (tree); 677extern bool is_aliased_with (tree, tree); 678extern bool may_aliases_intersect (tree, tree); 679extern struct ptr_info_def *get_ptr_info (tree); 680extern void new_type_alias (tree, tree, tree); 681extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *, bool *); 682static inline subvar_t get_subvars_for_var (tree); 683static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT); 684static inline bool ref_contains_array_ref (tree); 685static inline bool array_ref_contains_indirect_ref (tree); 686extern tree get_ref_base_and_extent (tree, HOST_WIDE_INT *, 687 HOST_WIDE_INT *, HOST_WIDE_INT *); 688static inline bool var_can_have_subvars (tree); 689static inline bool overlap_subvar (unsigned HOST_WIDE_INT, 690 unsigned HOST_WIDE_INT, 691 tree, bool *); 692 693/* Call-back function for walk_use_def_chains(). At each reaching 694 definition, a function with this prototype is called. */ 695typedef bool (*walk_use_def_chains_fn) (tree, tree, void *); 696 697/* In tree-ssa-alias-warnings.c */ 698extern void strict_aliasing_warning_backend (void); 699 700/* In tree-ssa.c */ 701extern void init_tree_ssa (void); 702extern edge ssa_redirect_edge (edge, basic_block); 703extern void flush_pending_stmts (edge); 704extern bool tree_ssa_useless_type_conversion (tree); 705extern bool tree_ssa_useless_type_conversion_1 (tree, tree); 706extern void verify_ssa (bool); 707extern void delete_tree_ssa (void); 708extern void register_new_def (tree, VEC(tree,heap) **); 709extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool); 710extern bool stmt_references_memory_p (tree); 711 712/* In tree-into-ssa.c */ 713void update_ssa (unsigned); 714void delete_update_ssa (void); 715void register_new_name_mapping (tree, tree); 716tree create_new_def_for (tree, tree, def_operand_p); 717bool need_ssa_update_p (void); 718bool name_registered_for_update_p (tree); 719bitmap ssa_names_to_replace (void); 720void release_ssa_name_after_update_ssa (tree name); 721void compute_global_livein (bitmap, bitmap); 722tree duplicate_ssa_name (tree, tree); 723void mark_sym_for_renaming (tree); 724void mark_set_for_renaming (bitmap); 725tree get_current_def (tree); 726void set_current_def (tree, tree); 727 728/* In tree-ssa-ccp.c */ 729bool fold_stmt (tree *); 730bool fold_stmt_inplace (tree); 731tree widen_bitfield (tree, tree, tree); 732 733/* In tree-vrp.c */ 734tree vrp_evaluate_conditional (tree, tree); 735void simplify_stmt_using_ranges (tree); 736 737/* In tree-ssa-dom.c */ 738extern void dump_dominator_optimization_stats (FILE *); 739extern void debug_dominator_optimization_stats (void); 740int loop_depth_of_name (tree); 741 742/* In tree-ssa-copy.c */ 743extern void merge_alias_info (tree, tree); 744extern void propagate_value (use_operand_p, tree); 745extern void propagate_tree_value (tree *, tree); 746extern void replace_exp (use_operand_p, tree); 747extern bool may_propagate_copy (tree, tree); 748extern bool may_propagate_copy_into_asm (tree); 749 750/* Affine iv. */ 751 752typedef struct 753{ 754 /* Iv = BASE + STEP * i. */ 755 tree base, step; 756 757 /* True if this iv does not overflow. */ 758 bool no_overflow; 759} affine_iv; 760 761/* Description of number of iterations of a loop. All the expressions inside 762 the structure can be evaluated at the end of the loop's preheader 763 (and due to ssa form, also anywhere inside the body of the loop). */ 764 765struct tree_niter_desc 766{ 767 tree assumptions; /* The boolean expression. If this expression evaluates 768 to false, then the other fields in this structure 769 should not be used; there is no guarantee that they 770 will be correct. */ 771 tree may_be_zero; /* The boolean expression. If it evaluates to true, 772 the loop will exit in the first iteration (i.e. 773 its latch will not be executed), even if the niter 774 field says otherwise. */ 775 tree niter; /* The expression giving the number of iterations of 776 a loop (provided that assumptions == true and 777 may_be_zero == false), more precisely the number 778 of executions of the latch of the loop. */ 779 tree additional_info; /* The boolean expression. Sometimes we use additional 780 knowledge to simplify the other expressions 781 contained in this structure (for example the 782 knowledge about value ranges of operands on entry to 783 the loop). If this is a case, conjunction of such 784 condition is stored in this field, so that we do not 785 lose the information: for example if may_be_zero 786 is (n <= 0) and niter is (unsigned) n, we know 787 that the number of iterations is at most 788 MAX_SIGNED_INT. However if the (n <= 0) assumption 789 is eliminated (by looking at the guard on entry of 790 the loop), then the information would be lost. */ 791 792 /* The simplified shape of the exit condition. The loop exits if 793 CONTROL CMP BOUND is false, where CMP is one of NE_EXPR, 794 LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is 795 LE_EXPR and negative if CMP is GE_EXPR. This information is used 796 by loop unrolling. */ 797 affine_iv control; 798 tree bound; 799 enum tree_code cmp; 800}; 801 802/* In tree-vectorizer.c */ 803void vectorize_loops (struct loops *); 804extern bool vect_can_force_dr_alignment_p (tree, unsigned int); 805extern tree get_vectype_for_scalar_type (tree); 806 807/* In tree-ssa-phiopt.c */ 808bool empty_block_p (basic_block); 809 810/* In tree-ssa-loop*.c */ 811 812void tree_ssa_lim (struct loops *); 813unsigned int tree_ssa_unswitch_loops (struct loops *); 814unsigned int canonicalize_induction_variables (struct loops *); 815unsigned int tree_unroll_loops_completely (struct loops *, bool); 816unsigned int tree_ssa_prefetch_arrays (struct loops *); 817unsigned int remove_empty_loops (struct loops *); 818void tree_ssa_iv_optimize (struct loops *); 819 820bool number_of_iterations_exit (struct loop *, edge, 821 struct tree_niter_desc *niter, bool); 822tree find_loop_niter (struct loop *, edge *); 823tree loop_niter_by_eval (struct loop *, edge); 824tree find_loop_niter_by_eval (struct loop *, edge *); 825void estimate_numbers_of_iterations (struct loops *); 826bool scev_probably_wraps_p (tree, tree, tree, struct loop *, bool); 827bool convert_affine_scev (struct loop *, tree, tree *, tree *, tree, bool); 828 829bool nowrap_type_p (tree); 830enum ev_direction {EV_DIR_GROWS, EV_DIR_DECREASES, EV_DIR_UNKNOWN}; 831enum ev_direction scev_direction (tree); 832 833void free_numbers_of_iterations_estimates (struct loops *); 834void free_numbers_of_iterations_estimates_loop (struct loop *); 835void rewrite_into_loop_closed_ssa (bitmap, unsigned); 836void verify_loop_closed_ssa (void); 837void loop_commit_inserts (void); 838bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *); 839void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool, 840 tree *, tree *); 841void split_loop_exit_edge (edge); 842unsigned force_expr_to_var_cost (tree); 843basic_block bsi_insert_on_edge_immediate_loop (edge, tree); 844void standard_iv_increment_position (struct loop *, block_stmt_iterator *, 845 bool *); 846basic_block ip_end_pos (struct loop *); 847basic_block ip_normal_pos (struct loop *); 848bool tree_duplicate_loop_to_header_edge (struct loop *, edge, struct loops *, 849 unsigned int, sbitmap, 850 edge, edge *, 851 unsigned int *, int); 852struct loop *tree_ssa_loop_version (struct loops *, struct loop *, tree, 853 basic_block *); 854tree expand_simple_operations (tree); 855void substitute_in_loop_info (struct loop *, tree, tree); 856edge single_dom_exit (struct loop *); 857bool can_unroll_loop_p (struct loop *loop, unsigned factor, 858 struct tree_niter_desc *niter); 859void tree_unroll_loop (struct loops *, struct loop *, unsigned, 860 edge, struct tree_niter_desc *); 861bool contains_abnormal_ssa_name_p (tree); 862 863/* In tree-ssa-threadedge.c */ 864extern bool potentially_threadable_block (basic_block); 865extern void thread_across_edge (tree, edge, bool, 866 VEC(tree, heap) **, tree (*) (tree, tree)); 867 868/* In tree-ssa-loop-im.c */ 869/* The possibilities of statement movement. */ 870 871enum move_pos 872 { 873 MOVE_IMPOSSIBLE, /* No movement -- side effect expression. */ 874 MOVE_PRESERVE_EXECUTION, /* Must not cause the non-executed statement 875 become executed -- memory accesses, ... */ 876 MOVE_POSSIBLE /* Unlimited movement. */ 877 }; 878extern enum move_pos movement_possibility (tree); 879 880/* The reasons a variable may escape a function. */ 881enum escape_type 882 { 883 NO_ESCAPE = 0, /* Doesn't escape. */ 884 ESCAPE_STORED_IN_GLOBAL = 1 << 1, 885 ESCAPE_TO_ASM = 1 << 2, /* Passed by address to an assembly 886 statement. */ 887 ESCAPE_TO_CALL = 1 << 3, /* Escapes to a function call. */ 888 ESCAPE_BAD_CAST = 1 << 4, /* Cast from pointer to integer */ 889 ESCAPE_TO_RETURN = 1 << 5, /* Returned from function. */ 890 ESCAPE_TO_PURE_CONST = 1 << 6, /* Escapes to a pure or constant 891 function call. */ 892 ESCAPE_IS_GLOBAL = 1 << 7, /* Is a global variable. */ 893 ESCAPE_IS_PARM = 1 << 8, /* Is an incoming function parameter. */ 894 ESCAPE_UNKNOWN = 1 << 9 /* We believe it escapes for some reason 895 not enumerated above. */ 896 }; 897 898/* In tree-flow-inline.h */ 899static inline bool is_call_clobbered (tree); 900static inline void mark_call_clobbered (tree, unsigned int); 901static inline void set_is_used (tree); 902static inline bool unmodifiable_var_p (tree); 903 904/* In tree-eh.c */ 905extern void make_eh_edges (tree); 906extern bool tree_could_trap_p (tree); 907extern bool tree_could_throw_p (tree); 908extern bool tree_can_throw_internal (tree); 909extern bool tree_can_throw_external (tree); 910extern int lookup_stmt_eh_region (tree); 911extern void add_stmt_to_eh_region (tree, int); 912extern bool remove_stmt_from_eh_region (tree); 913extern bool maybe_clean_or_replace_eh_stmt (tree, tree); 914 915/* In tree-ssa-pre.c */ 916void add_to_value (tree, tree); 917void debug_value_expressions (tree); 918void print_value_expressions (FILE *, tree); 919 920 921/* In tree-vn.c */ 922bool expressions_equal_p (tree, tree); 923tree get_value_handle (tree); 924hashval_t vn_compute (tree, hashval_t); 925void sort_vuses (VEC (tree, gc) *); 926tree vn_lookup_or_add (tree, tree); 927tree vn_lookup_or_add_with_vuses (tree, VEC (tree, gc) *); 928void vn_add (tree, tree); 929void vn_add_with_vuses (tree, tree, VEC (tree, gc) *); 930tree vn_lookup (tree, tree); 931tree vn_lookup_with_vuses (tree, VEC (tree, gc) *); 932void vn_init (void); 933void vn_delete (void); 934 935/* In tree-ssa-sink.c */ 936bool is_hidden_global_store (tree); 937 938/* In tree-sra.c */ 939void insert_edge_copies (tree, basic_block); 940void sra_insert_before (block_stmt_iterator *, tree); 941void sra_insert_after (block_stmt_iterator *, tree); 942void sra_init_cache (void); 943bool sra_type_can_be_decomposed_p (tree); 944 945/* In tree-loop-linear.c */ 946extern void linear_transform_loops (struct loops *); 947 948/* In tree-ssa-loop-ivopts.c */ 949bool expr_invariant_in_loop_p (struct loop *, tree); 950bool multiplier_allowed_in_address_p (HOST_WIDE_INT); 951unsigned multiply_by_cost (HOST_WIDE_INT, enum machine_mode); 952 953/* In tree-ssa-threadupdate.c. */ 954extern bool thread_through_all_blocks (void); 955extern void register_jump_thread (edge, edge); 956 957/* In gimplify.c */ 958tree force_gimple_operand (tree, tree *, bool, tree); 959tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree); 960 961/* In tree-ssa-structalias.c */ 962bool find_what_p_points_to (tree); 963 964/* In tree-ssa-live.c */ 965extern void remove_unused_locals (void); 966 967/* In tree-ssa-address.c */ 968 969/* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements 970 to make things simpler; this is sufficient in most cases. */ 971 972#define MAX_AFF_ELTS 8 973 974struct affine_tree_combination 975{ 976 /* Type of the result of the combination. */ 977 tree type; 978 979 /* Mask modulo that the operations are performed. */ 980 unsigned HOST_WIDE_INT mask; 981 982 /* Constant offset. */ 983 unsigned HOST_WIDE_INT offset; 984 985 /* Number of elements of the combination. */ 986 unsigned n; 987 988 /* Elements and their coefficients. */ 989 tree elts[MAX_AFF_ELTS]; 990 unsigned HOST_WIDE_INT coefs[MAX_AFF_ELTS]; 991 992 /* Remainder of the expression. */ 993 tree rest; 994}; 995 996/* Description of a memory address. */ 997 998struct mem_address 999{ 1000 tree symbol, base, index, step, offset; 1001}; 1002 1003tree create_mem_ref (block_stmt_iterator *, tree, 1004 struct affine_tree_combination *); 1005rtx addr_for_mem_ref (struct mem_address *, bool); 1006void get_address_description (tree, struct mem_address *); 1007tree maybe_fold_tmr (tree); 1008 1009/* This structure is simply used during pushing fields onto the fieldstack 1010 to track the offset of the field, since bitpos_of_field gives it relative 1011 to its immediate containing type, and we want it relative to the ultimate 1012 containing object. */ 1013 1014struct fieldoff 1015{ 1016 tree type; 1017 tree size; 1018 tree decl; 1019 HOST_WIDE_INT offset; 1020}; 1021typedef struct fieldoff fieldoff_s; 1022 1023DEF_VEC_O(fieldoff_s); 1024DEF_VEC_ALLOC_O(fieldoff_s,heap); 1025int push_fields_onto_fieldstack (tree, VEC(fieldoff_s,heap) **, 1026 HOST_WIDE_INT, bool *); 1027void sort_fieldstack (VEC(fieldoff_s,heap) *); 1028 1029void init_alias_heapvars (void); 1030void delete_alias_heapvars (void); 1031 1032#include "tree-flow-inline.h" 1033 1034void swap_tree_operands (tree, tree *, tree *); 1035 1036extern void recalculate_used_alone (void); 1037extern bool updating_used_alone; 1038#endif /* _TREE_FLOW_H */ 1039