This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Bug in PPC inline assembly?



Thanks for your help: using constraint "b" instead of "r" solved my problem.


-- Stefan


> Try using 'b' for the constraint - that selects for an "address base
> register", as opposed to 'r' that is any of the general registers (including
> R0)


>> I have some problems with using inline PowerPC assembly in GCC (4.0.1).
>> Consider the following code:
>>
>> void save_fp_register(double* buffer)
>> {
>> asm("stfd F0, 0(%0)" : : "r" (buffer) );
>> }
>>
>> When compiled with -Os the generated code becomes
>>
>> save_fp_register:
>> stfd F0, 0(3)
>> blr
>>
>> Which is OK; the input parameter comes in r3 which is used directly in the
>> stfd operation. However, when compiled with -O0 (no optimization) the
>> generated code instead becomes
>>
>> save_fp_register:
>> stwu 1,-24(1)
>> stw 31,20(1)
>> mr 31,1
>> stw 3,8(31)
>> lwz 0,8(31)
>> stfd F0, 0(0) <-- error
>> lwz 11,0(1)
>> lwz 31,-4(11)
>> mr 1,11
>> blr
>>
>> The input parameter r3 is transferred to r0, which is used in the stfd
>> operation. However, for this particular operation r0 means 0 -- not the value
>> stored in r0 -- which means that the machine will actually try to store the
>> value at address 0x0.
>>
>> Is this a bug in GCC or is it my code that is messed up?



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