[PATCH] D156156: [clang] Implement constexpr evaluation for `__builtin_{add,sub}c`

Daniel Bertalan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 11:03:02 PDT 2023


BertalanD created this revision.
BertalanD added reviewers: aaron.ballman, cjdb, erichkeane.
Herald added a project: All.
BertalanD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC has gained support for these multiprecision arithmetic builtins in
[`r14-1896-g2b4e0415ad6`](https://gcc.gnu.org/g:2b4e0415ad6), and although they aren't explicitly specified
as such in the documentation, they are usable in a constexpr context.

      

This commit adds constexpr evaluation support to Clang to match GCC's
behavior. The implementation mirrors how the builtins are lowered to a
pair of `u{add,sub}.with.overflow` operations and the carryout is set to
1 if either of those result in an overflow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156156

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/builtins-multiprecision.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156156.543639.patch
Type: text/x-patch
Size: 9616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230724/1ebaea80/attachment-0001.bin>


More information about the cfe-commits mailing list