X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fgenpreds.c;h=de913491469cbcd2e59461f4bbcad328d7eab721;hb=b79fd74bab6c1df40695f92609d4a05e3e032af5;hp=5a4e249ceb447c19559c07cbceeec6bbc23f4248;hpb=520196acbe531ccadf086d8eec034a1b1751ef63;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/genpreds.c b/gcc/genpreds.c index 5a4e249ceb4..de913491469 100644 --- a/gcc/genpreds.c +++ b/gcc/genpreds.c @@ -2,7 +2,7 @@ - prototype declarations for operand predicates (tm-preds.h) - function definitions of operand predicates, if defined new-style (insn-preds.c) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "rtl.h" #include "errors.h" #include "obstack.h" +#include "read-md.h" #include "gensupport.h" /* Given a predicate expression EXP, from form NAME at line LINENO, @@ -66,9 +67,8 @@ validate_exp (rtx exp, const char *name, int lineno) { if (!ISDIGIT (*p) && !ISLOWER (*p)) { - message_with_line (lineno, "%s: invalid character in path " - "string '%s'", name, XSTR (exp, 1)); - have_error = 1; + error_with_line (lineno, "%s: invalid character in path " + "string '%s'", name, XSTR (exp, 1)); return true; } } @@ -81,10 +81,9 @@ validate_exp (rtx exp, const char *name, int lineno) return false; default: - message_with_line (lineno, - "%s: cannot use '%s' in a predicate expression", - name, GET_RTX_NAME (GET_CODE (exp))); - have_error = 1; + error_with_line (lineno, + "%s: cannot use '%s' in a predicate expression", + name, GET_RTX_NAME (GET_CODE (exp))); return true; } } @@ -94,35 +93,7 @@ validate_exp (rtx exp, const char *name, int lineno) static void process_define_predicate (rtx defn, int lineno) { - struct pred_data *pred; - const char *p; - - if (!ISALPHA (XSTR (defn, 0)[0]) && XSTR (defn, 0)[0] != '_') - goto bad_name; - for (p = XSTR (defn, 0) + 1; *p; p++) - if (!ISALNUM (*p) && *p != '_') - goto bad_name; - - if (validate_exp (XEXP (defn, 1), XSTR (defn, 0), lineno)) - return; - - pred = XCNEW (struct pred_data); - pred->name = XSTR (defn, 0); - pred->exp = XEXP (defn, 1); - pred->c_block = XSTR (defn, 2); - - if (GET_CODE (defn) == DEFINE_SPECIAL_PREDICATE) - pred->special = true; - - add_predicate (pred); - return; - - bad_name: - message_with_line (lineno, - "%s: predicate name must be a valid C function name", - XSTR (defn, 0)); - have_error = 1; - return; + validate_exp (XEXP (defn, 1), XSTR (defn, 0), lineno); } /* Given a predicate, if it has an embedded C block, write the block @@ -153,7 +124,7 @@ process_define_predicate (rtx defn, int lineno) The only wart is that there's no way to insist on a { } string in an RTL template, so we have to handle "" strings. */ - + static void write_predicate_subfunction (struct pred_data *p) { @@ -183,7 +154,7 @@ write_predicate_subfunction (struct pred_data *p) printf ("static inline int\n" "%s_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)\n", p->name); - print_rtx_ptr_loc (p->c_block); + print_md_ptr_loc (p->c_block); if (p->c_block[0] == '{') fputs (p->c_block, stdout); else @@ -290,7 +261,7 @@ mark_mode_tests (rtx exp) NO_MODE_TEST (exp) = (NO_MODE_TEST (XEXP (exp, 0)) && NO_MODE_TEST (XEXP (exp, 1))); break; - + case IOR: mark_mode_tests (XEXP (exp, 0)); mark_mode_tests (XEXP (exp, 1)); @@ -383,23 +354,23 @@ add_mode_tests (struct pred_data *p) { int test0 = NO_MODE_TEST (XEXP (subexp, 0)); int test1 = NO_MODE_TEST (XEXP (subexp, 1)); - + gcc_assert (test0 || test1); - + if (test0 && test1) goto break_loop; pos = test0 ? &XEXP (subexp, 0) : &XEXP (subexp, 1); } break; - + case IF_THEN_ELSE: { int test0 = NO_MODE_TEST (XEXP (subexp, 0)); int test1 = NO_MODE_TEST (XEXP (subexp, 1)); int test2 = NO_MODE_TEST (XEXP (subexp, 2)); - + gcc_assert ((test0 && test1) || test2); - + if (test0 && test1 && test2) goto break_loop; if (test0 && test1) @@ -411,7 +382,7 @@ add_mode_tests (struct pred_data *p) pos = &XEXP (subexp, 2); } break; - + default: goto break_loop; } @@ -473,7 +444,7 @@ write_match_code (const char *path, const char *codes) putchar (TOUPPER (*code)); code++; } - + if (*codes == ',') fputs (" || ", stdout); } @@ -493,7 +464,7 @@ write_predicate_expr (rtx exp) write_predicate_expr (XEXP (exp, 1)); putchar (')'); break; - + case IOR: putchar ('('); write_predicate_expr (XEXP (exp, 0)); @@ -764,12 +735,11 @@ add_constraint (const char *name, const char *regclass, if (!ISALPHA (name[0]) && name[0] != '_') { if (name[1] == '\0') - message_with_line (lineno, "constraint name '%s' is not " - "a letter or underscore", name); + error_with_line (lineno, "constraint name '%s' is not " + "a letter or underscore", name); else - message_with_line (lineno, "constraint name '%s' does not begin " - "with a letter or underscore", name); - have_error = 1; + error_with_line (lineno, "constraint name '%s' does not begin " + "with a letter or underscore", name); return; } for (p = name; *p; p++) @@ -779,11 +749,10 @@ add_constraint (const char *name, const char *regclass, need_mangled_name = true; else { - message_with_line (lineno, - "constraint name '%s' must be composed of " - "letters, digits, underscores, and " - "angle brackets", name); - have_error = 1; + error_with_line (lineno, + "constraint name '%s' must be composed of " + "letters, digits, underscores, and " + "angle brackets", name); return; } } @@ -791,17 +760,16 @@ add_constraint (const char *name, const char *regclass, if (strchr (generic_constraint_letters, name[0])) { if (name[1] == '\0') - message_with_line (lineno, "constraint letter '%s' cannot be " - "redefined by the machine description", name); + error_with_line (lineno, "constraint letter '%s' cannot be " + "redefined by the machine description", name); else - message_with_line (lineno, "constraint name '%s' cannot be defined by " - "the machine description, as it begins with '%c'", - name, name[0]); - have_error = 1; + error_with_line (lineno, "constraint name '%s' cannot be defined by " + "the machine description, as it begins with '%c'", + name, name[0]); return; } - + namelen = strlen (name); slot = &constraints_by_letter_table[(unsigned int)name[0]]; for (iter = slot; *iter; iter = &(*iter)->next_this_letter) @@ -816,25 +784,22 @@ add_constraint (const char *name, const char *regclass, if (!strcmp ((*iter)->name, name)) { - message_with_line (lineno, "redefinition of constraint '%s'", name); + error_with_line (lineno, "redefinition of constraint '%s'", name); message_with_line ((*iter)->lineno, "previous definition is here"); - have_error = 1; return; } else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) { - message_with_line (lineno, "defining constraint '%s' here", name); + error_with_line (lineno, "defining constraint '%s' here", name); message_with_line ((*iter)->lineno, "renders constraint '%s' " "(defined here) a prefix", (*iter)->name); - have_error = 1; return; } else if (!strncmp ((*iter)->name, name, namelen)) { - message_with_line (lineno, "constraint '%s' is a prefix", name); + error_with_line (lineno, "constraint '%s' is a prefix", name); message_with_line ((*iter)->lineno, "of constraint '%s' " "(defined here)", (*iter)->name); - have_error = 1; return; } } @@ -855,48 +820,41 @@ add_constraint (const char *name, const char *regclass, GET_RTX_NAME (appropriate_code))) { if (name[1] == '\0') - message_with_line (lineno, "constraint letter '%c' is reserved " - "for %s constraints", - name[0], GET_RTX_NAME (appropriate_code)); + error_with_line (lineno, "constraint letter '%c' is reserved " + "for %s constraints", + name[0], GET_RTX_NAME (appropriate_code)); else - message_with_line (lineno, "constraint names beginning with '%c' " - "(%s) are reserved for %s constraints", - name[0], name, - GET_RTX_NAME (appropriate_code)); - - have_error = 1; + error_with_line (lineno, "constraint names beginning with '%c' " + "(%s) are reserved for %s constraints", + name[0], name, GET_RTX_NAME (appropriate_code)); return; } if (is_memory) { if (name[1] == '\0') - message_with_line (lineno, "constraint letter '%c' cannot be a " - "memory constraint", name[0]); + error_with_line (lineno, "constraint letter '%c' cannot be a " + "memory constraint", name[0]); else - message_with_line (lineno, "constraint name '%s' begins with '%c', " - "and therefore cannot be a memory constraint", - name, name[0]); - - have_error = 1; + error_with_line (lineno, "constraint name '%s' begins with '%c', " + "and therefore cannot be a memory constraint", + name, name[0]); return; } else if (is_address) { if (name[1] == '\0') - message_with_line (lineno, "constraint letter '%c' cannot be a " - "memory constraint", name[0]); + error_with_line (lineno, "constraint letter '%c' cannot be a " + "memory constraint", name[0]); else - message_with_line (lineno, "constraint name '%s' begins with '%c', " - "and therefore cannot be a memory constraint", - name, name[0]); - - have_error = 1; + error_with_line (lineno, "constraint name '%s' begins with '%c', " + "and therefore cannot be a memory constraint", + name, name[0]); return; } } - + c = XOBNEW (rtl_obstack, struct constraint_data); c->name = name; c->c_name = need_mangled_name ? mangle (name) : name; @@ -1048,7 +1006,7 @@ write_insn_constraint_len (void) " return 1;\n" "}\n"); } - + /* Write out the function which computes the register class corresponding to a register constraint. */ static void @@ -1115,7 +1073,7 @@ write_tm_constrs_h (void) puts (" const REAL_VALUE_TYPE *rval = 0;"); if (needs_ival) - puts (" if (GET_CODE (op) == CONST_INT)\n" + puts (" if (CONST_INT_P (op))\n" " ival = INTVAL (op);"); if (needs_hval) puts (" if (GET_CODE (op) == CONST_DOUBLE && mode == VOIDmode)" @@ -1320,7 +1278,7 @@ write_tm_preds_h (void) puts ("#endif /* tm-preds.h */"); } -/* Write insn-preds.c. +/* Write insn-preds.c. N.B. the list of headers to include was copied from genrecog; it may not be ideal. @@ -1348,12 +1306,11 @@ write_insn_preds_c (void) #include \"function.h\"\n\ #include \"insn-config.h\"\n\ #include \"recog.h\"\n\ -#include \"real.h\"\n\ #include \"output.h\"\n\ #include \"flags.h\"\n\ #include \"hard-reg-set.h\"\n\ #include \"resource.h\"\n\ -#include \"toplev.h\"\n\ +#include \"diagnostic-core.h\"\n\ #include \"reload.h\"\n\ #include \"regs.h\"\n\ #include \"tm-constrs.h\"\n"); @@ -1367,7 +1324,7 @@ write_insn_preds_c (void) if (have_register_constraints) write_regclass_for_constraint (); write_constraint_satisfied_p (); - + if (have_const_int_constraints) write_insn_const_int_ok_for_constraint (); @@ -1409,7 +1366,7 @@ main (int argc, char **argv) progname = argv[0]; if (argc <= 1) fatal ("no input file name"); - if (init_md_reader_args_cb (argc, argv, parse_option) != SUCCESS_EXIT_CODE) + if (!init_rtx_reader_args_cb (argc, argv, parse_option)) return FATAL_EXIT_CODE; while ((defn = read_md_rtx (&pattern_lineno, &next_insn_code)) != 0)