summaryrefslogtreecommitdiff
path: root/gcc/gensupport.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-08 21:28:27 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-08 21:28:27 +0000
commitc7a4c804ee577fe5a84652746dae82a50b34bd85 (patch)
treebe8f401f9b48aa6d624266499579b7f40d103455 /gcc/gensupport.c
parent40efb3382e6fc70e7d1eb0fcac943ff3da183bbf (diff)
downloadgcc-c7a4c804ee577fe5a84652746dae82a50b34bd85.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135090 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gensupport.c')
-rw-r--r--gcc/gensupport.c93
1 files changed, 55 insertions, 38 deletions
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 7cacfa4540b..f455eb97260 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -1299,6 +1299,34 @@ lookup_predicate (const char *name)
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
add_predicate (struct pred_data *pred)
{
@@ -1320,32 +1348,31 @@ struct std_pred_table
{
const char *name;
bool special;
+ bool allows_const_p;
RTX_CODE codes[NUM_RTX_CODE];
};
static const struct std_pred_table std_preds[] = {
- {"general_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
- LABEL_REF, SUBREG, REG, MEM }},
- {"address_operand", true, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
- LABEL_REF, SUBREG, REG, MEM,
- PLUS, MINUS, MULT}},
- {"register_operand", false, {SUBREG, REG}},
- {"pmode_register_operand", true, {SUBREG, REG}},
- {"scratch_operand", false, {SCRATCH, REG}},
- {"immediate_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
- LABEL_REF}},
- {"const_int_operand", false, {CONST_INT}},
- {"const_double_operand", false, {CONST_INT, CONST_DOUBLE}},
- {"nonimmediate_operand", false, {SUBREG, REG, MEM}},
- {"nonmemory_operand", false, {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
- LABEL_REF, SUBREG, REG}},
- {"push_operand", false, {MEM}},
- {"pop_operand", false, {MEM}},
- {"memory_operand", false, {SUBREG, MEM}},
- {"indirect_operand", false, {SUBREG, MEM}},
- {"comparison_operator", false, {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, GTU,
- UNORDERED, ORDERED, UNEQ, UNGE, UNGT, UNLE,
- UNLT, LTGT}}
+ {"general_operand", false, true, {SUBREG, REG, MEM}},
+ {"address_operand", true, true, {SUBREG, REG, MEM, PLUS, MINUS, MULT}},
+ {"register_operand", false, false, {SUBREG, REG}},
+ {"pmode_register_operand", true, false, {SUBREG, REG}},
+ {"scratch_operand", false, false, {SCRATCH, REG}},
+ {"immediate_operand", false, true, {0}},
+ {"const_int_operand", false, false, {CONST_INT}},
+ {"const_double_operand", false, false, {CONST_INT, CONST_DOUBLE}},
+ {"nonimmediate_operand", false, false, {SUBREG, REG, MEM}},
+ {"nonmemory_operand", false, true, {SUBREG, REG}},
+ {"push_operand", false, false, {MEM}},
+ {"pop_operand", false, false, {MEM}},
+ {"memory_operand", false, false, {SUBREG, MEM}},
+ {"indirect_operand", false, false, {SUBREG, MEM}},
+ {"comparison_operator", false, false, {EQ, NE,
+ LE, LT, GE, GT,
+ LEU, LTU, GEU, GTU,
+ UNORDERED, ORDERED,
+ UNEQ, UNGE, UNGT,
+ UNLE, UNLT, LTGT}}
};
#define NUM_KNOWN_STD_PREDS ARRAY_SIZE (std_preds)
@@ -1369,22 +1396,12 @@ init_predicate_table (void)
pred->special = std_preds[i].special;
for (j = 0; std_preds[i].codes[j] != 0; j++)
- {
- enum rtx_code code = std_preds[i].codes[j];
-
- 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 (j == 1)
- pred->singleton = std_preds[i].codes[0];
+ add_predicate_code (pred, std_preds[i].codes[j]);
+
+ if (std_preds[i].allows_const_p)
+ for (j = 0; j < NUM_RTX_CODE; j++)
+ if (GET_RTX_CLASS (j) == RTX_CONST_OBJ)
+ add_predicate_code (pred, j);
add_predicate (pred);
}