]>
Commit | Line | Data |
---|---|---|
e855c69d AB |
1 | /* Instruction scheduling pass. This file contains definitions used |
2 | internally in the scheduler. | |
d1e082c2 | 3 | Copyright (C) 2006-2013 Free Software Foundation, Inc. |
e855c69d AB |
4 | |
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #ifndef GCC_SEL_SCHED_IR_H | |
22 | #define GCC_SEL_SCHED_IR_H | |
23 | ||
24 | /* For state_t. */ | |
25 | #include "insn-attr.h" | |
7a8cba34 | 26 | #include "regset.h" |
e855c69d AB |
27 | #include "basic-block.h" |
28 | /* For reg_note. */ | |
29 | #include "rtl.h" | |
30 | #include "ggc.h" | |
31 | #include "bitmap.h" | |
e855c69d AB |
32 | #include "sched-int.h" |
33 | #include "cfgloop.h" | |
34 | ||
35 | /* tc_t is a short for target context. This is a state of the target | |
36 | backend. */ | |
37 | typedef void *tc_t; | |
38 | ||
39 | /* List data types used for av sets, fences, paths, and boundaries. */ | |
40 | ||
41 | /* Forward declarations for types that are part of some list nodes. */ | |
42 | struct _list_node; | |
43 | ||
44 | /* List backend. */ | |
45 | typedef struct _list_node *_list_t; | |
46 | #define _LIST_NEXT(L) ((L)->next) | |
47 | ||
48 | /* Instruction data that is part of vinsn type. */ | |
49 | struct idata_def; | |
50 | typedef struct idata_def *idata_t; | |
51 | ||
52 | /* A virtual instruction, i.e. an instruction as seen by the scheduler. */ | |
53 | struct vinsn_def; | |
54 | typedef struct vinsn_def *vinsn_t; | |
55 | ||
56 | /* RTX list. | |
57 | This type is the backend for ilist. */ | |
58 | typedef _list_t _xlist_t; | |
59 | #define _XLIST_X(L) ((L)->u.x) | |
60 | #define _XLIST_NEXT(L) (_LIST_NEXT (L)) | |
61 | ||
62 | /* Instruction. */ | |
63 | typedef rtx insn_t; | |
64 | ||
65 | /* List of insns. */ | |
66 | typedef _xlist_t ilist_t; | |
67 | #define ILIST_INSN(L) (_XLIST_X (L)) | |
68 | #define ILIST_NEXT(L) (_XLIST_NEXT (L)) | |
69 | ||
b8698a0f | 70 | /* This lists possible transformations that done locally, i.e. in |
e855c69d AB |
71 | moveup_expr. */ |
72 | enum local_trans_type | |
73 | { | |
74 | TRANS_SUBSTITUTION, | |
75 | TRANS_SPECULATION | |
76 | }; | |
77 | ||
b8698a0f | 78 | /* This struct is used to record the history of expression's |
e855c69d AB |
79 | transformations. */ |
80 | struct expr_history_def_1 | |
81 | { | |
82 | /* UID of the insn. */ | |
83 | unsigned uid; | |
84 | ||
85 | /* How the expression looked like. */ | |
86 | vinsn_t old_expr_vinsn; | |
87 | ||
88 | /* How the expression looks after the transformation. */ | |
89 | vinsn_t new_expr_vinsn; | |
90 | ||
91 | /* And its speculative status. */ | |
92 | ds_t spec_ds; | |
93 | ||
94 | /* Type of the transformation. */ | |
95 | enum local_trans_type type; | |
96 | }; | |
97 | ||
98 | typedef struct expr_history_def_1 expr_history_def; | |
99 | ||
e855c69d AB |
100 | |
101 | /* Expression information. */ | |
102 | struct _expr | |
103 | { | |
104 | /* Insn description. */ | |
105 | vinsn_t vinsn; | |
106 | ||
107 | /* SPEC is the degree of speculativeness. | |
108 | FIXME: now spec is increased when an rhs is moved through a | |
109 | conditional, thus showing only control speculativeness. In the | |
110 | future we'd like to count data spec separately to allow a better | |
111 | control on scheduling. */ | |
112 | int spec; | |
113 | ||
b8698a0f L |
114 | /* Degree of speculativeness measured as probability of executing |
115 | instruction's original basic block given relative to | |
e855c69d AB |
116 | the current scheduling point. */ |
117 | int usefulness; | |
118 | ||
119 | /* A priority of this expression. */ | |
120 | int priority; | |
121 | ||
122 | /* A priority adjustment of this expression. */ | |
123 | int priority_adj; | |
124 | ||
125 | /* Number of times the insn was scheduled. */ | |
126 | int sched_times; | |
127 | ||
b8698a0f | 128 | /* A basic block index this was originated from. Zero when there is |
e855c69d AB |
129 | more than one originator. */ |
130 | int orig_bb_index; | |
131 | ||
132 | /* Instruction should be of SPEC_DONE_DS type in order to be moved to this | |
133 | point. */ | |
134 | ds_t spec_done_ds; | |
135 | ||
136 | /* SPEC_TO_CHECK_DS hold speculation types that should be checked | |
137 | (used only during move_op ()). */ | |
138 | ds_t spec_to_check_ds; | |
139 | ||
b8698a0f | 140 | /* Cycle on which original insn was scheduled. Zero when it has not yet |
e855c69d AB |
141 | been scheduled or more than one originator. */ |
142 | int orig_sched_cycle; | |
143 | ||
144 | /* This vector contains the history of insn's transformations. */ | |
9771b263 | 145 | vec<expr_history_def> history_of_changes; |
e855c69d | 146 | |
b8698a0f | 147 | /* True (1) when original target (register or memory) of this instruction |
e855c69d AB |
148 | is available for scheduling, false otherwise. -1 means we're not sure; |
149 | please run find_used_regs to clarify. */ | |
150 | signed char target_available; | |
151 | ||
b8698a0f | 152 | /* True when this expression needs a speculation check to be scheduled. |
e855c69d AB |
153 | This is used during find_used_regs. */ |
154 | BOOL_BITFIELD needs_spec_check_p : 1; | |
155 | ||
b8698a0f | 156 | /* True when the expression was substituted. Used for statistical |
e855c69d AB |
157 | purposes. */ |
158 | BOOL_BITFIELD was_substituted : 1; | |
159 | ||
160 | /* True when the expression was renamed. */ | |
161 | BOOL_BITFIELD was_renamed : 1; | |
162 | ||
163 | /* True when expression can't be moved. */ | |
164 | BOOL_BITFIELD cant_move : 1; | |
165 | }; | |
166 | ||
167 | typedef struct _expr expr_def; | |
168 | typedef expr_def *expr_t; | |
169 | ||
170 | #define EXPR_VINSN(EXPR) ((EXPR)->vinsn) | |
171 | #define EXPR_INSN_RTX(EXPR) (VINSN_INSN_RTX (EXPR_VINSN (EXPR))) | |
172 | #define EXPR_PATTERN(EXPR) (VINSN_PATTERN (EXPR_VINSN (EXPR))) | |
173 | #define EXPR_LHS(EXPR) (VINSN_LHS (EXPR_VINSN (EXPR))) | |
174 | #define EXPR_RHS(EXPR) (VINSN_RHS (EXPR_VINSN (EXPR))) | |
175 | #define EXPR_TYPE(EXPR) (VINSN_TYPE (EXPR_VINSN (EXPR))) | |
176 | #define EXPR_SEPARABLE_P(EXPR) (VINSN_SEPARABLE_P (EXPR_VINSN (EXPR))) | |
177 | ||
178 | #define EXPR_SPEC(EXPR) ((EXPR)->spec) | |
179 | #define EXPR_USEFULNESS(EXPR) ((EXPR)->usefulness) | |
180 | #define EXPR_PRIORITY(EXPR) ((EXPR)->priority) | |
181 | #define EXPR_PRIORITY_ADJ(EXPR) ((EXPR)->priority_adj) | |
182 | #define EXPR_SCHED_TIMES(EXPR) ((EXPR)->sched_times) | |
183 | #define EXPR_ORIG_BB_INDEX(EXPR) ((EXPR)->orig_bb_index) | |
184 | #define EXPR_ORIG_SCHED_CYCLE(EXPR) ((EXPR)->orig_sched_cycle) | |
185 | #define EXPR_SPEC_DONE_DS(EXPR) ((EXPR)->spec_done_ds) | |
186 | #define EXPR_SPEC_TO_CHECK_DS(EXPR) ((EXPR)->spec_to_check_ds) | |
187 | #define EXPR_HISTORY_OF_CHANGES(EXPR) ((EXPR)->history_of_changes) | |
188 | #define EXPR_TARGET_AVAILABLE(EXPR) ((EXPR)->target_available) | |
189 | #define EXPR_NEEDS_SPEC_CHECK_P(EXPR) ((EXPR)->needs_spec_check_p) | |
190 | #define EXPR_WAS_SUBSTITUTED(EXPR) ((EXPR)->was_substituted) | |
191 | #define EXPR_WAS_RENAMED(EXPR) ((EXPR)->was_renamed) | |
192 | #define EXPR_CANT_MOVE(EXPR) ((EXPR)->cant_move) | |
193 | ||
e855c69d AB |
194 | /* Insn definition for list of original insns in find_used_regs. */ |
195 | struct _def | |
196 | { | |
197 | insn_t orig_insn; | |
198 | ||
199 | /* FIXME: Get rid of CROSSES_CALL in each def, since if we're moving up | |
200 | rhs from two different places, but only one of the code motion paths | |
b8698a0f | 201 | crosses a call, we can't use any of the call_used_regs, no matter which |
e855c69d AB |
202 | path or whether all paths crosses a call. Thus we should move CROSSES_CALL |
203 | to static params. */ | |
204 | bool crosses_call; | |
205 | }; | |
206 | typedef struct _def *def_t; | |
207 | ||
208 | ||
209 | /* Availability sets are sets of expressions we're scheduling. */ | |
210 | typedef _list_t av_set_t; | |
211 | #define _AV_SET_EXPR(L) (&(L)->u.expr) | |
212 | #define _AV_SET_NEXT(L) (_LIST_NEXT (L)) | |
213 | ||
214 | ||
215 | /* Boundary of the current fence group. */ | |
216 | struct _bnd | |
217 | { | |
218 | /* The actual boundary instruction. */ | |
219 | insn_t to; | |
220 | ||
221 | /* Its path to the fence. */ | |
222 | ilist_t ptr; | |
223 | ||
224 | /* Availability set at the boundary. */ | |
225 | av_set_t av; | |
226 | ||
227 | /* This set moved to the fence. */ | |
228 | av_set_t av1; | |
b8698a0f | 229 | |
e855c69d AB |
230 | /* Deps context at this boundary. As long as we have one boundary per fence, |
231 | this is just a pointer to the same deps context as in the corresponding | |
232 | fence. */ | |
233 | deps_t dc; | |
234 | }; | |
235 | typedef struct _bnd *bnd_t; | |
236 | #define BND_TO(B) ((B)->to) | |
237 | ||
238 | /* PTR stands not for pointer as you might think, but as a Path To Root of the | |
239 | current instruction group from boundary B. */ | |
240 | #define BND_PTR(B) ((B)->ptr) | |
241 | #define BND_AV(B) ((B)->av) | |
242 | #define BND_AV1(B) ((B)->av1) | |
243 | #define BND_DC(B) ((B)->dc) | |
244 | ||
245 | /* List of boundaries. */ | |
246 | typedef _list_t blist_t; | |
247 | #define BLIST_BND(L) (&(L)->u.bnd) | |
248 | #define BLIST_NEXT(L) (_LIST_NEXT (L)) | |
249 | ||
250 | ||
251 | /* Fence information. A fence represents current scheduling point and also | |
252 | blocks code motion through it when pipelining. */ | |
253 | struct _fence | |
254 | { | |
255 | /* Insn before which we gather an instruction group.*/ | |
256 | insn_t insn; | |
257 | ||
258 | /* Modeled state of the processor pipeline. */ | |
259 | state_t state; | |
260 | ||
261 | /* Current cycle that is being scheduled on this fence. */ | |
262 | int cycle; | |
263 | ||
264 | /* Number of insns that were scheduled on the current cycle. | |
265 | This information has to be local to a fence. */ | |
266 | int cycle_issued_insns; | |
267 | ||
268 | /* At the end of fill_insns () this field holds the list of the instructions | |
269 | that are inner boundaries of the scheduled parallel group. */ | |
270 | ilist_t bnds; | |
271 | ||
272 | /* Deps context at this fence. It is used to model dependencies at the | |
273 | fence so that insn ticks can be properly evaluated. */ | |
274 | deps_t dc; | |
275 | ||
276 | /* Target context at this fence. Used to save and load any local target | |
277 | scheduling information when changing fences. */ | |
278 | tc_t tc; | |
279 | ||
280 | /* A vector of insns that are scheduled but not yet completed. */ | |
9771b263 | 281 | vec<rtx, va_gc> *executing_insns; |
e855c69d | 282 | |
b8698a0f | 283 | /* A vector indexed by UIDs that caches the earliest cycle on which |
e855c69d AB |
284 | an insn can be scheduled on this fence. */ |
285 | int *ready_ticks; | |
286 | ||
287 | /* Its size. */ | |
288 | int ready_ticks_size; | |
289 | ||
290 | /* Insn, which has been scheduled last on this fence. */ | |
291 | rtx last_scheduled_insn; | |
292 | ||
136e01a3 AB |
293 | /* The last value of can_issue_more variable on this fence. */ |
294 | int issue_more; | |
295 | ||
e855c69d AB |
296 | /* If non-NULL force the next scheduled insn to be SCHED_NEXT. */ |
297 | rtx sched_next; | |
298 | ||
299 | /* True if fill_insns processed this fence. */ | |
300 | BOOL_BITFIELD processed_p : 1; | |
301 | ||
302 | /* True if fill_insns actually scheduled something on this fence. */ | |
303 | BOOL_BITFIELD scheduled_p : 1; | |
304 | ||
305 | /* True when the next insn scheduled here would start a cycle. */ | |
306 | BOOL_BITFIELD starts_cycle_p : 1; | |
307 | ||
308 | /* True when the next insn scheduled here would be scheduled after a stall. */ | |
309 | BOOL_BITFIELD after_stall_p : 1; | |
310 | }; | |
311 | typedef struct _fence *fence_t; | |
312 | ||
313 | #define FENCE_INSN(F) ((F)->insn) | |
314 | #define FENCE_STATE(F) ((F)->state) | |
315 | #define FENCE_BNDS(F) ((F)->bnds) | |
316 | #define FENCE_PROCESSED_P(F) ((F)->processed_p) | |
317 | #define FENCE_SCHEDULED_P(F) ((F)->scheduled_p) | |
318 | #define FENCE_ISSUED_INSNS(F) ((F)->cycle_issued_insns) | |
319 | #define FENCE_CYCLE(F) ((F)->cycle) | |
320 | #define FENCE_STARTS_CYCLE_P(F) ((F)->starts_cycle_p) | |
321 | #define FENCE_AFTER_STALL_P(F) ((F)->after_stall_p) | |
322 | #define FENCE_DC(F) ((F)->dc) | |
323 | #define FENCE_TC(F) ((F)->tc) | |
324 | #define FENCE_LAST_SCHEDULED_INSN(F) ((F)->last_scheduled_insn) | |
136e01a3 | 325 | #define FENCE_ISSUE_MORE(F) ((F)->issue_more) |
e855c69d AB |
326 | #define FENCE_EXECUTING_INSNS(F) ((F)->executing_insns) |
327 | #define FENCE_READY_TICKS(F) ((F)->ready_ticks) | |
328 | #define FENCE_READY_TICKS_SIZE(F) ((F)->ready_ticks_size) | |
329 | #define FENCE_SCHED_NEXT(F) ((F)->sched_next) | |
330 | ||
331 | /* List of fences. */ | |
332 | typedef _list_t flist_t; | |
333 | #define FLIST_FENCE(L) (&(L)->u.fence) | |
334 | #define FLIST_NEXT(L) (_LIST_NEXT (L)) | |
335 | ||
336 | /* List of fences with pointer to the tail node. */ | |
337 | struct flist_tail_def | |
338 | { | |
339 | flist_t head; | |
340 | flist_t *tailp; | |
341 | }; | |
342 | ||
343 | typedef struct flist_tail_def *flist_tail_t; | |
344 | #define FLIST_TAIL_HEAD(L) ((L)->head) | |
345 | #define FLIST_TAIL_TAILP(L) ((L)->tailp) | |
346 | ||
347 | /* List node information. A list node can be any of the types above. */ | |
348 | struct _list_node | |
349 | { | |
350 | _list_t next; | |
351 | ||
352 | union | |
353 | { | |
354 | rtx x; | |
355 | struct _bnd bnd; | |
356 | expr_def expr; | |
357 | struct _fence fence; | |
358 | struct _def def; | |
359 | void *data; | |
360 | } u; | |
361 | }; | |
362 | \f | |
363 | ||
364 | /* _list_t functions. | |
365 | All of _*list_* functions are used through accessor macros, thus | |
366 | we can't move them in sel-sched-ir.c. */ | |
367 | extern alloc_pool sched_lists_pool; | |
368 | ||
369 | static inline _list_t | |
370 | _list_alloc (void) | |
371 | { | |
372 | return (_list_t) pool_alloc (sched_lists_pool); | |
373 | } | |
374 | ||
375 | static inline void | |
376 | _list_add (_list_t *lp) | |
377 | { | |
378 | _list_t l = _list_alloc (); | |
379 | ||
380 | _LIST_NEXT (l) = *lp; | |
381 | *lp = l; | |
382 | } | |
383 | ||
384 | static inline void | |
385 | _list_remove_nofree (_list_t *lp) | |
386 | { | |
387 | _list_t n = *lp; | |
388 | ||
389 | *lp = _LIST_NEXT (n); | |
390 | } | |
391 | ||
392 | static inline void | |
393 | _list_remove (_list_t *lp) | |
394 | { | |
395 | _list_t n = *lp; | |
396 | ||
397 | *lp = _LIST_NEXT (n); | |
398 | pool_free (sched_lists_pool, n); | |
399 | } | |
400 | ||
401 | static inline void | |
402 | _list_clear (_list_t *l) | |
403 | { | |
404 | while (*l) | |
405 | _list_remove (l); | |
406 | } | |
407 | \f | |
408 | ||
409 | /* List iterator backend. */ | |
84562394 | 410 | struct _list_iterator |
e855c69d AB |
411 | { |
412 | /* The list we're iterating. */ | |
413 | _list_t *lp; | |
414 | ||
415 | /* True when this iterator supprts removing. */ | |
416 | bool can_remove_p; | |
417 | ||
418 | /* True when we've actually removed something. */ | |
419 | bool removed_p; | |
84562394 | 420 | }; |
e855c69d AB |
421 | |
422 | static inline void | |
423 | _list_iter_start (_list_iterator *ip, _list_t *lp, bool can_remove_p) | |
424 | { | |
425 | ip->lp = lp; | |
426 | ip->can_remove_p = can_remove_p; | |
427 | ip->removed_p = false; | |
428 | } | |
429 | ||
430 | static inline void | |
431 | _list_iter_next (_list_iterator *ip) | |
432 | { | |
433 | if (!ip->removed_p) | |
434 | ip->lp = &_LIST_NEXT (*ip->lp); | |
435 | else | |
436 | ip->removed_p = false; | |
437 | } | |
438 | ||
439 | static inline void | |
440 | _list_iter_remove (_list_iterator *ip) | |
441 | { | |
442 | gcc_assert (!ip->removed_p && ip->can_remove_p); | |
443 | _list_remove (ip->lp); | |
444 | ip->removed_p = true; | |
445 | } | |
446 | ||
447 | static inline void | |
448 | _list_iter_remove_nofree (_list_iterator *ip) | |
449 | { | |
450 | gcc_assert (!ip->removed_p && ip->can_remove_p); | |
451 | _list_remove_nofree (ip->lp); | |
452 | ip->removed_p = true; | |
453 | } | |
454 | ||
455 | /* General macros to traverse a list. FOR_EACH_* interfaces are | |
456 | implemented using these. */ | |
457 | #define _FOR_EACH(TYPE, ELEM, I, L) \ | |
458 | for (_list_iter_start (&(I), &(L), false); \ | |
459 | _list_iter_cond_##TYPE (*(I).lp, &(ELEM)); \ | |
460 | _list_iter_next (&(I))) | |
461 | ||
462 | #define _FOR_EACH_1(TYPE, ELEM, I, LP) \ | |
463 | for (_list_iter_start (&(I), (LP), true); \ | |
464 | _list_iter_cond_##TYPE (*(I).lp, &(ELEM)); \ | |
b8698a0f | 465 | _list_iter_next (&(I))) |
e855c69d AB |
466 | \f |
467 | ||
468 | /* _xlist_t functions. */ | |
469 | ||
470 | static inline void | |
471 | _xlist_add (_xlist_t *lp, rtx x) | |
472 | { | |
473 | _list_add (lp); | |
474 | _XLIST_X (*lp) = x; | |
475 | } | |
476 | ||
477 | #define _xlist_remove(LP) (_list_remove (LP)) | |
478 | #define _xlist_clear(LP) (_list_clear (LP)) | |
479 | ||
480 | static inline bool | |
481 | _xlist_is_in_p (_xlist_t l, rtx x) | |
482 | { | |
483 | while (l) | |
484 | { | |
485 | if (_XLIST_X (l) == x) | |
486 | return true; | |
487 | l = _XLIST_NEXT (l); | |
488 | } | |
489 | ||
490 | return false; | |
491 | } | |
492 | ||
493 | /* Used through _FOR_EACH. */ | |
494 | static inline bool | |
495 | _list_iter_cond_x (_xlist_t l, rtx *xp) | |
496 | { | |
497 | if (l) | |
498 | { | |
499 | *xp = _XLIST_X (l); | |
500 | return true; | |
501 | } | |
502 | ||
503 | return false; | |
504 | } | |
505 | ||
506 | #define _xlist_iter_remove(IP) (_list_iter_remove (IP)) | |
507 | ||
508 | typedef _list_iterator _xlist_iterator; | |
509 | #define _FOR_EACH_X(X, I, L) _FOR_EACH (x, (X), (I), (L)) | |
510 | #define _FOR_EACH_X_1(X, I, LP) _FOR_EACH_1 (x, (X), (I), (LP)) | |
511 | \f | |
512 | ||
513 | /* ilist_t functions. Instruction lists are simply RTX lists. */ | |
514 | ||
515 | #define ilist_add(LP, INSN) (_xlist_add ((LP), (INSN))) | |
516 | #define ilist_remove(LP) (_xlist_remove (LP)) | |
517 | #define ilist_clear(LP) (_xlist_clear (LP)) | |
518 | #define ilist_is_in_p(L, INSN) (_xlist_is_in_p ((L), (INSN))) | |
519 | #define ilist_iter_remove(IP) (_xlist_iter_remove (IP)) | |
520 | ||
521 | typedef _xlist_iterator ilist_iterator; | |
522 | #define FOR_EACH_INSN(INSN, I, L) _FOR_EACH_X (INSN, I, L) | |
523 | #define FOR_EACH_INSN_1(INSN, I, LP) _FOR_EACH_X_1 (INSN, I, LP) | |
524 | \f | |
525 | ||
526 | /* Av set iterators. */ | |
527 | typedef _list_iterator av_set_iterator; | |
528 | #define FOR_EACH_EXPR(EXPR, I, AV) _FOR_EACH (expr, (EXPR), (I), (AV)) | |
529 | #define FOR_EACH_EXPR_1(EXPR, I, AV) _FOR_EACH_1 (expr, (EXPR), (I), (AV)) | |
530 | ||
7b3b6ae4 | 531 | inline bool |
e855c69d AB |
532 | _list_iter_cond_expr (av_set_t av, expr_t *exprp) |
533 | { | |
534 | if (av) | |
535 | { | |
536 | *exprp = _AV_SET_EXPR (av); | |
537 | return true; | |
538 | } | |
539 | ||
540 | return false; | |
541 | } | |
542 | \f | |
543 | ||
544 | /* Def list iterators. */ | |
545 | typedef _list_t def_list_t; | |
546 | typedef _list_iterator def_list_iterator; | |
547 | ||
548 | #define DEF_LIST_NEXT(L) (_LIST_NEXT (L)) | |
549 | #define DEF_LIST_DEF(L) (&(L)->u.def) | |
550 | ||
551 | #define FOR_EACH_DEF(DEF, I, DEF_LIST) _FOR_EACH (def, (DEF), (I), (DEF_LIST)) | |
552 | ||
553 | static inline bool | |
554 | _list_iter_cond_def (def_list_t def_list, def_t *def) | |
555 | { | |
556 | if (def_list) | |
557 | { | |
558 | *def = DEF_LIST_DEF (def_list); | |
559 | return true; | |
560 | } | |
561 | ||
562 | return false; | |
563 | } | |
564 | \f | |
565 | ||
566 | /* InstructionData. Contains information about insn pattern. */ | |
567 | struct idata_def | |
568 | { | |
569 | /* Type of the insn. | |
570 | o CALL_INSN - Call insn | |
571 | o JUMP_INSN - Jump insn | |
572 | o INSN - INSN that cannot be cloned | |
573 | o USE - INSN that can be cloned | |
574 | o SET - INSN that can be cloned and separable into lhs and rhs | |
575 | o PC - simplejump. Insns that simply redirect control flow should not | |
576 | have any dependencies. Sched-deps.c, though, might consider them as | |
577 | producers or consumers of certain registers. To avoid that we handle | |
578 | dependency for simple jumps ourselves. */ | |
579 | int type; | |
580 | ||
581 | /* If insn is a SET, this is its left hand side. */ | |
582 | rtx lhs; | |
583 | ||
584 | /* If insn is a SET, this is its right hand side. */ | |
585 | rtx rhs; | |
586 | ||
587 | /* Registers that are set/used by this insn. This info is now gathered | |
588 | via sched-deps.c. The downside of this is that we also use live info | |
589 | from flow that is accumulated in the basic blocks. These two infos | |
590 | can be slightly inconsistent, hence in the beginning we make a pass | |
591 | through CFG and calculating the conservative solution for the info in | |
592 | basic blocks. When this scheduler will be switched to use dataflow, | |
593 | this can be unified as df gives us both per basic block and per | |
594 | instruction info. Actually, we don't do that pass and just hope | |
595 | for the best. */ | |
596 | regset reg_sets; | |
597 | ||
598 | regset reg_clobbers; | |
599 | ||
600 | regset reg_uses; | |
601 | }; | |
602 | ||
603 | #define IDATA_TYPE(ID) ((ID)->type) | |
604 | #define IDATA_LHS(ID) ((ID)->lhs) | |
605 | #define IDATA_RHS(ID) ((ID)->rhs) | |
606 | #define IDATA_REG_SETS(ID) ((ID)->reg_sets) | |
607 | #define IDATA_REG_USES(ID) ((ID)->reg_uses) | |
608 | #define IDATA_REG_CLOBBERS(ID) ((ID)->reg_clobbers) | |
609 | ||
610 | /* Type to represent all needed info to emit an insn. | |
611 | This is a virtual equivalent of the insn. | |
612 | Every insn in the stream has an associated vinsn. This is used | |
613 | to reduce memory consumption basing on the fact that many insns | |
614 | don't change through the scheduler. | |
615 | ||
616 | vinsn can be either normal or unique. | |
617 | * Normal vinsn is the one, that can be cloned multiple times and typically | |
618 | corresponds to normal instruction. | |
619 | ||
620 | * Unique vinsn derivates from CALL, ASM, JUMP (for a while) and other | |
621 | unusual stuff. Such a vinsn is described by its INSN field, which is a | |
622 | reference to the original instruction. */ | |
623 | struct vinsn_def | |
624 | { | |
625 | /* Associated insn. */ | |
626 | rtx insn_rtx; | |
627 | ||
628 | /* Its description. */ | |
629 | struct idata_def id; | |
630 | ||
631 | /* Hash of vinsn. It is computed either from pattern or from rhs using | |
632 | hash_rtx. It is not placed in ID for faster compares. */ | |
633 | unsigned hash; | |
634 | ||
635 | /* Hash of the insn_rtx pattern. */ | |
636 | unsigned hash_rtx; | |
637 | ||
638 | /* Smart pointer counter. */ | |
639 | int count; | |
640 | ||
641 | /* Cached cost of the vinsn. To access it please use vinsn_cost (). */ | |
642 | int cost; | |
643 | ||
644 | /* Mark insns that may trap so we don't move them through jumps. */ | |
645 | bool may_trap_p; | |
646 | }; | |
647 | ||
648 | #define VINSN_INSN_RTX(VI) ((VI)->insn_rtx) | |
649 | #define VINSN_PATTERN(VI) (PATTERN (VINSN_INSN_RTX (VI))) | |
650 | ||
651 | #define VINSN_ID(VI) (&((VI)->id)) | |
652 | #define VINSN_HASH(VI) ((VI)->hash) | |
653 | #define VINSN_HASH_RTX(VI) ((VI)->hash_rtx) | |
654 | #define VINSN_TYPE(VI) (IDATA_TYPE (VINSN_ID (VI))) | |
655 | #define VINSN_SEPARABLE_P(VI) (VINSN_TYPE (VI) == SET) | |
656 | #define VINSN_CLONABLE_P(VI) (VINSN_SEPARABLE_P (VI) || VINSN_TYPE (VI) == USE) | |
657 | #define VINSN_UNIQUE_P(VI) (!VINSN_CLONABLE_P (VI)) | |
658 | #define VINSN_LHS(VI) (IDATA_LHS (VINSN_ID (VI))) | |
659 | #define VINSN_RHS(VI) (IDATA_RHS (VINSN_ID (VI))) | |
660 | #define VINSN_REG_SETS(VI) (IDATA_REG_SETS (VINSN_ID (VI))) | |
661 | #define VINSN_REG_USES(VI) (IDATA_REG_USES (VINSN_ID (VI))) | |
662 | #define VINSN_REG_CLOBBERS(VI) (IDATA_REG_CLOBBERS (VINSN_ID (VI))) | |
663 | #define VINSN_COUNT(VI) ((VI)->count) | |
664 | #define VINSN_MAY_TRAP_P(VI) ((VI)->may_trap_p) | |
665 | \f | |
666 | ||
b8698a0f | 667 | /* An entry of the hashtable describing transformations happened when |
e855c69d AB |
668 | moving up through an insn. */ |
669 | struct transformed_insns | |
670 | { | |
671 | /* Previous vinsn. Used to find the proper element. */ | |
672 | vinsn_t vinsn_old; | |
673 | ||
674 | /* A new vinsn. */ | |
675 | vinsn_t vinsn_new; | |
676 | ||
677 | /* Speculative status. */ | |
678 | ds_t ds; | |
679 | ||
680 | /* Type of transformation happened. */ | |
681 | enum local_trans_type type; | |
682 | ||
683 | /* Whether a conflict on the target register happened. */ | |
684 | BOOL_BITFIELD was_target_conflict : 1; | |
685 | ||
686 | /* Whether a check was needed. */ | |
687 | BOOL_BITFIELD needs_check : 1; | |
688 | }; | |
689 | ||
690 | /* Indexed by INSN_LUID, the collection of all data associated with | |
691 | a single instruction that is in the stream. */ | |
692 | struct _sel_insn_data | |
693 | { | |
694 | /* The expression that contains vinsn for this insn and some | |
695 | flow-sensitive data like priority. */ | |
696 | expr_def expr; | |
697 | ||
698 | /* If (WS_LEVEL == GLOBAL_LEVEL) then AV is empty. */ | |
699 | int ws_level; | |
700 | ||
701 | /* A number that helps in defining a traversing order for a region. */ | |
702 | int seqno; | |
703 | ||
704 | /* A liveness data computed above this insn. */ | |
705 | regset live; | |
706 | ||
707 | /* An INSN_UID bit is set when deps analysis result is already known. */ | |
708 | bitmap analyzed_deps; | |
709 | ||
b8698a0f | 710 | /* An INSN_UID bit is set when a hard dep was found, not set when |
e855c69d AB |
711 | no dependence is found. This is meaningful only when the analyzed_deps |
712 | bitmap has its bit set. */ | |
713 | bitmap found_deps; | |
714 | ||
b8698a0f | 715 | /* An INSN_UID bit is set when this is a bookkeeping insn generated from |
14f30b87 AM |
716 | a parent with this uid. If a parent is a bookkeeping copy, all its |
717 | originators are transitively included in this set. */ | |
e855c69d AB |
718 | bitmap originators; |
719 | ||
720 | /* A hashtable caching the result of insn transformations through this one. */ | |
721 | htab_t transformed_insns; | |
b8698a0f | 722 | |
e855c69d | 723 | /* A context incapsulating this insn. */ |
88302d54 | 724 | struct deps_desc deps_context; |
e855c69d AB |
725 | |
726 | /* This field is initialized at the beginning of scheduling and is used | |
727 | to handle sched group instructions. If it is non-null, then it points | |
728 | to the instruction, which should be forced to schedule next. Such | |
729 | instructions are unique. */ | |
730 | insn_t sched_next; | |
731 | ||
732 | /* Cycle at which insn was scheduled. It is greater than zero if insn was | |
733 | scheduled. This is used for bundling. */ | |
734 | int sched_cycle; | |
735 | ||
736 | /* Cycle at which insn's data will be fully ready. */ | |
737 | int ready_cycle; | |
738 | ||
739 | /* Speculations that are being checked by this insn. */ | |
740 | ds_t spec_checked_ds; | |
741 | ||
742 | /* Whether the live set valid or not. */ | |
743 | BOOL_BITFIELD live_valid_p : 1; | |
744 | /* Insn is an ASM. */ | |
745 | BOOL_BITFIELD asm_p : 1; | |
746 | ||
747 | /* True when an insn is scheduled after we've determined that a stall is | |
748 | required. | |
749 | This is used when emulating the Haifa scheduler for bundling. */ | |
750 | BOOL_BITFIELD after_stall_p : 1; | |
751 | }; | |
752 | ||
753 | typedef struct _sel_insn_data sel_insn_data_def; | |
754 | typedef sel_insn_data_def *sel_insn_data_t; | |
755 | ||
9771b263 | 756 | extern vec<sel_insn_data_def> s_i_d; |
e855c69d AB |
757 | |
758 | /* Accessor macros for s_i_d. */ | |
9771b263 DN |
759 | #define SID(INSN) (&s_i_d[INSN_LUID (INSN)]) |
760 | #define SID_BY_UID(UID) (&s_i_d[LUID_BY_UID (UID)]) | |
e855c69d AB |
761 | |
762 | extern sel_insn_data_def insn_sid (insn_t); | |
763 | ||
764 | #define INSN_ASM_P(INSN) (SID (INSN)->asm_p) | |
765 | #define INSN_SCHED_NEXT(INSN) (SID (INSN)->sched_next) | |
766 | #define INSN_ANALYZED_DEPS(INSN) (SID (INSN)->analyzed_deps) | |
b8698a0f L |
767 | #define INSN_FOUND_DEPS(INSN) (SID (INSN)->found_deps) |
768 | #define INSN_DEPS_CONTEXT(INSN) (SID (INSN)->deps_context) | |
e855c69d AB |
769 | #define INSN_ORIGINATORS(INSN) (SID (INSN)->originators) |
770 | #define INSN_ORIGINATORS_BY_UID(UID) (SID_BY_UID (UID)->originators) | |
771 | #define INSN_TRANSFORMED_INSNS(INSN) (SID (INSN)->transformed_insns) | |
772 | ||
773 | #define INSN_EXPR(INSN) (&SID (INSN)->expr) | |
774 | #define INSN_LIVE(INSN) (SID (INSN)->live) | |
775 | #define INSN_LIVE_VALID_P(INSN) (SID (INSN)->live_valid_p) | |
776 | #define INSN_VINSN(INSN) (EXPR_VINSN (INSN_EXPR (INSN))) | |
777 | #define INSN_TYPE(INSN) (VINSN_TYPE (INSN_VINSN (INSN))) | |
778 | #define INSN_SIMPLEJUMP_P(INSN) (INSN_TYPE (INSN) == PC) | |
779 | #define INSN_LHS(INSN) (VINSN_LHS (INSN_VINSN (INSN))) | |
780 | #define INSN_RHS(INSN) (VINSN_RHS (INSN_VINSN (INSN))) | |
781 | #define INSN_REG_SETS(INSN) (VINSN_REG_SETS (INSN_VINSN (INSN))) | |
782 | #define INSN_REG_CLOBBERS(INSN) (VINSN_REG_CLOBBERS (INSN_VINSN (INSN))) | |
783 | #define INSN_REG_USES(INSN) (VINSN_REG_USES (INSN_VINSN (INSN))) | |
784 | #define INSN_SCHED_TIMES(INSN) (EXPR_SCHED_TIMES (INSN_EXPR (INSN))) | |
785 | #define INSN_SEQNO(INSN) (SID (INSN)->seqno) | |
786 | #define INSN_AFTER_STALL_P(INSN) (SID (INSN)->after_stall_p) | |
787 | #define INSN_SCHED_CYCLE(INSN) (SID (INSN)->sched_cycle) | |
788 | #define INSN_READY_CYCLE(INSN) (SID (INSN)->ready_cycle) | |
789 | #define INSN_SPEC_CHECKED_DS(INSN) (SID (INSN)->spec_checked_ds) | |
790 | ||
791 | /* A global level shows whether an insn is valid or not. */ | |
792 | extern int global_level; | |
793 | ||
794 | #define INSN_WS_LEVEL(INSN) (SID (INSN)->ws_level) | |
795 | ||
796 | extern av_set_t get_av_set (insn_t); | |
797 | extern int get_av_level (insn_t); | |
798 | ||
799 | #define AV_SET(INSN) (get_av_set (INSN)) | |
800 | #define AV_LEVEL(INSN) (get_av_level (INSN)) | |
801 | #define AV_SET_VALID_P(INSN) (AV_LEVEL (INSN) == global_level) | |
802 | ||
803 | /* A list of fences currently in the works. */ | |
804 | extern flist_t fences; | |
805 | ||
806 | /* A NOP pattern used as a placeholder for real insns. */ | |
807 | extern rtx nop_pattern; | |
808 | ||
809 | /* An insn that 'contained' in EXIT block. */ | |
810 | extern rtx exit_insn; | |
811 | ||
812 | /* Provide a separate luid for the insn. */ | |
813 | #define INSN_INIT_TODO_LUID (1) | |
814 | ||
815 | /* Initialize s_s_i_d. */ | |
816 | #define INSN_INIT_TODO_SSID (2) | |
817 | ||
818 | /* Initialize data for simplejump. */ | |
819 | #define INSN_INIT_TODO_SIMPLEJUMP (4) | |
820 | ||
821 | /* Return true if INSN is a local NOP. The nop is local in the sense that | |
822 | it was emitted by the scheduler as a temporary insn and will soon be | |
823 | deleted. These nops are identified by their pattern. */ | |
824 | #define INSN_NOP_P(INSN) (PATTERN (INSN) == nop_pattern) | |
825 | ||
826 | /* Return true if INSN is linked into instruction stream. | |
827 | NB: It is impossible for INSN to have one field null and the other not | |
828 | null: gcc_assert ((PREV_INSN (INSN) == NULL_RTX) | |
829 | == (NEXT_INSN (INSN) == NULL_RTX)) is valid. */ | |
830 | #define INSN_IN_STREAM_P(INSN) (PREV_INSN (INSN) && NEXT_INSN (INSN)) | |
831 | ||
832 | /* Return true if INSN is in current fence. */ | |
833 | #define IN_CURRENT_FENCE_P(INSN) (flist_lookup (fences, INSN) != NULL) | |
834 | ||
835 | /* Marks loop as being considered for pipelining. */ | |
836 | #define MARK_LOOP_FOR_PIPELINING(LOOP) ((LOOP)->aux = (void *)(size_t)(1)) | |
837 | #define LOOP_MARKED_FOR_PIPELINING_P(LOOP) ((size_t)((LOOP)->aux)) | |
838 | ||
839 | /* Saved loop preheader to transfer when scheduling the loop. */ | |
840 | #define LOOP_PREHEADER_BLOCKS(LOOP) ((size_t)((LOOP)->aux) == 1 \ | |
841 | ? NULL \ | |
9771b263 | 842 | : ((vec<basic_block> *) (LOOP)->aux)) |
e855c69d AB |
843 | #define SET_LOOP_PREHEADER_BLOCKS(LOOP,BLOCKS) ((LOOP)->aux \ |
844 | = (BLOCKS != NULL \ | |
845 | ? BLOCKS \ | |
846 | : (LOOP)->aux)) | |
847 | ||
848 | extern bitmap blocks_to_reschedule; | |
849 | \f | |
850 | ||
851 | /* A variable to track which part of rtx we are scanning in | |
852 | sched-deps.c: sched_analyze_insn (). */ | |
84562394 OE |
853 | enum deps_where_t |
854 | { | |
855 | DEPS_IN_INSN, | |
856 | DEPS_IN_LHS, | |
857 | DEPS_IN_RHS, | |
858 | DEPS_IN_NOWHERE | |
859 | }; | |
e855c69d AB |
860 | \f |
861 | ||
862 | /* Per basic block data for the whole CFG. */ | |
84562394 | 863 | struct sel_global_bb_info_def |
e855c69d AB |
864 | { |
865 | /* For each bb header this field contains a set of live registers. | |
866 | For all other insns this field has a NULL. | |
073a8998 | 867 | We also need to know LV sets for the instructions, that are immediately |
e855c69d AB |
868 | after the border of the region. */ |
869 | regset lv_set; | |
870 | ||
871 | /* Status of LV_SET. | |
872 | true - block has usable LV_SET. | |
873 | false - block's LV_SET should be recomputed. */ | |
874 | bool lv_set_valid_p; | |
84562394 | 875 | }; |
e855c69d AB |
876 | |
877 | typedef sel_global_bb_info_def *sel_global_bb_info_t; | |
878 | ||
e855c69d AB |
879 | |
880 | /* Per basic block data. This array is indexed by basic block index. */ | |
9771b263 | 881 | extern vec<sel_global_bb_info_def> sel_global_bb_info; |
e855c69d AB |
882 | |
883 | extern void sel_extend_global_bb_info (void); | |
884 | extern void sel_finish_global_bb_info (void); | |
885 | ||
886 | /* Get data for BB. */ | |
887 | #define SEL_GLOBAL_BB_INFO(BB) \ | |
9771b263 | 888 | (&sel_global_bb_info[(BB)->index]) |
e855c69d AB |
889 | |
890 | /* Access macros. */ | |
891 | #define BB_LV_SET(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set) | |
892 | #define BB_LV_SET_VALID_P(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set_valid_p) | |
893 | ||
894 | /* Per basic block data for the region. */ | |
84562394 | 895 | struct sel_region_bb_info_def |
e855c69d AB |
896 | { |
897 | /* This insn stream is constructed in such a way that it should be | |
898 | traversed by PREV_INSN field - (*not* NEXT_INSN). */ | |
899 | rtx note_list; | |
900 | ||
901 | /* Cached availability set at the beginning of a block. | |
902 | See also AV_LEVEL () for conditions when this av_set can be used. */ | |
903 | av_set_t av_set; | |
904 | ||
905 | /* If (AV_LEVEL == GLOBAL_LEVEL) then AV is valid. */ | |
906 | int av_level; | |
84562394 | 907 | }; |
e855c69d AB |
908 | |
909 | typedef sel_region_bb_info_def *sel_region_bb_info_t; | |
910 | ||
e855c69d AB |
911 | |
912 | /* Per basic block data. This array is indexed by basic block index. */ | |
9771b263 | 913 | extern vec<sel_region_bb_info_def> sel_region_bb_info; |
e855c69d AB |
914 | |
915 | /* Get data for BB. */ | |
9771b263 | 916 | #define SEL_REGION_BB_INFO(BB) (&sel_region_bb_info[(BB)->index]) |
e855c69d AB |
917 | |
918 | /* Get BB's note_list. | |
919 | A note_list is a list of various notes that was scattered across BB | |
920 | before scheduling, and will be appended at the beginning of BB after | |
921 | scheduling is finished. */ | |
922 | #define BB_NOTE_LIST(BB) (SEL_REGION_BB_INFO (BB)->note_list) | |
923 | ||
924 | #define BB_AV_SET(BB) (SEL_REGION_BB_INFO (BB)->av_set) | |
925 | #define BB_AV_LEVEL(BB) (SEL_REGION_BB_INFO (BB)->av_level) | |
926 | #define BB_AV_SET_VALID_P(BB) (BB_AV_LEVEL (BB) == global_level) | |
927 | ||
928 | /* Used in bb_in_ebb_p. */ | |
929 | extern bitmap_head *forced_ebb_heads; | |
930 | ||
931 | /* The loop nest being pipelined. */ | |
932 | extern struct loop *current_loop_nest; | |
933 | ||
934 | /* Saves pipelined blocks. Bitmap is indexed by bb->index. */ | |
935 | extern sbitmap bbs_pipelined; | |
936 | ||
937 | /* Various flags. */ | |
938 | extern bool enable_moveup_set_path_p; | |
939 | extern bool pipelining_p; | |
940 | extern bool bookkeeping_p; | |
b8698a0f | 941 | extern int max_insns_to_rename; |
e855c69d AB |
942 | extern bool preheader_removed; |
943 | ||
944 | /* Software lookahead window size. | |
b8698a0f | 945 | According to the results in Nakatani and Ebcioglu [1993], window size of 16 |
e855c69d AB |
946 | is enough to extract most ILP in integer code. */ |
947 | #define MAX_WS (PARAM_VALUE (PARAM_SELSCHED_MAX_LOOKAHEAD)) | |
948 | ||
949 | extern regset sel_all_regs; | |
950 | \f | |
951 | ||
952 | /* Successor iterator backend. */ | |
84562394 | 953 | struct succ_iterator |
e855c69d AB |
954 | { |
955 | /* True if we're at BB end. */ | |
956 | bool bb_end; | |
957 | ||
958 | /* An edge on which we're iterating. */ | |
959 | edge e1; | |
960 | ||
961 | /* The previous edge saved after skipping empty blocks. */ | |
962 | edge e2; | |
b8698a0f | 963 | |
e855c69d AB |
964 | /* Edge iterator used when there are successors in other basic blocks. */ |
965 | edge_iterator ei; | |
966 | ||
967 | /* Successor block we're traversing. */ | |
968 | basic_block bb; | |
969 | ||
970 | /* Flags that are passed to the iterator. We return only successors | |
971 | that comply to these flags. */ | |
972 | short flags; | |
b8698a0f L |
973 | |
974 | /* When flags include SUCCS_ALL, this will be set to the exact type | |
073a8998 | 975 | of the successor we're traversing now. */ |
e855c69d AB |
976 | short current_flags; |
977 | ||
978 | /* If skip to loop exits, save here information about loop exits. */ | |
979 | int current_exit; | |
9771b263 | 980 | vec<edge> loop_exits; |
84562394 | 981 | }; |
e855c69d AB |
982 | |
983 | /* A structure returning all successor's information. */ | |
984 | struct succs_info | |
985 | { | |
986 | /* Flags that these succcessors were computed with. */ | |
987 | short flags; | |
988 | ||
989 | /* Successors that correspond to the flags. */ | |
990 | insn_vec_t succs_ok; | |
991 | ||
b8698a0f | 992 | /* Their probabilities. As of now, we don't need this for other |
e855c69d | 993 | successors. */ |
9771b263 | 994 | vec<int> probs_ok; |
e855c69d AB |
995 | |
996 | /* Other successors. */ | |
997 | insn_vec_t succs_other; | |
998 | ||
999 | /* Probability of all successors. */ | |
1000 | int all_prob; | |
1001 | ||
1002 | /* The number of all successors. */ | |
1003 | int all_succs_n; | |
1004 | ||
1005 | /* The number of good successors. */ | |
1006 | int succs_ok_n; | |
1007 | }; | |
1008 | ||
1009 | /* Some needed definitions. */ | |
1010 | extern basic_block after_recovery; | |
1011 | ||
1012 | extern insn_t sel_bb_head (basic_block); | |
b5b8b0ac | 1013 | extern insn_t sel_bb_end (basic_block); |
e855c69d AB |
1014 | extern bool sel_bb_empty_p (basic_block); |
1015 | extern bool in_current_region_p (basic_block); | |
1016 | ||
1017 | /* True when BB is a header of the inner loop. */ | |
1018 | static inline bool | |
1019 | inner_loop_header_p (basic_block bb) | |
1020 | { | |
b8698a0f | 1021 | struct loop *inner_loop; |
e855c69d AB |
1022 | |
1023 | if (!current_loop_nest) | |
1024 | return false; | |
1025 | ||
fefa31b5 | 1026 | if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) |
e855c69d AB |
1027 | return false; |
1028 | ||
1029 | inner_loop = bb->loop_father; | |
1030 | if (inner_loop == current_loop_nest) | |
1031 | return false; | |
1032 | ||
1033 | /* If successor belongs to another loop. */ | |
1034 | if (bb == inner_loop->header | |
1035 | && flow_bb_inside_loop_p (current_loop_nest, bb)) | |
1036 | { | |
1037 | /* Could be '=' here because of wrong loop depths. */ | |
1038 | gcc_assert (loop_depth (inner_loop) >= loop_depth (current_loop_nest)); | |
1039 | return true; | |
1040 | } | |
1041 | ||
b8698a0f | 1042 | return false; |
e855c69d AB |
1043 | } |
1044 | ||
1045 | /* Return exit edges of LOOP, filtering out edges with the same dest bb. */ | |
9771b263 | 1046 | static inline vec<edge> |
e855c69d AB |
1047 | get_loop_exit_edges_unique_dests (const struct loop *loop) |
1048 | { | |
6e1aa848 | 1049 | vec<edge> edges = vNULL; |
e855c69d AB |
1050 | struct loop_exit *exit; |
1051 | ||
fefa31b5 | 1052 | gcc_assert (loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun) |
e855c69d AB |
1053 | && current_loops->state & LOOPS_HAVE_RECORDED_EXITS); |
1054 | ||
1055 | for (exit = loop->exits->next; exit->e; exit = exit->next) | |
1056 | { | |
1057 | int i; | |
1058 | edge e; | |
1059 | bool was_dest = false; | |
b8698a0f | 1060 | |
9771b263 | 1061 | for (i = 0; edges.iterate (i, &e); i++) |
e855c69d AB |
1062 | if (e->dest == exit->e->dest) |
1063 | { | |
1064 | was_dest = true; | |
1065 | break; | |
1066 | } | |
1067 | ||
1068 | if (!was_dest) | |
9771b263 | 1069 | edges.safe_push (exit->e); |
e855c69d AB |
1070 | } |
1071 | return edges; | |
1072 | } | |
1073 | ||
b5b8b0ac AO |
1074 | static bool |
1075 | sel_bb_empty_or_nop_p (basic_block bb) | |
1076 | { | |
1077 | insn_t first = sel_bb_head (bb), last; | |
1078 | ||
1079 | if (first == NULL_RTX) | |
1080 | return true; | |
1081 | ||
1082 | if (!INSN_NOP_P (first)) | |
1083 | return false; | |
1084 | ||
fefa31b5 | 1085 | if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) |
b5b8b0ac AO |
1086 | return false; |
1087 | ||
1088 | last = sel_bb_end (bb); | |
1089 | if (first != last) | |
1090 | return false; | |
1091 | ||
1092 | return true; | |
1093 | } | |
1094 | ||
b8698a0f | 1095 | /* Collect all loop exits recursively, skipping empty BBs between them. |
e855c69d AB |
1096 | E.g. if BB is a loop header which has several loop exits, |
1097 | traverse all of them and if any of them turns out to be another loop header | |
b8698a0f | 1098 | (after skipping empty BBs), add its loop exits to the resulting vector |
e855c69d | 1099 | as well. */ |
9771b263 | 1100 | static inline vec<edge> |
e855c69d AB |
1101 | get_all_loop_exits (basic_block bb) |
1102 | { | |
6e1aa848 | 1103 | vec<edge> exits = vNULL; |
e855c69d AB |
1104 | |
1105 | /* If bb is empty, and we're skipping to loop exits, then | |
1106 | consider bb as a possible gate to the inner loop now. */ | |
b5b8b0ac | 1107 | while (sel_bb_empty_or_nop_p (bb) |
3dbdd1b9 AB |
1108 | && in_current_region_p (bb) |
1109 | && EDGE_COUNT (bb->succs) > 0) | |
e855c69d AB |
1110 | { |
1111 | bb = single_succ (bb); | |
1112 | ||
1113 | /* This empty block could only lead outside the region. */ | |
1114 | gcc_assert (! in_current_region_p (bb)); | |
1115 | } | |
1116 | ||
1117 | /* And now check whether we should skip over inner loop. */ | |
1118 | if (inner_loop_header_p (bb)) | |
1119 | { | |
1120 | struct loop *this_loop; | |
1121 | struct loop *pred_loop = NULL; | |
1122 | int i; | |
1123 | edge e; | |
b8698a0f | 1124 | |
e855c69d AB |
1125 | for (this_loop = bb->loop_father; |
1126 | this_loop && this_loop != current_loop_nest; | |
1127 | this_loop = loop_outer (this_loop)) | |
1128 | pred_loop = this_loop; | |
b8698a0f | 1129 | |
e855c69d AB |
1130 | this_loop = pred_loop; |
1131 | gcc_assert (this_loop != NULL); | |
1132 | ||
1133 | exits = get_loop_exit_edges_unique_dests (this_loop); | |
1134 | ||
1135 | /* Traverse all loop headers. */ | |
9771b263 | 1136 | for (i = 0; exits.iterate (i, &e); i++) |
65b659ff AB |
1137 | if (in_current_region_p (e->dest) |
1138 | || inner_loop_header_p (e->dest)) | |
e855c69d | 1139 | { |
9771b263 | 1140 | vec<edge> next_exits = get_all_loop_exits (e->dest); |
b8698a0f | 1141 | |
9771b263 | 1142 | if (next_exits.exists ()) |
e855c69d AB |
1143 | { |
1144 | int j; | |
1145 | edge ne; | |
b8698a0f | 1146 | |
e855c69d AB |
1147 | /* Add all loop exits for the current edge into the |
1148 | resulting vector. */ | |
9771b263 DN |
1149 | for (j = 0; next_exits.iterate (j, &ne); j++) |
1150 | exits.safe_push (ne); | |
b8698a0f | 1151 | |
e855c69d | 1152 | /* Remove the original edge. */ |
9771b263 | 1153 | exits.ordered_remove (i); |
e855c69d AB |
1154 | |
1155 | /* Decrease the loop counter so we won't skip anything. */ | |
1156 | i--; | |
1157 | continue; | |
1158 | } | |
1159 | } | |
1160 | } | |
1161 | ||
1162 | return exits; | |
1163 | } | |
1164 | ||
1165 | /* Flags to pass to compute_succs_info and FOR_EACH_SUCC. | |
1166 | Any successor will fall into exactly one category. */ | |
1167 | ||
1168 | /* Include normal successors. */ | |
1169 | #define SUCCS_NORMAL (1) | |
1170 | ||
1171 | /* Include back-edge successors. */ | |
1172 | #define SUCCS_BACK (2) | |
1173 | ||
1174 | /* Include successors that are outside of the current region. */ | |
1175 | #define SUCCS_OUT (4) | |
1176 | ||
b8698a0f | 1177 | /* When pipelining of the outer loops is enabled, skip innermost loops |
e855c69d AB |
1178 | to their exits. */ |
1179 | #define SUCCS_SKIP_TO_LOOP_EXITS (8) | |
1180 | ||
1181 | /* Include all successors. */ | |
1182 | #define SUCCS_ALL (SUCCS_NORMAL | SUCCS_BACK | SUCCS_OUT) | |
1183 | ||
1184 | /* We need to return a succ_iterator to avoid 'unitialized' warning | |
1185 | during bootstrap. */ | |
1186 | static inline succ_iterator | |
1187 | _succ_iter_start (insn_t *succp, insn_t insn, int flags) | |
1188 | { | |
1189 | succ_iterator i; | |
1190 | ||
1191 | basic_block bb = BLOCK_FOR_INSN (insn); | |
1192 | ||
1193 | gcc_assert (INSN_P (insn) || NOTE_INSN_BASIC_BLOCK_P (insn)); | |
1194 | ||
1195 | i.flags = flags; | |
1196 | ||
1197 | /* Avoid 'uninitialized' warning. */ | |
1198 | *succp = NULL; | |
1199 | i.e1 = NULL; | |
1200 | i.e2 = NULL; | |
1201 | i.bb = bb; | |
1202 | i.current_flags = 0; | |
1203 | i.current_exit = -1; | |
9771b263 | 1204 | i.loop_exits.create (0); |
e855c69d | 1205 | |
fefa31b5 | 1206 | if (bb != EXIT_BLOCK_PTR_FOR_FN (cfun) && BB_END (bb) != insn) |
e855c69d AB |
1207 | { |
1208 | i.bb_end = false; | |
1209 | ||
1210 | /* Avoid 'uninitialized' warning. */ | |
1211 | i.ei.index = 0; | |
9771b263 | 1212 | i.ei.container = 0; |
e855c69d AB |
1213 | } |
1214 | else | |
1215 | { | |
1216 | i.ei = ei_start (bb->succs); | |
1217 | i.bb_end = true; | |
1218 | } | |
1219 | ||
1220 | return i; | |
1221 | } | |
1222 | ||
1223 | static inline bool | |
1224 | _succ_iter_cond (succ_iterator *ip, rtx *succp, rtx insn, | |
1225 | bool check (edge, succ_iterator *)) | |
1226 | { | |
1227 | if (!ip->bb_end) | |
1228 | { | |
1229 | /* When we're in a middle of a basic block, return | |
1230 | the next insn immediately, but only when SUCCS_NORMAL is set. */ | |
1231 | if (*succp != NULL || (ip->flags & SUCCS_NORMAL) == 0) | |
1232 | return false; | |
1233 | ||
1234 | *succp = NEXT_INSN (insn); | |
1235 | ip->current_flags = SUCCS_NORMAL; | |
1236 | return true; | |
1237 | } | |
1238 | else | |
1239 | { | |
b8698a0f | 1240 | while (1) |
e855c69d AB |
1241 | { |
1242 | edge e_tmp = NULL; | |
1243 | ||
1244 | /* First, try loop exits, if we have them. */ | |
9771b263 | 1245 | if (ip->loop_exits.exists ()) |
e855c69d AB |
1246 | { |
1247 | do | |
1248 | { | |
9771b263 | 1249 | ip->loop_exits.iterate (ip->current_exit, &e_tmp); |
e855c69d AB |
1250 | ip->current_exit++; |
1251 | } | |
1252 | while (e_tmp && !check (e_tmp, ip)); | |
b8698a0f | 1253 | |
e855c69d | 1254 | if (!e_tmp) |
9771b263 | 1255 | ip->loop_exits.release (); |
e855c69d AB |
1256 | } |
1257 | ||
1258 | /* If we have found a successor, then great. */ | |
1259 | if (e_tmp) | |
1260 | { | |
1261 | ip->e1 = e_tmp; | |
1262 | break; | |
1263 | } | |
1264 | ||
1265 | /* If not, then try the next edge. */ | |
1266 | while (ei_cond (ip->ei, &(ip->e1))) | |
1267 | { | |
1268 | basic_block bb = ip->e1->dest; | |
1269 | ||
1270 | /* Consider bb as a possible loop header. */ | |
1271 | if ((ip->flags & SUCCS_SKIP_TO_LOOP_EXITS) | |
1272 | && flag_sel_sched_pipelining_outer_loops | |
b8698a0f L |
1273 | && (!in_current_region_p (bb) |
1274 | || BLOCK_TO_BB (ip->bb->index) | |
e855c69d AB |
1275 | < BLOCK_TO_BB (bb->index))) |
1276 | { | |
1277 | /* Get all loop exits recursively. */ | |
1278 | ip->loop_exits = get_all_loop_exits (bb); | |
1279 | ||
9771b263 | 1280 | if (ip->loop_exits.exists ()) |
e855c69d AB |
1281 | { |
1282 | ip->current_exit = 0; | |
b8698a0f | 1283 | /* Move the iterator now, because we won't do |
e855c69d AB |
1284 | succ_iter_next until loop exits will end. */ |
1285 | ei_next (&(ip->ei)); | |
1286 | break; | |
1287 | } | |
1288 | } | |
1289 | ||
1290 | /* bb is not a loop header, check as usual. */ | |
1291 | if (check (ip->e1, ip)) | |
1292 | break; | |
1293 | ||
1294 | ei_next (&(ip->ei)); | |
1295 | } | |
1296 | ||
1297 | /* If loop_exits are non null, we have found an inner loop; | |
1298 | do one more iteration to fetch an edge from these exits. */ | |
9771b263 | 1299 | if (ip->loop_exits.exists ()) |
e855c69d AB |
1300 | continue; |
1301 | ||
1302 | /* Otherwise, we've found an edge in a usual way. Break now. */ | |
1303 | break; | |
1304 | } | |
1305 | ||
1306 | if (ip->e1) | |
1307 | { | |
1308 | basic_block bb = ip->e2->dest; | |
1309 | ||
fefa31b5 | 1310 | if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb == after_recovery) |
e855c69d AB |
1311 | *succp = exit_insn; |
1312 | else | |
1313 | { | |
1314 | *succp = sel_bb_head (bb); | |
1315 | ||
1316 | gcc_assert (ip->flags != SUCCS_NORMAL | |
1317 | || *succp == NEXT_INSN (bb_note (bb))); | |
1318 | gcc_assert (BLOCK_FOR_INSN (*succp) == bb); | |
1319 | } | |
1320 | ||
1321 | return true; | |
1322 | } | |
1323 | else | |
1324 | return false; | |
1325 | } | |
1326 | } | |
1327 | ||
1328 | static inline void | |
1329 | _succ_iter_next (succ_iterator *ip) | |
1330 | { | |
1331 | gcc_assert (!ip->e2 || ip->e1); | |
1332 | ||
9771b263 | 1333 | if (ip->bb_end && ip->e1 && !ip->loop_exits.exists ()) |
e855c69d AB |
1334 | ei_next (&(ip->ei)); |
1335 | } | |
1336 | ||
1337 | /* Returns true when E1 is an eligible successor edge, possibly skipping | |
1338 | empty blocks. When E2P is not null, the resulting edge is written there. | |
1339 | FLAGS are used to specify whether back edges and out-of-region edges | |
1340 | should be considered. */ | |
1341 | static inline bool | |
1342 | _eligible_successor_edge_p (edge e1, succ_iterator *ip) | |
1343 | { | |
1344 | edge e2 = e1; | |
1345 | basic_block bb; | |
1346 | int flags = ip->flags; | |
1347 | bool src_outside_rgn = !in_current_region_p (e1->src); | |
1348 | ||
1349 | gcc_assert (flags != 0); | |
1350 | ||
1351 | if (src_outside_rgn) | |
1352 | { | |
1353 | /* Any successor of the block that is outside current region is | |
1354 | ineligible, except when we're skipping to loop exits. */ | |
1355 | gcc_assert (flags & (SUCCS_OUT | SUCCS_SKIP_TO_LOOP_EXITS)); | |
1356 | ||
1357 | if (flags & SUCCS_OUT) | |
1358 | return false; | |
1359 | } | |
1360 | ||
1361 | bb = e2->dest; | |
1362 | ||
1363 | /* Skip empty blocks, but be careful not to leave the region. */ | |
1364 | while (1) | |
1365 | { | |
1366 | if (!sel_bb_empty_p (bb)) | |
b5b8b0ac AO |
1367 | { |
1368 | edge ne; | |
1369 | basic_block nbb; | |
1370 | ||
1371 | if (!sel_bb_empty_or_nop_p (bb)) | |
1372 | break; | |
1373 | ||
1374 | ne = EDGE_SUCC (bb, 0); | |
1375 | nbb = ne->dest; | |
1376 | ||
1377 | if (!in_current_region_p (nbb) | |
1378 | && !(flags & SUCCS_OUT)) | |
1379 | break; | |
1380 | ||
1381 | e2 = ne; | |
1382 | bb = nbb; | |
1383 | continue; | |
1384 | } | |
b8698a0f L |
1385 | |
1386 | if (!in_current_region_p (bb) | |
e855c69d AB |
1387 | && !(flags & SUCCS_OUT)) |
1388 | return false; | |
1389 | ||
4b2e464e SE |
1390 | if (EDGE_COUNT (bb->succs) == 0) |
1391 | return false; | |
1392 | ||
e855c69d AB |
1393 | e2 = EDGE_SUCC (bb, 0); |
1394 | bb = e2->dest; | |
e855c69d | 1395 | } |
b8698a0f | 1396 | |
e855c69d AB |
1397 | /* Save the second edge for later checks. */ |
1398 | ip->e2 = e2; | |
1399 | ||
1400 | if (in_current_region_p (bb)) | |
1401 | { | |
b8698a0f L |
1402 | /* BLOCK_TO_BB sets topological order of the region here. |
1403 | It is important to use real predecessor here, which is ip->bb, | |
1404 | as we may well have e1->src outside current region, | |
e855c69d AB |
1405 | when skipping to loop exits. */ |
1406 | bool succeeds_in_top_order = (BLOCK_TO_BB (ip->bb->index) | |
1407 | < BLOCK_TO_BB (bb->index)); | |
1408 | ||
1409 | /* This is true for the all cases except the last one. */ | |
1410 | ip->current_flags = SUCCS_NORMAL; | |
b8698a0f | 1411 | |
e855c69d AB |
1412 | /* We are advancing forward in the region, as usual. */ |
1413 | if (succeeds_in_top_order) | |
1414 | { | |
1415 | /* We are skipping to loop exits here. */ | |
1416 | gcc_assert (!src_outside_rgn | |
1417 | || flag_sel_sched_pipelining_outer_loops); | |
1418 | return !!(flags & SUCCS_NORMAL); | |
1419 | } | |
1420 | ||
b8698a0f | 1421 | /* This is a back edge. During pipelining we ignore back edges, |
e855c69d | 1422 | but only when it leads to the same loop. It can lead to the header |
b8698a0f | 1423 | of the outer loop, which will also be the preheader of |
e855c69d AB |
1424 | the current loop. */ |
1425 | if (pipelining_p | |
1426 | && e1->src->loop_father == bb->loop_father) | |
1427 | return !!(flags & SUCCS_NORMAL); | |
1428 | ||
1429 | /* A back edge should be requested explicitly. */ | |
1430 | ip->current_flags = SUCCS_BACK; | |
1431 | return !!(flags & SUCCS_BACK); | |
1432 | } | |
1433 | ||
1434 | ip->current_flags = SUCCS_OUT; | |
1435 | return !!(flags & SUCCS_OUT); | |
1436 | } | |
1437 | ||
1438 | #define FOR_EACH_SUCC_1(SUCC, ITER, INSN, FLAGS) \ | |
1439 | for ((ITER) = _succ_iter_start (&(SUCC), (INSN), (FLAGS)); \ | |
1440 | _succ_iter_cond (&(ITER), &(SUCC), (INSN), _eligible_successor_edge_p); \ | |
1441 | _succ_iter_next (&(ITER))) | |
1442 | ||
1443 | #define FOR_EACH_SUCC(SUCC, ITER, INSN) \ | |
1444 | FOR_EACH_SUCC_1 (SUCC, ITER, INSN, SUCCS_NORMAL) | |
1445 | ||
1446 | /* Return the current edge along which a successor was built. */ | |
1447 | #define SUCC_ITER_EDGE(ITER) ((ITER)->e1) | |
1448 | ||
1449 | /* Return the next block of BB not running into inconsistencies. */ | |
1450 | static inline basic_block | |
1451 | bb_next_bb (basic_block bb) | |
1452 | { | |
1453 | switch (EDGE_COUNT (bb->succs)) | |
1454 | { | |
1455 | case 0: | |
1456 | return bb->next_bb; | |
1457 | ||
b8698a0f | 1458 | case 1: |
e855c69d AB |
1459 | return single_succ (bb); |
1460 | ||
1461 | case 2: | |
1462 | return FALLTHRU_EDGE (bb)->dest; | |
b8698a0f | 1463 | |
e855c69d AB |
1464 | default: |
1465 | return bb->next_bb; | |
1466 | } | |
1467 | ||
1468 | gcc_unreachable (); | |
1469 | } | |
1470 | ||
1471 | \f | |
1472 | ||
1473 | /* Functions that are used in sel-sched.c. */ | |
1474 | ||
1475 | /* List functions. */ | |
1476 | extern ilist_t ilist_copy (ilist_t); | |
1477 | extern ilist_t ilist_invert (ilist_t); | |
1478 | extern void blist_add (blist_t *, insn_t, ilist_t, deps_t); | |
1479 | extern void blist_remove (blist_t *); | |
1480 | extern void flist_tail_init (flist_tail_t); | |
1481 | ||
1482 | extern fence_t flist_lookup (flist_t, insn_t); | |
1483 | extern void flist_clear (flist_t *); | |
1484 | extern void def_list_add (def_list_t *, insn_t, bool); | |
1485 | ||
1486 | /* Target context functions. */ | |
1487 | extern tc_t create_target_context (bool); | |
1488 | extern void set_target_context (tc_t); | |
1489 | extern void reset_target_context (tc_t, bool); | |
1490 | ||
1491 | /* Deps context functions. */ | |
1492 | extern void advance_deps_context (deps_t, insn_t); | |
1493 | ||
1494 | /* Fences functions. */ | |
1495 | extern void init_fences (insn_t); | |
1496 | extern void add_clean_fence_to_fences (flist_tail_t, insn_t, fence_t); | |
1497 | extern void add_dirty_fence_to_fences (flist_tail_t, insn_t, fence_t); | |
1498 | extern void move_fence_to_fences (flist_t, flist_tail_t); | |
1499 | ||
1500 | /* Pool functions. */ | |
1501 | extern regset get_regset_from_pool (void); | |
1502 | extern regset get_clear_regset_from_pool (void); | |
1503 | extern void return_regset_to_pool (regset); | |
1504 | extern void free_regset_pool (void); | |
1505 | ||
1506 | extern insn_t get_nop_from_pool (insn_t); | |
b5b8b0ac | 1507 | extern void return_nop_to_pool (insn_t, bool); |
e855c69d AB |
1508 | extern void free_nop_pool (void); |
1509 | ||
1510 | /* Vinsns functions. */ | |
1511 | extern bool vinsn_separable_p (vinsn_t); | |
1512 | extern bool vinsn_cond_branch_p (vinsn_t); | |
1513 | extern void recompute_vinsn_lhs_rhs (vinsn_t); | |
1514 | extern int sel_vinsn_cost (vinsn_t); | |
1515 | extern insn_t sel_gen_insn_from_rtx_after (rtx, expr_t, int, insn_t); | |
1516 | extern insn_t sel_gen_recovery_insn_from_rtx_after (rtx, expr_t, int, insn_t); | |
1517 | extern insn_t sel_gen_insn_from_expr_after (expr_t, vinsn_t, int, insn_t); | |
1518 | extern insn_t sel_move_insn (expr_t, int, insn_t); | |
1519 | extern void vinsn_attach (vinsn_t); | |
1520 | extern void vinsn_detach (vinsn_t); | |
1521 | extern vinsn_t vinsn_copy (vinsn_t, bool); | |
1522 | extern bool vinsn_equal_p (vinsn_t, vinsn_t); | |
1523 | ||
1524 | /* EXPR functions. */ | |
1525 | extern void copy_expr (expr_t, expr_t); | |
1526 | extern void copy_expr_onside (expr_t, expr_t); | |
1527 | extern void merge_expr_data (expr_t, expr_t, insn_t); | |
1528 | extern void merge_expr (expr_t, expr_t, insn_t); | |
1529 | extern void clear_expr (expr_t); | |
1530 | extern unsigned expr_dest_regno (expr_t); | |
b8698a0f | 1531 | extern rtx expr_dest_reg (expr_t); |
9771b263 | 1532 | extern int find_in_history_vect (vec<expr_history_def> , |
e855c69d | 1533 | rtx, vinsn_t, bool); |
9771b263 | 1534 | extern void insert_in_history_vect (vec<expr_history_def> *, |
b8698a0f | 1535 | unsigned, enum local_trans_type, |
e855c69d AB |
1536 | vinsn_t, vinsn_t, ds_t); |
1537 | extern void mark_unavailable_targets (av_set_t, av_set_t, regset); | |
1538 | extern int speculate_expr (expr_t, ds_t); | |
1539 | ||
1540 | /* Av set functions. */ | |
1541 | extern void av_set_add (av_set_t *, expr_t); | |
1542 | extern void av_set_iter_remove (av_set_iterator *); | |
1543 | extern expr_t av_set_lookup (av_set_t, vinsn_t); | |
1544 | extern expr_t merge_with_other_exprs (av_set_t *, av_set_iterator *, expr_t); | |
1545 | extern bool av_set_is_in_p (av_set_t, vinsn_t); | |
1546 | extern av_set_t av_set_copy (av_set_t); | |
1547 | extern void av_set_union_and_clear (av_set_t *, av_set_t *, insn_t); | |
1548 | extern void av_set_union_and_live (av_set_t *, av_set_t *, regset, regset, insn_t); | |
1549 | extern void av_set_clear (av_set_t *); | |
1550 | extern void av_set_leave_one_nonspec (av_set_t *); | |
1551 | extern expr_t av_set_element (av_set_t, int); | |
1552 | extern void av_set_substract_cond_branches (av_set_t *); | |
1553 | extern void av_set_split_usefulness (av_set_t, int, int); | |
5d369d58 | 1554 | extern void av_set_code_motion_filter (av_set_t *, av_set_t); |
e855c69d AB |
1555 | |
1556 | extern void sel_save_haifa_priorities (void); | |
1557 | ||
1558 | extern void sel_init_global_and_expr (bb_vec_t); | |
1559 | extern void sel_finish_global_and_expr (void); | |
1560 | ||
1561 | extern regset compute_live (insn_t); | |
cf3d5824 | 1562 | extern bool register_unavailable_p (regset, rtx); |
e855c69d AB |
1563 | |
1564 | /* Dependence analysis functions. */ | |
1565 | extern void sel_clear_has_dependence (void); | |
1566 | extern ds_t has_dependence_p (expr_t, insn_t, ds_t **); | |
1567 | ||
1568 | extern int tick_check_p (expr_t, deps_t, fence_t); | |
1569 | ||
1570 | /* Functions to work with insns. */ | |
1571 | extern bool lhs_of_insn_equals_to_dest_p (insn_t, rtx); | |
1572 | extern bool insn_eligible_for_subst_p (insn_t); | |
1573 | extern void get_dest_and_mode (rtx, rtx *, enum machine_mode *); | |
1574 | ||
1575 | extern bool bookkeeping_can_be_created_if_moved_through_p (insn_t); | |
1576 | extern bool sel_remove_insn (insn_t, bool, bool); | |
1577 | extern bool bb_header_p (insn_t); | |
1578 | extern void sel_init_invalid_data_sets (insn_t); | |
1579 | extern bool insn_at_boundary_p (insn_t); | |
e855c69d AB |
1580 | |
1581 | /* Basic block and CFG functions. */ | |
1582 | ||
1583 | extern insn_t sel_bb_head (basic_block); | |
1584 | extern bool sel_bb_head_p (insn_t); | |
1585 | extern insn_t sel_bb_end (basic_block); | |
1586 | extern bool sel_bb_end_p (insn_t); | |
1587 | extern bool sel_bb_empty_p (basic_block); | |
1588 | ||
1589 | extern bool in_current_region_p (basic_block); | |
1590 | extern basic_block fallthru_bb_of_jump (rtx); | |
1591 | ||
a95b23b4 | 1592 | extern void sel_init_bbs (bb_vec_t); |
e855c69d AB |
1593 | extern void sel_finish_bbs (void); |
1594 | ||
1595 | extern struct succs_info * compute_succs_info (insn_t, short); | |
1596 | extern void free_succs_info (struct succs_info *); | |
1597 | extern bool sel_insn_has_single_succ_p (insn_t, int); | |
1598 | extern bool sel_num_cfg_preds_gt_1 (insn_t); | |
1599 | extern int get_seqno_by_preds (rtx); | |
1600 | ||
1601 | extern bool bb_ends_ebb_p (basic_block); | |
1602 | extern bool in_same_ebb_p (insn_t, insn_t); | |
1603 | ||
1604 | extern bool tidy_control_flow (basic_block, bool); | |
1605 | extern void free_bb_note_pool (void); | |
1606 | ||
b59ab570 | 1607 | extern void purge_empty_blocks (void); |
e855c69d AB |
1608 | extern basic_block sel_split_edge (edge); |
1609 | extern basic_block sel_create_recovery_block (insn_t); | |
b59ab570 | 1610 | extern bool sel_redirect_edge_and_branch (edge, basic_block); |
e855c69d AB |
1611 | extern void sel_redirect_edge_and_branch_force (edge, basic_block); |
1612 | extern void sel_init_pipelining (void); | |
1613 | extern void sel_finish_pipelining (void); | |
1614 | extern void sel_sched_region (int); | |
e855c69d AB |
1615 | extern loop_p get_loop_nest_for_rgn (unsigned int); |
1616 | extern bool considered_for_pipelining_p (struct loop *); | |
9771b263 | 1617 | extern void make_region_from_loop_preheader (vec<basic_block> *&); |
ea4d630f | 1618 | extern void sel_add_loop_preheaders (bb_vec_t *); |
e855c69d AB |
1619 | extern bool sel_is_loop_preheader_p (basic_block); |
1620 | extern void clear_outdated_rtx_info (basic_block); | |
1621 | extern void free_data_sets (basic_block); | |
1622 | extern void exchange_data_sets (basic_block, basic_block); | |
1623 | extern void copy_data_sets (basic_block, basic_block); | |
1624 | ||
1625 | extern void sel_register_cfg_hooks (void); | |
1626 | extern void sel_unregister_cfg_hooks (void); | |
1627 | ||
1628 | /* Expression transformation routines. */ | |
1629 | extern rtx create_insn_rtx_from_pattern (rtx, rtx); | |
1630 | extern vinsn_t create_vinsn_from_insn_rtx (rtx, bool); | |
1631 | extern rtx create_copy_of_insn_rtx (rtx); | |
1632 | extern void change_vinsn_in_expr (expr_t, vinsn_t); | |
1633 | ||
1634 | /* Various initialization functions. */ | |
1635 | extern void init_lv_sets (void); | |
1636 | extern void free_lv_sets (void); | |
1637 | extern void setup_nop_and_exit_insns (void); | |
1638 | extern void free_nop_and_exit_insns (void); | |
bcf33775 | 1639 | extern void free_data_for_scheduled_insn (insn_t); |
e855c69d AB |
1640 | extern void setup_nop_vinsn (void); |
1641 | extern void free_nop_vinsn (void); | |
1642 | extern void sel_set_sched_flags (void); | |
1643 | extern void sel_setup_sched_infos (void); | |
1644 | extern void alloc_sched_pools (void); | |
1645 | extern void free_sched_pools (void); | |
1646 | ||
1647 | #endif /* GCC_SEL_SCHED_IR_H */ | |
1648 | ||
1649 | ||
1650 | ||
1651 | ||
1652 | ||
1653 | ||
1654 | ||
1655 |