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/genautomata.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/genautomata.c')
-rw-r--r-- | gcc/genautomata.c | 521 |
1 files changed, 239 insertions, 282 deletions
diff --git a/gcc/genautomata.c b/gcc/genautomata.c index 102e7d2..faa9bf8 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -213,20 +213,8 @@ static struct obstack irp; /* Declare vector types for various data structures: */ -DEF_VEC_P(alt_state_t); -DEF_VEC_ALLOC_P(alt_state_t, heap); -DEF_VEC_P(ainsn_t); -DEF_VEC_ALLOC_P(ainsn_t, heap); -DEF_VEC_P(state_t); -DEF_VEC_ALLOC_P(state_t, heap); -DEF_VEC_P(decl_t); -DEF_VEC_ALLOC_P(decl_t, heap); -DEF_VEC_P(reserv_sets_t); -DEF_VEC_ALLOC_P(reserv_sets_t, heap); - -DEF_VEC_I(vect_el_t); -DEF_VEC_ALLOC_I(vect_el_t, heap); -typedef VEC(vect_el_t, heap) *vla_hwint_t; + +typedef vec<vect_el_t> vla_hwint_t; /* Forward declarations of functions used before their definitions, only. */ static regexp_t gen_regexp_sequence (const char *); @@ -1150,7 +1138,7 @@ check_name (const char * name, pos_t pos ATTRIBUTE_UNUSED) /* Pointers to all declarations during IR generation are stored in the following. */ -static VEC(decl_t, heap) *decls; +static vec<decl_t> decls; /* Given a pointer to a (char *) and a separator, return an alloc'ed string containing the next separated element, taking parentheses @@ -1278,7 +1266,7 @@ gen_cpu_unit (rtx def) DECL_UNIT (decl)->query_p = 0; DECL_UNIT (decl)->min_occ_cycle_num = -1; DECL_UNIT (decl)->in_set_p = 0; - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } } @@ -1306,7 +1294,7 @@ gen_query_cpu_unit (rtx def) DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos); DECL_UNIT (decl)->automaton_name = XSTR (def, 1); DECL_UNIT (decl)->query_p = 1; - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } } @@ -1341,7 +1329,7 @@ gen_bypass (rtx def) DECL_BYPASS (decl)->out_pattern = out_patterns[i]; DECL_BYPASS (decl)->in_pattern = in_patterns[j]; DECL_BYPASS (decl)->bypass_guard_name = XSTR (def, 3); - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } } @@ -1380,7 +1368,7 @@ gen_excl_set (rtx def) else DECL_EXCL (decl)->names [i] = second_str_cpu_units [i - first_vect_length]; - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } /* Process a PRESENCE_SET, a FINAL_PRESENCE_SET, an ABSENCE_SET, @@ -1449,7 +1437,7 @@ gen_presence_absence_set (rtx def, int presence_p, int final_p) DECL_ABSENCE (decl)->patterns_num = patterns_length; DECL_ABSENCE (decl)->final_p = final_p; } - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } /* Process a PRESENCE_SET. @@ -1518,7 +1506,7 @@ gen_automaton (rtx def) decl->mode = dm_automaton; decl->pos = 0; DECL_AUTOMATON (decl)->name = check_name (str_automata [i], decl->pos); - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } } @@ -1723,7 +1711,7 @@ gen_reserv (rtx def) decl->pos = 0; DECL_RESERV (decl)->name = check_name (XSTR (def, 0), decl->pos); DECL_RESERV (decl)->regexp = gen_regexp (XSTR (def, 1)); - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } /* Process a DEFINE_INSN_RESERVATION. @@ -1744,7 +1732,7 @@ gen_insn_reserv (rtx def) DECL_INSN_RESERV (decl)->default_latency = XINT (def, 1); DECL_INSN_RESERV (decl)->condexp = XEXP (def, 2); DECL_INSN_RESERV (decl)->regexp = gen_regexp (XSTR (def, 3)); - VEC_safe_push (decl_t, heap, decls, decl); + decls.safe_push (decl); } @@ -3349,7 +3337,7 @@ static alt_state_t uniq_sort_alt_states (alt_state_t alt_states_list) { alt_state_t curr_alt_state; - VEC(alt_state_t, heap) *alt_states; + vec<alt_state_t> alt_states; size_t i; size_t prev_unique_state_ind; alt_state_t result; @@ -3359,33 +3347,31 @@ uniq_sort_alt_states (alt_state_t alt_states_list) if (alt_states_list->next_alt_state == 0) return alt_states_list; - alt_states = VEC_alloc (alt_state_t, heap, 150); + alt_states.create (150); for (curr_alt_state = alt_states_list; curr_alt_state != NULL; curr_alt_state = curr_alt_state->next_alt_state) - VEC_safe_push (alt_state_t, heap, alt_states, curr_alt_state); + alt_states.safe_push (curr_alt_state); - VEC_qsort (alt_state_t, alt_states, alt_state_cmp); + alt_states.qsort (alt_state_cmp); prev_unique_state_ind = 0; - for (i = 1; i < VEC_length (alt_state_t, alt_states); i++) - if (VEC_index (alt_state_t, alt_states, prev_unique_state_ind)->state - != VEC_index (alt_state_t, alt_states, i)->state) + for (i = 1; i < alt_states.length (); i++) + if (alt_states[prev_unique_state_ind]->state != alt_states[i]->state) { prev_unique_state_ind++; - VEC_replace (alt_state_t, alt_states, prev_unique_state_ind, - VEC_index (alt_state_t, alt_states, i)); + alt_states[prev_unique_state_ind] = alt_states[i]; } - VEC_truncate (alt_state_t, alt_states, prev_unique_state_ind + 1); + alt_states.truncate (prev_unique_state_ind + 1); - for (i = 1; i < VEC_length (alt_state_t, alt_states); i++) - VEC_index (alt_state_t, alt_states, i-1)->next_sorted_alt_state - = VEC_index (alt_state_t, alt_states, i); - VEC_last (alt_state_t, alt_states)->next_sorted_alt_state = 0; + for (i = 1; i < alt_states.length (); i++) + alt_states[i-1]->next_sorted_alt_state + = alt_states[i]; + alt_states.last ()->next_sorted_alt_state = 0; - result = VEC_index (alt_state_t, alt_states, 0); + result = alt_states[0]; - VEC_free (alt_state_t, heap, alt_states); + alt_states.release (); return result; } @@ -5030,7 +5016,7 @@ transform_insn_regexps (void) static int annotation_message_reported_p; /* The vector contains all decls which are automata. */ -static VEC(decl_t, heap) *automaton_decls; +static vec<decl_t> automaton_decls; /* The following structure describes usage of a unit in a reservation. */ struct unit_usage @@ -5044,8 +5030,6 @@ struct unit_usage }; typedef struct unit_usage *unit_usage_t; -DEF_VEC_P(unit_usage_t); -DEF_VEC_ALLOC_P(unit_usage_t, heap); /* Obstack for unit_usage structures. */ static struct obstack unit_usages; @@ -5056,7 +5040,7 @@ static struct obstack unit_usages; alternative with given number are referred through element with index equals to the cycle * number of all alternatives in the regexp + the alternative number. */ -static VEC(unit_usage_t, heap) *cycle_alt_unit_usages; +static vec<unit_usage_t> cycle_alt_unit_usages; /* The following function creates the structure unit_usage for UNIT on CYCLE in REGEXP alternative with ALT_NUM. The structure is made @@ -5075,13 +5059,12 @@ store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle, unit_decl = REGEXP_UNIT (unit)->unit_decl; length = (cycle + 1) * REGEXP_ONEOF (regexp)->regexps_num; - while (VEC_length (unit_usage_t, cycle_alt_unit_usages) < length) - VEC_safe_push (unit_usage_t, heap, cycle_alt_unit_usages, - (unit_usage_t) NULL); + while (cycle_alt_unit_usages.length () < length) + cycle_alt_unit_usages.safe_push (NULL); index = cycle * REGEXP_ONEOF (regexp)->regexps_num + alt_num; prev = NULL; - for (curr = VEC_index (unit_usage_t, cycle_alt_unit_usages, index); + for (curr = cycle_alt_unit_usages[index]; curr != NULL; prev = curr, curr = curr->next) if (curr->unit_decl >= unit_decl) @@ -5095,7 +5078,7 @@ store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle, unit_decl->last_distribution_check_cycle = -1; /* undefined */ unit_usage_ptr->next = curr; if (prev == NULL) - VEC_replace (unit_usage_t, cycle_alt_unit_usages, index, unit_usage_ptr); + cycle_alt_unit_usages[index] = unit_usage_ptr; else prev->next = unit_usage_ptr; } @@ -5124,11 +5107,11 @@ equal_alternatives_p (int alt1, int alt2, int n_alts, unit_usage_t list1, list2; for (i = 0; - i < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); + i < (int) cycle_alt_unit_usages.length (); i += n_alts) { - for (list1 = VEC_index (unit_usage_t, cycle_alt_unit_usages, i + alt1), - list2 = VEC_index (unit_usage_t, cycle_alt_unit_usages, i + alt2);; + for (list1 = cycle_alt_unit_usages[i + alt1], + list2 = cycle_alt_unit_usages[i + alt2];; list1 = list1->next, list2 = list2->next) { while (list1 != NULL @@ -5151,8 +5134,6 @@ equal_alternatives_p (int alt1, int alt2, int n_alts, return true; } -DEF_VEC_I(int); -DEF_VEC_ALLOC_I(int, heap); /* The function processes given REGEXP to find units with the wrong distribution. */ @@ -5164,13 +5145,13 @@ check_regexp_units_distribution (const char *insn_reserv_name, bool annotation_reservation_message_reported_p; regexp_t seq, allof, unit; struct unit_usage *unit_usage_ptr; - VEC(int, heap) *marked; + vec<int> marked; if (regexp == NULL || regexp->mode != rm_oneof) return; /* Store all unit usages in the regexp: */ obstack_init (&unit_usages); - cycle_alt_unit_usages = VEC_alloc (unit_usage_t, heap, 10); + cycle_alt_unit_usages.create (10); for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--) { @@ -5238,21 +5219,21 @@ check_regexp_units_distribution (const char *insn_reserv_name, } } /* Check distribution: */ - for (i = 0; i < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); i++) - for (unit_usage_ptr = VEC_index (unit_usage_t, cycle_alt_unit_usages, i); + for (i = 0; i < (int) cycle_alt_unit_usages.length (); i++) + for (unit_usage_ptr = cycle_alt_unit_usages[i]; unit_usage_ptr != NULL; unit_usage_ptr = unit_usage_ptr->next) unit_usage_ptr->unit_decl->last_distribution_check_cycle = -1; n_alts = REGEXP_ONEOF (regexp)->regexps_num; - marked = VEC_alloc (int, heap, n_alts); + marked.create (n_alts); for (i = 0; i < n_alts; i++) - VEC_safe_push (int, heap, marked, 0); + marked.safe_push (0); annotation_reservation_message_reported_p = false; - for (i = 0; i < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); i++) + for (i = 0; i < (int) cycle_alt_unit_usages.length (); i++) { cycle = i / n_alts; start = cycle * n_alts; - for (unit_usage_ptr = VEC_index (unit_usage_t, cycle_alt_unit_usages, i); + for (unit_usage_ptr = cycle_alt_unit_usages[i]; unit_usage_ptr != NULL; unit_usage_ptr = unit_usage_ptr->next) { @@ -5260,40 +5241,35 @@ check_regexp_units_distribution (const char *insn_reserv_name, continue; unit_usage_ptr->unit_decl->last_distribution_check_cycle = cycle; for (alt = 0; alt < n_alts; alt++) - if (! unit_present_on_list_p (VEC_index (unit_usage_t, - cycle_alt_unit_usages, - start + alt), + if (! unit_present_on_list_p (cycle_alt_unit_usages[start + alt], unit_usage_ptr->unit_decl)) break; if (alt >= n_alts) continue; - memset (VEC_address (int, marked), 0, n_alts * sizeof (int)); + memset (marked.address (), 0, n_alts * sizeof (int)); for (alt = 0; alt < n_alts; alt++) { - if (! unit_present_on_list_p (VEC_index (unit_usage_t, - cycle_alt_unit_usages, - start + alt), + if (! unit_present_on_list_p (cycle_alt_unit_usages[start + alt], unit_usage_ptr->unit_decl)) continue; for (j = 0; - j < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); + j < (int) cycle_alt_unit_usages.length (); j++) { alt2 = j % n_alts; if (! unit_present_on_list_p - (VEC_index (unit_usage_t, cycle_alt_unit_usages, - start + alt2), + (cycle_alt_unit_usages[start + alt2], unit_usage_ptr->unit_decl) && equal_alternatives_p (alt, alt2, n_alts, unit_usage_ptr ->unit_decl->automaton_decl)) { - VEC_replace (int, marked, alt, 1); - VEC_replace (int, marked, alt2, 1); + marked[alt] = 1; + marked[alt2] = 1; } } } - for (alt = 0; alt < n_alts && VEC_index (int, marked, alt); alt++) + for (alt = 0; alt < n_alts && marked[alt]; alt++) ; if (alt < n_alts && 0) { @@ -5315,8 +5291,8 @@ check_regexp_units_distribution (const char *insn_reserv_name, } } } - VEC_free (int, heap, marked); - VEC_free (unit_usage_t, heap, cycle_alt_unit_usages); + marked.release (); + cycle_alt_unit_usages.release (); obstack_free (&unit_usages, NULL); } @@ -5330,14 +5306,14 @@ check_unit_distributions_to_automata (void) if (progress_flag) fprintf (stderr, "Check unit distributions to automata..."); - automaton_decls = NULL; + automaton_decls.create (0); for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_automaton) - VEC_safe_push (decl_t, heap, automaton_decls, decl); + automaton_decls.safe_push (decl); } - if (VEC_length (decl_t, automaton_decls) > 1) + if (automaton_decls.length () > 1) { annotation_message_reported_p = FALSE; for (i = 0; i < description->decls_num; i++) @@ -5349,7 +5325,7 @@ check_unit_distributions_to_automata (void) DECL_INSN_RESERV (decl)->transformed_regexp); } } - VEC_free (decl_t, heap, automaton_decls); + automaton_decls.release (); if (progress_flag) fprintf (stderr, "done\n"); } @@ -5509,7 +5485,8 @@ form_ainsn_with_same_reservs (automaton_t automaton) { ainsn_t curr_ainsn; size_t i; - VEC(ainsn_t, heap) *last_insns = VEC_alloc (ainsn_t, heap, 150); + vec<ainsn_t> last_insns; + last_insns.create (150); for (curr_ainsn = automaton->ainsn_list; curr_ainsn != NULL; @@ -5521,26 +5498,25 @@ form_ainsn_with_same_reservs (automaton_t automaton) } else { - for (i = 0; i < VEC_length (ainsn_t, last_insns); i++) + for (i = 0; i < last_insns.length (); i++) if (alt_states_eq (curr_ainsn->sorted_alt_states, - VEC_index (ainsn_t, last_insns, i)->sorted_alt_states)) + last_insns[i]->sorted_alt_states)) break; curr_ainsn->next_same_reservs_insn = NULL; - if (i < VEC_length (ainsn_t, last_insns)) + if (i < last_insns.length ()) { curr_ainsn->first_insn_with_same_reservs = 0; - VEC_index (ainsn_t, last_insns, i)->next_same_reservs_insn - = curr_ainsn; - VEC_replace (ainsn_t, last_insns, i, curr_ainsn); + last_insns[i]->next_same_reservs_insn = curr_ainsn; + last_insns[i] = curr_ainsn; } else { - VEC_safe_push (ainsn_t, heap, last_insns, curr_ainsn); + last_insns.safe_push (curr_ainsn); curr_ainsn->first_insn_with_same_reservs = 1; } } - VEC_free (ainsn_t, heap, last_insns); + last_insns.release (); } /* Forming unit reservations which can affect creating the automaton @@ -5582,7 +5558,8 @@ make_automaton (automaton_t automaton) state_t state; state_t start_state; state_t state2; - VEC(state_t, heap) *state_stack = VEC_alloc(state_t, heap, 150); + vec<state_t> state_stack; + state_stack.create (150); int states_n; reserv_sets_t reservs_matter = form_reservs_matter (automaton); @@ -5590,11 +5567,11 @@ make_automaton (automaton_t automaton) start_state = insert_state (get_free_state (1, automaton)); automaton->start_state = start_state; start_state->it_was_placed_in_stack_for_NDFA_forming = 1; - VEC_safe_push (state_t, heap, state_stack, start_state); + state_stack.safe_push (start_state); states_n = 1; - while (VEC_length (state_t, state_stack) != 0) + while (state_stack.length () != 0) { - state = VEC_pop (state_t, state_stack); + state = state_stack.pop (); for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) @@ -5617,7 +5594,7 @@ make_automaton (automaton_t automaton) { state2->it_was_placed_in_stack_for_NDFA_forming = 1; - VEC_safe_push (state_t, heap, state_stack, state2); + state_stack.safe_push (state2); states_n++; if (progress_flag && states_n % 100 == 0) fprintf (stderr, "."); @@ -5634,14 +5611,14 @@ make_automaton (automaton_t automaton) if (!state2->it_was_placed_in_stack_for_NDFA_forming) { state2->it_was_placed_in_stack_for_NDFA_forming = 1; - VEC_safe_push (state_t, heap, state_stack, state2); + state_stack.safe_push (state2); states_n++; if (progress_flag && states_n % 100 == 0) fprintf (stderr, "."); } add_arc (state, state2, automaton->advance_ainsn); } - VEC_free (state_t, heap, state_stack); + state_stack.release (); } /* Form lists of all arcs of STATE marked by the same ainsn. */ @@ -5674,7 +5651,7 @@ form_arcs_marked_by_insn (state_t state) static int create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, - VEC(state_t, heap) **state_stack) + vec<state_t> *state_stack) { state_t state; alt_state_t alt_state, curr_alt_state; @@ -5770,7 +5747,7 @@ create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, if (!state->it_was_placed_in_stack_for_DFA_forming) { state->it_was_placed_in_stack_for_DFA_forming = 1; - VEC_safe_push (state_t, heap, *state_stack, state); + state_stack->safe_push (state); } return new_state_p; } @@ -5784,20 +5761,20 @@ NDFA_to_DFA (automaton_t automaton) state_t start_state; state_t state; decl_t decl; - VEC(state_t, heap) *state_stack; + vec<state_t> state_stack; int i; int states_n; - state_stack = VEC_alloc (state_t, heap, 0); + state_stack.create (0); /* Create the start state (empty state). */ start_state = automaton->start_state; start_state->it_was_placed_in_stack_for_DFA_forming = 1; - VEC_safe_push (state_t, heap, state_stack, start_state); + state_stack.safe_push (start_state); states_n = 1; - while (VEC_length (state_t, state_stack) != 0) + while (state_stack.length () != 0) { - state = VEC_pop (state_t, state_stack); + state = state_stack.pop (); form_arcs_marked_by_insn (state); for (i = 0; i < description->decls_num; i++) { @@ -5822,7 +5799,7 @@ NDFA_to_DFA (automaton_t automaton) if (!state2->it_was_placed_in_stack_for_DFA_forming) { state2->it_was_placed_in_stack_for_DFA_forming = 1; - VEC_safe_push (state_t, heap, state_stack, state2); + state_stack.safe_push (state2); } add_arc (state, state2, automaton->collapse_ainsn); } @@ -5830,7 +5807,7 @@ NDFA_to_DFA (automaton_t automaton) add_arc (state, state, automaton->collapse_ainsn); } } - VEC_free (state_t, heap, state_stack); + state_stack.release (); } /* The following variable value is current number (1, 2, ...) of passing @@ -5872,14 +5849,14 @@ initiate_pass_states (void) /* The following vla is used for storing pointers to all achieved states. */ -static VEC(state_t, heap) *all_achieved_states; +static vec<state_t> all_achieved_states; /* This function is called by function pass_states to add an achieved STATE. */ static void add_achieved_state (state_t state) { - VEC_safe_push (state_t, heap, all_achieved_states, state); + all_achieved_states.safe_push (state); } /* The function sets up equivalence numbers of insns which mark all @@ -6014,24 +5991,24 @@ compare_states_for_equiv (const void *state_ptr_1, } /* The function makes initial partition of STATES on equivalent - classes and saves it into *CLASSES. This function requires the input + classes and saves it into CLASSES. This function requires the input to be sorted via compare_states_for_equiv(). */ static int -init_equiv_class (VEC(state_t, heap) *states, VEC (state_t, heap) **classes) +init_equiv_class (vec<state_t> states, vec<state_t> *classes) { size_t i; state_t prev = 0; int class_num = 1; - *classes = VEC_alloc (state_t, heap, 150); - for (i = 0; i < VEC_length (state_t, states); i++) + classes->create (150); + for (i = 0; i < states.length (); i++) { - state_t state = VEC_index (state_t, states, i); + state_t state = states[i]; if (prev) { if (compare_states_for_equiv (&prev, &state) != 0) { - VEC_safe_push (state_t, heap, *classes, prev); + classes->safe_push (prev); class_num++; prev = NULL; } @@ -6041,17 +6018,17 @@ init_equiv_class (VEC(state_t, heap) *states, VEC (state_t, heap) **classes) prev = state; } if (prev) - VEC_safe_push (state_t, heap, *classes, prev); + classes->safe_push (prev); return class_num; } /* The function copies pointers to equivalent states from vla FROM into vla TO. */ static void -copy_equiv_class (VEC(state_t, heap) **to, VEC(state_t, heap) *from) +copy_equiv_class (vec<state_t> *to, vec<state_t> from) { - VEC_free (state_t, heap, *to); - *to = VEC_copy (state_t, heap, from); + to->release (); + *to = from.copy (); } /* The function processes equivalence class given by its first state, @@ -6063,7 +6040,7 @@ copy_equiv_class (VEC(state_t, heap) **to, VEC(state_t, heap) *from) partitioned, the function returns nonzero value. */ static int partition_equiv_class (state_t first_state, int odd_iteration_flag, - VEC(state_t, heap) **next_iteration_classes, + vec<state_t> *next_iteration_classes, int *new_equiv_class_num_ptr) { state_t new_equiv_class; @@ -6109,7 +6086,7 @@ partition_equiv_class (state_t first_state, int odd_iteration_flag, clear_arc_insns_equiv_num (first_state); } if (new_equiv_class != NULL) - VEC_safe_push (state_t, heap, *next_iteration_classes, new_equiv_class); + next_iteration_classes->safe_push (new_equiv_class); first_state = new_equiv_class; } return partition_p; @@ -6117,19 +6094,18 @@ partition_equiv_class (state_t first_state, int odd_iteration_flag, /* The function finds equivalent states of AUTOMATON. */ static void -evaluate_equiv_classes (automaton_t automaton, - VEC(state_t, heap) **equiv_classes) +evaluate_equiv_classes (automaton_t automaton, vec<state_t> *equiv_classes) { int new_equiv_class_num; int odd_iteration_flag; int finish_flag; - VEC (state_t, heap) *next_iteration_classes; + vec<state_t> next_iteration_classes; size_t i; - all_achieved_states = VEC_alloc (state_t, heap, 1500); + all_achieved_states.create (1500); pass_states (automaton, add_achieved_state); pass_states (automaton, cache_presence); - VEC_qsort (state_t, all_achieved_states, compare_states_for_equiv); + all_achieved_states.qsort (compare_states_for_equiv); odd_iteration_flag = 0; new_equiv_class_num = init_equiv_class (all_achieved_states, @@ -6142,29 +6118,29 @@ evaluate_equiv_classes (automaton_t automaton, copy_equiv_class (equiv_classes, next_iteration_classes); /* Transfer equiv numbers for the next iteration. */ - for (i = 0; i < VEC_length (state_t, all_achieved_states); i++) + for (i = 0; i < all_achieved_states.length (); i++) if (odd_iteration_flag) - VEC_index (state_t, all_achieved_states, i)->equiv_class_num_2 - = VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1; + all_achieved_states[i]->equiv_class_num_2 + = all_achieved_states[i]->equiv_class_num_1; else - VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1 - = VEC_index (state_t, all_achieved_states, i)->equiv_class_num_2; + all_achieved_states[i]->equiv_class_num_1 + = all_achieved_states[i]->equiv_class_num_2; - for (i = 0; i < VEC_length (state_t, *equiv_classes); i++) - if (partition_equiv_class (VEC_index (state_t, *equiv_classes, i), + for (i = 0; i < equiv_classes->length (); i++) + if (partition_equiv_class ((*equiv_classes)[i], odd_iteration_flag, &next_iteration_classes, &new_equiv_class_num)) finish_flag = 0; } while (!finish_flag); - VEC_free (state_t, heap, next_iteration_classes); - VEC_free (state_t, heap, all_achieved_states); + next_iteration_classes.release (); + all_achieved_states.release (); } /* The function merges equivalent states of AUTOMATON. */ static void -merge_states (automaton_t automaton, VEC(state_t, heap) *equiv_classes) +merge_states (automaton_t automaton, vec<state_t> equiv_classes) { state_t curr_state; state_t new_state; @@ -6177,9 +6153,9 @@ merge_states (automaton_t automaton, VEC(state_t, heap) *equiv_classes) /* Create states corresponding to equivalence classes containing two or more states. */ - for (i = 0; i < VEC_length (state_t, equiv_classes); i++) + for (i = 0; i < equiv_classes.length (); i++) { - curr_state = VEC_index (state_t, equiv_classes, i); + curr_state = equiv_classes[i]; if (curr_state->next_equiv_class_state != NULL) { /* There are more one states in the class equivalence. */ @@ -6218,9 +6194,9 @@ merge_states (automaton_t automaton, VEC(state_t, heap) *equiv_classes) curr_state->equiv_class_state = curr_state; } - for (i = 0; i < VEC_length (state_t, equiv_classes); i++) + for (i = 0; i < equiv_classes.length (); i++) { - curr_state = VEC_index (state_t, equiv_classes, i); + curr_state = equiv_classes[i]; if (curr_state->next_equiv_class_state != NULL) { first_class_state = curr_state; @@ -6279,13 +6255,13 @@ set_new_cycle_flags (state_t state) static void minimize_DFA (automaton_t automaton) { - VEC(state_t, heap) *equiv_classes = 0; + vec<state_t> equiv_classes = vec<state_t>(); evaluate_equiv_classes (automaton, &equiv_classes); merge_states (automaton, equiv_classes); pass_states (automaton, set_new_cycle_flags); - VEC_free (state_t, heap, equiv_classes); + equiv_classes.release (); } /* Values of two variables are counted number of states and arcs in an @@ -6952,7 +6928,7 @@ static void output_vect (vla_hwint_t vect) { int els_on_line; - size_t vect_length = VEC_length (vect_el_t, vect); + size_t vect_length = vect.length (); size_t i; els_on_line = 1; @@ -6961,7 +6937,7 @@ output_vect (vla_hwint_t vect) else for (i = 0; i < vect_length; i++) { - fprintf (output_file, "%5ld", (long) VEC_index (vect_el_t, vect, i)); + fprintf (output_file, "%5ld", (long) vect[i]); if (els_on_line == 10) { els_on_line = 0; @@ -7225,17 +7201,15 @@ output_translate_vect (automaton_t automaton) int insn_value; vla_hwint_t translate_vect; - translate_vect = VEC_alloc (vect_el_t, heap, description->insns_num); + translate_vect.create (description->insns_num); for (insn_value = 0; insn_value < description->insns_num; insn_value++) /* Undefined value */ - VEC_quick_push (vect_el_t, translate_vect, - automaton->insn_equiv_classes_num); + translate_vect.quick_push (automaton->insn_equiv_classes_num); for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) - VEC_replace (vect_el_t, translate_vect, - ainsn->insn_reserv_decl->insn_num, - ainsn->insn_equiv_class_num); + translate_vect[ainsn->insn_reserv_decl->insn_num] = + ainsn->insn_equiv_class_num; fprintf (output_file, "/* Vector translating external insn codes to internal ones.*/\n"); @@ -7246,7 +7220,7 @@ output_translate_vect (automaton_t automaton) fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (translate_vect); fprintf (output_file, "};\n\n"); - VEC_free (vect_el_t, heap, translate_vect); + translate_vect.release (); } /* The value in a table state x ainsn -> something which represents @@ -7260,8 +7234,7 @@ comb_vect_p (state_ainsn_table_t tab) { if (no_comb_flag) return false; - return (2 * VEC_length (vect_el_t, tab->full_vect) - > 5 * VEC_length (vect_el_t, tab->comb_vect)); + return (2 * tab->full_vect.length () > 5 * tab->comb_vect.length ()); } /* The following function creates new table for AUTOMATON. */ @@ -7275,18 +7248,17 @@ create_state_ainsn_table (automaton_t automaton) tab = XCREATENODE (struct state_ainsn_table); tab->automaton = automaton; - tab->comb_vect = VEC_alloc (vect_el_t, heap, 10000); - tab->check_vect = VEC_alloc (vect_el_t, heap, 10000); + tab->comb_vect.create (10000); + tab->check_vect.create (10000); - tab->base_vect = 0; - VEC_safe_grow (vect_el_t, heap, tab->base_vect, - automaton->achieved_states_num); + tab->base_vect.create (0); + tab->base_vect.safe_grow (automaton->achieved_states_num); full_vect_length = (automaton->insn_equiv_classes_num * automaton->achieved_states_num); - tab->full_vect = VEC_alloc (vect_el_t, heap, full_vect_length); + tab->full_vect.create (full_vect_length); for (i = 0; i < full_vect_length; i++) - VEC_quick_push (vect_el_t, tab->full_vect, undefined_vect_el_value); + tab->full_vect.quick_push (undefined_vect_el_value); tab->min_base_vect_el_value = 0; tab->max_base_vect_el_value = 0; @@ -7364,27 +7336,25 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) int i; unsigned long vect_mask, comb_vect_mask; - vect_length = VEC_length (vect_el_t, vect); + vect_length = vect.length (); gcc_assert (vect_length); - gcc_assert (VEC_last (vect_el_t, vect) != undefined_vect_el_value); + gcc_assert (vect.last () != undefined_vect_el_value); real_vect_length = tab->automaton->insn_equiv_classes_num; /* Form full vector in the table: */ { size_t full_base = tab->automaton->insn_equiv_classes_num * vect_num; - if (VEC_length (vect_el_t, tab->full_vect) < full_base + vect_length) - VEC_safe_grow (vect_el_t, heap, tab->full_vect, - full_base + vect_length); + if (tab->full_vect.length () < full_base + vect_length) + tab->full_vect.safe_grow (full_base + vect_length); for (i = 0; i < vect_length; i++) - VEC_replace (vect_el_t, tab->full_vect, full_base + i, - VEC_index (vect_el_t, vect, i)); + tab->full_vect[full_base + i] = vect[i]; } /* The comb_vect min/max values are also used for the full vector, so compute them now. */ for (vect_index = 0; vect_index < vect_length; vect_index++) - if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value) + if (vect[vect_index] != undefined_vect_el_value) { - vect_el_t x = VEC_index (vect_el_t, vect, vect_index); + vect_el_t x = vect[vect_index]; gcc_assert (x >= 0); if (tab->max_comb_vect_el_value < x) tab->max_comb_vect_el_value = x; @@ -7395,14 +7365,13 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) return; /* Form comb vector in the table: */ - gcc_assert (VEC_length (vect_el_t, tab->comb_vect) - == VEC_length (vect_el_t, tab->check_vect)); + gcc_assert (tab->comb_vect.length () == tab->check_vect.length ()); - comb_vect_els_num = VEC_length (vect_el_t, tab->comb_vect); + comb_vect_els_num = tab->comb_vect.length (); for (first_unempty_vect_index = 0; first_unempty_vect_index < vect_length; first_unempty_vect_index++) - if (VEC_index (vect_el_t, vect, first_unempty_vect_index) + if (vect[first_unempty_vect_index] != undefined_vect_el_value) break; @@ -7419,10 +7388,9 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) vect_index < vect_length && vect_index + comb_vect_index < comb_vect_els_num; vect_index++) - if (VEC_index (vect_el_t, vect, vect_index) + if (vect[vect_index] != undefined_vect_el_value - && (VEC_index (vect_el_t, tab->comb_vect, - vect_index + comb_vect_index) + && (tab->comb_vect[vect_index + comb_vect_index] != undefined_vect_el_value)) break; if (vect_index >= vect_length @@ -7439,7 +7407,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) vect_index++) { vect_mask = vect_mask << 1; - if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value) + if (vect[vect_index] != undefined_vect_el_value) vect_mask |= 1; } @@ -7455,7 +7423,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) { comb_vect_mask <<= 1; if (vect_index + comb_vect_index < comb_vect_els_num - && VEC_index (vect_el_t, tab->comb_vect, vect_index + comb_vect_index) + && tab->comb_vect[vect_index + comb_vect_index] != undefined_vect_el_value) comb_vect_mask |= 1; } @@ -7466,7 +7434,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) comb_vect_index++, i++) { comb_vect_mask = (comb_vect_mask << 1) | 1; - comb_vect_mask ^= (VEC_index (vect_el_t, tab->comb_vect, i) + comb_vect_mask ^= (tab->comb_vect[i] == undefined_vect_el_value); if ((vect_mask & comb_vect_mask) == 0) goto found; @@ -7488,25 +7456,22 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) no_state_value = tab->automaton->achieved_states_num; while (additional_els_num > 0) { - VEC_safe_push (vect_el_t, heap, tab->comb_vect, vect_el); - VEC_safe_push (vect_el_t, heap, tab->check_vect, no_state_value); + tab->comb_vect.safe_push (vect_el); + tab->check_vect.safe_push (no_state_value); additional_els_num--; } - gcc_assert (VEC_length (vect_el_t, tab->comb_vect) + gcc_assert (tab->comb_vect.length () >= comb_vect_index + real_vect_length); /* Fill comb and check vectors. */ for (vect_index = 0; vect_index < vect_length; vect_index++) - if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value) + if (vect[vect_index] != undefined_vect_el_value) { - vect_el_t x = VEC_index (vect_el_t, vect, vect_index); - gcc_assert (VEC_index (vect_el_t, tab->comb_vect, - comb_vect_index + vect_index) + vect_el_t x = vect[vect_index]; + gcc_assert (tab->comb_vect[comb_vect_index + vect_index] == undefined_vect_el_value); gcc_assert (x >= 0); - VEC_replace (vect_el_t, tab->comb_vect, - comb_vect_index + vect_index, x); - VEC_replace (vect_el_t, tab->check_vect, - comb_vect_index + vect_index, vect_num); + tab->comb_vect[comb_vect_index + vect_index] = x; + tab->check_vect[comb_vect_index + vect_index] = vect_num; } if (tab->max_comb_vect_el_value < undefined_vect_el_value) tab->max_comb_vect_el_value = undefined_vect_el_value; @@ -7517,7 +7482,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) if (tab->min_base_vect_el_value > comb_vect_index) tab->min_base_vect_el_value = comb_vect_index; - VEC_replace (vect_el_t, tab->base_vect, vect_num, comb_vect_index); + tab->base_vect[vect_num] = comb_vect_index; } /* Return number of out arcs of STATE. */ @@ -7558,29 +7523,29 @@ compare_transition_els_num (const void *state_ptr_1, /* The function adds element EL_VALUE to vector VECT for a table state x AINSN. */ static void -add_vect_el (vla_hwint_t *vect, ainsn_t ainsn, int el_value) +add_vect_el (vla_hwint_t &vect, ainsn_t ainsn, int el_value) { int equiv_class_num; int vect_index; gcc_assert (ainsn); equiv_class_num = ainsn->insn_equiv_class_num; - for (vect_index = VEC_length (vect_el_t, *vect); + for (vect_index = vect.length (); vect_index <= equiv_class_num; vect_index++) - VEC_safe_push (vect_el_t, heap, *vect, undefined_vect_el_value); - VEC_replace (vect_el_t, *vect, equiv_class_num, el_value); + vect.safe_push (undefined_vect_el_value); + vect[equiv_class_num] = el_value; } /* This is for forming vector of states of an automaton. */ -static VEC(state_t, heap) *output_states_vect; +static vec<state_t> output_states_vect; /* The function is called by function pass_states. The function adds STATE to `output_states_vect'. */ static void add_states_vect_el (state_t state) { - VEC_safe_push (state_t, heap, output_states_vect, state); + output_states_vect.safe_push (state); } /* Form and output vectors (comb, check, base or full vector) @@ -7590,30 +7555,30 @@ output_trans_table (automaton_t automaton) { size_t i; arc_t arc; - vla_hwint_t transition_vect = 0; + vla_hwint_t transition_vect = vla_hwint_t(); undefined_vect_el_value = automaton->achieved_states_num; automaton->trans_table = create_state_ainsn_table (automaton); /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ - output_states_vect = 0; + output_states_vect.create (0); pass_states (automaton, add_states_vect_el); - VEC_qsort (state_t, output_states_vect, compare_transition_els_num); + output_states_vect.qsort (compare_transition_els_num); - for (i = 0; i < VEC_length (state_t, output_states_vect); i++) + for (i = 0; i < output_states_vect.length (); i++) { - VEC_truncate (vect_el_t, transition_vect, 0); - for (arc = first_out_arc (VEC_index (state_t, output_states_vect, i)); + transition_vect.truncate (0); + for (arc = first_out_arc (output_states_vect[i]); arc != NULL; arc = next_out_arc (arc)) { gcc_assert (arc->insn); if (arc->insn->first_ainsn_with_given_equivalence_num) - add_vect_el (&transition_vect, arc->insn, + add_vect_el (transition_vect, arc->insn, arc->to_state->order_state_num); } add_vect (automaton->trans_table, - VEC_index (state_t, output_states_vect, i)->order_state_num, + output_states_vect[i]->order_state_num, transition_vect); } output_state_ainsn_table @@ -7621,8 +7586,8 @@ output_trans_table (automaton_t automaton) output_trans_full_vect_name, output_trans_comb_vect_name, output_trans_check_vect_name, output_trans_base_vect_name); - VEC_free (state_t, heap, output_states_vect); - VEC_free (vect_el_t, heap, transition_vect); + output_states_vect.release (); + transition_vect.release (); } /* Form and output vectors representing minimal issue delay table of @@ -7641,14 +7606,14 @@ output_min_issue_delay_table (automaton_t automaton) /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ - output_states_vect = 0; + output_states_vect.create (0); pass_states (automaton, add_states_vect_el); - min_issue_delay_len = (VEC_length (state_t, output_states_vect) + min_issue_delay_len = (output_states_vect.length () * automaton->insn_equiv_classes_num); - min_issue_delay_vect = VEC_alloc (vect_el_t, heap, min_issue_delay_len); + min_issue_delay_vect.create (min_issue_delay_len); for (i = 0; i < min_issue_delay_len; i++) - VEC_quick_push (vect_el_t, min_issue_delay_vect, -1); + min_issue_delay_vect.quick_push (-1); automaton->max_min_delay = 0; @@ -7658,10 +7623,10 @@ output_min_issue_delay_table (automaton_t automaton) changed = 0; - for (state_no = 0; state_no < VEC_length (state_t, output_states_vect); + for (state_no = 0; state_no < output_states_vect.length (); state_no++) { - state_t s = VEC_index (state_t, output_states_vect, state_no); + state_t s = output_states_vect[state_no]; arc_t arc; for (arc = first_out_arc (s); arc; arc = next_out_arc (arc)) @@ -7672,10 +7637,9 @@ output_min_issue_delay_table (automaton_t automaton) * automaton->insn_equiv_classes_num + arc->insn->insn_equiv_class_num; - if (VEC_index (vect_el_t, min_issue_delay_vect, asn)) + if (min_issue_delay_vect[asn]) { - VEC_replace (vect_el_t, min_issue_delay_vect, asn, - (vect_el_t) 0); + min_issue_delay_vect[asn] = (vect_el_t) 0; changed = 1; } @@ -7690,8 +7654,8 @@ output_min_issue_delay_table (automaton_t automaton) n1 = arc->to_state->order_state_num * automaton->insn_equiv_classes_num + k; - delay0 = VEC_index (vect_el_t, min_issue_delay_vect, n0); - delay1 = VEC_index (vect_el_t, min_issue_delay_vect, n1); + delay0 = min_issue_delay_vect[n0]; + delay1 = min_issue_delay_vect[n1]; if (delay1 != -1) { if (arc->insn->insn_reserv_decl @@ -7699,7 +7663,7 @@ output_min_issue_delay_table (automaton_t automaton) delay1++; if (delay1 < delay0 || delay0 == -1) { - VEC_replace (vect_el_t, min_issue_delay_vect, n0, delay1); + min_issue_delay_vect[n0] = delay1; changed = 1; } } @@ -7714,19 +7678,18 @@ output_min_issue_delay_table (automaton_t automaton) for (ainsn = automaton->ainsn_list; ainsn; ainsn = ainsn->next_ainsn) if (ainsn->first_ainsn_with_given_equivalence_num) { - for (i = 0; i < VEC_length (state_t, output_states_vect); i++) + for (i = 0; i < output_states_vect.length (); i++) { - state_t s = VEC_index (state_t, output_states_vect, i); + state_t s = output_states_vect[i]; size_t np = s->order_state_num * automaton->insn_equiv_classes_num + ainsn->insn_equiv_class_num; - vect_el_t x = VEC_index (vect_el_t, min_issue_delay_vect, np); + vect_el_t x = min_issue_delay_vect[np]; if (automaton->max_min_delay < x) automaton->max_min_delay = x; if (x == -1) - VEC_replace (vect_el_t, min_issue_delay_vect, np, - (vect_el_t) 0); + min_issue_delay_vect[np] = (vect_el_t) 0; } } @@ -7748,26 +7711,25 @@ output_min_issue_delay_table (automaton_t automaton) automaton->min_issue_delay_table_compression_factor = cfactor; compressed_min_issue_delay_len = (min_issue_delay_len+cfactor-1) / cfactor; - compressed_min_issue_delay_vect - = VEC_alloc (vect_el_t, heap, compressed_min_issue_delay_len); + compressed_min_issue_delay_vect.create (compressed_min_issue_delay_len); for (i = 0; i < compressed_min_issue_delay_len; i++) - VEC_quick_push (vect_el_t, compressed_min_issue_delay_vect, 0); + compressed_min_issue_delay_vect.quick_push (0); for (i = 0; i < min_issue_delay_len; i++) { size_t ci = i / cfactor; - vect_el_t x = VEC_index (vect_el_t, min_issue_delay_vect, i); - vect_el_t cx = VEC_index (vect_el_t, compressed_min_issue_delay_vect, ci); + vect_el_t x = min_issue_delay_vect[i]; + vect_el_t cx = compressed_min_issue_delay_vect[ci]; cx |= x << (8 - (i % cfactor + 1) * (8 / cfactor)); - VEC_replace (vect_el_t, compressed_min_issue_delay_vect, ci, cx); + compressed_min_issue_delay_vect[ci] = cx; } output_vect (compressed_min_issue_delay_vect); fprintf (output_file, "};\n\n"); - VEC_free (state_t, heap, output_states_vect); - VEC_free (vect_el_t, heap, min_issue_delay_vect); - VEC_free (vect_el_t, heap, compressed_min_issue_delay_vect); + output_states_vect.release (); + min_issue_delay_vect.release (); + compressed_min_issue_delay_vect.release (); } /* Form and output vector representing the locked states of @@ -7777,32 +7739,30 @@ output_dead_lock_vect (automaton_t automaton) { size_t i; arc_t arc; - vla_hwint_t dead_lock_vect = 0; + vla_hwint_t dead_lock_vect = vla_hwint_t(); /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ automaton->locked_states = 0; - output_states_vect = 0; + output_states_vect.create (0); pass_states (automaton, add_states_vect_el); - VEC_safe_grow (vect_el_t, heap, dead_lock_vect, - VEC_length (state_t, output_states_vect)); - for (i = 0; i < VEC_length (state_t, output_states_vect); i++) + dead_lock_vect.safe_grow (output_states_vect.length ()); + for (i = 0; i < output_states_vect.length (); i++) { - state_t s = VEC_index (state_t, output_states_vect, i); + state_t s = output_states_vect[i]; arc = first_out_arc (s); gcc_assert (arc); if (next_out_arc (arc) == NULL && (arc->insn->insn_reserv_decl == DECL_INSN_RESERV (advance_cycle_insn_decl))) { - VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, 1); + dead_lock_vect[s->order_state_num] = 1; automaton->locked_states++; } else - VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, - (vect_el_t) 0); + dead_lock_vect[s->order_state_num] = (vect_el_t) 0; } if (automaton->locked_states == 0) return; @@ -7815,8 +7775,8 @@ output_dead_lock_vect (automaton_t automaton) fprintf (output_file, "[] = {\n"); output_vect (dead_lock_vect); fprintf (output_file, "};\n\n"); - VEC_free (state_t, heap, output_states_vect); - VEC_free (vect_el_t, heap, dead_lock_vect); + output_states_vect.release (); + dead_lock_vect.release (); } /* Form and output vector representing reserved units of the states of @@ -7824,7 +7784,7 @@ output_dead_lock_vect (automaton_t automaton) static void output_reserved_units_table (automaton_t automaton) { - vla_hwint_t reserved_units_table = 0; + vla_hwint_t reserved_units_table = vla_hwint_t(); int state_byte_size; int reserved_units_size; size_t n; @@ -7834,30 +7794,30 @@ output_reserved_units_table (automaton_t automaton) return; /* Create vect of pointers to states. */ - output_states_vect = 0; + output_states_vect.create (0); pass_states (automaton, add_states_vect_el); /* Create vector. */ state_byte_size = (description->query_units_num + 7) / 8; - reserved_units_size = (VEC_length (state_t, output_states_vect) + reserved_units_size = (output_states_vect.length () * state_byte_size); - reserved_units_table = VEC_alloc (vect_el_t, heap, reserved_units_size); + reserved_units_table.create (reserved_units_size); for (i = 0; i < reserved_units_size; i++) - VEC_quick_push (vect_el_t, reserved_units_table, 0); - for (n = 0; n < VEC_length (state_t, output_states_vect); n++) + reserved_units_table.quick_push (0); + for (n = 0; n < output_states_vect.length (); n++) { - state_t s = VEC_index (state_t, output_states_vect, n); + state_t s = output_states_vect[n]; for (i = 0; i < description->units_num; i++) if (units_array [i]->query_p && first_cycle_unit_presence (s, i)) { int ri = (s->order_state_num * state_byte_size + units_array [i]->query_num / 8); - vect_el_t x = VEC_index (vect_el_t, reserved_units_table, ri); + vect_el_t x = reserved_units_table[ri]; x += 1 << (units_array [i]->query_num % 8); - VEC_replace (vect_el_t, reserved_units_table, ri, x); + reserved_units_table[ri] = x; } } fprintf (output_file, "\n#if %s\n", CPU_UNITS_QUERY_MACRO_NAME); @@ -7871,8 +7831,8 @@ output_reserved_units_table (automaton_t automaton) fprintf (output_file, "};\n#endif /* #if %s */\n\n", CPU_UNITS_QUERY_MACRO_NAME); - VEC_free (state_t, heap, output_states_vect); - VEC_free (vect_el_t, heap, reserved_units_table); + output_states_vect.release (); + reserved_units_table.release (); } /* The function outputs all tables representing DFA(s) used for fast @@ -8988,7 +8948,7 @@ output_automaton_units (automaton_t automaton) /* The following variable is used for forming array of all possible cpu unit reservations described by the current DFA state. */ -static VEC(reserv_sets_t, heap) *state_reservs; +static vec<reserv_sets_t> state_reservs; /* The function forms `state_reservs' for STATE. */ static void @@ -9002,7 +8962,7 @@ add_state_reservs (state_t state) curr_alt_state = curr_alt_state->next_sorted_alt_state) add_state_reservs (curr_alt_state->state); else - VEC_safe_push (reserv_sets_t, heap, state_reservs, state->reservs); + state_reservs.safe_push (state->reservs); } /* The function outputs readable representation of all out arcs of @@ -9070,15 +9030,13 @@ remove_state_duplicate_reservs (void) { size_t i, j; - for (i = 1, j = 0; i < VEC_length (reserv_sets_t, state_reservs); i++) - if (reserv_sets_cmp (VEC_index (reserv_sets_t, state_reservs, j), - VEC_index (reserv_sets_t, state_reservs, i))) + for (i = 1, j = 0; i < state_reservs.length (); i++) + if (reserv_sets_cmp (state_reservs[j], state_reservs[i])) { j++; - VEC_replace (reserv_sets_t, state_reservs, j, - VEC_index (reserv_sets_t, state_reservs, i)); + state_reservs[j] = state_reservs[i]; } - VEC_truncate (reserv_sets_t, state_reservs, j + 1); + state_reservs.truncate (j + 1); } /* The following function output readable representation of DFA(s) @@ -9090,24 +9048,23 @@ output_state (state_t state) { size_t i; - state_reservs = 0; + state_reservs.create (0); fprintf (output_description_file, " State #%d", state->order_state_num); fprintf (output_description_file, state->new_cycle_p ? " (new cycle)\n" : "\n"); add_state_reservs (state); - VEC_qsort (reserv_sets_t, state_reservs, state_reservs_cmp); + state_reservs.qsort (state_reservs_cmp); remove_state_duplicate_reservs (); - for (i = 0; i < VEC_length (reserv_sets_t, state_reservs); i++) + for (i = 0; i < state_reservs.length (); i++) { fprintf (output_description_file, " "); - output_reserv_sets (output_description_file, - VEC_index (reserv_sets_t, state_reservs, i)); + output_reserv_sets (output_description_file, state_reservs[i]); fprintf (output_description_file, "\n"); } fprintf (output_description_file, "\n"); output_state_arcs (state); - VEC_free (reserv_sets_t, heap, state_reservs); + state_reservs.release (); } /* The following function output readable representation of @@ -9172,8 +9129,8 @@ output_statistics (FILE *f) #ifndef NDEBUG fprintf (f, "%5ld transition comb vector els, %5ld trans table els: %s\n", - (long) VEC_length (vect_el_t, automaton->trans_table->comb_vect), - (long) VEC_length (vect_el_t, automaton->trans_table->full_vect), + (long) automaton->trans_table->comb_vect.length (), + (long) automaton->trans_table->full_vect.length (), (comb_vect_p (automaton->trans_table) ? "use comb vect" : "use simple vect")); fprintf @@ -9181,9 +9138,9 @@ output_statistics (FILE *f) (long) states_num * automaton->insn_equiv_classes_num, automaton->min_issue_delay_table_compression_factor); transition_comb_vect_els - += VEC_length (vect_el_t, automaton->trans_table->comb_vect); + += automaton->trans_table->comb_vect.length (); transition_full_vect_els - += VEC_length (vect_el_t, automaton->trans_table->full_vect); + += automaton->trans_table->full_vect.length (); min_issue_delay_vect_els += states_num * automaton->insn_equiv_classes_num; locked_states @@ -9393,14 +9350,14 @@ check_automata_insn_issues (void) /* The following vla is used for storing pointers to all achieved states. */ -static VEC(state_t, heap) *automaton_states; +static vec<state_t> automaton_states; /* This function is called by function pass_states to add an achieved STATE. */ static void add_automaton_state (state_t state) { - VEC_safe_push (state_t, heap, automaton_states, state); + automaton_states.safe_push (state); } /* The following function forms list of important automata (whose @@ -9415,17 +9372,17 @@ form_important_insn_automata_lists (void) int i; size_t n; - automaton_states = 0; + automaton_states.create (0); /* Mark important ainsns. */ for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { - VEC_truncate (state_t, automaton_states, 0); + automaton_states.truncate (0); pass_states (automaton, add_automaton_state); - for (n = 0; n < VEC_length (state_t, automaton_states); n++) + for (n = 0; n < automaton_states.length (); n++) { - state_t s = VEC_index (state_t, automaton_states, n); + state_t s = automaton_states[n]; for (arc = first_out_arc (s); arc != NULL; arc = next_out_arc (arc)) @@ -9439,7 +9396,7 @@ form_important_insn_automata_lists (void) } } } - VEC_free (state_t, heap, automaton_states); + automaton_states.release (); /* Create automata sets for the insns. */ for (i = 0; i < description->decls_num; i++) @@ -9477,13 +9434,13 @@ expand_automata (void) description = XCREATENODEVAR (struct description, sizeof (struct description) /* Two entries for special insns. */ - + sizeof (decl_t) * (VEC_length (decl_t, decls) + 1)); - description->decls_num = VEC_length (decl_t, decls); + + sizeof (decl_t) * (decls.length () + 1)); + description->decls_num = decls.length (); description->normal_decls_num = description->decls_num; description->query_units_num = 0; for (i = 0; i < description->decls_num; i++) { - description->decls [i] = VEC_index (decl_t, decls, i); + description->decls [i] = decls[i]; if (description->decls [i]->mode == dm_unit && DECL_UNIT (description->decls [i])->query_p) DECL_UNIT (description->decls [i])->query_num @@ -9694,7 +9651,7 @@ main (int argc, char **argv) if (have_error) return FATAL_EXIT_CODE; - if (VEC_length (decl_t, decls) > 0) + if (decls.length () > 0) { expand_automata (); if (!have_error) |