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-loop-distribution.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-loop-distribution.c')
-rw-r--r-- | gcc/tree-loop-distribution.c | 210 |
1 files changed, 108 insertions, 102 deletions
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 0ade107..a0a766b 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -64,8 +64,6 @@ typedef struct partition_s data_reference_p secondary_dr; } *partition_t; -DEF_VEC_P (partition_t); -DEF_VEC_ALLOC_P (partition_t, heap); /* Allocate and initialize a partition from BITMAP. */ @@ -618,11 +616,12 @@ mark_nodes_having_upstream_mem_writes (struct graph *rdg) if (!bitmap_bit_p (seen, v)) { unsigned i; - VEC (int, heap) *nodes = VEC_alloc (int, heap, 3); + vec<int> nodes; + nodes.create (3); graphds_dfs (rdg, &v, 1, &nodes, false, NULL); - FOR_EACH_VEC_ELT (int, nodes, i, x) + FOR_EACH_VEC_ELT (nodes, i, x) { if (!bitmap_set_bit (seen, x)) continue; @@ -638,7 +637,7 @@ mark_nodes_having_upstream_mem_writes (struct graph *rdg) } } - VEC_free (int, heap, nodes); + nodes.release (); } } @@ -749,7 +748,8 @@ rdg_flag_vertex_and_dependent (struct graph *rdg, int v, partition_t partition, bitmap loops, bitmap processed) { unsigned i; - VEC (int, heap) *nodes = VEC_alloc (int, heap, 3); + vec<int> nodes; + nodes.create (3); int x; bitmap_set_bit (processed, v); @@ -757,32 +757,32 @@ rdg_flag_vertex_and_dependent (struct graph *rdg, int v, partition_t partition, graphds_dfs (rdg, &v, 1, &nodes, false, remaining_stmts); rdg_flag_vertex (rdg, v, partition, loops); - FOR_EACH_VEC_ELT (int, nodes, i, x) + FOR_EACH_VEC_ELT (nodes, i, x) if (!already_processed_vertex_p (processed, x)) rdg_flag_vertex_and_dependent (rdg, x, partition, loops, processed); - VEC_free (int, heap, nodes); + nodes.release (); } /* Initialize CONDS with all the condition statements from the basic blocks of LOOP. */ static void -collect_condition_stmts (struct loop *loop, VEC (gimple, heap) **conds) +collect_condition_stmts (struct loop *loop, vec<gimple> *conds) { unsigned i; edge e; - VEC (edge, heap) *exits = get_loop_exit_edges (loop); + vec<edge> exits = get_loop_exit_edges (loop); - FOR_EACH_VEC_ELT (edge, exits, i, e) + FOR_EACH_VEC_ELT (exits, i, e) { gimple cond = last_stmt (e->src); if (cond) - VEC_safe_push (gimple, heap, *conds, cond); + conds->safe_push (cond); } - VEC_free (edge, heap, exits); + exits.release (); } /* Add to PARTITION all the exit condition statements for LOOPS @@ -795,14 +795,15 @@ rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition, { unsigned i; bitmap_iterator bi; - VEC (gimple, heap) *conds = VEC_alloc (gimple, heap, 3); + vec<gimple> conds; + conds.create (3); EXECUTE_IF_SET_IN_BITMAP (loops, 0, i, bi) collect_condition_stmts (get_loop (i), &conds); - while (!VEC_empty (gimple, conds)) + while (!conds.is_empty ()) { - gimple cond = VEC_pop (gimple, conds); + gimple cond = conds.pop (); int v = rdg_vertex_for_stmt (rdg, cond); bitmap new_loops = BITMAP_ALLOC (NULL); @@ -816,7 +817,7 @@ rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition, BITMAP_FREE (new_loops); } - VEC_free (gimple, heap, conds); + conds.release (); } /* Returns a bitmap in which all the statements needed for computing @@ -831,7 +832,7 @@ build_rdg_partition_for_component (struct graph *rdg, rdgc c) bitmap loops = BITMAP_ALLOC (NULL); bitmap processed = BITMAP_ALLOC (NULL); - FOR_EACH_VEC_ELT (int, c->vertices, i, v) + FOR_EACH_VEC_ELT (c->vertices, i, v) if (!already_processed_vertex_p (processed, v)) rdg_flag_vertex_and_dependent (rdg, v, partition, loops, processed); @@ -845,39 +846,42 @@ build_rdg_partition_for_component (struct graph *rdg, rdgc c) /* Free memory for COMPONENTS. */ static void -free_rdg_components (VEC (rdgc, heap) *components) +free_rdg_components (vec<rdgc> components) { int i; rdgc x; - FOR_EACH_VEC_ELT (rdgc, components, i, x) + FOR_EACH_VEC_ELT (components, i, x) { - VEC_free (int, heap, x->vertices); + x->vertices.release (); free (x); } - VEC_free (rdgc, heap, components); + components.release (); } /* Build the COMPONENTS vector with the strongly connected components of RDG in which the STARTING_VERTICES occur. */ static void -rdg_build_components (struct graph *rdg, VEC (int, heap) *starting_vertices, - VEC (rdgc, heap) **components) +rdg_build_components (struct graph *rdg, vec<int> starting_vertices, + vec<rdgc> *components) { int i, v; bitmap saved_components = BITMAP_ALLOC (NULL); int n_components = graphds_scc (rdg, NULL); - VEC (int, heap) **all_components = XNEWVEC (VEC (int, heap) *, n_components); + /* ??? Macros cannot process template types with more than one + argument, so we need this typedef. */ + typedef vec<int> vec_int_heap; + vec<int> *all_components = XNEWVEC (vec_int_heap, n_components); for (i = 0; i < n_components; i++) - all_components[i] = VEC_alloc (int, heap, 3); + all_components[i].create (3); for (i = 0; i < rdg->n_vertices; i++) - VEC_safe_push (int, heap, all_components[rdg->vertices[i].component], i); + all_components[rdg->vertices[i].component].safe_push (i); - FOR_EACH_VEC_ELT (int, starting_vertices, i, v) + FOR_EACH_VEC_ELT (starting_vertices, i, v) { int c = rdg->vertices[v].component; @@ -887,13 +891,13 @@ rdg_build_components (struct graph *rdg, VEC (int, heap) *starting_vertices, x->num = c; x->vertices = all_components[c]; - VEC_safe_push (rdgc, heap, *components, x); + components->safe_push (x); } } for (i = 0; i < n_components; i++) if (!bitmap_bit_p (saved_components, i)) - VEC_free (int, heap, all_components[i]); + all_components[i].release (); free (all_components); BITMAP_FREE (saved_components); @@ -962,8 +966,7 @@ classify_partition (loop_p loop, struct graph *rdg, partition_t partition) return; /* But exactly one store and/or load. */ - for (j = 0; - VEC_iterate (data_reference_p, RDG_DATAREFS (rdg, i), j, dr); ++j) + for (j = 0; RDG_DATAREFS (rdg, i).iterate (j, &dr); ++j) { if (DR_IS_READ (dr)) { @@ -1017,16 +1020,16 @@ classify_partition (loop_p loop, struct graph *rdg, partition_t partition) return; /* Now check that if there is a dependence this dependence is of a suitable form for memmove. */ - VEC(loop_p, heap) *loops = NULL; + vec<loop_p> loops = vec<loop_p>(); ddr_p ddr; - VEC_safe_push (loop_p, heap, loops, loop); + loops.safe_push (loop); ddr = initialize_data_dependence_relation (single_load, single_store, loops); compute_affine_dependence (ddr, loop); if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know) { free_dependence_relation (ddr); - VEC_free (loop_p, heap, loops); + loops.release (); return; } if (DDR_ARE_DEPENDENT (ddr) != chrec_known) @@ -1034,24 +1037,24 @@ classify_partition (loop_p loop, struct graph *rdg, partition_t partition) if (DDR_NUM_DIST_VECTS (ddr) == 0) { free_dependence_relation (ddr); - VEC_free (loop_p, heap, loops); + loops.release (); return; } lambda_vector dist_v; - FOR_EACH_VEC_ELT (lambda_vector, DDR_DIST_VECTS (ddr), i, dist_v) + FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), i, dist_v) { int dist = dist_v[index_in_loop_nest (loop->num, DDR_LOOP_NEST (ddr))]; if (dist > 0 && !DDR_REVERSED_P (ddr)) { free_dependence_relation (ddr); - VEC_free (loop_p, heap, loops); + loops.release (); return; } } } free_dependence_relation (ddr); - VEC_free (loop_p, heap, loops); + loops.release (); partition->kind = PKIND_MEMCPY; partition->main_dr = single_store; partition->secondary_dr = single_load; @@ -1099,12 +1102,11 @@ similar_memory_accesses (struct graph *rdg, partition_t partition1, if (RDG_MEM_WRITE_STMT (rdg, j) || RDG_MEM_READS_STMT (rdg, j)) { - FOR_EACH_VEC_ELT (data_reference_p, RDG_DATAREFS (rdg, i), k, ref1) + FOR_EACH_VEC_ELT (RDG_DATAREFS (rdg, i), k, ref1) { tree base1 = ref_base_address (ref1); if (base1) - FOR_EACH_VEC_ELT (data_reference_p, - RDG_DATAREFS (rdg, j), l, ref2) + FOR_EACH_VEC_ELT (RDG_DATAREFS (rdg, j), l, ref2) if (base1 == ref_base_address (ref2)) return true; } @@ -1118,18 +1120,18 @@ similar_memory_accesses (struct graph *rdg, partition_t partition1, distributed in different loops. */ static void -rdg_build_partitions (struct graph *rdg, VEC (rdgc, heap) *components, - VEC (int, heap) **other_stores, - VEC (partition_t, heap) **partitions, bitmap processed) +rdg_build_partitions (struct graph *rdg, vec<rdgc> components, + vec<int> *other_stores, + vec<partition_t> *partitions, bitmap processed) { int i; rdgc x; partition_t partition = partition_alloc (NULL); - FOR_EACH_VEC_ELT (rdgc, components, i, x) + FOR_EACH_VEC_ELT (components, i, x) { partition_t np; - int v = VEC_index (int, x->vertices, 0); + int v = x->vertices[0]; if (bitmap_bit_p (processed, v)) continue; @@ -1148,7 +1150,7 @@ rdg_build_partitions (struct graph *rdg, VEC (rdgc, heap) *components, dump_bitmap (dump_file, partition->stmts); } - VEC_safe_push (partition_t, heap, *partitions, partition); + partitions->safe_push (partition); partition = partition_alloc (NULL); } } @@ -1159,26 +1161,28 @@ rdg_build_partitions (struct graph *rdg, VEC (rdgc, heap) *components, for (i = 0; i < rdg->n_vertices; i++) if (!bitmap_bit_p (processed, i) && rdg_defs_used_in_other_loops_p (rdg, i)) - VEC_safe_push (int, heap, *other_stores, i); + other_stores->safe_push (i); /* If there are still statements left in the OTHER_STORES array, create other components and partitions with these stores and their dependences. */ - if (VEC_length (int, *other_stores) > 0) + if (other_stores->length () > 0) { - VEC (rdgc, heap) *comps = VEC_alloc (rdgc, heap, 3); - VEC (int, heap) *foo = VEC_alloc (int, heap, 3); + vec<rdgc> comps; + comps.create (3); + vec<int> foo; + foo.create (3); rdg_build_components (rdg, *other_stores, &comps); rdg_build_partitions (rdg, comps, &foo, partitions, processed); - VEC_free (int, heap, foo); + foo.release (); free_rdg_components (comps); } /* If there is something left in the last partition, save it. */ if (bitmap_count_bits (partition->stmts) > 0) - VEC_safe_push (partition_t, heap, *partitions, partition); + partitions->safe_push (partition); else partition_free (partition); } @@ -1186,20 +1190,20 @@ rdg_build_partitions (struct graph *rdg, VEC (rdgc, heap) *components, /* Dump to FILE the PARTITIONS. */ static void -dump_rdg_partitions (FILE *file, VEC (partition_t, heap) *partitions) +dump_rdg_partitions (FILE *file, vec<partition_t> partitions) { int i; partition_t partition; - FOR_EACH_VEC_ELT (partition_t, partitions, i, partition) + FOR_EACH_VEC_ELT (partitions, i, partition) debug_bitmap_file (file, partition->stmts); } /* Debug PARTITIONS. */ -extern void debug_rdg_partitions (VEC (partition_t, heap) *); +extern void debug_rdg_partitions (vec<partition_t> ); DEBUG_FUNCTION void -debug_rdg_partitions (VEC (partition_t, heap) *partitions) +debug_rdg_partitions (vec<partition_t> partitions) { dump_rdg_partitions (stderr, partitions); } @@ -1249,13 +1253,14 @@ number_of_rw_in_partition (struct graph *rdg, partition_t partition) write operations of RDG. */ static bool -partition_contains_all_rw (struct graph *rdg, VEC (partition_t, heap) *partitions) +partition_contains_all_rw (struct graph *rdg, + vec<partition_t> partitions) { int i; partition_t partition; int nrw = number_of_rw_in_rdg (rdg); - FOR_EACH_VEC_ELT (partition_t, partitions, i, partition) + FOR_EACH_VEC_ELT (partitions, i, partition) if (nrw == number_of_rw_in_partition (rdg, partition)) return true; @@ -1267,12 +1272,15 @@ partition_contains_all_rw (struct graph *rdg, VEC (partition_t, heap) *partition static int ldist_gen (struct loop *loop, struct graph *rdg, - VEC (int, heap) *starting_vertices) + vec<int> starting_vertices) { int i, nbp; - VEC (rdgc, heap) *components = VEC_alloc (rdgc, heap, 3); - VEC (partition_t, heap) *partitions = VEC_alloc (partition_t, heap, 3); - VEC (int, heap) *other_stores = VEC_alloc (int, heap, 3); + vec<rdgc> components; + components.create (3); + vec<partition_t> partitions; + partitions.create (3); + vec<int> other_stores; + other_stores.create (3); partition_t partition; bitmap processed = BITMAP_ALLOC (NULL); bool any_builtin; @@ -1292,7 +1300,7 @@ ldist_gen (struct loop *loop, struct graph *rdg, unsigned j; bool found = false; - FOR_EACH_VEC_ELT (int, starting_vertices, j, v) + FOR_EACH_VEC_ELT (starting_vertices, j, v) if (i == v) { found = true; @@ -1300,7 +1308,7 @@ ldist_gen (struct loop *loop, struct graph *rdg, } if (!found) - VEC_safe_push (int, heap, other_stores, i); + other_stores.safe_push (i); } } @@ -1311,7 +1319,7 @@ ldist_gen (struct loop *loop, struct graph *rdg, BITMAP_FREE (processed); any_builtin = false; - FOR_EACH_VEC_ELT (partition_t, partitions, i, partition) + FOR_EACH_VEC_ELT (partitions, i, partition) { classify_partition (loop, rdg, partition); any_builtin |= partition_builtin_p (partition); @@ -1334,31 +1342,31 @@ ldist_gen (struct loop *loop, struct graph *rdg, i = 0; do { - for (; VEC_iterate (partition_t, partitions, i, into); ++i) + for (; partitions.iterate (i, &into); ++i) if (!partition_builtin_p (into)) break; - for (++i; VEC_iterate (partition_t, partitions, i, partition); ++i) + for (++i; partitions.iterate (i, &partition); ++i) if (!partition_builtin_p (partition)) { bitmap_ior_into (into->stmts, partition->stmts); - VEC_ordered_remove (partition_t, partitions, i); + partitions.ordered_remove (i); i--; } else break; } - while ((unsigned) i < VEC_length (partition_t, partitions)); + while ((unsigned) i < partitions.length ()); } else { partition_t into; int j; - for (i = 0; VEC_iterate (partition_t, partitions, i, into); ++i) + for (i = 0; partitions.iterate (i, &into); ++i) { if (partition_builtin_p (into)) continue; for (j = i + 1; - VEC_iterate (partition_t, partitions, j, partition); ++j) + partitions.iterate (j, &partition); ++j) { if (!partition_builtin_p (partition) /* ??? The following is horribly inefficient, @@ -1375,19 +1383,17 @@ ldist_gen (struct loop *loop, struct graph *rdg, "memory accesses\n"); } bitmap_ior_into (into->stmts, partition->stmts); - VEC_ordered_remove (partition_t, partitions, j); + partitions.ordered_remove (j); j--; } } } } - nbp = VEC_length (partition_t, partitions); + nbp = partitions.length (); if (nbp == 0 - || (nbp == 1 - && !partition_builtin_p (VEC_index (partition_t, partitions, 0))) - || (nbp > 1 - && partition_contains_all_rw (rdg, partitions))) + || (nbp == 1 && !partition_builtin_p (partitions[0])) + || (nbp > 1 && partition_contains_all_rw (rdg, partitions))) { nbp = 0; goto ldist_done; @@ -1396,7 +1402,7 @@ ldist_gen (struct loop *loop, struct graph *rdg, if (dump_file && (dump_flags & TDF_DETAILS)) dump_rdg_partitions (dump_file, partitions); - FOR_EACH_VEC_ELT (partition_t, partitions, i, partition) + FOR_EACH_VEC_ELT (partitions, i, partition) generate_code_for_partition (loop, partition, i < nbp - 1); ldist_done: @@ -1404,11 +1410,11 @@ ldist_gen (struct loop *loop, struct graph *rdg, BITMAP_FREE (remaining_stmts); BITMAP_FREE (upstream_mem_writes); - FOR_EACH_VEC_ELT (partition_t, partitions, i, partition) + FOR_EACH_VEC_ELT (partitions, i, partition) partition_free (partition); - VEC_free (int, heap, other_stores); - VEC_free (partition_t, heap, partitions); + other_stores.release (); + partitions.release (); free_rdg_components (components); return nbp; } @@ -1420,20 +1426,20 @@ ldist_gen (struct loop *loop, struct graph *rdg, Returns the number of distributed loops. */ static int -distribute_loop (struct loop *loop, VEC (gimple, heap) *stmts) +distribute_loop (struct loop *loop, vec<gimple> stmts) { int res = 0; struct graph *rdg; gimple s; unsigned i; - VEC (int, heap) *vertices; - VEC (ddr_p, heap) *dependence_relations; - VEC (data_reference_p, heap) *datarefs; - VEC (loop_p, heap) *loop_nest; - - datarefs = VEC_alloc (data_reference_p, heap, 10); - dependence_relations = VEC_alloc (ddr_p, heap, 100); - loop_nest = VEC_alloc (loop_p, heap, 3); + vec<int> vertices; + vec<ddr_p> dependence_relations; + vec<data_reference_p> datarefs; + vec<loop_p> loop_nest; + + datarefs.create (10); + dependence_relations.create (100); + loop_nest.create (3); rdg = build_rdg (loop, &loop_nest, &dependence_relations, &datarefs); if (!rdg) @@ -1445,22 +1451,22 @@ distribute_loop (struct loop *loop, VEC (gimple, heap) *stmts) free_dependence_relations (dependence_relations); free_data_refs (datarefs); - VEC_free (loop_p, heap, loop_nest); + loop_nest.release (); return res; } - vertices = VEC_alloc (int, heap, 3); + vertices.create (3); if (dump_file && (dump_flags & TDF_DETAILS)) dump_rdg (dump_file, rdg); - FOR_EACH_VEC_ELT (gimple, stmts, i, s) + FOR_EACH_VEC_ELT (stmts, i, s) { int v = rdg_vertex_for_stmt (rdg, s); if (v >= 0) { - VEC_safe_push (int, heap, vertices, v); + vertices.safe_push (v); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, @@ -1469,11 +1475,11 @@ distribute_loop (struct loop *loop, VEC (gimple, heap) *stmts) } res = ldist_gen (loop, rdg, vertices); - VEC_free (int, heap, vertices); + vertices.release (); free_rdg (rdg); free_dependence_relations (dependence_relations); free_data_refs (datarefs); - VEC_free (loop_p, heap, loop_nest); + loop_nest.release (); return res; } @@ -1500,7 +1506,7 @@ tree_loop_distribution (void) walking to innermost loops. */ FOR_EACH_LOOP (li, loop, LI_ONLY_INNERMOST) { - VEC (gimple, heap) *work_list = NULL; + vec<gimple> work_list = vec<gimple>(); basic_block *bbs; int num = loop->num; int nb_generated_loops = 0; @@ -1534,12 +1540,12 @@ tree_loop_distribution (void) || is_gimple_reg (gimple_assign_lhs (stmt))) continue; - VEC_safe_push (gimple, heap, work_list, stmt); + work_list.safe_push (stmt); } } free (bbs); - if (VEC_length (gimple, work_list) > 0) + if (work_list.length () > 0) nb_generated_loops = distribute_loop (loop, work_list); if (nb_generated_loops > 0) @@ -1554,7 +1560,7 @@ tree_loop_distribution (void) fprintf (dump_file, "Loop %d is the same.\n", num); } - VEC_free (gimple, heap, work_list); + work_list.release (); } if (changed) |