00001 /* Instruction scheduling pass. This file contains definitions used 00002 internally in the scheduler. 00003 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 00004 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 00005 00006 This file is part of GCC. 00007 00008 GCC is free software; you can redistribute it and/or modify it under 00009 the terms of the GNU General Public License as published by the Free 00010 Software Foundation; either version 2, or (at your option) any later 00011 version. 00012 00013 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with GCC; see the file COPYING. If not, write to the Free 00020 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 00021 02110-1301, USA. */ 00022 00023 #ifndef GCC_SCHED_INT_H 00024 #define GCC_SCHED_INT_H 00025 00026 /* For state_t. */ 00027 #include "insn-attr.h" 00028 /* For regset_head. */ 00029 #include "basic-block.h" 00030 /* For reg_note. */ 00031 #include "rtl.h" 00032 00033 /* Pointer to data describing the current DFA state. */ 00034 extern state_t curr_state; 00035 00036 /* Forward declaration. */ 00037 struct ready_list; 00038 00039 /* Type to represent status of a dependence. */ 00040 typedef int ds_t; 00041 00042 /* Type to represent weakness of speculative dependence. */ 00043 typedef int dw_t; 00044 00045 /* Describe state of dependencies used during sched_analyze phase. */ 00046 struct deps 00047 { 00048 /* The *_insns and *_mems are paired lists. Each pending memory operation 00049 will have a pointer to the MEM rtx on one list and a pointer to the 00050 containing insn on the other list in the same place in the list. */ 00051 00052 /* We can't use add_dependence like the old code did, because a single insn 00053 may have multiple memory accesses, and hence needs to be on the list 00054 once for each memory access. Add_dependence won't let you add an insn 00055 to a list more than once. */ 00056 00057 /* An INSN_LIST containing all insns with pending read operations. */ 00058 rtx pending_read_insns; 00059 00060 /* An EXPR_LIST containing all MEM rtx's which are pending reads. */ 00061 rtx pending_read_mems; 00062 00063 /* An INSN_LIST containing all insns with pending write operations. */ 00064 rtx pending_write_insns; 00065 00066 /* An EXPR_LIST containing all MEM rtx's which are pending writes. */ 00067 rtx pending_write_mems; 00068 00069 /* Indicates the combined length of the two pending lists. We must prevent 00070 these lists from ever growing too large since the number of dependencies 00071 produced is at least O(N*N), and execution time is at least O(4*N*N), as 00072 a function of the length of these pending lists. */ 00073 int pending_lists_length; 00074 00075 /* Length of the pending memory flush list. Large functions with no 00076 calls may build up extremely large lists. */ 00077 int pending_flush_length; 00078 00079 /* The last insn upon which all memory references must depend. 00080 This is an insn which flushed the pending lists, creating a dependency 00081 between it and all previously pending memory references. This creates 00082 a barrier (or a checkpoint) which no memory reference is allowed to cross. 00083 00084 This includes all non constant CALL_INSNs. When we do interprocedural 00085 alias analysis, this restriction can be relaxed. 00086 This may also be an INSN that writes memory if the pending lists grow 00087 too large. */ 00088 rtx last_pending_memory_flush; 00089 00090 /* A list of the last function calls we have seen. We use a list to 00091 represent last function calls from multiple predecessor blocks. 00092 Used to prevent register lifetimes from expanding unnecessarily. */ 00093 rtx last_function_call; 00094 00095 /* A list of insns which use a pseudo register that does not already 00096 cross a call. We create dependencies between each of those insn 00097 and the next call insn, to ensure that they won't cross a call after 00098 scheduling is done. */ 00099 rtx sched_before_next_call; 00100 00101 /* Used to keep post-call pseudo/hard reg movements together with 00102 the call. */ 00103 enum { not_post_call, post_call, post_call_initial } in_post_call_group_p; 00104 00105 /* Set to the tail insn of the outermost libcall block. 00106 00107 When nonzero, we will mark each insn processed by sched_analyze_insn 00108 with SCHED_GROUP_P to ensure libcalls are scheduled as a unit. */ 00109 rtx libcall_block_tail_insn; 00110 00111 /* The maximum register number for the following arrays. Before reload 00112 this is max_reg_num; after reload it is FIRST_PSEUDO_REGISTER. */ 00113 int max_reg; 00114 00115 /* Element N is the next insn that sets (hard or pseudo) register 00116 N within the current basic block; or zero, if there is no 00117 such insn. Needed for new registers which may be introduced 00118 by splitting insns. */ 00119 struct deps_reg 00120 { 00121 rtx uses; 00122 rtx sets; 00123 rtx clobbers; 00124 int uses_length; 00125 int clobbers_length; 00126 } *reg_last; 00127 00128 /* Element N is set for each register that has any nonzero element 00129 in reg_last[N].{uses,sets,clobbers}. */ 00130 regset_head reg_last_in_use; 00131 00132 /* Element N is set for each register that is conditionally set. */ 00133 regset_head reg_conditional_sets; 00134 }; 00135 00136 /* This structure holds some state of the current scheduling pass, and 00137 contains some function pointers that abstract out some of the non-generic 00138 functionality from functions such as schedule_block or schedule_insn. 00139 There is one global variable, current_sched_info, which points to the 00140 sched_info structure currently in use. */ 00141 struct sched_info 00142 { 00143 /* Add all insns that are initially ready to the ready list. Called once 00144 before scheduling a set of insns. */ 00145 void (*init_ready_list) (void); 00146 /* Called after taking an insn from the ready list. Returns nonzero if 00147 this insn can be scheduled, nonzero if we should silently discard it. */ 00148 int (*can_schedule_ready_p) (rtx); 00149 /* Return nonzero if there are more insns that should be scheduled. */ 00150 int (*schedule_more_p) (void); 00151 /* Called after an insn has all its hard dependencies resolved. 00152 Adjusts status of instruction (which is passed through second parameter) 00153 to indicate if instruction should be moved to the ready list or the 00154 queue, or if it should silently discard it (until next resolved 00155 dependence). */ 00156 ds_t (*new_ready) (rtx, ds_t); 00157 /* Compare priority of two insns. Return a positive number if the second 00158 insn is to be preferred for scheduling, and a negative one if the first 00159 is to be preferred. Zero if they are equally good. */ 00160 int (*rank) (rtx, rtx); 00161 /* Return a string that contains the insn uid and optionally anything else 00162 necessary to identify this insn in an output. It's valid to use a 00163 static buffer for this. The ALIGNED parameter should cause the string 00164 to be formatted so that multiple output lines will line up nicely. */ 00165 const char *(*print_insn) (rtx, int); 00166 /* Return nonzero if an insn should be included in priority 00167 calculations. */ 00168 int (*contributes_to_priority) (rtx, rtx); 00169 /* Called when computing dependencies for a JUMP_INSN. This function 00170 should store the set of registers that must be considered as set by 00171 the jump in the regset. */ 00172 void (*compute_jump_reg_dependencies) (rtx, regset, regset, regset); 00173 00174 /* The boundaries of the set of insns to be scheduled. */ 00175 rtx prev_head, next_tail; 00176 00177 /* Filled in after the schedule is finished; the first and last scheduled 00178 insns. */ 00179 rtx head, tail; 00180 00181 /* If nonzero, enables an additional sanity check in schedule_block. */ 00182 unsigned int queue_must_finish_empty:1; 00183 /* Nonzero if we should use cselib for better alias analysis. This 00184 must be 0 if the dependency information is used after sched_analyze 00185 has completed, e.g. if we're using it to initialize state for successor 00186 blocks in region scheduling. */ 00187 unsigned int use_cselib:1; 00188 00189 /* Maximum priority that has been assigned to an insn. */ 00190 int sched_max_insns_priority; 00191 00192 /* Hooks to support speculative scheduling. */ 00193 00194 /* Called to notify frontend that instruction is being added (second 00195 parameter == 0) or removed (second parameter == 1). */ 00196 void (*add_remove_insn) (rtx, int); 00197 00198 /* Called to notify frontend that instruction is being scheduled. 00199 The first parameter - instruction to scheduled, the second parameter - 00200 last scheduled instruction. */ 00201 void (*begin_schedule_ready) (rtx, rtx); 00202 00203 /* Called to notify frontend, that new basic block is being added. 00204 The first parameter - new basic block. 00205 The second parameter - block, after which new basic block is being added, 00206 or EXIT_BLOCK_PTR, if recovery block is being added, 00207 or NULL, if standalone block is being added. */ 00208 void (*add_block) (basic_block, basic_block); 00209 00210 /* If the second parameter is not NULL, return nonnull value, if the 00211 basic block should be advanced. 00212 If the second parameter is NULL, return the next basic block in EBB. 00213 The first parameter is the current basic block in EBB. */ 00214 basic_block (*advance_target_bb) (basic_block, rtx); 00215 00216 /* Called after blocks were rearranged due to movement of jump instruction. 00217 The first parameter - index of basic block, in which jump currently is. 00218 The second parameter - index of basic block, in which jump used 00219 to be. 00220 The third parameter - index of basic block, that follows the second 00221 parameter. */ 00222 void (*fix_recovery_cfg) (int, int, int); 00223 00224 #ifdef ENABLE_CHECKING 00225 /* If the second parameter is zero, return nonzero, if block is head of the 00226 region. 00227 If the second parameter is nonzero, return nonzero, if block is leaf of 00228 the region. 00229 global_live_at_start should not change in region heads and 00230 global_live_at_end should not change in region leafs due to scheduling. */ 00231 int (*region_head_or_leaf_p) (basic_block, int); 00232 #endif 00233 00234 /* ??? FIXME: should use straight bitfields inside sched_info instead of 00235 this flag field. */ 00236 unsigned int flags; 00237 }; 00238 00239 /* This structure holds description of the properties for speculative 00240 scheduling. */ 00241 struct spec_info_def 00242 { 00243 /* Holds types of allowed speculations: BEGIN_{DATA|CONTROL}, 00244 BE_IN_{DATA_CONTROL}. */ 00245 int mask; 00246 00247 /* A dump file for additional information on speculative scheduling. */ 00248 FILE *dump; 00249 00250 /* Minimal cumulative weakness of speculative instruction's 00251 dependencies, so that insn will be scheduled. */ 00252 dw_t weakness_cutoff; 00253 00254 /* Flags from the enum SPEC_SCHED_FLAGS. */ 00255 int flags; 00256 }; 00257 typedef struct spec_info_def *spec_info_t; 00258 00259 extern struct sched_info *current_sched_info; 00260 00261 /* Indexed by INSN_UID, the collection of all data associated with 00262 a single instruction. */ 00263 00264 struct haifa_insn_data 00265 { 00266 /* A list of insns which depend on the instruction. Unlike LOG_LINKS, 00267 it represents forward dependencies. */ 00268 rtx depend; 00269 00270 /* A list of scheduled producers of the instruction. Links are being moved 00271 from LOG_LINKS to RESOLVED_DEPS during scheduling. */ 00272 rtx resolved_deps; 00273 00274 /* The line number note in effect for each insn. For line number 00275 notes, this indicates whether the note may be reused. */ 00276 rtx line_note; 00277 00278 /* Logical uid gives the original ordering of the insns. */ 00279 int luid; 00280 00281 /* A priority for each insn. */ 00282 int priority; 00283 00284 /* The number of incoming edges in the forward dependency graph. 00285 As scheduling proceeds, counts are decreased. An insn moves to 00286 the ready queue when its counter reaches zero. */ 00287 int dep_count; 00288 00289 /* Number of instructions referring to this insn. */ 00290 int ref_count; 00291 00292 /* The minimum clock tick at which the insn becomes ready. This is 00293 used to note timing constraints for the insns in the pending list. */ 00294 int tick; 00295 00296 /* INTER_TICK is used to adjust INSN_TICKs of instructions from the 00297 subsequent blocks in a region. */ 00298 int inter_tick; 00299 00300 /* See comment on QUEUE_INDEX macro in haifa-sched.c. */ 00301 int queue_index; 00302 00303 short cost; 00304 00305 /* This weight is an estimation of the insn's contribution to 00306 register pressure. */ 00307 short reg_weight; 00308 00309 /* Some insns (e.g. call) are not allowed to move across blocks. */ 00310 unsigned int cant_move : 1; 00311 00312 /* Set if there's DEF-USE dependence between some speculatively 00313 moved load insn and this one. */ 00314 unsigned int fed_by_spec_load : 1; 00315 unsigned int is_load_insn : 1; 00316 00317 /* Nonzero if priority has been computed already. */ 00318 unsigned int priority_known : 1; 00319 00320 /* Nonzero if instruction has internal dependence 00321 (e.g. add_dependence was invoked with (insn == elem)). */ 00322 unsigned int has_internal_dep : 1; 00323 00324 /* What speculations are necessary to apply to schedule the instruction. */ 00325 ds_t todo_spec; 00326 /* What speculations were already applied. */ 00327 ds_t done_spec; 00328 /* What speculations are checked by this instruction. */ 00329 ds_t check_spec; 00330 00331 /* Recovery block for speculation checks. */ 00332 basic_block recovery_block; 00333 00334 /* Original pattern of the instruction. */ 00335 rtx orig_pat; 00336 }; 00337 00338 extern struct haifa_insn_data *h_i_d; 00339 /* Used only if (current_sched_info->flags & USE_GLAT) != 0. 00340 These regsets store global_live_at_{start, end} information 00341 for each basic block. */ 00342 extern regset *glat_start, *glat_end; 00343 00344 /* Accessor macros for h_i_d. There are more in haifa-sched.c and 00345 sched-rgn.c. */ 00346 #define INSN_DEPEND(INSN) (h_i_d[INSN_UID (INSN)].depend) 00347 #define RESOLVED_DEPS(INSN) (h_i_d[INSN_UID (INSN)].resolved_deps) 00348 #define INSN_LUID(INSN) (h_i_d[INSN_UID (INSN)].luid) 00349 #define CANT_MOVE(insn) (h_i_d[INSN_UID (insn)].cant_move) 00350 #define INSN_DEP_COUNT(INSN) (h_i_d[INSN_UID (INSN)].dep_count) 00351 #define INSN_PRIORITY(INSN) (h_i_d[INSN_UID (INSN)].priority) 00352 #define INSN_PRIORITY_KNOWN(INSN) (h_i_d[INSN_UID (INSN)].priority_known) 00353 #define INSN_COST(INSN) (h_i_d[INSN_UID (INSN)].cost) 00354 #define INSN_REG_WEIGHT(INSN) (h_i_d[INSN_UID (INSN)].reg_weight) 00355 #define HAS_INTERNAL_DEP(INSN) (h_i_d[INSN_UID (INSN)].has_internal_dep) 00356 #define TODO_SPEC(INSN) (h_i_d[INSN_UID (INSN)].todo_spec) 00357 #define DONE_SPEC(INSN) (h_i_d[INSN_UID (INSN)].done_spec) 00358 #define CHECK_SPEC(INSN) (h_i_d[INSN_UID (INSN)].check_spec) 00359 #define RECOVERY_BLOCK(INSN) (h_i_d[INSN_UID (INSN)].recovery_block) 00360 #define ORIG_PAT(INSN) (h_i_d[INSN_UID (INSN)].orig_pat) 00361 00362 /* INSN is either a simple or a branchy speculation check. */ 00363 #define IS_SPECULATION_CHECK_P(INSN) (RECOVERY_BLOCK (INSN) != NULL) 00364 00365 /* INSN is a speculation check that will simply reexecute the speculatively 00366 scheduled instruction if the speculation fails. */ 00367 #define IS_SPECULATION_SIMPLE_CHECK_P(INSN) \ 00368 (RECOVERY_BLOCK (INSN) == EXIT_BLOCK_PTR) 00369 00370 /* INSN is a speculation check that will branch to RECOVERY_BLOCK if the 00371 speculation fails. Insns in that block will reexecute the speculatively 00372 scheduled code and then will return immediately after INSN thus preserving 00373 semantics of the program. */ 00374 #define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \ 00375 (RECOVERY_BLOCK (INSN) != NULL && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR) 00376 00377 /* DEP_STATUS of the link encapsulates information, that is needed for 00378 speculative scheduling. Namely, it is 4 integers in the range 00379 [0, MAX_DEP_WEAK] and 3 bits. 00380 The integers correspond to the probability of the dependence to *not* 00381 exist, it is the probability, that overcoming of this dependence will 00382 not be followed by execution of the recovery code. Nevertheless, 00383 whatever high the probability of success is, recovery code should still 00384 be generated to preserve semantics of the program. To find a way to 00385 get/set these integers, please refer to the {get, set}_dep_weak () 00386 functions in sched-deps.c . 00387 The 3 bits in the DEP_STATUS correspond to 3 dependence types: true-, 00388 output- and anti- dependence. It is not enough for speculative scheduling 00389 to know just the major type of all the dependence between two instructions, 00390 as only true dependence can be overcome. 00391 There also is the 4-th bit in the DEP_STATUS (HARD_DEP), that is reserved 00392 for using to describe instruction's status. It is set whenever instruction 00393 has at least one dependence, that cannot be overcome. 00394 See also: check_dep_status () in sched-deps.c . */ 00395 #define DEP_STATUS(LINK) XINT (LINK, 2) 00396 00397 /* We exclude sign bit. */ 00398 #define BITS_PER_DEP_STATUS (HOST_BITS_PER_INT - 1) 00399 00400 /* First '4' stands for 3 dep type bits and HARD_DEP bit. 00401 Second '4' stands for BEGIN_{DATA, CONTROL}, BE_IN_{DATA, CONTROL} 00402 dep weakness. */ 00403 #define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 4) / 4) 00404 00405 /* Mask of speculative weakness in dep_status. */ 00406 #define DEP_WEAK_MASK ((1 << BITS_PER_DEP_WEAK) - 1) 00407 00408 /* This constant means that dependence is fake with 99.999...% probability. 00409 This is the maximum value, that can appear in dep_status. 00410 Note, that we don't want MAX_DEP_WEAK to be the same as DEP_WEAK_MASK for 00411 debugging reasons. Though, it can be set to DEP_WEAK_MASK, and, when 00412 done so, we'll get fast (mul for)/(div by) NO_DEP_WEAK. */ 00413 #define MAX_DEP_WEAK (DEP_WEAK_MASK - 1) 00414 00415 /* This constant means that dependence is 99.999...% real and it is a really 00416 bad idea to overcome it (though this can be done, preserving program 00417 semantics). */ 00418 #define MIN_DEP_WEAK 1 00419 00420 /* This constant represents 100% probability. 00421 E.g. it is used to represent weakness of dependence, that doesn't exist. */ 00422 #define NO_DEP_WEAK (MAX_DEP_WEAK + MIN_DEP_WEAK) 00423 00424 /* Default weakness of speculative dependence. Used when we can't say 00425 neither bad nor good about the dependence. */ 00426 #define UNCERTAIN_DEP_WEAK (MAX_DEP_WEAK - MAX_DEP_WEAK / 4) 00427 00428 /* Offset for speculative weaknesses in dep_status. */ 00429 enum SPEC_TYPES_OFFSETS { 00430 BEGIN_DATA_BITS_OFFSET = 0, 00431 BE_IN_DATA_BITS_OFFSET = BEGIN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK, 00432 BEGIN_CONTROL_BITS_OFFSET = BE_IN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK, 00433 BE_IN_CONTROL_BITS_OFFSET = BEGIN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK 00434 }; 00435 00436 /* The following defines provide numerous constants used to distinguish between 00437 different types of speculative dependencies. */ 00438 00439 /* Dependence can be overcome with generation of new data speculative 00440 instruction. */ 00441 #define BEGIN_DATA (((ds_t) DEP_WEAK_MASK) << BEGIN_DATA_BITS_OFFSET) 00442 00443 /* This dependence is to the instruction in the recovery block, that was 00444 formed to recover after data-speculation failure. 00445 Thus, this dependence can overcome with generating of the copy of 00446 this instruction in the recovery block. */ 00447 #define BE_IN_DATA (((ds_t) DEP_WEAK_MASK) << BE_IN_DATA_BITS_OFFSET) 00448 00449 /* Dependence can be overcome with generation of new control speculative 00450 instruction. */ 00451 #define BEGIN_CONTROL (((ds_t) DEP_WEAK_MASK) << BEGIN_CONTROL_BITS_OFFSET) 00452 00453 /* This dependence is to the instruction in the recovery block, that was 00454 formed to recover after control-speculation failure. 00455 Thus, this dependence can be overcome with generating of the copy of 00456 this instruction in the recovery block. */ 00457 #define BE_IN_CONTROL (((ds_t) DEP_WEAK_MASK) << BE_IN_CONTROL_BITS_OFFSET) 00458 00459 /* A few convenient combinations. */ 00460 #define BEGIN_SPEC (BEGIN_DATA | BEGIN_CONTROL) 00461 #define DATA_SPEC (BEGIN_DATA | BE_IN_DATA) 00462 #define CONTROL_SPEC (BEGIN_CONTROL | BE_IN_CONTROL) 00463 #define SPECULATIVE (DATA_SPEC | CONTROL_SPEC) 00464 #define BE_IN_SPEC (BE_IN_DATA | BE_IN_CONTROL) 00465 00466 /* Constants, that are helpful in iterating through dep_status. */ 00467 #define FIRST_SPEC_TYPE BEGIN_DATA 00468 #define LAST_SPEC_TYPE BE_IN_CONTROL 00469 #define SPEC_TYPE_SHIFT BITS_PER_DEP_WEAK 00470 00471 /* Dependence on instruction can be of multiple types 00472 (e.g. true and output). This fields enhance REG_NOTE_KIND information 00473 of the dependence. */ 00474 #define DEP_TRUE (((ds_t) 1) << (BE_IN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK)) 00475 #define DEP_OUTPUT (DEP_TRUE << 1) 00476 #define DEP_ANTI (DEP_OUTPUT << 1) 00477 00478 #define DEP_TYPES (DEP_TRUE | DEP_OUTPUT | DEP_ANTI) 00479 00480 /* Instruction has non-speculative dependence. This bit represents the 00481 property of an instruction - not the one of a dependence. 00482 Therefore, it can appear only in TODO_SPEC field of an instruction. */ 00483 #define HARD_DEP (DEP_ANTI << 1) 00484 00485 /* This represents the results of calling sched-deps.c functions, 00486 which modify dependencies. Possible choices are: a dependence 00487 is already present and nothing has been changed; a dependence type 00488 has been changed; brand new dependence has been created. */ 00489 enum DEPS_ADJUST_RESULT { 00490 DEP_PRESENT = 1, 00491 DEP_CHANGED = 2, 00492 DEP_CREATED = 3 00493 }; 00494 00495 /* Represents the bits that can be set in the flags field of the 00496 sched_info structure. */ 00497 enum SCHED_FLAGS { 00498 /* If set, generate links between instruction as DEPS_LIST. 00499 Otherwise, generate usual INSN_LIST links. */ 00500 USE_DEPS_LIST = 1, 00501 /* Perform data or control (or both) speculation. 00502 Results in generation of data and control speculative dependencies. 00503 Requires USE_DEPS_LIST set. */ 00504 DO_SPECULATION = USE_DEPS_LIST << 1, 00505 SCHED_RGN = DO_SPECULATION << 1, 00506 SCHED_EBB = SCHED_RGN << 1, 00507 /* Detach register live information from basic block headers. 00508 This is necessary to invoke functions, that change CFG (e.g. split_edge). 00509 Requires USE_GLAT. */ 00510 DETACH_LIFE_INFO = SCHED_EBB << 1, 00511 /* Save register live information from basic block headers to 00512 glat_{start, end} arrays. */ 00513 USE_GLAT = DETACH_LIFE_INFO << 1 00514 }; 00515 00516 enum SPEC_SCHED_FLAGS { 00517 COUNT_SPEC_IN_CRITICAL_PATH = 1, 00518 PREFER_NON_DATA_SPEC = COUNT_SPEC_IN_CRITICAL_PATH << 1, 00519 PREFER_NON_CONTROL_SPEC = PREFER_NON_DATA_SPEC << 1 00520 }; 00521 00522 #define NOTE_NOT_BB_P(NOTE) (NOTE_P (NOTE) && (NOTE_LINE_NUMBER (NOTE) \ 00523 != NOTE_INSN_BASIC_BLOCK)) 00524 00525 extern FILE *sched_dump; 00526 extern int sched_verbose; 00527 00528 /* Exception Free Loads: 00529 00530 We define five classes of speculative loads: IFREE, IRISKY, 00531 PFREE, PRISKY, and MFREE. 00532 00533 IFREE loads are loads that are proved to be exception-free, just 00534 by examining the load insn. Examples for such loads are loads 00535 from TOC and loads of global data. 00536 00537 IRISKY loads are loads that are proved to be exception-risky, 00538 just by examining the load insn. Examples for such loads are 00539 volatile loads and loads from shared memory. 00540 00541 PFREE loads are loads for which we can prove, by examining other 00542 insns, that they are exception-free. Currently, this class consists 00543 of loads for which we are able to find a "similar load", either in 00544 the target block, or, if only one split-block exists, in that split 00545 block. Load2 is similar to load1 if both have same single base 00546 register. We identify only part of the similar loads, by finding 00547 an insn upon which both load1 and load2 have a DEF-USE dependence. 00548 00549 PRISKY loads are loads for which we can prove, by examining other 00550 insns, that they are exception-risky. Currently we have two proofs for 00551 such loads. The first proof detects loads that are probably guarded by a 00552 test on the memory address. This proof is based on the 00553 backward and forward data dependence information for the region. 00554 Let load-insn be the examined load. 00555 Load-insn is PRISKY iff ALL the following hold: 00556 00557 - insn1 is not in the same block as load-insn 00558 - there is a DEF-USE dependence chain (insn1, ..., load-insn) 00559 - test-insn is either a compare or a branch, not in the same block 00560 as load-insn 00561 - load-insn is reachable from test-insn 00562 - there is a DEF-USE dependence chain (insn1, ..., test-insn) 00563 00564 This proof might fail when the compare and the load are fed 00565 by an insn not in the region. To solve this, we will add to this 00566 group all loads that have no input DEF-USE dependence. 00567 00568 The second proof detects loads that are directly or indirectly 00569 fed by a speculative load. This proof is affected by the 00570 scheduling process. We will use the flag fed_by_spec_load. 00571 Initially, all insns have this flag reset. After a speculative 00572 motion of an insn, if insn is either a load, or marked as 00573 fed_by_spec_load, we will also mark as fed_by_spec_load every 00574 insn1 for which a DEF-USE dependence (insn, insn1) exists. A 00575 load which is fed_by_spec_load is also PRISKY. 00576 00577 MFREE (maybe-free) loads are all the remaining loads. They may be 00578 exception-free, but we cannot prove it. 00579 00580 Now, all loads in IFREE and PFREE classes are considered 00581 exception-free, while all loads in IRISKY and PRISKY classes are 00582 considered exception-risky. As for loads in the MFREE class, 00583 these are considered either exception-free or exception-risky, 00584 depending on whether we are pessimistic or optimistic. We have 00585 to take the pessimistic approach to assure the safety of 00586 speculative scheduling, but we can take the optimistic approach 00587 by invoking the -fsched_spec_load_dangerous option. */ 00588 00589 enum INSN_TRAP_CLASS 00590 { 00591 TRAP_FREE = 0, IFREE = 1, PFREE_CANDIDATE = 2, 00592 PRISKY_CANDIDATE = 3, IRISKY = 4, TRAP_RISKY = 5 00593 }; 00594 00595 #define WORST_CLASS(class1, class2) \ 00596 ((class1 > class2) ? class1 : class2) 00597 00598 #ifndef __GNUC__ 00599 #define __inline 00600 #endif 00601 00602 #ifndef HAIFA_INLINE 00603 #define HAIFA_INLINE __inline 00604 #endif 00605 00606 /* Functions in sched-vis.c. */ 00607 extern void print_insn (char *, rtx, int); 00608 00609 /* Functions in sched-deps.c. */ 00610 extern bool sched_insns_conditions_mutex_p (rtx, rtx); 00611 extern void add_dependence (rtx, rtx, enum reg_note); 00612 extern void sched_analyze (struct deps *, rtx, rtx); 00613 extern void init_deps (struct deps *); 00614 extern void free_deps (struct deps *); 00615 extern void init_deps_global (void); 00616 extern void finish_deps_global (void); 00617 extern void add_forw_dep (rtx, rtx); 00618 extern void compute_forward_dependences (rtx, rtx); 00619 extern rtx find_insn_list (rtx, rtx); 00620 extern void init_dependency_caches (int); 00621 extern void free_dependency_caches (void); 00622 extern void extend_dependency_caches (int, bool); 00623 extern enum DEPS_ADJUST_RESULT add_or_update_back_dep (rtx, rtx, 00624 enum reg_note, ds_t); 00625 extern void add_or_update_back_forw_dep (rtx, rtx, enum reg_note, ds_t); 00626 extern void add_back_forw_dep (rtx, rtx, enum reg_note, ds_t); 00627 extern void delete_back_forw_dep (rtx, rtx); 00628 extern dw_t get_dep_weak (ds_t, ds_t); 00629 extern ds_t set_dep_weak (ds_t, ds_t, dw_t); 00630 extern ds_t ds_merge (ds_t, ds_t); 00631 00632 /* Functions in haifa-sched.c. */ 00633 extern int haifa_classify_insn (rtx); 00634 extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *); 00635 extern int no_real_insns_p (rtx, rtx); 00636 00637 extern void rm_line_notes (rtx, rtx); 00638 extern void save_line_notes (int, rtx, rtx); 00639 extern void restore_line_notes (rtx, rtx); 00640 extern void rm_redundant_line_notes (void); 00641 extern void rm_other_notes (rtx, rtx); 00642 00643 extern int insn_cost (rtx, rtx, rtx); 00644 extern int set_priorities (rtx, rtx); 00645 00646 extern void schedule_block (basic_block *, int); 00647 extern void sched_init (void); 00648 extern void sched_finish (void); 00649 00650 extern int try_ready (rtx); 00651 extern void * xrecalloc (void *, size_t, size_t, size_t); 00652 extern void unlink_bb_notes (basic_block, basic_block); 00653 extern void add_block (basic_block, basic_block); 00654 extern void attach_life_info (void); 00655 extern rtx bb_note (basic_block); 00656 00657 #ifdef ENABLE_CHECKING 00658 extern void check_reg_live (bool); 00659 #endif 00660 00661 #endif /* GCC_SCHED_INT_H */
1.5.6