public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* How to issue POWERPC instructions or byte codes?
@ 2022-03-29 23:22 Jeffrey Walton
  2022-03-29 23:51 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey Walton @ 2022-03-29 23:22 UTC (permalink / raw)
  To: Binutils

Hi Everyone,

I need some help with the assembler. We are using cpu feature probes
to determine when Altivec, POWER7 and POWER8 are available. For POWER8
we perform a 64-bit add (64-bit add is POWER8 and above). The code
executes within a SIGILL handler.

For POWER8 we compile the source file with -mcpu=power8. GCC conflates
our use of POWER8 with its own ability to use POWER8. We use
-mcpu=power8 because we are forced to (otherwise a program will not
compile). Then, GCC thinks it can use POWER8. (This is the root
problem. The toolchain thinks it can use the same options we are
forced to use).

I need to switch to inline assembler and byte codes so I can drop
-mcpu=power8. ARM has .inst to issue instructions and byte codes. For
example, here is a ARMv7 probe:

       asm volatile (
    #if defined(__thumb__)
           ".inst.n 0xf241, 0x2034  \n\t"   // movw r0, 0x1234
           ".inst.n 0xf2c1, 0x2034  \n\t"   // movt r0, 0x1234
           "mov %0, r0              \n\t"   // mov [a], r0
    #else
           ".inst 0xe3010234  \n\t"   // movw r0, 0x1234
           ".inst 0xe3410234  \n\t"   // movt r0, 0x1234
           "mov %0, r0        \n\t"   // mov [a], r0
    #endif
           : "=r" (a) : : "r0");

My question is, what does POWERPC offer to issue instructions or byte code?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to issue POWERPC instructions or byte codes?
  2022-03-29 23:22 How to issue POWERPC instructions or byte codes? Jeffrey Walton
@ 2022-03-29 23:51 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2022-03-29 23:51 UTC (permalink / raw)
  To: noloader; +Cc: Binutils

On Tue, Mar 29, 2022 at 07:22:04PM -0400, Jeffrey Walton via Binutils wrote:
> I need to switch to inline assembler and byte codes so I can drop
> -mcpu=power8. ARM has .inst to issue instructions and byte codes. For
> example, here is a ARMv7 probe:
> 
>        asm volatile (
>     #if defined(__thumb__)
>            ".inst.n 0xf241, 0x2034  \n\t"   // movw r0, 0x1234
>            ".inst.n 0xf2c1, 0x2034  \n\t"   // movt r0, 0x1234
>            "mov %0, r0              \n\t"   // mov [a], r0
>     #else
>            ".inst 0xe3010234  \n\t"   // movw r0, 0x1234
>            ".inst 0xe3410234  \n\t"   // movt r0, 0x1234
>            "mov %0, r0        \n\t"   // mov [a], r0
>     #endif
>            : "=r" (a) : : "r0");
> 
> My question is, what does POWERPC offer to issue instructions or byte code?

 .machine push
 .machine power8
 power8 instructions here
 .machine pop

or if you want to emit raw machine code, just ".long <number>".

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-29 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 23:22 How to issue POWERPC instructions or byte codes? Jeffrey Walton
2022-03-29 23:51 ` Alan Modra

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 read-only IMAP folder(s) and NNTP newsgroup(s).