diff options
Diffstat (limited to 'gcc/genextract.c')
-rw-r--r-- | gcc/genextract.c | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/gcc/genextract.c b/gcc/genextract.c index fb1428687ca..063c2211152 100644 --- a/gcc/genextract.c +++ b/gcc/genextract.c @@ -29,7 +29,6 @@ along with GCC; see the file COPYING3. If not see #include "read-md.h" #include "gensupport.h" #include "vec.h" -#include "vecprim.h" /* This structure contains all the information needed to describe one set of extractions methods. Each method may be used by more than @@ -70,15 +69,13 @@ static struct code_ptr *peepholes; /* This structure is used by gen_insn and walk_rtx to accumulate the data that will be used to produce an extractions structure. */ -DEF_VEC_P(locstr); -DEF_VEC_ALLOC_P(locstr,heap); struct accum_extract { - VEC(locstr,heap) *oplocs; - VEC(locstr,heap) *duplocs; - VEC(int,heap) *dupnums; - VEC(char,heap) *pathstr; + vec<locstr> oplocs; + vec<locstr> duplocs; + vec<int> dupnums; + vec<char> pathstr; }; int line_no; @@ -95,10 +92,10 @@ gen_insn (rtx insn, int insn_code_number) struct code_ptr *link; struct accum_extract acc; - acc.oplocs = VEC_alloc (locstr,heap, 10); - acc.duplocs = VEC_alloc (locstr,heap, 10); - acc.dupnums = VEC_alloc (int,heap, 10); - acc.pathstr = VEC_alloc (char,heap, 20); + acc.oplocs.create (10); + acc.duplocs.create (10); + acc.dupnums.create (10); + acc.pathstr.create (20); /* Walk the insn's pattern, remembering at all times the path down to the walking point. */ @@ -108,9 +105,9 @@ gen_insn (rtx insn, int insn_code_number) else for (i = XVECLEN (insn, 1) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc.pathstr, 'a' + i); + acc.pathstr.safe_push ('a' + i); walk_rtx (XVECEXP (insn, 1, i), &acc); - VEC_pop (char, acc.pathstr); + acc.pathstr.pop (); } link = XNEW (struct code_ptr); @@ -118,9 +115,9 @@ gen_insn (rtx insn, int insn_code_number) /* See if we find something that already had this extraction method. */ - op_count = VEC_length (locstr, acc.oplocs); - dup_count = VEC_length (locstr, acc.duplocs); - gcc_assert (dup_count == VEC_length (int, acc.dupnums)); + op_count = acc.oplocs.length (); + dup_count = acc.duplocs.length (); + gcc_assert (dup_count == acc.dupnums.length ()); for (p = extractions; p; p = p->next) { @@ -130,7 +127,7 @@ gen_insn (rtx insn, int insn_code_number) for (j = 0; j < op_count; j++) { char *a = p->oplocs[j]; - char *b = VEC_index (locstr, acc.oplocs, j); + char *b = acc.oplocs[j]; if (a != b && (!a || !b || strcmp (a, b))) break; } @@ -139,8 +136,8 @@ gen_insn (rtx insn, int insn_code_number) continue; for (j = 0; j < dup_count; j++) - if (p->dupnums[j] != VEC_index (int, acc.dupnums, j) - || strcmp (p->duplocs[j], VEC_index (locstr, acc.duplocs, j))) + if (p->dupnums[j] != acc.dupnums[j] + || strcmp (p->duplocs[j], acc.duplocs[j])) break; if (j != dup_count) @@ -170,50 +167,50 @@ gen_insn (rtx insn, int insn_code_number) p->duplocs = p->oplocs + op_count; p->dupnums = (int *)(p->duplocs + dup_count); - memcpy(p->oplocs, VEC_address(locstr,acc.oplocs), op_count*sizeof(locstr)); - memcpy(p->duplocs, VEC_address(locstr,acc.duplocs), dup_count*sizeof(locstr)); - memcpy(p->dupnums, VEC_address(int, acc.dupnums), dup_count*sizeof(int)); + memcpy(p->oplocs, acc.oplocs.address(), op_count*sizeof(locstr)); + memcpy(p->duplocs, acc.duplocs.address(), dup_count*sizeof(locstr)); + memcpy(p->dupnums, acc.dupnums.address(), dup_count*sizeof(int)); done: - VEC_free (locstr,heap, acc.oplocs); - VEC_free (locstr,heap, acc.duplocs); - VEC_free (int,heap, acc.dupnums); - VEC_free (char,heap, acc.pathstr); + acc.oplocs.release (); + acc.duplocs.release (); + acc.dupnums.release (); + acc.pathstr.release (); } -/* Helper subroutine of walk_rtx: given a VEC(locstr), an index, and a +/* Helper subroutine of walk_rtx: given a vec<locstr>, an index, and a string, insert the string at the index, which should either already exist and be NULL, or not yet exist within the vector. In the latter case the vector is enlarged as appropriate. */ static void -VEC_safe_set_locstr (VEC(locstr,heap) **vp, unsigned int ix, char *str) +VEC_safe_set_locstr (vec<locstr> *vp, unsigned int ix, char *str) { - if (ix < VEC_length (locstr, *vp)) + if (ix < (*vp).length ()) { - if (VEC_index (locstr, *vp, ix)) + if ((*vp)[ix]) { message_with_line (line_no, "repeated operand number %d", ix); have_error = 1; } else - VEC_replace (locstr, *vp, ix, str); + (*vp)[ix] = str; } else { - while (ix > VEC_length (locstr, *vp)) - VEC_safe_push (locstr, heap, *vp, NULL); - VEC_safe_push (locstr, heap, *vp, str); + while (ix > (*vp).length ()) + vp->safe_push (NULL); + vp->safe_push (str); } } -/* Another helper subroutine of walk_rtx: given a VEC(char), convert it +/* Another helper subroutine of walk_rtx: given a vec<char>, convert it to a NUL-terminated string in malloc memory. */ static char * -VEC_char_to_string (VEC(char,heap) *v) +VEC_char_to_string (vec<char> v) { - size_t n = VEC_length (char, v); + size_t n = v.length (); char *s = XNEWVEC (char, n + 1); - memcpy (s, VEC_address (char, v), n); + memcpy (s, v.address (), n); s[n] = '\0'; return s; } @@ -251,18 +248,17 @@ walk_rtx (rtx x, struct accum_extract *acc) base = (code == MATCH_OPERATOR ? '0' : 'a'); for (i = XVECLEN (x, 2) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc->pathstr, base + i); + acc->pathstr.safe_push (base + i); walk_rtx (XVECEXP (x, 2, i), acc); - VEC_pop (char, acc->pathstr); + acc->pathstr.pop (); } return; case MATCH_DUP: case MATCH_PAR_DUP: case MATCH_OP_DUP: - VEC_safe_push (locstr,heap, acc->duplocs, - VEC_char_to_string (acc->pathstr)); - VEC_safe_push (int,heap, acc->dupnums, XINT (x, 0)); + acc->duplocs.safe_push (VEC_char_to_string (acc->pathstr)); + acc->dupnums.safe_push (XINT (x, 0)); if (code == MATCH_DUP) break; @@ -270,9 +266,9 @@ walk_rtx (rtx x, struct accum_extract *acc) base = (code == MATCH_OP_DUP ? '0' : 'a'); for (i = XVECLEN (x, 1) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc->pathstr, base + i); + acc->pathstr.safe_push (base + i); walk_rtx (XVECEXP (x, 1, i), acc); - VEC_pop (char, acc->pathstr); + acc->pathstr.pop (); } return; @@ -286,18 +282,18 @@ walk_rtx (rtx x, struct accum_extract *acc) { if (fmt[i] == 'e' || fmt[i] == 'u') { - VEC_safe_push (char,heap, acc->pathstr, '0' + i); + acc->pathstr.safe_push ('0' + i); walk_rtx (XEXP (x, i), acc); - VEC_pop (char, acc->pathstr); + acc->pathstr.pop (); } else if (fmt[i] == 'E') { int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) { - VEC_safe_push (char,heap, acc->pathstr, 'a' + j); + acc->pathstr.safe_push ('a' + j); walk_rtx (XVECEXP (x, i, j), acc); - VEC_pop (char, acc->pathstr); + acc->pathstr.pop (); } } } |