From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2682C43466 for ; Mon, 21 Sep 2020 16:55:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5640E206DC for ; Mon, 21 Sep 2020 16:55:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MNfMASUs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5640E206DC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JqGksYe/Qw5ngVJ5rNAOHHLYjHlTGdsilbDDKaXOB3s=; b=MNfMASUs484bruNX+8ciyf0mO FKdkqdTW7RHpMUOa/zRkOFPXTVIMg3VdmEZheTjGoP7jc53tOZ6AOWom8mKCKBxy+6nUhedvGnPGK vJyo5Ov/a7mIY7vGju06Oro+fYa8SmPwB3c0mh6GqOL99ITj7NLU9WiXMvsDg+VLWbMyz0iJRfy/8 hVqT1ofLhS/Q2hLsbcgRzffG2WkjTeylUUkZjOo4vH4tz0NM5X+1mKVLovgpgVVlU0czabJB+FKx3 aDqAyzCqyQYJQNEKrCy1oUUDU2HLHtYL1QZdfIgvNGtpbc70MO/vNxT0YDofCEMVWTveNKVcAnLzC 3RgFrPIcQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKP4Q-0004g4-CF; Mon, 21 Sep 2020 16:53:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKP4M-0004eh-Uj for linux-arm-kernel@lists.infradead.org; Mon, 21 Sep 2020 16:53:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 926ADD6E; Mon, 21 Sep 2020 09:53:36 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 779AA3F73B; Mon, 21 Sep 2020 09:53:35 -0700 (PDT) Date: Mon, 21 Sep 2020 17:53:32 +0100 From: Dave Martin To: Will Deacon Subject: Re: [PATCH v4 3/8] arm64/fpsimdmacros: Allow the macro "for" to be used in more cases Message-ID: <20200921165330.GB6642@arm.com> References: <20200828181155.17745-1-broonie@kernel.org> <20200828181155.17745-4-broonie@kernel.org> <20200921123802.GG2139@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200921123802.GG2139@willie-the-truck> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_125339_077730_F7229163 X-CRM114-Status: GOOD ( 30.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , Catalin Marinas , Zhang Lei , Julien Grall , Mark Brown , linux-arm-kernel@lists.infradead.org, Daniel Kiss Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 21, 2020 at 01:38:03PM +0100, Will Deacon wrote: > On Fri, Aug 28, 2020 at 07:11:50PM +0100, Mark Brown wrote: > > From: Julien Grall > > > > The current version of the macro "for" is not able to work when the > > counter is used to generate registers using mnemonics. This is because > > gas is not able to evaluate the expression generated if used in > > register's name (i.e x\n). > > > > Gas offers a way to evaluate macro arguments by using % in front of > > them under the alternate macro mode. > > altmacro mode doesn't appear to be very widely used in the kernel at all, > so I'm a bit nervous about this. Note, altmacro is ancient and doesn't seem to have changed in living memory, so I'd say it's stable. I think the idea with this patch was to make sure that .altmacro is only in effect for the internals of _for: it gets turned off again before expanding any other macro, and at the end. > > The implementation of "for" is updated to use the alternate macro mode > > and %, so we can use the macro in more cases. As the alternate macro > > mode may have side-effects, this is disabled when expanding the body. > > > > While it is enough to prefix the argument of the macro "__for_body" > > with %, the arguments of "__for" are also prefixed to get a more > > bearable value in case of compilation error. > > > > Suggested-by: Dave Martin > > Signed-off-by: Julien Grall > > Reviewed-by: Dave Martin > > Signed-off-by: Mark Brown > > --- > > arch/arm64/include/asm/fpsimdmacros.h | 10 +++++++--- > > 1 file changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h > > index 636e9d9c7929..75293f111a6b 100644 > > --- a/arch/arm64/include/asm/fpsimdmacros.h > > +++ b/arch/arm64/include/asm/fpsimdmacros.h > > @@ -166,19 +166,23 @@ > > > > .macro __for from:req, to:req > > .if (\from) == (\to) > > - _for__body \from > > + _for__body %\from > > .else > > - __for \from, (\from) + ((\to) - (\from)) / 2 > > - __for (\from) + ((\to) - (\from)) / 2 + 1, \to > > + __for %\from, %((\from) + ((\to) - (\from)) / 2) > > + __for %((\from) + ((\to) - (\from)) / 2 + 1), %\to > > .endif > > .endm > > > > .macro _for var:req, from:req, to:req, insn:vararg > > .macro _for__body \var:req > > + .noaltmacro > > \insn > > + .altmacro > > Why do we need to disable alt macro mode here? >From memory, I think this was down to the principle of least surprise: \insn may itself be a macro call, and throughout the kernel macros either don't care what the macro expansion mode is, or expect non- altmacro mode. So this sticks to that convention so that we don't leak altmacro mode into code that isn't expecting it. > > .endm > > > > + .altmacro > > __for \from, \to > > + .noaltmacro > > Why do we enable it here, rather than in the __for macro itself? Again from memory, I think the mode takes effect when a macro is expanded. If .altmacro was put inside __for, the macro may already have been expanded (in non-altmacro mode) before the .altmacro directive takes effect. Cheers ---Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel