X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fgenextract.c;h=09e7cde838018ef5baf70343485db4f90dbefe29;hb=1f5a839c957bc03e63b234ccf1cd7dca437b5482;hp=4ef4d982ca69f8b3c20113b332bc60fa420e05af;hpb=ea4b1692d1a67d549f0584f9b46a8932330bc52a;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/genextract.c b/gcc/genextract.c index 4ef4d982ca6..09e7cde8380 100644 --- a/gcc/genextract.c +++ b/gcc/genextract.c @@ -1,13 +1,13 @@ /* Generate code from machine description to extract operands from insn as rtl. Copyright (C) 1987, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2003, - 2004, 2005 + 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later +Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY @@ -16,9 +16,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING. If not, write to the Free -Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. */ +along with GCC; see the file COPYING3. If not see +. */ #include "bconfig.h" @@ -27,8 +26,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tm.h" #include "rtl.h" #include "errors.h" +#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 @@ -69,11 +70,7 @@ 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_I(int); -DEF_VEC_I(char); DEF_VEC_P(locstr); -DEF_VEC_ALLOC_I(int,heap); -DEF_VEC_ALLOC_I(char,heap); DEF_VEC_ALLOC_P(locstr,heap); struct accum_extract @@ -84,6 +81,8 @@ struct accum_extract VEC(char,heap) *pathstr; }; +int line_no; + /* Forward declarations. */ static void walk_rtx (rtx, struct accum_extract *); @@ -156,7 +155,7 @@ gen_insn (rtx insn, int insn_code_number) /* Otherwise, make a new extraction method. We stash the arrays after the extraction structure in memory. */ - p = xmalloc (sizeof (struct extraction) + p = XNEWVAR (struct extraction, sizeof (struct extraction) + op_count*sizeof (char *) + dup_count*sizeof (char *) + dup_count*sizeof (int)); @@ -191,8 +190,13 @@ VEC_safe_set_locstr (VEC(locstr,heap) **vp, unsigned int ix, char *str) { if (ix < VEC_length (locstr, *vp)) { - gcc_assert (VEC_index (locstr, *vp, ix) == 0); - VEC_replace (locstr, *vp, ix, str); + if (VEC_index (locstr, *vp, ix)) + { + message_with_line (line_no, "repeated operand number %d", ix); + have_error = 1; + } + else + VEC_replace (locstr, *vp, ix, str); } else { @@ -208,7 +212,7 @@ static char * VEC_char_to_string (VEC(char,heap) *v) { size_t n = VEC_length (char, v); - char *s = xmalloc (n + 1); + char *s = XNEWVEC (char, n + 1); memcpy (s, VEC_address (char, v), n); s[n] = '\0'; return s; @@ -361,7 +365,7 @@ print_header (void) #include \"rtl.h\"\n\ #include \"insn-config.h\"\n\ #include \"recog.h\"\n\ -#include \"toplev.h\"\n\ +#include \"diagnostic-core.h\"\n\ \n\ /* This variable is used as the \"location\" of any missing operand\n\ whose numbers are skipped by a given pattern. */\n\ @@ -403,11 +407,10 @@ main (int argc, char **argv) struct code_ptr *link; const char *name; int insn_code_number; - int line_no; progname = "genextract"; - if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) + if (!init_rtx_reader_args (argc, argv)) return (FATAL_EXIT_CODE); /* Read the machine description. */ @@ -419,7 +422,7 @@ main (int argc, char **argv) else if (GET_CODE (desc) == DEFINE_PEEPHOLE) { - struct code_ptr *link = xmalloc (sizeof (struct code_ptr)); + struct code_ptr *link = XNEW (struct code_ptr); link->insn_code = insn_code_number; link->next = peepholes; @@ -427,6 +430,9 @@ main (int argc, char **argv) } } + if (have_error) + return FATAL_EXIT_CODE; + print_header (); /* Write out code to handle peepholes and the insn_codes that it should