]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
r110125@banpei: zack | 2006-01-22 14:46:46 -0800
authorZack Weinberg <zackw@panix.com>
Mon, 23 Jan 2006 15:15:34 +0000 (15:15 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Mon, 23 Jan 2006 15:15:34 +0000 (15:15 +0000)
 r110125@banpei:  zack | 2006-01-22 14:46:46 -0800
  * genautomata.c:  Include vec.h, not varray.h.
  Delete vla_ptr_t, all of the VLA_PTR_ macros, and all of the
  VLA_HWINT_ macros.  Change vla_hwint_t to a typedef for
  VEC(vect_el_t,heap) *.  Convert all uses of VLA_* macros to
  VEC_* macros operating on appropriately typed vectors, or to
  malloced arrays when the size is known in advance.  Const-ify
  many char* variables and function arguments.  No functional changes.
  * Makefile.in (build/varray.o): Delete rule.
  (build/genattrtab): Depend on build/vec.o instead of build/varray.o.
  (build/genautomata.o): Depend on vec.h instead of $(VARRAY_H).

From-SVN: r110121

gcc/ChangeLog
gcc/Makefile.in
gcc/genautomata.c

index b67c0339b6c92728f152cd3bb9c38091da819e7e..3224426efbff875dd2fca1ddb681313af3efb078 100644 (file)
@@ -1,3 +1,16 @@
+2006-01-22  Zack Weinberg  <zackw@panix.com>
+
+       * genautomata.c:  Include vec.h, not varray.h.
+       Delete vla_ptr_t, all of the VLA_PTR_ macros, and all of the
+       VLA_HWINT_ macros.  Change vla_hwint_t to a typedef for
+       VEC(vect_el_t,heap) *.  Convert all uses of VLA_* macros to
+       VEC_* macros operating on appropriately typed vectors, or to
+       malloced arrays when the size is known in advance.  Const-ify
+       many char* variables and function arguments.  No functional changes.
+       * Makefile.in (build/varray.o): Delete rule.
+       (build/genattrtab): Depend on build/vec.o instead of build/varray.o.
+       (build/genautomata.o): Depend on vec.h instead of $(VARRAY_H).
+
 2006-01-22  Zack Weinberg  <zackw@panix.com>
 
        * gensupport.c: Define get_insn_name and record_insn_name here.
index 6d25f9001c10ebfb8ca660e64e887c581e78efda..f9e85d211921211164367b3eb67ba59fa4253215 100644 (file)
@@ -2894,8 +2894,6 @@ build/read-rtl.o: read-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
   $(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) $(HASHTAB_H) gensupport.h
 build/rtl.o: rtl.c $(BCONFIG_H) coretypes.h $(GTM_H) $(SYSTEM_H)       \
   $(RTL_H) real.h $(GGC_H) errors.h
-build/varray.o: varray.c $(BCONFIG_H) coretypes.h $(GTM_H) $(SYSTEM_H) \
-  $(VARRAY_H) $(RTL_BASE_H) $(GGC_H) $(TREE_H) bitmap.h errors.h
 build/vec.o : vec.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) coretypes.h vec.h \
    $(GGC_H) toplev.h
 build/gencondmd.o : build/gencondmd.c $(CONFIG_H) $(SYSTEM_H) $(GTM_H) \
@@ -2910,7 +2908,7 @@ build/genattrtab.o : genattrtab.c $(RTL_BASE_H) $(OBSTACK_H)              \
   $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(GGC_H)      \
   gensupport.h genattrtab.h
 build/genautomata.o : genautomata.c $(RTL_BASE_H) $(OBSTACK_H)         \
-  $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(VARRAY_H)   \
+  $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h vec.h         \
   genattrtab.h $(HASHTAB_H)
 build/gencheck.o : gencheck.c gencheck.h tree.def $(BCONFIG_H) $(GTM_H)        \
        $(SYSTEM_H) coretypes.h $(lang_tree_files)
@@ -2968,7 +2966,7 @@ $(genprogmd:%=build/gen%$(build_exeext)): $(BUILD_RTL) $(BUILD_ERRORS)
 
 # These programs need files over and above what they get from the above list.
 build/genextract$(build_exeext) : build/vec.o
-build/genattrtab$(build_exeext) : build/genautomata.o build/varray.o
+build/genattrtab$(build_exeext) : build/genautomata.o build/vec.o
 build/genattrtab$(build_exeext) : BUILD_LIBS += -lm
 
 # These programs are not linked with the MD reader.
index e39d32727a9564ffd27d5f9074f9761b99b5f9d2..987d1e78275e41b0b9f2ee663847e7105f3e321d 100644 (file)
@@ -113,6 +113,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include <math.h>
 #include "hashtab.h"
 #include "varray.h"
+#include "vec.h"
 
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
@@ -132,17 +133,6 @@ typedef unsigned HOST_WIDE_INT set_el_t;
    type.  */
 typedef set_el_t *reserv_sets_t;
 
-/* The following structure represents variable length array (vla) of
-   pointers and HOST WIDE INTs.  We could be use only varray.  But we
-   add new lay because we add elements very frequently and this could
-   stress OS allocator when varray is used only.  */
-typedef struct {
-  size_t length;      /* current size of vla.  */
-  varray_type varray; /* container for vla.  */
-} vla_ptr_t;
-
-typedef vla_ptr_t vla_hwint_t;
-
 /* The following structure describes a ticker.  */
 struct ticker
 {
@@ -218,24 +208,24 @@ typedef struct state_ainsn_table *state_ainsn_table_t;
 
 static void *create_node             (size_t);
 static void *copy_node               (const void *, size_t);
-static char *check_name              (char *, pos_t);
-static char *next_sep_el             (char **, int, int);
-static int n_sep_els                 (char *, int, int);
-static char **get_str_vect           (char *, int *, int, int);
+static const char *check_name        (const char *, pos_t);
+static char *next_sep_el             (const char **, int, int);
+static int n_sep_els                 (const char *, int, int);
+static char **get_str_vect           (const char *, int *, int, int);
 static void gen_presence_absence_set (rtx, int, int);
-static regexp_t gen_regexp_el        (char *);
-static regexp_t gen_regexp_repeat    (char *);
-static regexp_t gen_regexp_allof     (char *);
-static regexp_t gen_regexp_oneof     (char *);
-static regexp_t gen_regexp_sequence  (char *);
-static regexp_t gen_regexp           (char *);
+static regexp_t gen_regexp_el        (const char *);
+static regexp_t gen_regexp_repeat    (const char *);
+static regexp_t gen_regexp_allof     (const char *);
+static regexp_t gen_regexp_oneof     (const char *);
+static regexp_t gen_regexp_sequence  (const char *);
+static regexp_t gen_regexp           (const char *);
 
 static unsigned string_hash          (const char *);
 static unsigned automaton_decl_hash  (const void *);
 static int automaton_decl_eq_p       (const void *,
                                      const void *);
 static decl_t insert_automaton_decl       (decl_t);
-static decl_t find_automaton_decl         (char *);
+static decl_t find_automaton_decl         (const char *);
 static void initiate_automaton_decl_table (void);
 static void finish_automaton_decl_table   (void);
 
@@ -243,7 +233,7 @@ static hashval_t insn_decl_hash           (const void *);
 static int insn_decl_eq_p                 (const void *,
                                           const void *);
 static decl_t insert_insn_decl            (decl_t);
-static decl_t find_insn_decl              (char *);
+static decl_t find_insn_decl              (const char *);
 static void initiate_insn_decl_table      (void);
 static void finish_insn_decl_table        (void);
 
@@ -251,7 +241,7 @@ static hashval_t decl_hash                (const void *);
 static int decl_eq_p                      (const void *,
                                           const void *);
 static decl_t insert_decl                 (decl_t);
-static decl_t find_decl                   (char *);
+static decl_t find_decl                   (const char *);
 static void initiate_decl_table           (void);
 static void finish_decl_table             (void);
 
@@ -385,7 +375,6 @@ static void form_ainsn_with_same_reservs    (automaton_t);
 static reserv_sets_t form_reservs_matter (automaton_t);
 static void make_automaton           (automaton_t);
 static void form_arcs_marked_by_insn (state_t);
-static int create_composed_state     (state_t, arc_t, vla_ptr_t *);
 static void NDFA_to_DFA              (automaton_t);
 static void pass_state_graph         (state_t, void (*) (state_t));
 static void pass_states              (automaton_t,
@@ -394,15 +383,8 @@ static void initiate_pass_states       (void);
 static void add_achieved_state         (state_t);
 static int set_out_arc_insns_equiv_num (state_t, int);
 static void clear_arc_insns_equiv_num  (state_t);
-static void copy_equiv_class           (vla_ptr_t *to,
-                                       const vla_ptr_t *from);
 static int first_cycle_unit_presence   (state_t, int);
 static int state_is_differed           (state_t, state_t, int, int);
-static state_t init_equiv_class        (state_t *states, int);
-static int partition_equiv_class       (state_t *, int,
-                                       vla_ptr_t *, int *);
-static void evaluate_equiv_classes     (automaton_t, vla_ptr_t *);
-static void merge_states               (automaton_t, vla_ptr_t *);
 static void set_new_cycle_flags        (state_t);
 static void minimize_DFA               (automaton_t);
 static void incr_states_and_arcs_nums  (state_t);
@@ -434,7 +416,6 @@ static void output_range_type            (FILE *, long int, long int);
 static int longest_path_length           (state_t);
 static void process_state_longest_path_length (state_t);
 static void output_dfa_max_issue_rate    (void);
-static void output_vect                  (vect_el_t *, int);
 static void output_chip_member_name      (FILE *, automaton_t);
 static void output_temp_chip_member_name (FILE *, automaton_t);
 static void output_translate_vect_name   (FILE *, automaton_t);
@@ -455,15 +436,11 @@ static void output_translate_vect        (automaton_t);
 static int comb_vect_p                   (state_ainsn_table_t);
 static state_ainsn_table_t create_state_ainsn_table (automaton_t);
 static void output_state_ainsn_table
-   (state_ainsn_table_t, char *, void (*) (FILE *, automaton_t),
+   (state_ainsn_table_t, const char *, void (*) (FILE *, automaton_t),
     void (*) (FILE *, automaton_t), void (*) (FILE *, automaton_t),
     void (*) (FILE *, automaton_t));
-static void add_vect                     (state_ainsn_table_t,
-                                         int, vect_el_t *, int);
 static int out_state_arcs_num            (state_t);
 static int compare_transition_els_num    (const void *, const void *);
-static void add_vect_el                 (vla_hwint_t *,
-                                         ainsn_t, int);
 static void add_states_vect_el           (state_t);
 static void output_trans_table           (automaton_t);
 static void output_state_alts_table      (automaton_t);
@@ -539,110 +516,22 @@ static pos_t no_pos = 0;
 static struct obstack irp;
 
 \f
-
-/* This page contains code for work with variable length array (vla)
-   of pointers.  We could be use only varray.  But we add new lay
-   because we add elements very frequently and this could stress OS
-   allocator when varray is used only.  */
-
-/* Start work with vla.  */
-#define VLA_PTR_CREATE(vla, allocated_length, name)     \
-  do                                                                    \
-    {   \
-      vla_ptr_t *const _vla_ptr = &(vla);                                \
-        \
-      VARRAY_GENERIC_PTR_INIT (_vla_ptr->varray, allocated_length, name);\
-      _vla_ptr->length = 0;                                              \
-    }                                                                   \
-  while (0)
-
-/* Finish work with the vla.  */
-#define VLA_PTR_DELETE(vla) VARRAY_FREE ((vla).varray)
-
-/* Return start address of the vla.  */
-#define VLA_PTR_BEGIN(vla) ((void *) &VARRAY_GENERIC_PTR ((vla).varray, 0))
-
-/* Address of the last element of the vla.  Do not use side effects in
-   the macro argument.  */
-#define VLA_PTR_LAST(vla) (&VARRAY_GENERIC_PTR ((vla).varray,         \
-                                                (vla).length - 1))
-/* Nullify the vla.  */
-#define VLA_PTR_NULLIFY(vla)  ((vla).length = 0)
-
-/* Shorten the vla on given number bytes.  */
-#define VLA_PTR_SHORTEN(vla, n)  ((vla).length -= (n))
-
-/* Expand the vla on N elements.  The values of new elements are
-   undefined.  */
-#define VLA_PTR_EXPAND(vla, n)                                        \
-  do {                                                                \
-    vla_ptr_t *const _expand_vla_ptr = &(vla);                        \
-    const size_t _new_length = (n) + _expand_vla_ptr->length;         \
-                                                                      \
-    if (VARRAY_SIZE (_expand_vla_ptr->varray) < _new_length)          \
-      VARRAY_GROW (_expand_vla_ptr->varray,                           \
-                   (_new_length - _expand_vla_ptr->length < 128       \
-                    ? _expand_vla_ptr->length + 128 : _new_length));  \
-    _expand_vla_ptr->length = _new_length;                            \
-  } while (0)
-
-/* Add element to the end of the vla.  */
-#define VLA_PTR_ADD(vla, ptr)                                           \
-  do {                                                                  \
-    vla_ptr_t *const _vla_ptr = &(vla);                                 \
-                                                                        \
-    VLA_PTR_EXPAND (*_vla_ptr, 1);                                      \
-    VARRAY_GENERIC_PTR (_vla_ptr->varray, _vla_ptr->length - 1) = (ptr);\
-  } while (0)
-
-/* Length of the vla in elements.  */
-#define VLA_PTR_LENGTH(vla) ((vla).length)
-
-/* N-th element of the vla.  */
-#define VLA_PTR(vla, n) VARRAY_GENERIC_PTR ((vla).varray, n)
-
-
-/* The following macros are analogous to the previous ones but for
-   VLAs of HOST WIDE INTs.  */
-
-#define VLA_HWINT_CREATE(vla, allocated_length, name)                 \
-  do {                                                                \
-    vla_hwint_t *const _vla_ptr = &(vla);                             \
-                                                                      \
-    VARRAY_WIDE_INT_INIT (_vla_ptr->varray, allocated_length, name);  \
-    _vla_ptr->length = 0;                                             \
-  } while (0)
-
-#define VLA_HWINT_DELETE(vla) VARRAY_FREE ((vla).varray)
-
-#define VLA_HWINT_BEGIN(vla) (&VARRAY_WIDE_INT ((vla).varray, 0))
-
-#define VLA_HWINT_NULLIFY(vla)  ((vla).length = 0)
-
-#define VLA_HWINT_EXPAND(vla, n)                                      \
-  do {                                                                \
-    vla_hwint_t *const _expand_vla_ptr = &(vla);                      \
-    const size_t _new_length = (n) + _expand_vla_ptr->length;         \
-                                                                      \
-    if (VARRAY_SIZE (_expand_vla_ptr->varray) < _new_length)          \
-      VARRAY_GROW (_expand_vla_ptr->varray,                           \
-                   (_new_length - _expand_vla_ptr->length < 128       \
-                    ? _expand_vla_ptr->length + 128 : _new_length));  \
-    _expand_vla_ptr->length = _new_length;                            \
-  } while (0)
-
-#define VLA_HWINT_ADD(vla, ptr)                                       \
-  do {                                                                \
-    vla_hwint_t *const _vla_ptr = &(vla);                             \
-                                                                      \
-    VLA_HWINT_EXPAND (*_vla_ptr, 1);                                  \
-    VARRAY_WIDE_INT (_vla_ptr->varray, _vla_ptr->length - 1) = (ptr); \
-  } while (0)
-
-#define VLA_HWINT_LENGTH(vla) ((vla).length)
-
-#define VLA_HWINT(vla, n) VARRAY_WIDE_INT ((vla).varray, n)
-
+/* 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;
 \f
 
 /* Options with the following names can be set up in automata_option
@@ -727,9 +616,9 @@ enum decl_mode
    rtl.def).  */
 struct unit_decl
 {
-  char *name;
+  const char *name;
   /* NULL if the automaton name is absent.  */
-  char *automaton_name;
+  const char *automaton_name;
   /* If the following value is not zero, the cpu unit reservation is
      described in define_query_cpu_unit.  */
   char query_p;
@@ -789,9 +678,9 @@ struct unit_decl
 struct bypass_decl
 {
   int latency;
-  char *out_insn_name;
-  char *in_insn_name;
-  char *bypass_guard_name;
+  const char *out_insn_name;
+  const char *in_insn_name;
+  const char *bypass_guard_name;
 
   /* The following fields are defined by checker.  */
 
@@ -805,7 +694,7 @@ struct bypass_decl
 /* This describes define_automaton (see file rtl.def).  */
 struct automaton_decl
 {
-  char *name;
+  const char *name;
 
   /* The following fields are defined by automaton generator.  */
 
@@ -845,7 +734,7 @@ struct unit_pattern_rel_decl
 /* This describes define_reservation (see file rtl.def).  */
 struct reserv_decl
 {
-  char *name;
+  const char *name;
   regexp_t regexp;
 
   /* The following fields are defined by checker.  */
@@ -864,7 +753,7 @@ struct insn_reserv_decl
   rtx condexp;
   int default_latency;
   regexp_t regexp;
-  char *name;
+  const char *name;
 
   /* The following fields are defined by checker.  */
 
@@ -938,14 +827,14 @@ enum regexp_mode
 /* Cpu unit in reservation.  */
 struct unit_regexp
 {
-  char *name;
+  const char *name;
   unit_decl_t unit_decl;
 };
 
 /* Define_reservation in a reservation.  */
 struct reserv_regexp
 {
-  char *name;
+  const char *name;
   struct reserv_decl *reserv_decl;
 };
 
@@ -1532,8 +1421,8 @@ copy_node (const void *from, size_t size)
 }
 
 /* The function checks that NAME does not contain quotes (`"').  */
-static char *
-check_name (char * name, pos_t pos ATTRIBUTE_UNUSED)
+static const char *
+check_name (const char * name, pos_t pos ATTRIBUTE_UNUSED)
 {
   const char *str;
 
@@ -1545,7 +1434,7 @@ check_name (char * name, pos_t pos ATTRIBUTE_UNUSED)
 
 /* Pointers to all declarations during IR generation are stored in the
    following.  */
-static vla_ptr_t decls;
+static VEC(decl_t,heap) *decls;
 
 /* Given a pointer to a (char *) and a separator, return an alloc'ed
    string containing the next separated element, taking parentheses
@@ -1553,10 +1442,10 @@ static vla_ptr_t decls;
    after the string scanned, or the end-of-string.  Return NULL if at
    end of string.  */
 static char *
-next_sep_el (char **pstr, int sep, int par_flag)
+next_sep_el (const char **pstr, int sep, int par_flag)
 {
   char *out_str;
-  char *p;
+  const char *p;
   int pars_num;
   int n_spaces;
 
@@ -1601,7 +1490,7 @@ next_sep_el (char **pstr, int sep, int par_flag)
    nonzero value.  Return 0 for the null string, -1 if parentheses is
    not balanced.  */
 static int
-n_sep_els (char *s, int sep, int par_flag)
+n_sep_els (const char *s, int sep, int par_flag)
 {
   int n;
   int pars_num;
@@ -1626,11 +1515,11 @@ n_sep_els (char *s, int sep, int par_flag)
    function also inserts the end marker NULL at the end of vector.
    Return 0 for the null string, -1 if parentheses are not balanced.  */
 static char **
-get_str_vect (char *str, int *els_num, int sep, int paren_p)
+get_str_vect (const char *str, int *els_num, int sep, int paren_p)
 {
   int i;
   char **vect;
-  char **pstr;
+  const char **pstr;
   char *trail;
 
   *els_num = n_sep_els (str, sep, paren_p);
@@ -1660,8 +1549,7 @@ gen_cpu_unit (rtx def)
   int vect_length;
   int i;
 
-  str_cpu_units = get_str_vect ((char *) XSTR (def, 0), &vect_length, ',',
-                               FALSE);
+  str_cpu_units = get_str_vect (XSTR (def, 0), &vect_length, ',', FALSE);
   if (str_cpu_units == NULL)
     fatal ("invalid string `%s' in define_cpu_unit", XSTR (def, 0));
   for (i = 0; i < vect_length; i++)
@@ -1670,11 +1558,11 @@ gen_cpu_unit (rtx def)
       decl->mode = dm_unit;
       decl->pos = 0;
       DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
-      DECL_UNIT (decl)->automaton_name = (char *) XSTR (def, 1);
+      DECL_UNIT (decl)->automaton_name = XSTR (def, 1);
       DECL_UNIT (decl)->query_p = 0;
       DECL_UNIT (decl)->min_occ_cycle_num = -1;
       DECL_UNIT (decl)->in_set_p = 0;
-      VLA_PTR_ADD (decls, decl);
+      VEC_safe_push (decl_t,heap, decls, decl);
       num_dfa_decls++;
     }
 }
@@ -1691,7 +1579,7 @@ gen_query_cpu_unit (rtx def)
   int vect_length;
   int i;
 
-  str_cpu_units = get_str_vect ((char *) XSTR (def, 0), &vect_length, ',',
+  str_cpu_units = get_str_vect (XSTR (def, 0), &vect_length, ',',
                                FALSE);
   if (str_cpu_units == NULL)
     fatal ("invalid string `%s' in define_query_cpu_unit", XSTR (def, 0));
@@ -1701,9 +1589,9 @@ gen_query_cpu_unit (rtx def)
       decl->mode = dm_unit;
       decl->pos = 0;
       DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
-      DECL_UNIT (decl)->automaton_name = (char *) XSTR (def, 1);
+      DECL_UNIT (decl)->automaton_name = XSTR (def, 1);
       DECL_UNIT (decl)->query_p = 1;
-      VLA_PTR_ADD (decls, decl);
+      VEC_safe_push (decl_t,heap, decls, decl);
       num_dfa_decls++;
     }
 }
@@ -1723,10 +1611,10 @@ gen_bypass (rtx def)
   int in_length;
   int i, j;
 
-  out_insns = get_str_vect ((char *) XSTR (def, 1), &out_length, ',', FALSE);
+  out_insns = get_str_vect (XSTR (def, 1), &out_length, ',', FALSE);
   if (out_insns == NULL)
     fatal ("invalid string `%s' in define_bypass", XSTR (def, 1));
-  in_insns = get_str_vect ((char *) XSTR (def, 2), &in_length, ',', FALSE);
+  in_insns = get_str_vect (XSTR (def, 2), &in_length, ',', FALSE);
   if (in_insns == NULL)
     fatal ("invalid string `%s' in define_bypass", XSTR (def, 2));
   for (i = 0; i < out_length; i++)
@@ -1738,8 +1626,8 @@ gen_bypass (rtx def)
        DECL_BYPASS (decl)->latency = XINT (def, 0);
        DECL_BYPASS (decl)->out_insn_name = out_insns [i];
        DECL_BYPASS (decl)->in_insn_name = in_insns [j];
-       DECL_BYPASS (decl)->bypass_guard_name = (char *) XSTR (def, 3);
-       VLA_PTR_ADD (decls, decl);
+       DECL_BYPASS (decl)->bypass_guard_name = XSTR (def, 3);
+       VEC_safe_push (decl_t,heap, decls, decl);
        num_dfa_decls++;
       }
 }
@@ -1760,10 +1648,10 @@ gen_excl_set (rtx def)
   int i;
 
   first_str_cpu_units
-    = get_str_vect ((char *) XSTR (def, 0), &first_vect_length, ',', FALSE);
+    = get_str_vect (XSTR (def, 0), &first_vect_length, ',', FALSE);
   if (first_str_cpu_units == NULL)
     fatal ("invalid first string `%s' in exclusion_set", XSTR (def, 0));
-  second_str_cpu_units = get_str_vect ((char *) XSTR (def, 1), &length, ',',
+  second_str_cpu_units = get_str_vect (XSTR (def, 1), &length, ',',
                                       FALSE);
   if (second_str_cpu_units == NULL)
     fatal ("invalid second string `%s' in exclusion_set", XSTR (def, 1));
@@ -1779,7 +1667,7 @@ gen_excl_set (rtx def)
     else
       DECL_EXCL (decl)->names [i]
        = second_str_cpu_units [i - first_vect_length];
-  VLA_PTR_ADD (decls, decl);
+  VEC_safe_push (decl_t,heap, decls, decl);
   num_dfa_decls++;
 }
 
@@ -1794,13 +1682,14 @@ gen_presence_absence_set (rtx def, int presence_p, int final_p)
 {
   decl_t decl;
   char **str_cpu_units;
+  char **str_pattern_lists;
   char ***str_patterns;
   int cpu_units_length;
   int length;
   int patterns_length;
   int i;
 
-  str_cpu_units = get_str_vect ((char *) XSTR (def, 0), &cpu_units_length, ',',
+  str_cpu_units = get_str_vect (XSTR (def, 0), &cpu_units_length, ',',
                                FALSE);
   if (str_cpu_units == NULL)
     fatal ((presence_p
@@ -1811,9 +1700,9 @@ gen_presence_absence_set (rtx def, int presence_p, int final_p)
               ? "invalid first string `%s' in final_absence_set"
               : "invalid first string `%s' in absence_set")),
           XSTR (def, 0));
-  str_patterns = (char ***) get_str_vect ((char *) XSTR (def, 1),
-                                         &patterns_length, ',', FALSE);
-  if (str_patterns == NULL)
+  str_pattern_lists = get_str_vect (XSTR (def, 1),
+                                   &patterns_length, ',', FALSE);
+  if (str_pattern_lists == NULL)
     fatal ((presence_p
            ? (final_p
               ? "invalid second string `%s' in final_presence_set"
@@ -1821,10 +1710,11 @@ gen_presence_absence_set (rtx def, int presence_p, int final_p)
            : (final_p
               ? "invalid second string `%s' in final_absence_set"
               : "invalid second string `%s' in absence_set")), XSTR (def, 1));
+  str_patterns = obstack_alloc (&irp, patterns_length * sizeof (char **));
   for (i = 0; i < patterns_length; i++)
     {
-      str_patterns [i] = get_str_vect ((char *) str_patterns [i], &length, ' ',
-                                      FALSE);
+      str_patterns [i] = get_str_vect (str_pattern_lists [i],
+                                      &length, ' ', FALSE);
       gcc_assert (str_patterns [i]);
     }
   decl = create_node (sizeof (struct decl));
@@ -1847,7 +1737,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;
     }
-  VLA_PTR_ADD (decls, decl);
+  VEC_safe_push (decl_t,heap, decls, decl);
   num_dfa_decls++;
 }
 
@@ -1908,8 +1798,7 @@ gen_automaton (rtx def)
   int vect_length;
   int i;
 
-  str_automata = get_str_vect ((char *) XSTR (def, 0), &vect_length, ',',
-                              FALSE);
+  str_automata = get_str_vect (XSTR (def, 0), &vect_length, ',', FALSE);
   if (str_automata == NULL)
     fatal ("invalid string `%s' in define_automaton", XSTR (def, 0));
   for (i = 0; i < vect_length; i++)
@@ -1918,7 +1807,7 @@ gen_automaton (rtx def)
       decl->mode = dm_automaton;
       decl->pos = 0;
       DECL_AUTOMATON (decl)->name = check_name (str_automata [i], decl->pos);
-      VLA_PTR_ADD (decls, decl);
+      VEC_safe_push (decl_t,heap, decls, decl);
       num_dfa_decls++;
     }
 }
@@ -1951,13 +1840,14 @@ gen_automata_option (rtx def)
 
 /* The following string contains original reservation string being
    parsed.  */
-static char *reserv_str;
+static const char *reserv_str;
 
 /* Parse an element in STR.  */
 static regexp_t
-gen_regexp_el (char *str)
+gen_regexp_el (const char *str)
 {
   regexp_t regexp;
+  char *dstr;
   int len;
 
   if (*str == '(')
@@ -1965,8 +1855,10 @@ gen_regexp_el (char *str)
       len = strlen (str);
       if (str [len - 1] != ')')
        fatal ("garbage after ) in reservation `%s'", reserv_str);
-      str [len - 1] = '\0';
-      regexp = gen_regexp_sequence (str + 1);
+      dstr = alloca (len - 1);
+      memcpy (dstr, str + 1, len - 2);
+      dstr [len-2] = '\0';
+      regexp = gen_regexp_sequence (dstr);
     }
   else if (strcmp (str, NOTHING_NAME) == 0)
     {
@@ -1984,7 +1876,7 @@ gen_regexp_el (char *str)
 
 /* Parse construction `repeat' in STR.  */
 static regexp_t
-gen_regexp_repeat (char *str)
+gen_regexp_repeat (const char *str)
 {
   regexp_t regexp;
   regexp_t repeat;
@@ -2017,7 +1909,7 @@ gen_regexp_repeat (char *str)
 
 /* Parse reservation STR which possibly contains separator '+'.  */
 static regexp_t
-gen_regexp_allof (char *str)
+gen_regexp_allof (const char *str)
 {
   regexp_t allof;
   char **allof_vect;
@@ -2043,7 +1935,7 @@ gen_regexp_allof (char *str)
 
 /* Parse reservation STR which possibly contains separator '|'.  */
 static regexp_t
-gen_regexp_oneof (char *str)
+gen_regexp_oneof (const char *str)
 {
   regexp_t oneof;
   char **oneof_vect;
@@ -2069,7 +1961,7 @@ gen_regexp_oneof (char *str)
 
 /* Parse reservation STR which possibly contains separator ','.  */
 static regexp_t
-gen_regexp_sequence (char *str)
+gen_regexp_sequence (const char *str)
 {
   regexp_t sequence;
   char **sequence_vect;
@@ -2094,7 +1986,7 @@ gen_regexp_sequence (char *str)
 
 /* Parse construction reservation STR.  */
 static regexp_t
-gen_regexp (char *str)
+gen_regexp (const char *str)
 {
   reserv_str = str;
   return gen_regexp_sequence (str);;
@@ -2113,9 +2005,9 @@ gen_reserv (rtx def)
   decl = create_node (sizeof (struct decl));
   decl->mode = dm_reserv;
   decl->pos = 0;
-  DECL_RESERV (decl)->name = check_name ((char *) XSTR (def, 0), decl->pos);
-  DECL_RESERV (decl)->regexp = gen_regexp ((char *) XSTR (def, 1));
-  VLA_PTR_ADD (decls, decl);
+  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);
   num_dfa_decls++;
 }
 
@@ -2133,11 +2025,11 @@ gen_insn_reserv (rtx def)
   decl->mode = dm_insn_reserv;
   decl->pos = 0;
   DECL_INSN_RESERV (decl)->name
-    = check_name ((char *) XSTR (def, 0), decl->pos);
+    = check_name (XSTR (def, 0), decl->pos);
   DECL_INSN_RESERV (decl)->default_latency = XINT (def, 1);
   DECL_INSN_RESERV (decl)->condexp = XEXP (def, 2);
-  DECL_INSN_RESERV (decl)->regexp = gen_regexp ((char *) XSTR (def, 3));
-  VLA_PTR_ADD (decls, decl);
+  DECL_INSN_RESERV (decl)->regexp = gen_regexp (XSTR (def, 3));
+  VEC_safe_push (decl_t,heap, decls, decl);
   num_dfa_decls++;
 }
 
@@ -2223,7 +2115,7 @@ static struct decl work_automaton_decl;
    declaration.  The function returns node found in the table, NULL if
    such node does not exist in the table.  */
 static decl_t
-find_automaton_decl (char *name)
+find_automaton_decl (const char *name)
 {
   void *entry;
 
@@ -2322,7 +2214,7 @@ static struct decl work_insn_decl;
    declaration.  The function returns node found in the table, NULL if
    such node does not exist in the table.  */
 static decl_t
-find_insn_decl (char *name)
+find_insn_decl (const char *name)
 {
   void *entry;
 
@@ -2422,7 +2314,7 @@ static struct decl work_decl;
    returns node found in the table, NULL if such node does not exist
    in the table.  */
 static decl_t
-find_decl (char *name)
+find_decl (const char *name)
 {
   void *entry;
 
@@ -3537,7 +3429,7 @@ add_advance_cycle_insn_decl (void)
   advance_cycle_insn_decl->mode = dm_insn_reserv;
   advance_cycle_insn_decl->pos = no_pos;
   DECL_INSN_RESERV (advance_cycle_insn_decl)->regexp = NULL;
-  DECL_INSN_RESERV (advance_cycle_insn_decl)->name = (char *) "$advance_cycle";
+  DECL_INSN_RESERV (advance_cycle_insn_decl)->name = "$advance_cycle";
   DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num
     = description->insns_num;
   description->decls [description->decls_num] = advance_cycle_insn_decl;
@@ -3628,47 +3520,50 @@ alt_state_cmp (const void *alt_state_ptr_1, const void *alt_state_ptr_2)
 /* The function sorts ALT_STATES_LIST and removes duplicated alt
    states from the list.  The comparison key is alt state unique
    number.  */
+
 static alt_state_t
 uniq_sort_alt_states (alt_state_t alt_states_list)
 {
   alt_state_t curr_alt_state;
-  vla_ptr_t alt_states;
+  VEC(alt_state_t,heap) *alt_states;
   size_t i;
   size_t prev_unique_state_ind;
   alt_state_t result;
-  alt_state_t *result_ptr;
 
-  VLA_PTR_CREATE (alt_states, 150, "alt_states");
+  if (alt_states_list == 0)
+    return 0;
+  if (alt_states_list->next_alt_state == 0)
+    return alt_states_list;
+
+  alt_states = VEC_alloc (alt_state_t,heap, 150);
   for (curr_alt_state = alt_states_list;
        curr_alt_state != NULL;
        curr_alt_state = curr_alt_state->next_alt_state)
-    VLA_PTR_ADD (alt_states, curr_alt_state);
-  qsort (VLA_PTR_BEGIN (alt_states), VLA_PTR_LENGTH (alt_states),
+    VEC_safe_push (alt_state_t,heap, alt_states, curr_alt_state);
+
+  qsort (VEC_address (alt_state_t, alt_states),
+        VEC_length  (alt_state_t, alt_states),
         sizeof (alt_state_t), alt_state_cmp);
-  if (VLA_PTR_LENGTH (alt_states) == 0)
-    result = NULL;
-  else
-    {
-      result_ptr = VLA_PTR_BEGIN (alt_states);
-      prev_unique_state_ind = 0;
-      for (i = 1; i < VLA_PTR_LENGTH (alt_states); i++)
-        if (result_ptr [prev_unique_state_ind]->state != result_ptr [i]->state)
-          {
-            prev_unique_state_ind++;
-            result_ptr [prev_unique_state_ind] = result_ptr [i];
-          }
-#if 0
-      for (i = prev_unique_state_ind + 1; i < VLA_PTR_LENGTH (alt_states); i++)
-        free_alt_state (result_ptr [i]);
-#endif
-      VLA_PTR_SHORTEN (alt_states, i - prev_unique_state_ind - 1);
-      result_ptr = VLA_PTR_BEGIN (alt_states);
-      for (i = 1; i < VLA_PTR_LENGTH (alt_states); i++)
-        result_ptr [i - 1]->next_sorted_alt_state = result_ptr [i];
-      result_ptr [i - 1]->next_sorted_alt_state = NULL;
-      result = *result_ptr;
-    }
-  VLA_PTR_DELETE (alt_states);
+
+  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)
+      {
+       prev_unique_state_ind++;
+       VEC_replace (alt_state_t, alt_states, prev_unique_state_ind,
+                    VEC_index (alt_state_t, alt_states, i));
+      }
+  VEC_truncate (alt_state_t, alt_states, 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;
+
+  result = VEC_index (alt_state_t, alt_states, 0);
+
+  VEC_free (alt_state_t,heap, alt_states);
   return result;
 }
 
@@ -3736,11 +3631,7 @@ static int els_in_cycle_reserv;
    variable value * number of bits in set_el_t.  */
 static int els_in_reservs;
 
-/* VLA for representation of array of pointers to unit
-   declarations.  */
-static vla_ptr_t units_container;
-
-/* The start address of the array.  */
+/* Array of pointers to unit declarations.  */
 static unit_decl_t *units_array;
 
 /* Temporary reservation of maximal length.  */
@@ -3749,9 +3640,9 @@ static reserv_sets_t temp_reserv;
 /* The state table itself is represented by the following variable.  */
 static htab_t state_table;
 
-/* VLA for representation of array of pointers to free nodes
-   `state'.  */
-static vla_ptr_t free_states;
+/* Linked list of free 'state' structures to be recycled.  The
+   next_equiv_class_state pointer is borrowed for a free list.  */
+static state_t first_free_state;
 
 static int curr_unique_state_num;
 
@@ -4053,10 +3944,12 @@ get_free_state (int with_reservs, automaton_t automaton)
   state_t result;
 
   gcc_assert (max_cycles_num > 0 && automaton);
-  if (VLA_PTR_LENGTH (free_states) != 0)
+  if (first_free_state)
     {
-      result = VLA_PTR (free_states, VLA_PTR_LENGTH (free_states) - 1);
-      VLA_PTR_SHORTEN (free_states, 1);
+      result = first_free_state;
+      first_free_state = result->next_equiv_class_state;
+
+      result->next_equiv_class_state = NULL;
       result->automaton = automaton;
       result->first_out_arc = NULL;
       result->it_was_placed_in_stack_for_NDFA_forming = 0;
@@ -4091,7 +3984,8 @@ static void
 free_state (state_t state)
 {
   free_alt_states (state->component_states);
-  VLA_PTR_ADD (free_states, state);
+  state->next_equiv_class_state = first_free_state;
+  first_free_state = state;
 }
 
 /* Hash value of STATE.  If STATE represents deterministic state it is
@@ -4232,10 +4126,11 @@ initiate_states (void)
   decl_t decl;
   int i;
 
-  VLA_PTR_CREATE (units_container, description->units_num, "units_container");
-  units_array
-    = (description->decls_num && description->units_num
-       ? VLA_PTR_BEGIN (units_container) : NULL);
+  if (description->units_num)
+    units_array = xmalloc (description->units_num * sizeof (unit_decl_t));
+  else
+    units_array = 0;
+
   for (i = 0; i < description->decls_num; i++)
     {
       decl = description->decls [i];
@@ -4249,7 +4144,6 @@ initiate_states (void)
   els_in_reservs = els_in_cycle_reserv * max_cycles_num;
   curr_unique_state_num = 0;
   initiate_alt_states ();
-  VLA_PTR_CREATE (free_states, 1500, "free states");
   state_table = htab_create (1500, state_hash, state_eq_p, (htab_del) 0);
   temp_reserv = alloc_empty_reserv_sets ();
 }
@@ -4258,9 +4152,10 @@ initiate_states (void)
 static void
 finish_states (void)
 {
-  VLA_PTR_DELETE (units_container);
+  free (units_array);
+  units_array = 0;
   htab_delete (state_table);
-  VLA_PTR_DELETE (free_states);
+  first_free_state = NULL;
   finish_alt_states ();
 }
 
@@ -5337,6 +5232,10 @@ struct unit_usage
      same alternative.  */
   struct unit_usage *next;
 };
+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;
@@ -5347,7 +5246,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 vla_ptr_t cycle_alt_unit_usages;
+static VEC(unit_usage_t,heap) *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
@@ -5356,29 +5255,26 @@ static void
 store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle,
                      int alt_num)
 {
-  size_t i, length, old_length;
+  size_t length;
   unit_decl_t unit_decl;
-  struct unit_usage *unit_usage_ptr;
+  unit_usage_t unit_usage_ptr;
   int index;
 
   gcc_assert (regexp && regexp->mode == rm_oneof
              && alt_num < REGEXP_ONEOF (regexp)->regexps_num);
   unit_decl = REGEXP_UNIT (unit)->unit_decl;
-  old_length = VLA_PTR_LENGTH (cycle_alt_unit_usages);
+
   length = (cycle + 1) * REGEXP_ONEOF (regexp)->regexps_num;
-  if (old_length < length)
-    {
-      VLA_PTR_EXPAND (cycle_alt_unit_usages, length - old_length);
-      for (i = old_length; i < length; i++)
-       VLA_PTR (cycle_alt_unit_usages, i) = NULL;
-    }
+  while (VEC_length (unit_usage_t, cycle_alt_unit_usages) < length)
+    VEC_safe_push (unit_usage_t,heap, cycle_alt_unit_usages, 0);
+  
   obstack_blank (&unit_usages, sizeof (struct unit_usage));
   unit_usage_ptr = (struct unit_usage *) obstack_base (&unit_usages);
   obstack_finish (&unit_usages);
   unit_usage_ptr->unit_decl = unit_decl;
   index = cycle * REGEXP_ONEOF (regexp)->regexps_num + alt_num;
-  unit_usage_ptr->next = VLA_PTR (cycle_alt_unit_usages, index);
-  VLA_PTR (cycle_alt_unit_usages, index) = unit_usage_ptr;
+  unit_usage_ptr->next = VEC_index (unit_usage_t, cycle_alt_unit_usages, index);
+  VEC_replace (unit_usage_t, cycle_alt_unit_usages, index, unit_usage_ptr);
   unit_decl->last_distribution_check_cycle = -1; /* undefined */
 }
 
@@ -5396,7 +5292,8 @@ check_regexp_units_distribution (const char *insn_reserv_name,
     return;
   /* Store all unit usages in the regexp:  */
   obstack_init (&unit_usages);
-  VLA_PTR_CREATE (cycle_alt_unit_usages, 100, "unit usages on cycles");
+  cycle_alt_unit_usages = 0;
+
   for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--)
     {
       seq = REGEXP_ONEOF (regexp)->regexps [i];
@@ -5463,31 +5360,33 @@ check_regexp_units_distribution (const char *insn_reserv_name,
        }
     }
   /* Check distribution:  */
-  for (i = 0; i < (int) VLA_PTR_LENGTH (cycle_alt_unit_usages); i++)
+  for (i = 0; i < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); i++)
     {
       cycle = i / REGEXP_ONEOF (regexp)->regexps_num;
-      for (unit_usage_ptr = VLA_PTR (cycle_alt_unit_usages, i);
+      for (unit_usage_ptr = VEC_index (unit_usage_t, cycle_alt_unit_usages, i);
           unit_usage_ptr != NULL;
           unit_usage_ptr = unit_usage_ptr->next)
        if (cycle != unit_usage_ptr->unit_decl->last_distribution_check_cycle)
          {
            unit_usage_ptr->unit_decl->last_distribution_check_cycle = cycle;
            for (k = cycle * REGEXP_ONEOF (regexp)->regexps_num;
-                k < (int) VLA_PTR_LENGTH (cycle_alt_unit_usages)
+                k < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages)
                   && k == cycle * REGEXP_ONEOF (regexp)->regexps_num;
                 k++)
              {
-               for (other_unit_usage_ptr = VLA_PTR (cycle_alt_unit_usages, k);
+               for (other_unit_usage_ptr
+                      = VEC_index (unit_usage_t, cycle_alt_unit_usages, k);
                     other_unit_usage_ptr != NULL;
                     other_unit_usage_ptr = other_unit_usage_ptr->next)
                  if (unit_usage_ptr->unit_decl->automaton_decl
                      == other_unit_usage_ptr->unit_decl->automaton_decl)
                    break;
                if (other_unit_usage_ptr == NULL
-                   && VLA_PTR (cycle_alt_unit_usages, k) != NULL)
+                   && (VEC_index (unit_usage_t, cycle_alt_unit_usages, k)
+                       != NULL))
                  break;
              }
-           if (k < (int) VLA_PTR_LENGTH (cycle_alt_unit_usages)
+           if (k < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages)
                && k == cycle * REGEXP_ONEOF (regexp)->regexps_num)
              {
                if (!annotation_message_reported_p)
@@ -5503,7 +5402,7 @@ check_regexp_units_distribution (const char *insn_reserv_name,
              }
          }
     }
-  VLA_PTR_DELETE (cycle_alt_unit_usages);
+  VEC_free (unit_usage_t,heap, cycle_alt_unit_usages);
   obstack_free (&unit_usages, NULL);
 }
 
@@ -5679,16 +5578,14 @@ create_alt_states (automaton_t automaton)
 
 /* The function forms list of ainsns of AUTOMATON with the same
    reservation.  */
+
 static void
 form_ainsn_with_same_reservs (automaton_t automaton)
 {
   ainsn_t curr_ainsn;
   size_t i;
-  vla_ptr_t first_insns;
-  vla_ptr_t last_insns;
+  VEC(ainsn_t,heap) *last_insns = VEC_alloc (ainsn_t,heap, 150);
 
-  VLA_PTR_CREATE (first_insns, 150, "first insns with the same reservs");
-  VLA_PTR_CREATE (last_insns, 150, "last insns with the same reservs");
   for (curr_ainsn = automaton->ainsn_list;
        curr_ainsn != NULL;
        curr_ainsn = curr_ainsn->next_ainsn)
@@ -5700,28 +5597,26 @@ form_ainsn_with_same_reservs (automaton_t automaton)
       }
     else
       {
-        for (i = 0; i < VLA_PTR_LENGTH (first_insns); i++)
+        for (i = 0; i < VEC_length (ainsn_t, last_insns); i++)
           if (alt_states_eq
               (curr_ainsn->sorted_alt_states,
-               ((ainsn_t) VLA_PTR (first_insns, i))->sorted_alt_states))
+               VEC_index (ainsn_t, last_insns, i)->sorted_alt_states))
             break;
         curr_ainsn->next_same_reservs_insn = NULL;
-        if (i < VLA_PTR_LENGTH (first_insns))
+        if (i < VEC_length (ainsn_t, last_insns))
           {
             curr_ainsn->first_insn_with_same_reservs = 0;
-           ((ainsn_t) VLA_PTR (last_insns, i))->next_same_reservs_insn
+           VEC_index (ainsn_t, last_insns, i)->next_same_reservs_insn
              = curr_ainsn;
-            VLA_PTR (last_insns, i) = curr_ainsn;
+            VEC_replace (ainsn_t, last_insns, i, curr_ainsn);
           }
         else
           {
-            VLA_PTR_ADD (first_insns, curr_ainsn);
-            VLA_PTR_ADD (last_insns, curr_ainsn);
+            VEC_safe_push (ainsn_t, heap, last_insns, curr_ainsn);
             curr_ainsn->first_insn_with_same_reservs = 1;
           }
       }
-  VLA_PTR_DELETE (first_insns);
-  VLA_PTR_DELETE (last_insns);
+  VEC_free (ainsn_t,heap, last_insns);
 }
 
 /* Forming unit reservations which can affect creating the automaton
@@ -5753,8 +5648,7 @@ form_reservs_matter (automaton_t automaton)
   return reservs_matter;
 }
 
-/* The following function creates all states of nondeterministic (if
-   NDFA_FLAG has nonzero value) or deterministic AUTOMATON.  */
+/* The following function creates all states of nondeterministic AUTOMATON.  */
 static void
 make_automaton (automaton_t automaton)
 {
@@ -5766,21 +5660,19 @@ make_automaton (automaton_t automaton)
   state_t state2;
   ainsn_t advance_cycle_ainsn;
   arc_t added_arc;
-  vla_ptr_t state_stack;
+  VEC(state_t,heap) *state_stack = VEC_alloc(state_t,heap, 150);
   int states_n;
   reserv_sets_t reservs_matter = form_reservs_matter (automaton);
 
-  VLA_PTR_CREATE (state_stack, 150, "state stack");
   /* Create the start state (empty state).  */
   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;
-  VLA_PTR_ADD (state_stack, start_state);
+  VEC_safe_push (state_t,heap, state_stack, start_state);
   states_n = 1;
-  while (VLA_PTR_LENGTH (state_stack) != 0)
+  while (VEC_length (state_t, state_stack) != 0)
     {
-      state = VLA_PTR (state_stack, VLA_PTR_LENGTH (state_stack) - 1);
-      VLA_PTR_SHORTEN (state_stack, 1);
+      state = VEC_pop (state_t, state_stack);
       advance_cycle_ainsn = NULL;
       for (ainsn = automaton->ainsn_list;
           ainsn != NULL;
@@ -5805,7 +5697,7 @@ make_automaton (automaton_t automaton)
                           {
                             state2->it_was_placed_in_stack_for_NDFA_forming
                              = 1;
-                            VLA_PTR_ADD (state_stack, state2);
+                            VEC_safe_push (state_t,heap, state_stack, state2);
                            states_n++;
                            if (progress_flag && states_n % 100 == 0)
                              fprintf (stderr, ".");
@@ -5836,7 +5728,7 @@ 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;
-          VLA_PTR_ADD (state_stack, state2);
+          VEC_safe_push (state_t,heap, state_stack, state2);
          states_n++;
          if (progress_flag && states_n % 100 == 0)
            fprintf (stderr, ".");
@@ -5844,7 +5736,7 @@ make_automaton (automaton_t automaton)
       gcc_assert (advance_cycle_ainsn);
       add_arc (state, state2, advance_cycle_ainsn, 1);
     }
-  VLA_PTR_DELETE (state_stack);
+  VEC_free (state_t,heap, state_stack);
 }
 
 /* Foms lists of all arcs of STATE marked by the same ainsn.  */
@@ -5874,9 +5766,10 @@ form_arcs_marked_by_insn (state_t state)
    ORIGINAL_STATE and list of arcs ARCS_MARKED_BY_INSN marked by the
    same insn.  If the composed state is not in STATE_STACK yet, it is
    pushed into STATE_STACK.  */
+
 static int
 create_composed_state (state_t original_state, arc_t arcs_marked_by_insn,
-                      vla_ptr_t *state_stack)
+                      VEC(state_t,heap) **state_stack)
 {
   state_t state;
   alt_state_t alt_state, curr_alt_state;
@@ -5967,33 +5860,34 @@ 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;
-      VLA_PTR_ADD (*state_stack, state);
+      VEC_safe_push (state_t,heap, *state_stack, state);
     }
   return new_state_p;
 }
 
 /* The function transforms nondeterministic AUTOMATON into
    deterministic.  */
+
 static void
 NDFA_to_DFA (automaton_t automaton)
 {
   state_t start_state;
   state_t state;
   decl_t decl;
-  vla_ptr_t state_stack;
+  VEC(state_t,heap) *state_stack;
   int i;
   int states_n;
 
-  VLA_PTR_CREATE (state_stack, 150, "state stack");
+  state_stack = VEC_alloc (state_t,heap, 0);
+
   /* Create the start state (empty state).  */
   start_state = automaton->start_state;
   start_state->it_was_placed_in_stack_for_DFA_forming = 1;
-  VLA_PTR_ADD (state_stack, start_state);
+  VEC_safe_push (state_t,heap, state_stack, start_state);
   states_n = 1;
-  while (VLA_PTR_LENGTH (state_stack) != 0)
+  while (VEC_length (state_t, state_stack) != 0)
     {
-      state = VLA_PTR (state_stack, VLA_PTR_LENGTH (state_stack) - 1);
-      VLA_PTR_SHORTEN (state_stack, 1);
+      state = VEC_pop (state_t, state_stack);
       form_arcs_marked_by_insn (state);
       for (i = 0; i < description->decls_num; i++)
        {
@@ -6009,7 +5903,7 @@ NDFA_to_DFA (automaton_t automaton)
            }
        }
     }
-  VLA_PTR_DELETE (state_stack);
+  VEC_free (state_t,heap, state_stack);
 }
 
 /* The following variable value is current number (1, 2, ...) of passing
@@ -6051,14 +5945,14 @@ initiate_pass_states (void)
 
 /* The following vla is used for storing pointers to all achieved
    states.  */
-static vla_ptr_t all_achieved_states;
+static VEC(state_t,heap) *all_achieved_states;
 
 /* This function is called by function pass_states to add an achieved
    STATE.  */
 static void
 add_achieved_state (state_t state)
 {
-  VLA_PTR_ADD (all_achieved_states, state);
+  VEC_safe_push (state_t,heap, all_achieved_states, state);
 }
 
 /* The function sets up equivalence numbers of insns which mark all
@@ -6102,19 +5996,6 @@ clear_arc_insns_equiv_num (state_t state)
     }
 }
 
-/* The function copies pointers to equivalent states from vla FROM
-   into vla TO.  */
-static void
-copy_equiv_class (vla_ptr_t *to, const vla_ptr_t *from)
-{
-  state_t *class_ptr;
-
-  VLA_PTR_NULLIFY (*to);
-  for (class_ptr = VLA_PTR_BEGIN (*from);
-       class_ptr <= (state_t *) VLA_PTR_LAST (*from);
-       class_ptr++)
-    VLA_PTR_ADD (*to, *class_ptr);
-}
 
 /* The following function returns TRUE if STATE reserves the unit with
    UNIT_NUM on the first cycle.  */
@@ -6178,46 +6059,50 @@ state_is_differed (state_t state, state_t another_state,
 /* The function makes initial partition of STATES on equivalent
    classes.  */
 static state_t
-init_equiv_class (state_t *states, int states_num)
+init_equiv_class (VEC(state_t,heap) *states)
 {
-  state_t *state_ptr;
-  state_t result_equiv_class;
+  size_t i;
+  state_t prev = 0;
 
-  result_equiv_class = NULL;
-  for (state_ptr = states; state_ptr < states + states_num; state_ptr++)
+  for (i = 0; i < VEC_length (state_t, states); i++)
     {
-      (*state_ptr)->equiv_class_num_1 = 1;
-      (*state_ptr)->next_equiv_class_state = result_equiv_class;
-      result_equiv_class = *state_ptr;
+      VEC_index (state_t, states, i)->equiv_class_num_1 = 1;
+      VEC_index (state_t, states, i)->next_equiv_class_state = prev;
+      prev = VEC_index (state_t, states, i);
     }
-  return result_equiv_class;
+  return prev;
 }
 
-/* The function processes equivalence class given by its pointer
-   EQUIV_CLASS_PTR on odd iteration if ODD_ITERATION_FLAG.  If there
+/* 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)
+{
+  VEC_free (state_t,heap, *to);
+  *to = VEC_copy (state_t,heap, from);
+}
+/* The function processes equivalence class given by its first state,
+   FIRST_STATE, on odd iteration if ODD_ITERATION_FLAG.  If there
    are not equivalent states, the function partitions the class
    removing nonequivalent states and placing them in
    *NEXT_ITERATION_CLASSES, increments *NEW_EQUIV_CLASS_NUM_PTR ans
    assigns it to the state equivalence number.  If the class has been
    partitioned, the function returns nonzero value.  */
 static int
-partition_equiv_class (state_t *equiv_class_ptr, int odd_iteration_flag,
-                      vla_ptr_t *next_iteration_classes,
+partition_equiv_class (state_t first_state, int odd_iteration_flag,
+                      VEC(state_t,heap) **next_iteration_classes,
                       int *new_equiv_class_num_ptr)
 {
   state_t new_equiv_class;
   int partition_p;
-  state_t first_state;
   state_t curr_state;
   state_t prev_state;
   state_t next_state;
   int out_arcs_num;
 
   partition_p = 0;
-  gcc_assert (*equiv_class_ptr);
-  for (first_state = *equiv_class_ptr;
-       first_state != NULL;
-       first_state = new_equiv_class)
+
+  while (first_state != NULL)
     {
       new_equiv_class = NULL;
       if (first_state->next_equiv_class_state != NULL)
@@ -6253,62 +6138,64 @@ partition_equiv_class (state_t *equiv_class_ptr, int odd_iteration_flag,
          clear_arc_insns_equiv_num (first_state);
        }
       if (new_equiv_class != NULL)
-       VLA_PTR_ADD  (*next_iteration_classes, new_equiv_class);
+       VEC_safe_push (state_t,heap, *next_iteration_classes, new_equiv_class);
+      first_state = new_equiv_class;
     }
   return partition_p;
 }
 
 /* The function finds equivalent states of AUTOMATON.  */
 static void
-evaluate_equiv_classes (automaton_t automaton, vla_ptr_t *equiv_classes)
+evaluate_equiv_classes (automaton_t automaton,
+                       VEC(state_t,heap) **equiv_classes)
 {
   state_t new_equiv_class;
   int new_equiv_class_num;
   int odd_iteration_flag;
   int finish_flag;
-  vla_ptr_t next_iteration_classes;
-  state_t *equiv_class_ptr;
-  state_t *state_ptr;
+  VEC (state_t,heap) *next_iteration_classes;
+  size_t i;
 
-  VLA_PTR_CREATE (all_achieved_states, 1500, "all achieved states");
+  all_achieved_states = VEC_alloc (state_t,heap, 1500);
   pass_states (automaton, add_achieved_state);
-  new_equiv_class = init_equiv_class (VLA_PTR_BEGIN (all_achieved_states),
-                                      VLA_PTR_LENGTH (all_achieved_states));
+  new_equiv_class = init_equiv_class (all_achieved_states);
   odd_iteration_flag = 0;
   new_equiv_class_num = 1;
-  VLA_PTR_CREATE (next_iteration_classes, 150, "next iteration classes");
-  VLA_PTR_ADD (next_iteration_classes, new_equiv_class);
+
+  next_iteration_classes = VEC_alloc (state_t,heap, 150);
+  VEC_quick_push (state_t, next_iteration_classes, new_equiv_class);
+
   do
     {
       odd_iteration_flag = !odd_iteration_flag;
       finish_flag = 1;
-      copy_equiv_class (equiv_classes, &next_iteration_classes);
+      copy_equiv_class (equiv_classes, next_iteration_classes);
+
       /* Transfer equiv numbers for the next iteration.  */
-      for (state_ptr = VLA_PTR_BEGIN (all_achieved_states);
-          state_ptr <= (state_t *) VLA_PTR_LAST (all_achieved_states);
-           state_ptr++)
+      for (i = 0; i < VEC_length (state_t, all_achieved_states); i++)
        if (odd_iteration_flag)
-         (*state_ptr)->equiv_class_num_2 = (*state_ptr)->equiv_class_num_1;
+         VEC_index (state_t, all_achieved_states, i)->equiv_class_num_2
+           = VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1;
        else
-         (*state_ptr)->equiv_class_num_1 = (*state_ptr)->equiv_class_num_2;
-      for (equiv_class_ptr = VLA_PTR_BEGIN (*equiv_classes);
-           equiv_class_ptr <= (state_t *) VLA_PTR_LAST (*equiv_classes);
-           equiv_class_ptr++)
-       if (partition_equiv_class (equiv_class_ptr, odd_iteration_flag,
+         VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1
+           = VEC_index (state_t, 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),
+                                  odd_iteration_flag,
                                   &next_iteration_classes,
                                   &new_equiv_class_num))
          finish_flag = 0;
     }
   while (!finish_flag);
-  VLA_PTR_DELETE (next_iteration_classes);
-  VLA_PTR_DELETE (all_achieved_states);
+  VEC_free (state_t,heap, next_iteration_classes);
+  VEC_free (state_t,heap, all_achieved_states);
 }
 
 /* The function merges equivalent states of AUTOMATON.  */
 static void
-merge_states (automaton_t automaton, vla_ptr_t *equiv_classes)
+merge_states (automaton_t automaton, VEC(state_t,heap) *equiv_classes)
 {
-  state_t *equiv_class_ptr;
   state_t curr_state;
   state_t new_state;
   state_t first_class_state;
@@ -6316,88 +6203,92 @@ merge_states (automaton_t automaton, vla_ptr_t *equiv_classes)
   alt_state_t alt_state, new_alt_state;
   arc_t curr_arc;
   arc_t next_arc;
+  size_t i;
 
   /* Create states corresponding to equivalence classes containing two
      or more states.  */
-  for (equiv_class_ptr = VLA_PTR_BEGIN (*equiv_classes);
-       equiv_class_ptr <= (state_t *) VLA_PTR_LAST (*equiv_classes);
-       equiv_class_ptr++)
-    if ((*equiv_class_ptr)->next_equiv_class_state != NULL)
-      {
-        /* There are more one states in the class equivalence.  */
-        /* Create new compound state.  */
-        new_state = get_free_state (0, automaton);
-        alt_states = NULL;
-        first_class_state = *equiv_class_ptr;
-        for (curr_state = first_class_state;
-             curr_state != NULL;
-             curr_state = curr_state->next_equiv_class_state)
-          {
-            curr_state->equiv_class_state = new_state;
-           if (curr_state->component_states == NULL)
-             {
-               new_alt_state = get_free_alt_state ();
-               new_alt_state->state = curr_state;
-               new_alt_state->next_alt_state = alt_states;
-               alt_states = new_alt_state;
-             }
-           else
-             for (alt_state = curr_state->component_states;
-                  alt_state != NULL;
-                  alt_state = alt_state->next_sorted_alt_state)
+  for (i = 0; i < VEC_length (state_t, equiv_classes); i++)
+    {
+      curr_state = VEC_index (state_t, equiv_classes, i);
+      if (curr_state->next_equiv_class_state != NULL)
+       {
+         /* There are more one states in the class equivalence.  */
+         /* Create new compound state.  */
+         new_state = get_free_state (0, automaton);
+         alt_states = NULL;
+         first_class_state = curr_state;
+         for (curr_state = first_class_state;
+              curr_state != NULL;
+              curr_state = curr_state->next_equiv_class_state)
+           {
+             curr_state->equiv_class_state = new_state;
+             if (curr_state->component_states == NULL)
                {
                  new_alt_state = get_free_alt_state ();
-                 new_alt_state->state = alt_state->state;
+                 new_alt_state->state = curr_state;
                  new_alt_state->next_alt_state = alt_states;
                  alt_states = new_alt_state;
                }
-          }
-       /* Its is important that alt states were sorted before and
-           after merging to have the same querying results.  */
-        new_state->component_states = uniq_sort_alt_states (alt_states);
-      }
-    else
-      (*equiv_class_ptr)->equiv_class_state = *equiv_class_ptr;
-  for (equiv_class_ptr = VLA_PTR_BEGIN (*equiv_classes);
-       equiv_class_ptr <= (state_t *) VLA_PTR_LAST (*equiv_classes);
-       equiv_class_ptr++)
-    if ((*equiv_class_ptr)->next_equiv_class_state != NULL)
-      {
-        first_class_state = *equiv_class_ptr;
-        /* Create new arcs output from the state corresponding to
-           equiv class.  */
-        for (curr_arc = first_out_arc (first_class_state);
-             curr_arc != NULL;
-             curr_arc = next_out_arc (curr_arc))
-          add_arc (first_class_state->equiv_class_state,
-                   curr_arc->to_state->equiv_class_state,
-                  curr_arc->insn, curr_arc->state_alts);
-        /* Delete output arcs from states of given class equivalence.  */
-        for (curr_state = first_class_state;
-             curr_state != NULL;
-             curr_state = curr_state->next_equiv_class_state)
-          {
-            if (automaton->start_state == curr_state)
-              automaton->start_state = curr_state->equiv_class_state;
-            /* Delete the state and its output arcs.  */
-            for (curr_arc = first_out_arc (curr_state);
-                 curr_arc != NULL;
-                 curr_arc = next_arc)
-              {
-                next_arc = next_out_arc (curr_arc);
-                free_arc (curr_arc);
-              }
-          }
-      }
-    else
-      {
-        /* Change `to_state' of arcs output from the state of given
-           equivalence class.  */
-        for (curr_arc = first_out_arc (*equiv_class_ptr);
-             curr_arc != NULL;
-             curr_arc = next_out_arc (curr_arc))
-          curr_arc->to_state = curr_arc->to_state->equiv_class_state;
-      }
+             else
+               for (alt_state = curr_state->component_states;
+                    alt_state != NULL;
+                    alt_state = alt_state->next_sorted_alt_state)
+                 {
+                   new_alt_state = get_free_alt_state ();
+                   new_alt_state->state = alt_state->state;
+                   new_alt_state->next_alt_state = alt_states;
+                   alt_states = new_alt_state;
+                 }
+           }
+         /* Its is important that alt states were sorted before and
+            after merging to have the same querying results.  */
+         new_state->component_states = uniq_sort_alt_states (alt_states);
+       }
+      else
+       curr_state->equiv_class_state = curr_state;
+    }
+
+  for (i = 0; i < VEC_length (state_t, equiv_classes); i++)
+    {
+      curr_state = VEC_index (state_t, equiv_classes, i);
+      if (curr_state->next_equiv_class_state != NULL)
+       {
+         first_class_state = curr_state;
+         /* Create new arcs output from the state corresponding to
+            equiv class.  */
+         for (curr_arc = first_out_arc (first_class_state);
+              curr_arc != NULL;
+              curr_arc = next_out_arc (curr_arc))
+           add_arc (first_class_state->equiv_class_state,
+                    curr_arc->to_state->equiv_class_state,
+                    curr_arc->insn, curr_arc->state_alts);
+         /* Delete output arcs from states of given class equivalence.  */
+         for (curr_state = first_class_state;
+              curr_state != NULL;
+              curr_state = curr_state->next_equiv_class_state)
+           {
+             if (automaton->start_state == curr_state)
+               automaton->start_state = curr_state->equiv_class_state;
+             /* Delete the state and its output arcs.  */
+             for (curr_arc = first_out_arc (curr_state);
+                  curr_arc != NULL;
+                  curr_arc = next_arc)
+               {
+                 next_arc = next_out_arc (curr_arc);
+                 free_arc (curr_arc);
+               }
+           }
+       }
+      else
+       {
+         /* Change `to_state' of arcs output from the state of given
+            equivalence class.  */
+         for (curr_arc = first_out_arc (curr_state);
+              curr_arc != NULL;
+              curr_arc = next_out_arc (curr_arc))
+           curr_arc->to_state = curr_arc->to_state->equiv_class_state;
+       }
+    }
 }
 
 /* The function sets up new_cycle_p for states if there is arc to the
@@ -6418,13 +6309,13 @@ set_new_cycle_flags (state_t state)
 static void
 minimize_DFA (automaton_t automaton)
 {
-  vla_ptr_t equiv_classes;
+  VEC(state_t,heap) *equiv_classes = 0;
 
-  VLA_PTR_CREATE (equiv_classes, 1500, "equivalence classes");
   evaluate_equiv_classes (automaton, &equiv_classes);
-  merge_states (automaton, &equiv_classes);
+  merge_states (automaton, equiv_classes);
   pass_states (automaton, set_new_cycle_flags);
-  VLA_PTR_DELETE (equiv_classes);
+
+  VEC_free (state_t,heap, equiv_classes);
 }
 
 /* Values of two variables are counted number of states and arcs in an
@@ -6623,21 +6514,15 @@ static void
 process_state_for_insn_equiv_partition (state_t state)
 {
   arc_t arc;
-  arc_t *insn_arcs_array;
-  int i;
-  vla_ptr_t insn_arcs_vect;
+  arc_t *insn_arcs_array = xmalloc (description->insns_num * sizeof(arc_t));
 
-  VLA_PTR_CREATE (insn_arcs_vect, 500, "insn arcs vector");
-  VLA_PTR_EXPAND (insn_arcs_vect, description->insns_num);
-  insn_arcs_array = VLA_PTR_BEGIN (insn_arcs_vect);
   /* Process insns of the arcs.  */
-  for (i = 0; i < description->insns_num; i++)
-    insn_arcs_array [i] = NULL;
   for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
     insn_arcs_array [arc->insn->insn_reserv_decl->insn_num] = arc;
   for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
     process_insn_equiv_class (arc->insn, insn_arcs_array);
-  VLA_PTR_DELETE (insn_arcs_vect);
+
+  free (insn_arcs_array);
 }
 
 /* The function searches for equivalent ainsns of AUTOMATON.  */
@@ -6745,56 +6630,53 @@ compare_max_occ_cycle_nums (const void *unit_decl_1,
 
 /* The function makes heuristic assigning automata to units.  Actually
    efficacy of the algorithm has been checked yet??? */
+
 static void
 units_to_automata_heuristic_distr (void)
 {
   double estimation_bound;
-  decl_t decl;
-  decl_t *unit_decl_ptr;
   int automaton_num;
   int rest_units_num;
   double bound_value;
-  vla_ptr_t unit_decls;
-  int i;
+  unit_decl_t *unit_decls;
+  int i, j;
 
   if (description->units_num == 0)
     return;
   estimation_bound = estimate_one_automaton_bound ();
-  VLA_PTR_CREATE (unit_decls, 150, "unit decls");
-  for (i = 0; i < description->decls_num; i++)
-    {
-      decl = description->decls [i];
-      if (decl->mode == dm_unit)
-       VLA_PTR_ADD (unit_decls, decl);
-    }
-  qsort (VLA_PTR_BEGIN (unit_decls), VLA_PTR_LENGTH (unit_decls),
-         sizeof (decl_t), compare_max_occ_cycle_nums);
+  unit_decls = xmalloc (description->units_num * sizeof (unit_decl_t));
+
+  for (i = 0, j = 0; i < description->decls_num; i++)
+    if (description->decls[i]->mode == dm_unit)
+      unit_decls[j++] = DECL_UNIT (description->decls[i]);
+  gcc_assert (j == description->units_num);
+
+  qsort (unit_decls, description->units_num,
+         sizeof (unit_decl_t), compare_max_occ_cycle_nums);
+
   automaton_num = 0;
-  unit_decl_ptr = VLA_PTR_BEGIN (unit_decls);
-  bound_value = DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num;
-  DECL_UNIT (*unit_decl_ptr)->corresponding_automaton_num = automaton_num;
-  for (unit_decl_ptr++;
-       unit_decl_ptr <= (decl_t *) VLA_PTR_LAST (unit_decls);
-       unit_decl_ptr++)
-    {
-      rest_units_num
-       = ((decl_t *) VLA_PTR_LAST (unit_decls) - unit_decl_ptr + 1);
+  bound_value = unit_decls[0]->max_occ_cycle_num;
+  unit_decls[0]->corresponding_automaton_num = automaton_num;
+
+  for (i = 1; i < description->units_num; i++)
+    {
+      rest_units_num = description->units_num - i + 1;
       gcc_assert (automata_num - automaton_num - 1 <= rest_units_num);
       if (automaton_num < automata_num - 1
           && ((automata_num - automaton_num - 1 == rest_units_num)
               || (bound_value
                   > (estimation_bound
-                    / (DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num)))))
+                    / unit_decls[i]->max_occ_cycle_num))))
         {
-          bound_value = DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num;
+          bound_value = unit_decls[i]->max_occ_cycle_num;
           automaton_num++;
         }
       else
-        bound_value *= DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num;
-      DECL_UNIT (*unit_decl_ptr)->corresponding_automaton_num = automaton_num;
+        bound_value *= unit_decls[i]->max_occ_cycle_num;
+      unit_decls[i]->corresponding_automaton_num = automaton_num;
     }
   gcc_assert (automaton_num == automata_num - 1);
-  VLA_PTR_DELETE (unit_decls);
+  free (unit_decls);
 }
 
 /* The functions creates automaton insns for each automata.  Automaton
@@ -7174,35 +7056,30 @@ output_dfa_max_issue_rate (void)
           MAX_DFA_ISSUE_RATE_VAR_NAME, max_dfa_issue_rate);
 }
 
-/* The function outputs all initialization values of VECT with length
-   vect_length.  */
+/* The function outputs all initialization values of VECT.  */
 static void
-output_vect (vect_el_t *vect, int vect_length)
+output_vect (vla_hwint_t vect)
 {
   int els_on_line;
+  size_t vect_length = VEC_length (vect_el_t, vect);
+  size_t i;
 
   els_on_line = 1;
   if (vect_length == 0)
-    fprintf (output_file,
-             "0 /* This is dummy el because the vect is empty */");
+    fputs ("0 /* This is dummy el because the vect is empty */", output_file);
   else
-    {
-      do
-        {
-          fprintf (output_file, "%5ld", (long) *vect);
-          vect_length--;
-          if (els_on_line == 10)
-           {
-             els_on_line = 0;
-             fprintf (output_file, ",\n");
-           }
-          else if (vect_length != 0)
-            fprintf (output_file, ", ");
-          els_on_line++;
-          vect++;
-        }
-      while (vect_length != 0);
-    }
+    for (i = 0; i < vect_length; i++)
+      {
+       fprintf (output_file, "%5ld", (long) VEC_index (vect_el_t, vect, i));
+       if (els_on_line == 10)
+         {
+           els_on_line = 0;
+           fputs (",\n", output_file);
+         }
+       else if (i < vect_length-1)
+         fputs (", ", output_file);
+       els_on_line++;
+      }
 }
 
 /* The following is name of the structure which represents DFA(s) for
@@ -7514,14 +7391,18 @@ output_translate_vect (automaton_t automaton)
   int insn_value;
   vla_hwint_t translate_vect;
 
-  VLA_HWINT_CREATE (translate_vect, 250, "translate vector");
-  VLA_HWINT_EXPAND (translate_vect, description->insns_num);
+  translate_vect = VEC_alloc (vect_el_t,heap, description->insns_num);
+
   for (insn_value = 0; insn_value < description->insns_num; insn_value++)
     /* Undefined value */
-    VLA_HWINT (translate_vect, insn_value) = automaton->insn_equiv_classes_num;
+    VEC_quick_push (vect_el_t, translate_vect,
+                   automaton->insn_equiv_classes_num);
+
   for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn)
-    VLA_HWINT (translate_vect, ainsn->insn_reserv_decl->insn_num)
-      = ainsn->insn_equiv_class_num;
+    VEC_replace (vect_el_t, 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");
   fprintf (output_file, "static const ");
@@ -7529,10 +7410,9 @@ output_translate_vect (automaton_t automaton)
   fprintf (output_file, " ");
   output_translate_vect_name (output_file, automaton);
   fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n");
-  output_vect (VLA_HWINT_BEGIN (translate_vect),
-              VLA_HWINT_LENGTH (translate_vect));
+  output_vect (translate_vect);
   fprintf (output_file, "};\n\n");
-  VLA_HWINT_DELETE (translate_vect);
+  VEC_free (vect_el_t,heap, translate_vect);
 }
 
 /* The value in a table state x ainsn -> something which represents
@@ -7544,8 +7424,8 @@ static int undefined_vect_el_value;
 static int
 comb_vect_p (state_ainsn_table_t tab)
 {
-  return  (2 * VLA_HWINT_LENGTH (tab->full_vect)
-           > 5 * VLA_HWINT_LENGTH (tab->comb_vect));
+  return  (2 * VEC_length (vect_el_t, tab->full_vect)
+           > 5 * VEC_length (vect_el_t, tab->comb_vect));
 }
 
 /* The following function creates new table for AUTOMATON.  */
@@ -7558,16 +7438,20 @@ create_state_ainsn_table (automaton_t automaton)
 
   tab = create_node (sizeof (struct state_ainsn_table));
   tab->automaton = automaton;
-  VLA_HWINT_CREATE (tab->comb_vect, 10000, "comb vector");
-  VLA_HWINT_CREATE (tab->check_vect, 10000, "check vector");
-  VLA_HWINT_CREATE (tab->base_vect, 1000, "base vector");
-  VLA_HWINT_EXPAND (tab->base_vect, automaton->achieved_states_num);
-  VLA_HWINT_CREATE (tab->full_vect, 10000, "full vector");
+
+  tab->comb_vect  = VEC_alloc (vect_el_t,heap, 10000);
+  tab->check_vect = VEC_alloc (vect_el_t,heap, 10000);
+
+  tab->base_vect  = 0;
+  VEC_safe_grow (vect_el_t,heap, tab->base_vect,
+                automaton->achieved_states_num);
+
   full_vect_length = (automaton->insn_equiv_classes_num
                       * automaton->achieved_states_num);
-  VLA_HWINT_EXPAND (tab->full_vect, full_vect_length);
+  tab->full_vect  = VEC_alloc (vect_el_t,heap, full_vect_length);
   for (i = 0; i < full_vect_length; i++)
-    VLA_HWINT (tab->full_vect, i) = undefined_vect_el_value;
+    VEC_quick_push (vect_el_t, tab->full_vect, undefined_vect_el_value);
+
   tab->min_base_vect_el_value = 0;
   tab->max_base_vect_el_value = 0;
   tab->min_comb_vect_el_value = 0;
@@ -7578,7 +7462,7 @@ create_state_ainsn_table (automaton_t automaton)
 /* The following function outputs the best C representation of the
    table TAB of given TABLE_NAME.  */
 static void
-output_state_ainsn_table (state_ainsn_table_t tab, char *table_name,
+output_state_ainsn_table (state_ainsn_table_t tab, const char *table_name,
                          void (*output_full_vect_name_func) (FILE *, automaton_t),
                          void (*output_comb_vect_name_func) (FILE *, automaton_t),
                          void (*output_check_vect_name_func) (FILE *, automaton_t),
@@ -7593,8 +7477,7 @@ output_state_ainsn_table (state_ainsn_table_t tab, char *table_name,
       fprintf (output_file, " ");
       (*output_full_vect_name_func) (output_file, tab->automaton);
       fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n");
-      output_vect (VLA_HWINT_BEGIN (tab->full_vect),
-                   VLA_HWINT_LENGTH (tab->full_vect));
+      output_vect (tab->full_vect);
       fprintf (output_file, "};\n\n");
     }
   else
@@ -7606,8 +7489,7 @@ output_state_ainsn_table (state_ainsn_table_t tab, char *table_name,
       fprintf (output_file, " ");
       (*output_comb_vect_name_func) (output_file, tab->automaton);
       fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n");
-      output_vect (VLA_HWINT_BEGIN (tab->comb_vect),
-                   VLA_HWINT_LENGTH (tab->comb_vect));
+      output_vect (tab->comb_vect);
       fprintf (output_file, "};\n\n");
       fprintf (output_file, "/* Check vector for %s.  */\n", table_name);
       fprintf (output_file, "static const ");
@@ -7615,8 +7497,7 @@ output_state_ainsn_table (state_ainsn_table_t tab, char *table_name,
       fprintf (output_file, " ");
       (*output_check_vect_name_func) (output_file, tab->automaton);
       fprintf (output_file, "[] = {\n");
-      output_vect (VLA_HWINT_BEGIN (tab->check_vect),
-                   VLA_HWINT_LENGTH (tab->check_vect));
+      output_vect (tab->check_vect);
       fprintf (output_file, "};\n\n");
       fprintf (output_file, "/* Base vector for %s.  */\n", table_name);
       fprintf (output_file, "static const ");
@@ -7625,22 +7506,18 @@ output_state_ainsn_table (state_ainsn_table_t tab, char *table_name,
       fprintf (output_file, " ");
       (*output_base_vect_name_func) (output_file, tab->automaton);
       fprintf (output_file, "[] = {\n");
-      output_vect (VLA_HWINT_BEGIN (tab->base_vect),
-                   VLA_HWINT_LENGTH (tab->base_vect));
+      output_vect (tab->base_vect);
       fprintf (output_file, "};\n\n");
     }
 }
 
-/* The following function adds vector with length VECT_LENGTH and
-   elements pointed to by VECT to table TAB as its line with number
-   VECT_NUM.  */
+/* The following function adds vector VECT to table TAB as its line
+   with number VECT_NUM.  */
 static void
-add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
-         int vect_length)
+add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect)
 {
-  int real_vect_length;
-  vect_el_t *comb_vect_start;
-  vect_el_t *check_vect_start;
+  int vect_length;
+  size_t real_vect_length;
   int comb_vect_index;
   int comb_vect_els_num;
   int vect_index;
@@ -7651,23 +7528,30 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
   int i;
   unsigned long vect_mask, comb_vect_mask;
 
+  vect_length = VEC_length (vect_el_t, vect);
   gcc_assert (vect_length);
+  gcc_assert (VEC_last (vect_el_t, vect) != undefined_vect_el_value);
   real_vect_length = tab->automaton->insn_equiv_classes_num;
-  gcc_assert (vect [vect_length - 1] != undefined_vect_el_value);
   /* Form full vector in the table: */
-  for (i = 0; i < vect_length; i++)
-    VLA_HWINT (tab->full_vect,
-               i + tab->automaton->insn_equiv_classes_num * vect_num)
-      = vect [i];
+  {
+    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);
+    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));
+  }
   /* Form comb vector in the table: */
-  gcc_assert (VLA_HWINT_LENGTH (tab->comb_vect)
-             == VLA_HWINT_LENGTH (tab->check_vect));
-  comb_vect_start = VLA_HWINT_BEGIN (tab->comb_vect);
-  comb_vect_els_num = VLA_HWINT_LENGTH (tab->comb_vect);
+  gcc_assert (VEC_length (vect_el_t, tab->comb_vect)
+             == VEC_length (vect_el_t, tab->check_vect));
+
+  comb_vect_els_num = VEC_length (vect_el_t, tab->comb_vect);
   for (first_unempty_vect_index = 0;
        first_unempty_vect_index < vect_length;
        first_unempty_vect_index++)
-    if (vect [first_unempty_vect_index] != undefined_vect_el_value)
+    if (VEC_index (vect_el_t, vect, first_unempty_vect_index)
+       != undefined_vect_el_value)
       break;
 
   /* Search for the place in comb vect for the inserted vect.  */
@@ -7683,8 +7567,10 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
                vect_index < vect_length
                && vect_index + comb_vect_index < comb_vect_els_num;
                vect_index++)
-            if (vect [vect_index] != undefined_vect_el_value
-                && (comb_vect_start [vect_index + comb_vect_index]
+            if (VEC_index (vect_el_t, vect, vect_index)
+               != undefined_vect_el_value
+                && (VEC_index (vect_el_t, tab->comb_vect,
+                              vect_index + comb_vect_index)
                    != undefined_vect_el_value))
               break;
           if (vect_index >= vect_length
@@ -7701,7 +7587,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
        vect_index++)
     {
       vect_mask = vect_mask << 1;
-      if (vect [vect_index] != undefined_vect_el_value)
+      if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value)
        vect_mask |= 1;
     }
 
@@ -7717,7 +7603,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
     {
       comb_vect_mask <<= 1;
       if (vect_index + comb_vect_index < comb_vect_els_num
-         && comb_vect_start [vect_index + comb_vect_index]
+         && VEC_index (vect_el_t, tab->comb_vect, vect_index + comb_vect_index)
             != undefined_vect_el_value)
        comb_vect_mask |= 1;
     }
@@ -7728,7 +7614,8 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
        comb_vect_index++, i++)
     {
       comb_vect_mask = (comb_vect_mask << 1) | 1;
-      comb_vect_mask ^= comb_vect_start [i] == undefined_vect_el_value;
+      comb_vect_mask ^= (VEC_index (vect_el_t, tab->comb_vect, i)
+                        == undefined_vect_el_value);
       if ((vect_mask & comb_vect_mask) == 0)
        goto found;
     }
@@ -7749,27 +7636,29 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
   no_state_value = tab->automaton->achieved_states_num;
   while (additional_els_num > 0)
     {
-      VLA_HWINT_ADD (tab->comb_vect, vect_el);
-      VLA_HWINT_ADD (tab->check_vect, no_state_value);
+      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);
       additional_els_num--;
     }
-  comb_vect_start = VLA_HWINT_BEGIN (tab->comb_vect);
-  check_vect_start = VLA_HWINT_BEGIN (tab->check_vect);
-  gcc_assert (VLA_HWINT_LENGTH (tab->comb_vect)
-             >= (size_t) (comb_vect_index + real_vect_length));
+  gcc_assert (VEC_length (vect_el_t, tab->comb_vect)
+             >= comb_vect_index + real_vect_length);
   /* Fill comb and check vectors.  */
   for (vect_index = 0; vect_index < vect_length; vect_index++)
-    if (vect [vect_index] != undefined_vect_el_value)
+    if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value)
       {
-        gcc_assert (comb_vect_start [comb_vect_index + vect_index]
+       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)
                    == undefined_vect_el_value);
-        comb_vect_start [comb_vect_index + vect_index] = vect [vect_index];
-        gcc_assert (vect [vect_index] >= 0);
-        if (tab->max_comb_vect_el_value < vect [vect_index])
-          tab->max_comb_vect_el_value = vect [vect_index];
-        if (tab->min_comb_vect_el_value > vect [vect_index])
-          tab->min_comb_vect_el_value = vect [vect_index];
-        check_vect_start [comb_vect_index + vect_index] = vect_num;
+        gcc_assert (x >= 0);
+        if (tab->max_comb_vect_el_value < x)
+          tab->max_comb_vect_el_value = x;
+        if (tab->min_comb_vect_el_value > x)
+          tab->min_comb_vect_el_value = x;
+       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);
       }
   if (tab->max_comb_vect_el_value < undefined_vect_el_value)
     tab->max_comb_vect_el_value = undefined_vect_el_value;
@@ -7779,7 +7668,8 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect,
     tab->max_base_vect_el_value = comb_vect_index;
   if (tab->min_base_vect_el_value > comb_vect_index)
     tab->min_base_vect_el_value = comb_vect_index;
-  VLA_HWINT (tab->base_vect, vect_num) = comb_vect_index;
+
+  VEC_replace (vect_el_t, tab->base_vect, vect_num, comb_vect_index);
 }
 
 /* Return number of out arcs of STATE.  */
@@ -7827,22 +7717,22 @@ add_vect_el (vla_hwint_t *vect, ainsn_t ainsn, int el_value)
 
   gcc_assert (ainsn);
   equiv_class_num = ainsn->insn_equiv_class_num;
-  for (vect_index = VLA_HWINT_LENGTH (*vect);
+  for (vect_index = VEC_length (vect_el_t, *vect);
        vect_index <= equiv_class_num;
        vect_index++)
-    VLA_HWINT_ADD (*vect, undefined_vect_el_value);
-  VLA_HWINT (*vect, equiv_class_num) = el_value;
+    VEC_safe_push (vect_el_t,heap, *vect, undefined_vect_el_value);
+  VEC_replace (vect_el_t, *vect, equiv_class_num, el_value);
 }
 
 /* This is for forming vector of states of an automaton.  */
-static vla_ptr_t output_states_vect;
+static VEC(state_t,heap) *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)
 {
-  VLA_PTR_ADD (output_states_vect, state);
+  VEC_safe_push (state_t,heap, output_states_vect, state);
 }
 
 /* Form and output vectors (comb, check, base or full vector)
@@ -7850,26 +7740,24 @@ add_states_vect_el (state_t state)
 static void
 output_trans_table (automaton_t automaton)
 {
-  state_t *state_ptr;
+  size_t i;
   arc_t arc;
-  vla_hwint_t transition_vect;
+  vla_hwint_t transition_vect = 0;
 
   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).  */
-  VLA_PTR_CREATE (output_states_vect, 1500, "output states vector");
+  output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
-  qsort (VLA_PTR_BEGIN (output_states_vect),
-         VLA_PTR_LENGTH (output_states_vect),
+  qsort (VEC_address (state_t, output_states_vect),
+        VEC_length (state_t, output_states_vect),
          sizeof (state_t), compare_transition_els_num);
-  VLA_HWINT_CREATE (transition_vect, 500, "transition vector");
-  for (state_ptr = VLA_PTR_BEGIN (output_states_vect);
-       state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-       state_ptr++)
+
+  for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
     {
-      VLA_HWINT_NULLIFY (transition_vect);
-      for (arc = first_out_arc (*state_ptr);
+      VEC_truncate (vect_el_t, transition_vect, 0);
+      for (arc = first_out_arc (VEC_index (state_t, output_states_vect, i));
           arc != NULL;
           arc = next_out_arc (arc))
         {
@@ -7878,16 +7766,17 @@ output_trans_table (automaton_t automaton)
             add_vect_el (&transition_vect, arc->insn,
                          arc->to_state->order_state_num);
         }
-      add_vect (automaton->trans_table, (*state_ptr)->order_state_num,
-                VLA_HWINT_BEGIN (transition_vect),
-                VLA_HWINT_LENGTH (transition_vect));
+      add_vect (automaton->trans_table,
+               VEC_index (state_t, output_states_vect, i)->order_state_num,
+               transition_vect);
     }
   output_state_ainsn_table
-    (automaton->trans_table, (char *) "state transitions",
+    (automaton->trans_table, "state transitions",
      output_trans_full_vect_name, output_trans_comb_vect_name,
      output_trans_check_vect_name, output_trans_base_vect_name);
-  VLA_PTR_DELETE (output_states_vect);
-  VLA_HWINT_DELETE (transition_vect);
+
+  VEC_free (state_t,heap, output_states_vect);
+  VEC_free (vect_el_t,heap, transition_vect);
 }
 
 /* Form and output vectors (comb, check, base or simple vect)
@@ -7897,7 +7786,7 @@ output_trans_table (automaton_t automaton)
 static void
 output_state_alts_table (automaton_t automaton)
 {
-  state_t *state_ptr;
+  size_t i;
   arc_t arc;
   vla_hwint_t state_alts_vect;
 
@@ -7905,19 +7794,19 @@ output_state_alts_table (automaton_t automaton)
   automaton->state_alts_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).  */
-  VLA_PTR_CREATE (output_states_vect, 1500, "output states vector");
+  output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
-  qsort (VLA_PTR_BEGIN (output_states_vect),
-         VLA_PTR_LENGTH (output_states_vect),
+  qsort (VEC_address (state_t, output_states_vect),
+        VEC_length (state_t, output_states_vect),
          sizeof (state_t), compare_transition_els_num);
+
   /* Create base, comb, and check vectors.  */
-  VLA_HWINT_CREATE (state_alts_vect, 500, "state alts vector");
-  for (state_ptr = VLA_PTR_BEGIN (output_states_vect);
-       state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-       state_ptr++)
+  state_alts_vect = 0;
+
+  for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
     {
-      VLA_HWINT_NULLIFY (state_alts_vect);
-      for (arc = first_out_arc (*state_ptr);
+      VEC_truncate (vect_el_t, state_alts_vect, 0);
+      for (arc = first_out_arc (VEC_index (state_t, output_states_vect, i));
           arc != NULL;
           arc = next_out_arc (arc))
         {
@@ -7925,16 +7814,17 @@ output_state_alts_table (automaton_t automaton)
           if (arc->insn->first_ainsn_with_given_equivalence_num)
             add_vect_el (&state_alts_vect, arc->insn, arc->state_alts);
         }
-      add_vect (automaton->state_alts_table, (*state_ptr)->order_state_num,
-                VLA_HWINT_BEGIN (state_alts_vect),
-                VLA_HWINT_LENGTH (state_alts_vect));
+      add_vect (automaton->state_alts_table,
+               VEC_index (state_t, output_states_vect, i)->order_state_num,
+                state_alts_vect);
     }
   output_state_ainsn_table
-    (automaton->state_alts_table, (char *) "state insn alternatives",
+    (automaton->state_alts_table, "state insn alternatives",
      output_state_alts_full_vect_name, output_state_alts_comb_vect_name,
      output_state_alts_check_vect_name, output_state_alts_base_vect_name);
-  VLA_PTR_DELETE (output_states_vect);
-  VLA_HWINT_DELETE (state_alts_vect);
+
+  VEC_free (state_t,heap, output_states_vect);
+  VEC_free (vect_el_t,heap, state_alts_vect);
 }
 
 /* The current number of passing states to find minimal issue delay
@@ -8013,41 +7903,38 @@ output_min_issue_delay_table (automaton_t automaton)
   vla_hwint_t compressed_min_issue_delay_vect;
   vect_el_t min_delay;
   ainsn_t ainsn;
-  state_t *state_ptr;
-  int i;
+  size_t i, min_issue_delay_len;
+  size_t compressed_min_issue_delay_len;
+  size_t cfactor;
 
   /* Create vect of pointers to states ordered by num of transitions
      from the state (state with the maximum num is the first).  */
-  VLA_PTR_CREATE (output_states_vect, 1500, "output states vector");
+  output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
-  VLA_HWINT_CREATE (min_issue_delay_vect, 1500, "min issue delay vector");
-  VLA_HWINT_EXPAND (min_issue_delay_vect,
-                   VLA_HWINT_LENGTH (output_states_vect)
-                   * automaton->insn_equiv_classes_num);
-  for (i = 0;
-       i < ((int) VLA_HWINT_LENGTH (output_states_vect)
-           * automaton->insn_equiv_classes_num);
-       i++)
-    VLA_HWINT (min_issue_delay_vect, i) = 0;
+
+  min_issue_delay_len = (VEC_length (state_t, output_states_vect)
+                        * automaton->insn_equiv_classes_num);
+  min_issue_delay_vect = VEC_alloc (vect_el_t,heap, min_issue_delay_len);
+  for (i = 0; i < min_issue_delay_len; i++)
+    VEC_quick_push (vect_el_t, min_issue_delay_vect, 0);
+
   automaton->max_min_delay = 0;
   for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn)
     if (ainsn->first_ainsn_with_given_equivalence_num)
       {
-       for (state_ptr = VLA_PTR_BEGIN (output_states_vect);
-            state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-            state_ptr++)
-         (*state_ptr)->min_insn_issue_delay = -1;
-       for (state_ptr = VLA_PTR_BEGIN (output_states_vect);
-            state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-            state_ptr++)
+       for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
+         VEC_index (state_t, output_states_vect, i)->min_insn_issue_delay = -1;
+       for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
          {
-            min_delay = min_issue_delay (*state_ptr, ainsn);
+           state_t s = VEC_index (state_t, output_states_vect, i);
+            min_delay = min_issue_delay (s, ainsn);
            if (automaton->max_min_delay < min_delay)
              automaton->max_min_delay = min_delay;
-           VLA_HWINT (min_issue_delay_vect,
-                      (*state_ptr)->order_state_num
-                      * automaton->insn_equiv_classes_num
-                      + ainsn->insn_equiv_class_num) = min_delay;
+           VEC_replace (vect_el_t, min_issue_delay_vect,
+                        s->order_state_num
+                        * automaton->insn_equiv_classes_num
+                        + ainsn->insn_equiv_class_num,
+                        min_delay);
          }
       }
   fprintf (output_file, "/* Vector of min issue delay of insns.  */\n");
@@ -8058,37 +7945,36 @@ output_min_issue_delay_table (automaton_t automaton)
   fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n");
   /* Compress the vector.  */
   if (automaton->max_min_delay < 2)
-    automaton->min_issue_delay_table_compression_factor = 8;
+    cfactor = 8;
   else if (automaton->max_min_delay < 4)
-    automaton->min_issue_delay_table_compression_factor = 4;
+    cfactor = 4;
   else if (automaton->max_min_delay < 16)
-    automaton->min_issue_delay_table_compression_factor = 2;
+    cfactor = 2;
   else
-    automaton->min_issue_delay_table_compression_factor = 1;
-  VLA_HWINT_CREATE (compressed_min_issue_delay_vect, 1500,
-                   "compressed min issue delay vector");
-  VLA_HWINT_EXPAND (compressed_min_issue_delay_vect,
-                   (VLA_HWINT_LENGTH (min_issue_delay_vect)
-                    + automaton->min_issue_delay_table_compression_factor
-                    - 1)
-                   / automaton->min_issue_delay_table_compression_factor);
-  for (i = 0;
-       i < (int) VLA_HWINT_LENGTH (compressed_min_issue_delay_vect);
-       i++)
-    VLA_HWINT (compressed_min_issue_delay_vect, i) = 0;
-  for (i = 0; i < (int) VLA_HWINT_LENGTH (min_issue_delay_vect); i++)
-    VLA_HWINT (compressed_min_issue_delay_vect,
-              i / automaton->min_issue_delay_table_compression_factor)
-      |= (VLA_HWINT (min_issue_delay_vect, i)
-         << (8 - (i % automaton->min_issue_delay_table_compression_factor
-                  + 1)
-             * (8 / automaton->min_issue_delay_table_compression_factor)));
-  output_vect (VLA_HWINT_BEGIN (compressed_min_issue_delay_vect),
-               VLA_HWINT_LENGTH (compressed_min_issue_delay_vect));
+    cfactor = 1;
+  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);
+
+  for (i = 0; i < compressed_min_issue_delay_len; i++)
+    VEC_quick_push (vect_el_t, compressed_min_issue_delay_vect, 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);
+
+      cx |= x << (8 - (i % cfactor + 1) * (8 / cfactor));
+      VEC_replace (vect_el_t, compressed_min_issue_delay_vect, ci, cx);
+    }
+  output_vect (compressed_min_issue_delay_vect);
   fprintf (output_file, "};\n\n");
-  VLA_PTR_DELETE (output_states_vect);
-  VLA_HWINT_DELETE (min_issue_delay_vect);
-  VLA_HWINT_DELETE (compressed_min_issue_delay_vect);
+  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);
 }
 
 #ifndef NDEBUG
@@ -8102,29 +7988,30 @@ static int locked_states_num;
 static void
 output_dead_lock_vect (automaton_t automaton)
 {
-  state_t *state_ptr;
+  size_t i;
   arc_t arc;
-  vla_hwint_t dead_lock_vect;
+  vla_hwint_t dead_lock_vect = 0;
 
   /* Create vect of pointers to states ordered by num of
      transitions from the state (state with the maximum num is the
      first).  */
-  VLA_PTR_CREATE (output_states_vect, 1500, "output states vector");
+  output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
-  VLA_HWINT_CREATE (dead_lock_vect, 1500, "is dead locked vector");
-  VLA_HWINT_EXPAND (dead_lock_vect, VLA_HWINT_LENGTH (output_states_vect));
-  for (state_ptr = VLA_PTR_BEGIN (output_states_vect);
-       state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-       state_ptr++)
+
+  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++)
     {
-      arc = first_out_arc (*state_ptr);
+      state_t s = VEC_index (state_t, output_states_vect, i);
+      arc = first_out_arc (s);
       gcc_assert (arc);
-      VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num)
-        = (next_out_arc (arc) == NULL
-           && (arc->insn->insn_reserv_decl
-               == DECL_INSN_RESERV (advance_cycle_insn_decl)) ? 1 : 0);
+      VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num,
+                  (next_out_arc (arc) == NULL
+                   && (arc->insn->insn_reserv_decl
+                       == DECL_INSN_RESERV (advance_cycle_insn_decl))
+                   ? 1 : 0));
 #ifndef NDEBUG
-      if (VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num))
+      if (VEC_index (vect_el_t,dead_lock_vect, s->order_state_num))
         locked_states_num++;
 #endif
     }
@@ -8134,11 +8021,10 @@ output_dead_lock_vect (automaton_t automaton)
   fprintf (output_file, " ");
   output_dead_lock_vect_name (output_file, automaton);
   fprintf (output_file, "[] = {\n");
-  output_vect (VLA_HWINT_BEGIN (dead_lock_vect),
-              VLA_HWINT_LENGTH (dead_lock_vect));
+  output_vect (dead_lock_vect);
   fprintf (output_file, "};\n\n");
-  VLA_HWINT_DELETE (dead_lock_vect);
-  VLA_PTR_DELETE (output_states_vect);
+  VEC_free (state_t,heap, output_states_vect);
+  VEC_free (vect_el_t,heap, dead_lock_vect);
 }
 
 /* Form and output vector representing reserved units of the states of
@@ -8146,34 +8032,38 @@ output_dead_lock_vect (automaton_t automaton)
 static void
 output_reserved_units_table (automaton_t automaton)
 {
-  state_t *curr_state_ptr;
-  vla_hwint_t reserved_units_table;
-  size_t state_byte_size;
+  vla_hwint_t reserved_units_table = 0;
+  int state_byte_size;
+  int reserved_units_size;
+  size_t n;
   int i;
 
   /* Create vect of pointers to states.  */
-  VLA_PTR_CREATE (output_states_vect, 1500, "output states vector");
+  output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
   /* Create vector.  */
-  VLA_HWINT_CREATE (reserved_units_table, 1500, "reserved units vector");
   state_byte_size = (description->query_units_num + 7) / 8;
-  VLA_HWINT_EXPAND (reserved_units_table,
-                   VLA_HWINT_LENGTH (output_states_vect) * state_byte_size);
-  for (i = 0;
-       i < (int) (VLA_HWINT_LENGTH (output_states_vect) * state_byte_size);
-       i++)
-    VLA_HWINT (reserved_units_table, i) = 0;
-  for (curr_state_ptr = VLA_PTR_BEGIN (output_states_vect);
-       curr_state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect);
-       curr_state_ptr++)
+  reserved_units_size = (VEC_length (state_t, output_states_vect)
+                        * state_byte_size);
+
+  reserved_units_table = VEC_alloc (vect_el_t,heap, 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++)
     {
+      state_t s = VEC_index (state_t, output_states_vect, n);
       for (i = 0; i < description->units_num; i++)
        if (units_array [i]->query_p
-           && first_cycle_unit_presence (*curr_state_ptr, i))
-         VLA_HWINT (reserved_units_table,
-                    (*curr_state_ptr)->order_state_num * state_byte_size
-                    + units_array [i]->query_num / 8)
-           += (1 << (units_array [i]->query_num % 8));
+           && 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);
+
+           x += 1 << (units_array [i]->query_num % 8);
+           VEC_replace (vect_el_t, reserved_units_table, ri, x);
+         }
     }
   fprintf (output_file, "/* Vector for reserved units of states.  */\n");
   fprintf (output_file, "static const ");
@@ -8181,11 +8071,11 @@ output_reserved_units_table (automaton_t automaton)
   fprintf (output_file, " ");
   output_reserved_units_table_name (output_file, automaton);
   fprintf (output_file, "[] = {\n");
-  output_vect (VLA_HWINT_BEGIN (reserved_units_table),
-               VLA_HWINT_LENGTH (reserved_units_table));
+  output_vect (reserved_units_table);
   fprintf (output_file, "};\n\n");
-  VLA_HWINT_DELETE (reserved_units_table);
-  VLA_PTR_DELETE (output_states_vect);
+
+  VEC_free (state_t,heap, output_states_vect);
+  VEC_free (vect_el_t,heap, reserved_units_table);
 }
 
 /* The function outputs all tables representing DFA(s) used for fast
@@ -9225,7 +9115,7 @@ static void
 output_automaton_units (automaton_t automaton)
 {
   decl_t decl;
-  char *name;
+  const char *name;
   int curr_line_length;
   int there_is_an_automaton_unit;
   int i;
@@ -9263,14 +9153,13 @@ 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 vla_ptr_t state_reservs;
+static VEC(reserv_sets_t,heap) *state_reservs;
 
 /* The function forms `state_reservs' for STATE.  */
 static void
 add_state_reservs (state_t state)
 {
   alt_state_t curr_alt_state;
-  reserv_sets_t reservs;
 
   if (state->component_states != NULL)
     for (curr_alt_state = state->component_states;
@@ -9278,10 +9167,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
-    {
-      reservs = state->reservs;
-      VLA_PTR_ADD (state_reservs, reservs);
-    }
+    VEC_safe_push (reserv_sets_t,heap, state_reservs, state->reservs);
 }
 
 /* The function outputs readable representation of all out arcs of
@@ -9291,7 +9177,7 @@ output_state_arcs (state_t state)
 {
   arc_t arc;
   ainsn_t ainsn;
-  char *insn_name;
+  const char *insn_name;
   int curr_line_length;
 
   for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
@@ -9347,21 +9233,17 @@ state_reservs_cmp (const void *reservs_ptr_1, const void *reservs_ptr_2)
 static void
 remove_state_duplicate_reservs (void)
 {
-  reserv_sets_t *reservs_ptr;
-  reserv_sets_t *last_formed_reservs_ptr;
+  size_t i, j;
 
-  last_formed_reservs_ptr = NULL;
-  for (reservs_ptr = VLA_PTR_BEGIN (state_reservs);
-       reservs_ptr <= (reserv_sets_t *) VLA_PTR_LAST (state_reservs);
-       reservs_ptr++)
-    if (last_formed_reservs_ptr == NULL)
-      last_formed_reservs_ptr = reservs_ptr;
-    else if (reserv_sets_cmp (*last_formed_reservs_ptr, *reservs_ptr) != 0)
+  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)))
       {
-        ++last_formed_reservs_ptr;
-        *last_formed_reservs_ptr = *reservs_ptr;
+       j++;
+       VEC_replace (reserv_sets_t, state_reservs, j,
+                    VEC_index (reserv_sets_t, state_reservs, i));
       }
-  VLA_PTR_SHORTEN (state_reservs, reservs_ptr - last_formed_reservs_ptr - 1);
+  VEC_truncate (reserv_sets_t, state_reservs, j + 1);
 }
 
 /* The following function output readable representation of DFA(s)
@@ -9371,27 +9253,28 @@ remove_state_duplicate_reservs (void)
 static void
 output_state (state_t state)
 {
-  reserv_sets_t *reservs_ptr;
+  size_t i;
+
+  state_reservs = 0;
 
-  VLA_PTR_CREATE (state_reservs, 150, "state reservations");
   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);
-  qsort (VLA_PTR_BEGIN (state_reservs), VLA_PTR_LENGTH (state_reservs),
+  qsort (VEC_address (reserv_sets_t, state_reservs),
+        VEC_length (reserv_sets_t, state_reservs),
          sizeof (reserv_sets_t), state_reservs_cmp);
   remove_state_duplicate_reservs ();
-  for (reservs_ptr = VLA_PTR_BEGIN (state_reservs);
-       reservs_ptr <= (reserv_sets_t *) VLA_PTR_LAST (state_reservs);
-       reservs_ptr++)
+  for (i = 1; i < VEC_length (reserv_sets_t, state_reservs); i++)
     {
       fprintf (output_description_file, "    ");
-      output_reserv_sets (output_description_file, *reservs_ptr);
+      output_reserv_sets (output_description_file,
+                         VEC_index (reserv_sets_t, state_reservs, i));
       fprintf (output_description_file, "\n");
     }
   fprintf (output_description_file, "\n");
   output_state_arcs (state);
-  VLA_PTR_DELETE (state_reservs);
+  VEC_free (reserv_sets_t,heap, state_reservs);
 }
 
 /* The following function output readable representation of
@@ -9456,14 +9339,14 @@ output_statistics (FILE *f)
 #ifndef NDEBUG
       fprintf
        (f, "%5ld transition comb vector els, %5ld trans table els: %s\n",
-        (long) VLA_HWINT_LENGTH (automaton->trans_table->comb_vect),
-        (long) VLA_HWINT_LENGTH (automaton->trans_table->full_vect),
+        (long) VEC_length (vect_el_t, automaton->trans_table->comb_vect),
+        (long) VEC_length (vect_el_t, automaton->trans_table->full_vect),
         (comb_vect_p (automaton->trans_table)
          ? "use comb vect" : "use simple vect"));
       fprintf
         (f, "%5ld state alts comb vector els, %5ld state alts table els: %s\n",
-         (long) VLA_HWINT_LENGTH (automaton->state_alts_table->comb_vect),
-         (long) VLA_HWINT_LENGTH (automaton->state_alts_table->full_vect),
+         (long) VEC_length (vect_el_t, automaton->state_alts_table->comb_vect),
+         (long) VEC_length (vect_el_t, automaton->state_alts_table->full_vect),
          (comb_vect_p (automaton->state_alts_table)
           ? "use comb vect" : "use simple vect"));
       fprintf
@@ -9471,13 +9354,13 @@ output_statistics (FILE *f)
          (long) states_num * automaton->insn_equiv_classes_num,
         automaton->min_issue_delay_table_compression_factor);
       transition_comb_vect_els
-       += VLA_HWINT_LENGTH (automaton->trans_table->comb_vect);
+       += VEC_length (vect_el_t, automaton->trans_table->comb_vect);
       transition_full_vect_els
-        += VLA_HWINT_LENGTH (automaton->trans_table->full_vect);
+        += VEC_length (vect_el_t, automaton->trans_table->full_vect);
       state_alts_comb_vect_els
-        += VLA_HWINT_LENGTH (automaton->state_alts_table->comb_vect);
+        += VEC_length (vect_el_t, automaton->state_alts_table->comb_vect);
       state_alts_full_vect_els
-        += VLA_HWINT_LENGTH (automaton->state_alts_table->full_vect);
+        += VEC_length (vect_el_t, automaton->state_alts_table->full_vect);
       min_issue_delay_vect_els
        += states_num * automaton->insn_equiv_classes_num;
 #endif
@@ -9773,7 +9656,7 @@ initiate_automaton_gen (int argc, char **argv)
        fatal ("option `-split' has not been implemented yet\n");
        /* split_argument = atoi (argument_vect [i + 1]); */
       }
-  VLA_PTR_CREATE (decls, 150, "decls");
+
   /* Initialize IR storage.  */
   obstack_init (&irp);
   initiate_automaton_decl_table ();
@@ -9838,14 +9721,14 @@ check_automata_insn_issues (void)
 
 /* The following vla is used for storing pointers to all achieved
    states.  */
-static vla_ptr_t automaton_states;
+static VEC(state_t,heap) *automaton_states;
 
 /* This function is called by function pass_states to add an achieved
    STATE.  */
 static void
 add_automaton_state (state_t state)
 {
-  VLA_PTR_ADD (automaton_states, state);
+  VEC_safe_push (state_t,heap, automaton_states, state);
 }
 
 /* The following function forms list of important automata (whose
@@ -9854,29 +9737,27 @@ static void
 form_important_insn_automata_lists (void)
 {
   automaton_t automaton;
-  state_t *state_ptr;
   decl_t decl;
   ainsn_t ainsn;
   arc_t arc;
   int i;
+  size_t n;
 
-  VLA_PTR_CREATE (automaton_states, 1500,
-                 "automaton states for forming important insn automata sets");
+  automaton_states = 0;
   /* Mark important ainsns.  */
   for (automaton = description->first_automaton;
        automaton != NULL;
        automaton = automaton->next_automaton)
     {
-      VLA_PTR_NULLIFY (automaton_states);
+      VEC_truncate (state_t, automaton_states, 0);
       pass_states (automaton, add_automaton_state);
-      for (state_ptr = VLA_PTR_BEGIN (automaton_states);
-          state_ptr <= (state_t *) VLA_PTR_LAST (automaton_states);
-          state_ptr++)
+      for (n = 0; n < VEC_length (state_t, automaton_states); n++)
        {
-         for (arc = first_out_arc (*state_ptr);
+         state_t s = VEC_index (state_t, automaton_states, n);
+         for (arc = first_out_arc (s);
               arc != NULL;
               arc = next_out_arc (arc))
-           if (arc->to_state != *state_ptr)
+           if (arc->to_state != s)
              {
                gcc_assert (arc->insn->first_insn_with_same_reservs);
                for (ainsn = arc->insn;
@@ -9886,7 +9767,8 @@ form_important_insn_automata_lists (void)
              }
        }
     }
-  VLA_PTR_DELETE (automaton_states);
+  VEC_free (state_t,heap, automaton_states);
+
   /* Create automata sets for the insns.  */
   for (i = 0; i < description->decls_num; i++)
     {
@@ -9922,12 +9804,12 @@ expand_automata (void)
 
   description = create_node (sizeof (struct description)
                             /* One entry for cycle advancing insn.  */
-                            + sizeof (decl_t) * VLA_PTR_LENGTH (decls));
-  description->decls_num = VLA_PTR_LENGTH (decls);
+                            + sizeof (decl_t) * VEC_length (decl_t, decls));
+  description->decls_num = VEC_length (decl_t, decls);
   description->query_units_num = 0;
   for (i = 0; i < description->decls_num; i++)
     {
-      description->decls [i] = VLA_PTR (decls, i);
+      description->decls [i] = VEC_index (decl_t, decls, i);
       if (description->decls [i]->mode == dm_unit
          && DECL_UNIT (description->decls [i])->query_p)
         DECL_UNIT (description->decls [i])->query_num