comparison gcc/sched-int.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Instruction scheduling pass. This file contains definitions used 1 /* Instruction scheduling pass. This file contains definitions used
2 internally in the scheduler. 2 internally in the scheduler.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3 Copyright (C) 1992-2017 Free Software Foundation, Inc.
4 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc.
6 4
7 This file is part of GCC. 5 This file is part of GCC.
8 6
9 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free 8 the terms of the GNU General Public License as published by the Free
23 #ifndef GCC_SCHED_INT_H 21 #ifndef GCC_SCHED_INT_H
24 #define GCC_SCHED_INT_H 22 #define GCC_SCHED_INT_H
25 23
26 #ifdef INSN_SCHEDULING 24 #ifdef INSN_SCHEDULING
27 25
28 /* For state_t. */
29 #include "insn-attr.h"
30 #include "df.h"
31 #include "basic-block.h"
32
33 /* For VEC (int, heap). */
34 #include "vecprim.h"
35
36 /* Identificator of a scheduler pass. */ 26 /* Identificator of a scheduler pass. */
37 enum sched_pass_id_t { SCHED_PASS_UNKNOWN, SCHED_RGN_PASS, SCHED_EBB_PASS, 27 enum sched_pass_id_t { SCHED_PASS_UNKNOWN, SCHED_RGN_PASS, SCHED_EBB_PASS,
38 SCHED_SMS_PASS, SCHED_SEL_PASS }; 28 SCHED_SMS_PASS, SCHED_SEL_PASS };
39 29
40 typedef VEC (basic_block, heap) *bb_vec_t; 30 /* The algorithm used to implement -fsched-pressure. */
41 typedef VEC (rtx, heap) *insn_vec_t; 31 enum sched_pressure_algorithm
42 typedef VEC(rtx, heap) *rtx_vec_t; 32 {
43 33 SCHED_PRESSURE_NONE,
44 struct sched_scan_info_def 34 SCHED_PRESSURE_WEIGHTED,
45 { 35 SCHED_PRESSURE_MODEL
46 /* This hook notifies scheduler frontend to extend its internal per basic 36 };
47 block data structures. This hook should be called once before a series of 37
48 calls to bb_init (). */ 38 typedef vec<basic_block> bb_vec_t;
49 void (*extend_bb) (void); 39 typedef vec<rtx_insn *> insn_vec_t;
50 40 typedef vec<rtx_insn *> rtx_vec_t;
51 /* This hook makes scheduler frontend to initialize its internal data
52 structures for the passed basic block. */
53 void (*init_bb) (basic_block);
54
55 /* This hook notifies scheduler frontend to extend its internal per insn data
56 structures. This hook should be called once before a series of calls to
57 insn_init (). */
58 void (*extend_insn) (void);
59
60 /* This hook makes scheduler frontend to initialize its internal data
61 structures for the passed insn. */
62 void (*init_insn) (rtx);
63 };
64
65 extern const struct sched_scan_info_def *sched_scan_info;
66
67 extern void sched_scan (const struct sched_scan_info_def *,
68 bb_vec_t, basic_block, insn_vec_t, rtx);
69 41
70 extern void sched_init_bbs (void); 42 extern void sched_init_bbs (void);
71 43
72 extern void sched_init_luids (bb_vec_t, basic_block, insn_vec_t, rtx); 44 extern void sched_extend_luids (void);
45 extern void sched_init_insn_luid (rtx_insn *);
46 extern void sched_init_luids (bb_vec_t);
73 extern void sched_finish_luids (void); 47 extern void sched_finish_luids (void);
74 48
75 extern void sched_extend_target (void); 49 extern void sched_extend_target (void);
76 50
77 extern void haifa_init_h_i_d (bb_vec_t, basic_block, insn_vec_t, rtx); 51 extern void haifa_init_h_i_d (bb_vec_t);
78 extern void haifa_finish_h_i_d (void); 52 extern void haifa_finish_h_i_d (void);
79 53
80 /* Hooks that are common to all the schedulers. */ 54 /* Hooks that are common to all the schedulers. */
81 struct common_sched_info_def 55 struct common_sched_info_def
82 { 56 {
89 void (*fix_recovery_cfg) (int, int, int); 63 void (*fix_recovery_cfg) (int, int, int);
90 64
91 /* Called to notify frontend, that new basic block is being added. 65 /* Called to notify frontend, that new basic block is being added.
92 The first parameter - new basic block. 66 The first parameter - new basic block.
93 The second parameter - block, after which new basic block is being added, 67 The second parameter - block, after which new basic block is being added,
94 or EXIT_BLOCK_PTR, if recovery block is being added, 68 or the exit block, if recovery block is being added,
95 or NULL, if standalone block is being added. */ 69 or NULL, if standalone block is being added. */
96 void (*add_block) (basic_block, basic_block); 70 void (*add_block) (basic_block, basic_block);
97 71
98 /* Estimate number of insns in the basic block. */ 72 /* Estimate number of insns in the basic block. */
99 int (*estimate_number_of_insns) (basic_block); 73 int (*estimate_number_of_insns) (basic_block);
124 98
125 /* Increases effective priority for INSN by AMOUNT. */ 99 /* Increases effective priority for INSN by AMOUNT. */
126 extern void sel_add_to_insn_priority (rtx, int); 100 extern void sel_add_to_insn_priority (rtx, int);
127 101
128 /* True if during selective scheduling we need to emulate some of haifa 102 /* True if during selective scheduling we need to emulate some of haifa
129 scheduler behaviour. */ 103 scheduler behavior. */
130 extern int sched_emulate_haifa_p; 104 extern int sched_emulate_haifa_p;
131 105
132 /* Mapping from INSN_UID to INSN_LUID. In the end all other per insn data 106 /* Mapping from INSN_UID to INSN_LUID. In the end all other per insn data
133 structures should be indexed by luid. */ 107 structures should be indexed by luid. */
134 extern VEC (int, heap) *sched_luids; 108 extern vec<int> sched_luids;
135 #define INSN_LUID(INSN) (VEC_index (int, sched_luids, INSN_UID (INSN))) 109 #define INSN_LUID(INSN) (sched_luids[INSN_UID (INSN)])
136 #define LUID_BY_UID(UID) (VEC_index (int, sched_luids, UID)) 110 #define LUID_BY_UID(UID) (sched_luids[UID])
137 111
138 #define SET_INSN_LUID(INSN, LUID) \ 112 #define SET_INSN_LUID(INSN, LUID) \
139 (VEC_replace (int, sched_luids, INSN_UID (INSN), (LUID))) 113 (sched_luids[INSN_UID (INSN)] = (LUID))
140 114
141 /* The highest INSN_LUID. */ 115 /* The highest INSN_LUID. */
142 extern int sched_max_luid; 116 extern int sched_max_luid;
143 117
144 extern int insn_luid (rtx); 118 extern int insn_luid (rtx);
145 119
146 /* This list holds ripped off notes from the current block. These notes will 120 /* This list holds ripped off notes from the current block. These notes will
147 be attached to the beginning of the block when its scheduling is 121 be attached to the beginning of the block when its scheduling is
148 finished. */ 122 finished. */
149 extern rtx note_list; 123 extern rtx_insn *note_list;
150 124
151 extern void remove_notes (rtx, rtx); 125 extern void remove_notes (rtx_insn *, rtx_insn *);
152 extern rtx restore_other_notes (rtx, basic_block); 126 extern rtx_insn *restore_other_notes (rtx_insn *, basic_block);
153 extern void sched_insns_init (rtx); 127 extern void sched_insns_init (rtx);
154 extern void sched_insns_finish (void); 128 extern void sched_insns_finish (void);
155 129
156 extern void *xrecalloc (void *, size_t, size_t, size_t); 130 extern void *xrecalloc (void *, size_t, size_t, size_t);
157 extern rtx bb_note (basic_block); 131
158 132 extern void reemit_notes (rtx_insn *);
159 extern void reemit_notes (rtx);
160 133
161 /* Functions in haifa-sched.c. */ 134 /* Functions in haifa-sched.c. */
162 extern int haifa_classify_insn (const_rtx); 135 extern int haifa_classify_insn (const_rtx);
163 136
164 /* Functions in sel-sched-ir.c. */ 137 /* Functions in sel-sched-ir.c. */
183 priority. 156 priority.
184 N_READY determines how many insns are on the ready list. 157 N_READY determines how many insns are on the ready list.
185 N_DEBUG determines how many debug insns are on the ready list. */ 158 N_DEBUG determines how many debug insns are on the ready list. */
186 struct ready_list 159 struct ready_list
187 { 160 {
188 rtx *vec; 161 rtx_insn **vec;
189 int veclen; 162 int veclen;
190 int first; 163 int first;
191 int n_ready; 164 int n_ready;
192 int n_debug; 165 int n_debug;
193 }; 166 };
194 167
195 extern char *ready_try; 168 extern signed char *ready_try;
196 extern struct ready_list ready; 169 extern struct ready_list ready;
197 170
198 extern int max_issue (struct ready_list *, int, state_t, bool, int *); 171 extern int max_issue (struct ready_list *, int, state_t, bool, int *);
199 172
200 extern void ebb_compute_jump_reg_dependencies (rtx, regset, regset, regset); 173 extern void ebb_compute_jump_reg_dependencies (rtx, regset);
201 174
202 extern edge find_fallthru_edge_from (basic_block); 175 extern edge find_fallthru_edge_from (basic_block);
203 176
204 extern void (* sched_init_only_bb) (basic_block, basic_block); 177 extern void (* sched_init_only_bb) (basic_block, basic_block);
205 extern basic_block (* sched_split_block) (basic_block, rtx); 178 extern basic_block (* sched_split_block) (basic_block, rtx);
213 186
214 /* Pointer to data describing the current DFA state. */ 187 /* Pointer to data describing the current DFA state. */
215 extern state_t curr_state; 188 extern state_t curr_state;
216 189
217 /* Type to represent status of a dependence. */ 190 /* Type to represent status of a dependence. */
218 typedef int ds_t; 191 typedef unsigned int ds_t;
192 #define BITS_PER_DEP_STATUS HOST_BITS_PER_INT
219 193
220 /* Type to represent weakness of speculative dependence. */ 194 /* Type to represent weakness of speculative dependence. */
221 typedef int dw_t; 195 typedef unsigned int dw_t;
222 196
223 extern enum reg_note ds_to_dk (ds_t); 197 extern enum reg_note ds_to_dk (ds_t);
224 extern ds_t dk_to_ds (enum reg_note); 198 extern ds_t dk_to_ds (enum reg_note);
225 199
200 /* Describe a dependency that can be broken by making a replacement
201 in one of the patterns. LOC is the location, ORIG and NEWVAL the
202 two alternative contents, and INSN the instruction that must be
203 changed. */
204 struct dep_replacement
205 {
206 rtx *loc;
207 rtx orig;
208 rtx newval;
209 rtx_insn *insn;
210 };
211
226 /* Information about the dependency. */ 212 /* Information about the dependency. */
227 struct _dep 213 struct _dep
228 { 214 {
229 /* Producer. */ 215 /* Producer. */
230 rtx pro; 216 rtx_insn *pro;
231 217
232 /* Consumer. */ 218 /* Consumer. */
233 rtx con; 219 rtx_insn *con;
234 220
235 /* Dependency major type. This field is superseded by STATUS below. 221 /* If nonnull, holds a pointer to information about how to break the
236 Though, it is still in place because some targets use it. */ 222 dependency by making a replacement in one of the insns. There is
237 enum reg_note type; 223 only one such dependency for each insn that must be modified in
224 order to break such a dependency. */
225 struct dep_replacement *replace;
238 226
239 /* Dependency status. This field holds all dependency types and additional 227 /* Dependency status. This field holds all dependency types and additional
240 information for speculative dependencies. */ 228 information for speculative dependencies. */
241 ds_t status; 229 ds_t status;
242 }; 230
231 /* Dependency major type. This field is superseded by STATUS above.
232 Though, it is still in place because some targets use it. */
233 ENUM_BITFIELD(reg_note) type:6;
234
235 unsigned nonreg:1;
236 unsigned multiple:1;
237
238 /* Cached cost of the dependency. Make sure to update UNKNOWN_DEP_COST
239 when changing the size of this field. */
240 int cost:20;
241 };
242
243 #define UNKNOWN_DEP_COST ((int) ((unsigned int) -1 << 19))
243 244
244 typedef struct _dep dep_def; 245 typedef struct _dep dep_def;
245 typedef dep_def *dep_t; 246 typedef dep_def *dep_t;
246 247
247 #define DEP_PRO(D) ((D)->pro) 248 #define DEP_PRO(D) ((D)->pro)
248 #define DEP_CON(D) ((D)->con) 249 #define DEP_CON(D) ((D)->con)
249 #define DEP_TYPE(D) ((D)->type) 250 #define DEP_TYPE(D) ((D)->type)
250 #define DEP_STATUS(D) ((D)->status) 251 #define DEP_STATUS(D) ((D)->status)
252 #define DEP_COST(D) ((D)->cost)
253 #define DEP_NONREG(D) ((D)->nonreg)
254 #define DEP_MULTIPLE(D) ((D)->multiple)
255 #define DEP_REPLACE(D) ((D)->replace)
251 256
252 /* Functions to work with dep. */ 257 /* Functions to work with dep. */
253 258
254 extern void init_dep_1 (dep_t, rtx, rtx, enum reg_note, ds_t); 259 extern void init_dep_1 (dep_t, rtx_insn *, rtx_insn *, enum reg_note, ds_t);
255 extern void init_dep (dep_t, rtx, rtx, enum reg_note); 260 extern void init_dep (dep_t, rtx_insn *, rtx_insn *, enum reg_note);
256 261
257 extern void sd_debug_dep (dep_t); 262 extern void sd_debug_dep (dep_t);
258 263
259 /* Definition of this struct resides below. */ 264 /* Definition of this struct resides below. */
260 struct _dep_node; 265 struct _dep_node;
437 }; 442 };
438 443
439 /* Insns which affect pseudo-registers. */ 444 /* Insns which affect pseudo-registers. */
440 struct deps_reg 445 struct deps_reg
441 { 446 {
442 rtx uses; 447 rtx_insn_list *uses;
443 rtx sets; 448 rtx_insn_list *sets;
444 rtx implicit_sets; 449 rtx_insn_list *implicit_sets;
445 rtx clobbers; 450 rtx_insn_list *control_uses;
451 rtx_insn_list *clobbers;
446 int uses_length; 452 int uses_length;
447 int clobbers_length; 453 int clobbers_length;
448 }; 454 };
449 455
450 /* Describe state of dependencies used during sched_analyze phase. */ 456 /* Describe state of dependencies used during sched_analyze phase. */
458 may have multiple memory accesses, and hence needs to be on the list 464 may have multiple memory accesses, and hence needs to be on the list
459 once for each memory access. Add_dependence won't let you add an insn 465 once for each memory access. Add_dependence won't let you add an insn
460 to a list more than once. */ 466 to a list more than once. */
461 467
462 /* An INSN_LIST containing all insns with pending read operations. */ 468 /* An INSN_LIST containing all insns with pending read operations. */
463 rtx pending_read_insns; 469 rtx_insn_list *pending_read_insns;
464 470
465 /* An EXPR_LIST containing all MEM rtx's which are pending reads. */ 471 /* An EXPR_LIST containing all MEM rtx's which are pending reads. */
466 rtx pending_read_mems; 472 rtx_expr_list *pending_read_mems;
467 473
468 /* An INSN_LIST containing all insns with pending write operations. */ 474 /* An INSN_LIST containing all insns with pending write operations. */
469 rtx pending_write_insns; 475 rtx_insn_list *pending_write_insns;
470 476
471 /* An EXPR_LIST containing all MEM rtx's which are pending writes. */ 477 /* An EXPR_LIST containing all MEM rtx's which are pending writes. */
472 rtx pending_write_mems; 478 rtx_expr_list *pending_write_mems;
479
480 /* An INSN_LIST containing all jump insns. */
481 rtx_insn_list *pending_jump_insns;
473 482
474 /* We must prevent the above lists from ever growing too large since 483 /* We must prevent the above lists from ever growing too large since
475 the number of dependencies produced is at least O(N*N), 484 the number of dependencies produced is at least O(N*N),
476 and execution time is at least O(4*N*N), as a function of the 485 and execution time is at least O(4*N*N), as a function of the
477 length of these pending lists. */ 486 length of these pending lists. */
480 int pending_read_list_length; 489 int pending_read_list_length;
481 490
482 /* Indicates the length of the pending_write list. */ 491 /* Indicates the length of the pending_write list. */
483 int pending_write_list_length; 492 int pending_write_list_length;
484 493
485 /* Length of the pending memory flush list. Large functions with no 494 /* Length of the pending memory flush list plus the length of the pending
486 calls may build up extremely large lists. */ 495 jump insn list. Large functions with no calls may build up extremely
496 large lists. */
487 int pending_flush_length; 497 int pending_flush_length;
488 498
489 /* The last insn upon which all memory references must depend. 499 /* The last insn upon which all memory references must depend.
490 This is an insn which flushed the pending lists, creating a dependency 500 This is an insn which flushed the pending lists, creating a dependency
491 between it and all previously pending memory references. This creates 501 between it and all previously pending memory references. This creates
493 503
494 This includes all non constant CALL_INSNs. When we do interprocedural 504 This includes all non constant CALL_INSNs. When we do interprocedural
495 alias analysis, this restriction can be relaxed. 505 alias analysis, this restriction can be relaxed.
496 This may also be an INSN that writes memory if the pending lists grow 506 This may also be an INSN that writes memory if the pending lists grow
497 too large. */ 507 too large. */
498 rtx last_pending_memory_flush; 508 rtx_insn_list *last_pending_memory_flush;
499 509
500 /* A list of the last function calls we have seen. We use a list to 510 /* A list of the last function calls we have seen. We use a list to
501 represent last function calls from multiple predecessor blocks. 511 represent last function calls from multiple predecessor blocks.
502 Used to prevent register lifetimes from expanding unnecessarily. */ 512 Used to prevent register lifetimes from expanding unnecessarily. */
503 rtx last_function_call; 513 rtx_insn_list *last_function_call;
504 514
505 /* A list of the last function calls that may not return normally 515 /* A list of the last function calls that may not return normally
506 we have seen. We use a list to represent last function calls from 516 we have seen. We use a list to represent last function calls from
507 multiple predecessor blocks. Used to prevent moving trapping insns 517 multiple predecessor blocks. Used to prevent moving trapping insns
508 across such calls. */ 518 across such calls. */
509 rtx last_function_call_may_noreturn; 519 rtx_insn_list *last_function_call_may_noreturn;
510 520
511 /* A list of insns which use a pseudo register that does not already 521 /* A list of insns which use a pseudo register that does not already
512 cross a call. We create dependencies between each of those insn 522 cross a call. We create dependencies between each of those insn
513 and the next call insn, to ensure that they won't cross a call after 523 and the next call insn, to ensure that they won't cross a call after
514 scheduling is done. */ 524 scheduling is done. */
515 rtx sched_before_next_call; 525 rtx_insn_list *sched_before_next_call;
526
527 /* Similarly, a list of insns which should not cross a branch. */
528 rtx_insn_list *sched_before_next_jump;
516 529
517 /* Used to keep post-call pseudo/hard reg movements together with 530 /* Used to keep post-call pseudo/hard reg movements together with
518 the call. */ 531 the call. */
519 enum post_call_group in_post_call_group_p; 532 enum post_call_group in_post_call_group_p;
520 533
521 /* The last debug insn we've seen. */ 534 /* The last debug insn we've seen. */
522 rtx last_debug_insn; 535 rtx_insn *last_debug_insn;
536
537 /* The last insn bearing REG_ARGS_SIZE that we've seen. */
538 rtx_insn *last_args_size;
539
540 /* A list of all prologue insns we have seen without intervening epilogue
541 insns, and one of all epilogue insns we have seen without intervening
542 prologue insns. This is used to prevent mixing prologue and epilogue
543 insns. See PR78029. */
544 rtx_insn_list *last_prologue;
545 rtx_insn_list *last_epilogue;
546
547 /* Whether the last *logue insn was an epilogue insn or a prologue insn
548 instead. */
549 bool last_logue_was_epilogue;
523 550
524 /* The maximum register number for the following arrays. Before reload 551 /* The maximum register number for the following arrays. Before reload
525 this is max_reg_num; after reload it is FIRST_PSEUDO_REGISTER. */ 552 this is max_reg_num; after reload it is FIRST_PSEUDO_REGISTER. */
526 int max_reg; 553 int max_reg;
527 554
532 struct deps_reg *reg_last; 559 struct deps_reg *reg_last;
533 560
534 /* Element N is set for each register that has any nonzero element 561 /* Element N is set for each register that has any nonzero element
535 in reg_last[N].{uses,sets,clobbers}. */ 562 in reg_last[N].{uses,sets,clobbers}. */
536 regset_head reg_last_in_use; 563 regset_head reg_last_in_use;
537
538 /* Element N is set for each register that is conditionally set. */
539 regset_head reg_conditional_sets;
540 564
541 /* Shows the last value of reg_pending_barrier associated with the insn. */ 565 /* Shows the last value of reg_pending_barrier associated with the insn. */
542 enum reg_pending_barrier_mode last_reg_pending_barrier; 566 enum reg_pending_barrier_mode last_reg_pending_barrier;
543 567
544 /* True when this context should be treated as a readonly by 568 /* True when this context should be treated as a readonly by
558 /* Add all insns that are initially ready to the ready list. Called once 582 /* Add all insns that are initially ready to the ready list. Called once
559 before scheduling a set of insns. */ 583 before scheduling a set of insns. */
560 void (*init_ready_list) (void); 584 void (*init_ready_list) (void);
561 /* Called after taking an insn from the ready list. Returns nonzero if 585 /* Called after taking an insn from the ready list. Returns nonzero if
562 this insn can be scheduled, nonzero if we should silently discard it. */ 586 this insn can be scheduled, nonzero if we should silently discard it. */
563 int (*can_schedule_ready_p) (rtx); 587 int (*can_schedule_ready_p) (rtx_insn *);
564 /* Return nonzero if there are more insns that should be scheduled. */ 588 /* Return nonzero if there are more insns that should be scheduled. */
565 int (*schedule_more_p) (void); 589 int (*schedule_more_p) (void);
566 /* Called after an insn has all its hard dependencies resolved. 590 /* Called after an insn has all its hard dependencies resolved.
567 Adjusts status of instruction (which is passed through second parameter) 591 Adjusts status of instruction (which is passed through second parameter)
568 to indicate if instruction should be moved to the ready list or the 592 to indicate if instruction should be moved to the ready list or the
569 queue, or if it should silently discard it (until next resolved 593 queue, or if it should silently discard it (until next resolved
570 dependence). */ 594 dependence). */
571 ds_t (*new_ready) (rtx, ds_t); 595 ds_t (*new_ready) (rtx_insn *, ds_t);
572 /* Compare priority of two insns. Return a positive number if the second 596 /* Compare priority of two insns. Return a positive number if the second
573 insn is to be preferred for scheduling, and a negative one if the first 597 insn is to be preferred for scheduling, and a negative one if the first
574 is to be preferred. Zero if they are equally good. */ 598 is to be preferred. Zero if they are equally good. */
575 int (*rank) (rtx, rtx); 599 int (*rank) (rtx_insn *, rtx_insn *);
576 /* Return a string that contains the insn uid and optionally anything else 600 /* Return a string that contains the insn uid and optionally anything else
577 necessary to identify this insn in an output. It's valid to use a 601 necessary to identify this insn in an output. It's valid to use a
578 static buffer for this. The ALIGNED parameter should cause the string 602 static buffer for this. The ALIGNED parameter should cause the string
579 to be formatted so that multiple output lines will line up nicely. */ 603 to be formatted so that multiple output lines will line up nicely. */
580 const char *(*print_insn) (const_rtx, int); 604 const char *(*print_insn) (const rtx_insn *, int);
581 /* Return nonzero if an insn should be included in priority 605 /* Return nonzero if an insn should be included in priority
582 calculations. */ 606 calculations. */
583 int (*contributes_to_priority) (rtx, rtx); 607 int (*contributes_to_priority) (rtx_insn *, rtx_insn *);
584 608
585 /* Return true if scheduling insn (passed as the parameter) will trigger 609 /* Return true if scheduling insn (passed as the parameter) will trigger
586 finish of scheduling current block. */ 610 finish of scheduling current block. */
587 bool (*insn_finishes_block_p) (rtx); 611 bool (*insn_finishes_block_p) (rtx_insn *);
588 612
589 /* The boundaries of the set of insns to be scheduled. */ 613 /* The boundaries of the set of insns to be scheduled. */
590 rtx prev_head, next_tail; 614 rtx_insn *prev_head, *next_tail;
591 615
592 /* Filled in after the schedule is finished; the first and last scheduled 616 /* Filled in after the schedule is finished; the first and last scheduled
593 insns. */ 617 insns. */
594 rtx head, tail; 618 rtx_insn *head, *tail;
595 619
596 /* If nonzero, enables an additional sanity check in schedule_block. */ 620 /* If nonzero, enables an additional sanity check in schedule_block. */
597 unsigned int queue_must_finish_empty:1; 621 unsigned int queue_must_finish_empty:1;
598 622
599 /* Maximum priority that has been assigned to an insn. */ 623 /* Maximum priority that has been assigned to an insn. */
601 625
602 /* Hooks to support speculative scheduling. */ 626 /* Hooks to support speculative scheduling. */
603 627
604 /* Called to notify frontend that instruction is being added (second 628 /* Called to notify frontend that instruction is being added (second
605 parameter == 0) or removed (second parameter == 1). */ 629 parameter == 0) or removed (second parameter == 1). */
606 void (*add_remove_insn) (rtx, int); 630 void (*add_remove_insn) (rtx_insn *, int);
607 631
608 /* Called to notify frontend that instruction is being scheduled. 632 /* Called to notify the frontend that instruction INSN is being
609 The first parameter - instruction to scheduled, the second parameter - 633 scheduled. */
610 last scheduled instruction. */ 634 void (*begin_schedule_ready) (rtx_insn *insn);
611 void (*begin_schedule_ready) (rtx, rtx); 635
636 /* Called to notify the frontend that an instruction INSN is about to be
637 moved to its correct place in the final schedule. This is done for all
638 insns in order of the schedule. LAST indicates the last scheduled
639 instruction. */
640 void (*begin_move_insn) (rtx_insn *insn, rtx_insn *last);
612 641
613 /* If the second parameter is not NULL, return nonnull value, if the 642 /* If the second parameter is not NULL, return nonnull value, if the
614 basic block should be advanced. 643 basic block should be advanced.
615 If the second parameter is NULL, return the next basic block in EBB. 644 If the second parameter is NULL, return the next basic block in EBB.
616 The first parameter is the current basic block in EBB. */ 645 The first parameter is the current basic block in EBB. */
617 basic_block (*advance_target_bb) (basic_block, rtx); 646 basic_block (*advance_target_bb) (basic_block, rtx_insn *);
647
648 /* Allocate memory, store the frontend scheduler state in it, and
649 return it. */
650 void *(*save_state) (void);
651 /* Restore frontend scheduler state from the argument, and free the
652 memory. */
653 void (*restore_state) (void *);
618 654
619 /* ??? FIXME: should use straight bitfields inside sched_info instead of 655 /* ??? FIXME: should use straight bitfields inside sched_info instead of
620 this flag field. */ 656 this flag field. */
621 unsigned int flags; 657 unsigned int flags;
622 }; 658 };
649 685
650 extern struct haifa_sched_info *current_sched_info; 686 extern struct haifa_sched_info *current_sched_info;
651 687
652 /* Do register pressure sensitive insn scheduling if the flag is set 688 /* Do register pressure sensitive insn scheduling if the flag is set
653 up. */ 689 up. */
654 extern bool sched_pressure_p; 690 extern enum sched_pressure_algorithm sched_pressure;
655 691
656 /* Map regno -> its cover class. The map defined only when 692 /* Map regno -> its pressure class. The map defined only when
657 SCHED_PRESSURE_P is true. */ 693 SCHED_PRESSURE_P is true. */
658 extern enum reg_class *sched_regno_cover_class; 694 extern enum reg_class *sched_regno_pressure_class;
659 695
660 /* Indexed by INSN_UID, the collection of all data associated with 696 /* Indexed by INSN_UID, the collection of all data associated with
661 a single instruction. */ 697 a single instruction. */
662 698
663 struct _haifa_deps_insn_data 699 struct _haifa_deps_insn_data
696 /* A list of scheduled consumers of the instruction. Links are being moved 732 /* A list of scheduled consumers of the instruction. Links are being moved
697 from 'forw_deps' to 'resolved_forw_deps' while scheduling to fasten the 733 from 'forw_deps' to 'resolved_forw_deps' while scheduling to fasten the
698 search in 'forw_deps'. */ 734 search in 'forw_deps'. */
699 deps_list_t resolved_forw_deps; 735 deps_list_t resolved_forw_deps;
700 736
737 /* If the insn is conditional (either through COND_EXEC, or because
738 it is a conditional branch), this records the condition. NULL
739 for insns that haven't been seen yet or don't have a condition;
740 const_true_rtx to mark an insn without a condition, or with a
741 condition that has been clobbered by a subsequent insn. */
742 rtx cond;
743
744 /* For a conditional insn, a list of insns that could set the condition
745 register. Used when generating control dependencies. */
746 rtx_insn_list *cond_deps;
747
748 /* True if the condition in 'cond' should be reversed to get the actual
749 condition. */
750 unsigned int reverse_cond : 1;
751
701 /* Some insns (e.g. call) are not allowed to move across blocks. */ 752 /* Some insns (e.g. call) are not allowed to move across blocks. */
702 unsigned int cant_move : 1; 753 unsigned int cant_move : 1;
703 }; 754 };
704 755
756
705 /* Bits used for storing values of the fields in the following 757 /* Bits used for storing values of the fields in the following
706 structure. */ 758 structure. */
707 #define INCREASE_BITS 8 759 #define INCREASE_BITS 8
708 760
709 /* The structure describes how the corresponding insn increases the 761 /* The structure describes how the corresponding insn increases the
710 register pressure for each cover class. */ 762 register pressure for each pressure class. */
711 struct reg_pressure_data 763 struct reg_pressure_data
712 { 764 {
713 /* Pressure increase for given class because of clobber. */ 765 /* Pressure increase for given class because of clobber. */
714 unsigned int clobber_increase : INCREASE_BITS; 766 unsigned int clobber_increase : INCREASE_BITS;
715 /* Increase in register pressure for given class because of register 767 /* Increase in register pressure for given class because of register
726 struct reg_use_data 778 struct reg_use_data
727 { 779 {
728 /* Regno used in the insn. */ 780 /* Regno used in the insn. */
729 int regno; 781 int regno;
730 /* Insn using the regno. */ 782 /* Insn using the regno. */
731 rtx insn; 783 rtx_insn *insn;
732 /* Cyclic list of elements with the same regno. */ 784 /* Cyclic list of elements with the same regno. */
733 struct reg_use_data *next_regno_use; 785 struct reg_use_data *next_regno_use;
734 /* List of elements with the same insn. */ 786 /* List of elements with the same insn. */
735 struct reg_use_data *next_insn_use; 787 struct reg_use_data *next_insn_use;
736 }; 788 };
737 789
738 /* The following structure describes used sets of registers by insns. 790 /* The following structure describes used sets of registers by insns.
739 Registers are pseudos whose cover class is not NO_REGS or hard 791 Registers are pseudos whose pressure class is not NO_REGS or hard
740 registers available for allocations. */ 792 registers available for allocations. */
741 struct reg_set_data 793 struct reg_set_data
742 { 794 {
743 /* Regno used in the insn. */ 795 /* Regno used in the insn. */
744 int regno; 796 int regno;
746 rtx insn; 798 rtx insn;
747 /* List of elements with the same insn. */ 799 /* List of elements with the same insn. */
748 struct reg_set_data *next_insn_set; 800 struct reg_set_data *next_insn_set;
749 }; 801 };
750 802
803 enum autopref_multipass_data_status {
804 /* Entry is irrelevant for auto-prefetcher. */
805 AUTOPREF_MULTIPASS_DATA_IRRELEVANT = -2,
806 /* Entry is uninitialized. */
807 AUTOPREF_MULTIPASS_DATA_UNINITIALIZED = -1,
808 /* Entry is relevant for auto-prefetcher and insn can be delayed
809 to allow another insn through. */
810 AUTOPREF_MULTIPASS_DATA_NORMAL = 0,
811 /* Entry is relevant for auto-prefetcher, but insn should not be
812 delayed as that will break scheduling. */
813 AUTOPREF_MULTIPASS_DATA_DONT_DELAY = 1
814 };
815
816 /* Data for modeling cache auto-prefetcher. */
817 struct autopref_multipass_data_
818 {
819 /* Base part of memory address. */
820 rtx base;
821
822 /* Memory offsets from the base. */
823 int offset;
824
825 /* Entry status. */
826 enum autopref_multipass_data_status status;
827 };
828 typedef struct autopref_multipass_data_ autopref_multipass_data_def;
829 typedef autopref_multipass_data_def *autopref_multipass_data_t;
830
751 struct _haifa_insn_data 831 struct _haifa_insn_data
752 { 832 {
753 /* We can't place 'struct _deps_list' into h_i_d instead of deps_list_t 833 /* We can't place 'struct _deps_list' into h_i_d instead of deps_list_t
754 because when h_i_d extends, addresses of the deps_list->first 834 because when h_i_d extends, addresses of the deps_list->first
755 change without updating deps_list->first->next->prev_nextp. */ 835 change without updating deps_list->first->next->prev_nextp. */
758 int luid; 838 int luid;
759 839
760 /* A priority for each insn. */ 840 /* A priority for each insn. */
761 int priority; 841 int priority;
762 842
843 /* The fusion priority for each insn. */
844 int fusion_priority;
845
763 /* The minimum clock tick at which the insn becomes ready. This is 846 /* The minimum clock tick at which the insn becomes ready. This is
764 used to note timing constraints for the insns in the pending list. */ 847 used to note timing constraints for the insns in the pending list. */
765 int tick; 848 int tick;
766 849
850 /* For insns that are scheduled at a fixed difference from another,
851 this records the tick in which they must be ready. */
852 int exact_tick;
853
767 /* INTER_TICK is used to adjust INSN_TICKs of instructions from the 854 /* INTER_TICK is used to adjust INSN_TICKs of instructions from the
768 subsequent blocks in a region. */ 855 subsequent blocks in a region. */
769 int inter_tick; 856 int inter_tick;
770 857
858 /* Used temporarily to estimate an INSN_TICK value for an insn given
859 current knowledge. */
860 int tick_estimate;
861
771 /* See comment on QUEUE_INDEX macro in haifa-sched.c. */ 862 /* See comment on QUEUE_INDEX macro in haifa-sched.c. */
772 int queue_index; 863 int queue_index;
773 864
774 short cost; 865 short cost;
866
867 /* '> 0' if priority is valid,
868 '== 0' if priority was not yet computed,
869 '< 0' if priority in invalid and should be recomputed. */
870 signed char priority_status;
775 871
776 /* Set if there's DEF-USE dependence between some speculatively 872 /* Set if there's DEF-USE dependence between some speculatively
777 moved load insn and this one. */ 873 moved load insn and this one. */
778 unsigned int fed_by_spec_load : 1; 874 unsigned int fed_by_spec_load : 1;
779 unsigned int is_load_insn : 1; 875 unsigned int is_load_insn : 1;
780 876 /* Nonzero if this insn has negative-cost forward dependencies against
781 /* '> 0' if priority is valid, 877 an already scheduled insn. */
782 '== 0' if priority was not yet computed, 878 unsigned int feeds_backtrack_insn : 1;
783 '< 0' if priority in invalid and should be recomputed. */ 879
784 signed char priority_status; 880 /* Nonzero if this insn is a shadow of another, scheduled after a fixed
881 delay. We only emit shadows at the end of a cycle, with no other
882 real insns following them. */
883 unsigned int shadow_p : 1;
884
885 /* Used internally in unschedule_insns_until to mark insns that must have
886 their TODO_SPEC recomputed. */
887 unsigned int must_recompute_spec : 1;
785 888
786 /* What speculations are necessary to apply to schedule the instruction. */ 889 /* What speculations are necessary to apply to schedule the instruction. */
787 ds_t todo_spec; 890 ds_t todo_spec;
788 891
789 /* What speculations were already applied. */ 892 /* What speculations were already applied. */
795 /* Recovery block for speculation checks. */ 898 /* Recovery block for speculation checks. */
796 basic_block recovery_block; 899 basic_block recovery_block;
797 900
798 /* Original pattern of the instruction. */ 901 /* Original pattern of the instruction. */
799 rtx orig_pat; 902 rtx orig_pat;
903
904 /* For insns with DEP_CONTROL dependencies, the predicated pattern if it
905 was ever successfully constructed. */
906 rtx predicated_pat;
800 907
801 /* The following array contains info how the insn increases register 908 /* The following array contains info how the insn increases register
802 pressure. There is an element for each cover class of pseudos 909 pressure. There is an element for each cover class of pseudos
803 referenced in insns. */ 910 referenced in insns. */
804 struct reg_pressure_data *reg_pressure; 911 struct reg_pressure_data *reg_pressure;
805 /* The following array contains maximal reg pressure between last 912 /* The following array contains maximal reg pressure between last
806 scheduled insn and given insn. There is an element for each 913 scheduled insn and given insn. There is an element for each
807 cover class of pseudos referenced in insns. This info updated 914 pressure class of pseudos referenced in insns. This info updated
808 after scheduling each insn for each insn between the two 915 after scheduling each insn for each insn between the two
809 mentioned insns. */ 916 mentioned insns. */
810 int *max_reg_pressure; 917 int *max_reg_pressure;
811 /* The following list contains info about used pseudos and hard 918 /* The following list contains info about used pseudos and hard
812 registers available for allocation. */ 919 registers available for allocation. */
815 registers available for allocation. */ 922 registers available for allocation. */
816 struct reg_set_data *reg_set_list; 923 struct reg_set_data *reg_set_list;
817 /* Info about how scheduling the insn changes cost of register 924 /* Info about how scheduling the insn changes cost of register
818 pressure excess (between source and target). */ 925 pressure excess (between source and target). */
819 int reg_pressure_excess_cost_change; 926 int reg_pressure_excess_cost_change;
927 int model_index;
928
929 /* Original order of insns in the ready list. */
930 int rfs_debug_orig_order;
931
932 /* The deciding reason for INSN's place in the ready list. */
933 int last_rfs_win;
934
935 /* Two entries for cache auto-prefetcher model: one for mem reads,
936 and one for mem writes. */
937 autopref_multipass_data_def autopref_multipass_data[2];
820 }; 938 };
821 939
822 typedef struct _haifa_insn_data haifa_insn_data_def; 940 typedef struct _haifa_insn_data haifa_insn_data_def;
823 typedef haifa_insn_data_def *haifa_insn_data_t; 941 typedef haifa_insn_data_def *haifa_insn_data_t;
824 942
825 DEF_VEC_O (haifa_insn_data_def); 943
826 DEF_VEC_ALLOC_O (haifa_insn_data_def, heap); 944 extern vec<haifa_insn_data_def> h_i_d;
827 945
828 extern VEC(haifa_insn_data_def, heap) *h_i_d; 946 #define HID(INSN) (&h_i_d[INSN_UID (INSN)])
829
830 #define HID(INSN) (VEC_index (haifa_insn_data_def, h_i_d, INSN_UID (INSN)))
831 947
832 /* Accessor macros for h_i_d. There are more in haifa-sched.c and 948 /* Accessor macros for h_i_d. There are more in haifa-sched.c and
833 sched-rgn.c. */ 949 sched-rgn.c. */
834 #define INSN_PRIORITY(INSN) (HID (INSN)->priority) 950 #define INSN_PRIORITY(INSN) (HID (INSN)->priority)
951 #define INSN_FUSION_PRIORITY(INSN) (HID (INSN)->fusion_priority)
835 #define INSN_REG_PRESSURE(INSN) (HID (INSN)->reg_pressure) 952 #define INSN_REG_PRESSURE(INSN) (HID (INSN)->reg_pressure)
836 #define INSN_MAX_REG_PRESSURE(INSN) (HID (INSN)->max_reg_pressure) 953 #define INSN_MAX_REG_PRESSURE(INSN) (HID (INSN)->max_reg_pressure)
837 #define INSN_REG_USE_LIST(INSN) (HID (INSN)->reg_use_list) 954 #define INSN_REG_USE_LIST(INSN) (HID (INSN)->reg_use_list)
838 #define INSN_REG_SET_LIST(INSN) (HID (INSN)->reg_set_list) 955 #define INSN_REG_SET_LIST(INSN) (HID (INSN)->reg_set_list)
839 #define INSN_REG_PRESSURE_EXCESS_COST_CHANGE(INSN) \ 956 #define INSN_REG_PRESSURE_EXCESS_COST_CHANGE(INSN) \
840 (HID (INSN)->reg_pressure_excess_cost_change) 957 (HID (INSN)->reg_pressure_excess_cost_change)
841 #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status) 958 #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status)
959 #define INSN_MODEL_INDEX(INSN) (HID (INSN)->model_index)
960 #define INSN_AUTOPREF_MULTIPASS_DATA(INSN) \
961 (HID (INSN)->autopref_multipass_data)
842 962
843 typedef struct _haifa_deps_insn_data haifa_deps_insn_data_def; 963 typedef struct _haifa_deps_insn_data haifa_deps_insn_data_def;
844 typedef haifa_deps_insn_data_def *haifa_deps_insn_data_t; 964 typedef haifa_deps_insn_data_def *haifa_deps_insn_data_t;
845 965
846 DEF_VEC_O (haifa_deps_insn_data_def); 966
847 DEF_VEC_ALLOC_O (haifa_deps_insn_data_def, heap); 967 extern vec<haifa_deps_insn_data_def> h_d_i_d;
848 968
849 extern VEC(haifa_deps_insn_data_def, heap) *h_d_i_d; 969 #define HDID(INSN) (&h_d_i_d[INSN_LUID (INSN)])
850
851 #define HDID(INSN) (VEC_index (haifa_deps_insn_data_def, h_d_i_d, \
852 INSN_LUID (INSN)))
853 #define INSN_DEP_COUNT(INSN) (HDID (INSN)->dep_count) 970 #define INSN_DEP_COUNT(INSN) (HDID (INSN)->dep_count)
854 #define HAS_INTERNAL_DEP(INSN) (HDID (INSN)->has_internal_dep) 971 #define HAS_INTERNAL_DEP(INSN) (HDID (INSN)->has_internal_dep)
855 #define INSN_FORW_DEPS(INSN) (HDID (INSN)->forw_deps) 972 #define INSN_FORW_DEPS(INSN) (HDID (INSN)->forw_deps)
856 #define INSN_RESOLVED_BACK_DEPS(INSN) (HDID (INSN)->resolved_back_deps) 973 #define INSN_RESOLVED_BACK_DEPS(INSN) (HDID (INSN)->resolved_back_deps)
857 #define INSN_RESOLVED_FORW_DEPS(INSN) (HDID (INSN)->resolved_forw_deps) 974 #define INSN_RESOLVED_FORW_DEPS(INSN) (HDID (INSN)->resolved_forw_deps)
858 #define INSN_HARD_BACK_DEPS(INSN) (HDID (INSN)->hard_back_deps) 975 #define INSN_HARD_BACK_DEPS(INSN) (HDID (INSN)->hard_back_deps)
859 #define INSN_SPEC_BACK_DEPS(INSN) (HDID (INSN)->spec_back_deps) 976 #define INSN_SPEC_BACK_DEPS(INSN) (HDID (INSN)->spec_back_deps)
977 #define INSN_CACHED_COND(INSN) (HDID (INSN)->cond)
978 #define INSN_REVERSE_COND(INSN) (HDID (INSN)->reverse_cond)
979 #define INSN_COND_DEPS(INSN) (HDID (INSN)->cond_deps)
860 #define CANT_MOVE(INSN) (HDID (INSN)->cant_move) 980 #define CANT_MOVE(INSN) (HDID (INSN)->cant_move)
861 #define CANT_MOVE_BY_LUID(LUID) (VEC_index (haifa_deps_insn_data_def, h_d_i_d, \ 981 #define CANT_MOVE_BY_LUID(LUID) (h_d_i_d[LUID].cant_move)
862 LUID)->cant_move)
863 982
864 983
865 #define INSN_PRIORITY(INSN) (HID (INSN)->priority) 984 #define INSN_PRIORITY(INSN) (HID (INSN)->priority)
866 #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status) 985 #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status)
867 #define INSN_PRIORITY_KNOWN(INSN) (INSN_PRIORITY_STATUS (INSN) > 0) 986 #define INSN_PRIORITY_KNOWN(INSN) (INSN_PRIORITY_STATUS (INSN) > 0)
868 #define TODO_SPEC(INSN) (HID (INSN)->todo_spec) 987 #define TODO_SPEC(INSN) (HID (INSN)->todo_spec)
869 #define DONE_SPEC(INSN) (HID (INSN)->done_spec) 988 #define DONE_SPEC(INSN) (HID (INSN)->done_spec)
870 #define CHECK_SPEC(INSN) (HID (INSN)->check_spec) 989 #define CHECK_SPEC(INSN) (HID (INSN)->check_spec)
871 #define RECOVERY_BLOCK(INSN) (HID (INSN)->recovery_block) 990 #define RECOVERY_BLOCK(INSN) (HID (INSN)->recovery_block)
872 #define ORIG_PAT(INSN) (HID (INSN)->orig_pat) 991 #define ORIG_PAT(INSN) (HID (INSN)->orig_pat)
992 #define PREDICATED_PAT(INSN) (HID (INSN)->predicated_pat)
873 993
874 /* INSN is either a simple or a branchy speculation check. */ 994 /* INSN is either a simple or a branchy speculation check. */
875 #define IS_SPECULATION_CHECK_P(INSN) \ 995 #define IS_SPECULATION_CHECK_P(INSN) \
876 (sel_sched_p () ? sel_insn_is_speculation_check (INSN) : RECOVERY_BLOCK (INSN) != NULL) 996 (sel_sched_p () ? sel_insn_is_speculation_check (INSN) : RECOVERY_BLOCK (INSN) != NULL)
877 997
878 /* INSN is a speculation check that will simply reexecute the speculatively 998 /* INSN is a speculation check that will simply reexecute the speculatively
879 scheduled instruction if the speculation fails. */ 999 scheduled instruction if the speculation fails. */
880 #define IS_SPECULATION_SIMPLE_CHECK_P(INSN) \ 1000 #define IS_SPECULATION_SIMPLE_CHECK_P(INSN) \
881 (RECOVERY_BLOCK (INSN) == EXIT_BLOCK_PTR) 1001 (RECOVERY_BLOCK (INSN) == EXIT_BLOCK_PTR_FOR_FN (cfun))
882 1002
883 /* INSN is a speculation check that will branch to RECOVERY_BLOCK if the 1003 /* INSN is a speculation check that will branch to RECOVERY_BLOCK if the
884 speculation fails. Insns in that block will reexecute the speculatively 1004 speculation fails. Insns in that block will reexecute the speculatively
885 scheduled code and then will return immediately after INSN thus preserving 1005 scheduled code and then will return immediately after INSN thus preserving
886 semantics of the program. */ 1006 semantics of the program. */
887 #define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \ 1007 #define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \
888 (RECOVERY_BLOCK (INSN) != NULL && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR) 1008 (RECOVERY_BLOCK (INSN) != NULL \
889 1009 && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR_FOR_FN (cfun))
890 /* Dep status (aka ds_t) of the link encapsulates information, that is needed 1010
891 for speculative scheduling. Namely, it is 4 integers in the range 1011
892 [0, MAX_DEP_WEAK] and 3 bits. 1012 /* Dep status (aka ds_t) of the link encapsulates all information for a given
893 The integers correspond to the probability of the dependence to *not* 1013 dependency, including everything that is needed for speculative scheduling.
894 exist, it is the probability, that overcoming of this dependence will 1014
895 not be followed by execution of the recovery code. Nevertheless, 1015 The lay-out of a ds_t is as follows:
896 whatever high the probability of success is, recovery code should still 1016
897 be generated to preserve semantics of the program. To find a way to 1017 1. Integers corresponding to the probability of the dependence to *not*
898 get/set these integers, please refer to the {get, set}_dep_weak () 1018 exist. This is the probability that overcoming this dependence will
899 functions in sched-deps.c . 1019 not be followed by execution of the recovery code. Note that however
900 The 3 bits in the DEP_STATUS correspond to 3 dependence types: true-, 1020 high this probability is, the recovery code should still always be
901 output- and anti- dependence. It is not enough for speculative scheduling 1021 generated to preserve semantics of the program.
902 to know just the major type of all the dependence between two instructions, 1022
903 as only true dependence can be overcome. 1023 The probability values can be set or retrieved using the functions
904 There also is the 4-th bit in the DEP_STATUS (HARD_DEP), that is reserved 1024 the set_dep_weak() and get_dep_weak() in sched-deps.c. The values
905 for using to describe instruction's status. It is set whenever instruction 1025 are always in the range [0, MAX_DEP_WEAK].
906 has at least one dependence, that cannot be overcame. 1026
1027 BEGIN_DATA : BITS_PER_DEP_WEAK
1028 BE_IN_DATA : BITS_PER_DEP_WEAK
1029 BEGIN_CONTROL : BITS_PER_DEP_WEAK
1030 BE_IN_CONTROL : BITS_PER_DEP_WEAK
1031
1032 The basic type of DS_T is a host int. For a 32-bits int, the values
1033 will each take 6 bits.
1034
1035 2. The type of dependence. This supercedes the old-style REG_NOTE_KIND
1036 values. TODO: Use this field instead of DEP_TYPE, or make DEP_TYPE
1037 extract the dependence type from here.
1038
1039 dep_type : 4 => DEP_{TRUE|OUTPUT|ANTI|CONTROL}
1040
1041 3. Various flags:
1042
1043 HARD_DEP : 1 => Set if an instruction has a non-speculative
1044 dependence. This is an instruction property
1045 so this bit can only appear in the TODO_SPEC
1046 field of an instruction.
1047 DEP_POSTPONED : 1 => Like HARD_DEP, but the hard dependence may
1048 still be broken by adjusting the instruction.
1049 DEP_CANCELLED : 1 => Set if a dependency has been broken using
1050 some form of speculation.
1051 RESERVED : 1 => Reserved for use in the delay slot scheduler.
1052
907 See also: check_dep_status () in sched-deps.c . */ 1053 See also: check_dep_status () in sched-deps.c . */
908 1054
909 /* We exclude sign bit. */ 1055 /* The number of bits per weakness probability. There are 4 weakness types
910 #define BITS_PER_DEP_STATUS (HOST_BITS_PER_INT - 1) 1056 and we need 8 bits for other data in a DS_T. */
911 1057 #define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 8) / 4)
912 /* First '4' stands for 3 dep type bits and HARD_DEP bit.
913 Second '4' stands for BEGIN_{DATA, CONTROL}, BE_IN_{DATA, CONTROL}
914 dep weakness. */
915 #define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 4) / 4)
916 1058
917 /* Mask of speculative weakness in dep_status. */ 1059 /* Mask of speculative weakness in dep_status. */
918 #define DEP_WEAK_MASK ((1 << BITS_PER_DEP_WEAK) - 1) 1060 #define DEP_WEAK_MASK ((1 << BITS_PER_DEP_WEAK) - 1)
919 1061
920 /* This constant means that dependence is fake with 99.999...% probability. 1062 /* This constant means that dependence is fake with 99.999...% probability.
928 bad idea to overcome it (though this can be done, preserving program 1070 bad idea to overcome it (though this can be done, preserving program
929 semantics). */ 1071 semantics). */
930 #define MIN_DEP_WEAK 1 1072 #define MIN_DEP_WEAK 1
931 1073
932 /* This constant represents 100% probability. 1074 /* This constant represents 100% probability.
933 E.g. it is used to represent weakness of dependence, that doesn't exist. */ 1075 E.g. it is used to represent weakness of dependence, that doesn't exist.
1076 This value never appears in a ds_t, it is only used for computing the
1077 weakness of a dependence. */
934 #define NO_DEP_WEAK (MAX_DEP_WEAK + MIN_DEP_WEAK) 1078 #define NO_DEP_WEAK (MAX_DEP_WEAK + MIN_DEP_WEAK)
935 1079
936 /* Default weakness of speculative dependence. Used when we can't say 1080 /* Default weakness of speculative dependence. Used when we can't say
937 neither bad nor good about the dependence. */ 1081 neither bad nor good about the dependence. */
938 #define UNCERTAIN_DEP_WEAK (MAX_DEP_WEAK - MAX_DEP_WEAK / 4) 1082 #define UNCERTAIN_DEP_WEAK (MAX_DEP_WEAK - MAX_DEP_WEAK / 4)
943 BE_IN_DATA_BITS_OFFSET = BEGIN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK, 1087 BE_IN_DATA_BITS_OFFSET = BEGIN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK,
944 BEGIN_CONTROL_BITS_OFFSET = BE_IN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK, 1088 BEGIN_CONTROL_BITS_OFFSET = BE_IN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK,
945 BE_IN_CONTROL_BITS_OFFSET = BEGIN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK 1089 BE_IN_CONTROL_BITS_OFFSET = BEGIN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK
946 }; 1090 };
947 1091
948 /* The following defines provide numerous constants used to distinguish between 1092 /* The following defines provide numerous constants used to distinguish
949 different types of speculative dependencies. */ 1093 between different types of speculative dependencies. They are also
1094 used as masks to clear/preserve the bits corresponding to the type
1095 of dependency weakness. */
950 1096
951 /* Dependence can be overcome with generation of new data speculative 1097 /* Dependence can be overcome with generation of new data speculative
952 instruction. */ 1098 instruction. */
953 #define BEGIN_DATA (((ds_t) DEP_WEAK_MASK) << BEGIN_DATA_BITS_OFFSET) 1099 #define BEGIN_DATA (((ds_t) DEP_WEAK_MASK) << BEGIN_DATA_BITS_OFFSET)
954 1100
984 (e.g. true and output). This fields enhance REG_NOTE_KIND information 1130 (e.g. true and output). This fields enhance REG_NOTE_KIND information
985 of the dependence. */ 1131 of the dependence. */
986 #define DEP_TRUE (((ds_t) 1) << (BE_IN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK)) 1132 #define DEP_TRUE (((ds_t) 1) << (BE_IN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK))
987 #define DEP_OUTPUT (DEP_TRUE << 1) 1133 #define DEP_OUTPUT (DEP_TRUE << 1)
988 #define DEP_ANTI (DEP_OUTPUT << 1) 1134 #define DEP_ANTI (DEP_OUTPUT << 1)
989 1135 #define DEP_CONTROL (DEP_ANTI << 1)
990 #define DEP_TYPES (DEP_TRUE | DEP_OUTPUT | DEP_ANTI) 1136
1137 #define DEP_TYPES (DEP_TRUE | DEP_OUTPUT | DEP_ANTI | DEP_CONTROL)
991 1138
992 /* Instruction has non-speculative dependence. This bit represents the 1139 /* Instruction has non-speculative dependence. This bit represents the
993 property of an instruction - not the one of a dependence. 1140 property of an instruction - not the one of a dependence.
994 Therefore, it can appear only in TODO_SPEC field of an instruction. */ 1141 Therefore, it can appear only in the TODO_SPEC field of an instruction. */
995 #define HARD_DEP (DEP_ANTI << 1) 1142 #define HARD_DEP (DEP_CONTROL << 1)
996 1143
1144 /* Like HARD_DEP, but dependencies can perhaps be broken by modifying
1145 the instructions. This is used for example to change:
1146
1147 rn++ => rm=[rn + 4]
1148 rm=[rn] rn++
1149
1150 For instructions that have this bit set, one of the dependencies of
1151 the instructions will have a non-NULL REPLACE field in its DEP_T.
1152 Just like HARD_DEP, this bit is only ever set in TODO_SPEC. */
1153 #define DEP_POSTPONED (HARD_DEP << 1)
1154
1155 /* Set if a dependency is cancelled via speculation. */
1156 #define DEP_CANCELLED (DEP_POSTPONED << 1)
1157
1158
997 /* This represents the results of calling sched-deps.c functions, 1159 /* This represents the results of calling sched-deps.c functions,
998 which modify dependencies. */ 1160 which modify dependencies. */
999 enum DEPS_ADJUST_RESULT { 1161 enum DEPS_ADJUST_RESULT {
1000 /* No dependence needed (e.g. producer == consumer). */ 1162 /* No dependence needed (e.g. producer == consumer). */
1001 DEP_NODEP, 1163 DEP_NODEP,
1015 USE_DEPS_LIST = 1, 1177 USE_DEPS_LIST = 1,
1016 /* Perform data or control (or both) speculation. 1178 /* Perform data or control (or both) speculation.
1017 Results in generation of data and control speculative dependencies. 1179 Results in generation of data and control speculative dependencies.
1018 Requires USE_DEPS_LIST set. */ 1180 Requires USE_DEPS_LIST set. */
1019 DO_SPECULATION = USE_DEPS_LIST << 1, 1181 DO_SPECULATION = USE_DEPS_LIST << 1,
1020 SCHED_RGN = DO_SPECULATION << 1, 1182 DO_BACKTRACKING = DO_SPECULATION << 1,
1183 DO_PREDICATION = DO_BACKTRACKING << 1,
1184 DONT_BREAK_DEPENDENCIES = DO_PREDICATION << 1,
1185 SCHED_RGN = DONT_BREAK_DEPENDENCIES << 1,
1021 SCHED_EBB = SCHED_RGN << 1, 1186 SCHED_EBB = SCHED_RGN << 1,
1022 /* Scheduler can possibly create new basic blocks. Used for assertions. */ 1187 /* Scheduler can possibly create new basic blocks. Used for assertions. */
1023 NEW_BBS = SCHED_EBB << 1, 1188 NEW_BBS = SCHED_EBB << 1,
1024 SEL_SCHED = NEW_BBS << 1 1189 SEL_SCHED = NEW_BBS << 1
1025 }; 1190 };
1026 1191
1027 enum SPEC_SCHED_FLAGS { 1192 enum SPEC_SCHED_FLAGS {
1028 COUNT_SPEC_IN_CRITICAL_PATH = 1, 1193 COUNT_SPEC_IN_CRITICAL_PATH = 1,
1029 PREFER_NON_DATA_SPEC = COUNT_SPEC_IN_CRITICAL_PATH << 1, 1194 SEL_SCHED_SPEC_DONT_CHECK_CONTROL = COUNT_SPEC_IN_CRITICAL_PATH << 1
1030 PREFER_NON_CONTROL_SPEC = PREFER_NON_DATA_SPEC << 1,
1031 SEL_SCHED_SPEC_DONT_CHECK_CONTROL = PREFER_NON_CONTROL_SPEC << 1
1032 }; 1195 };
1033 1196
1034 #define NOTE_NOT_BB_P(NOTE) (NOTE_P (NOTE) && (NOTE_KIND (NOTE) \ 1197 #define NOTE_NOT_BB_P(NOTE) (NOTE_P (NOTE) && (NOTE_KIND (NOTE) \
1035 != NOTE_INSN_BASIC_BLOCK)) 1198 != NOTE_INSN_BASIC_BLOCK))
1036 1199
1121 struct sched_deps_info_def 1284 struct sched_deps_info_def
1122 { 1285 {
1123 /* Called when computing dependencies for a JUMP_INSN. This function 1286 /* Called when computing dependencies for a JUMP_INSN. This function
1124 should store the set of registers that must be considered as set by 1287 should store the set of registers that must be considered as set by
1125 the jump in the regset. */ 1288 the jump in the regset. */
1126 void (*compute_jump_reg_dependencies) (rtx, regset, regset, regset); 1289 void (*compute_jump_reg_dependencies) (rtx, regset);
1127 1290
1128 /* Start analyzing insn. */ 1291 /* Start analyzing insn. */
1129 void (*start_insn) (rtx); 1292 void (*start_insn) (rtx_insn *);
1130 1293
1131 /* Finish analyzing insn. */ 1294 /* Finish analyzing insn. */
1132 void (*finish_insn) (void); 1295 void (*finish_insn) (void);
1133 1296
1134 /* Start analyzing insn LHS (Left Hand Side). */ 1297 /* Start analyzing insn LHS (Left Hand Side). */
1152 /* Note use of the register. */ 1315 /* Note use of the register. */
1153 void (*note_reg_use) (int); 1316 void (*note_reg_use) (int);
1154 1317
1155 /* Note memory dependence of type DS between MEM1 and MEM2 (which is 1318 /* Note memory dependence of type DS between MEM1 and MEM2 (which is
1156 in the INSN2). */ 1319 in the INSN2). */
1157 void (*note_mem_dep) (rtx mem1, rtx mem2, rtx insn2, ds_t ds); 1320 void (*note_mem_dep) (rtx mem1, rtx mem2, rtx_insn *insn2, ds_t ds);
1158 1321
1159 /* Note a dependence of type DS from the INSN. */ 1322 /* Note a dependence of type DS from the INSN. */
1160 void (*note_dep) (rtx insn, ds_t ds); 1323 void (*note_dep) (rtx_insn *, ds_t ds);
1161 1324
1162 /* Nonzero if we should use cselib for better alias analysis. This 1325 /* Nonzero if we should use cselib for better alias analysis. This
1163 must be 0 if the dependency information is used after sched_analyze 1326 must be 0 if the dependency information is used after sched_analyze
1164 has completed, e.g. if we're using it to initialize state for successor 1327 has completed, e.g. if we're using it to initialize state for successor
1165 blocks in region scheduling. */ 1328 blocks in region scheduling. */
1176 1339
1177 extern struct sched_deps_info_def *sched_deps_info; 1340 extern struct sched_deps_info_def *sched_deps_info;
1178 1341
1179 1342
1180 /* Functions in sched-deps.c. */ 1343 /* Functions in sched-deps.c. */
1181 extern bool sched_insns_conditions_mutex_p (const_rtx, const_rtx); 1344 extern rtx sched_get_reverse_condition_uncached (const rtx_insn *);
1182 extern bool sched_insn_is_legitimate_for_speculation_p (const_rtx, ds_t); 1345 extern bool sched_insns_conditions_mutex_p (const rtx_insn *,
1183 extern void add_dependence (rtx, rtx, enum reg_note); 1346 const rtx_insn *);
1184 extern void sched_analyze (struct deps_desc *, rtx, rtx); 1347 extern bool sched_insn_is_legitimate_for_speculation_p (const rtx_insn *, ds_t);
1348 extern void add_dependence (rtx_insn *, rtx_insn *, enum reg_note);
1349 extern void sched_analyze (struct deps_desc *, rtx_insn *, rtx_insn *);
1185 extern void init_deps (struct deps_desc *, bool); 1350 extern void init_deps (struct deps_desc *, bool);
1186 extern void init_deps_reg_last (struct deps_desc *); 1351 extern void init_deps_reg_last (struct deps_desc *);
1187 extern void free_deps (struct deps_desc *); 1352 extern void free_deps (struct deps_desc *);
1188 extern void init_deps_global (void); 1353 extern void init_deps_global (void);
1189 extern void finish_deps_global (void); 1354 extern void finish_deps_global (void);
1190 extern void deps_analyze_insn (struct deps_desc *, rtx); 1355 extern void deps_analyze_insn (struct deps_desc *, rtx_insn *);
1191 extern void remove_from_deps (struct deps_desc *, rtx); 1356 extern void remove_from_deps (struct deps_desc *, rtx_insn *);
1192 1357 extern void init_insn_reg_pressure_info (rtx_insn *);
1193 extern dw_t get_dep_weak_1 (ds_t, ds_t); 1358 extern void get_implicit_reg_pending_clobbers (HARD_REG_SET *, rtx_insn *);
1359
1194 extern dw_t get_dep_weak (ds_t, ds_t); 1360 extern dw_t get_dep_weak (ds_t, ds_t);
1195 extern ds_t set_dep_weak (ds_t, ds_t, dw_t); 1361 extern ds_t set_dep_weak (ds_t, ds_t, dw_t);
1196 extern dw_t estimate_dep_weak (rtx, rtx); 1362 extern dw_t estimate_dep_weak (rtx, rtx);
1197 extern ds_t ds_merge (ds_t, ds_t); 1363 extern ds_t ds_merge (ds_t, ds_t);
1198 extern ds_t ds_full_merge (ds_t, ds_t, rtx, rtx); 1364 extern ds_t ds_full_merge (ds_t, ds_t, rtx, rtx);
1208 extern void haifa_note_reg_clobber (int); 1374 extern void haifa_note_reg_clobber (int);
1209 extern void haifa_note_reg_use (int); 1375 extern void haifa_note_reg_use (int);
1210 1376
1211 extern void maybe_extend_reg_info_p (void); 1377 extern void maybe_extend_reg_info_p (void);
1212 1378
1213 extern void deps_start_bb (struct deps_desc *, rtx); 1379 extern void deps_start_bb (struct deps_desc *, rtx_insn *);
1214 extern enum reg_note ds_to_dt (ds_t); 1380 extern enum reg_note ds_to_dt (ds_t);
1215 1381
1216 extern bool deps_pools_are_empty_p (void); 1382 extern bool deps_pools_are_empty_p (void);
1217 extern void sched_free_deps (rtx, rtx, bool); 1383 extern void sched_free_deps (rtx_insn *, rtx_insn *, bool);
1218 extern void extend_dependency_caches (int, bool); 1384 extern void extend_dependency_caches (int, bool);
1219 1385
1220 extern void debug_ds (ds_t); 1386 extern void debug_ds (ds_t);
1221 1387
1222 1388
1223 /* Functions in haifa-sched.c. */ 1389 /* Functions in haifa-sched.c. */
1390 extern void initialize_live_range_shrinkage (void);
1391 extern void finish_live_range_shrinkage (void);
1224 extern void sched_init_region_reg_pressure_info (void); 1392 extern void sched_init_region_reg_pressure_info (void);
1393 extern void free_global_sched_pressure_data (void);
1225 extern int haifa_classify_insn (const_rtx); 1394 extern int haifa_classify_insn (const_rtx);
1226 extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *); 1395 extern void get_ebb_head_tail (basic_block, basic_block,
1227 extern int no_real_insns_p (const_rtx, const_rtx); 1396 rtx_insn **, rtx_insn **);
1228 1397 extern int no_real_insns_p (const rtx_insn *, const rtx_insn *);
1229 extern int insn_cost (rtx); 1398
1399 extern int insn_sched_cost (rtx_insn *);
1230 extern int dep_cost_1 (dep_t, dw_t); 1400 extern int dep_cost_1 (dep_t, dw_t);
1231 extern int dep_cost (dep_t); 1401 extern int dep_cost (dep_t);
1232 extern int set_priorities (rtx, rtx); 1402 extern int set_priorities (rtx_insn *, rtx_insn *);
1233 1403
1234 extern void sched_setup_bb_reg_pressure_info (basic_block, rtx); 1404 extern void sched_setup_bb_reg_pressure_info (basic_block, rtx_insn *);
1235 extern void schedule_block (basic_block *); 1405 extern bool schedule_block (basic_block *, state_t);
1236 1406
1237 extern int cycle_issued_insns; 1407 extern int cycle_issued_insns;
1238 extern int issue_rate; 1408 extern int issue_rate;
1239 extern int dfa_lookahead; 1409 extern int dfa_lookahead;
1240 1410
1241 extern void ready_sort (struct ready_list *); 1411 extern int autopref_multipass_dfa_lookahead_guard (rtx_insn *, int);
1242 extern rtx ready_element (struct ready_list *, int); 1412
1243 extern rtx *ready_lastpos (struct ready_list *); 1413 extern rtx_insn *ready_element (struct ready_list *, int);
1244 1414 extern rtx_insn **ready_lastpos (struct ready_list *);
1245 extern int try_ready (rtx); 1415
1416 extern int try_ready (rtx_insn *);
1246 extern void sched_extend_ready_list (int); 1417 extern void sched_extend_ready_list (int);
1247 extern void sched_finish_ready_list (void); 1418 extern void sched_finish_ready_list (void);
1248 extern void sched_change_pattern (rtx, rtx); 1419 extern void sched_change_pattern (rtx, rtx);
1249 extern int sched_speculate_insn (rtx, ds_t, rtx *); 1420 extern int sched_speculate_insn (rtx_insn *, ds_t, rtx *);
1250 extern void unlink_bb_notes (basic_block, basic_block); 1421 extern void unlink_bb_notes (basic_block, basic_block);
1251 extern void add_block (basic_block, basic_block); 1422 extern void add_block (basic_block, basic_block);
1252 extern rtx bb_note (basic_block); 1423 extern rtx_note *bb_note (basic_block);
1253 extern void concat_note_lists (rtx, rtx *); 1424 extern void concat_note_lists (rtx_insn *, rtx_insn **);
1254 extern rtx sched_emit_insn (rtx); 1425 extern rtx_insn *sched_emit_insn (rtx);
1255 extern rtx get_ready_element (int); 1426 extern rtx_insn *get_ready_element (int);
1256 extern int number_in_ready (void); 1427 extern int number_in_ready (void);
1257 1428
1258 1429 /* Types and functions in sched-ebb.c. */
1430
1431 extern basic_block schedule_ebb (rtx_insn *, rtx_insn *, bool);
1432 extern void schedule_ebbs_init (void);
1433 extern void schedule_ebbs_finish (void);
1434
1259 /* Types and functions in sched-rgn.c. */ 1435 /* Types and functions in sched-rgn.c. */
1260 1436
1261 /* A region is the main entity for interblock scheduling: insns 1437 /* A region is the main entity for interblock scheduling: insns
1262 are allowed to move between blocks in the same region, along 1438 are allowed to move between blocks in the same region, along
1263 control flow graph edges, in the 'up' direction. */ 1439 control flow graph edges, in the 'up' direction. */
1264 typedef struct 1440 struct region
1265 { 1441 {
1266 /* Number of extended basic blocks in region. */ 1442 /* Number of extended basic blocks in region. */
1267 int rgn_nr_blocks; 1443 int rgn_nr_blocks;
1268 /* cblocks in the region (actually index in rgn_bb_table). */ 1444 /* cblocks in the region (actually index in rgn_bb_table). */
1269 int rgn_blocks; 1445 int rgn_blocks;
1270 /* Dependencies for this region are already computed. Basically, indicates, 1446 /* Dependencies for this region are already computed. Basically, indicates,
1271 that this is a recovery block. */ 1447 that this is a recovery block. */
1272 unsigned int dont_calc_deps : 1; 1448 unsigned int dont_calc_deps : 1;
1273 /* This region has at least one non-trivial ebb. */ 1449 /* This region has at least one non-trivial ebb. */
1274 unsigned int has_real_ebb : 1; 1450 unsigned int has_real_ebb : 1;
1275 } 1451 };
1276 region;
1277 1452
1278 extern int nr_regions; 1453 extern int nr_regions;
1279 extern region *rgn_table; 1454 extern region *rgn_table;
1280 extern int *rgn_bb_table; 1455 extern int *rgn_bb_table;
1281 extern int *block_to_bb; 1456 extern int *block_to_bb;
1294 #define CONTAINING_RGN(block) (containing_rgn[block]) 1469 #define CONTAINING_RGN(block) (containing_rgn[block])
1295 1470
1296 /* The mapping from ebb to block. */ 1471 /* The mapping from ebb to block. */
1297 extern int *ebb_head; 1472 extern int *ebb_head;
1298 #define BB_TO_BLOCK(ebb) (rgn_bb_table[ebb_head[ebb]]) 1473 #define BB_TO_BLOCK(ebb) (rgn_bb_table[ebb_head[ebb]])
1299 #define EBB_FIRST_BB(ebb) BASIC_BLOCK (BB_TO_BLOCK (ebb)) 1474 #define EBB_FIRST_BB(ebb) BASIC_BLOCK_FOR_FN (cfun, BB_TO_BLOCK (ebb))
1300 #define EBB_LAST_BB(ebb) BASIC_BLOCK (rgn_bb_table[ebb_head[ebb + 1] - 1]) 1475 #define EBB_LAST_BB(ebb) \
1476 BASIC_BLOCK_FOR_FN (cfun, rgn_bb_table[ebb_head[ebb + 1] - 1])
1301 #define INSN_BB(INSN) (BLOCK_TO_BB (BLOCK_NUM (INSN))) 1477 #define INSN_BB(INSN) (BLOCK_TO_BB (BLOCK_NUM (INSN)))
1302 1478
1303 extern int current_nr_blocks; 1479 extern int current_nr_blocks;
1304 extern int current_blocks; 1480 extern int current_blocks;
1305 extern int target_bb; 1481 extern int target_bb;
1306 1482 extern bool sched_no_dce;
1483
1484 extern void set_modulo_params (int, int, int, int);
1485 extern void record_delay_slot_pair (rtx_insn *, rtx_insn *, int, int);
1486 extern rtx_insn *real_insn_for_shadow (rtx_insn *);
1487 extern void discard_delay_pairs_above (int);
1488 extern void free_delay_pairs (void);
1489 extern void add_delay_dependencies (rtx_insn *);
1307 extern bool sched_is_disabled_for_current_region_p (void); 1490 extern bool sched_is_disabled_for_current_region_p (void);
1308 extern void sched_rgn_init (bool); 1491 extern void sched_rgn_init (bool);
1309 extern void sched_rgn_finish (void); 1492 extern void sched_rgn_finish (void);
1310 extern void rgn_setup_region (int); 1493 extern void rgn_setup_region (int);
1311 extern void sched_rgn_compute_dependencies (int); 1494 extern void sched_rgn_compute_dependencies (int);
1314 extern void sched_rgn_local_free (void); 1497 extern void sched_rgn_local_free (void);
1315 extern void extend_regions (void); 1498 extern void extend_regions (void);
1316 extern void rgn_make_new_region_out_of_new_block (basic_block); 1499 extern void rgn_make_new_region_out_of_new_block (basic_block);
1317 1500
1318 extern void compute_priorities (void); 1501 extern void compute_priorities (void);
1319 extern void increase_insn_priority (rtx, int); 1502 extern void increase_insn_priority (rtx_insn *, int);
1320 extern void debug_rgn_dependencies (int); 1503 extern void debug_rgn_dependencies (int);
1321 extern void debug_dependencies (rtx, rtx); 1504 extern void debug_dependencies (rtx_insn *, rtx_insn *);
1505 extern void dump_rgn_dependencies_dot (FILE *);
1506 extern void dump_rgn_dependencies_dot (const char *);
1507
1322 extern void free_rgn_deps (void); 1508 extern void free_rgn_deps (void);
1323 extern int contributes_to_priority (rtx, rtx); 1509 extern int contributes_to_priority (rtx_insn *, rtx_insn *);
1324 extern void extend_rgns (int *, int *, sbitmap, int *); 1510 extern void extend_rgns (int *, int *, sbitmap, int *);
1325 extern void deps_join (struct deps_desc *, struct deps_desc *); 1511 extern void deps_join (struct deps_desc *, struct deps_desc *);
1326 1512
1327 extern void rgn_setup_common_sched_info (void); 1513 extern void rgn_setup_common_sched_info (void);
1328 extern void rgn_setup_sched_infos (void); 1514 extern void rgn_setup_sched_infos (void);
1332 extern void dump_region_dot (FILE *, int); 1518 extern void dump_region_dot (FILE *, int);
1333 extern void dump_region_dot_file (const char *, int); 1519 extern void dump_region_dot_file (const char *, int);
1334 1520
1335 extern void haifa_sched_init (void); 1521 extern void haifa_sched_init (void);
1336 extern void haifa_sched_finish (void); 1522 extern void haifa_sched_finish (void);
1523
1524 extern void find_modifiable_mems (rtx_insn *, rtx_insn *);
1337 1525
1338 /* sched-deps.c interface to walk, add, search, update, resolve, delete 1526 /* sched-deps.c interface to walk, add, search, update, resolve, delete
1339 and debug instruction dependencies. */ 1527 and debug instruction dependencies. */
1340 1528
1341 /* Constants defining dependences lists. */ 1529 /* Constants defining dependences lists. */
1417 1605
1418 /* Return the current element. */ 1606 /* Return the current element. */
1419 static inline bool 1607 static inline bool
1420 sd_iterator_cond (sd_iterator_def *it_ptr, dep_t *dep_ptr) 1608 sd_iterator_cond (sd_iterator_def *it_ptr, dep_t *dep_ptr)
1421 { 1609 {
1422 dep_link_t link = *it_ptr->linkp; 1610 while (true)
1423
1424 if (link != NULL)
1425 { 1611 {
1426 *dep_ptr = DEP_LINK_DEP (link); 1612 dep_link_t link = *it_ptr->linkp;
1427 return true; 1613
1428 } 1614 if (link != NULL)
1429 else
1430 {
1431 sd_list_types_def types = it_ptr->types;
1432
1433 if (types != SD_LIST_NONE)
1434 /* Switch to next list. */
1435 { 1615 {
1436 deps_list_t list; 1616 *dep_ptr = DEP_LINK_DEP (link);
1437 1617 return true;
1438 sd_next_list (it_ptr->insn,
1439 &it_ptr->types, &list, &it_ptr->resolved_p);
1440
1441 it_ptr->linkp = &DEPS_LIST_FIRST (list);
1442
1443 if (list)
1444 return sd_iterator_cond (it_ptr, dep_ptr);
1445 } 1618 }
1446 1619 else
1447 *dep_ptr = NULL; 1620 {
1448 return false; 1621 sd_list_types_def types = it_ptr->types;
1449 } 1622
1623 if (types != SD_LIST_NONE)
1624 /* Switch to next list. */
1625 {
1626 deps_list_t list;
1627
1628 sd_next_list (it_ptr->insn,
1629 &it_ptr->types, &list, &it_ptr->resolved_p);
1630
1631 if (list)
1632 {
1633 it_ptr->linkp = &DEPS_LIST_FIRST (list);
1634 continue;
1635 }
1636 }
1637
1638 *dep_ptr = NULL;
1639 return false;
1640 }
1641 }
1450 } 1642 }
1451 1643
1452 /* Advance iterator. */ 1644 /* Advance iterator. */
1453 static inline void 1645 static inline void
1454 sd_iterator_next (sd_iterator_def *it_ptr) 1646 sd_iterator_next (sd_iterator_def *it_ptr)
1469 #define DISPATCH_INIT 5 1661 #define DISPATCH_INIT 5
1470 #define ADD_TO_DISPATCH_WINDOW 6 1662 #define ADD_TO_DISPATCH_WINDOW 6
1471 1663
1472 extern int sd_lists_size (const_rtx, sd_list_types_def); 1664 extern int sd_lists_size (const_rtx, sd_list_types_def);
1473 extern bool sd_lists_empty_p (const_rtx, sd_list_types_def); 1665 extern bool sd_lists_empty_p (const_rtx, sd_list_types_def);
1474 extern void sd_init_insn (rtx); 1666 extern void sd_init_insn (rtx_insn *);
1475 extern void sd_finish_insn (rtx); 1667 extern void sd_finish_insn (rtx_insn *);
1476 extern dep_t sd_find_dep_between (rtx, rtx, bool); 1668 extern dep_t sd_find_dep_between (rtx, rtx, bool);
1477 extern void sd_add_dep (dep_t, bool); 1669 extern void sd_add_dep (dep_t, bool);
1478 extern enum DEPS_ADJUST_RESULT sd_add_or_update_dep (dep_t, bool); 1670 extern enum DEPS_ADJUST_RESULT sd_add_or_update_dep (dep_t, bool);
1479 extern void sd_resolve_dep (sd_iterator_def); 1671 extern void sd_resolve_dep (sd_iterator_def);
1480 extern void sd_copy_back_deps (rtx, rtx, bool); 1672 extern void sd_unresolve_dep (sd_iterator_def);
1673 extern void sd_copy_back_deps (rtx_insn *, rtx_insn *, bool);
1481 extern void sd_delete_dep (sd_iterator_def); 1674 extern void sd_delete_dep (sd_iterator_def);
1482 extern void sd_debug_lists (rtx, sd_list_types_def); 1675 extern void sd_debug_lists (rtx, sd_list_types_def);
1483 1676
1677 /* Macros and declarations for scheduling fusion. */
1678 #define FUSION_MAX_PRIORITY (INT_MAX)
1679 extern bool sched_fusion;
1680
1484 #endif /* INSN_SCHEDULING */ 1681 #endif /* INSN_SCHEDULING */
1485 1682
1486 /* Functions in sched-vis.c. These must be outside INSN_SCHEDULING as
1487 sched-vis.c is compiled always. */
1488 extern void print_insn (char *, const_rtx, int);
1489 extern void print_pattern (char *, const_rtx, int);
1490 extern void print_value (char *, const_rtx, int);
1491
1492 #endif /* GCC_SCHED_INT_H */ 1683 #endif /* GCC_SCHED_INT_H */
1684