aboutsummaryrefslogtreecommitdiff
path: root/gcc/genpreds.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2006-01-23 15:16:19 +0000
committerZack Weinberg <zack@gcc.gnu.org>2006-01-23 15:16:19 +0000
commit6e7a4706fdf5641516cd85b20d5ac9070a348e15 (patch)
treeffc73708bd6be59b11ab8a71a9537d0d6289dced /gcc/genpreds.c
parent6ff09968f1d0f5523b026701374f4a0386eb054c (diff)
downloadgcc-6e7a4706fdf5641516cd85b20d5ac9070a348e15.zip
gcc-6e7a4706fdf5641516cd85b20d5ac9070a348e15.tar.gz
gcc-6e7a4706fdf5641516cd85b20d5ac9070a348e15.tar.bz2
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
Diffstat (limited to 'gcc/genpreds.c')
-rw-r--r--gcc/genpreds.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/gcc/genpreds.c b/gcc/genpreds.c
index 6dbe7d4..bfd681c 100644
--- a/gcc/genpreds.c
+++ b/gcc/genpreds.c
@@ -148,11 +148,11 @@ write_predicate_subfunction (struct pred_data *p)
/* Given an RTL expression EXP, find all subexpressions which we may
assume to perform mode tests. Normal MATCH_OPERAND does;
- MATCH_CODE does if and only if it accepts CONST_INT or
- CONST_DOUBLE; and we have to assume that MATCH_TEST does not.
- These combine in almost-boolean fashion - the only exception is
- that (not X) must be assumed not to perform a mode test, whether or
- not X does.
+ MATCH_CODE does if it applies to the whole expression and accepts
+ CONST_INT or CONST_DOUBLE; and we have to assume that MATCH_TEST
+ does not. These combine in almost-boolean fashion - the only
+ exception is that (not X) must be assumed not to perform a mode
+ test, whether or not X does.
The mark is the RTL /v flag, which is true for subexpressions which
do *not* perform mode tests.
@@ -174,8 +174,9 @@ mark_mode_tests (rtx exp)
break;
case MATCH_CODE:
- if (!strstr (XSTR (exp, 0), "const_int")
- && !strstr (XSTR (exp, 0), "const_double"))
+ if (XSTR (exp, 1)[0] != '\0'
+ || (!strstr (XSTR (exp, 0), "const_int")
+ && !strstr (XSTR (exp, 0), "const_double")))
NO_MODE_TEST (exp) = 1;
break;
@@ -305,17 +306,56 @@ add_mode_tests (struct pred_data *p)
*pos = and_exp;
}
+/* PATH is a string describing a path from the root of an RTL
+ expression to an inner subexpression to be tested. Output
+ code which computes the subexpression from the variable
+ holding the root of the expression. */
+static void
+write_extract_subexp (const char *path)
+{
+ int len = strlen (path);
+ int i;
+
+ /* We first write out the operations (XEXP or XVECEXP) in reverse
+ order, then write "op", then the indices in forward order. */
+ for (i = len - 1; i >= 0; i--)
+ {
+ if (ISLOWER (path[i]))
+ fputs ("XVECEXP (", stdout);
+ else if (ISDIGIT (path[i]))
+ fputs ("XEXP (", stdout);
+ else
+ {
+ error ("bad character in path string '%s'", path);
+ return;
+ }
+ }
+
+ fputs ("op", stdout);
+
+ for (i = 0; i < len; i++)
+ {
+ if (ISLOWER (path[i]))
+ printf (", 0, %d)", path[i] - 'a');
+ else if (ISDIGIT (path[i]))
+ printf (", %d)", path[i] - '0');
+ else
+ gcc_unreachable ();
+ }
+}
/* CODES is a list of RTX codes. Write out an expression which
determines whether the operand has one of those codes. */
static void
-write_match_code (const char *codes)
+write_match_code (const char *path, const char *codes)
{
const char *code;
while ((code = scan_comma_elt (&codes)) != 0)
{
- fputs ("GET_CODE (op) == ", stdout);
+ fputs ("GET_CODE (", stdout);
+ write_extract_subexp (path);
+ fputs (") == ", stdout);
while (code < codes)
{
putchar (TOUPPER (*code));
@@ -374,7 +414,7 @@ write_predicate_expr (const char *name, rtx exp)
break;
case MATCH_CODE:
- write_match_code (XSTR (exp, 0));
+ write_match_code (XSTR (exp, 1), XSTR (exp, 0));
break;
case MATCH_TEST: