[LLVMdev] Generating Floating point constants

Dale Johannesen dalej at apple.com
Wed Jun 2 11:07:39 PDT 2010


On Jun 2, 2010, at 11:05 AMPDT, Stéphane Letz wrote:
>>> 
>>>> and you don't care about the precise hexadecimal
>>>> representation, AFAIK just printing a decimal float works.  
>>> 
>>> Seems like some values cannot be assembled later on (for instance with "llc")
>> 
>> Yes, there are floating point values (such as NaNs) that cannot be expressed in decimal, and others that would require a prohibitively large number of digits.  You don't want to do that.
>> 
>> The code that writes out APFloats is in WriteConstantInt [sic] in VMCore/AsmWriter.cpp.  It's not set up to do conversions separately from writing out, but you should be able to figure it out.
> 
> Thanks... but this is linked to the LLVM code base right?

It's part of LLVM, yes.

> Is there any self-contained code that can be used to handle floats when writing textual LLVM IR?

Not that I know of.





More information about the llvm-dev mailing list