]> granicus.if.org Git - llvm/commit
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)
commit6012b271292286c5e4e39fe6f5fd112482d33502
tree1a5188117e03e7604ccab2b345c18581ea2544da
parent2f85bd146425cf16c321e023ad0331a30d0e59aa
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast

This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a
bit_cast from a value v to a type T. This expression can be evaluated at
compile time under specific circumstances.

The compile time evaluation currently doesn't support bit-fields, but I'm
planning on fixing this in a follow up (some of the logic for figuring this out
is in CodeGen). I'm also planning follow-ups for supporting some more esoteric
types that the constexpr evaluator supports, as well as extending
__builtin_memcpy constexpr evaluation to use the same infrastructure.

rdar://44987528

Differential revision: https://reviews.llvm.org/D62825

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364954 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/APInt.h
lib/ExecutionEngine/ExecutionEngine.cpp
lib/Support/APInt.cpp