[cfe-commits] [llvm-commits] [patch] fp128 sint_to_fp folding fix

Richard Smith richard at metafoo.co.uk
Thu Jan 17 14:21:20 PST 2013


Instead of storing the fltSemantics* on the FloatingLiteral, you can
use ASTContext::getFloatTypeSemantics(Literal->getType()). You'll need
to update getValue to take a const ASTContext&.

On Thu, Jan 17, 2013 at 4:37 AM, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi again,
>
> This clang part of the patch has been waiting for quite a while now.
> Could someone look at it?
>
> Cheers.
>
> Tim.
>
>>> I've got some updated patches here that remove any default behaviour; as
>>> Duncan pointed out it *is* largely inappropriate. The new interface is
>>>
>>>     APFloat::APFloat(const fltSemantics&, const APInt&)
>>>
>>> On the whole it turned out rather neatly. When needed, the fltSemantics
>>> were usually easy to come by, even though there's a redundancy in APInt
>>> size and semantics for the smaller cases.
>>>
>>> I experimented with alternatives before settling on this (ignore names):
>>>
>>>     APFloat::APFloat(const APInt&) // Faults if 128-bit attempted
>>>     APFloat::getIEEEQuad(const APInt&)
>>>     APFloat::getPPCDblDbl(const APInt&)
>>>
>>> This seemed promising, but there were lots of places where code wanted to
>>> all floating-point types, so some generic function was beneficial, and at
>>> that point is it really worth adding a helper that only works for types <
>>> 64 bits. You can bet someone will use it without thinking things through
>>> properly.
>>>
>>>     APFloat::APFloat(const APInt&, enum { irrelevent, ieee128, ppc128 })
>>>
>>> This was basically the same as the chosen variant, except that it
>>> introduced a largely redundant enum.
>>>
>>> I'm much less certain about the patch to Clang. What was there was clearly
>>> wrong: AST serialisation didn't save the IsIEEE property, however there's
>>> no existing good way to serialise an fltSemantics. Is there a better way
>>> I've missed, or should I put the enum in a more standard place? There
>>> didn't seem to be a directly equivalent construct.
>>>
>>> Tim.
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list