On 15 December 2014 at 02:03, Prathamesh Kulkarni <prathamesh.kulka...@linaro.org> wrote: > Print name of capture in patterns written by user. > > * genmatch.c > (capture::name): New. > (capture::capture): New default argument. > (parse_capture): Pass id to capture::capture. > (print_operand): Print name of capture if available. > oops, forgot to attach the patch.
> Thanks, > Prathamesh
Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 218664) +++ gcc/genmatch.c (working copy) @@ -508,12 +508,15 @@ struct capture : public operand { - capture (unsigned where_, operand *what_) - : operand (OP_CAPTURE), where (where_), what (what_) {} + capture (unsigned where_, operand *what_, const char *name_ = 0) + : operand (OP_CAPTURE), where (where_), what (what_), name (name_) {} /* Identifier index for the value. */ unsigned where; /* The captured value. */ operand *what; + /* The original capture name */ + const char *name; + virtual void gen_transform (FILE *f, const char *, bool, int, const char *, capture_info *, dt_operand ** = 0, bool = true); @@ -605,6 +608,8 @@ if (capture *c = dyn_cast<capture *> (o)) { fprintf (f, "@%u", c->where); + if (c->name) + fprintf (f, "(%s)", c->name); if (c->what && flattened == false) { putc (':', f); @@ -2940,7 +2945,7 @@ unsigned &num = capture_ids->get_or_insert (id, &existed); if (!existed) num = next_id; - return new capture (num, op); + return new capture (num, op, id); } /* Parse an expression