27 assert(!Obj && Wildcard &&
"The memory object has been determined.");
36 Address.toStringUnsigned(AddrStr, 16);
37 OS <<
"ptr 0x" << AddrStr <<
" [";
39 if (Obj->isIRGlobalValue())
42 if (Address != Obj->getAddress())
43 OS <<
" + " << (Address - Obj->getAddress());
45 if (Obj->isInaccessible())
46 OS <<
" (inaccessible)";
50 OS << (Prov->isWildcard() ?
"wildcard" :
"nullary");
61 return Address ==
DL.getNullPtrValue(AS);
67 if (
IntVal.getBitWidth() == 1) {
68 OS << (
IntVal.getBoolValue() ?
"T" :
"F");
104 if (
FloatVal.toStringRoundTrip(StrVal, 6,
111 Bits.toStringUnsigned(StrVal, 16);
112 size_t MaxDigits =
divideCeil(Bits.getBitWidth(), 4);
114 for (
size_t Digits = StrVal.size(); Digits != MaxDigits; ++Digits)
134 for (
size_t I = 0,
E =
AggVal.size();
I !=
E; ++
I) {
144void AnyValue::destroy() {
168 switch (
Other.Kind) {
169 case StorageKind::Integer:
170 new (&IntVal) APInt(Other.IntVal);
172 case StorageKind::Float:
173 new (&FloatVal) APFloat(Other.FloatVal);
175 case StorageKind::Pointer:
176 new (&PtrVal) Pointer(Other.PtrVal);
178 case StorageKind::Byte:
179 new (&ByteVal) ByteValue(Other.ByteVal);
181 case StorageKind::Poison:
182 case StorageKind::None:
184 case StorageKind::Aggregate:
185 new (&AggVal) std::vector<AnyValue>(Other.AggVal);
190 switch (
Other.Kind) {
191 case StorageKind::Integer:
192 new (&IntVal) APInt(std::move(Other.IntVal));
194 case StorageKind::Float:
195 new (&FloatVal) APFloat(std::move(Other.FloatVal));
197 case StorageKind::Pointer:
198 new (&PtrVal) Pointer(std::move(Other.PtrVal));
200 case StorageKind::Byte:
201 new (&ByteVal) ByteValue(std::move(Other.ByteVal));
203 case StorageKind::Poison:
204 case StorageKind::None:
206 case StorageKind::Aggregate:
207 new (&AggVal) std::vector<AnyValue>(std::move(Other.AggVal));
218 switch (
Other.Kind) {
246 switch (
Other.Kind) {
263 new (&
AggVal) std::vector<AnyValue>(std::move(
Other.AggVal));
271 if (Ty->isFloatingPointTy() || Ty->isIntegerTy() || Ty->isPointerTy())
275 Ctx.getDataLayout().isLittleEndian());
277 uint32_t NumElements = Ctx.getEVL(VecTy->getElementCount());
278 return AnyValue(std::vector<AnyValue>(
282 uint64_t NumElements = ArrTy->getNumElements();
283 return AnyValue(std::vector<AnyValue>(
287 std::vector<AnyValue> Elements;
288 Elements.reserve(StructTy->getNumElements());
289 for (
uint32_t I = 0,
E = StructTy->getNumElements();
I !=
E; ++
I)
291 return AnyValue(std::move(Elements));
296 if (Ty->isIntegerTy())
298 if (Ty->isFloatingPointTy())
300 if (Ty->isPointerTy())
301 return Pointer::null(Ty->getPointerAddressSpace(), Ctx.getDataLayout());
304 Ctx.getDataLayout().isLittleEndian());
306 uint32_t NumElements = Ctx.getEVL(VecTy->getElementCount());
307 return AnyValue(std::vector<AnyValue>(
308 NumElements,
getNullValue(Ctx, VecTy->getElementType())));
311 uint64_t NumElements = ArrTy->getNumElements();
312 return AnyValue(std::vector<AnyValue>(
313 NumElements,
getNullValue(Ctx, ArrTy->getElementType())));
316 std::vector<AnyValue> Elements;
317 Elements.reserve(StructTy->getNumElements());
318 for (
uint32_t I = 0,
E = StructTy->getNumElements();
I !=
E; ++
I)
319 Elements.push_back(
getNullValue(Ctx, StructTy->getElementType(
I)));
320 return AnyValue(std::move(Elements));
326 assert(!Scalar.isAggregate() && !Scalar.isNone() &&
"Expect a scalar value");
327 return AnyValue(std::vector<AnyValue>(NumElements, Scalar));
331 : BitWidth(
V.
getBitWidth()), IsLittleEndian(IsLittleEndian) {
336 V.extractBitsAsZExtValue(std::min(BitWidth -
I, 8U),
I)));
351 OS <<
'b' << BitWidth <<
' ';
353 auto PrintByte = [&](
const Byte &
V) {
354 bool IsFullByte = (BitWidth & 7) == 0 ||
355 (IsLittleEndian ? &Val.back() : &Val.front()) != &
V;
357 if (IsFullByte &&
V.ConcreteMask == 255 &&
V.TagMask == 0) {
360 }
else if (IsFullByte &&
V.ConcreteMask == 0) {
361 assert(
V.Value == 0 &&
"Byte values don't contain undef bits.");
365 uint32_t BitEnd = IsFullByte ? 8 : BitWidth & 7;
368 if (
V.ConcreteMask & Mask)
369 OS << (
V.Value & Mask ?
'1' :
'0');
371 assert((
V.Value & Mask) == 0 &&
372 "Byte values don't contain undef bits.");
376 assert((
V.ConcreteMask &
V.TagMask) ==
V.TagMask);
382 if (
V.TagMask & Mask)
383 OS << (
V.TagValue & Mask ?
'1' :
'0');
393 auto &
DL = Ctx.getDataLayout();
394 unsigned PtrWidthForAS0 =
DL.getPointerSizeInBits(0);
397 if (PtrWidthForAS0 % 8 == 0 && BitWidth % PtrWidthForAS0 == 0) {
399 unsigned PtrSize = PtrWidthForAS0 / 8;
400 for (
size_t I = 0,
E = Val.size();
I !=
E;
I += PtrSize) {
403 assert((
V.ConcreteMask &
V.TagMask) ==
V.TagMask);
404 return V.TagMask == 255;
406 AnyValue Res = Ctx.fromBytes(Slice, PtrTy);
415 for (
size_t J = 0; J != PtrSize; ++J)
416 PrintByte(Val[
I + J]);
419 for (
const Byte &
V : Val)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the SmallString class.
static LLVM_ABI Semantics SemanticsToEnum(const llvm::fltSemantics &Sem)
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
A parsed version of the target data layout string in and methods for querying it.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
The instances of the Type class are immutable: once they are created, they are never changed.
This class implements an extremely fast bulk output stream that can only output to a stream.
static LLVM_ABI AnyValue getPoisonValue(Context &Ctx, Type *Ty)
static AnyValue poison()
Use getPoisonValue unless you know the scalar type is integer/fp/ptr!
std::vector< AnyValue > AggVal
const Pointer & asPointer() const
LLVM_ABI void print(Context &Ctx, raw_ostream &OS) const
static LLVM_ABI AnyValue getVectorSplat(const AnyValue &Scalar, size_t NumElements)
LLVM_ABI AnyValue & operator=(const AnyValue &)
static LLVM_ABI AnyValue getNullValue(Context &Ctx, Type *Ty)
Represents a scalar byte value.
static LLVM_ABI ByteValue poison(uint32_t BitWidth, bool IsLittleEndian)
LLVM_ABI void print(Context &Ctx, raw_ostream &OS) const
static LLVM_ABI ByteValue zero(uint32_t BitWidth, bool IsLittleEndian)
LLVM_ABI ByteValue(const APInt &V, bool IsLittleEndian)
uint32_t getBitWidth() const
The global context for the interpreter.
static LLVM_ABI AnyValue null(unsigned AS, const DataLayout &DL)
LLVM_ABI bool isNullPtr(unsigned AS, const DataLayout &DL) const
LLVM_ABI void print(raw_ostream &OS) const
static LLVM_ABI IntrusiveRefCntPtr< Provenance > nullary()
LLVM_ABI IntrusiveRefCntPtr< Provenance > getWithKnownMemoryObject(MemoryObject &Obj)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
BytesView< MutableArrayRef< Byte > > MutableBytesView
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
IntrusiveRefCntPtr< T > makeIntrusiveRefCnt(Args &&...A)
Factory function for creating intrusive ref counted pointers.
char hexdigit(unsigned X, bool LowerCase=false)
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
ArrayRef(const T &OneElt) -> ArrayRef< T >
Representation of a byte in memory.
static Byte concrete(uint8_t Val)