[LLVMdev] Floating point number format in .ll files changed?
Dale Johannesen
dalej at apple.com
Tue Oct 2 11:00:58 PDT 2007
On Oct 2, 2007, at 8:15 AM, Jan Rehders wrote:
> Hi,
>
> after upgrading to 2.1 I noticed that the format for floating point
> numbers in .ll files apparently changed. I now get errors like
>
> "llvm-as: var.ll:48,0: Floating point constant invalid for type"
>
> for such code:
>
> "@gmFloat = constant float 0.3".
>
> I checked with llvm-gcc and it now generates code for the hexadecimal
> floating point representation. The documentation at http://llvm.org/
> docs/LangRef.html#simpleconstants still says
>
> "Floating point constants use standard decimal notation (e.g.
> 123.421), exponential notation (e.g. 1.23421e+2), or a more precise
> hexadecimal notation (see below)".
Farther down it says:
"The only time hexadecimal floating point constants are required (and
the only time that they are generated by the disassembler) is when a
floating point constant must be emitted but it cannot be represented
as a decimal floating point number."
Represented means represented exactly, with no loss of information.
> I tried some numbers and llvm-as accepted "1.000000e+00", "1.0", "1."
> while it rejected "0.3", ".3", "0.1", "0.300000e+00" and "0.3000000e
> +00". It accepts more numbers for variables of type double (like
> 0.1). I think the pattern I can spot is to use hexadecimal notation
> if the decimal number cannot be represented as a float.
Right.
> Does LLVM
> provide any help converting floats to hexadecimal representation?
Sure, there are internal conversion routines. Most constants are
held in APFloat objects these days, you might want to look at that.
What are you trying to do?
> Which formats are accepted for floating point numbers in 2.1?
>
> greetings,
> Jan
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list