Commit e663da80 by Richard Sandiford Committed by Richard Sandiford

gensupport.h (pred_data): Add a "num_codes" field.

gcc/
	* gensupport.h (pred_data): Add a "num_codes" field.
	(add_predicate_code): Declare.
	* gensupport.c (add_predicate_code): New function.
	(std_pred_table): Add an "allows_const_p" field.
	(std_preds): Set this field for predicates that allow RTX_CONST_OBJs.
	Remove the (incomplete) list of such codes from the codes field.
	(init_predicate_table): Use add_predicate_code.  Add all
	RTX_CONST_OBJs if allows_const_p is true.
	* genrecog.c (process_define_predicate): Use add_predicate_code.

From-SVN: r135090
parent 977502ff
2008-05-08 Richard Sandiford <rsandifo@nildram.co.uk>
* gensupport.h (pred_data): Add a "num_codes" field.
(add_predicate_code): Declare.
* gensupport.c (add_predicate_code): New function.
(std_pred_table): Add an "allows_const_p" field.
(std_preds): Set this field for predicates that allow RTX_CONST_OBJs.
Remove the (incomplete) list of such codes from the codes field.
(init_predicate_table): Use add_predicate_code. Add all
RTX_CONST_OBJs if allows_const_p is true.
* genrecog.c (process_define_predicate): Use add_predicate_code.
2008-05-08 David Daney <ddaney@avtrex.com> 2008-05-08 David Daney <ddaney@avtrex.com>
Richard Sandiford <rsandifo@nildram.co.uk> Richard Sandiford <rsandifo@nildram.co.uk>
......
...@@ -368,7 +368,6 @@ process_define_predicate (rtx desc) ...@@ -368,7 +368,6 @@ process_define_predicate (rtx desc)
{ {
struct pred_data *pred = xcalloc (sizeof (struct pred_data), 1); struct pred_data *pred = xcalloc (sizeof (struct pred_data), 1);
char codes[NUM_RTX_CODE]; char codes[NUM_RTX_CODE];
bool seen_one = false;
int i; int i;
pred->name = XSTR (desc, 0); pred->name = XSTR (desc, 0);
...@@ -379,26 +378,8 @@ process_define_predicate (rtx desc) ...@@ -379,26 +378,8 @@ process_define_predicate (rtx desc)
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
if (codes[i] != N) if (codes[i] != N)
{ add_predicate_code (pred, i);
pred->codes[i] = true;
if (GET_RTX_CLASS (i) != RTX_CONST_OBJ)
pred->allows_non_const = true;
if (i != REG
&& i != SUBREG
&& i != MEM
&& i != CONCAT
&& i != PARALLEL
&& i != STRICT_LOW_PART)
pred->allows_non_lvalue = true;
if (seen_one)
pred->singleton = UNKNOWN;
else
{
pred->singleton = i;
seen_one = true;
}
}
add_predicate (pred); add_predicate (pred);
} }
#undef I #undef I
......
...@@ -1299,6 +1299,34 @@ lookup_predicate (const char *name) ...@@ -1299,6 +1299,34 @@ lookup_predicate (const char *name)
return (struct pred_data *) htab_find (predicate_table, &key); return (struct pred_data *) htab_find (predicate_table, &key);
} }
/* Record that predicate PRED can accept CODE. */
void
add_predicate_code (struct pred_data *pred, enum rtx_code code)
{
if (!pred->codes[code])
{
pred->num_codes++;
pred->codes[code] = true;
if (GET_RTX_CLASS (code) != RTX_CONST_OBJ)
pred->allows_non_const = true;
if (code != REG
&& code != SUBREG
&& code != MEM
&& code != CONCAT
&& code != PARALLEL
&& code != STRICT_LOW_PART)
pred->allows_non_lvalue = true;
if (pred->num_codes == 1)
pred->singleton = code;
else if (pred->num_codes == 2)
pred->singleton = UNKNOWN;
}
}
void void
add_predicate (struct pred_data *pred) add_predicate (struct pred_data *pred)
{ {
...@@ -1320,32 +1348,31 @@ struct std_pred_table ...@@ -1320,32 +1348,31 @@ struct std_pred_table
{ {
const char *name; const char *name;
bool special; bool special;
bool allows_const_p;
RTX_CODE codes[NUM_RTX_CODE]; RTX_CODE codes[NUM_RTX_CODE];
}; };
static const struct std_pred_table std_preds[] = { static const struct std_pred_table std_preds[] = {
{"general_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, {"general_operand", false, true, {SUBREG, REG, MEM}},
LABEL_REF, SUBREG, REG, MEM }}, {"address_operand", true, true, {SUBREG, REG, MEM, PLUS, MINUS, MULT}},
{"address_operand", true, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, {"register_operand", false, false, {SUBREG, REG}},
LABEL_REF, SUBREG, REG, MEM, {"pmode_register_operand", true, false, {SUBREG, REG}},
PLUS, MINUS, MULT}}, {"scratch_operand", false, false, {SCRATCH, REG}},
{"register_operand", false, {SUBREG, REG}}, {"immediate_operand", false, true, {0}},
{"pmode_register_operand", true, {SUBREG, REG}}, {"const_int_operand", false, false, {CONST_INT}},
{"scratch_operand", false, {SCRATCH, REG}}, {"const_double_operand", false, false, {CONST_INT, CONST_DOUBLE}},
{"immediate_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, {"nonimmediate_operand", false, false, {SUBREG, REG, MEM}},
LABEL_REF}}, {"nonmemory_operand", false, true, {SUBREG, REG}},
{"const_int_operand", false, {CONST_INT}}, {"push_operand", false, false, {MEM}},
{"const_double_operand", false, {CONST_INT, CONST_DOUBLE}}, {"pop_operand", false, false, {MEM}},
{"nonimmediate_operand", false, {SUBREG, REG, MEM}}, {"memory_operand", false, false, {SUBREG, MEM}},
{"nonmemory_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, {"indirect_operand", false, false, {SUBREG, MEM}},
LABEL_REF, SUBREG, REG}}, {"comparison_operator", false, false, {EQ, NE,
{"push_operand", false, {MEM}}, LE, LT, GE, GT,
{"pop_operand", false, {MEM}}, LEU, LTU, GEU, GTU,
{"memory_operand", false, {SUBREG, MEM}}, UNORDERED, ORDERED,
{"indirect_operand", false, {SUBREG, MEM}}, UNEQ, UNGE, UNGT,
{"comparison_operator", false, {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, GTU, UNLE, UNLT, LTGT}}
UNORDERED, ORDERED, UNEQ, UNGE, UNGT, UNLE,
UNLT, LTGT}}
}; };
#define NUM_KNOWN_STD_PREDS ARRAY_SIZE (std_preds) #define NUM_KNOWN_STD_PREDS ARRAY_SIZE (std_preds)
...@@ -1369,22 +1396,12 @@ init_predicate_table (void) ...@@ -1369,22 +1396,12 @@ init_predicate_table (void)
pred->special = std_preds[i].special; pred->special = std_preds[i].special;
for (j = 0; std_preds[i].codes[j] != 0; j++) for (j = 0; std_preds[i].codes[j] != 0; j++)
{ add_predicate_code (pred, std_preds[i].codes[j]);
enum rtx_code code = std_preds[i].codes[j];
if (std_preds[i].allows_const_p)
pred->codes[code] = true; for (j = 0; j < NUM_RTX_CODE; j++)
if (GET_RTX_CLASS (code) != RTX_CONST_OBJ) if (GET_RTX_CLASS (j) == RTX_CONST_OBJ)
pred->allows_non_const = true; add_predicate_code (pred, j);
if (code != REG
&& code != SUBREG
&& code != MEM
&& code != CONCAT
&& code != PARALLEL
&& code != STRICT_LOW_PART)
pred->allows_non_lvalue = true;
}
if (j == 1)
pred->singleton = std_preds[i].codes[0];
add_predicate (pred); add_predicate (pred);
} }
......
...@@ -76,6 +76,7 @@ struct pred_data ...@@ -76,6 +76,7 @@ struct pred_data
/* data used primarily by genrecog.c */ /* data used primarily by genrecog.c */
enum rtx_code singleton; /* if pred takes only one code, that code */ enum rtx_code singleton; /* if pred takes only one code, that code */
int num_codes; /* number of codes accepted */
bool allows_non_lvalue; /* if pred allows non-lvalue expressions */ bool allows_non_lvalue; /* if pred allows non-lvalue expressions */
bool allows_non_const; /* if pred allows non-const expressions */ bool allows_non_const; /* if pred allows non-const expressions */
bool codes[NUM_RTX_CODE]; /* set of codes accepted */ bool codes[NUM_RTX_CODE]; /* set of codes accepted */
...@@ -83,6 +84,7 @@ struct pred_data ...@@ -83,6 +84,7 @@ struct pred_data
extern struct pred_data *first_predicate; extern struct pred_data *first_predicate;
extern struct pred_data *lookup_predicate (const char *); extern struct pred_data *lookup_predicate (const char *);
extern void add_predicate_code (struct pred_data *, enum rtx_code);
extern void add_predicate (struct pred_data *); extern void add_predicate (struct pred_data *);
#define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next) #define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next)
......
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