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/config | |
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/config')
-rw-r--r-- | gcc/config/bfin/bfin.c | 8 | ||||
-rw-r--r-- | gcc/config/c6x/c6x.c | 43 | ||||
-rw-r--r-- | gcc/config/darwin.c | 28 | ||||
-rw-r--r-- | gcc/config/epiphany/resolve-sw-modes.c | 14 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 20 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.c | 27 | ||||
-rw-r--r-- | gcc/config/mep/mep.c | 86 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 19 | ||||
-rw-r--r-- | gcc/config/pa/pa.c | 47 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000-c.c | 26 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 16 | ||||
-rw-r--r-- | gcc/config/rx/rx.c | 70 | ||||
-rw-r--r-- | gcc/config/spu/spu-c.c | 6 | ||||
-rw-r--r-- | gcc/config/vms/vms.c | 4 | ||||
-rw-r--r-- | gcc/config/vxworks.c | 9 |
15 files changed, 204 insertions, 219 deletions
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 2c01cf7..f2d8473 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -3480,8 +3480,8 @@ hwloop_optimize (hwloop_info loop) insn = BB_END (loop->incoming_src); /* If we have to insert the LSETUP before a jump, count that jump in the length. */ - if (VEC_length (edge, loop->incoming) > 1 - || !(VEC_last (edge, loop->incoming)->flags & EDGE_FALLTHRU)) + if (vec_safe_length (loop->incoming) > 1 + || !(loop->incoming->last ()->flags & EDGE_FALLTHRU)) { gcc_assert (JUMP_P (insn)); insn = PREV_INSN (insn); @@ -3749,8 +3749,8 @@ hwloop_optimize (hwloop_info loop) if (loop->incoming_src) { rtx prev = BB_END (loop->incoming_src); - if (VEC_length (edge, loop->incoming) > 1 - || !(VEC_last (edge, loop->incoming)->flags & EDGE_FALLTHRU)) + if (vec_safe_length (loop->incoming) > 1 + || !(loop->incoming->last ()->flags & EDGE_FALLTHRU)) { gcc_assert (JUMP_P (prev)); prev = PREV_INSN (prev); diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index 32807d8..175e119 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -119,14 +119,12 @@ typedef struct unsigned int unit_mask; } c6x_sched_insn_info; -DEF_VEC_O(c6x_sched_insn_info); -DEF_VEC_ALLOC_O(c6x_sched_insn_info, heap); /* Record a c6x_sched_insn_info structure for every insn in the function. */ -static VEC(c6x_sched_insn_info, heap) *insn_info; +static vec<c6x_sched_insn_info> insn_info; -#define INSN_INFO_LENGTH (VEC_length (c6x_sched_insn_info, insn_info)) -#define INSN_INFO_ENTRY(N) (VEC_index (c6x_sched_insn_info, insn_info, (N))) +#define INSN_INFO_LENGTH (insn_info).length () +#define INSN_INFO_ENTRY(N) (insn_info[(N)]) static bool done_cfi_sections; @@ -1971,7 +1969,7 @@ c6x_get_unit_specifier (rtx insn) { enum attr_units units; - if (insn_info) + if (insn_info.exists ()) { int unit = INSN_INFO_ENTRY (INSN_UID (insn)).reservation; return c6x_unit_names[unit][0]; @@ -2023,7 +2021,7 @@ c6x_print_unit_specifier_field (FILE *file, rtx insn) return; } - if (insn_info) + if (insn_info.exists ()) { int unit = INSN_INFO_ENTRY (INSN_UID (insn)).reservation; fputs (".", file); @@ -3422,7 +3420,7 @@ try_rename_operands (rtx head, rtx tail, unit_req_table reqs, rtx insn, int i; unsigned tmp_mask; int best_reg, old_reg; - VEC (du_head_p, heap) *involved_chains = NULL; + vec<du_head_p> involved_chains = vec<du_head_p>(); unit_req_table new_reqs; for (i = 0, tmp_mask = op_mask; tmp_mask; i++) @@ -3433,14 +3431,14 @@ try_rename_operands (rtx head, rtx tail, unit_req_table reqs, rtx insn, if (info->op_info[i].n_chains != 1) goto out_fail; op_chain = regrename_chain_from_id (info->op_info[i].heads[0]->id); - VEC_safe_push (du_head_p, heap, involved_chains, op_chain); + involved_chains.safe_push (op_chain); tmp_mask &= ~(1 << i); } - if (VEC_length (du_head_p, involved_chains) > 1) + if (involved_chains.length () > 1) goto out_fail; - this_head = VEC_index (du_head_p, involved_chains, 0); + this_head = involved_chains[0]; if (this_head->cannot_rename) goto out_fail; @@ -3448,8 +3446,7 @@ try_rename_operands (rtx head, rtx tail, unit_req_table reqs, rtx insn, { unsigned int mask1, mask2, mask_changed; int count, side1, side2, req1, req2; - insn_rr_info *this_rr = &VEC_index (insn_rr_info, insn_rr, - INSN_UID (chain->insn)); + insn_rr_info *this_rr = &insn_rr[INSN_UID (chain->insn)]; count = get_unit_reqs (chain->insn, &req1, &side1, &req2, &side2); @@ -3508,7 +3505,7 @@ try_rename_operands (rtx head, rtx tail, unit_req_table reqs, rtx insn, memcpy (reqs, new_reqs, sizeof (unit_req_table)); out_fail: - VEC_free (du_head_p, heap, involved_chains); + involved_chains.release (); } /* Find insns in LOOP which would, if shifted to the other side @@ -3555,7 +3552,7 @@ reshuffle_units (basic_block loop) if (!get_unit_operand_masks (insn, &mask1, &mask2)) continue; - info = &VEC_index (insn_rr_info, insn_rr, INSN_UID (insn)); + info = &insn_rr[INSN_UID (insn)]; if (info->op_info == NULL) continue; @@ -3707,7 +3704,7 @@ insn_set_clock (rtx insn, int cycle) unsigned uid = INSN_UID (insn); if (uid >= INSN_INFO_LENGTH) - VEC_safe_grow (c6x_sched_insn_info, heap, insn_info, uid * 5 / 4 + 10); + insn_info.safe_grow (uid * 5 / 4 + 10); INSN_INFO_ENTRY (uid).clock = cycle; INSN_INFO_ENTRY (uid).new_cond = NULL; @@ -4361,7 +4358,7 @@ c6x_variable_issue (FILE *dump ATTRIBUTE_UNUSED, ss.last_scheduled_iter0 = insn; if (GET_CODE (PATTERN (insn)) != USE && GET_CODE (PATTERN (insn)) != CLOBBER) ss.issued_this_cycle++; - if (insn_info) + if (insn_info.exists ()) { state_t st_after = alloca (dfa_state_size); int curr_clock = ss.curr_sched_clock; @@ -5537,7 +5534,7 @@ hwloop_optimize (hwloop_info loop) gcc_assert (loop->incoming_dest == loop->head); entry_edge = NULL; - FOR_EACH_VEC_ELT (edge, loop->incoming, i, entry_edge) + FOR_EACH_VEC_SAFE_ELT (loop->incoming, i, entry_edge) if (entry_edge->flags & EDGE_FALLTHRU) break; if (entry_edge == NULL) @@ -5777,7 +5774,7 @@ hwloop_optimize (hwloop_info loop) seq = get_insns (); - if (!single_succ_p (entry_bb) || VEC_length (edge, loop->incoming) > 1) + if (!single_succ_p (entry_bb) || vec_safe_length (loop->incoming) > 1) { basic_block new_bb; edge e; @@ -5809,7 +5806,7 @@ hwloop_optimize (hwloop_info loop) end_sequence (); /* Make sure we don't try to schedule this loop again. */ - for (ix = 0; VEC_iterate (basic_block, loop->blocks, ix, bb); ix++) + for (ix = 0; loop->blocks.iterate (ix, &bb); ix++) bb->flags |= BB_DISABLE_SCHEDULE; return true; @@ -5928,7 +5925,7 @@ c6x_reorg (void) { int sz = get_max_uid () * 3 / 2 + 1; - insn_info = VEC_alloc (c6x_sched_insn_info, heap, sz); + insn_info.create (sz); } /* Make sure the real-jump insns we create are not deleted. When modulo- @@ -5993,9 +5990,7 @@ c6x_function_end (FILE *file, const char *fname) { c6x_output_fn_unwind (file); - if (insn_info) - VEC_free (c6x_sched_insn_info, heap, insn_info); - insn_info = NULL; + insn_info.release (); if (!flag_inhibit_size_directive) ASM_OUTPUT_MEASURED_SIZE (file, fname); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index e56205b..6645270 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1791,10 +1791,8 @@ static unsigned int lto_section_num = 0; typedef struct GTY (()) darwin_lto_section_e { const char *sectname; } darwin_lto_section_e ; -DEF_VEC_O(darwin_lto_section_e); -DEF_VEC_ALLOC_O(darwin_lto_section_e, gc); -static GTY (()) VEC (darwin_lto_section_e, gc) * lto_section_names; +static GTY (()) vec<darwin_lto_section_e, va_gc> *lto_section_names; /* Segment for LTO data. */ #define LTO_SEGMENT_NAME "__GNU_LTO" @@ -1877,8 +1875,8 @@ darwin_asm_named_section (const char *name, TODO: check that we do not revisit sections, that would break the assumption of how this is done. */ if (lto_section_names == NULL) - lto_section_names = VEC_alloc (darwin_lto_section_e, gc, 16); - VEC_safe_push (darwin_lto_section_e, gc, lto_section_names, e); + vec_alloc (lto_section_names, 16); + vec_safe_push (lto_section_names, e); } else if (strncmp (name, "__DWARF,", 8) == 0) darwin_asm_dwarf_section (name, flags, decl); @@ -2635,7 +2633,7 @@ darwin_assemble_visibility (tree decl, int vis) "not supported in this configuration; ignored"); } -/* VEC Used by darwin_asm_dwarf_section. +/* vec used by darwin_asm_dwarf_section. Maybe a hash tab would be better here - but the intention is that this is a very short list (fewer than 16 items) and each entry should (ideally, eventually) only be presented once. @@ -2648,11 +2646,9 @@ typedef struct GTY(()) dwarf_sect_used_entry { } dwarf_sect_used_entry; -DEF_VEC_O(dwarf_sect_used_entry); -DEF_VEC_ALLOC_O(dwarf_sect_used_entry, gc); /* A list of used __DWARF sections. */ -static GTY (()) VEC (dwarf_sect_used_entry, gc) * dwarf_sect_names_table; +static GTY (()) vec<dwarf_sect_used_entry, va_gc> *dwarf_sect_names_table; /* This is called when we are asked to assemble a named section and the name begins with __DWARF,. We keep a list of the section names (without @@ -2675,10 +2671,10 @@ darwin_asm_dwarf_section (const char *name, unsigned int flags, namelen = strchr (sname, ',') - sname; gcc_assert (namelen); if (dwarf_sect_names_table == NULL) - dwarf_sect_names_table = VEC_alloc (dwarf_sect_used_entry, gc, 16); + vec_alloc (dwarf_sect_names_table, 16); else for (i = 0; - VEC_iterate (dwarf_sect_used_entry, dwarf_sect_names_table, i, ref); + dwarf_sect_names_table->iterate (i, &ref); i++) { if (!ref) @@ -2698,7 +2694,7 @@ darwin_asm_dwarf_section (const char *name, unsigned int flags, fprintf (asm_out_file, "Lsection%.*s:\n", namelen, sname); e.count = 1; e.name = xstrdup (sname); - VEC_safe_push (dwarf_sect_used_entry, gc, dwarf_sect_names_table, e); + vec_safe_push (dwarf_sect_names_table, e); } } @@ -2813,7 +2809,7 @@ darwin_file_end (void) } /* Output the names and indices. */ - if (lto_section_names && VEC_length (darwin_lto_section_e, lto_section_names)) + if (lto_section_names && lto_section_names->length ()) { int count; darwin_lto_section_e *ref; @@ -2824,7 +2820,7 @@ darwin_file_end (void) /* Emit the names. */ fprintf (asm_out_file, "\t.section %s,%s,regular,debug\n", LTO_SEGMENT_NAME, LTO_NAMES_SECTION); - FOR_EACH_VEC_ELT (darwin_lto_section_e, lto_section_names, count, ref) + FOR_EACH_VEC_ELT (*lto_section_names, count, ref) { fprintf (asm_out_file, "L_GNU_LTO_NAME%d:\n", count); /* We have to jump through hoops to get the values of the intra-section @@ -2847,7 +2843,7 @@ darwin_file_end (void) fputs ("\t.align\t2\n", asm_out_file); fputs ("# Section offset, Section length, Name offset, Name length\n", asm_out_file); - FOR_EACH_VEC_ELT (darwin_lto_section_e, lto_section_names, count, ref) + FOR_EACH_VEC_ELT (*lto_section_names, count, ref) { fprintf (asm_out_file, "%s L$gnu$lto$offs%d\t;# %s\n", op, count, ref->sectname); @@ -3338,7 +3334,7 @@ darwin_build_constant_cfstring (tree str) if (!desc) { tree var, constructor, field; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; int length = TREE_STRING_LENGTH (str) - 1; if (darwin_warn_nonportable_cfstrings) diff --git a/gcc/config/epiphany/resolve-sw-modes.c b/gcc/config/epiphany/resolve-sw-modes.c index ec0dfcc..9704553 100644 --- a/gcc/config/epiphany/resolve-sw-modes.c +++ b/gcc/config/epiphany/resolve-sw-modes.c @@ -56,12 +56,12 @@ resolve_sw_modes (void) { basic_block bb; rtx insn, src; - VEC (basic_block, heap) *todo; + vec<basic_block> todo; sbitmap pushed; bool need_commit = false; bool finalize_fp_sets = (MACHINE_FUNCTION (cfun)->unknown_mode_sets == 0); - todo = VEC_alloc (basic_block, heap, last_basic_block); + todo.create (last_basic_block); pushed = sbitmap_alloc (last_basic_block); bitmap_clear (pushed); if (!finalize_fp_sets) @@ -98,7 +98,7 @@ resolve_sw_modes (void) checking the total frequency of the affected edges. */ selected_mode = (enum attr_fp_mode) epiphany_normal_fp_rounding; - VEC_quick_push (basic_block, todo, bb); + todo.quick_push (bb); bitmap_set_bit (pushed, bb->index); } XVECEXP (XEXP (src, 0), 0, 0) = GEN_INT (selected_mode); @@ -106,9 +106,9 @@ resolve_sw_modes (void) SET_SRC (XVECEXP (PATTERN (insn), 0, 2)) = copy_rtx (src); df_insn_rescan (insn); } - while (VEC_length (basic_block, todo)) + while (todo.length ()) { - basic_block bb = VEC_pop (basic_block, todo); + basic_block bb = todo.pop (); int selected_reg, jilted_reg; enum attr_fp_mode jilted_mode; edge e; @@ -141,7 +141,7 @@ resolve_sw_modes (void) { if (bitmap_bit_p (pushed, succ->index)) continue; - VEC_quick_push (basic_block, todo, succ); + todo.quick_push (succ); bitmap_set_bit (pushed, bb->index); continue; } @@ -154,7 +154,7 @@ resolve_sw_modes (void) insert_insn_on_edge (seq, e); } } - VEC_free (basic_block, heap, todo); + todo.release (); sbitmap_free (pushed); if (need_commit) commit_edge_insertions (); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 03c6675..4bc105d 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -28737,7 +28737,7 @@ dispatch_function_versions (tree dispatch_decl, gimple_seq gseq; int ix; tree ele; - VEC (tree, heap) *fndecls; + vec<tree> *fndecls; unsigned int num_versions = 0; unsigned int actual_versions = 0; unsigned int i; @@ -28754,17 +28754,17 @@ dispatch_function_versions (tree dispatch_decl, && empty_bb != NULL); /*fndecls_p is actually a vector. */ - fndecls = (VEC (tree, heap) *)fndecls_p; + fndecls = static_cast<vec<tree> *> (fndecls_p); /* At least one more version other than the default. */ - num_versions = VEC_length (tree, fndecls); + num_versions = fndecls->length (); gcc_assert (num_versions >= 2); function_version_info = (struct _function_version_info *) XNEWVEC (struct _function_version_info, (num_versions - 1)); /* The first version in the vector is the default decl. */ - default_decl = VEC_index (tree, fndecls, 0); + default_decl = (*fndecls)[0]; push_cfun (DECL_STRUCT_FUNCTION (dispatch_decl)); @@ -28772,7 +28772,7 @@ dispatch_function_versions (tree dispatch_decl, /* Function version dispatch is via IFUNC. IFUNC resolvers fire before constructors, so explicity call __builtin_cpu_init here. */ ifunc_cpu_init_stmt = gimple_build_call_vec ( - ix86_builtins [(int) IX86_BUILTIN_CPU_INIT], NULL); + ix86_builtins [(int) IX86_BUILTIN_CPU_INIT], vec<tree>()); gimple_seq_add_stmt (&gseq, ifunc_cpu_init_stmt); gimple_set_bb (ifunc_cpu_init_stmt, *empty_bb); set_bb_seq (*empty_bb, gseq); @@ -28780,7 +28780,7 @@ dispatch_function_versions (tree dispatch_decl, pop_cfun (); - for (ix = 1; VEC_iterate (tree, fndecls, ix, ele); ++ix) + for (ix = 1; fndecls->iterate (ix, &ele); ++ix) { tree version_decl = ele; tree predicate_chain = NULL_TREE; @@ -29276,7 +29276,7 @@ ix86_generate_version_dispatcher_body (void *node_p) { tree resolver_decl; basic_block empty_bb; - VEC (tree, heap) *fn_ver_vec = NULL; + vec<tree> fn_ver_vec = vec<tree>(); tree default_ver_decl; struct cgraph_node *versn; struct cgraph_node *node; @@ -29306,7 +29306,7 @@ ix86_generate_version_dispatcher_body (void *node_p) push_cfun (DECL_STRUCT_FUNCTION (resolver_decl)); - fn_ver_vec = VEC_alloc (tree, heap, 2); + fn_ver_vec.create (2); for (versn_info = node_version_info->next; versn_info; versn_info = versn_info->next) @@ -29320,10 +29320,10 @@ ix86_generate_version_dispatcher_body (void *node_p) if (DECL_VINDEX (versn->symbol.decl)) error_at (DECL_SOURCE_LOCATION (versn->symbol.decl), "Virtual function multiversioning not supported"); - VEC_safe_push (tree, heap, fn_ver_vec, versn->symbol.decl); + fn_ver_vec.safe_push (versn->symbol.decl); } - dispatch_function_versions (resolver_decl, fn_ver_vec, &empty_bb); + dispatch_function_versions (resolver_decl, &fn_ver_vec, &empty_bb); rebuild_cgraph_edges (); pop_cfun (); diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 66f85de..9a7528f 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -5937,21 +5937,22 @@ ia64_option_override (void) { unsigned int i; cl_deferred_option *opt; - VEC(cl_deferred_option,heap) *vec - = (VEC(cl_deferred_option,heap) *) ia64_deferred_options; + vec<cl_deferred_option> *v + = (vec<cl_deferred_option> *) ia64_deferred_options; - FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt) - { - switch (opt->opt_index) - { - case OPT_mfixed_range_: - fix_range (opt->arg); - break; + if (v) + FOR_EACH_VEC_ELT (*v, i, opt) + { + switch (opt->opt_index) + { + case OPT_mfixed_range_: + fix_range (opt->arg); + break; - default: - gcc_unreachable (); - } - } + default: + gcc_unreachable (); + } + } if (TARGET_AUTO_PIC) target_flags |= MASK_CONST_GP; diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index 79611a8..a44e521 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -300,54 +300,54 @@ mep_option_override (void) unsigned int i; int j; cl_deferred_option *opt; - VEC(cl_deferred_option,heap) *vec - = (VEC(cl_deferred_option,heap) *) mep_deferred_options; + vec<cl_deferred_option> *v = (vec<cl_deferred_option> *) mep_deferred_options; - FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt) - { - switch (opt->opt_index) - { - case OPT_mivc2: - for (j = 0; j < 32; j++) - fixed_regs[j + 48] = 0; - for (j = 0; j < 32; j++) - call_used_regs[j + 48] = 1; - for (j = 6; j < 8; j++) - call_used_regs[j + 48] = 0; + if (v) + FOR_EACH_VEC_ELT (*v, i, opt) + { + switch (opt->opt_index) + { + case OPT_mivc2: + for (j = 0; j < 32; j++) + fixed_regs[j + 48] = 0; + for (j = 0; j < 32; j++) + call_used_regs[j + 48] = 1; + for (j = 6; j < 8; j++) + call_used_regs[j + 48] = 0; #define RN(n,s) reg_names[FIRST_CCR_REGNO + n] = s - RN (0, "$csar0"); - RN (1, "$cc"); - RN (4, "$cofr0"); - RN (5, "$cofr1"); - RN (6, "$cofa0"); - RN (7, "$cofa1"); - RN (15, "$csar1"); - - RN (16, "$acc0_0"); - RN (17, "$acc0_1"); - RN (18, "$acc0_2"); - RN (19, "$acc0_3"); - RN (20, "$acc0_4"); - RN (21, "$acc0_5"); - RN (22, "$acc0_6"); - RN (23, "$acc0_7"); - - RN (24, "$acc1_0"); - RN (25, "$acc1_1"); - RN (26, "$acc1_2"); - RN (27, "$acc1_3"); - RN (28, "$acc1_4"); - RN (29, "$acc1_5"); - RN (30, "$acc1_6"); - RN (31, "$acc1_7"); + RN (0, "$csar0"); + RN (1, "$cc"); + RN (4, "$cofr0"); + RN (5, "$cofr1"); + RN (6, "$cofa0"); + RN (7, "$cofa1"); + RN (15, "$csar1"); + + RN (16, "$acc0_0"); + RN (17, "$acc0_1"); + RN (18, "$acc0_2"); + RN (19, "$acc0_3"); + RN (20, "$acc0_4"); + RN (21, "$acc0_5"); + RN (22, "$acc0_6"); + RN (23, "$acc0_7"); + + RN (24, "$acc1_0"); + RN (25, "$acc1_1"); + RN (26, "$acc1_2"); + RN (27, "$acc1_3"); + RN (28, "$acc1_4"); + RN (29, "$acc1_5"); + RN (30, "$acc1_6"); + RN (31, "$acc1_7"); #undef RN - break; + break; - default: - gcc_unreachable (); - } - } + default: + gcc_unreachable (); + } + } if (flag_pic == 1) warning (OPT_fpic, "-fpic is not supported"); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 01f6b61..78c5a88 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -4012,12 +4012,8 @@ struct mips_multi_member { }; typedef struct mips_multi_member mips_multi_member; -/* Vector definitions for the above. */ -DEF_VEC_O(mips_multi_member); -DEF_VEC_ALLOC_O(mips_multi_member, heap); - /* The instructions that make up the current multi-insn sequence. */ -static VEC (mips_multi_member, heap) *mips_multi_members; +static vec<mips_multi_member> mips_multi_members; /* How many instructions (as opposed to labels) are in the current multi-insn sequence. */ @@ -4028,7 +4024,7 @@ static unsigned int mips_multi_num_insns; static void mips_multi_start (void) { - VEC_truncate (mips_multi_member, mips_multi_members, 0); + mips_multi_members.truncate (0); mips_multi_num_insns = 0; } @@ -4038,7 +4034,7 @@ static struct mips_multi_member * mips_multi_add (void) { mips_multi_member empty; - return VEC_safe_push (mips_multi_member, heap, mips_multi_members, empty); + return mips_multi_members.safe_push (empty); } /* Add a normal insn with the given asm format to the current multi-insn @@ -4081,7 +4077,7 @@ mips_multi_add_label (const char *label) static unsigned int mips_multi_last_index (void) { - return VEC_length (mips_multi_member, mips_multi_members) - 1; + return mips_multi_members.length () - 1; } /* Add a copy of an existing instruction to the current multi-insn @@ -4093,8 +4089,7 @@ mips_multi_copy_insn (unsigned int i) struct mips_multi_member *member; member = mips_multi_add (); - memcpy (member, &VEC_index (mips_multi_member, mips_multi_members, i), - sizeof (*member)); + memcpy (member, &mips_multi_members[i], sizeof (*member)); gcc_assert (!member->is_label_p); } @@ -4105,7 +4100,7 @@ mips_multi_copy_insn (unsigned int i) static void mips_multi_set_operand (unsigned int i, unsigned int op, rtx x) { - VEC_index (mips_multi_member, mips_multi_members, i).operands[op] = x; + mips_multi_members[i].operands[op] = x; } /* Write out the asm code for the current multi-insn sequence. */ @@ -4116,7 +4111,7 @@ mips_multi_write (void) struct mips_multi_member *member; unsigned int i; - FOR_EACH_VEC_ELT (mips_multi_member, mips_multi_members, i, member) + FOR_EACH_VEC_ELT (mips_multi_members, i, member) if (member->is_label_p) fprintf (asm_out_file, "%s\n", member->format); else diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index afcfd1a..8b93aa9 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -469,21 +469,22 @@ pa_option_override (void) { unsigned int i; cl_deferred_option *opt; - VEC(cl_deferred_option,heap) *vec - = (VEC(cl_deferred_option,heap) *) pa_deferred_options; + vec<cl_deferred_option> *v + = (vec<cl_deferred_option> *) pa_deferred_options; - FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt) - { - switch (opt->opt_index) - { - case OPT_mfixed_range_: - fix_range (opt->arg); - break; + if (v) + FOR_EACH_VEC_ELT (*v, i, opt) + { + switch (opt->opt_index) + { + case OPT_mfixed_range_: + fix_range (opt->arg); + break; - default: - gcc_unreachable (); - } - } + default: + gcc_unreachable (); + } + } /* Unconditional branches in the delay slot are not compatible with dwarf2 call frame information. There is no benefit in using this optimization @@ -4401,7 +4402,7 @@ hppa_pic_save_rtx (void) /* Vector of funcdef numbers. */ -static VEC(int,heap) *funcdef_nos; +static vec<int> funcdef_nos; /* Output deferred profile counters. */ static void @@ -4410,20 +4411,20 @@ output_deferred_profile_counters (void) unsigned int i; int align, n; - if (VEC_empty (int, funcdef_nos)) + if (funcdef_nos.is_empty ()) return; switch_to_section (data_section); align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE); ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); - for (i = 0; VEC_iterate (int, funcdef_nos, i, n); i++) + for (i = 0; funcdef_nos.iterate (i, &n); i++) { targetm.asm_out.internal_label (asm_out_file, "LP", n); assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, align, 1); } - VEC_free (int, heap, funcdef_nos); + funcdef_nos.release (); } void @@ -4465,7 +4466,7 @@ hppa_profile_hook (int label_no) rtx count_label_rtx, addr, r24; char count_label_name[16]; - VEC_safe_push (int, heap, funcdef_nos, label_no); + funcdef_nos.safe_push (label_no); ASM_GENERATE_INTERNAL_LABEL (count_label_name, "LP", label_no); count_label_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (count_label_name)); @@ -9948,11 +9949,9 @@ typedef struct GTY(()) extern_symbol } extern_symbol; /* Define gc'd vector type for extern_symbol. */ -DEF_VEC_O(extern_symbol); -DEF_VEC_ALLOC_O(extern_symbol,gc); /* Vector of extern_symbol pointers. */ -static GTY(()) VEC(extern_symbol,gc) *extern_symbols; +static GTY(()) vec<extern_symbol, va_gc> *extern_symbols; #ifdef ASM_OUTPUT_EXTERNAL_REAL /* Mark DECL (name NAME) as an external reference (assembler output @@ -9964,7 +9963,7 @@ pa_hpux_asm_output_external (FILE *file, tree decl, const char *name) { gcc_assert (file == asm_out_file); extern_symbol p = {decl, name}; - VEC_safe_push (extern_symbol, gc, extern_symbols, p); + vec_safe_push (extern_symbols, p); } /* Output text required at the end of an assembler file. @@ -9982,7 +9981,7 @@ pa_hpux_file_end (void) output_deferred_plabels (); - for (i = 0; VEC_iterate (extern_symbol, extern_symbols, i, p); i++) + for (i = 0; vec_safe_iterate (extern_symbols, i, &p); i++) { tree decl = p->decl; @@ -9991,7 +9990,7 @@ pa_hpux_file_end (void) ASM_OUTPUT_EXTERNAL_REAL (asm_out_file, decl, p->name); } - VEC_free (extern_symbol, gc, extern_symbols); + vec_free (extern_symbols); } #endif diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 295015f..79da7a6 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -3505,8 +3505,8 @@ tree altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, void *passed_arglist) { - VEC(tree,gc) *arglist = (VEC(tree,gc) *) passed_arglist; - unsigned int nargs = VEC_length (tree, arglist); + vec<tree, va_gc> *arglist = static_cast<vec<tree, va_gc> *> (passed_arglist); + unsigned int nargs = vec_safe_length (arglist); enum rs6000_builtins fcode = (enum rs6000_builtins)DECL_FUNCTION_CODE (fndecl); tree fnargs = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); @@ -3529,7 +3529,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, int size; int i; bool unsigned_p; - VEC(constructor_elt,gc) *vec; + vec<constructor_elt, va_gc> *vec; const char *name = fcode == ALTIVEC_BUILTIN_VEC_SPLATS ? "vec_splats": "vec_promote"; if (nargs == 0) @@ -3549,10 +3549,10 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, } /* Ignore promote's element argument. */ if (fcode == ALTIVEC_BUILTIN_VEC_PROMOTE - && !INTEGRAL_TYPE_P (TREE_TYPE (VEC_index (tree, arglist, 1)))) + && !INTEGRAL_TYPE_P (TREE_TYPE ((*arglist)[1]))) goto bad; - arg = VEC_index (tree, arglist, 0); + arg = (*arglist)[0]; type = TREE_TYPE (arg); if (!SCALAR_FLOAT_TYPE_P (type) && !INTEGRAL_TYPE_P (type)) @@ -3582,11 +3582,11 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, goto bad; } arg = save_expr (fold_convert (TREE_TYPE (type), arg)); - vec = VEC_alloc (constructor_elt, gc, size); + vec_alloc (vec, size); for(i = 0; i < size; i++) { constructor_elt elt = {NULL_TREE, arg}; - VEC_quick_push (constructor_elt, vec, elt); + vec->quick_push (elt); } return build_constructor (type, vec); } @@ -3610,8 +3610,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, return error_mark_node; } - arg2 = VEC_index (tree, arglist, 1); - arg1 = VEC_index (tree, arglist, 0); + arg2 = (*arglist)[1]; + arg1 = (*arglist)[0]; arg1_type = TREE_TYPE (arg1); if (TREE_CODE (arg1_type) != VECTOR_TYPE) @@ -3686,10 +3686,10 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, return error_mark_node; } - arg0 = VEC_index (tree, arglist, 0); - arg1 = VEC_index (tree, arglist, 1); + arg0 = (*arglist)[0]; + arg1 = (*arglist)[1]; arg1_type = TREE_TYPE (arg1); - arg2 = VEC_index (tree, arglist, 2); + arg2 = (*arglist)[2]; if (TREE_CODE (arg1_type) != VECTOR_TYPE) goto bad; @@ -3752,7 +3752,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, fnargs = TREE_CHAIN (fnargs), n++) { tree decl_type = TREE_VALUE (fnargs); - tree arg = VEC_index (tree, arglist, n); + tree arg = (*arglist)[n]; tree type; if (arg == error_mark_node) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b37bca9..4bde320 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24928,10 +24928,8 @@ typedef struct branch_island_d { int line_number; } branch_island; -DEF_VEC_O(branch_island); -DEF_VEC_ALLOC_O(branch_island,gc); -static VEC(branch_island,gc) *branch_islands; +static vec<branch_island, va_gc> *branch_islands; /* Remember to generate a branch island for far calls to the given function. */ @@ -24941,7 +24939,7 @@ add_compiler_branch_island (tree label_name, tree function_name, int line_number) { branch_island bi = {function_name, label_name, line_number}; - VEC_safe_push (branch_island, gc, branch_islands, bi); + vec_safe_push (branch_islands, bi); } /* Generate far-jump branch islands for everything recorded in @@ -24955,9 +24953,9 @@ macho_branch_islands (void) { char tmp_buf[512]; - while (!VEC_empty (branch_island, branch_islands)) + while (!vec_safe_is_empty (branch_islands)) { - branch_island *bi = &VEC_last (branch_island, branch_islands); + branch_island *bi = &branch_islands->last (); const char *label = IDENTIFIER_POINTER (bi->label_name); const char *name = IDENTIFIER_POINTER (bi->function_name); char name_buf[512]; @@ -25025,7 +25023,7 @@ macho_branch_islands (void) if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) dbxout_stabd (N_SLINE, bi->line_number); #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */ - VEC_pop (branch_island, branch_islands); + branch_islands->pop (); } } @@ -25038,7 +25036,7 @@ no_previous_def (tree function_name) branch_island *bi; unsigned ix; - FOR_EACH_VEC_ELT (branch_island, branch_islands, ix, bi) + FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi) if (function_name == bi->function_name) return 0; return 1; @@ -25053,7 +25051,7 @@ get_prev_label (tree function_name) branch_island *bi; unsigned ix; - FOR_EACH_VEC_ELT (branch_island, branch_islands, ix, bi) + FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi) if (function_name == bi->function_name) return bi->label_name; return NULL_TREE; diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index 5d31eac..8cd9253 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -2614,43 +2614,43 @@ rx_option_override (void) { unsigned int i; cl_deferred_option *opt; - VEC(cl_deferred_option,heap) *vec - = (VEC(cl_deferred_option,heap) *) rx_deferred_options; + vec<cl_deferred_option> *v = (vec<cl_deferred_option> *) rx_deferred_options; - FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt) - { - switch (opt->opt_index) - { - case OPT_mint_register_: - switch (opt->value) - { - case 4: - fixed_regs[10] = call_used_regs [10] = 1; - /* Fall through. */ - case 3: - fixed_regs[11] = call_used_regs [11] = 1; - /* Fall through. */ - case 2: - fixed_regs[12] = call_used_regs [12] = 1; - /* Fall through. */ - case 1: - fixed_regs[13] = call_used_regs [13] = 1; - /* Fall through. */ - case 0: - rx_num_interrupt_regs = opt->value; - break; - default: - rx_num_interrupt_regs = 0; - /* Error message already given because rx_handle_option - returned false. */ - break; - } - break; + if (v) + FOR_EACH_VEC_ELT (*v, i, opt) + { + switch (opt->opt_index) + { + case OPT_mint_register_: + switch (opt->value) + { + case 4: + fixed_regs[10] = call_used_regs [10] = 1; + /* Fall through. */ + case 3: + fixed_regs[11] = call_used_regs [11] = 1; + /* Fall through. */ + case 2: + fixed_regs[12] = call_used_regs [12] = 1; + /* Fall through. */ + case 1: + fixed_regs[13] = call_used_regs [13] = 1; + /* Fall through. */ + case 0: + rx_num_interrupt_regs = opt->value; + break; + default: + rx_num_interrupt_regs = 0; + /* Error message already given because rx_handle_option + returned false. */ + break; + } + break; - default: - gcc_unreachable (); - } - } + default: + gcc_unreachable (); + } + } /* This target defaults to strict volatile bitfields. */ if (flag_strict_volatile_bitfields < 0 && abi_version_at_least(2)) diff --git a/gcc/config/spu/spu-c.c b/gcc/config/spu/spu-c.c index 905030d..6fa8d17 100644 --- a/gcc/config/spu/spu-c.c +++ b/gcc/config/spu/spu-c.c @@ -93,8 +93,8 @@ spu_resolve_overloaded_builtin (location_t loc, tree fndecl, void *passed_args) #define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \ || SCALAR_FLOAT_TYPE_P (t) \ || POINTER_TYPE_P (t)) - VEC(tree,gc) *fnargs = (VEC(tree,gc) *) passed_args; - unsigned int nargs = VEC_length (tree, fnargs); + vec<tree, va_gc> *fnargs = static_cast <vec<tree, va_gc> *> (passed_args); + unsigned int nargs = vec_safe_length (fnargs); int new_fcode, fcode = DECL_FUNCTION_CODE (fndecl); struct spu_builtin_description *desc; tree match = NULL_TREE; @@ -137,7 +137,7 @@ spu_resolve_overloaded_builtin (location_t loc, tree fndecl, void *passed_args) return error_mark_node; } - var = VEC_index (tree, fnargs, p); + var = (*fnargs)[p]; if (TREE_CODE (var) == NON_LVALUE_EXPR) var = TREE_OPERAND (var, 0); diff --git a/gcc/config/vms/vms.c b/gcc/config/vms/vms.c index d23e8a8..65bf42a 100644 --- a/gcc/config/vms/vms.c +++ b/gcc/config/vms/vms.c @@ -101,7 +101,7 @@ static const struct vms_crtl_name vms_crtl_names[] = /* List of aliased identifiers. They must be persistent across gc. */ -static GTY(()) VEC(tree,gc) *aliases_id; +static GTY(()) vec<tree, va_gc> *aliases_id; /* Add a CRTL translation. This simply use the transparent alias mechanism, which is platform independent and works with the @@ -120,7 +120,7 @@ vms_add_crtl_xlat (const char *name, size_t nlen, IDENTIFIER_TRANSPARENT_ALIAS (targ) = 1; TREE_CHAIN (targ) = get_identifier_with_length (id_str, id_len); - VEC_safe_push (tree, gc, aliases_id, targ); + vec_safe_push (aliases_id, targ); } /* Do VMS specific stuff on builtins: disable the ones that are not diff --git a/gcc/config/vxworks.c b/gcc/config/vxworks.c index 9eeefc0..e305904 100644 --- a/gcc/config/vxworks.c +++ b/gcc/config/vxworks.c @@ -96,23 +96,24 @@ vxworks_emutls_var_fields (tree type, tree *name) static tree vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr) { - VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 3); + vec<constructor_elt, va_gc> *v; + vec_alloc (v, 3); tree type = TREE_TYPE (var); tree field = TYPE_FIELDS (type); constructor_elt elt = {field, fold_convert (TREE_TYPE (field), tmpl_addr)}; - VEC_quick_push (constructor_elt, v, elt); + v->quick_push (elt); field = DECL_CHAIN (field); elt.index = field; elt.value = build_int_cst (TREE_TYPE (field), 0); - VEC_quick_push (constructor_elt, v, elt); + v->quick_push (elt); field = DECL_CHAIN (field); elt.index = field; elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl)); - VEC_quick_push (constructor_elt, v, elt); + v->quick_push (elt); return build_constructor (type, v); } |