From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Nicholas Piggin <npiggin@gmail.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] powerpc: cleanup hw_irq.h
Date: Tue, 27 Aug 2019 13:26:16 -0500 [thread overview]
Message-ID: <20190827182616.GB31406@gate.crashing.org> (raw)
In-Reply-To: <1410046b-e1a3-b892-2add-6c1d353cb781@c-s.fr>
On Tue, Aug 27, 2019 at 07:36:35PM +0200, Christophe Leroy wrote:
> Le 27/08/2019 à 19:29, Segher Boessenkool a écrit :
> >On Tue, Aug 27, 2019 at 10:48:24PM +1000, Nicholas Piggin wrote:
> >>Christophe Leroy's on August 27, 2019 6:13 pm:
> >>>+#define wrtee(val) asm volatile("wrtee %0" : : "r" (val) : "memory")
> >>>+#define wrteei(val) asm volatile("wrteei %0" : : "i" (val) :
> >>>"memory")
> >>
> >>Can you implement just one macro that uses __builtin_constant_p to
> >>select between the imm and reg versions? I forgot if there's some
> >>corner cases that prevent that working with inline asm i constraints.
> >
> >static inline void wrtee(long val)
> >{
> > asm volatile("wrtee%I0 %0" : : "n"(val) : "memory");
> >}
>
> Great, didn't know that possibility.
>
> Can it be used with any insn, for instance with add/addi ?
> Or with mr/li ?
Any instruction, yes. %I<n> simply outputs an "i" if operand n is a
constant integer, and nothing otherwise.
So
asm("add%I2 %0,%1,%2" : "=r"(dst) : "r"(src1), "ri"(src1));
works well. I don't see how you would use it for li/mr... You can do
asm("add%I1 %0,0,%1" : "=r"(dst) : "ri"(src));
I suppose, but that is not really an mr.
> >(This output modifier goes back to the dark ages, some 2.4 or something).
>
> Hope Clang support it ...
I don't know, sorry. But it is used all over the place, see sfp-machine.h
for example, so maybe?
Segher
next prev parent reply other threads:[~2019-08-27 18:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 8:13 [PATCH 1/2] powerpc: permanently include 8xx registers in reg.h Christophe Leroy
2019-08-27 8:13 ` [PATCH 2/2] powerpc: cleanup hw_irq.h Christophe Leroy
2019-08-27 12:48 ` Nicholas Piggin
2019-08-27 17:29 ` Segher Boessenkool
2019-08-27 17:36 ` Christophe Leroy
2019-08-27 18:26 ` Segher Boessenkool [this message]
2019-08-27 18:33 ` Christophe Leroy
2019-08-27 19:11 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190827182616.GB31406@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=benh@kernel.crashing.org \
--cc=christophe.leroy@c-s.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).