[cfe-commits] r52914 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Builtins.def include/clang/Basic/TargetInfo.h lib/AST/ASTContext.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenTypes.cpp lib/Co

Chris Lattner clattner at apple.com
Mon Jun 30 18:40:32 PDT 2008


On Jun 30, 2008, at 3:59 PM, Eli Friedman wrote:

> On Mon, Jun 30, 2008 at 11:32 AM, Chris Lattner <sabre at nondot.org>  
> wrote:
>> Author: lattner
>> Date: Mon Jun 30 13:32:54 2008
>> New Revision: 52914
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=52914&view=rev
>> Log:
>> Make a few related changes:
>>
>> 1) add a new ASTContext::getFloatTypeSemantics method.
>> 2) Use it from SemaExpr.cpp, CodeGenTypes.cpp and other places.
>> 3) Change the TargetInfo.h get*Format methods to return their
>>  fltSemantics byref instead of by pointer.
>> 4) Change CodeGenFunction::EmitBuiltinExpr to allow builtins which
>>  sometimes expand specially and othertimes fall back to libm.
>> 5) Add support for __builtin_nan("") to codegen, cases that don't  
>> pass
>>  in an empty string are currently lowered to libm calls.
>> 6) Fix codegen of __builtin_infl.
>
> Okay, makes sense... it's a rather different approach from the
> original patch, but it's probably better this way.  Although, why do
> we need to be able to sometimes expand the libm calls?  Are we trying
> to match gcc guarantees about folding, or something like that?

GCC allows you to do this:

const char *foo(const char *X) { return __builtin_nan(X); }

which should call the libm 'nan' function.

> I guess the constant-expression eval code will eventually need to
> learn how to calculate the value of anything we want to be able to
> consider constant, like __builtin_infl and __builtin_nan.  Not really
> relevant to this patch, though.

Yep,

-Chris



More information about the cfe-commits mailing list