aboutsummaryrefslogtreecommitdiff
path: root/gcc/genmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/genmatch.c')
-rw-r--r--gcc/genmatch.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 109bd9e..7403ccb 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -347,8 +347,9 @@ comparison_code_p (enum tree_code code)
/* Base class for all identifiers the parser knows. */
-struct id_base : nofree_ptr_hash<id_base>
+class id_base : public nofree_ptr_hash<id_base>
{
+public:
enum id_kind { CODE, FN, PREDICATE, USER, NULL_ID } kind;
id_base (id_kind, const char *, int = -1);
@@ -393,8 +394,9 @@ id_base::id_base (id_kind kind_, const char *id_, int nargs_)
/* Identifier that maps to a tree code. */
-struct operator_id : public id_base
+class operator_id : public id_base
{
+public:
operator_id (enum tree_code code_, const char *id_, unsigned nargs_,
const char *tcc_)
: id_base (id_base::CODE, id_, nargs_), code (code_), tcc (tcc_) {}
@@ -404,8 +406,9 @@ struct operator_id : public id_base
/* Identifier that maps to a builtin or internal function code. */
-struct fn_id : public id_base
+class fn_id : public id_base
{
+public:
fn_id (enum built_in_function fn_, const char *id_)
: id_base (id_base::FN, id_), fn (fn_) {}
fn_id (enum internal_fn fn_, const char *id_)
@@ -417,8 +420,9 @@ struct simplify;
/* Identifier that maps to a user-defined predicate. */
-struct predicate_id : public id_base
+class predicate_id : public id_base
{
+public:
predicate_id (const char *id_)
: id_base (id_base::PREDICATE, id_), matchers (vNULL) {}
vec<simplify *> matchers;
@@ -426,8 +430,9 @@ struct predicate_id : public id_base
/* Identifier that maps to a operator defined by a 'for' directive. */
-struct user_id : public id_base
+class user_id : public id_base
{
+public:
user_id (const char *id_, bool is_oper_list_ = false)
: id_base (id_base::USER, id_), substitutes (vNULL),
used (false), is_oper_list (is_oper_list_) {}
@@ -665,7 +670,8 @@ struct capture_info;
/* The base class for operands. */
-struct operand {
+class operand {
+public:
enum op_type { OP_PREDICATE, OP_EXPR, OP_CAPTURE, OP_C_EXPR, OP_IF, OP_WITH };
operand (enum op_type type_, location_t loc_)
: type (type_), location (loc_) {}
@@ -680,8 +686,9 @@ struct operand {
/* A predicate operand. Predicates are leafs in the AST. */
-struct predicate : public operand
+class predicate : public operand
{
+public:
predicate (predicate_id *p_, location_t loc)
: operand (OP_PREDICATE, loc), p (p_) {}
predicate_id *p;
@@ -690,8 +697,9 @@ struct predicate : public operand
/* An operand that constitutes an expression. Expressions include
function calls and user-defined predicate invocations. */
-struct expr : public operand
+class expr : public operand
{
+public:
expr (id_base *operation_, location_t loc, bool is_commutative_ = false)
: operand (OP_EXPR, loc), operation (operation_),
ops (vNULL), expr_type (NULL), is_commutative (is_commutative_),
@@ -723,11 +731,13 @@ struct expr : public operand
a leaf operand in the AST. This class is also used to represent
the code to be generated for 'if' and 'with' expressions. */
-struct c_expr : public operand
+class c_expr : public operand
{
+public:
/* A mapping of an identifier and its replacement. Used to apply
'for' lowering. */
- struct id_tab {
+ class id_tab {
+ public:
const char *id;
const char *oper;
id_tab (const char *id_, const char *oper_): id (id_), oper (oper_) {}
@@ -753,8 +763,9 @@ struct c_expr : public operand
/* A wrapper around another operand that captures its value. */
-struct capture : public operand
+class capture : public operand
{
+public:
capture (location_t loc, unsigned where_, operand *what_, bool value_)
: operand (OP_CAPTURE, loc), where (where_), value_match (value_),
what (what_) {}
@@ -773,8 +784,9 @@ struct capture : public operand
/* if expression. */
-struct if_expr : public operand
+class if_expr : public operand
{
+public:
if_expr (location_t loc)
: operand (OP_IF, loc), cond (NULL), trueexpr (NULL), falseexpr (NULL) {}
c_expr *cond;
@@ -784,8 +796,9 @@ struct if_expr : public operand
/* with expression. */
-struct with_expr : public operand
+class with_expr : public operand
{
+public:
with_expr (location_t loc)
: operand (OP_WITH, loc), with (NULL), subexpr (NULL) {}
c_expr *with;
@@ -845,8 +858,9 @@ is_a_helper <with_expr *>::test (operand *op)
duplicates all outer 'if' and 'for' expressions here so each
simplify can exist in isolation. */
-struct simplify
+class simplify
{
+public:
enum simplify_kind { SIMPLIFY, MATCH };
simplify (simplify_kind kind_, unsigned id_, operand *match_,
@@ -1598,8 +1612,9 @@ static unsigned current_id;
/* Decision tree base class, used for DT_NODE. */
-struct dt_node
+class dt_node
{
+public:
enum dt_type { DT_NODE, DT_OPERAND, DT_TRUE, DT_MATCH, DT_SIMPLIFY };
enum dt_type type;
@@ -1634,8 +1649,9 @@ struct dt_node
/* Generic decision tree node used for DT_OPERAND, DT_MATCH and DT_TRUE. */
-struct dt_operand : public dt_node
+class dt_operand : public dt_node
{
+public:
operand *op;
dt_operand *match_dop;
unsigned pos;
@@ -1660,8 +1676,9 @@ struct dt_operand : public dt_node
/* Leaf node of the decision tree, used for DT_SIMPLIFY. */
-struct dt_simplify : public dt_node
+class dt_simplify : public dt_node
{
+public:
simplify *s;
unsigned pattern_no;
dt_operand **indexes;
@@ -1697,8 +1714,9 @@ is_a_helper <dt_simplify *>::test (dt_node *n)
/* A container for the actual decision tree. */
-struct decision_tree
+class decision_tree
{
+public:
dt_node *root;
void insert (struct simplify *, unsigned);
@@ -2070,8 +2088,9 @@ decision_tree::print (FILE *f)
on the outermost match expression operands for cases we cannot
handle. */
-struct capture_info
+class capture_info
{
+public:
capture_info (simplify *s, operand *, bool);
void walk_match (operand *o, unsigned toplevel_arg, bool, bool);
bool walk_result (operand *o, bool, operand *);