[PATCH] powerpc/irq: Modernise inline assembly in irq_soft_mask_{set,return}
Segher Boessenkool
segher at kernel.crashing.org
Sun Sep 25 02:14:24 AEST 2022
On Sat, Sep 24, 2022 at 02:00:55PM +1000, Nicholas Piggin wrote:
> On Sat Sep 24, 2022 at 8:15 AM AEST, Segher Boessenkool wrote:
> > Never it is guaranteed that all accesses through this variable will use
> > the register directly: this fundamentally cannot work on all archs, and
> > also not at -O0. More in general it doesn't work if some basic
> > optimisations are not done, be it because of a compiler deficiency, or a
> > straight out bug, or maybe it is a conscious choice in some cases.
>
> Right, and we know better than to rely on a spec that is not 100% air
> tight with no possibility of lawyering. This may be what the intention is,
> it may be what gcc and clang do now, and everybody involved today agrees
> with that interpretation. We still have to maintain the kernel tomorrow
> though, so explicit r13 it must be.
It has *always* been this way. Very old GCC (say, GCC < 3.x) tried to
guarantee more, even, but that turned out to be untenable. But this is
all in the distant past.
I have no idea if clang implements the GCC C extensions correctly. If
they don't it is just another compiler bug and they'll just have to fix
it.
The rules *are* airtight. But this does not mean you can assume random
other stuff, adjacent or not :-P
> > (Please use "n" instead of "i". Doesn't matter here, but it does in
> > many other places.)
>
> What is the difference? Just "i" allows assmebly-time constants?
"n" means "number": constant integers. "i" means "immediate": any
constant. The address of a global variable is "i" but not "n" (in most
ABIs, no -fPIC and such) for example.
> How about "I"? that looks like it was made for it. Gives much better
> errors.
For PowerPC, "I" is a signed 16-bit number. "K" is unsigned 16-bit,
and there are more as well. Just like for "n" you'll have to make
sure the number you feed in will work in the assembler, and you'll get
the same error message (but, as you say, for "I" in some cases the
compiler will give errors already). It's otherwise only useful if you
use e.g. "IL" as constraint, and then write "addi%e2 %0,%1,%2" for
example, so the asm can generate "addis" insns. Such things aren't very
often useful in internal asm. The main reason any of this exists is
this is how GCC works internally; extended inline asm exposes a lot of
that.
Segher
More information about the Linuxppc-dev
mailing list