[cfe-dev] [RFC] Introduce overflow builtins

Dave Zarzycki zarzycki at apple.com
Tue Mar 27 22:51:21 PDT 2012


On Mar 27, 2012, at 8:22 PM, Xi Wang <xi.wang at gmail.com> wrote:

> On Mar 24, 2012, at 10:04 PM, Chris Lattner wrote:
>> On Mar 22, 2012, at 6:12 AM, Xi Wang wrote:
>>> Actually I used __builtin_saddo (__builtin_sadd_with_overflow is just too long).  Since this "saddo" looked a little bizarre to me, I changed it to __overflow_sadd.
>> 
>> I don't think a long name is a bad thing.  These builtins will be rarely used, it's just that they are important when they do get used.
>> 
>>> I was also wondering which would be better, __overflow_*(T*, T, T) or __overflow_*(T, T, T*).
>> 
>> I don't have a preference one way or the other.  Are there any precedents?

> 
> Okay.  Let's try
> 
> 	__builtin_*_with_overflow(T, T, T*);
> 
> to keep the names consistent with the LLVM counterparts.  Also it's probably more intuitive to let the output parameter come after the inputs.
> 
> Does this sound good?

There is precedence for the opposite order. For example, the  __sync_*() APIs put the pointer first: T*, T, ...

This makes sense too. One shouldn't have to reorder "x = y + z" to "y, z, &x". That'll just confuse people in the long run.

davez




More information about the cfe-dev mailing list