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