This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: double argument casting
Thanks for the feedback.
In that case your patch modification seems to work better since it seems
to remove the cast from the callee and does the sign extension on the
caller:
(gcc4.5.1 with your patch applied)
0001024c <somme>:
1024c: 10 80 00 04 b 1025c <somme+0x10>
10250: 82 10 20 00 clr %g1
10254: 82 00 60 01 inc %g1
10258: 91 3a 20 18 sra %o0, 0x18, %o0
1025c: 80 a0 40 09 cmp %g1, %o1
10260: 26 bf ff fd bl,a 10254 <somme+0x8>
10264: 91 2a 20 19 sll %o0, 0x19, %o0
10268: 90 02 00 09 add %o0, %o1, %o0
1026c: 91 2a 20 10 sll %o0, 0x10, %o0
10270: 81 c3 e0 08 retl
10274: 91 3a 20 10 sra %o0, 0x10, %o0
000102ac <main>:
102ac: 9d e3 bf 98 save %sp, -104, %sp
102b0: 82 10 20 01 mov 1, %g1
102b4: c2 37 bf fc sth %g1, [ %fp + -4 ]
102b8: c2 2f bf ff stb %g1, [ %fp + -1 ]
102bc: c2 2f bf fe stb %g1, [ %fp + -2 ]
102c0: d0 0f bf ff ldub [ %fp + -1 ], %o0
102c4: d2 17 bf fc lduh [ %fp + -4 ], %o1
102c8: 91 2a 20 18 sll %o0, 0x18, %o0
102cc: 93 2a 60 10 sll %o1, 0x10, %o1
102d0: 91 3a 20 18 sra %o0, 0x18, %o0
102d4: 7f ff ff de call 1024c <somme>
102d8: 93 3a 60 10 sra %o1, 0x10, %o1
102dc: d0 37 bf fc sth %o0, [ %fp + -4 ]
102e0: d0 0f bf fe ldub [ %fp + -2 ], %o0
102e4: d2 17 bf fc lduh [ %fp + -4 ], %o1
102e8: 91 2a 20 18 sll %o0, 0x18, %o0
102ec: 93 2a 60 10 sll %o1, 0x10, %o1
102f0: 91 3a 20 18 sra %o0, 0x18, %o0
102f4: 7f ff ff d6 call 1024c <somme>
...
isn't that right?
Thanks
Eric Botcazou wrote:
>> we modified the function *TARGET_PROMOTE_PROTOTYPES
>> *(http://goo.gl/2pQQ) and set it to the default value which is FALSE.
>>
>> static bool
>> sparc_promote_prototypes (const_tree fntype ATTRIBUTE_UNUSED)
>> {
>> return TARGET_ARCH32 ? true : false;
>> }
>>
>> was replaced by
>>
>> static bool
>> sparc_promote_prototypes (const_tree fntype ATTRIBUTE_UNUSED)
>> {
>> return false;
>> }
>>
>
> As mentioned in the PR, this will result in ABI violations. But, in fact,
> this is already visible in the modified assembly code:
>
>
>> 000102b4 <main>:
>> 102b4: 9d e3 bf 98 save %sp, -104, %sp
>> 102b8: 82 10 20 01 mov 1, %g1
>> 102bc: c2 37 bf fc sth %g1, [ %fp + -4 ]
>> 102c0: c2 2f bf ff stb %g1, [ %fp + -1 ]
>> 102c4: c2 2f bf fe stb %g1, [ %fp + -2 ]
>> 102c8: d0 0f bf ff ldub [ %fp + -1 ], %o0
>> 102cc: d2 17 bf fc lduh [ %fp + -4 ], %o1
>> 102d0: 7f ff ff df call 1024c <somme>
>> 102d4: 01 00 00 00 nop
>>
>
> The ABI says that %o1 should be sign-extended since it's for a 'short'. It is
> now zero-extended, so this isn't conforming.
>
>