This is an archive of the discontinued LLVM Phabricator instance.

[Builtins] Implement half-precision conversions.
ClosedPublic

Authored by ab on May 11 2015, 6:39 PM.

Details

Summary

Mostly uninteresting, except:

  • in __extendXfYf2, when checking if the number is normal, the current code relies on the unsignedness of src_rep_t, which is fine. Except that when sizeof(src_rep_t) < sizeof(int), the result gets promoted to int, the signedness of which breaks the comparison. I added an explicit cast to avoid that; it shouldn't affect other types.
  • we can't just pass __fp16 around (you even get a clang error), so I made uint16_t explicit.
  • is there a good way to define aliases (for the gnu_*_ieee names) ? Using the attribute, on darwin, clang complains about only weak aliases being supported, so I went with the simple def.

I also need to finish writing unit tests in compiler-rt proper (I paused when I realized lit+cmake isn't supported). In the meantime, opinions welcome.

Diff Detail

Event Timeline

ab updated this revision to Diff 25541.May 11 2015, 6:39 PM
ab retitled this revision from to [Builtins] Implement half-precision conversions..
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added a reviewer: scanon.
ab added a subscriber: Unknown Object (MLST).
scanon edited edge metadata.May 12 2015, 3:03 AM

Looks reasonable to me. Someone else will need to answer your question about gnu_*_ieee aliases.

– Steve

This revision was automatically updated to reflect the committed changes.
ab added a comment.May 12 2015, 11:39 AM

After some investigation into aliases, I don't think there's a better alternative to duplicated bodies, so I went ahead with that.

Thanks!
-Ahmed