[cfe-dev] ObjC builtin functions for GNU back end

David Chisnall csdavec at swansea.ac.uk
Mon Mar 30 10:53:34 PDT 2009


On 30 Mar 2009, at 18:49, Eli Friedman wrote:

> On Mon, Mar 30, 2009 at 10:37 AM, David Chisnall <csdavec at swansea.ac.uk 
> > wrote:
>> Something like:
>>
>> int __builtin_add_check_overflow(int*, int, int)
>
> Do you mean __builtin_signed_add_check_overflow?  Or are we assuming
> nobody cares about unsigned overflow?

I was assuming that these would be overloaded, like the atomic  
operations, and infer the type of operation from the types of the  
arguments, but they could equally be explicit.

>> Would be be nice, with the return being a zero-extended version of  
>> the i1
>> (or, since clang supports arbitrary-with integers now, leaving it  
>> as an i1,
>> as long as this can be used in a comparison).
>
> So rather, "_Bool __builtin_signed_add_check_overflow(int*, int,
> int)"?  Seems reasonable, and rather easy to implement.

Sounds great.

>> if (__builtin_expect(__builtin_add_check_overflow(&a, b, c), 0))
>
> Note that LLVM doesn't support __builtin_expect...

Yet...?

David



More information about the cfe-dev mailing list