This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add add_with_carry to builtin wrapper.
ClosedPublic

Authored by lntue on Nov 4 2022, 11:31 AM.

Details

Summary

Add add_with_carry to builtin wrapper to be used by UInt class.

Diff Detail

Event Timeline

lntue created this revision.Nov 4 2022, 11:31 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 4 2022, 11:31 AM
lntue requested review of this revision.Nov 4 2022, 11:31 AM
orex accepted this revision.Nov 4 2022, 12:11 PM

Another question to you is how the functions will work with implicit conversion. What I would do is to force input be the same with is_same of enable_if, if they are available.

libc/src/__support/builtin_wrappers.h
71

Don't you think it will be good to add here static assert, that T is integer and unsigned for this implementation?

74

Nit: From my point of view boolean OR will be more clear, than binary OR.

This revision is now accepted and ready to land.Nov 4 2022, 12:11 PM
lntue updated this revision to Diff 473317.Nov 4 2022, 12:42 PM

Address comments.

lntue marked an inline comment as done.Nov 4 2022, 12:43 PM
lntue added inline comments.
libc/src/__support/builtin_wrappers.h
71

Use enable_if to restrict to unsigned integers.

orex added inline comments.Nov 4 2022, 1:28 PM
libc/src/__support/builtin_wrappers.h
72

Thank you. Font you think, that you should put ::value everywhere here? I'm not so familiar with internal classes...

lntue added inline comments.Nov 4 2022, 1:35 PM
libc/src/__support/builtin_wrappers.h
72

Since C++17, _t and _v helpers were added to C++, and some of our internal cpp:: templates did follow.
https://en.cppreference.com/w/cpp/types/is_integral

This revision was automatically updated to reflect the committed changes.