* gcc 4.5 powerpc wants r31
@ 2011-09-14 13:08 Fabian Cenedese
2011-09-14 13:39 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: Fabian Cenedese @ 2011-09-14 13:08 UTC (permalink / raw)
To: gcc-help
Hi
Using a cross compiled gcc for PowerPC-CPUs: powerpc-eabi-gcc.exe --version
powerpc-eabi-gcc.exe (crosstool-NG-1.8.2) 4.5.2
I'm having a problem compiling some inline assembler code. This
works with older compilers but 4.5 doesn't like it.
register uint32 uFlags asm("r20") = 0;
asm volatile ("mr 31,%0": : "r" (uFlags) : "31");
Compiling unoptimized I get
file.cpp:3271:1: error: 31 cannot be used in asm here
Compiling with -O2 works.
Seems like this problem is already old (2006):
https://bugs.gentoo.org/show_bug.cgi?format=multiple;id=133948
http://www.stackless.com/pipermail/stackless/2006-August/002415.html
Is there a solution apart from -fomit-frame-pointer or "don't do this"?
Thanks
bye Fabi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gcc 4.5 powerpc wants r31
2011-09-14 13:08 gcc 4.5 powerpc wants r31 Fabian Cenedese
@ 2011-09-14 13:39 ` Ian Lance Taylor
2011-09-14 13:57 ` Fabian Cenedese
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2011-09-14 13:39 UTC (permalink / raw)
To: Fabian Cenedese; +Cc: gcc-help
Fabian Cenedese <Cenedese@indel.ch> writes:
> Using a cross compiled gcc for PowerPC-CPUs: powerpc-eabi-gcc.exe --version
> powerpc-eabi-gcc.exe (crosstool-NG-1.8.2) 4.5.2
>
> I'm having a problem compiling some inline assembler code. This
> works with older compilers but 4.5 doesn't like it.
>
> register uint32 uFlags asm("r20") = 0;
> asm volatile ("mr 31,%0": : "r" (uFlags) : "31");
>
> Compiling unoptimized I get
>
> file.cpp:3271:1: error: 31 cannot be used in asm here
>
> Compiling with -O2 works.
>
> Seems like this problem is already old (2006):
> https://bugs.gentoo.org/show_bug.cgi?format=multiple;id=133948
> http://www.stackless.com/pipermail/stackless/2006-August/002415.html
>
> Is there a solution apart from -fomit-frame-pointer or "don't do this"?
No. If gcc is using the frame pointer, then it can't work correctly if
you clobber the frame pointer. It's a feature that gcc is telling you
this.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gcc 4.5 powerpc wants r31
2011-09-14 13:39 ` Ian Lance Taylor
@ 2011-09-14 13:57 ` Fabian Cenedese
0 siblings, 0 replies; 3+ messages in thread
From: Fabian Cenedese @ 2011-09-14 13:57 UTC (permalink / raw)
To: gcc-help
At 06:38 14.09.2011 -0700, Ian Lance Taylor wrote:
>Fabian Cenedese <Cenedese@indel.ch> writes:
>> register uint32 uFlags asm("r20") = 0;
>> asm volatile ("mr 31,%0": : "r" (uFlags) : "31");
>>
>> file.cpp:3271:1: error: 31 cannot be used in asm here
>>
>> Is there a solution apart from -fomit-frame-pointer or "don't do this"?
>
>No. If gcc is using the frame pointer, then it can't work correctly if
>you clobber the frame pointer. It's a feature that gcc is telling you
>this.
This code is part of an embedded operating system. So of course
we'd like full control over all registers. After this register setting
is an asm jump to some other code, so r31 is not really used
for the C-code anymore.
I found that it works if I remove the clobber. That is good enough
as there's no more C-code that could look at the clobber.
Thanks
bye Fabi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-14 13:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-14 13:08 gcc 4.5 powerpc wants r31 Fabian Cenedese
2011-09-14 13:39 ` Ian Lance Taylor
2011-09-14 13:57 ` Fabian Cenedese
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).