From patchwork Sun Dec 14 20:36:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 420906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D60661400D5 for ; Mon, 15 Dec 2014 07:36:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; q=dns; s=default; b=tFLpfBqo1Dya6lWwKNB/r 2mmU8en4VdbJ4SUFh1IrLJXWAo/4mYKhjpLsiQuB9L/ZxJEkOxnz7Yi1eDySpS+p zPW1HLvO67FS5OsG9SXqTjkPgud6VEn4TNzzBwFQ7MEnOWOQJmzIExorzBSh6wzw PBATd+vNg1BjWieXhGk5AY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:content-type; s=default; bh=iUMIVWeHtSZYrc67g4C5Zj5ZV4c =; b=agiSHRgNB0KOrpCI4U8R05oksKn1wesMU74CDXC3LadcROYpjYUCN2rg9rC 1nbYQLd7NLA2eR6/OGtP+MieFlUwEnB7ttjhyUjpMCZ+FQlEbj6bPqi2ohyUN4o2 12tUhEgNhcJgP98zQOF3T4lvTUmXgvGOHKPwGTBxyVL3xdy8= Received: (qmail 17220 invoked by alias); 14 Dec 2014 20:36:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17210 invoked by uid 89); 14 Dec 2014 20:36:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f180.google.com Received: from mail-lb0-f180.google.com (HELO mail-lb0-f180.google.com) (209.85.217.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 14 Dec 2014 20:36:38 +0000 Received: by mail-lb0-f180.google.com with SMTP id l4so8299151lbv.11 for ; Sun, 14 Dec 2014 12:36:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=b6/KVR8+CByPuT97nGOtLaG4rTtk39hj+0HenzC8hmY=; b=j4OjIiiKQwMK6/QbloMLntepCtKNCzvNWUFN+9LAGeqoB70+5jVt40/GViP9H+//my UjJdWOBJAok+9v+FYv/JjqvDROVWm+RFPA50ygTRJDKeldCDlmfr+Z+azqTYIe0Q4tdb zutmJZ/TzV6nmgfNZt5C6VSU0FB4D1rUfuy6DDHIknzgVspfzVCizS9SC6tmIko1HLKM vQcCQKIDJh1NSUEyiNSh9JYUyfZAcW1WlM/C5REPBNjQaBKdSrjApUTDMOjz917tQanQ gSJT7Smc92uUmrdH/yCniuy5/psiUtBLifoj/4mAFRLktWLBgNWmBeQJ3YWzgsXpf9mb l+Sg== X-Gm-Message-State: ALoCoQkbgfXl1HDYARP/2DOrnAxmDFdYkpRj48klKn0SLhcOsnSXWQ6Ql98DuJ6BZq7ayRle2paT MIME-Version: 1.0 X-Received: by 10.112.24.130 with SMTP id u2mr26599652lbf.57.1418589394616; Sun, 14 Dec 2014 12:36:34 -0800 (PST) Received: by 10.25.211.16 with HTTP; Sun, 14 Dec 2014 12:36:34 -0800 (PST) In-Reply-To: References: Date: Mon, 15 Dec 2014 02:06:34 +0530 Message-ID: Subject: Re: [match-and-simplify] print capture name From: Prathamesh Kulkarni To: rguenther@suse.de, gcc-patches@gcc.gnu.org X-IsSubscribed: yes On 15 December 2014 at 02:03, Prathamesh Kulkarni 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 (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