summaryrefslogtreecommitdiff
path: root/gcc/genpreds.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-23 15:16:19 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-23 15:16:19 +0000
commit6c9ff2793c7c1875b1a2db026ea01b46cf9e4ad1 (patch)
treeffc73708bd6be59b11ab8a71a9537d0d6289dced /gcc/genpreds.c
parentaab72a2c39963a7afc2537bd2ed9d91ab58a0cfb (diff)
downloadgcc-6c9ff2793c7c1875b1a2db026ea01b46cf9e4ad1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110126 138bc75d-0d04-0410-961f-82ee72b054a4
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 6dbe7d4b920..bfd681cc7b8 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: