9#ifndef LLVM_ADT_POINTEREMBEDDEDINT_H
10#define LLVM_ADT_POINTEREMBEDDEDINT_H
32template <
typename IntT,
int Bits = sizeof(IntT) * CHAR_BIT>
33class PointerEmbeddedInt {
38 static_assert(Bits <
sizeof(uintptr_t) * CHAR_BIT,
39 "Cannot embed more bits than we have in a pointer!");
44 Shift =
sizeof(uintptr_t) * CHAR_BIT - Bits,
48 explicit RawValueTag() =
default;
62 "Integer has bits outside those preserved!");
63 Value =
static_cast<uintptr_t
>(
I) << Shift;
69 operator IntT()
const {
70 if (std::is_signed<IntT>::value)
71 return static_cast<IntT
>(
static_cast<intptr_t
>(Value) >> Shift);
72 return static_cast<IntT
>(Value >> Shift);
78template <
typename IntT,
int Bits>
83 return reinterpret_cast<void *
>(
P.Value);
87 return T(
reinterpret_cast<uintptr_t
>(
P),
typename T::RawValueTag());
91 return T(
reinterpret_cast<uintptr_t
>(
P),
typename T::RawValueTag());
99template <
typename IntT,
int Bits>
108 return IntInfo::getHashValue(Arg);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines DenseMapInfo traits for DenseMap.
Utility to embed an integer into a pointer-like type.
PointerEmbeddedInt & operator=(IntT I)
PointerEmbeddedInt(IntT I)
PointerEmbeddedInt()=default
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
static unsigned getHashValue(const T &Arg)
static bool isEqual(const T &LHS, const T &RHS)
PointerEmbeddedInt< IntT, Bits > T
DenseMapInfo< IntT > IntInfo
static T getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
static T getFromVoidPointer(const void *P)
PointerEmbeddedInt< IntT, Bits > T
static void * getAsVoidPointer(const T &P)
static T getFromVoidPointer(void *P)
static constexpr int NumLowBitsAvailable
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...