This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [match-and-simplify] print capture name
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: rguenther at suse dot de, gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Dec 2014 02:06:34 +0530
- Subject: Re: [match-and-simplify] print capture name
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMnKurv=-5haeGYgJTRsmVWXsup+mH9q3QqJ0UEef77_OA at mail dot gmail dot com>
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
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