This is an archive of the discontinued LLVM Phabricator instance.

[APFloat] Add DoubleAPFloat mode to APFloat. NFC.
ClosedPublic

Authored by timshen on Oct 26 2016, 3:52 AM.

Details

Summary

This patch adds DoubleAPFloat mode to APFloat.

Now, an APFloat with semantics PPCDoubleDouble will have DoubleAPFloat layout
(APFloat.U.Double), which contains two underlying APFloats as
PPCDoubleDoubleImpl and IEEEdouble semantics. Currently the IEEEdouble APFloat
is not used, and the first APFloat behaves exactly the same before this change.

This patch consists of three kinds of logics:

  1. Construction and destruction of APFloat. Now the ctors, dtor, assign opertors and factory functions construct different underlying layout based on the semantics passed in.
  2. s/IEEE/getIEEE()/ for normal, lifetime-unrelated computation functions. These functions only access Floats[0] in DoubleAPFloat, which is the same as today's semantic.
  3. A "Double dispatch" function, APFloat::convert. Converting between two different layouts requires appropriate logic.

Neither of these change the external behavior.

Diff Detail

Repository
rL LLVM

Event Timeline

timshen updated this revision to Diff 75844.Oct 26 2016, 3:52 AM
timshen retitled this revision from to [APFloat] Add DoubleAPFloat mode to APFloat. NFC..
timshen updated this object.
timshen added reviewers: hfinkel, kbarton, echristo, iteratee.
timshen added a subscriber: llvm-commits.
hfinkel accepted this revision.Oct 26 2016, 5:35 PM
hfinkel edited edge metadata.

Some grammar,etc. nits, otherwise LGTM.

llvm/include/llvm/ADT/APFloat.h
569 ↗(On Diff #75844)

s/Notice/Note/

600 ↗(On Diff #75844)

semantic -> semantics

601 ↗(On Diff #75844)

semantic is -> semantics are

602 ↗(On Diff #75844)

semantic is -> semantics are

(semantics are always plural, unless you're taking about one particular property in particular - here, we're always talking about all of the properties that define a particular kind of floating-point number).

604 ↗(On Diff #75844)

Notice -> Note

723 ↗(On Diff #75844)

I think this would look better if you lined up the 'std::is_same's vertically.

724 ↗(On Diff #75844)

This should fit on the previous line.

llvm/lib/Support/APFloat.cpp
80 ↗(On Diff #75844)

This is a transient semantics for -> These are temporary semantics for

83 ↗(On Diff #75844)

operates -> operate

86 ↗(On Diff #75844)

we -> we'll

This revision is now accepted and ready to land.Oct 26 2016, 5:35 PM
timshen updated this revision to Diff 76091.Oct 27 2016, 1:39 PM
timshen marked 10 inline comments as done.
timshen edited edge metadata.

Update comments.

This revision was automatically updated to reflect the committed changes.

Added a workaround for old clang in r285358.

llvm/include/llvm/ADT/APFloat.h
723 ↗(On Diff #75844)

Clang-format has its opinion, but I don't really care about format.