Commit 851ee5f4 by Richard Sandiford Committed by Richard Sandiford

gensupport.h (compute_test_codes): Declare.

gcc/
	* gensupport.h (compute_test_codes): Declare.
	* gensupport.c (compute_predicate_codes): Rename to...
	(compute_test_codes): ...this.  Generalize error message.
	(process_define_predicate): Update accordingly.
	* genpreds.c (compute_maybe_allows): Delete.
	(add_constraint): Use compute_test_codes to determine whether
	something can accept a SUBREG, REG or MEM.

From-SVN: r223687
parent 3a37ecec
2015-05-26 Richard Sandiford <richard.sandiford@arm.com>
* gensupport.h (compute_test_codes): Declare.
* gensupport.c (compute_predicate_codes): Rename to...
(compute_test_codes): ...this. Generalize error message.
(process_define_predicate): Update accordingly.
* genpreds.c (compute_maybe_allows): Delete.
(add_constraint): Use compute_test_codes to determine whether
something can accept a SUBREG, REG or MEM.
2015-05-26 Torvald Riegel <triegel@redhat.com> 2015-05-26 Torvald Riegel <triegel@redhat.com>
* doc/extend.texi (__atomic Builtins): Use 'memory order' instead of * doc/extend.texi (__atomic Builtins): Use 'memory order' instead of
......
...@@ -716,34 +716,6 @@ mangle (const char *name) ...@@ -716,34 +716,6 @@ mangle (const char *name)
return XOBFINISH (rtl_obstack, const char *); return XOBFINISH (rtl_obstack, const char *);
} }
/* Return a bitmask, bit 1 if EXP maybe allows a REG/SUBREG, 2 if EXP
maybe allows a MEM. Bits should be clear only when we are sure it
will not allow a REG/SUBREG or a MEM. */
static int
compute_maybe_allows (rtx exp)
{
switch (GET_CODE (exp))
{
case IF_THEN_ELSE:
/* Conservative answer is like IOR, of the THEN and ELSE branches. */
return compute_maybe_allows (XEXP (exp, 1))
| compute_maybe_allows (XEXP (exp, 2));
case AND:
return compute_maybe_allows (XEXP (exp, 0))
& compute_maybe_allows (XEXP (exp, 1));
case IOR:
return compute_maybe_allows (XEXP (exp, 0))
| compute_maybe_allows (XEXP (exp, 1));
case MATCH_CODE:
if (*XSTR (exp, 1) == '\0')
return (strstr (XSTR (exp, 0), "reg") != NULL ? 1 : 0)
| (strstr (XSTR (exp, 0), "mem") != NULL ? 2 : 0);
/* FALLTHRU */
default:
return 3;
}
}
/* Add one constraint, of any sort, to the tables. NAME is its name; /* Add one constraint, of any sort, to the tables. NAME is its name;
REGCLASS is the register class, if any; EXP is the expression to REGCLASS is the register class, if any; EXP is the expression to
test, if any; IS_MEMORY and IS_ADDRESS indicate memory and address test, if any; IS_MEMORY and IS_ADDRESS indicate memory and address
...@@ -899,12 +871,17 @@ add_constraint (const char *name, const char *regclass, ...@@ -899,12 +871,17 @@ add_constraint (const char *name, const char *regclass,
c->is_extra = !(regclass || is_const_int || is_const_dbl); c->is_extra = !(regclass || is_const_int || is_const_dbl);
c->is_memory = is_memory; c->is_memory = is_memory;
c->is_address = is_address; c->is_address = is_address;
int maybe_allows = 3; c->maybe_allows_reg = true;
c->maybe_allows_mem = true;
if (exp) if (exp)
maybe_allows = compute_maybe_allows (exp); {
c->maybe_allows_reg = (maybe_allows & 1) != 0; char codes[NUM_RTX_CODE];
c->maybe_allows_mem = (maybe_allows & 2) != 0; compute_test_codes (exp, lineno, codes);
if (!codes[REG] && !codes[SUBREG])
c->maybe_allows_reg = false;
if (!codes[MEM])
c->maybe_allows_mem = false;
}
c->next_this_letter = *slot; c->next_this_letter = *slot;
*slot = c; *slot = c;
......
...@@ -204,8 +204,8 @@ static char did_you_mean_codes[NUM_RTX_CODE]; ...@@ -204,8 +204,8 @@ static char did_you_mean_codes[NUM_RTX_CODE];
predicate expression EXP, writing the result to CODES. LINENO is predicate expression EXP, writing the result to CODES. LINENO is
the line number on which the directive containing EXP appeared. */ the line number on which the directive containing EXP appeared. */
static void void
compute_predicate_codes (rtx exp, int lineno, char codes[NUM_RTX_CODE]) compute_test_codes (rtx exp, int lineno, char *codes)
{ {
char op0_codes[NUM_RTX_CODE]; char op0_codes[NUM_RTX_CODE];
char op1_codes[NUM_RTX_CODE]; char op1_codes[NUM_RTX_CODE];
...@@ -215,29 +215,29 @@ compute_predicate_codes (rtx exp, int lineno, char codes[NUM_RTX_CODE]) ...@@ -215,29 +215,29 @@ compute_predicate_codes (rtx exp, int lineno, char codes[NUM_RTX_CODE])
switch (GET_CODE (exp)) switch (GET_CODE (exp))
{ {
case AND: case AND:
compute_predicate_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
compute_predicate_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), lineno, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_AND (op0_codes[i], op1_codes[i]); codes[i] = TRISTATE_AND (op0_codes[i], op1_codes[i]);
break; break;
case IOR: case IOR:
compute_predicate_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
compute_predicate_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), lineno, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (op0_codes[i], op1_codes[i]); codes[i] = TRISTATE_OR (op0_codes[i], op1_codes[i]);
break; break;
case NOT: case NOT:
compute_predicate_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_NOT (op0_codes[i]); codes[i] = TRISTATE_NOT (op0_codes[i]);
break; break;
case IF_THEN_ELSE: case IF_THEN_ELSE:
/* a ? b : c accepts the same codes as (a & b) | (!a & c). */ /* a ? b : c accepts the same codes as (a & b) | (!a & c). */
compute_predicate_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
compute_predicate_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), lineno, op1_codes);
compute_predicate_codes (XEXP (exp, 2), lineno, op2_codes); compute_test_codes (XEXP (exp, 2), lineno, op2_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (TRISTATE_AND (op0_codes[i], op1_codes[i]), codes[i] = TRISTATE_OR (TRISTATE_AND (op0_codes[i], op1_codes[i]),
TRISTATE_AND (TRISTATE_NOT (op0_codes[i]), TRISTATE_AND (TRISTATE_NOT (op0_codes[i]),
...@@ -321,7 +321,7 @@ compute_predicate_codes (rtx exp, int lineno, char codes[NUM_RTX_CODE]) ...@@ -321,7 +321,7 @@ compute_predicate_codes (rtx exp, int lineno, char codes[NUM_RTX_CODE])
default: default:
error_with_line (lineno, error_with_line (lineno,
"'%s' cannot be used in a define_predicate expression", "'%s' cannot be used in predicates or constraints",
GET_RTX_NAME (GET_CODE (exp))); GET_RTX_NAME (GET_CODE (exp)));
memset (codes, I, NUM_RTX_CODE); memset (codes, I, NUM_RTX_CODE);
break; break;
...@@ -373,7 +373,7 @@ process_define_predicate (rtx desc, int lineno) ...@@ -373,7 +373,7 @@ process_define_predicate (rtx desc, int lineno)
if (GET_CODE (desc) == DEFINE_SPECIAL_PREDICATE) if (GET_CODE (desc) == DEFINE_SPECIAL_PREDICATE)
pred->special = true; pred->special = true;
compute_predicate_codes (XEXP (desc, 1), lineno, codes); compute_test_codes (XEXP (desc, 1), lineno, codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
if (codes[i] != N) if (codes[i] != N)
......
...@@ -109,5 +109,6 @@ struct pattern_stats ...@@ -109,5 +109,6 @@ struct pattern_stats
}; };
extern void get_pattern_stats (struct pattern_stats *ranges, rtvec vec); extern void get_pattern_stats (struct pattern_stats *ranges, rtvec vec);
extern void compute_test_codes (rtx, int, char *);
#endif /* GCC_GENSUPPORT_H */ #endif /* GCC_GENSUPPORT_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment