[LLVMdev] promotion of return value.

Rafael Espindola
Thu, 12 Mar 2009 18:25:14 -0000

>> 4) There will be 4 new function attributes:
>>   sign_ext_from_i8, sign_ext_from_i16
>>   zero_ext_from_i8, zero_ext_from_i16
>>   These attributes will be placed on the function CALL node by
>> front-end
>>   to inform the backend about such promotions and enable optimization
>> of
>>   return value. This should be sufficient for direct and indirect
>> call.
>>   (syntax of these attributes to be defined)
>

I am a bit lost, but if we are going to do what gcc does (only extent
in the caller) I don't thin we need this. We can compile

char foo() {
   char c = ...
   return c;
}

into

define i8 @foo() {
     ...
   %tmp = ....
     ret i8 %tmp
}

and if a caller wants a 32 bit value it can extend it according to the
c/c++ prototype of the function.

In theory I think we could also do this for passing arguments to
functions, but I am not sure how this would
interact with existing code compiled with gcc.

Cheers,
--
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047