21 #ifndef GCC_SEL_SCHED_IR_H
22 #define GCC_SEL_SCHED_IR_H
25 #include "insn-attr.h"
46 #define _LIST_NEXT(L) ((L)->next)
59 #define _XLIST_X(L) ((L)->u.x)
60 #define _XLIST_NEXT(L) (_LIST_NEXT (L))
67 #define ILIST_INSN(L) (_XLIST_X (L))
68 #define ILIST_NEXT(L) (_XLIST_NEXT (L))
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)))
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)
211 #define _AV_SET_EXPR(L) (&(L)->u.expr)
212 #define _AV_SET_NEXT(L) (_LIST_NEXT (L))
236 #define BND_TO(B) ((B)->to)
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)
247 #define BLIST_BND(L) (&(L)->u.bnd)
248 #define BLIST_NEXT(L) (_LIST_NEXT (L))
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)
325 #define FENCE_ISSUE_MORE(F) ((F)->issue_more)
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)
333 #define FLIST_FENCE(L) (&(L)->u.fence)
334 #define FLIST_NEXT(L) (_LIST_NEXT (L))
344 #define FLIST_TAIL_HEAD(L) ((L)->head)
345 #define FLIST_TAIL_TAILP(L) ((L)->tailp)
369 static inline _list_t
372 return (_list_t)
pool_alloc (sched_lists_pool);
380 _LIST_NEXT (l) = *lp;
389 *lp = _LIST_NEXT (n);
397 *lp = _LIST_NEXT (n);
434 ip->
lp = &_LIST_NEXT (*ip->
lp);
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)))
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)); \
465 _list_iter_next (&(I)))
477 #define _xlist_remove(LP) (_list_remove (LP))
478 #define _xlist_clear(LP) (_list_clear (LP))
485 if (_XLIST_X (l) == x)
506 #define _xlist_iter_remove(IP) (_list_iter_remove (IP))
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))
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))
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)
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))
536 *exprp = _AV_SET_EXPR (av);
548 #define DEF_LIST_NEXT(L) (_LIST_NEXT (L))
549 #define DEF_LIST_DEF(L) (&(L)->u.def)
551 #define FOR_EACH_DEF(DEF, I, DEF_LIST) _FOR_EACH (def, (DEF), (I), (DEF_LIST))
558 *def = DEF_LIST_DEF (def_list);
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)
648 #define VINSN_INSN_RTX(VI) ((VI)->insn_rtx)
649 #define VINSN_PATTERN(VI) (PATTERN (VINSN_INSN_RTX (VI)))
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)
759 #define SID(INSN) (&s_i_d[INSN_LUID (INSN)])
760 #define SID_BY_UID(UID) (&s_i_d[LUID_BY_UID (UID)])
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)
767 #define INSN_FOUND_DEPS(INSN) (SID (INSN)->found_deps)
768 #define INSN_DEPS_CONTEXT(INSN) (SID (INSN)->deps_context)
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)
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)
794 #define INSN_WS_LEVEL(INSN) (SID (INSN)->ws_level)
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)
813 #define INSN_INIT_TODO_LUID (1)
816 #define INSN_INIT_TODO_SSID (2)
819 #define INSN_INIT_TODO_SIMPLEJUMP (4)
824 #define INSN_NOP_P(INSN) (PATTERN (INSN) == nop_pattern)
830 #define INSN_IN_STREAM_P(INSN) (PREV_INSN (INSN) && NEXT_INSN (INSN))
833 #define IN_CURRENT_FENCE_P(INSN) (flist_lookup (fences, INSN) != NULL)
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))
840 #define LOOP_PREHEADER_BLOCKS(LOOP) ((size_t)((LOOP)->aux) == 1 \
842 : ((vec<basic_block> *) (LOOP)->aux))
843 #define SET_LOOP_PREHEADER_BLOCKS(LOOP,BLOCKS) ((LOOP)->aux \
888 #define SEL_GLOBAL_BB_INFO(BB) \
889 (&sel_global_bb_info[(BB)->index])
892 #define BB_LV_SET(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set)
893 #define BB_LV_SET_VALID_P(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set_valid_p)
917 #define SEL_REGION_BB_INFO(BB) (&sel_region_bb_info[(BB)->index])
923 #define BB_NOTE_LIST(BB) (SEL_REGION_BB_INFO (BB)->note_list)
925 #define BB_AV_SET(BB) (SEL_REGION_BB_INFO (BB)->av_set)
926 #define BB_AV_LEVEL(BB) (SEL_REGION_BB_INFO (BB)->av_level)
927 #define BB_AV_SET_VALID_P(BB) (BB_AV_LEVEL (BB) == global_level)
948 #define MAX_WS (PARAM_VALUE (PARAM_SELSCHED_MAX_LOOKAHEAD))
1022 struct loop *inner_loop;
1024 if (!current_loop_nest)
1027 if (bb == EXIT_BLOCK_PTR)
1031 if (inner_loop == current_loop_nest)
1035 if (bb == inner_loop->
header
1053 gcc_assert (loop->
latch != EXIT_BLOCK_PTR
1060 bool was_dest =
false;
1062 for (i = 0; edges.iterate (i, &e); i++)
1070 edges.safe_push (exit->
e);
1080 if (first == NULL_RTX)
1083 if (!INSN_NOP_P (first))
1086 if (bb == EXIT_BLOCK_PTR)
1110 && EDGE_COUNT (bb->
succs) > 0)
1121 struct loop *this_loop;
1122 struct loop *pred_loop = NULL;
1127 this_loop && this_loop != current_loop_nest;
1129 pred_loop = this_loop;
1131 this_loop = pred_loop;
1132 gcc_assert (this_loop != NULL);
1137 for (i = 0; exits.iterate (i, &e); i++)
1143 if (next_exits.exists ())
1150 for (j = 0; next_exits.iterate (j, &ne); j++)
1151 exits.safe_push (ne);
1154 exits.ordered_remove (i);
1170 #define SUCCS_NORMAL (1)
1173 #define SUCCS_BACK (2)
1176 #define SUCCS_OUT (4)
1180 #define SUCCS_SKIP_TO_LOOP_EXITS (8)
1183 #define SUCCS_ALL (SUCCS_NORMAL | SUCCS_BACK | SUCCS_OUT)
1194 gcc_assert (INSN_P (insn) || NOTE_INSN_BASIC_BLOCK_P (insn));
1207 if (bb != EXIT_BLOCK_PTR && BB_END (bb) != insn)
1232 if (*succp != NULL || (ip->
flags & SUCCS_NORMAL) == 0)
1235 *succp = NEXT_INSN (insn);
1253 while (e_tmp && !check (e_tmp, ip));
1272 if ((ip->
flags & SUCCS_SKIP_TO_LOOP_EXITS)
1273 && flag_sel_sched_pipelining_outer_loops
1275 || BLOCK_TO_BB (ip->
bb->
index)
1276 < BLOCK_TO_BB (bb->
index)))
1292 if (check (ip->
e1, ip))
1311 if (bb == EXIT_BLOCK_PTR || bb == after_recovery)
1317 gcc_assert (ip->
flags != SUCCS_NORMAL
1318 || *succp == NEXT_INSN (
bb_note (bb)));
1319 gcc_assert (BLOCK_FOR_INSN (*succp) == bb);
1332 gcc_assert (!ip->
e2 || ip->
e1);
1347 int flags = ip->
flags;
1350 gcc_assert (flags != 0);
1352 if (src_outside_rgn)
1356 gcc_assert (flags & (SUCCS_OUT | SUCCS_SKIP_TO_LOOP_EXITS));
1358 if (flags & SUCCS_OUT)
1375 ne = EDGE_SUCC (bb, 0);
1379 && !(flags & SUCCS_OUT))
1388 && !(flags & SUCCS_OUT))
1391 if (EDGE_COUNT (bb->
succs) == 0)
1394 e2 = EDGE_SUCC (bb, 0);
1407 bool succeeds_in_top_order = (BLOCK_TO_BB (ip->
bb->
index)
1408 < BLOCK_TO_BB (bb->
index));
1414 if (succeeds_in_top_order)
1417 gcc_assert (!src_outside_rgn
1418 || flag_sel_sched_pipelining_outer_loops);
1419 return !!(flags & SUCCS_NORMAL);
1428 return !!(flags & SUCCS_NORMAL);
1432 return !!(flags & SUCCS_BACK);
1436 return !!(flags & SUCCS_OUT);
1439 #define FOR_EACH_SUCC_1(SUCC, ITER, INSN, FLAGS) \
1440 for ((ITER) = _succ_iter_start (&(SUCC), (INSN), (FLAGS)); \
1441 _succ_iter_cond (&(ITER), &(SUCC), (INSN), _eligible_successor_edge_p); \
1442 _succ_iter_next (&(ITER)))
1444 #define FOR_EACH_SUCC(SUCC, ITER, INSN) \
1445 FOR_EACH_SUCC_1 (SUCC, ITER, INSN, SUCCS_NORMAL)
1448 #define SUCC_ITER_EDGE(ITER) ((ITER)->e1)
1454 switch (EDGE_COUNT (bb->
succs))
1463 return FALLTHRU_EDGE (bb)->dest;
1534 rtx, vinsn_t,
bool);
1537 vinsn_t, vinsn_t,
ds_t);