diff options
author | Diego Novillo <dnovillo@google.com> | 2012-11-17 21:54:30 -0500 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2012-11-17 21:54:30 -0500 |
commit | 9771b26396c39dfaecd5a76dd359fb65d3be4cb6 (patch) | |
tree | 1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/tree-predcom.c | |
parent | 0f4119158064e271e48a14ce3f88a67e7baf14e0 (diff) | |
download | gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.zip gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.tar.gz gcc-9771b26396c39dfaecd5a76dd359fb65d3be4cb6.tar.bz2 |
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
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.
From-SVN: r193595
Diffstat (limited to 'gcc/tree-predcom.c')
-rw-r--r-- | gcc/tree-predcom.c | 268 |
1 files changed, 132 insertions, 136 deletions
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index ba61c5b..b1dce08 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -239,8 +239,6 @@ typedef struct dref_d unsigned always_accessed : 1; } *dref; -DEF_VEC_P (dref); -DEF_VEC_ALLOC_P (dref, heap); /* Type of the chain of the references. */ @@ -273,16 +271,16 @@ typedef struct chain struct chain *ch1, *ch2; /* The references in the chain. */ - VEC(dref,heap) *refs; + vec<dref> refs; /* The maximum distance of the reference in the chain from the root. */ unsigned length; /* The variables used to copy the value throughout iterations. */ - VEC(tree,heap) *vars; + vec<tree> vars; /* Initializers for the variables. */ - VEC(tree,heap) *inits; + vec<tree> inits; /* True if there is a use of a variable with the maximal distance that comes after the root in the loop. */ @@ -295,8 +293,6 @@ typedef struct chain unsigned combined : 1; } *chain_p; -DEF_VEC_P (chain_p); -DEF_VEC_ALLOC_P (chain_p, heap); /* Describes the knowledge about the step of the memory references in the component. */ @@ -318,7 +314,7 @@ enum ref_step_type struct component { /* The references in the component. */ - VEC(dref,heap) *refs; + vec<dref> refs; /* What we know about the step of the references in the component. */ enum ref_step_type comp_step; @@ -416,10 +412,10 @@ dump_chain (FILE *file, chain_p chain) fprintf (file, "\n"); } - if (chain->vars) + if (chain->vars.exists ()) { fprintf (file, " vars"); - FOR_EACH_VEC_ELT (tree, chain->vars, i, var) + FOR_EACH_VEC_ELT (chain->vars, i, var) { fprintf (file, " "); print_generic_expr (file, var, TDF_SLIM); @@ -427,10 +423,10 @@ dump_chain (FILE *file, chain_p chain) fprintf (file, "\n"); } - if (chain->inits) + if (chain->inits.exists ()) { fprintf (file, " inits"); - FOR_EACH_VEC_ELT (tree, chain->inits, i, var) + FOR_EACH_VEC_ELT (chain->inits, i, var) { fprintf (file, " "); print_generic_expr (file, var, TDF_SLIM); @@ -439,7 +435,7 @@ dump_chain (FILE *file, chain_p chain) } fprintf (file, " references:\n"); - FOR_EACH_VEC_ELT (dref, chain->refs, i, a) + FOR_EACH_VEC_ELT (chain->refs, i, a) dump_dref (file, a); fprintf (file, "\n"); @@ -447,14 +443,14 @@ dump_chain (FILE *file, chain_p chain) /* Dumps CHAINS to FILE. */ -extern void dump_chains (FILE *, VEC (chain_p, heap) *); +extern void dump_chains (FILE *, vec<chain_p> ); void -dump_chains (FILE *file, VEC (chain_p, heap) *chains) +dump_chains (FILE *file, vec<chain_p> chains) { chain_p chain; unsigned i; - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) + FOR_EACH_VEC_ELT (chains, i, chain) dump_chain (file, chain); } @@ -469,7 +465,7 @@ dump_component (FILE *file, struct component *comp) fprintf (file, "Component%s:\n", comp->comp_step == RS_INVARIANT ? " (invariant)" : ""); - FOR_EACH_VEC_ELT (dref, comp->refs, i, a) + FOR_EACH_VEC_ELT (comp->refs, i, a) dump_dref (file, a); fprintf (file, "\n"); } @@ -497,12 +493,12 @@ release_chain (chain_p chain) if (chain == NULL) return; - FOR_EACH_VEC_ELT (dref, chain->refs, i, ref) + FOR_EACH_VEC_ELT (chain->refs, i, ref) free (ref); - VEC_free (dref, heap, chain->refs); - VEC_free (tree, heap, chain->vars); - VEC_free (tree, heap, chain->inits); + chain->refs.release (); + chain->vars.release (); + chain->inits.release (); free (chain); } @@ -510,14 +506,14 @@ release_chain (chain_p chain) /* Frees CHAINS. */ static void -release_chains (VEC (chain_p, heap) *chains) +release_chains (vec<chain_p> chains) { unsigned i; chain_p chain; - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) + FOR_EACH_VEC_ELT (chains, i, chain) release_chain (chain); - VEC_free (chain_p, heap, chains); + chains.release (); } /* Frees a component COMP. */ @@ -525,7 +521,7 @@ release_chains (VEC (chain_p, heap) *chains) static void release_component (struct component *comp) { - VEC_free (dref, heap, comp->refs); + comp->refs.release (); free (comp); } @@ -679,13 +675,13 @@ static basic_block last_always_executed_block (struct loop *loop) { unsigned i; - VEC (edge, heap) *exits = get_loop_exit_edges (loop); + vec<edge> exits = get_loop_exit_edges (loop); edge ex; basic_block last = loop->latch; - FOR_EACH_VEC_ELT (edge, exits, i, ex) + FOR_EACH_VEC_ELT (exits, i, ex) last = nearest_common_dominator (CDI_DOMINATORS, last, ex->src); - VEC_free (edge, heap, exits); + exits.release (); return last; } @@ -694,10 +690,10 @@ last_always_executed_block (struct loop *loop) static struct component * split_data_refs_to_components (struct loop *loop, - VEC (data_reference_p, heap) *datarefs, - VEC (ddr_p, heap) *depends) + vec<data_reference_p> datarefs, + vec<ddr_p> depends) { - unsigned i, n = VEC_length (data_reference_p, datarefs); + unsigned i, n = datarefs.length (); unsigned ca, ia, ib, bad; unsigned *comp_father = XNEWVEC (unsigned, n + 1); unsigned *comp_size = XNEWVEC (unsigned, n + 1); @@ -708,7 +704,7 @@ split_data_refs_to_components (struct loop *loop, dref dataref; basic_block last_always_executed = last_always_executed_block (loop); - FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr) + FOR_EACH_VEC_ELT (datarefs, i, dr) { if (!DR_REF (dr)) { @@ -725,7 +721,7 @@ split_data_refs_to_components (struct loop *loop, comp_father[n] = n; comp_size[n] = 1; - FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr) + FOR_EACH_VEC_ELT (datarefs, i, dr) { enum ref_step_type dummy; @@ -736,7 +732,7 @@ split_data_refs_to_components (struct loop *loop, } } - FOR_EACH_VEC_ELT (ddr_p, depends, i, ddr) + FOR_EACH_VEC_ELT (depends, i, ddr) { double_int dummy_off; @@ -763,7 +759,7 @@ split_data_refs_to_components (struct loop *loop, comps = XCNEWVEC (struct component *, n); bad = component_of (comp_father, n); - FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr) + FOR_EACH_VEC_ELT (datarefs, i, dr) { ia = (unsigned) (size_t) dr->aux; ca = component_of (comp_father, ia); @@ -774,7 +770,7 @@ split_data_refs_to_components (struct loop *loop, if (!comp) { comp = XCNEW (struct component); - comp->refs = VEC_alloc (dref, heap, comp_size[ca]); + comp->refs.create (comp_size[ca]); comps[ca] = comp; } @@ -787,8 +783,8 @@ split_data_refs_to_components (struct loop *loop, dataref->always_accessed = dominated_by_p (CDI_DOMINATORS, last_always_executed, gimple_bb (dataref->stmt)); - dataref->pos = VEC_length (dref, comp->refs); - VEC_quick_push (dref, comp->refs, dataref); + dataref->pos = comp->refs.length (); + comp->refs.quick_push (dataref); } for (i = 0; i < n; i++) @@ -820,7 +816,7 @@ suitable_component_p (struct loop *loop, struct component *comp) basic_block ba, bp = loop->header; bool ok, has_write = false; - FOR_EACH_VEC_ELT (dref, comp->refs, i, a) + FOR_EACH_VEC_ELT (comp->refs, i, a) { ba = gimple_bb (a->stmt); @@ -834,12 +830,12 @@ suitable_component_p (struct loop *loop, struct component *comp) has_write = true; } - first = VEC_index (dref, comp->refs, 0); + first = comp->refs[0]; ok = suitable_reference_p (first->ref, &comp->comp_step); gcc_assert (ok); first->offset = double_int_zero; - for (i = 1; VEC_iterate (dref, comp->refs, i, a); i++) + for (i = 1; comp->refs.iterate (i, &a); i++) { if (!determine_offset (first->ref, a->ref, &a->offset)) return false; @@ -884,7 +880,7 @@ filter_suitable_components (struct loop *loop, struct component *comps) unsigned i; *comp = act->next; - FOR_EACH_VEC_ELT (dref, act->refs, i, ref) + FOR_EACH_VEC_ELT (act->refs, i, ref) free (ref); release_component (act); } @@ -914,7 +910,7 @@ order_drefs (const void *a, const void *b) static inline dref get_chain_root (chain_p chain) { - return VEC_index (dref, chain->refs, 0); + return chain->refs[0]; } /* Adds REF to the chain CHAIN. */ @@ -934,7 +930,7 @@ add_ref_to_chain (chain_p chain, dref ref) } gcc_assert (dist.fits_uhwi ()); - VEC_safe_push (dref, heap, chain->refs, ref); + chain->refs.safe_push (ref); ref->distance = dist.to_uhwi (); @@ -964,9 +960,9 @@ make_invariant_chain (struct component *comp) chain->all_always_accessed = true; - FOR_EACH_VEC_ELT (dref, comp->refs, i, ref) + FOR_EACH_VEC_ELT (comp->refs, i, ref) { - VEC_safe_push (dref, heap, chain->refs, ref); + chain->refs.safe_push (ref); chain->all_always_accessed &= ref->always_accessed; } @@ -982,7 +978,7 @@ make_rooted_chain (dref ref) chain->type = DR_IS_READ (ref->ref) ? CT_LOAD : CT_STORE_LOAD; - VEC_safe_push (dref, heap, chain->refs, ref); + chain->refs.safe_push (ref); chain->all_always_accessed = ref->always_accessed; ref->distance = 0; @@ -995,7 +991,7 @@ make_rooted_chain (dref ref) static bool nontrivial_chain_p (chain_p chain) { - return chain != NULL && VEC_length (dref, chain->refs) > 1; + return chain != NULL && chain->refs.length () > 1; } /* Returns the ssa name that contains the value of REF, or NULL_TREE if there @@ -1136,10 +1132,10 @@ insert_looparound_copy (chain_p chain, dref ref, gimple phi) nw->distance = ref->distance + 1; nw->always_accessed = 1; - FOR_EACH_VEC_ELT (dref, chain->refs, i, aref) + FOR_EACH_VEC_ELT (chain->refs, i, aref) if (aref->distance >= nw->distance) break; - VEC_safe_insert (dref, heap, chain->refs, i, nw); + chain->refs.safe_insert (i, nw); if (nw->distance > chain->length) { @@ -1160,7 +1156,7 @@ add_looparound_copies (struct loop *loop, chain_p chain) dref ref, root = get_chain_root (chain); gimple phi; - FOR_EACH_VEC_ELT (dref, chain->refs, i, ref) + FOR_EACH_VEC_ELT (chain->refs, i, ref) { phi = find_looparound_phi (loop, ref, root); if (!phi) @@ -1178,7 +1174,7 @@ add_looparound_copies (struct loop *loop, chain_p chain) static void determine_roots_comp (struct loop *loop, struct component *comp, - VEC (chain_p, heap) **chains) + vec<chain_p> *chains) { unsigned i; dref a; @@ -1189,13 +1185,13 @@ determine_roots_comp (struct loop *loop, if (comp->comp_step == RS_INVARIANT) { chain = make_invariant_chain (comp); - VEC_safe_push (chain_p, heap, *chains, chain); + chains->safe_push (chain); return; } - VEC_qsort (dref, comp->refs, order_drefs); + comp->refs.qsort (order_drefs); - FOR_EACH_VEC_ELT (dref, comp->refs, i, a) + FOR_EACH_VEC_ELT (comp->refs, i, a) { if (!chain || DR_IS_WRITE (a->ref) || double_int::from_uhwi (MAX_DISTANCE).ule (a->offset - last_ofs)) @@ -1203,7 +1199,7 @@ determine_roots_comp (struct loop *loop, if (nontrivial_chain_p (chain)) { add_looparound_copies (loop, chain); - VEC_safe_push (chain_p, heap, *chains, chain); + chains->safe_push (chain); } else release_chain (chain); @@ -1218,7 +1214,7 @@ determine_roots_comp (struct loop *loop, if (nontrivial_chain_p (chain)) { add_looparound_copies (loop, chain); - VEC_safe_push (chain_p, heap, *chains, chain); + chains->safe_push (chain); } else release_chain (chain); @@ -1229,7 +1225,7 @@ determine_roots_comp (struct loop *loop, static void determine_roots (struct loop *loop, - struct component *comps, VEC (chain_p, heap) **chains) + struct component *comps, vec<chain_p> *chains) { struct component *comp; @@ -1428,7 +1424,7 @@ get_init_expr (chain_p chain, unsigned index) return fold_build2 (chain->op, chain->rslt_type, e1, e2); } else - return VEC_index (tree, chain->inits, index); + return chain->inits[index]; } /* Returns a new temporary variable used for the I-th variable carrying @@ -1465,7 +1461,7 @@ initialize_root_vars (struct loop *loop, chain_p chain, bitmap tmp_vars) since this is an nonempty chain, reuse_first cannot be true. */ gcc_assert (n > 0 || !reuse_first); - chain->vars = VEC_alloc (tree, heap, n + 1); + chain->vars.create (n + 1); if (chain->type == CT_COMBINATION) ref = gimple_assign_lhs (root->stmt); @@ -1475,18 +1471,18 @@ initialize_root_vars (struct loop *loop, chain_p chain, bitmap tmp_vars) for (i = 0; i < n + (reuse_first ? 0 : 1); i++) { var = predcom_tmp_var (ref, i, tmp_vars); - VEC_quick_push (tree, chain->vars, var); + chain->vars.quick_push (var); } if (reuse_first) - VEC_quick_push (tree, chain->vars, VEC_index (tree, chain->vars, 0)); + chain->vars.quick_push (chain->vars[0]); - FOR_EACH_VEC_ELT (tree, chain->vars, i, var) - VEC_replace (tree, chain->vars, i, make_ssa_name (var, NULL)); + FOR_EACH_VEC_ELT (chain->vars, i, var) + chain->vars[i] = make_ssa_name (var, NULL); for (i = 0; i < n; i++) { - var = VEC_index (tree, chain->vars, i); - next = VEC_index (tree, chain->vars, i + 1); + var = chain->vars[i]; + next = chain->vars[i + 1]; init = get_init_expr (chain, i); init = force_gimple_operand (init, &stmts, true, NULL_TREE); @@ -1512,7 +1508,7 @@ initialize_root (struct loop *loop, chain_p chain, bitmap tmp_vars) initialize_root_vars (loop, chain, tmp_vars); replace_ref_with (root->stmt, - VEC_index (tree, chain->vars, chain->length), + chain->vars[chain->length], true, in_lhs); } @@ -1525,7 +1521,7 @@ initialize_root (struct loop *loop, chain_p chain, bitmap tmp_vars) static void initialize_root_vars_lm (struct loop *loop, dref root, bool written, - VEC(tree, heap) **vars, VEC(tree, heap) *inits, + vec<tree> *vars, vec<tree> inits, bitmap tmp_vars) { unsigned i; @@ -1536,18 +1532,18 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written, /* Find the initializer for the variable, and check that it cannot trap. */ - init = VEC_index (tree, inits, 0); + init = inits[0]; - *vars = VEC_alloc (tree, heap, written ? 2 : 1); + vars->create (written ? 2 : 1); var = predcom_tmp_var (ref, 0, tmp_vars); - VEC_quick_push (tree, *vars, var); + vars->quick_push (var); if (written) - VEC_quick_push (tree, *vars, VEC_index (tree, *vars, 0)); + vars->quick_push ((*vars)[0]); - FOR_EACH_VEC_ELT (tree, *vars, i, var) - VEC_replace (tree, *vars, i, make_ssa_name (var, NULL)); + FOR_EACH_VEC_ELT (*vars, i, var) + (*vars)[i] = make_ssa_name (var, NULL); - var = VEC_index (tree, *vars, 0); + var = (*vars)[0]; init = force_gimple_operand (init, &stmts, written, NULL_TREE); if (stmts) @@ -1555,7 +1551,7 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written, if (written) { - next = VEC_index (tree, *vars, 1); + next = (*vars)[1]; phi = create_phi_node (var, loop->header); add_phi_arg (phi, init, entry, UNKNOWN_LOCATION); add_phi_arg (phi, next, latch, UNKNOWN_LOCATION); @@ -1574,26 +1570,26 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written, static void execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars) { - VEC (tree, heap) *vars; + vec<tree> vars; dref a; unsigned n_writes = 0, ridx, i; tree var; gcc_assert (chain->type == CT_INVARIANT); gcc_assert (!chain->combined); - FOR_EACH_VEC_ELT (dref, chain->refs, i, a) + FOR_EACH_VEC_ELT (chain->refs, i, a) if (DR_IS_WRITE (a->ref)) n_writes++; /* If there are no reads in the loop, there is nothing to do. */ - if (n_writes == VEC_length (dref, chain->refs)) + if (n_writes == chain->refs.length ()) return; initialize_root_vars_lm (loop, get_chain_root (chain), n_writes > 0, &vars, chain->inits, tmp_vars); ridx = 0; - FOR_EACH_VEC_ELT (dref, chain->refs, i, a) + FOR_EACH_VEC_ELT (chain->refs, i, a) { bool is_read = DR_IS_READ (a->ref); @@ -1602,19 +1598,19 @@ execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars) n_writes--; if (n_writes) { - var = VEC_index (tree, vars, 0); + var = vars[0]; var = make_ssa_name (SSA_NAME_VAR (var), NULL); - VEC_replace (tree, vars, 0, var); + vars[0] = var; } else ridx = 1; } - replace_ref_with (a->stmt, VEC_index (tree, vars, ridx), + replace_ref_with (a->stmt, vars[ridx], !is_read, !is_read); } - VEC_free (tree, heap, vars); + vars.release (); } /* Returns the single statement in that NAME is used, excepting @@ -1719,7 +1715,7 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain, { /* For combined chains, just remove the statements that are used to compute the values of the expression (except for the root one). */ - for (i = 1; VEC_iterate (dref, chain->refs, i, a); i++) + for (i = 1; chain->refs.iterate (i, &a); i++) remove_stmt (a->stmt); } else @@ -1728,9 +1724,9 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain, and replace the uses of the original references by these variables. */ initialize_root (loop, chain, tmp_vars); - for (i = 1; VEC_iterate (dref, chain->refs, i, a); i++) + for (i = 1; chain->refs.iterate (i, &a); i++) { - var = VEC_index (tree, chain->vars, chain->length - a->distance); + var = chain->vars[chain->length - a->distance]; replace_ref_with (a->stmt, var, false, false); } } @@ -1741,13 +1737,13 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain, optimized. */ static unsigned -determine_unroll_factor (VEC (chain_p, heap) *chains) +determine_unroll_factor (vec<chain_p> chains) { chain_p chain; unsigned factor = 1, af, nfactor, i; unsigned max = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES); - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) + FOR_EACH_VEC_ELT (chains, i, chain) { if (chain->type == CT_INVARIANT || chain->combined) continue; @@ -1770,13 +1766,13 @@ determine_unroll_factor (VEC (chain_p, heap) *chains) Uids of the newly created temporary variables are marked in TMP_VARS. */ static void -execute_pred_commoning (struct loop *loop, VEC (chain_p, heap) *chains, +execute_pred_commoning (struct loop *loop, vec<chain_p> chains, bitmap tmp_vars) { chain_p chain; unsigned i; - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) + FOR_EACH_VEC_ELT (chains, i, chain) { if (chain->type == CT_INVARIANT) execute_load_motion (loop, chain, tmp_vars); @@ -1791,14 +1787,14 @@ execute_pred_commoning (struct loop *loop, VEC (chain_p, heap) *chains, phi node, record the ssa name that is defined by it. */ static void -replace_phis_by_defined_names (VEC (chain_p, heap) *chains) +replace_phis_by_defined_names (vec<chain_p> chains) { chain_p chain; dref a; unsigned i, j; - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) - FOR_EACH_VEC_ELT (dref, chain->refs, j, a) + FOR_EACH_VEC_ELT (chains, i, chain) + FOR_EACH_VEC_ELT (chain->refs, j, a) { if (gimple_code (a->stmt) == GIMPLE_PHI) { @@ -1812,14 +1808,14 @@ replace_phis_by_defined_names (VEC (chain_p, heap) *chains) NULL, use it to set the stmt field. */ static void -replace_names_by_phis (VEC (chain_p, heap) *chains) +replace_names_by_phis (vec<chain_p> chains) { chain_p chain; dref a; unsigned i, j; - FOR_EACH_VEC_ELT (chain_p, chains, i, chain) - FOR_EACH_VEC_ELT (dref, chain->refs, j, a) + FOR_EACH_VEC_ELT (chains, i, chain) + FOR_EACH_VEC_ELT (chain->refs, j, a) if (a->stmt == NULL) { a->stmt = SSA_NAME_DEF_STMT (a->name_defined_by_phi); @@ -1833,7 +1829,7 @@ replace_names_by_phis (VEC (chain_p, heap) *chains) struct epcc_data { - VEC (chain_p, heap) *chains; + vec<chain_p> chains; bitmap tmp_vars; }; @@ -2242,11 +2238,11 @@ combine_chains (chain_p ch1, chain_p ch2) if (ch1->length != ch2->length) return NULL; - if (VEC_length (dref, ch1->refs) != VEC_length (dref, ch2->refs)) + if (ch1->refs.length () != ch2->refs.length ()) return NULL; - for (i = 0; (VEC_iterate (dref, ch1->refs, i, r1) - && VEC_iterate (dref, ch2->refs, i, r2)); i++) + for (i = 0; (ch1->refs.iterate (i, &r1) + && ch2->refs.iterate (i, &r2)); i++) { if (r1->distance != r2->distance) return NULL; @@ -2270,19 +2266,19 @@ combine_chains (chain_p ch1, chain_p ch2) new_chain->rslt_type = rslt_type; new_chain->length = ch1->length; - for (i = 0; (VEC_iterate (dref, ch1->refs, i, r1) - && VEC_iterate (dref, ch2->refs, i, r2)); i++) + for (i = 0; (ch1->refs.iterate (i, &r1) + && ch2->refs.iterate (i, &r2)); i++) { nw = XCNEW (struct dref_d); nw->stmt = stmt_combining_refs (r1, r2); nw->distance = r1->distance; - VEC_safe_push (dref, heap, new_chain->refs, nw); + new_chain->refs.safe_push (nw); } new_chain->has_max_use_after = false; root_stmt = get_chain_root (new_chain)->stmt; - for (i = 1; VEC_iterate (dref, new_chain->refs, i, nw); i++) + for (i = 1; new_chain->refs.iterate (i, &nw); i++) { if (nw->distance == new_chain->length && !stmt_dominates_stmt_p (nw->stmt, root_stmt)) @@ -2300,23 +2296,23 @@ combine_chains (chain_p ch1, chain_p ch2) /* Try to combine the CHAINS. */ static void -try_combine_chains (VEC (chain_p, heap) **chains) +try_combine_chains (vec<chain_p> *chains) { unsigned i, j; chain_p ch1, ch2, cch; - VEC (chain_p, heap) *worklist = NULL; + vec<chain_p> worklist = vec<chain_p>(); - FOR_EACH_VEC_ELT (chain_p, *chains, i, ch1) + FOR_EACH_VEC_ELT (*chains, i, ch1) if (chain_can_be_combined_p (ch1)) - VEC_safe_push (chain_p, heap, worklist, ch1); + worklist.safe_push (ch1); - while (!VEC_empty (chain_p, worklist)) + while (!worklist.is_empty ()) { - ch1 = VEC_pop (chain_p, worklist); + ch1 = worklist.pop (); if (!chain_can_be_combined_p (ch1)) continue; - FOR_EACH_VEC_ELT (chain_p, *chains, j, ch2) + FOR_EACH_VEC_ELT (*chains, j, ch2) { if (!chain_can_be_combined_p (ch2)) continue; @@ -2324,14 +2320,14 @@ try_combine_chains (VEC (chain_p, heap) **chains) cch = combine_chains (ch1, ch2); if (cch) { - VEC_safe_push (chain_p, heap, worklist, cch); - VEC_safe_push (chain_p, heap, *chains, cch); + worklist.safe_push (cch); + chains->safe_push (cch); break; } } } - VEC_free (chain_p, heap, worklist); + worklist.release (); } /* Prepare initializers for CHAIN in LOOP. Returns false if this is @@ -2349,25 +2345,25 @@ prepare_initializers_chain (struct loop *loop, chain_p chain) /* Find the initializers for the variables, and check that they cannot trap. */ - chain->inits = VEC_alloc (tree, heap, n); + chain->inits.create (n); for (i = 0; i < n; i++) - VEC_quick_push (tree, chain->inits, NULL_TREE); + chain->inits.quick_push (NULL_TREE); /* If we have replaced some looparound phi nodes, use their initializers instead of creating our own. */ - FOR_EACH_VEC_ELT (dref, chain->refs, i, laref) + FOR_EACH_VEC_ELT (chain->refs, i, laref) { if (gimple_code (laref->stmt) != GIMPLE_PHI) continue; gcc_assert (laref->distance > 0); - VEC_replace (tree, chain->inits, n - laref->distance, - PHI_ARG_DEF_FROM_EDGE (laref->stmt, entry)); + chain->inits[n - laref->distance] + = PHI_ARG_DEF_FROM_EDGE (laref->stmt, entry); } for (i = 0; i < n; i++) { - if (VEC_index (tree, chain->inits, i) != NULL_TREE) + if (chain->inits[i] != NULL_TREE) continue; init = ref_at_iteration (loop, DR_REF (dr), (int) i - n); @@ -2381,7 +2377,7 @@ prepare_initializers_chain (struct loop *loop, chain_p chain) if (stmts) gsi_insert_seq_on_edge_immediate (entry, stmts); - VEC_replace (tree, chain->inits, i, init); + chain->inits[i] = init; } return true; @@ -2391,20 +2387,20 @@ prepare_initializers_chain (struct loop *loop, chain_p chain) be used because the initializers might trap. */ static void -prepare_initializers (struct loop *loop, VEC (chain_p, heap) *chains) +prepare_initializers (struct loop *loop, vec<chain_p> chains) { chain_p chain; unsigned i; - for (i = 0; i < VEC_length (chain_p, chains); ) + for (i = 0; i < chains.length (); ) { - chain = VEC_index (chain_p, chains, i); + chain = chains[i]; if (prepare_initializers_chain (loop, chain)) i++; else { release_chain (chain); - VEC_unordered_remove (chain_p, chains, i); + chains.unordered_remove (i); } } } @@ -2415,11 +2411,11 @@ prepare_initializers (struct loop *loop, VEC (chain_p, heap) *chains) static bool tree_predictive_commoning_loop (struct loop *loop) { - VEC (loop_p, heap) *loop_nest; - VEC (data_reference_p, heap) *datarefs; - VEC (ddr_p, heap) *dependences; + vec<loop_p> loop_nest; + vec<data_reference_p> datarefs; + vec<ddr_p> dependences; struct component *components; - VEC (chain_p, heap) *chains = NULL; + vec<chain_p> chains = vec<chain_p>(); unsigned unroll_factor; struct tree_niter_desc desc; bool unroll = false; @@ -2431,15 +2427,15 @@ tree_predictive_commoning_loop (struct loop *loop) /* Find the data references and split them into components according to their dependence relations. */ - datarefs = VEC_alloc (data_reference_p, heap, 10); - dependences = VEC_alloc (ddr_p, heap, 10); - loop_nest = VEC_alloc (loop_p, heap, 3); + datarefs.create (10); + dependences.create (10); + loop_nest.create (3); if (! compute_data_dependences_for_loop (loop, true, &loop_nest, &datarefs, &dependences)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Cannot analyze data dependencies\n"); - VEC_free (loop_p, heap, loop_nest); + loop_nest.release (); free_data_refs (datarefs); free_dependence_relations (dependences); return false; @@ -2449,7 +2445,7 @@ tree_predictive_commoning_loop (struct loop *loop) dump_data_dependence_relations (dump_file, dependences); components = split_data_refs_to_components (loop, datarefs, dependences); - VEC_free (loop_p, heap, loop_nest); + loop_nest.release (); free_dependence_relations (dependences); if (!components) { @@ -2471,7 +2467,7 @@ tree_predictive_commoning_loop (struct loop *loop) determine_roots (loop, components, &chains); release_components (components); - if (!chains) + if (!chains.exists ()) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, |