This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: PPC GCC Inline assembly help
- From: Ian Lance Taylor <iant at google dot com>
- To: eija_flight <ajie dot dirgantara at flightfocus dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 06 May 2009 07:31:56 -0700
- Subject: Re: PPC GCC Inline assembly help
- References: <23403005.post@talk.nabble.com>
eija_flight <ajie.dirgantara@flightfocus.net> writes:
> I'm using GCC inline assembly on PowerPc.
>
> Below codes is works :
>
> int reg_gpr()
> {
> int Rx = 0;
> __asm__ (
> "mr 31,%0\n"
> :
> :"i"(Rx)
> );
> }
>
> But not with this one :
>
> reg_gpr(0);
> int reg_gpr(int Rx)
> {
> __asm__ (
> "mr 31,%0\n"
> :
> :"i"(Rx)
> );
> }
>
> It will send error messages "impossible constraints in asm"
> Is there any other method to modify Rx value from outside functions?
By using the 'i' constraint you are requiring a constant integer. In
the second case you only have a constant integer if the function is
inlined, which will normally not happen when not optimizing. You can
force it to happen generally by using __attribute__ ((always_inline)).
Or, you could change to using the 'r' constraint instead of, or in
addition to, the 'i' constraint. The 'r' constraint will permit the
value to be in a general register.
Ian