Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions clang/lib/AST/ByteCode/IntegralAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ template <bool Signed> class IntegralAP final {
return IntegralAP<false>(Copy);
}

void bitcastToMemory(std::byte *Dest) const { assert(false); }
void bitcastToMemory(std::byte *Dest) const {
llvm::StoreIntToMemory(V, (uint8_t *)Dest, bitWidth() / 8);
}

static IntegralAP bitcastFromMemory(const std::byte *Src, unsigned BitWidth) {
return IntegralAP();
APInt V(BitWidth, static_cast<uint64_t>(0), Signed);
llvm::LoadIntFromMemory(V, (const uint8_t *)Src, BitWidth / 8);
return IntegralAP(V);
}

ComparisonCategoryResult compare(const IntegralAP &RHS) const {
Expand Down
5 changes: 5 additions & 0 deletions clang/test/AST/ByteCode/builtin-bit-cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ constexpr bool operator==(const struct bits<N, T, P>& lhs, const struct bits<N,
return lhs.bits == rhs.bits;
}

#ifdef __SIZEOF_INT128__
static_assert(check_round_trip<__int128_t>((__int128_t)34));
static_assert(check_round_trip<__int128_t>((__int128_t)-34));
#endif


namespace simple {
constexpr int A = __builtin_bit_cast(int, 10);
Expand Down
Loading