Hello, I'm playing with llvm/clang and I have a problem when I try to use the -ast-print options for a file that uses long double. The Basic/Targets.cpp file defined the x86 (and x86_64) long double type as APFloat::x87DoubleExtended. Then, when the AST printer try to write a long double literal value (using VisitFloatingLiteral()), it call FloatingLiteral- >getValueAsDouble() and the later does not support long double, so it try to call convertToDouble() as a fallback and crash due to an invalid assertion. APFloat.cpp:2631: failed assertion `semantics == (const llvm::fltSemantics*)&IEEEdouble' This is a know issue as some there is some comments like "// FIXME: We need something for long double here." in FloatingLiteral- >getValueAsDouble(), and "// FIXME: print value more precisely." in VisitFloatingLiteral(). I wonder what will be the best way to solve those both issue. Has somebody planned to add support for long double to APInt and APFloat ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080606/c23706bc/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2427 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080606/c23706bc/attachment.bin>
On Jun 6, 2008, at 8:51 AM, Jean-Daniel Dupas wrote:> Hello, > > > I'm playing with llvm/clang and I have a problem when I try to use > the -ast-print options for a file that uses long double. > > The Basic/Targets.cpp file defined the x86 (and x86_64) long double > type as APFloat::x87DoubleExtended. > Then, when the AST printer try to write a long double literal value > (using VisitFloatingLiteral()), it call FloatingLiteral- > >getValueAsDouble() and the later does not support long double, so > it try to call convertToDouble() as a fallback and crash due to an > invalid assertion. APFloat.cpp:2631: failed assertion `semantics == > (const llvm::fltSemantics*)&IEEEdouble' > > This is a know issue as some there is some comments like "// FIXME: > We need something for long double here." in FloatingLiteral- > >getValueAsDouble(), and "// FIXME: print value more precisely." in > VisitFloatingLiteral(). > > I wonder what will be the best way to solve those both issue. Has > somebody planned to add support for long double to APInt and APFloat ?There are no plans to support the use of host long double anywhere, if that's what you mean. Probably this dumper should use APFloat::convert to get the long double into APFloat::IEEEdouble format (with loss of precision; the comment claims that's OK), then use convertToDouble on that. If you want full precision, you'll need to print all the bits in hex; see EmitGlobalConstant in AsmPrinter.cpp. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080606/6860d98a/attachment.html>
Le 6 juin 08 à 18:47, Dale Johannesen a écrit :> > On Jun 6, 2008, at 8:51 AM, Jean-Daniel Dupas wrote: > >> Hello, >> >> >> I'm playing with llvm/clang and I have a problem when I try to use >> the -ast-print options for a file that uses long double. >> >> The Basic/Targets.cpp file defined the x86 (and x86_64) long double >> type as APFloat::x87DoubleExtended. >> Then, when the AST printer try to write a long double literal value >> (using VisitFloatingLiteral()), it call FloatingLiteral- >> >getValueAsDouble() and the later does not support long double, so >> it try to call convertToDouble() as a fallback and crash due to an >> invalid assertion. APFloat.cpp:2631: failed assertion `semantics == >> (const llvm::fltSemantics*)&IEEEdouble' >> >> This is a know issue as some there is some comments like "// FIXME: >> We need something for long double here." in FloatingLiteral- >> >getValueAsDouble(), and "// FIXME: print value more precisely." in >> VisitFloatingLiteral(). >> >> I wonder what will be the best way to solve those both issue. Has >> somebody planned to add support for long double to APInt and >> APFloat ? > > There are no plans to support the use of host long double anywhere, > if that's what you mean. > > Probably this dumper should use APFloat::convert to get the long > double into APFloat::IEEEdouble format (with loss of precision; the > comment claims that's OK), then use convertToDouble on that. If you > want full precision, you'll need to print all the bits in hex; see > EmitGlobalConstant in AsmPrinter.cpp.Thank you for the reply, it give me some track to investigate. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080606/43bb1c30/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2427 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080606/43bb1c30/attachment.bin>
On Jun 6, 2008, at 9:47 AM, Dale Johannesen wrote:>> I wonder what will be the best way to solve those both issue. Has >> somebody planned to add support for long double to APInt and >> APFloat ? > > There are no plans to support the use of host long double anywhere, > if that's what you mean. > > Probably this dumper should use APFloat::convert to get the long > double into APFloat::IEEEdouble format (with loss of precision; the > comment claims that's OK), then use convertToDouble on that. If you > want full precision, you'll need to print all the bits in hex; see > EmitGlobalConstant in AsmPrinter.cpp. >I implemented this, thanks Dale. As a note, the preferred list for clang discussion is on cfe-dev. No harm in using llvmdev though. -Chris