This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to tell PPC assembler VSX is available?


On Mon, Mar 12, 2018 at 9:03 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> On Sat, Mar 10, 2018 at 11:18:12PM -0500, Jeffrey Walton wrote:
>> I used "g" from simple machine constraints. I thought giving GCC the
>> option of using memory or a register was the correct strategy. Sorry
>> about that.
>
> "g" is almost never useful for PowerPC.  "g" allows constants and memory
> and registers, and there are no machine instructions that allow more than
> one of those!  For reg vs. constant you can use %I but there is nothing
> similar for memory.
>
> Also "g" allows all allocatable registers, not what you want.
>
> Peter's advice is good; however you should use the *memory* as input
> to your asm, not the address of the memory!  Or if you really do not
> want to, at least you have to describe that that memory is read.  If
> you do not care much about optimisation you can use a "memory" clobber
> for that.

Thanks Segher.

Forgive my ignorance... According to
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, there's a fixed
size array eample that says:

<BEGIN SNIP>
An x86 example where the string memory argument is of unknown length.

asm("repne scasb"
    : "=c" (count), "+D" (p)
    : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));

If you know the above will only be reading a ten byte array then you
could instead use a memory input like: "m" (*(const char (*)[10]) p).
<END SNIP>

In this context:

>>   uint32x4_p8 res;
>>   __asm(" lxvd2x  %x0, %1, %2    \n\t"
>>         : "=wa" (res)
>>         : "g" (data), "g" (offset));

So are you saying to use something along the lines of  `"m" (*(const
char (*)[10]) p)`. Maybe:

    uint32x4_p8 res;
    __asm(" lxvd2x  %x0, %1, %2    \n\t"
          : "=wa" (res)
          : "m" (*(const unsigned int (*)[4]) data), "r" (offset));

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]