From patchwork Wed Sep 9 23:53:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Collison X-Patchwork-Id: 53358 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 5BACB22B05 for ; Wed, 9 Sep 2015 23:53:43 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf8415144lbb.3 for ; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding:x-original-sender :x-original-authentication-results; bh=Vf/fVQaKzSUhKEj6wE+v1xZnkSEFhDjPF6rE5c2NQro=; b=ksDPEqJ8jFlIW3cCkHtrlGPTmmuQ7DLJeaUhuFAZQ1qEPLh7RM3KVduH8dHWUxXmSY SGtfnNvXVwVgDQ9+AMD45giOjyX0EYJB3x+qlWQC3UqsQYlQtzhtOUd6sRIMa+1MnrNd 7r4iXQ3pG8TFR+AI1Z2T2LqVGoyhTptMZCeGU8DMr+YTFn8eHqgA9PROE4pJvQXM2bgF AkAO15fMmGGKgn/SR2euNXOh3FFn54r3gqjimZ8kbNPo2GgBPwB+114yJJhAOhh4YX4Q kdU+DNtC5p9lWl0VD2LQpJ9gLtsG4b841ucdAXDsGVLir0HKTTaEQY0t96HdvQtk7U7a B+KQ== X-Gm-Message-State: ALoCoQm70bL10WXZe8Uii+kzpqOK6qpbq3It06Gy8WiA2bKe3YEC+ZBG/0aBQSBkhwmwewpZJ4LZ X-Received: by 10.180.100.71 with SMTP id ew7mr9013291wib.0.1441842821387; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.105 with SMTP id i9ls121539laa.72.gmail; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) X-Received: by 10.112.199.5 with SMTP id jg5mr32103137lbc.57.1441842821224; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com. [2a00:1450:4010:c04::22c]) by mx.google.com with ESMTPS id r3si8407734laa.97.2015.09.09.16.53.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 16:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) client-ip=2a00:1450:4010:c04::22c; Received: by lbbmp1 with SMTP id mp1so14414410lbb.1 for ; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr32075395lbb.36.1441842821082; Wed, 09 Sep 2015 16:53:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp623910lbq; Wed, 9 Sep 2015 16:53:40 -0700 (PDT) X-Received: by 10.107.154.213 with SMTP id c204mr18425534ioe.80.1441842820015; Wed, 09 Sep 2015 16:53:40 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 73si8045031ioo.2.2015.09.09.16.53.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 16:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-407006-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9412 invoked by alias); 9 Sep 2015 23:53:27 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 9400 invoked by uid 89); 9 Sep 2015 23:53:26 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 09 Sep 2015 23:53:25 +0000 Received: by padhk3 with SMTP id hk3so23988931pad.3 for ; Wed, 09 Sep 2015 16:53:23 -0700 (PDT) X-Received: by 10.66.235.226 with SMTP id up2mr37081556pac.89.1441842803297; Wed, 09 Sep 2015 16:53:23 -0700 (PDT) Received: from [192.168.1.14] (ip70-176-202-128.ph.ph.cox.net. [70.176.202.128]) by smtp.googlemail.com with ESMTPSA id as4sm8260549pbc.48.2015.09.09.16.53.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Sep 2015 16:53:22 -0700 (PDT) Message-ID: <55F0C66F.8010205@linaro.org> Date: Wed, 09 Sep 2015 16:53:19 -0700 From: Michael Collison User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gcc Patches , richard.sandiford@arm.com Subject: Re: [PATCH, PR 57195] Allow mode iterators inside angle brackets References: <55DC37D4.9050900@linaro.org> <8737yq5zpx.fsf@e105548-lin.cambridge.arm.com> In-Reply-To: <8737yq5zpx.fsf@e105548-lin.cambridge.arm.com> X-Original-Sender: michael.collison@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Richard, Here is a modified patch that takes your comments into account. Breaking on depth == 0 with '>' does not work due to the code looking for whitespace. 2015-08-25 Michael Collison PR other/57195 * read-md.c (read_name): Allow mode iterators inside angle brackets in rtl expressions. On 09/07/2015 02:46 AM, Richard Sandiford wrote: > Michael Collison writes: >> This patch allow mode iterators inside angle brackets in machine >> description files. I discovered the issue when attempting to use >> iterators on match_operand's as follows: >> >> match_operand: 0 "s_register_operand" "=w") >> >> The function 'read_name' is nor properly handling ':' inside angle brackets. >> >> Bootstrapped on arm-linux. > Sorry for the slow review. > >> diff --git a/gcc/read-md.c b/gcc/read-md.c >> index 9f158ec..0171fb0 100644 >> --- a/gcc/read-md.c >> +++ b/gcc/read-md.c >> @@ -399,17 +399,25 @@ read_name (struct md_name *name) >> { >> int c; >> size_t i; >> + bool in_angle_bracket; >> >> c = read_skip_spaces (); >> >> i = 0; >> + in_angle_bracket = false; >> while (1) >> { >> + if (c == '<') >> + in_angle_bracket = true; >> + >> + if (c == '>') >> + in_angle_bracket = false; >> + >> if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r' >> || c == EOF) >> break; >> - if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/' >> - || c == '(' || c == '[') >> + if (((c == ':') and (!in_angle_bracket)) || c == ')' || c == ']' >> + || c == '"' || c == '/' || c == '(' || c == '[') >> { >> unread_char (c); >> break; > I think we should have a nesting depth rather than a boolean. > It also seems more natural to skip the final "if" statement above when > inside an angle bracket, rather than treating ':' as a special case. > (We'd still break at the end of the line in the case of a missing '>', > so the error reporting shouldn't be too bad.) > > I suppose logically '>' with a nesting depth of 0 should also break > the loop. > > Thanks for fixing this. > > Richard > --- a/gcc/read-md.c +++ b/gcc/read-md.c @@ -399,20 +399,31 @@ read_name (struct md_name *name) { int c; size_t i; + int angle_bracket_depth; c = read_skip_spaces (); i = 0; + angle_bracket_depth = 0; while (1) { + if (c == '<') + angle_bracket_depth++; + + if ((c == '>') && (angle_bracket_depth > 0)) + angle_bracket_depth--; + if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r' || c == EOF) break; - if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/' - || c == '(' || c == '[') + if (angle_bracket_depth == 0) { - unread_char (c); - break; + if (c == ':' || c == ')' || c == ']' + || c == '"' || c == '/' || c == '(' || c == '[') + { + unread_char (c); + break; + } } if (i == sizeof (name->buffer) - 1)