/* Generate code from machine description to recognize rtl as insns.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
{
DT_mode, DT_code, DT_veclen,
DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe,
+ DT_const_int,
DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
DT_accept_op, DT_accept_insn
} type;
static struct decision_test *new_decision_test
(enum decision_type, struct decision_test ***);
static rtx find_operand
- (rtx, int);
+ (rtx, int, rtx);
static rtx find_matching_operand
(rtx, int);
static void validate_pattern
return test;
}
-/* Search for and return operand N. */
+/* Search for and return operand N, stop when reaching node STOP. */
static rtx
-find_operand (rtx pattern, int n)
+find_operand (rtx pattern, int n, rtx stop)
{
const char *fmt;
RTX_CODE code;
int i, j, len;
rtx r;
+ if (pattern == stop)
+ return stop;
+
code = GET_CODE (pattern);
if ((code == MATCH_SCRATCH
- || code == MATCH_INSN
|| code == MATCH_OPERAND
|| code == MATCH_OPERATOR
|| code == MATCH_PARALLEL)
switch (fmt[i])
{
case 'e': case 'u':
- if ((r = find_operand (XEXP (pattern, i), n)) != NULL_RTX)
+ if ((r = find_operand (XEXP (pattern, i), n, stop)) != NULL_RTX)
return r;
break;
case 'V':
if (! XVEC (pattern, i))
break;
- /* FALLTHRU */
+ /* Fall through. */
case 'E':
for (j = 0; j < XVECLEN (pattern, i); j++)
- if ((r = find_operand (XVECEXP (pattern, i, j), n)) != NULL_RTX)
+ if ((r = find_operand (XVECEXP (pattern, i, j), n, stop))
+ != NULL_RTX)
return r;
break;
case 'V':
if (! XVEC (pattern, i))
break;
- /* FALLTHRU */
+ /* Fall through. */
case 'E':
for (j = 0; j < XVECLEN (pattern, i); j++)
{
case MATCH_SCRATCH:
return;
-
- case MATCH_INSN:
+ case MATCH_DUP:
+ case MATCH_OP_DUP:
+ case MATCH_PAR_DUP:
+ if (find_operand (insn, XINT (pattern, 0), pattern) == pattern)
+ {
+ message_with_line (pattern_lineno,
+ "operand %i duplicated before defined",
+ XINT (pattern, 0));
+ error_count++;
+ }
+ break;
case MATCH_OPERAND:
case MATCH_OPERATOR:
{
if (GET_CODE (dest) == MATCH_DUP
|| GET_CODE (dest) == MATCH_OP_DUP
|| GET_CODE (dest) == MATCH_PAR_DUP)
- dest = find_operand (insn, XINT (dest, 0));
+ dest = find_operand (insn, XINT (dest, 0), NULL);
if (GET_CODE (src) == MATCH_DUP
|| GET_CODE (src) == MATCH_OP_DUP
|| GET_CODE (src) == MATCH_PAR_DUP)
- src = find_operand (insn, XINT (src, 0));
+ src = find_operand (insn, XINT (src, 0), NULL);
dmode = GET_MODE (dest);
smode = GET_MODE (src);
beyond the end of the vector. */
test = new_decision_test (DT_veclen_ge, &place);
test->u.veclen = XVECLEN (pattern, 2);
- /* FALLTHRU */
+ /* Fall through. */
case MATCH_OPERAND:
case MATCH_SCRATCH:
case MATCH_OPERATOR:
- case MATCH_INSN:
{
const char *pred_name;
RTX_CODE was_code = code;
print_host_wide_int (p->u.intval);
break;
+ case DT_const_int:
+ printf ("x%d == const_int_rtx[MAX_SAVED_CONST_INT + (%d)]",
+ depth, (int) p->u.intval);
+ break;
+
case DT_veclen_ge:
printf ("XVECLEN (x%d, 0) >= %d", depth, p->u.veclen);
break;
struct decision_test *test, *last_test;
int uncond;
+ /* Scan the tests and simplify comparisons against small
+ constants. */
+ for (test = p->tests; test; test = test->next)
+ {
+ if (test->type == DT_code
+ && test->u.code == CONST_INT
+ && test->next
+ && test->next->type == DT_elt_zero_wide_safe
+ && -MAX_SAVED_CONST_INT <= test->next->u.intval
+ && test->next->u.intval <= MAX_SAVED_CONST_INT)
+ {
+ test->type = DT_const_int;
+ test->u.intval = test->next->u.intval;
+ test->next = test->next->next;
+ }
+ }
+
last_test = test = p->tests;
uncond = is_unconditional (test, subroutine_type);
if (uncond == 0)
while ((test = test->next) != NULL)
{
- int uncond2;
-
last_test = test;
- uncond2 = is_unconditional (test, subroutine_type);
- if (uncond2 != 0)
+ if (is_unconditional (test, subroutine_type))
break;
printf ("\n && ");