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-ssa-sccvn.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-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 323 |
1 files changed, 153 insertions, 170 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 2391632..ed89a5a 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -149,17 +149,15 @@ static unsigned int next_value_id; detection. */ static unsigned int next_dfs_num; -static VEC (tree, heap) *sccstack; +static vec<tree> sccstack; -DEF_VEC_P(vn_ssa_aux_t); -DEF_VEC_ALLOC_P(vn_ssa_aux_t, heap); /* Table of vn_ssa_aux_t's, one per ssa_name. The vn_ssa_aux_t objects are allocated on an obstack for locality reasons, and to free them - without looping over the VEC. */ + without looping over the vec. */ -static VEC (vn_ssa_aux_t, heap) *vn_ssa_aux_table; +static vec<vn_ssa_aux_t> vn_ssa_aux_table; static struct obstack vn_ssa_aux_obstack; /* Return the value numbering information for a given SSA name. */ @@ -167,8 +165,7 @@ static struct obstack vn_ssa_aux_obstack; vn_ssa_aux_t VN_INFO (tree name) { - vn_ssa_aux_t res = VEC_index (vn_ssa_aux_t, vn_ssa_aux_table, - SSA_NAME_VERSION (name)); + vn_ssa_aux_t res = vn_ssa_aux_table[SSA_NAME_VERSION (name)]; gcc_checking_assert (res); return res; } @@ -179,8 +176,7 @@ VN_INFO (tree name) static inline void VN_INFO_SET (tree name, vn_ssa_aux_t value) { - VEC_replace (vn_ssa_aux_t, vn_ssa_aux_table, - SSA_NAME_VERSION (name), value); + vn_ssa_aux_table[SSA_NAME_VERSION (name)] = value; } /* Initialize the value numbering info for a given SSA name. @@ -193,11 +189,9 @@ VN_INFO_GET (tree name) newinfo = XOBNEW (&vn_ssa_aux_obstack, struct vn_ssa_aux); memset (newinfo, 0, sizeof (struct vn_ssa_aux)); - if (SSA_NAME_VERSION (name) >= VEC_length (vn_ssa_aux_t, vn_ssa_aux_table)) - VEC_safe_grow (vn_ssa_aux_t, heap, vn_ssa_aux_table, - SSA_NAME_VERSION (name) + 1); - VEC_replace (vn_ssa_aux_t, vn_ssa_aux_table, - SSA_NAME_VERSION (name), newinfo); + if (SSA_NAME_VERSION (name) >= vn_ssa_aux_table.length ()) + vn_ssa_aux_table.safe_grow (SSA_NAME_VERSION (name) + 1); + vn_ssa_aux_table[SSA_NAME_VERSION (name)] = newinfo; return newinfo; } @@ -351,7 +345,7 @@ static void free_phi (void *vp) { vn_phi_t phi = (vn_phi_t) vp; - VEC_free (tree, heap, phi->phiargs); + phi->phiargs.release (); } /* Free a reference operation structure VP. */ @@ -360,7 +354,7 @@ static void free_reference (void *vp) { vn_reference_t vr = (vn_reference_t) vp; - VEC_free (vn_reference_op_s, heap, vr->operands); + vr->operands.release (); } /* Hash table equality function for vn_constant_t. */ @@ -493,7 +487,7 @@ vn_reference_compute_hash (const vn_reference_t vr1) HOST_WIDE_INT off = -1; bool deref = false; - FOR_EACH_VEC_ELT (vn_reference_op_s, vr1->operands, i, vro) + FOR_EACH_VEC_ELT (vr1->operands, i, vro) { if (vro->opcode == MEM_REF) deref = true; @@ -582,7 +576,7 @@ vn_reference_eq (const void *p1, const void *p2) vn_reference_op_t vro1, vro2; vn_reference_op_s tem1, tem2; bool deref1 = false, deref2 = false; - for (; VEC_iterate (vn_reference_op_s, vr1->operands, i, vro1); i++) + for (; vr1->operands.iterate (i, &vro1); i++) { if (vro1->opcode == MEM_REF) deref1 = true; @@ -590,7 +584,7 @@ vn_reference_eq (const void *p1, const void *p2) break; off1 += vro1->off; } - for (; VEC_iterate (vn_reference_op_s, vr2->operands, j, vro2); j++) + for (; vr2->operands.iterate (j, &vro2); j++) { if (vro2->opcode == MEM_REF) deref2 = true; @@ -625,8 +619,8 @@ vn_reference_eq (const void *p1, const void *p2) ++j; ++i; } - while (VEC_length (vn_reference_op_s, vr1->operands) != i - || VEC_length (vn_reference_op_s, vr2->operands) != j); + while (vr1->operands.length () != i + || vr2->operands.length () != j); return true; } @@ -635,7 +629,7 @@ vn_reference_eq (const void *p1, const void *p2) vn_reference_op_s's. */ void -copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) +copy_reference_ops_from_ref (tree ref, vec<vn_reference_op_s> *result) { if (TREE_CODE (ref) == TARGET_MEM_REF) { @@ -648,21 +642,21 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) temp.op1 = TMR_STEP (ref); temp.op2 = TMR_OFFSET (ref); temp.off = -1; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); memset (&temp, 0, sizeof (temp)); temp.type = NULL_TREE; temp.opcode = ERROR_MARK; temp.op0 = TMR_INDEX2 (ref); temp.off = -1; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); memset (&temp, 0, sizeof (temp)); temp.type = NULL_TREE; temp.opcode = TREE_CODE (TMR_BASE (ref)); temp.op0 = TMR_BASE (ref); temp.off = -1; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); return; } @@ -757,7 +751,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) temp.opcode = MEM_REF; temp.op0 = build_int_cst (build_pointer_type (TREE_TYPE (ref)), 0); temp.off = 0; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); temp.opcode = ADDR_EXPR; temp.op0 = build_fold_addr_expr (ref); temp.type = TREE_TYPE (temp.op0); @@ -796,7 +790,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) default: gcc_unreachable (); } - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); if (REFERENCE_CLASS_P (ref) || TREE_CODE (ref) == MODIFY_EXPR @@ -816,7 +810,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) bool ao_ref_init_from_vn_reference (ao_ref *ref, alias_set_type set, tree type, - VEC (vn_reference_op_s, heap) *ops) + vec<vn_reference_op_s> ops) { vn_reference_op_t op; unsigned i; @@ -829,7 +823,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, alias_set_type base_alias_set = -1; /* First get the final access size from just the outermost expression. */ - op = &VEC_index (vn_reference_op_s, ops, 0); + op = &ops[0]; if (op->opcode == COMPONENT_REF) size_tree = DECL_SIZE (op->op0); else if (op->opcode == BIT_FIELD_REF) @@ -856,7 +850,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, /* Compute cumulative bit-offset for nested component-refs and array-refs, and find the ultimate containing object. */ - FOR_EACH_VEC_ELT (vn_reference_op_s, ops, i, op) + FOR_EACH_VEC_ELT (ops, i, op) { switch (op->opcode) { @@ -869,7 +863,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, && op->op0 && DECL_P (TREE_OPERAND (op->op0, 0))) { - vn_reference_op_t pop = &VEC_index (vn_reference_op_s, ops, i-1); + vn_reference_op_t pop = &ops[i-1]; base = TREE_OPERAND (op->op0, 0); if (pop->off == -1) { @@ -990,7 +984,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, void copy_reference_ops_from_call (gimple call, - VEC(vn_reference_op_s, heap) **result) + vec<vn_reference_op_s> *result) { vn_reference_op_s temp; unsigned i; @@ -1006,7 +1000,7 @@ copy_reference_ops_from_call (gimple call, temp.type = TREE_TYPE (lhs); temp.op0 = lhs; temp.off = -1; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); } /* Copy the type, opcode, function being called and static chain. */ @@ -1016,7 +1010,7 @@ copy_reference_ops_from_call (gimple call, temp.op0 = gimple_call_fn (call); temp.op1 = gimple_call_chain (call); temp.off = -1; - VEC_safe_push (vn_reference_op_s, heap, *result, temp); + result->safe_push (temp); /* Copy the call arguments. As they can be references as well, just chain them together. */ @@ -1030,10 +1024,10 @@ copy_reference_ops_from_call (gimple call, /* Create a vector of vn_reference_op_s structures from REF, a REFERENCE_CLASS_P tree. The vector is not shared. */ -static VEC(vn_reference_op_s, heap) * +static vec<vn_reference_op_s> create_reference_ops_from_ref (tree ref) { - VEC (vn_reference_op_s, heap) *result = NULL; + vec<vn_reference_op_s> result = vec<vn_reference_op_s>(); copy_reference_ops_from_ref (ref, &result); return result; @@ -1042,10 +1036,10 @@ create_reference_ops_from_ref (tree ref) /* Create a vector of vn_reference_op_s structures from CALL, a call statement. The vector is not shared. */ -static VEC(vn_reference_op_s, heap) * +static vec<vn_reference_op_s> create_reference_ops_from_call (gimple call) { - VEC (vn_reference_op_s, heap) *result = NULL; + vec<vn_reference_op_s> result = vec<vn_reference_op_s>(); copy_reference_ops_from_call (call, &result); return result; @@ -1054,12 +1048,12 @@ create_reference_ops_from_call (gimple call) /* Fold *& at position *I_P in a vn_reference_op_s vector *OPS. Updates *I_P to point to the last element of the replacement. */ void -vn_reference_fold_indirect (VEC (vn_reference_op_s, heap) **ops, +vn_reference_fold_indirect (vec<vn_reference_op_s> *ops, unsigned int *i_p) { unsigned int i = *i_p; - vn_reference_op_t op = &VEC_index (vn_reference_op_s, *ops, i); - vn_reference_op_t mem_op = &VEC_index (vn_reference_op_s, *ops, i - 1); + vn_reference_op_t op = &(*ops)[i]; + vn_reference_op_t mem_op = &(*ops)[i - 1]; tree addr_base; HOST_WIDE_INT addr_offset = 0; @@ -1086,12 +1080,12 @@ vn_reference_fold_indirect (VEC (vn_reference_op_s, heap) **ops, /* Fold *& at position *I_P in a vn_reference_op_s vector *OPS. Updates *I_P to point to the last element of the replacement. */ static void -vn_reference_maybe_forwprop_address (VEC (vn_reference_op_s, heap) **ops, +vn_reference_maybe_forwprop_address (vec<vn_reference_op_s> *ops, unsigned int *i_p) { unsigned int i = *i_p; - vn_reference_op_t op = &VEC_index (vn_reference_op_s, *ops, i); - vn_reference_op_t mem_op = &VEC_index (vn_reference_op_s, *ops, i - 1); + vn_reference_op_t op = &(*ops)[i]; + vn_reference_op_t mem_op = &(*ops)[i - 1]; gimple def_stmt; enum tree_code code; double_int off; @@ -1163,24 +1157,24 @@ vn_reference_maybe_forwprop_address (VEC (vn_reference_op_s, heap) **ops, tree fully_constant_vn_reference_p (vn_reference_t ref) { - VEC (vn_reference_op_s, heap) *operands = ref->operands; + vec<vn_reference_op_s> operands = ref->operands; vn_reference_op_t op; /* Try to simplify the translated expression if it is a call to a builtin function with at most two arguments. */ - op = &VEC_index (vn_reference_op_s, operands, 0); + op = &operands[0]; if (op->opcode == CALL_EXPR && TREE_CODE (op->op0) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (op->op0, 0)) == FUNCTION_DECL && DECL_BUILT_IN (TREE_OPERAND (op->op0, 0)) - && VEC_length (vn_reference_op_s, operands) >= 2 - && VEC_length (vn_reference_op_s, operands) <= 3) + && operands.length () >= 2 + && operands.length () <= 3) { vn_reference_op_t arg0, arg1 = NULL; bool anyconst = false; - arg0 = &VEC_index (vn_reference_op_s, operands, 1); - if (VEC_length (vn_reference_op_s, operands) > 2) - arg1 = &VEC_index (vn_reference_op_s, operands, 2); + arg0 = &operands[1]; + if (operands.length () > 2) + arg1 = &operands[2]; if (TREE_CODE_CLASS (arg0->opcode) == tcc_constant || (arg0->opcode == ADDR_EXPR && is_gimple_min_invariant (arg0->op0))) @@ -1209,10 +1203,10 @@ fully_constant_vn_reference_p (vn_reference_t ref) else if (op->opcode == ARRAY_REF && TREE_CODE (op->op0) == INTEGER_CST && integer_zerop (op->op1) - && VEC_length (vn_reference_op_s, operands) == 2) + && operands.length () == 2) { vn_reference_op_t arg0; - arg0 = &VEC_index (vn_reference_op_s, operands, 1); + arg0 = &operands[1]; if (arg0->opcode == STRING_CST && (TYPE_MODE (op->type) == TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0->op0)))) @@ -1232,15 +1226,15 @@ fully_constant_vn_reference_p (vn_reference_t ref) the vector passed in is returned. *VALUEIZED_ANYTHING will specify whether any operands were valueized. */ -static VEC (vn_reference_op_s, heap) * -valueize_refs_1 (VEC (vn_reference_op_s, heap) *orig, bool *valueized_anything) +static vec<vn_reference_op_s> +valueize_refs_1 (vec<vn_reference_op_s> orig, bool *valueized_anything) { vn_reference_op_t vro; unsigned int i; *valueized_anything = false; - FOR_EACH_VEC_ELT (vn_reference_op_s, orig, i, vro) + FOR_EACH_VEC_ELT (orig, i, vro) { if (vro->opcode == SSA_NAME || (vro->op0 && TREE_CODE (vro->op0) == SSA_NAME)) @@ -1279,13 +1273,11 @@ valueize_refs_1 (VEC (vn_reference_op_s, heap) *orig, bool *valueized_anything) if (i > 0 && vro->op0 && TREE_CODE (vro->op0) == ADDR_EXPR - && VEC_index (vn_reference_op_s, - orig, i - 1).opcode == MEM_REF) + && orig[i - 1].opcode == MEM_REF) vn_reference_fold_indirect (&orig, &i); else if (i > 0 && vro->opcode == SSA_NAME - && VEC_index (vn_reference_op_s, - orig, i - 1).opcode == MEM_REF) + && orig[i - 1].opcode == MEM_REF) vn_reference_maybe_forwprop_address (&orig, &i); /* If it transforms a non-constant ARRAY_REF into a constant one, adjust the constant offset. */ @@ -1306,26 +1298,26 @@ valueize_refs_1 (VEC (vn_reference_op_s, heap) *orig, bool *valueized_anything) return orig; } -static VEC (vn_reference_op_s, heap) * -valueize_refs (VEC (vn_reference_op_s, heap) *orig) +static vec<vn_reference_op_s> +valueize_refs (vec<vn_reference_op_s> orig) { bool tem; return valueize_refs_1 (orig, &tem); } -static VEC(vn_reference_op_s, heap) *shared_lookup_references; +static vec<vn_reference_op_s> shared_lookup_references; /* Create a vector of vn_reference_op_s structures from REF, a REFERENCE_CLASS_P tree. The vector is shared among all callers of this function. *VALUEIZED_ANYTHING will specify whether any operands were valueized. */ -static VEC(vn_reference_op_s, heap) * +static vec<vn_reference_op_s> valueize_shared_reference_ops_from_ref (tree ref, bool *valueized_anything) { if (!ref) - return NULL; - VEC_truncate (vn_reference_op_s, shared_lookup_references, 0); + return vec<vn_reference_op_s>(); + shared_lookup_references.truncate (0); copy_reference_ops_from_ref (ref, &shared_lookup_references); shared_lookup_references = valueize_refs_1 (shared_lookup_references, valueized_anything); @@ -1336,12 +1328,12 @@ valueize_shared_reference_ops_from_ref (tree ref, bool *valueized_anything) call statement. The vector is shared among all callers of this function. */ -static VEC(vn_reference_op_s, heap) * +static vec<vn_reference_op_s> valueize_shared_reference_ops_from_call (gimple call) { if (!call) - return NULL; - VEC_truncate (vn_reference_op_s, shared_lookup_references, 0); + return vec<vn_reference_op_s>(); + shared_lookup_references.truncate (0); copy_reference_ops_from_call (call, &shared_lookup_references); shared_lookup_references = valueize_refs (shared_lookup_references); return shared_lookup_references; @@ -1425,8 +1417,8 @@ static vn_reference_t vn_reference_lookup_or_insert_for_pieces (tree vuse, alias_set_type set, tree type, - VEC (vn_reference_op_s, - heap) *operands, + vec<vn_reference_op_s, + va_heap> operands, tree value) { struct vn_reference_s vr1; @@ -1444,8 +1436,7 @@ vn_reference_lookup_or_insert_for_pieces (tree vuse, else value_id = get_or_alloc_constant_value_id (value); return vn_reference_insert_pieces (vuse, set, type, - VEC_copy (vn_reference_op_s, heap, - operands), value, value_id); + operands.copy (), value, value_id); } /* Callback for walk_non_aliased_vuses. Tries to perform a lookup @@ -1460,18 +1451,19 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) gimple def_stmt = SSA_NAME_DEF_STMT (vuse); tree base; HOST_WIDE_INT offset, maxsize; - static VEC (vn_reference_op_s, heap) *lhs_ops = NULL; + static vec<vn_reference_op_s> + lhs_ops = vec<vn_reference_op_s>(); ao_ref lhs_ref; bool lhs_ref_ok = false; /* First try to disambiguate after value-replacing in the definitions LHS. */ if (is_gimple_assign (def_stmt)) { - VEC (vn_reference_op_s, heap) *tem; + vec<vn_reference_op_s> tem; tree lhs = gimple_assign_lhs (def_stmt); bool valueized_anything = false; /* Avoid re-allocation overhead. */ - VEC_truncate (vn_reference_op_s, lhs_ops, 0); + lhs_ops.truncate (0); copy_reference_ops_from_ref (lhs, &lhs_ops); tem = lhs_ops; lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything); @@ -1665,7 +1657,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) tree base2; HOST_WIDE_INT offset2, size2, maxsize2; int i, j; - VEC (vn_reference_op_s, heap) *rhs = NULL; + vec<vn_reference_op_s> + rhs = vec<vn_reference_op_s>(); vn_reference_op_t vro; ao_ref r; @@ -1685,12 +1678,10 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) /* Find the common base of ref and the lhs. lhs_ops already contains valueized operands for the lhs. */ - i = VEC_length (vn_reference_op_s, vr->operands) - 1; - j = VEC_length (vn_reference_op_s, lhs_ops) - 1; + i = vr->operands.length () - 1; + j = lhs_ops.length () - 1; while (j >= 0 && i >= 0 - && vn_reference_op_eq (&VEC_index (vn_reference_op_s, - vr->operands, i), - &VEC_index (vn_reference_op_s, lhs_ops, j))) + && vn_reference_op_eq (&vr->operands[i], &lhs_ops[j])) { i--; j--; @@ -1703,10 +1694,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) don't care here - further lookups with the rewritten operands will simply fail if we messed up types too badly. */ if (j == 0 && i >= 0 - && VEC_index (vn_reference_op_s, lhs_ops, 0).opcode == MEM_REF - && VEC_index (vn_reference_op_s, lhs_ops, 0).off != -1 - && (VEC_index (vn_reference_op_s, lhs_ops, 0).off - == VEC_index (vn_reference_op_s, vr->operands, i).off)) + && lhs_ops[0].opcode == MEM_REF + && lhs_ops[0].off != -1 + && (lhs_ops[0].off == vr->operands[i].off)) i--, j--; /* i now points to the first additional op. @@ -1719,22 +1709,19 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) /* Now re-write REF to be based on the rhs of the assignment. */ copy_reference_ops_from_ref (gimple_assign_rhs1 (def_stmt), &rhs); /* We need to pre-pend vr->operands[0..i] to rhs. */ - if (i + 1 + VEC_length (vn_reference_op_s, rhs) - > VEC_length (vn_reference_op_s, vr->operands)) + if (i + 1 + rhs.length () > vr->operands.length ()) { - VEC (vn_reference_op_s, heap) *old = vr->operands; - VEC_safe_grow (vn_reference_op_s, heap, vr->operands, - i + 1 + VEC_length (vn_reference_op_s, rhs)); + vec<vn_reference_op_s> old = vr->operands; + vr->operands.safe_grow (i + 1 + rhs.length ()); if (old == shared_lookup_references && vr->operands != old) - shared_lookup_references = NULL; + shared_lookup_references = vec<vn_reference_op_s>(); } else - VEC_truncate (vn_reference_op_s, vr->operands, - i + 1 + VEC_length (vn_reference_op_s, rhs)); - FOR_EACH_VEC_ELT (vn_reference_op_s, rhs, j, vro) - VEC_replace (vn_reference_op_s, vr->operands, i + 1 + j, *vro); - VEC_free (vn_reference_op_s, heap, rhs); + vr->operands.truncate (i + 1 + rhs.length ()); + FOR_EACH_VEC_ELT (rhs, j, vro) + vr->operands[i + 1 + j] = *vro; + rhs.release (); vr->operands = valueize_refs (vr->operands); vr->hashcode = vn_reference_compute_hash (vr); @@ -1854,16 +1841,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) return (void *)-1; /* Make room for 2 operands in the new reference. */ - if (VEC_length (vn_reference_op_s, vr->operands) < 2) + if (vr->operands.length () < 2) { - VEC (vn_reference_op_s, heap) *old = vr->operands; - VEC_safe_grow (vn_reference_op_s, heap, vr->operands, 2); + vec<vn_reference_op_s> old = vr->operands; + vr->operands.safe_grow_cleared (2); if (old == shared_lookup_references && vr->operands != old) - shared_lookup_references = NULL; + shared_lookup_references.create (0); } else - VEC_truncate (vn_reference_op_s, vr->operands, 2); + vr->operands.truncate (2); /* The looked-through reference is a simple MEM_REF. */ memset (&op, 0, sizeof (op)); @@ -1871,12 +1858,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) op.opcode = MEM_REF; op.op0 = build_int_cst (ptr_type_node, at - rhs_offset); op.off = at - lhs_offset + rhs_offset; - VEC_replace (vn_reference_op_s, vr->operands, 0, op); + vr->operands[0] = op; op.type = TREE_TYPE (rhs); op.opcode = TREE_CODE (rhs); op.op0 = rhs; op.off = -1; - VEC_replace (vn_reference_op_s, vr->operands, 1, op); + vr->operands[1] = op; vr->hashcode = vn_reference_compute_hash (vr); /* Adjust *ref from the new operands. */ @@ -1905,7 +1892,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) tree vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, - VEC (vn_reference_op_s, heap) *operands, + vec<vn_reference_op_s> operands, vn_reference_t *vnresult, vn_lookup_kind kind) { struct vn_reference_s vr1; @@ -1917,13 +1904,12 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, *vnresult = NULL; vr1.vuse = vuse ? SSA_VAL (vuse) : NULL_TREE; - VEC_truncate (vn_reference_op_s, shared_lookup_references, 0); - VEC_safe_grow (vn_reference_op_s, heap, shared_lookup_references, - VEC_length (vn_reference_op_s, operands)); - memcpy (VEC_address (vn_reference_op_s, shared_lookup_references), - VEC_address (vn_reference_op_s, operands), + shared_lookup_references.truncate (0); + shared_lookup_references.safe_grow (operands.length ()); + memcpy (shared_lookup_references.address (), + operands.address (), sizeof (vn_reference_op_s) - * VEC_length (vn_reference_op_s, operands)); + * operands.length ()); vr1.operands = operands = shared_lookup_references = valueize_refs (shared_lookup_references); vr1.type = type; @@ -1945,7 +1931,7 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, vn_reference_lookup_2, vn_reference_lookup_3, &vr1); if (vr1.operands != operands) - VEC_free (vn_reference_op_s, heap, vr1.operands); + vr1.operands.release (); } if (*vnresult) @@ -1964,7 +1950,7 @@ tree vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, vn_reference_t *vnresult) { - VEC (vn_reference_op_s, heap) *operands; + vec<vn_reference_op_s> operands; struct vn_reference_s vr1; tree cst; bool valuezied_anything; @@ -1998,7 +1984,7 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, vn_reference_lookup_2, vn_reference_lookup_3, &vr1); if (vr1.operands != operands) - VEC_free (vn_reference_op_s, heap, vr1.operands); + vr1.operands.release (); if (wvnresult) { if (vnresult) @@ -2060,7 +2046,7 @@ vn_reference_insert (tree op, tree result, tree vuse, tree vdef) vn_reference_t vn_reference_insert_pieces (tree vuse, alias_set_type set, tree type, - VEC (vn_reference_op_s, heap) *operands, + vec<vn_reference_op_s> operands, tree result, unsigned int value_id) { @@ -2416,12 +2402,12 @@ vn_phi_compute_hash (vn_phi_t vp1) /* If all PHI arguments are constants we need to distinguish the PHI node via its type. */ - type = TREE_TYPE (VEC_index (tree, vp1->phiargs, 0)); + type = TREE_TYPE (vp1->phiargs[0]); result += (INTEGRAL_TYPE_P (type) + (INTEGRAL_TYPE_P (type) ? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0)); - FOR_EACH_VEC_ELT (tree, vp1->phiargs, i, phi1op) + FOR_EACH_VEC_ELT (vp1->phiargs, i, phi1op) { if (phi1op == VN_TOP) continue; @@ -2458,15 +2444,15 @@ vn_phi_eq (const void *p1, const void *p2) /* If the PHI nodes do not have compatible types they are not the same. */ - if (!types_compatible_p (TREE_TYPE (VEC_index (tree, vp1->phiargs, 0)), - TREE_TYPE (VEC_index (tree, vp2->phiargs, 0)))) + if (!types_compatible_p (TREE_TYPE (vp1->phiargs[0]), + TREE_TYPE (vp2->phiargs[0]))) return false; /* Any phi in the same block will have it's arguments in the same edge order, because of how we store phi nodes. */ - FOR_EACH_VEC_ELT (tree, vp1->phiargs, i, phi1op) + FOR_EACH_VEC_ELT (vp1->phiargs, i, phi1op) { - tree phi2op = VEC_index (tree, vp2->phiargs, i); + tree phi2op = vp2->phiargs[i]; if (phi1op == VN_TOP || phi2op == VN_TOP) continue; if (!expressions_equal_p (phi1op, phi2op)) @@ -2477,7 +2463,7 @@ vn_phi_eq (const void *p1, const void *p2) return false; } -static VEC(tree, heap) *shared_lookup_phiargs; +static vec<tree> shared_lookup_phiargs; /* Lookup PHI in the current hash table, and return the resulting value number if it exists in the hash table. Return NULL_TREE if @@ -2490,14 +2476,14 @@ vn_phi_lookup (gimple phi) struct vn_phi_s vp1; unsigned i; - VEC_truncate (tree, shared_lookup_phiargs, 0); + shared_lookup_phiargs.truncate (0); /* Canonicalize the SSA_NAME's to their value number. */ for (i = 0; i < gimple_phi_num_args (phi); i++) { tree def = PHI_ARG_DEF (phi, i); def = TREE_CODE (def) == SSA_NAME ? SSA_VAL (def) : def; - VEC_safe_push (tree, heap, shared_lookup_phiargs, def); + shared_lookup_phiargs.safe_push (def); } vp1.phiargs = shared_lookup_phiargs; vp1.block = gimple_bb (phi); @@ -2521,14 +2507,14 @@ vn_phi_insert (gimple phi, tree result) void **slot; vn_phi_t vp1 = (vn_phi_t) pool_alloc (current_info->phis_pool); unsigned i; - VEC (tree, heap) *args = NULL; + vec<tree> args = vec<tree>(); /* Canonicalize the SSA_NAME's to their value number. */ for (i = 0; i < gimple_phi_num_args (phi); i++) { tree def = PHI_ARG_DEF (phi, i); def = TREE_CODE (def) == SSA_NAME ? SSA_VAL (def) : def; - VEC_safe_push (tree, heap, args, def); + args.safe_push (def); } vp1->value_id = VN_INFO (result)->value_id; vp1->phiargs = args; @@ -2549,13 +2535,13 @@ vn_phi_insert (gimple phi, tree result) /* Print set of components in strongly connected component SCC to OUT. */ static void -print_scc (FILE *out, VEC (tree, heap) *scc) +print_scc (FILE *out, vec<tree> scc) { tree var; unsigned int i; fprintf (out, "SCC consists of:"); - FOR_EACH_VEC_ELT (tree, scc, i, var) + FOR_EACH_VEC_ELT (scc, i, var) { fprintf (out, " "); print_generic_expr (out, var, 0); @@ -3557,9 +3543,9 @@ compare_ops (const void *pa, const void *pb) array will give you the members in RPO order. */ static void -sort_scc (VEC (tree, heap) *scc) +sort_scc (vec<tree> scc) { - VEC_qsort (tree, scc, compare_ops); + scc.qsort (compare_ops); } /* Insert the no longer used nary ONARY to the hash INFO. */ @@ -3582,7 +3568,7 @@ copy_phi (vn_phi_t ophi, vn_tables_t info) vn_phi_t phi = (vn_phi_t) pool_alloc (info->phis_pool); void **slot; memcpy (phi, ophi, sizeof (*phi)); - ophi->phiargs = NULL; + ophi->phiargs.create (0); slot = htab_find_slot_with_hash (info->phis, phi, phi->hashcode, INSERT); gcc_assert (!*slot); *slot = phi; @@ -3597,7 +3583,7 @@ copy_reference (vn_reference_t oref, vn_tables_t info) void **slot; ref = (vn_reference_t) pool_alloc (info->references_pool); memcpy (ref, oref, sizeof (*ref)); - oref->operands = NULL; + oref->operands.create (0); slot = htab_find_slot_with_hash (info->references, ref, ref->hashcode, INSERT); if (*slot) @@ -3608,7 +3594,7 @@ copy_reference (vn_reference_t oref, vn_tables_t info) /* Process a strongly connected component in the SSA graph. */ static void -process_scc (VEC (tree, heap) *scc) +process_scc (vec<tree> scc) { tree var; unsigned int i; @@ -3620,9 +3606,9 @@ process_scc (VEC (tree, heap) *scc) vn_reference_t ref; /* If the SCC has a single member, just visit it. */ - if (VEC_length (tree, scc) == 1) + if (scc.length () == 1) { - tree use = VEC_index (tree, scc, 0); + tree use = scc[0]; if (VN_INFO (use)->use_processed) return; /* We need to make sure it doesn't form a cycle itself, which can @@ -3658,9 +3644,9 @@ process_scc (VEC (tree, heap) *scc) gcc_obstack_init (&optimistic_info->nary_obstack); empty_alloc_pool (optimistic_info->phis_pool); empty_alloc_pool (optimistic_info->references_pool); - FOR_EACH_VEC_ELT (tree, scc, i, var) + FOR_EACH_VEC_ELT (scc, i, var) VN_INFO (var)->expr = NULL_TREE; - FOR_EACH_VEC_ELT (tree, scc, i, var) + FOR_EACH_VEC_ELT (scc, i, var) changed |= visit_use (var); } @@ -3678,8 +3664,6 @@ process_scc (VEC (tree, heap) *scc) current_info = valid_info; } -DEF_VEC_O(ssa_op_iter); -DEF_VEC_ALLOC_O(ssa_op_iter,heap); /* Pop the components of the found SCC for NAME off the SCC stack and process them. Returns true if all went well, false if @@ -3688,33 +3672,33 @@ DEF_VEC_ALLOC_O(ssa_op_iter,heap); static bool extract_and_process_scc_for_name (tree name) { - VEC (tree, heap) *scc = NULL; + vec<tree> scc = vec<tree>(); tree x; /* Found an SCC, pop the components off the SCC stack and process them. */ do { - x = VEC_pop (tree, sccstack); + x = sccstack.pop (); VN_INFO (x)->on_sccstack = false; - VEC_safe_push (tree, heap, scc, x); + scc.safe_push (x); } while (x != name); /* Bail out of SCCVN in case a SCC turns out to be incredibly large. */ - if (VEC_length (tree, scc) + if (scc.length () > (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE)) { if (dump_file) fprintf (dump_file, "WARNING: Giving up with SCCVN due to " - "SCC size %u exceeding %u\n", VEC_length (tree, scc), + "SCC size %u exceeding %u\n", scc.length (), (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE)); - VEC_free (tree, heap, scc); + scc.release (); return false; } - if (VEC_length (tree, scc) > 1) + if (scc.length () > 1) sort_scc (scc); if (dump_file && (dump_flags & TDF_DETAILS)) @@ -3722,7 +3706,7 @@ extract_and_process_scc_for_name (tree name) process_scc (scc); - VEC_free (tree, heap, scc); + scc.release (); return true; } @@ -3737,8 +3721,8 @@ extract_and_process_scc_for_name (tree name) static bool DFS (tree name) { - VEC(ssa_op_iter, heap) *itervec = NULL; - VEC(tree, heap) *namevec = NULL; + vec<ssa_op_iter> itervec = vec<ssa_op_iter>(); + vec<tree> namevec = vec<tree>(); use_operand_p usep = NULL; gimple defstmt; tree use; @@ -3750,7 +3734,7 @@ start_over: VN_INFO (name)->visited = true; VN_INFO (name)->low = VN_INFO (name)->dfsnum; - VEC_safe_push (tree, heap, sccstack, name); + sccstack.safe_push (name); VN_INFO (name)->on_sccstack = true; defstmt = SSA_NAME_DEF_STMT (name); @@ -3776,25 +3760,25 @@ start_over: if (VN_INFO (name)->low == VN_INFO (name)->dfsnum) if (!extract_and_process_scc_for_name (name)) { - VEC_free (tree, heap, namevec); - VEC_free (ssa_op_iter, heap, itervec); + namevec.release (); + itervec.release (); return false; } /* Check if we are done. */ - if (VEC_empty (tree, namevec)) + if (namevec.is_empty ()) { - VEC_free (tree, heap, namevec); - VEC_free (ssa_op_iter, heap, itervec); + namevec.release (); + itervec.release (); return true; } /* Restore the last use walker and continue walking there. */ use = name; - name = VEC_pop (tree, namevec); - memcpy (&iter, &VEC_last (ssa_op_iter, itervec), + name = namevec.pop (); + memcpy (&iter, &itervec.last (), sizeof (ssa_op_iter)); - VEC_pop (ssa_op_iter, itervec); + itervec.pop (); goto continue_walking; } @@ -3808,8 +3792,8 @@ start_over: { /* Recurse by pushing the current use walking state on the stack and starting over. */ - VEC_safe_push(ssa_op_iter, heap, itervec, iter); - VEC_safe_push(tree, heap, namevec, name); + itervec.safe_push (iter); + namevec.safe_push (name); name = use; goto start_over; @@ -3869,7 +3853,7 @@ init_scc_vn (void) int *rpo_numbers_temp; calculate_dominance_info (CDI_DOMINATORS); - sccstack = NULL; + sccstack.create (0); constant_to_value_id = htab_create (23, vn_constant_hash, vn_constant_eq, free); @@ -3878,15 +3862,14 @@ init_scc_vn (void) next_dfs_num = 1; next_value_id = 1; - vn_ssa_aux_table = VEC_alloc (vn_ssa_aux_t, heap, num_ssa_names + 1); + vn_ssa_aux_table.create (num_ssa_names + 1); /* VEC_alloc doesn't actually grow it to the right size, it just preallocates the space to do so. */ - VEC_safe_grow_cleared (vn_ssa_aux_t, heap, vn_ssa_aux_table, - num_ssa_names + 1); + vn_ssa_aux_table.safe_grow_cleared (num_ssa_names + 1); gcc_obstack_init (&vn_ssa_aux_obstack); - shared_lookup_phiargs = NULL; - shared_lookup_references = NULL; + shared_lookup_phiargs.create (0); + shared_lookup_references.create (0); rpo_numbers = XNEWVEC (int, last_basic_block); rpo_numbers_temp = XNEWVEC (int, n_basic_blocks - NUM_FIXED_BLOCKS); pre_and_rev_post_order_compute (NULL, rpo_numbers_temp, false); @@ -3930,8 +3913,8 @@ free_scc_vn (void) htab_delete (constant_to_value_id); BITMAP_FREE (constant_value_ids); - VEC_free (tree, heap, shared_lookup_phiargs); - VEC_free (vn_reference_op_s, heap, shared_lookup_references); + shared_lookup_phiargs.release (); + shared_lookup_references.release (); XDELETEVEC (rpo_numbers); for (i = 0; i < num_ssa_names; i++) @@ -3942,9 +3925,9 @@ free_scc_vn (void) release_ssa_name (name); } obstack_free (&vn_ssa_aux_obstack, NULL); - VEC_free (vn_ssa_aux_t, heap, vn_ssa_aux_table); + vn_ssa_aux_table.release (); - VEC_free (tree, heap, sccstack); + sccstack.release (); free_vn_table (valid_info); XDELETE (valid_info); free_vn_table (optimistic_info); |