From 6e7a4706fdf5641516cd85b20d5ac9070a348e15 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Mon, 23 Jan 2006 15:16:19 +0000 Subject: r110130@banpei: zack | 2006-01-22 14:52:43 -0800 r110130@banpei: zack | 2006-01-22 14:52:43 -0800 * rtl.def (match_code): Add second argument. * genpreds.c (write_extract_subexp): New function. (write_match_code): Add path argument. Use write_extract_subexp. (write_predicate_expr): Pass path to write_match_code. (mark_mode_tests): MATCH_CODE applied to a subexpression does not perform a mode test. * genrecog.c (compute_predicate_codes): MATCH_CODE applied to a subexpression does not constrain the top-level code set. * read-rtl.c (read_rtx_variadic): New function. (read_rtx_1): Use it; allow AND and IOR to be variadic. * doc/md.texi: Document new notation. * config/i386/predicates.md (cmpsi_operand_1): Fold into ... (cmpsi_operand): ... here, using new notation. From-SVN: r110126 --- gcc/read-rtl.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'gcc/read-rtl.c') diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index b4b1051..5eb642ee 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -145,6 +145,7 @@ static int find_macro (struct macro_group *, const char *, FILE *); static struct mapping *read_mapping (struct macro_group *, htab_t, FILE *); static void check_code_macro (struct mapping *, FILE *); static rtx read_rtx_1 (FILE *, struct map_value **); +static rtx read_rtx_variadic (FILE *, struct map_value **, rtx); /* The mode and code macro structures. */ static struct macro_group modes, codes; @@ -1696,7 +1697,49 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps) c = read_skip_spaces (infile); if (c != ')') - fatal_expected_char (infile, ')', c); + { + /* Syntactic sugar for AND and IOR, allowing Lisp-like + arbitrary number of arguments for them. */ + if (c == '(' && (GET_CODE (return_rtx) == AND + || GET_CODE (return_rtx) == IOR)) + return read_rtx_variadic (infile, mode_maps, return_rtx); + else + fatal_expected_char (infile, ')', c); + } return return_rtx; } + +/* Mutually recursive subroutine of read_rtx which reads + (thing x1 x2 x3 ...) and produces RTL as if + (thing x1 (thing x2 (thing x3 ...))) had been written. + When called, FORM is (thing x1 x2), and the file position + is just past the leading parenthesis of x3. Only works + for THINGs which are dyadic expressions, e.g. AND, IOR. */ +static rtx +read_rtx_variadic (FILE *infile, struct map_value **mode_maps, rtx form) +{ + char c = '('; + rtx p = form, q; + + do + { + ungetc (c, infile); + + q = rtx_alloc (GET_CODE (p)); + PUT_MODE (q, GET_MODE (p)); + + XEXP (q, 0) = XEXP (p, 1); + XEXP (q, 1) = read_rtx_1 (infile, mode_maps); + + XEXP (p, 1) = q; + p = q; + c = read_skip_spaces (infile); + } + while (c == '('); + + if (c != ')') + fatal_expected_char (infile, ')', c); + + return form; +} -- cgit v1.1