diff mbox

[match-and-simplify] print capture name

Message ID CAAgBjMmAQvHb9vx9qCpOfE1xWvR+zk=cA361Kkxf3thUa4PyUg@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni Dec. 14, 2014, 8:36 p.m. UTC
On 15 December 2014 at 02:03, Prathamesh Kulkarni
<prathamesh.kulkarni@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

Comments

Richard Biener Dec. 15, 2014, 12:27 p.m. UTC | #1
On Mon, 15 Dec 2014, Prathamesh Kulkarni wrote:

> On 15 December 2014 at 02:03, Prathamesh Kulkarni
> <prathamesh.kulkarni@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.

Applied - thanks,
Richard.

> > Thanks,
> > Prathamesh
>
diff mbox

Patch

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