summaryrefslogtreecommitdiff
path: root/gcc/sel-sched-ir.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-18 02:54:30 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-18 02:54:30 +0000
commitf1f41a6cdc47d5123dd30ab110cc35c90f8189cb (patch)
tree1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/sel-sched-ir.c
parent85ed3b5a235c79e565d04354e67c979abdc66057 (diff)
downloadgcc-f1f41a6cdc47d5123dd30ab110cc35c90f8189cb.tar.gz
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec. I have tested the patch pretty extensively: - Regular bootstraps on x86_64, ppc, ia64, sparc and hppa. - Bootstraps with --enable-checking=release - Bootstraps with --enable-checking=gc,gcac - Basic builds on all targets (using contrib/config-list.mk). We no longer access the vectors via VEC_* macros. The pattern is "VEC_operation (T, A, V, args)" becomes "V.operation (args)". The only thing I could not do is create proper ctors and dtors for the vec class. Since these vectors are stored in unions, we have to keep them as PODs (C++03 does not allow non-PODs in unions). This means that creation and destruction must be explicit. There is a new method vec<type, allocation, layout>::create() and another vec<type, allocation, layout>::destroy() to allocate the internal vector. For vectors that must be pointers, there is a family of free functions that implement the operations that need to tolerate NULL vectors. These functions all start with the prefix 'vec_safe_'. See the wiki page for details. The gengtype change removes the special handling for VEC() that used to exist in gengtype. Additionally, it allows gengtype to recognize templates of more than one argument and introduces the concept of an undefined type (useful for template arguments that may or may not be types). When a TYPE_UNDEFINED is reached, gengtype will ignore it if it happens inside a type marked with GTY((user)). Otherwise, it will emit an error. Finally, gengtype rejects root types marked GTY((user)) that are not first class pointers. 2012-11-16 Diego Novillo <dnovillo@google.com> VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) * vec.c (register_overhead): Convert it into member function of vec_prefix. (release_overhead): Likewise. (calculate_allocation): Likewise. (vec_heap_free): Remove. (vec_gc_o_reserve_1): Remove. (vec_heap_o_reserve_1): Remove. (vec_stack_o_reserve_1): Remove. (vec_stack_o_reserve_exact): Remove. (register_stack_vec): New. (stack_vec_register_index): New. (unregister_stack_vec): New. (vec_assert_fail): Remove. * vec.h: Conditionally include ggc.h. Document conditional hackery. Update top-level documentation. (ALONE_VEC_CHECK_INFO): Remove. (VEC_CHECK_INFO): Remove. (ALONE_VEC_CHECK_DECL): Remove. (VEC_CHECK_DECL): Remove. (ALONE_VEC_CHECK_PASS): Remove. (VEC_CHECK_PASS): Remove. (VEC_ASSERT): Remove. (vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and va_stack. Mark fields alloc_ and num_ as protected. (struct vec_t): Remove. Remove all function members. (struct vl_embed): Declare. (struct vl_ptr): Declare. (free): Remove. (reserve_exact): Remove. (reserve): Remove. (safe_splice): Remove. (safe_push): Remove. (safe_grow): Remove. (safe_grow_cleared): Remove. (safe_insert): Remove. (DEF_VEC_I): Remove. (DEF_VEC_ALLOC_I): Remove. (DEF_VEC_P): Remove. (DEF_VEC_ALLOC_P): Remove. (DEF_VEC_O): Remove. (DEF_VEC_ALLOC_O): Remove. (DEF_VEC_ALLOC_P_STACK): Remove. (DEF_VEC_ALLOC_O_STACK): Remove. (DEF_VEC_ALLOC_I_STACK): Remove. (DEF_VEC_A): Remove. (DEF_VEC_ALLOC_A): Remove. (vec_stack_p_reserve_exact_1): Remove. (vec_stack_o_reserve): Remove. (vec_stack_o_reserve_exact): Remove. (VEC_length): Remove. (VEC_empty): Remove. (VEC_address): Remove. (vec_address): Remove. (VEC_last): Remove. (VEC_index): Remove. (VEC_iterate): Remove. (VEC_embedded_size): Remove. (VEC_embedded_init): Remove. (VEC_free): Remove. (VEC_copy): Remove. (VEC_space): Remove. (VEC_reserve): Remove. (VEC_reserve_exact): Remove. (VEC_splice): Remove. (VEC_safe_splice): Remove. (VEC_quick_push): Remove. (VEC_safe_push): Remove. (VEC_pop): Remove. (VEC_truncate): Remove. (VEC_safe_grow): Remove. (VEC_replace): Remove. (VEC_quick_insert): Remove. (VEC_safe_insert): Remove. (VEC_ordered_remove): Remove. (VEC_unordered_remove): Remove. (VEC_block_remove): Remove. (VEC_lower_bound): Remove. (VEC_alloc): Remove. (VEC_qsort): Remove. (va_heap): Declare. (va_heap::default_layout): New typedef to vl_ptr. (va_heap::reserve): New. (va_heap::release): New. (va_gc): Declare. (va_gc::default_layout): New typedef to vl_embed. (va_gc::reserve): New. (va_gc::release): New. (va_gc_atomic): Declare. Inherit from va_gc. (va_stack): Declare. (va_stack::default_layout): New typedef to vl_ptr. (va_stack::alloc): New. (va_stack::reserve): New. (va_stack::release): New. (register_stack_vec): Declare. (stack_vec_register_index): Declare. (unregister_stack_vec): Declare. (vec<T, A = va_heap, L = typename A::default_layout>): Declare empty vec template. (vec<T, A, vl_embed>): Partial specialization for embedded layout. (vec<T, A, vl_embed>::allocated): New. (vec<T, A, vl_embed>::length): New. (vec<T, A, vl_embed>::is_empty): New. (vec<T, A, vl_embed>::address): New. (vec<T, A, vl_embed>::operator[]): New. (vec<T, A, vl_embed>::last New. (vec<T, A, vl_embed>::space): New. (vec<T, A, vl_embed>::iterate): New. (vec<T, A, vl_embed>::iterate): New. (vec<T, A, vl_embed>::copy): New. (vec<T, A, vl_embed>::splice): New. (vec<T, A, vl_embed>::quick_push New. (vec<T, A, vl_embed>::pop New. (vec<T, A, vl_embed>::truncate): New. (vec<T, A, vl_embed>::quick_insert): New. (vec<T, A, vl_embed>::ordered_remove): New. (vec<T, A, vl_embed>::unordered_remove): New. (vec<T, A, vl_embed>::block_remove): New. (vec<T, A, vl_embed>::qsort): New. (vec<T, A, vl_embed>::lower_bound): New. (vec<T, A, vl_embed>::embedded_size): New. (vec<T, A, vl_embed>::embedded_init): New. (vec<T, A, vl_embed>::quick_grow): New. (vec<T, A, vl_embed>::quick_grow_cleared): New. (vec_safe_space): New. (vec_safe_length): New. (vec_safe_address): New. (vec_safe_is_empty): New. (vec_safe_reserve): New. (vec_safe_reserve_exact): New. (vec_alloc): New. (vec_free): New. (vec_safe_grow): New. (vec_safe_grow_cleared): New. (vec_safe_iterate): New. (vec_safe_push): New. (vec_safe_insert): New. (vec_safe_truncate): New. (vec_safe_copy): New. (vec_safe_splice): New. (vec<T, A, vl_ptr>): New partial specialization for the space efficient layout. (vec<T, A, vl_ptr>::exists): New. (vec<T, A, vl_ptr>::is_empty): New. (vec<T, A, vl_ptr>::length): New. (vec<T, A, vl_ptr>::address): New. (vec<T, A, vl_ptr>::operator[]): New. (vec<T, A, vl_ptr>::operator!=): New. (vec<T, A, vl_ptr>::operator==): New. (vec<T, A, vl_ptr>::last): New. (vec<T, A, vl_ptr>::space): New. (vec<T, A, vl_ptr>::iterate): New. (vec<T, A, vl_ptr>::copy): New. (vec<T, A, vl_ptr>::reserve): New. (vec<T, A, vl_ptr>::reserve_exact): New. (vec<T, A, vl_ptr>::splice): New. (vec<T, A, vl_ptr>::safe_splice): New. (vec<T, A, vl_ptr>::quick_push): New. (vec<T, A, vl_ptr>::safe_push): New. (vec<T, A, vl_ptr>::pop): New. (vec<T, A, vl_ptr>::truncate): New. (vec<T, A, vl_ptr>::safe_grow): New. (vec<T, A, vl_ptr>::safe_grow_cleared): New. (vec<T, A, vl_ptr>::quick_grow): New. (vec<T, A, vl_ptr>::quick_grow_cleared): New. (vec<T, A, vl_ptr>::quick_insert): New. (vec<T, A, vl_ptr>::safe_insert): New. (vec<T, A, vl_ptr>::ordered_remove): New. (vec<T, A, vl_ptr>::unordered_remove): New. (vec<T, A, vl_ptr>::block_remove): New. (vec<T, A, vl_ptr>::qsort): New. (vec<T, A, vl_ptr>::lower_bound): New. (vec_stack_alloc): Define. (FOR_EACH_VEC_SAFE_ELT): Define. * vecir.h: Remove. Update all users. * vecprim.h: Remove. Update all users. Move uchar to coretypes.h. * Makefile.in (VEC_H): Add $(GGC_H). Remove vecir.h and vecprim.h dependencies everywhere. 2012-11-16 Diego Novillo <dnovillo@google.com> * gengtype-lex.l (VEC): Remove. Add characters in the set [\!\>\.-]. * gengtype-parse.c (token_names): Remove "VEC". (require_template_declaration): Remove handling of VEC_TOKEN. (type): Likewise. Call create_user_defined_type when parsing GTY((user)). * gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED. (write_state_undefined_type): New. (write_state_type): Call write_state_undefined_type for TYPE_UNDEFINED. (read_state_type): Call read_state_undefined_type for TYPE_UNDEFINED. * gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED. (create_user_defined_type): Make extern. (type_for_name): Factor out of resolve_typedef. (create_undefined_type): New (resolve_typedef): Call it when we cannot find a previous typedef and the type is not a template. (find_structure): Accept TYPE_UNDEFINED. (set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES, default to false. Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or ALLOWED_UNDEFINED_TYPES is set. Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT. (filter_type_name): Accept templates with more than one argument. (output_mangled_typename): Handle TYPE_UNDEFINED (walk_type): Likewise. (write_types_process_field): Likewise. (write_func_for_structure): If CHAIN_NEXT is set, ORIG_S should not be a user-defined type. (write_types_local_user_process_field): Handle TYPE_ARRAY, TYPE_NONE and TYPE_UNDEFINED. (write_types_local_process_field): Likewise. (contains_scalar_p): Return 0 for TYPE_USER_STRUCT. (write_root): Reject user-defined types that are not pointers. Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT and TYPE_PARAM_STRUCT. (output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and TYPE_ARRAY. (dump_typekind): Handle TYPE_UNDEFINED. * gengtype.h (enum typekind): Add TYPE_UNDEFINED. (create_user_defined_type): Declare. (enum gty_token): Remove VEC_TOKEN. 2012-11-16 Diego Novillo <dnovillo@google.com> Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) * coretypes.h (uchar): Define. * alias.c: Use new vec API in vec.h. * asan.c: Likewise. * attribs.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * builtins.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgcleanup.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopanal.c: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * compare-elim.c: Likewise. * coverage.c: Likewise. * cprop.c: Likewise. * data-streamer.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * domwalk.h: Likewise. * dse.c: Likewise. * dwarf2cfi.c: Likewise. * dwarf2out.c: Likewise. * dwarf2out.h: Likewise. * emit-rtl.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genextract.c: Likewise. * genopinit.c: Likewise * ggc-common.c: Likewise. * ggc.h: Likewise. * gimple-low.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimple-streamer-in.c: Likewise. * gimple.c: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graph.c: Likewise. * graphds.c: Likewise. * graphds.h: Likewise. * graphite-blocking.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-optimize-isl.c: Likewise. * graphite-poly.c: Likewise. * graphite-poly.h: Likewise. * graphite-scop-detection.c: Likewise. * graphite-scop-detection.h: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * godump.c: Likewise. * haifa-sched.c: Likewise. * hw-doloop.c: Likewise. * hw-doloop.h: Likewise. * ifcvt.c: Likewise. * insn-addr.h: Likewise. * ipa-cp.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline-transform.c: Likewise. * ipa-inline.c: Likewise. * ipa-inline.h: Likewise. * ipa-prop.c: Likewise. * ipa-prop.h: Likewise. * ipa-pure-const.c: Likewise. * ipa-ref-inline.h: Likewise. * ipa-ref.c: Likewise. * ipa-ref.h: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lra-lives.c: Likewise. * lra.c: Likewise. * lto-cgraph.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * mcf.c: Likewise. * modulo-sched.c: Likewise. * omp-low.c: Likewise. * opts-common.c: Likewise. * opts-global.c: Likewise. * opts.c: Likewise. * opts.h: Likewise. * passes.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * profile.h: Likewise. * read-rtl.c: Likewise. * ree.c: Likewise. * reg-stack.c: Likewise. * regrename.c: Likewise. * regrename.h: Likewise. * reload.c: Likewise. * reload.h: Likewise. * reload1.c: Likewise. * rtl.h: Likewise. * sched-deps.c: Likewise. * sched-int.h: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * sese.h: Likewise. * statistics.h: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-browser.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-diagnostic.c: Likewise. * tree-dump.c: Likewise. * tree-eh.c: Likewise. * tree-emutls.c: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-inline.h: Likewise. * tree-into-ssa.c: Likewise. * tree-iterator.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-mudflap.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sccvn.h: Likewise. * tree-ssa-strlen.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-tail-merge.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-stdarg.c: Likewise. * tree-streamer-in.c: Likewise. * tree-streamer-out.c: Likewise. * tree-streamer.c: Likewise. * tree-streamer.h: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.h: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vmsdbgout.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/darwin.c: Likewise. * config/i386/i386.c: Likewise. * config/ia64/ia64.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/pa.c: Likewise. * config/rs6000/rs6000-c.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/rx/rx.c: Likewise. * config/spu/spu-c.c: Likewise. * config/vms/vms.c: Likewise. * config/vxworks.c: Likewise. * config/epiphany/resolve-sw-modes.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193595 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/sel-sched-ir.c')
-rw-r--r--gcc/sel-sched-ir.c273
1 files changed, 133 insertions, 140 deletions
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index e0239dc3637..e5929299c11 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -49,10 +49,12 @@ along with GCC; see the file COPYING3. If not see
#include "sel-sched-dump.h"
/* A vector holding bb info for whole scheduling pass. */
-VEC(sel_global_bb_info_def, heap) *sel_global_bb_info = NULL;
+vec<sel_global_bb_info_def>
+ sel_global_bb_info = vec<sel_global_bb_info_def>();
/* A vector holding bb info. */
-VEC(sel_region_bb_info_def, heap) *sel_region_bb_info = NULL;
+vec<sel_region_bb_info_def>
+ sel_region_bb_info = vec<sel_region_bb_info_def>();
/* A pool for allocating all lists. */
alloc_pool sched_lists_pool;
@@ -68,7 +70,7 @@ struct loop *current_loop_nest;
/* LOOP_NESTS is a vector containing the corresponding loop nest for
each region. */
-static VEC(loop_p, heap) *loop_nests = NULL;
+static vec<loop_p> loop_nests = vec<loop_p>();
/* Saves blocks already in loop regions, indexed by bb->index. */
static sbitmap bbs_in_loop_rgns = NULL;
@@ -147,7 +149,7 @@ static expr_t set_insn_init (expr_t, vinsn_t, int);
static void cfg_preds (basic_block, insn_t **, int *);
static void prepare_insn_expr (insn_t, int);
-static void free_history_vect (VEC (expr_history_def, heap) **);
+static void free_history_vect (vec<expr_history_def> &);
static void move_bb_info (basic_block, basic_block);
static void remove_empty_bb (basic_block, bool);
@@ -261,7 +263,7 @@ init_fence_for_scheduling (fence_t f)
/* Add new fence consisting of INSN and STATE to the list pointed to by LP. */
static void
flist_add (flist_t *lp, insn_t insn, state_t state, deps_t dc, void *tc,
- insn_t last_scheduled_insn, VEC(rtx,gc) *executing_insns,
+ insn_t last_scheduled_insn, vec<rtx, va_gc> *executing_insns,
int *ready_ticks, int ready_ticks_size, insn_t sched_next,
int cycle, int cycle_issued_insns, int issue_more,
bool starts_cycle_p, bool after_stall_p)
@@ -586,7 +588,7 @@ fence_clear (fence_t f)
if (tc != NULL)
delete_target_context (tc);
- VEC_free (rtx, gc, FENCE_EXECUTING_INSNS (f));
+ vec_free (FENCE_EXECUTING_INSNS (f));
free (FENCE_READY_TICKS (f));
FENCE_READY_TICKS (f) = NULL;
}
@@ -636,7 +638,7 @@ init_fences (insn_t old_fence)
static void
merge_fences (fence_t f, insn_t insn,
state_t state, deps_t dc, void *tc,
- rtx last_scheduled_insn, VEC(rtx, gc) *executing_insns,
+ rtx last_scheduled_insn, vec<rtx, va_gc> *executing_insns,
int *ready_ticks, int ready_ticks_size,
rtx sched_next, int cycle, int issue_more, bool after_stall_p)
{
@@ -669,11 +671,11 @@ merge_fences (fence_t f, insn_t insn,
FENCE_LAST_SCHEDULED_INSN (f) = NULL;
FENCE_ISSUE_MORE (f) = issue_rate;
- VEC_free (rtx, gc, executing_insns);
+ vec_free (executing_insns);
free (ready_ticks);
if (FENCE_EXECUTING_INSNS (f))
- VEC_block_remove (rtx, FENCE_EXECUTING_INSNS (f), 0,
- VEC_length (rtx, FENCE_EXECUTING_INSNS (f)));
+ FENCE_EXECUTING_INSNS (f)->block_remove (0,
+ FENCE_EXECUTING_INSNS (f)->length ());
if (FENCE_READY_TICKS (f))
memset (FENCE_READY_TICKS (f), 0, FENCE_READY_TICKS_SIZE (f));
}
@@ -757,13 +759,13 @@ merge_fences (fence_t f, insn_t insn,
{
reset_deps_context (FENCE_DC (f));
delete_deps_context (dc);
- VEC_free (rtx, gc, executing_insns);
+ vec_free (executing_insns);
free (ready_ticks);
FENCE_CYCLE (f) = MAX (FENCE_CYCLE (f), cycle);
if (FENCE_EXECUTING_INSNS (f))
- VEC_block_remove (rtx, FENCE_EXECUTING_INSNS (f), 0,
- VEC_length (rtx, FENCE_EXECUTING_INSNS (f)));
+ FENCE_EXECUTING_INSNS (f)->block_remove (0,
+ FENCE_EXECUTING_INSNS (f)->length ());
if (FENCE_READY_TICKS (f))
memset (FENCE_READY_TICKS (f), 0, FENCE_READY_TICKS_SIZE (f));
}
@@ -772,7 +774,7 @@ merge_fences (fence_t f, insn_t insn,
{
delete_deps_context (FENCE_DC (f));
FENCE_DC (f) = dc;
- VEC_free (rtx, gc, FENCE_EXECUTING_INSNS (f));
+ vec_free (FENCE_EXECUTING_INSNS (f));
FENCE_EXECUTING_INSNS (f) = executing_insns;
free (FENCE_READY_TICKS (f));
FENCE_READY_TICKS (f) = ready_ticks;
@@ -783,7 +785,7 @@ merge_fences (fence_t f, insn_t insn,
{
/* Leave DC and CYCLE untouched. */
delete_deps_context (dc);
- VEC_free (rtx, gc, executing_insns);
+ vec_free (executing_insns);
free (ready_ticks);
}
}
@@ -802,7 +804,7 @@ merge_fences (fence_t f, insn_t insn,
static void
add_to_fences (flist_tail_t new_fences, insn_t insn,
state_t state, deps_t dc, void *tc, rtx last_scheduled_insn,
- VEC(rtx, gc) *executing_insns, int *ready_ticks,
+ vec<rtx, va_gc> *executing_insns, int *ready_ticks,
int ready_ticks_size, rtx sched_next, int cycle,
int cycle_issued_insns, int issue_rate,
bool starts_cycle_p, bool after_stall_p)
@@ -886,7 +888,7 @@ add_dirty_fence_to_fences (flist_tail_t new_fences, insn_t succ, fence_t fence)
create_copy_of_deps_context (FENCE_DC (fence)),
create_copy_of_target_context (FENCE_TC (fence)),
FENCE_LAST_SCHEDULED_INSN (fence),
- VEC_copy (rtx, gc, FENCE_EXECUTING_INSNS (fence)),
+ vec_safe_copy (FENCE_EXECUTING_INSNS (fence)),
new_ready_ticks,
FENCE_READY_TICKS_SIZE (fence),
FENCE_SCHED_NEXT (fence),
@@ -1438,12 +1440,12 @@ sel_move_insn (expr_t expr, int seqno, insn_t after)
the search has stopped, such that inserting the new element at INDP will
retain VECT's sort order. */
static bool
-find_in_history_vect_1 (VEC(expr_history_def, heap) *vect,
+find_in_history_vect_1 (vec<expr_history_def> vect,
unsigned uid, vinsn_t new_vinsn,
bool compare_vinsns, int *indp)
{
expr_history_def *arr;
- int i, j, len = VEC_length (expr_history_def, vect);
+ int i, j, len = vect.length ();
if (len == 0)
{
@@ -1451,7 +1453,7 @@ find_in_history_vect_1 (VEC(expr_history_def, heap) *vect,
return false;
}
- arr = VEC_address (expr_history_def, vect);
+ arr = vect.address ();
i = 0, j = len - 1;
while (i <= j)
@@ -1483,7 +1485,7 @@ find_in_history_vect_1 (VEC(expr_history_def, heap) *vect,
the position found or -1, if no such value is in vector.
Search also for UIDs of insn's originators, if ORIGINATORS_P is true. */
int
-find_in_history_vect (VEC(expr_history_def, heap) *vect, rtx insn,
+find_in_history_vect (vec<expr_history_def> vect, rtx insn,
vinsn_t new_vinsn, bool originators_p)
{
int ind;
@@ -1510,12 +1512,12 @@ find_in_history_vect (VEC(expr_history_def, heap) *vect, rtx insn,
UID/NEW_EXPR_VINSN pair. TYPE, OLD_EXPR_VINSN and SPEC_DS save
the history of a transformation. */
void
-insert_in_history_vect (VEC (expr_history_def, heap) **pvect,
+insert_in_history_vect (vec<expr_history_def> *pvect,
unsigned uid, enum local_trans_type type,
vinsn_t old_expr_vinsn, vinsn_t new_expr_vinsn,
ds_t spec_ds)
{
- VEC(expr_history_def, heap) *vect = *pvect;
+ vec<expr_history_def> vect = *pvect;
expr_history_def temp;
bool res;
int ind;
@@ -1524,7 +1526,7 @@ insert_in_history_vect (VEC (expr_history_def, heap) **pvect,
if (res)
{
- expr_history_def *phist = &VEC_index (expr_history_def, vect, ind);
+ expr_history_def *phist = &vect[ind];
/* It is possible that speculation types of expressions that were
propagated through different paths will be different here. In this
@@ -1542,42 +1544,39 @@ insert_in_history_vect (VEC (expr_history_def, heap) **pvect,
vinsn_attach (old_expr_vinsn);
vinsn_attach (new_expr_vinsn);
- VEC_safe_insert (expr_history_def, heap, vect, ind, temp);
+ vect.safe_insert (ind, temp);
*pvect = vect;
}
/* Free history vector PVECT. */
static void
-free_history_vect (VEC (expr_history_def, heap) **pvect)
+free_history_vect (vec<expr_history_def> &pvect)
{
unsigned i;
expr_history_def *phist;
- if (! *pvect)
+ if (! pvect.exists ())
return;
- for (i = 0;
- VEC_iterate (expr_history_def, *pvect, i, phist);
- i++)
+ for (i = 0; pvect.iterate (i, &phist); i++)
{
vinsn_detach (phist->old_expr_vinsn);
vinsn_detach (phist->new_expr_vinsn);
}
- VEC_free (expr_history_def, heap, *pvect);
- *pvect = NULL;
+ pvect.release ();
}
/* Merge vector FROM to PVECT. */
static void
-merge_history_vect (VEC (expr_history_def, heap) **pvect,
- VEC (expr_history_def, heap) *from)
+merge_history_vect (vec<expr_history_def> *pvect,
+ vec<expr_history_def> from)
{
expr_history_def *phist;
int i;
/* We keep this vector sorted. */
- for (i = 0; VEC_iterate (expr_history_def, from, i, phist); i++)
+ for (i = 0; from.iterate (i, &phist); i++)
insert_in_history_vect (pvect, phist->uid, phist->type,
phist->old_expr_vinsn, phist->new_expr_vinsn,
phist->spec_ds);
@@ -1619,7 +1618,8 @@ static void
init_expr (expr_t expr, vinsn_t vi, int spec, int use, int priority,
int sched_times, int orig_bb_index, ds_t spec_done_ds,
ds_t spec_to_check_ds, int orig_sched_cycle,
- VEC(expr_history_def, heap) *history, signed char target_available,
+ vec<expr_history_def> history,
+ signed char target_available,
bool was_substituted, bool was_renamed, bool needs_spec_check_p,
bool cant_move)
{
@@ -1636,10 +1636,10 @@ init_expr (expr_t expr, vinsn_t vi, int spec, int use, int priority,
EXPR_SPEC_DONE_DS (expr) = spec_done_ds;
EXPR_SPEC_TO_CHECK_DS (expr) = spec_to_check_ds;
- if (history)
+ if (history.exists ())
EXPR_HISTORY_OF_CHANGES (expr) = history;
else
- EXPR_HISTORY_OF_CHANGES (expr) = NULL;
+ EXPR_HISTORY_OF_CHANGES (expr).create (0);
EXPR_TARGET_AVAILABLE (expr) = target_available;
EXPR_WAS_SUBSTITUTED (expr) = was_substituted;
@@ -1652,16 +1652,16 @@ init_expr (expr_t expr, vinsn_t vi, int spec, int use, int priority,
void
copy_expr (expr_t to, expr_t from)
{
- VEC(expr_history_def, heap) *temp = NULL;
+ vec<expr_history_def> temp = vec<expr_history_def>();
- if (EXPR_HISTORY_OF_CHANGES (from))
+ if (EXPR_HISTORY_OF_CHANGES (from).exists ())
{
unsigned i;
expr_history_def *phist;
- temp = VEC_copy (expr_history_def, heap, EXPR_HISTORY_OF_CHANGES (from));
+ temp = EXPR_HISTORY_OF_CHANGES (from).copy ();
for (i = 0;
- VEC_iterate (expr_history_def, temp, i, phist);
+ temp.iterate (i, &phist);
i++)
{
vinsn_attach (phist->old_expr_vinsn);
@@ -1686,7 +1686,8 @@ copy_expr_onside (expr_t to, expr_t from)
{
init_expr (to, EXPR_VINSN (from), EXPR_SPEC (from), EXPR_USEFULNESS (from),
EXPR_PRIORITY (from), EXPR_SCHED_TIMES (from), 0,
- EXPR_SPEC_DONE_DS (from), EXPR_SPEC_TO_CHECK_DS (from), 0, NULL,
+ EXPR_SPEC_DONE_DS (from), EXPR_SPEC_TO_CHECK_DS (from), 0,
+ vec<expr_history_def>(),
EXPR_TARGET_AVAILABLE (from), EXPR_WAS_SUBSTITUTED (from),
EXPR_WAS_RENAMED (from), EXPR_NEEDS_SPEC_CHECK_P (from),
EXPR_CANT_MOVE (from));
@@ -1718,7 +1719,7 @@ prepare_insn_expr (insn_t insn, int seqno)
if (ds)
EXPR_SPEC_DONE_DS (expr) = ds_get_max_dep_weak (ds);
- free_history_vect (&EXPR_HISTORY_OF_CHANGES (expr));
+ free_history_vect (EXPR_HISTORY_OF_CHANGES (expr));
}
/* Update target_available bits when merging exprs TO and FROM. SPLIT_POINT
@@ -1882,7 +1883,7 @@ clear_expr (expr_t expr)
vinsn_detach (EXPR_VINSN (expr));
EXPR_VINSN (expr) = NULL;
- free_history_vect (&EXPR_HISTORY_OF_CHANGES (expr));
+ free_history_vect (EXPR_HISTORY_OF_CHANGES (expr));
}
/* For a given LV_SET, mark EXPR having unavailable target register. */
@@ -2781,14 +2782,14 @@ sched_scan (const struct sched_scan_info_def *ssi, bb_vec_t bbs)
ssi->extend_bb ();
if (ssi->init_bb)
- FOR_EACH_VEC_ELT (basic_block, bbs, i, bb)
+ FOR_EACH_VEC_ELT (bbs, i, bb)
ssi->init_bb (bb);
if (ssi->extend_insn)
ssi->extend_insn ();
if (ssi->init_insn)
- FOR_EACH_VEC_ELT (basic_block, bbs, i, bb)
+ FOR_EACH_VEC_ELT (bbs, i, bb)
{
rtx insn;
@@ -3003,8 +3004,8 @@ init_global_and_expr_for_insn (insn_t insn)
/* Initialize INSN's expr. */
init_expr (INSN_EXPR (insn), vinsn_create (insn, force_unique_p), 0,
REG_BR_PROB_BASE, INSN_PRIORITY (insn), 0, BLOCK_NUM (insn),
- spec_done_ds, 0, 0, NULL, true, false, false, false,
- CANT_MOVE (insn));
+ spec_done_ds, 0, 0, vec<expr_history_def>(), true,
+ false, false, false, CANT_MOVE (insn));
}
init_first_time_insn_data (insn);
@@ -3065,10 +3066,10 @@ sel_finish_global_and_expr (void)
bb_vec_t bbs;
int i;
- bbs = VEC_alloc (basic_block, heap, current_nr_blocks);
+ bbs.create (current_nr_blocks);
for (i = 0; i < current_nr_blocks; i++)
- VEC_quick_push (basic_block, bbs, BASIC_BLOCK (BB_TO_BLOCK (i)));
+ bbs.quick_push (BASIC_BLOCK (BB_TO_BLOCK (i)));
/* Clear AV_SETs and INSN_EXPRs. */
{
@@ -3083,7 +3084,7 @@ sel_finish_global_and_expr (void)
sched_scan (&ssi, bbs);
}
- VEC_free (basic_block, heap, bbs);
+ bbs.release ();
}
finish_insns ();
@@ -3563,7 +3564,7 @@ insn_sid (insn_t insn)
bool
sel_insn_is_speculation_check (rtx insn)
{
- return s_i_d && !! INSN_SPEC_CHECKED_DS (insn);
+ return s_i_d.exists () && !! INSN_SPEC_CHECKED_DS (insn);
}
/* Extracts machine mode MODE and destination location DST_LOC
@@ -3665,7 +3666,7 @@ static bool
maybe_tidy_empty_bb (basic_block bb)
{
basic_block succ_bb, pred_bb, note_bb;
- VEC (basic_block, heap) *dom_bbs;
+ vec<basic_block> dom_bbs;
edge e;
edge_iterator ei;
bool rescan_p;
@@ -3717,7 +3718,7 @@ maybe_tidy_empty_bb (basic_block bb)
succ_bb = single_succ (bb);
rescan_p = true;
pred_bb = NULL;
- dom_bbs = NULL;
+ dom_bbs.create (0);
/* Save a pred/succ from the current region to attach the notes to. */
note_bb = NULL;
@@ -3749,7 +3750,7 @@ maybe_tidy_empty_bb (basic_block bb)
sel_redirect_edge_and_branch will take care of it. */
if (e->dest != bb
&& single_pred_p (e->dest))
- VEC_safe_push (basic_block, heap, dom_bbs, e->dest);
+ dom_bbs.safe_push (e->dest);
sel_redirect_edge_and_branch (e, succ_bb);
rescan_p = true;
break;
@@ -3784,11 +3785,11 @@ maybe_tidy_empty_bb (basic_block bb)
remove_empty_bb (bb, true);
}
- if (!VEC_empty (basic_block, dom_bbs))
+ if (!dom_bbs.is_empty ())
{
- VEC_safe_push (basic_block, heap, dom_bbs, succ_bb);
+ dom_bbs.safe_push (succ_bb);
iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
- VEC_free (basic_block, heap, dom_bbs);
+ dom_bbs.release ();
}
return true;
@@ -4100,16 +4101,14 @@ get_seqno_by_preds (rtx insn)
void
sel_extend_global_bb_info (void)
{
- VEC_safe_grow_cleared (sel_global_bb_info_def, heap, sel_global_bb_info,
- last_basic_block);
+ sel_global_bb_info.safe_grow_cleared (last_basic_block);
}
/* Extend region-scope data structures for basic blocks. */
static void
extend_region_bb_info (void)
{
- VEC_safe_grow_cleared (sel_region_bb_info_def, heap, sel_region_bb_info,
- last_basic_block);
+ sel_region_bb_info.safe_grow_cleared (last_basic_block);
}
/* Extend all data structures to fit for all basic blocks. */
@@ -4124,19 +4123,19 @@ extend_bb_info (void)
void
sel_finish_global_bb_info (void)
{
- VEC_free (sel_global_bb_info_def, heap, sel_global_bb_info);
+ sel_global_bb_info.release ();
}
/* Finalize region-scope data structures for basic blocks. */
static void
finish_region_bb_info (void)
{
- VEC_free (sel_region_bb_info_def, heap, sel_region_bb_info);
+ sel_region_bb_info.release ();
}
/* Data for each insn in current region. */
-VEC (sel_insn_data_def, heap) *s_i_d = NULL;
+vec<sel_insn_data_def> s_i_d = vec<sel_insn_data_def>();
/* Extend data structures for insns from current region. */
static void
@@ -4148,10 +4147,8 @@ extend_insn_data (void)
sched_deps_init (false);
/* Extend data structures for insns from current region. */
- reserve = (sched_max_luid + 1
- - VEC_length (sel_insn_data_def, s_i_d));
- if (reserve > 0
- && ! VEC_space (sel_insn_data_def, s_i_d, reserve))
+ reserve = (sched_max_luid + 1 - s_i_d.length ());
+ if (reserve > 0 && ! s_i_d.space (reserve))
{
int size;
@@ -4161,7 +4158,7 @@ extend_insn_data (void)
size = 3 * sched_max_luid / 2;
- VEC_safe_grow_cleared (sel_insn_data_def, heap, s_i_d, size);
+ s_i_d.safe_grow_cleared (size);
}
}
@@ -4173,9 +4170,9 @@ finish_insns (void)
/* Clear here all dependence contexts that may have left from insns that were
removed during the scheduling. */
- for (i = 0; i < VEC_length (sel_insn_data_def, s_i_d); i++)
+ for (i = 0; i < s_i_d.length (); i++)
{
- sel_insn_data_def *sid_entry = &VEC_index (sel_insn_data_def, s_i_d, i);
+ sel_insn_data_def *sid_entry = &s_i_d[i];
if (sid_entry->live)
return_regset_to_pool (sid_entry->live);
@@ -4196,7 +4193,7 @@ finish_insns (void)
}
}
- VEC_free (sel_insn_data_def, heap, s_i_d);
+ s_i_d.release ();
}
/* A proxy to pass initialization data to init_insn (). */
@@ -4255,7 +4252,8 @@ static void
init_simplejump_data (insn_t insn)
{
init_expr (INSN_EXPR (insn), vinsn_create (insn, false), 0,
- REG_BR_PROB_BASE, 0, 0, 0, 0, 0, 0, NULL, true, false, false,
+ REG_BR_PROB_BASE, 0, 0, 0, 0, 0, 0,
+ vec<expr_history_def>(), true, false, false,
false, true);
INSN_SEQNO (insn) = get_seqno_for_a_jump (insn);
init_first_time_insn_data (insn);
@@ -4505,7 +4503,8 @@ get_av_level (insn_t insn)
/* The basic block that already has been processed by the sched_data_update (),
but hasn't been in sel_add_bb () yet. */
-static VEC (basic_block, heap) *last_added_blocks = NULL;
+static vec<basic_block>
+ last_added_blocks = vec<basic_block>();
/* A pool for allocating successor infos. */
static struct
@@ -4707,9 +4706,9 @@ alloc_succs_info (void)
gcc_unreachable ();
i = ++succs_info_pool.top;
- succs_info_pool.stack[i].succs_ok = VEC_alloc (rtx, heap, 10);
- succs_info_pool.stack[i].succs_other = VEC_alloc (rtx, heap, 10);
- succs_info_pool.stack[i].probs_ok = VEC_alloc (int, heap, 10);
+ succs_info_pool.stack[i].succs_ok.create (10);
+ succs_info_pool.stack[i].succs_other.create (10);
+ succs_info_pool.stack[i].probs_ok.create (10);
}
else
succs_info_pool.top++;
@@ -4726,12 +4725,9 @@ free_succs_info (struct succs_info * sinfo)
succs_info_pool.top--;
/* Clear stale info. */
- VEC_block_remove (rtx, sinfo->succs_ok,
- 0, VEC_length (rtx, sinfo->succs_ok));
- VEC_block_remove (rtx, sinfo->succs_other,
- 0, VEC_length (rtx, sinfo->succs_other));
- VEC_block_remove (int, sinfo->probs_ok,
- 0, VEC_length (int, sinfo->probs_ok));
+ sinfo->succs_ok.block_remove (0, sinfo->succs_ok.length ());
+ sinfo->succs_other.block_remove (0, sinfo->succs_other.length ());
+ sinfo->probs_ok.block_remove (0, sinfo->probs_ok.length ());
sinfo->all_prob = 0;
sinfo->succs_ok_n = 0;
sinfo->all_succs_n = 0;
@@ -4755,17 +4751,15 @@ compute_succs_info (insn_t insn, short flags)
if (current_flags & flags)
{
- VEC_safe_push (rtx, heap, sinfo->succs_ok, succ);
- VEC_safe_push (int, heap, sinfo->probs_ok,
- /* FIXME: Improve calculation when skipping
- inner loop to exits. */
- (si.bb_end
- ? si.e1->probability
- : REG_BR_PROB_BASE));
+ sinfo->succs_ok.safe_push (succ);
+ sinfo->probs_ok.safe_push (
+ /* FIXME: Improve calculation when skipping
+ inner loop to exits. */
+ si.bb_end ? si.e1->probability : REG_BR_PROB_BASE);
sinfo->succs_ok_n++;
}
else
- VEC_safe_push (rtx, heap, sinfo->succs_other, succ);
+ sinfo->succs_other.safe_push (succ);
/* Compute all_prob. */
if (!si.bb_end)
@@ -4972,18 +4966,18 @@ return_bb_to_pool (basic_block bb)
/* It turns out that current cfg infrastructure does not support
reuse of basic blocks. Don't bother for now. */
- /*VEC_safe_push (rtx, heap, bb_note_pool, note);*/
+ /*bb_note_pool.safe_push (note);*/
}
/* Get a bb_note from pool or return NULL_RTX if pool is empty. */
static rtx
get_bb_note_from_pool (void)
{
- if (VEC_empty (rtx, bb_note_pool))
+ if (bb_note_pool.is_empty ())
return NULL_RTX;
else
{
- rtx note = VEC_pop (rtx, bb_note_pool);
+ rtx note = bb_note_pool.pop ();
PREV_INSN (note) = NULL_RTX;
NEXT_INSN (note) = NULL_RTX;
@@ -4996,7 +4990,7 @@ get_bb_note_from_pool (void)
void
free_bb_note_pool (void)
{
- VEC_free (rtx, heap, bb_note_pool);
+ bb_note_pool.release ();
}
/* Setup scheduler pool and successor structure. */
@@ -5025,9 +5019,9 @@ free_sched_pools (void)
gcc_assert (succs_info_pool.top == -1);
for (i = 0; i < succs_info_pool.max_top; i++)
{
- VEC_free (rtx, heap, succs_info_pool.stack[i].succs_ok);
- VEC_free (rtx, heap, succs_info_pool.stack[i].succs_other);
- VEC_free (int, heap, succs_info_pool.stack[i].probs_ok);
+ succs_info_pool.stack[i].succs_ok.release ();
+ succs_info_pool.stack[i].succs_other.release ();
+ succs_info_pool.stack[i].probs_ok.release ();
}
free (succs_info_pool.stack);
}
@@ -5194,13 +5188,12 @@ sel_add_bb (basic_block bb)
/* When bb is passed explicitly, the vector should contain
the only element that equals to bb; otherwise, the vector
should not be NULL. */
- gcc_assert (last_added_blocks != NULL);
+ gcc_assert (last_added_blocks.exists ());
if (bb != NULL)
{
- gcc_assert (VEC_length (basic_block, last_added_blocks) == 1
- && VEC_index (basic_block,
- last_added_blocks, 0) == bb);
+ gcc_assert (last_added_blocks.length () == 1
+ && last_added_blocks[0] == bb);
add_block_to_current_region (bb);
/* We associate creating/deleting data sets with the first insn
@@ -5208,7 +5201,7 @@ sel_add_bb (basic_block bb)
if (!sel_bb_empty_p (bb) && BB_LV_SET (bb) == NULL)
create_initial_data_sets (bb);
- VEC_free (basic_block, heap, last_added_blocks);
+ last_added_blocks.release ();
}
else
/* BB is NULL - process LAST_ADDED_BLOCKS instead. */
@@ -5217,7 +5210,7 @@ sel_add_bb (basic_block bb)
basic_block temp_bb = NULL;
for (i = 0;
- VEC_iterate (basic_block, last_added_blocks, i, bb); i++)
+ last_added_blocks.iterate (i, &bb); i++)
{
add_block_to_current_region (bb);
temp_bb = bb;
@@ -5228,7 +5221,7 @@ sel_add_bb (basic_block bb)
gcc_assert (temp_bb != NULL);
bb = temp_bb;
- VEC_free (basic_block, heap, last_added_blocks);
+ last_added_blocks.release ();
}
rgn_setup_region (CONTAINING_RGN (bb->index));
@@ -5345,7 +5338,7 @@ sel_create_basic_block (void *headp, void *endp, basic_block after)
insn_t new_bb_note;
gcc_assert (flag_sel_sched_pipelining_outer_loops
- || last_added_blocks == NULL);
+ || !last_added_blocks.exists ());
new_bb_note = get_bb_note_from_pool ();
@@ -5358,7 +5351,7 @@ sel_create_basic_block (void *headp, void *endp, basic_block after)
new_bb->aux = NULL;
}
- VEC_safe_push (basic_block, heap, last_added_blocks, new_bb);
+ last_added_blocks.safe_push (new_bb);
return new_bb;
}
@@ -5489,7 +5482,7 @@ sel_split_edge (edge e)
/* Some of the basic blocks might not have been added to the loop.
Add them here, until this is fixed in force_fallthru. */
for (i = 0;
- VEC_iterate (basic_block, last_added_blocks, i, bb); i++)
+ last_added_blocks.iterate (i, &bb); i++)
if (!bb->loop_father)
{
add_bb_to_loop (bb, e->dest->loop_father);
@@ -5523,10 +5516,10 @@ sel_create_empty_bb (basic_block after)
/* We'll explicitly initialize NEW_BB via sel_init_only_bb () a bit
later. */
- gcc_assert (VEC_length (basic_block, last_added_blocks) == 1
- && VEC_index (basic_block, last_added_blocks, 0) == new_bb);
+ gcc_assert (last_added_blocks.length () == 1
+ && last_added_blocks[0] == new_bb);
- VEC_free (basic_block, heap, last_added_blocks);
+ last_added_blocks.release ();
return new_bb;
}
@@ -5640,7 +5633,7 @@ sel_redirect_edge_and_branch (edge e, basic_block to)
redirected = redirect_edge_and_branch (e, to);
- gcc_assert (redirected && last_added_blocks == NULL);
+ gcc_assert (redirected && !last_added_blocks.exists ());
/* When we've redirected a latch edge, update the header. */
if (latch_edge_p)
@@ -6034,7 +6027,7 @@ make_region_from_loop (struct loop *loop)
/* Create a new region from preheader blocks LOOP_BLOCKS. */
void
-make_region_from_loop_preheader (VEC(basic_block, heap) **loop_blocks)
+make_region_from_loop_preheader (vec<basic_block> *&loop_blocks)
{
unsigned int i;
int new_rgn_number = -1;
@@ -6045,15 +6038,14 @@ make_region_from_loop_preheader (VEC(basic_block, heap) **loop_blocks)
new_rgn_number = sel_create_new_region ();
- FOR_EACH_VEC_ELT (basic_block, *loop_blocks, i, bb)
+ FOR_EACH_VEC_ELT (*loop_blocks, i, bb)
{
gcc_assert (new_rgn_number >= 0);
sel_add_block_to_region (bb, &bb_ord_index, new_rgn_number);
}
- VEC_free (basic_block, heap, *loop_blocks);
- gcc_assert (*loop_blocks == NULL);
+ vec_free (loop_blocks);
}
@@ -6078,7 +6070,7 @@ make_regions_from_loop_nest (struct loop *loop)
if (rgn_number < 0)
return false;
- VEC_safe_push (loop_p, heap, loop_nests, loop);
+ loop_nests.safe_push (loop);
return true;
}
@@ -6105,8 +6097,8 @@ get_loop_nest_for_rgn (unsigned int rgn)
{
/* Regions created with extend_rgns don't have corresponding loop nests,
because they don't represent loops. */
- if (rgn < VEC_length (loop_p, loop_nests))
- return VEC_index (loop_p, loop_nests, rgn);
+ if (rgn < loop_nests.length ())
+ return loop_nests[rgn];
else
return NULL;
}
@@ -6128,7 +6120,7 @@ considered_for_pipelining_p (struct loop *loop)
{
int rgn = CONTAINING_RGN (loop->latch->index);
- gcc_assert ((unsigned) rgn < VEC_length (loop_p, loop_nests));
+ gcc_assert ((unsigned) rgn < loop_nests.length ());
return true;
}
@@ -6224,7 +6216,7 @@ void sel_finish_pipelining (void)
loop_optimizer_finalize ();
- VEC_free (loop_p, heap, loop_nests);
+ loop_nests.release ();
free (rev_top_order_index);
rev_top_order_index = NULL;
@@ -6267,19 +6259,20 @@ sel_add_loop_preheaders (bb_vec_t *bbs)
{
int i;
basic_block bb;
- VEC(basic_block, heap) *preheader_blocks
+ vec<basic_block> *preheader_blocks
= LOOP_PREHEADER_BLOCKS (current_loop_nest);
- for (i = 0;
- VEC_iterate (basic_block, preheader_blocks, i, bb);
- i++)
+ if (!preheader_blocks)
+ return;
+
+ for (i = 0; preheader_blocks->iterate (i, &bb); i++)
{
- VEC_safe_push (basic_block, heap, *bbs, bb);
- VEC_safe_push (basic_block, heap, last_added_blocks, bb);
+ bbs->safe_push (bb);
+ last_added_blocks.safe_push (bb);
sel_add_bb (bb);
}
- VEC_free (basic_block, heap, preheader_blocks);
+ vec_free (preheader_blocks);
}
/* While pipelining outer loops, returns TRUE if BB is a loop preheader.
@@ -6350,11 +6343,13 @@ sel_remove_loop_preheader (void)
int cur_rgn = CONTAINING_RGN (BB_TO_BLOCK (0));
basic_block bb;
bool all_empty_p = true;
- VEC(basic_block, heap) *preheader_blocks
+ vec<basic_block> *preheader_blocks
= LOOP_PREHEADER_BLOCKS (loop_outer (current_loop_nest));
+ vec_check_alloc (preheader_blocks, 0);
+
gcc_assert (current_loop_nest);
- old_len = VEC_length (basic_block, preheader_blocks);
+ old_len = preheader_blocks->length ();
/* Add blocks that aren't within the current loop to PREHEADER_BLOCKS. */
for (i = 0; i < RGN_NR_BLOCKS (cur_rgn); i++)
@@ -6365,18 +6360,16 @@ sel_remove_loop_preheader (void)
corresponding loop, then it should be a preheader. */
if (sel_is_loop_preheader_p (bb))
{
- VEC_safe_push (basic_block, heap, preheader_blocks, bb);
+ preheader_blocks->safe_push (bb);
if (BB_END (bb) != bb_note (bb))
all_empty_p = false;
}
}
/* Remove these blocks only after iterating over the whole region. */
- for (i = VEC_length (basic_block, preheader_blocks) - 1;
- i >= old_len;
- i--)
+ for (i = preheader_blocks->length () - 1; i >= old_len; i--)
{
- bb = VEC_index (basic_block, preheader_blocks, i);
+ bb = (*preheader_blocks)[i];
sel_remove_bb (bb, false);
}
@@ -6384,12 +6377,12 @@ sel_remove_loop_preheader (void)
{
if (!all_empty_p)
/* Immediately create new region from preheader. */
- make_region_from_loop_preheader (&preheader_blocks);
+ make_region_from_loop_preheader (preheader_blocks);
else
{
/* If all preheader blocks are empty - dont create new empty region.
Instead, remove them completely. */
- FOR_EACH_VEC_ELT (basic_block, preheader_blocks, i, bb)
+ FOR_EACH_VEC_ELT (*preheader_blocks, i, bb)
{
edge e;
edge_iterator ei;
@@ -6424,7 +6417,7 @@ sel_remove_loop_preheader (void)
next_bb));
}
}
- VEC_free (basic_block, heap, preheader_blocks);
+ vec_free (preheader_blocks);
}
else
/* Store preheader within the father's loop structure. */