Mercurial > hg > CbC > CbC_gcc
diff gcc/sel-sched-ir.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/gcc/sel-sched-ir.h Sun Aug 21 07:07:55 2011 +0900 +++ b/gcc/sel-sched-ir.h Fri Oct 27 22:46:09 2017 +0900 @@ -1,6 +1,6 @@ /* Instruction scheduling pass. This file contains definitions used internally in the scheduler. - Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006-2017 Free Software Foundation, Inc. This file is part of GCC. @@ -22,16 +22,7 @@ #define GCC_SEL_SCHED_IR_H /* For state_t. */ -#include "insn-attr.h" -#include "regset.h" -#include "basic-block.h" /* For reg_note. */ -#include "rtl.h" -#include "ggc.h" -#include "bitmap.h" -#include "vecprim.h" -#include "sched-int.h" -#include "cfgloop.h" /* tc_t is a short for target context. This is a state of the target backend. */ @@ -61,12 +52,12 @@ #define _XLIST_NEXT(L) (_LIST_NEXT (L)) /* Instruction. */ -typedef rtx insn_t; +typedef rtx_insn *insn_t; /* List of insns. */ -typedef _xlist_t ilist_t; -#define ILIST_INSN(L) (_XLIST_X (L)) -#define ILIST_NEXT(L) (_XLIST_NEXT (L)) +typedef _list_t ilist_t; +#define ILIST_INSN(L) ((L)->u.insn) +#define ILIST_NEXT(L) (_LIST_NEXT (L)) /* This lists possible transformations that done locally, i.e. in moveup_expr. */ @@ -98,8 +89,6 @@ typedef struct expr_history_def_1 expr_history_def; -DEF_VEC_O (expr_history_def); -DEF_VEC_ALLOC_O (expr_history_def, heap); /* Expression information. */ struct _expr @@ -145,7 +134,7 @@ int orig_sched_cycle; /* This vector contains the history of insn's transformations. */ - VEC(expr_history_def, heap) *history_of_changes; + vec<expr_history_def> history_of_changes; /* True (1) when original target (register or memory) of this instruction is available for scheduling, false otherwise. -1 means we're not sure; @@ -194,9 +183,6 @@ #define EXPR_WAS_RENAMED(EXPR) ((EXPR)->was_renamed) #define EXPR_CANT_MOVE(EXPR) ((EXPR)->cant_move) -#define EXPR_WAS_CHANGED(EXPR) (VEC_length (expr_history_def, \ - EXPR_HISTORY_OF_CHANGES (EXPR)) > 0) - /* Insn definition for list of original insns in find_used_regs. */ struct _def { @@ -284,7 +270,7 @@ tc_t tc; /* A vector of insns that are scheduled but not yet completed. */ - VEC (rtx,gc) *executing_insns; + vec<rtx_insn *, va_gc> *executing_insns; /* A vector indexed by UIDs that caches the earliest cycle on which an insn can be scheduled on this fence. */ @@ -294,13 +280,13 @@ int ready_ticks_size; /* Insn, which has been scheduled last on this fence. */ - rtx last_scheduled_insn; + rtx_insn *last_scheduled_insn; /* The last value of can_issue_more variable on this fence. */ int issue_more; /* If non-NULL force the next scheduled insn to be SCHED_NEXT. */ - rtx sched_next; + rtx_insn *sched_next; /* True if fill_insns processed this fence. */ BOOL_BITFIELD processed_p : 1; @@ -358,6 +344,7 @@ union { rtx x; + insn_t insn; struct _bnd bnd; expr_def expr; struct _fence fence; @@ -370,12 +357,12 @@ /* _list_t functions. All of _*list_* functions are used through accessor macros, thus we can't move them in sel-sched-ir.c. */ -extern alloc_pool sched_lists_pool; +extern object_allocator<_list_node> sched_lists_pool; static inline _list_t _list_alloc (void) { - return (_list_t) pool_alloc (sched_lists_pool); + return sched_lists_pool.allocate (); } static inline void @@ -401,7 +388,7 @@ _list_t n = *lp; *lp = _LIST_NEXT (n); - pool_free (sched_lists_pool, n); + sched_lists_pool.remove (n); } static inline void @@ -413,7 +400,7 @@ /* List iterator backend. */ -typedef struct +struct _list_iterator { /* The list we're iterating. */ _list_t *lp; @@ -423,7 +410,7 @@ /* True when we've actually removed something. */ bool removed_p; -} _list_iterator; +}; static inline void _list_iter_start (_list_iterator *ip, _list_t *lp, bool can_remove_p) @@ -516,17 +503,48 @@ #define _FOR_EACH_X_1(X, I, LP) _FOR_EACH_1 (x, (X), (I), (LP)) -/* ilist_t functions. Instruction lists are simply RTX lists. */ +/* ilist_t functions. */ + +static inline void +ilist_add (ilist_t *lp, insn_t insn) +{ + _list_add (lp); + ILIST_INSN (*lp) = insn; +} +#define ilist_remove(LP) (_list_remove (LP)) +#define ilist_clear(LP) (_list_clear (LP)) + +static inline bool +ilist_is_in_p (ilist_t l, insn_t insn) +{ + while (l) + { + if (ILIST_INSN (l) == insn) + return true; + l = ILIST_NEXT (l); + } -#define ilist_add(LP, INSN) (_xlist_add ((LP), (INSN))) -#define ilist_remove(LP) (_xlist_remove (LP)) -#define ilist_clear(LP) (_xlist_clear (LP)) -#define ilist_is_in_p(L, INSN) (_xlist_is_in_p ((L), (INSN))) -#define ilist_iter_remove(IP) (_xlist_iter_remove (IP)) + return false; +} -typedef _xlist_iterator ilist_iterator; -#define FOR_EACH_INSN(INSN, I, L) _FOR_EACH_X (INSN, I, L) -#define FOR_EACH_INSN_1(INSN, I, LP) _FOR_EACH_X_1 (INSN, I, LP) +/* Used through _FOR_EACH. */ +static inline bool +_list_iter_cond_insn (ilist_t l, insn_t *ip) +{ + if (l) + { + *ip = ILIST_INSN (l); + return true; + } + + return false; +} + +#define ilist_iter_remove(IP) (_list_iter_remove (IP)) + +typedef _list_iterator ilist_iterator; +#define FOR_EACH_INSN(INSN, I, L) _FOR_EACH (insn, (INSN), (I), (L)) +#define FOR_EACH_INSN_1(INSN, I, LP) _FOR_EACH_1 (insn, (INSN), (I), (LP)) /* Av set iterators. */ @@ -534,7 +552,7 @@ #define FOR_EACH_EXPR(EXPR, I, AV) _FOR_EACH (expr, (EXPR), (I), (AV)) #define FOR_EACH_EXPR_1(EXPR, I, AV) _FOR_EACH_1 (expr, (EXPR), (I), (AV)) -static bool +inline bool _list_iter_cond_expr (av_set_t av, expr_t *exprp) { if (av) @@ -629,7 +647,7 @@ struct vinsn_def { /* Associated insn. */ - rtx insn_rtx; + rtx_insn *insn_rtx; /* Its description. */ struct idata_def id; @@ -759,13 +777,11 @@ typedef struct _sel_insn_data sel_insn_data_def; typedef sel_insn_data_def *sel_insn_data_t; -DEF_VEC_O (sel_insn_data_def); -DEF_VEC_ALLOC_O (sel_insn_data_def, heap); -extern VEC (sel_insn_data_def, heap) *s_i_d; +extern vec<sel_insn_data_def> s_i_d; /* Accessor macros for s_i_d. */ -#define SID(INSN) (VEC_index (sel_insn_data_def, s_i_d, INSN_LUID (INSN))) -#define SID_BY_UID(UID) (VEC_index (sel_insn_data_def, s_i_d, LUID_BY_UID (UID))) +#define SID(INSN) (&s_i_d[INSN_LUID (INSN)]) +#define SID_BY_UID(UID) (&s_i_d[LUID_BY_UID (UID)]) extern sel_insn_data_def insn_sid (insn_t); @@ -815,7 +831,7 @@ extern rtx nop_pattern; /* An insn that 'contained' in EXIT block. */ -extern rtx exit_insn; +extern rtx_insn *exit_insn; /* Provide a separate luid for the insn. */ #define INSN_INIT_TODO_LUID (1) @@ -847,7 +863,7 @@ /* Saved loop preheader to transfer when scheduling the loop. */ #define LOOP_PREHEADER_BLOCKS(LOOP) ((size_t)((LOOP)->aux) == 1 \ ? NULL \ - : ((VEC(basic_block, heap) *) (LOOP)->aux)) + : ((vec<basic_block> *) (LOOP)->aux)) #define SET_LOOP_PREHEADER_BLOCKS(LOOP,BLOCKS) ((LOOP)->aux \ = (BLOCKS != NULL \ ? BLOCKS \ @@ -858,22 +874,21 @@ /* A variable to track which part of rtx we are scanning in sched-deps.c: sched_analyze_insn (). */ -enum deps_where_def - { - DEPS_IN_INSN, - DEPS_IN_LHS, - DEPS_IN_RHS, - DEPS_IN_NOWHERE - }; -typedef enum deps_where_def deps_where_t; +enum deps_where_t +{ + DEPS_IN_INSN, + DEPS_IN_LHS, + DEPS_IN_RHS, + DEPS_IN_NOWHERE +}; /* Per basic block data for the whole CFG. */ -typedef struct +struct sel_global_bb_info_def { /* For each bb header this field contains a set of live registers. For all other insns this field has a NULL. - We also need to know LV sets for the instructions, that are immediatly + We also need to know LV sets for the instructions, that are immediately after the border of the region. */ regset lv_set; @@ -881,33 +896,31 @@ true - block has usable LV_SET. false - block's LV_SET should be recomputed. */ bool lv_set_valid_p; -} sel_global_bb_info_def; +}; typedef sel_global_bb_info_def *sel_global_bb_info_t; -DEF_VEC_O (sel_global_bb_info_def); -DEF_VEC_ALLOC_O (sel_global_bb_info_def, heap); /* Per basic block data. This array is indexed by basic block index. */ -extern VEC (sel_global_bb_info_def, heap) *sel_global_bb_info; +extern vec<sel_global_bb_info_def> sel_global_bb_info; extern void sel_extend_global_bb_info (void); extern void sel_finish_global_bb_info (void); /* Get data for BB. */ #define SEL_GLOBAL_BB_INFO(BB) \ - (VEC_index (sel_global_bb_info_def, sel_global_bb_info, (BB)->index)) + (&sel_global_bb_info[(BB)->index]) /* Access macros. */ #define BB_LV_SET(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set) #define BB_LV_SET_VALID_P(BB) (SEL_GLOBAL_BB_INFO (BB)->lv_set_valid_p) /* Per basic block data for the region. */ -typedef struct +struct sel_region_bb_info_def { /* This insn stream is constructed in such a way that it should be traversed by PREV_INSN field - (*not* NEXT_INSN). */ - rtx note_list; + rtx_insn *note_list; /* Cached availability set at the beginning of a block. See also AV_LEVEL () for conditions when this av_set can be used. */ @@ -915,19 +928,16 @@ /* If (AV_LEVEL == GLOBAL_LEVEL) then AV is valid. */ int av_level; -} sel_region_bb_info_def; +}; typedef sel_region_bb_info_def *sel_region_bb_info_t; -DEF_VEC_O (sel_region_bb_info_def); -DEF_VEC_ALLOC_O (sel_region_bb_info_def, heap); /* Per basic block data. This array is indexed by basic block index. */ -extern VEC (sel_region_bb_info_def, heap) *sel_region_bb_info; +extern vec<sel_region_bb_info_def> sel_region_bb_info; /* Get data for BB. */ -#define SEL_REGION_BB_INFO(BB) (VEC_index (sel_region_bb_info_def, \ - sel_region_bb_info, (BB)->index)) +#define SEL_REGION_BB_INFO(BB) (&sel_region_bb_info[(BB)->index]) /* Get BB's note_list. A note_list is a list of various notes that was scattered across BB @@ -964,7 +974,7 @@ /* Successor iterator backend. */ -typedef struct +struct succ_iterator { /* True if we're at BB end. */ bool bb_end; @@ -986,13 +996,13 @@ short flags; /* When flags include SUCCS_ALL, this will be set to the exact type - of the sucessor we're traversing now. */ + of the successor we're traversing now. */ short current_flags; /* If skip to loop exits, save here information about loop exits. */ int current_exit; - VEC (edge, heap) *loop_exits; -} succ_iterator; + vec<edge> loop_exits; +}; /* A structure returning all successor's information. */ struct succs_info @@ -1005,7 +1015,7 @@ /* Their probabilities. As of now, we don't need this for other successors. */ - VEC(int,heap) *probs_ok; + vec<int> probs_ok; /* Other successors. */ insn_vec_t succs_other; @@ -1023,8 +1033,8 @@ /* Some needed definitions. */ extern basic_block after_recovery; -extern insn_t sel_bb_head (basic_block); -extern insn_t sel_bb_end (basic_block); +extern rtx_insn *sel_bb_head (basic_block); +extern rtx_insn *sel_bb_end (basic_block); extern bool sel_bb_empty_p (basic_block); extern bool in_current_region_p (basic_block); @@ -1037,7 +1047,7 @@ if (!current_loop_nest) return false; - if (bb == EXIT_BLOCK_PTR) + if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) return false; inner_loop = bb->loop_father; @@ -1057,13 +1067,13 @@ } /* Return exit edges of LOOP, filtering out edges with the same dest bb. */ -static inline VEC (edge, heap) * +static inline vec<edge> get_loop_exit_edges_unique_dests (const struct loop *loop) { - VEC (edge, heap) *edges = NULL; + vec<edge> edges = vNULL; struct loop_exit *exit; - gcc_assert (loop->latch != EXIT_BLOCK_PTR + gcc_assert (loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun) && current_loops->state & LOOPS_HAVE_RECORDED_EXITS); for (exit = loop->exits->next; exit->e; exit = exit->next) @@ -1072,7 +1082,7 @@ edge e; bool was_dest = false; - for (i = 0; VEC_iterate (edge, edges, i, e); i++) + for (i = 0; edges.iterate (i, &e); i++) if (e->dest == exit->e->dest) { was_dest = true; @@ -1080,7 +1090,7 @@ } if (!was_dest) - VEC_safe_push (edge, heap, edges, exit->e); + edges.safe_push (exit->e); } return edges; } @@ -1096,7 +1106,7 @@ if (!INSN_NOP_P (first)) return false; - if (bb == EXIT_BLOCK_PTR) + if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) return false; last = sel_bb_end (bb); @@ -1111,15 +1121,16 @@ traverse all of them and if any of them turns out to be another loop header (after skipping empty BBs), add its loop exits to the resulting vector as well. */ -static inline VEC(edge, heap) * +static inline vec<edge> get_all_loop_exits (basic_block bb) { - VEC(edge, heap) *exits = NULL; + vec<edge> exits = vNULL; /* If bb is empty, and we're skipping to loop exits, then consider bb as a possible gate to the inner loop now. */ while (sel_bb_empty_or_nop_p (bb) - && in_current_region_p (bb)) + && in_current_region_p (bb) + && EDGE_COUNT (bb->succs) > 0) { bb = single_succ (bb); @@ -1146,24 +1157,24 @@ exits = get_loop_exit_edges_unique_dests (this_loop); /* Traverse all loop headers. */ - for (i = 0; VEC_iterate (edge, exits, i, e); i++) + for (i = 0; exits.iterate (i, &e); i++) if (in_current_region_p (e->dest) || inner_loop_header_p (e->dest)) { - VEC(edge, heap) *next_exits = get_all_loop_exits (e->dest); + vec<edge> next_exits = get_all_loop_exits (e->dest); - if (next_exits) + if (next_exits.exists ()) { int j; edge ne; /* Add all loop exits for the current edge into the resulting vector. */ - for (j = 0; VEC_iterate (edge, next_exits, j, ne); j++) - VEC_safe_push (edge, heap, exits, ne); + for (j = 0; next_exits.iterate (j, &ne); j++) + exits.safe_push (ne); /* Remove the original edge. */ - VEC_ordered_remove (edge, exits, i); + exits.ordered_remove (i); /* Decrease the loop counter so we won't skip anything. */ i--; @@ -1214,15 +1225,15 @@ i.bb = bb; i.current_flags = 0; i.current_exit = -1; - i.loop_exits = NULL; + i.loop_exits.create (0); - if (bb != EXIT_BLOCK_PTR && BB_END (bb) != insn) + if (bb != EXIT_BLOCK_PTR_FOR_FN (cfun) && BB_END (bb) != insn) { i.bb_end = false; /* Avoid 'uninitialized' warning. */ i.ei.index = 0; - i.ei.container = NULL; + i.ei.container = 0; } else { @@ -1234,7 +1245,7 @@ } static inline bool -_succ_iter_cond (succ_iterator *ip, rtx *succp, rtx insn, +_succ_iter_cond (succ_iterator *ip, insn_t *succp, insn_t insn, bool check (edge, succ_iterator *)) { if (!ip->bb_end) @@ -1255,18 +1266,17 @@ edge e_tmp = NULL; /* First, try loop exits, if we have them. */ - if (ip->loop_exits) + if (ip->loop_exits.exists ()) { do { - VEC_iterate (edge, ip->loop_exits, - ip->current_exit, e_tmp); + ip->loop_exits.iterate (ip->current_exit, &e_tmp); ip->current_exit++; } while (e_tmp && !check (e_tmp, ip)); if (!e_tmp) - VEC_free (edge, heap, ip->loop_exits); + ip->loop_exits.release (); } /* If we have found a successor, then great. */ @@ -1291,7 +1301,7 @@ /* Get all loop exits recursively. */ ip->loop_exits = get_all_loop_exits (bb); - if (ip->loop_exits) + if (ip->loop_exits.exists ()) { ip->current_exit = 0; /* Move the iterator now, because we won't do @@ -1310,7 +1320,7 @@ /* If loop_exits are non null, we have found an inner loop; do one more iteration to fetch an edge from these exits. */ - if (ip->loop_exits) + if (ip->loop_exits.exists ()) continue; /* Otherwise, we've found an edge in a usual way. Break now. */ @@ -1321,7 +1331,7 @@ { basic_block bb = ip->e2->dest; - if (bb == EXIT_BLOCK_PTR || bb == after_recovery) + if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb == after_recovery) *succp = exit_insn; else { @@ -1344,7 +1354,7 @@ { gcc_assert (!ip->e2 || ip->e1); - if (ip->bb_end && ip->e1 && !ip->loop_exits) + if (ip->bb_end && ip->e1 && !ip->loop_exits.exists ()) ei_next (&(ip->ei)); } @@ -1543,9 +1553,9 @@ extern void clear_expr (expr_t); extern unsigned expr_dest_regno (expr_t); extern rtx expr_dest_reg (expr_t); -extern int find_in_history_vect (VEC(expr_history_def, heap) *, +extern int find_in_history_vect (vec<expr_history_def> , rtx, vinsn_t, bool); -extern void insert_in_history_vect (VEC(expr_history_def, heap) **, +extern void insert_in_history_vect (vec<expr_history_def> *, unsigned, enum local_trans_type, vinsn_t, vinsn_t, ds_t); extern void mark_unavailable_targets (av_set_t, av_set_t, regset); @@ -1565,7 +1575,7 @@ extern expr_t av_set_element (av_set_t, int); extern void av_set_substract_cond_branches (av_set_t *); extern void av_set_split_usefulness (av_set_t, int, int); -extern void av_set_intersect (av_set_t *, av_set_t); +extern void av_set_code_motion_filter (av_set_t *, av_set_t); extern void sel_save_haifa_priorities (void); @@ -1573,6 +1583,7 @@ extern void sel_finish_global_and_expr (void); extern regset compute_live (insn_t); +extern bool register_unavailable_p (regset, rtx); /* Dependence analysis functions. */ extern void sel_clear_has_dependence (void); @@ -1583,7 +1594,7 @@ /* Functions to work with insns. */ extern bool lhs_of_insn_equals_to_dest_p (insn_t, rtx); extern bool insn_eligible_for_subst_p (insn_t); -extern void get_dest_and_mode (rtx, rtx *, enum machine_mode *); +extern void get_dest_and_mode (rtx, rtx *, machine_mode *); extern bool bookkeeping_can_be_created_if_moved_through_p (insn_t); extern bool sel_remove_insn (insn_t, bool, bool); @@ -1593,23 +1604,23 @@ /* Basic block and CFG functions. */ -extern insn_t sel_bb_head (basic_block); +extern rtx_insn *sel_bb_head (basic_block); extern bool sel_bb_head_p (insn_t); -extern insn_t sel_bb_end (basic_block); +extern rtx_insn *sel_bb_end (basic_block); extern bool sel_bb_end_p (insn_t); extern bool sel_bb_empty_p (basic_block); extern bool in_current_region_p (basic_block); -extern basic_block fallthru_bb_of_jump (rtx); +extern basic_block fallthru_bb_of_jump (const rtx_insn *); -extern void sel_init_bbs (bb_vec_t, basic_block); +extern void sel_init_bbs (bb_vec_t); extern void sel_finish_bbs (void); extern struct succs_info * compute_succs_info (insn_t, short); extern void free_succs_info (struct succs_info *); extern bool sel_insn_has_single_succ_p (insn_t, int); extern bool sel_num_cfg_preds_gt_1 (insn_t); -extern int get_seqno_by_preds (rtx); +extern int get_seqno_by_preds (rtx_insn *); extern bool bb_ends_ebb_p (basic_block); extern bool in_same_ebb_p (insn_t, insn_t); @@ -1627,8 +1638,8 @@ extern void sel_sched_region (int); extern loop_p get_loop_nest_for_rgn (unsigned int); extern bool considered_for_pipelining_p (struct loop *); -extern void make_region_from_loop_preheader (VEC(basic_block, heap) **); -extern void sel_add_loop_preheaders (void); +extern void make_region_from_loop_preheader (vec<basic_block> *&); +extern void sel_add_loop_preheaders (bb_vec_t *); extern bool sel_is_loop_preheader_p (basic_block); extern void clear_outdated_rtx_info (basic_block); extern void free_data_sets (basic_block); @@ -1639,9 +1650,9 @@ extern void sel_unregister_cfg_hooks (void); /* Expression transformation routines. */ -extern rtx create_insn_rtx_from_pattern (rtx, rtx); -extern vinsn_t create_vinsn_from_insn_rtx (rtx, bool); -extern rtx create_copy_of_insn_rtx (rtx); +extern rtx_insn *create_insn_rtx_from_pattern (rtx, rtx); +extern vinsn_t create_vinsn_from_insn_rtx (rtx_insn *, bool); +extern rtx_insn *create_copy_of_insn_rtx (rtx); extern void change_vinsn_in_expr (expr_t, vinsn_t); /* Various initialization functions. */ @@ -1658,11 +1669,3 @@ extern void free_sched_pools (void); #endif /* GCC_SEL_SCHED_IR_H */ - - - - - - - -