Hi,
Thanks for responding to my previous mail. A few more queries
a. What is the use of adding format specifiers in inline assembly
like
asm volatile("ld%U1%X1 %0,%1":"=r"(ret) : "m"(*ptr) : "memory");
b. using m or Z with a memory address. I tried replacing m/Z but no change
Is there some guideline ?
gcc documentation says Z is obsolete. Is m/Z replaceable ?
- Manish
On Fri, Jul 03, 2009 at 12:14:41PM +0530, kernel mailz wrote:
> Thanks for responding to my previous mail. A few more queries
>
> a. What is the use of adding format specifiers in inline assembly
> like
> asm volatile("ld%U1%X1 %0,%1":"=r"(ret) : "m"(*ptr) : "memory");
The format specifiers limit which registers or addressing modes will
be chosen to access that parameter. For example, if you're using an
instruction that treats r0 as a literal 0 value, you can't use the
"r" specifier for that or you may see problems if it happens to allocate
r0 for that particular argument. For memory access, the "m" lets you
use any of the normal load/store patterns (which is why this particular
choice also requires the "%U1%X1" part to allow changing the instruction).
The system was setup for an older style chip like x86 or 68k with many
restrictions on which registers can be used where and large numbers of
different addressing modes for accessing memory. It's a little clumsy
for ppc by comparison to most other chips, but it's a fundamental part
of inline assembly processing in gcc.
> b. using m or Z with a memory address. I tried replacing m/Z but no change
> Is there some guideline ?
> gcc documentation says Z is obsolete. Is m/Z replaceable ?
No idea. I don't remember ever seeing 'Z' used in anything. Maybe somebody
else remembers what it used to mean.
Brad Boyer
[email protected]
Hi Brad,
Thanks for responding.
My query was more on %U1%X1, I guess it is specifying U and/or X for %1 right ?
what does U/X stand for (is it similar to u - unsigned and x for a hex address)
are there any more literals like U/X/...
-Manish
On Fri, Jul 3, 2009 at 11:10 PM, Brad Boyer<[email protected]> wrote:
> On Fri, Jul 03, 2009 at 12:14:41PM +0530, kernel mailz wrote:
>> Thanks for responding to my previous mail. A few more queries
>>
>> a. What is the use of adding format specifiers in inline assembly
>> like
>> asm volatile("ld%U1%X1 %0,%1":"=r"(ret) : "m"(*ptr) : "memory");
>
> The format specifiers limit which registers or addressing modes will
> be chosen to access that parameter. For example, if you're using an
> instruction that treats r0 as a literal 0 value, you can't use the
> "r" specifier for that or you may see problems if it happens to allocate
> r0 for that particular argument. For memory access, the "m" lets you
> use any of the normal load/store patterns (which is why this particular
> choice also requires the "%U1%X1" part to allow changing the instruction).
> The system was setup for an older style chip like x86 or 68k with many
> restrictions on which registers can be used where and large numbers of
> different addressing modes for accessing memory. It's a little clumsy
> for ppc by comparison to most other chips, but it's a fundamental part
> of inline assembly processing in gcc.
>
>> b. using m or Z ?with a memory address. I tried replacing m/Z but no change
>> Is there some guideline ?
>> gcc documentation says Z is obsolete. Is m/Z replaceable ?
>
> No idea. I don't remember ever seeing 'Z' used in anything. Maybe somebody
> else remembers what it used to mean.
>
> ? ? ? ?Brad Boyer
> ? ? ? [email protected]
>
>
Brad Boyer <[email protected]> writes:
> On Fri, Jul 03, 2009 at 12:14:41PM +0530, kernel mailz wrote:
>> b. using m or Z with a memory address. I tried replacing m/Z but no change
>> Is there some guideline ?
>> gcc documentation says Z is obsolete. Is m/Z replaceable ?
>
> No idea. I don't remember ever seeing 'Z' used in anything. Maybe somebody
> else remembers what it used to mean.
The 'Z' constraint is required for a memory operand for insns that don't
have an update form (which would be selected by the %U modifier). It
should only be used together with the %y operand modifier, which makes
sure that the first register is never 0. If the 'm' constraint were
used the operand could contain a pre-in/decrement operation, and without
%U the side effect would be lost.
Andreas.
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
kernel mailz <[email protected]> writes:
> My query was more on %U1%X1, I guess it is specifying U and/or X for %1 right ?
> what does U/X stand for (is it similar to u - unsigned and x for a hex address)
> are there any more literals like U/X/...
The 'U' and 'X' modifiers expand to 'u' and 'x' resp, depending on the
form of the referenced memory operand. That allows one to select the
right mnemonic among for example lwz, lwzu, lwzx and lwzux. Those
modifiers must always be used together with the "m" constraint.
Andreas.
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
On Fri, Jul 03, 2009 at 10:57:12PM +0200, Andreas Schwab wrote:
> Brad Boyer <[email protected]> writes:
>
> > On Fri, Jul 03, 2009 at 12:14:41PM +0530, kernel mailz wrote:
> >> b. using m or Z with a memory address. I tried replacing m/Z but no change
> >> Is there some guideline ?
> >> gcc documentation says Z is obsolete. Is m/Z replaceable ?
> >
> > No idea. I don't remember ever seeing 'Z' used in anything. Maybe somebody
> > else remembers what it used to mean.
>
> The 'Z' constraint is required for a memory operand for insns that don't
> have an update form (which would be selected by the %U modifier).
Hmmm, I believed that it was for instructions that only have an indexed
form (all Altivec, byte reverse, and l?arx/st?cx for atomic operations).
Of course none of these instructions have an update form, but they don't
have an offset encoded in the instruction either.
Gabriel
Gabriel Paubert <[email protected]> writes:
> On Fri, Jul 03, 2009 at 10:57:12PM +0200, Andreas Schwab wrote:
>> The 'Z' constraint is required for a memory operand for insns that don't
>> have an update form (which would be selected by the %U modifier).
>
> Hmmm, I believed that it was for instructions that only have an indexed
> form (all Altivec, byte reverse, and l?arx/st?cx for atomic operations).
>
> Of course none of these instructions have an update form, but they don't
> have an offset encoded in the instruction either.
Yes, you are right. IIRC there are either all u/x/ux forms or only the
x form.
Andreas.
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
On Tue, Jul 07, 2009 at 02:40:02PM +0200, Andreas Schwab wrote:
> Gabriel Paubert <[email protected]> writes:
>
> > On Fri, Jul 03, 2009 at 10:57:12PM +0200, Andreas Schwab wrote:
> >> The 'Z' constraint is required for a memory operand for insns that don't
> >> have an update form (which would be selected by the %U modifier).
> >
> > Hmmm, I believed that it was for instructions that only have an indexed
> > form (all Altivec, byte reverse, and l?arx/st?cx for atomic operations).
> >
> > Of course none of these instructions have an update form, but they don't
> > have an offset encoded in the instruction either.
>
> Yes, you are right. IIRC there are either all u/x/ux forms or only the
> x form.
AFAIR IBM (probably) managed to screw up by making an exception for lwa:
lwa, lwax and lwaux exist, but not lwau!
Gabriel