Lines Matching full:pointer
1 //===--- Pointer.h - Types for the constexpr VM -----------------*- C++ -*-===//
9 // Defines the classes responsible for pointer tracking.
28 class Pointer; variable
33 class Pointer; variable
34 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P);
37 /// The block the pointer is pointing to.
50 /// A pointer to a memory block, live or dead.
55 /// In the simplest form, a Pointer has a Block* (the pointee) and both Base
64 /// data the pointer decribes can be found at
65 /// Pointee->rawData() + Pointer.Offset.
79 class Pointer {
85 Pointer() { in Pointer() function
90 Pointer(Block *B);
91 Pointer(Block *B, uint64_t BaseAndOffset);
92 Pointer(const Pointer &P);
93 Pointer(Pointer &&P);
94 Pointer(uint64_t Address, const Descriptor *Desc, uint64_t Offset = 0)
99 ~Pointer();
101 void operator=(const Pointer &P);
102 void operator=(Pointer &&P);
105 bool operator==(const Pointer &P) const {
118 bool operator!=(const Pointer &P) const { return !(P == *this); }
120 /// Converts the pointer to an APValue.
123 /// Converts the pointer to a string usable in diagnostics.
132 /// Converts the pointer to an APValue that is an rvalue.
136 /// Offsets a pointer inside an array.
137 [[nodiscard]] Pointer atIndex(uint64_t Idx) const { in atIndex()
139 return Pointer(asIntPointer().Value, asIntPointer().Desc, Idx); in atIndex()
142 return Pointer(asBlockPointer().Pointee, RootPtrMark, in atIndex()
149 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, in atIndex()
153 /// Creates a pointer to a field.
154 [[nodiscard]] Pointer atField(unsigned Off) const { in atField()
157 return Pointer(asIntPointer().Value + Field, asIntPointer().Desc); in atField()
158 return Pointer(asBlockPointer().Pointee, Field, Field); in atField()
162 /// of the pointer.
163 [[nodiscard]] Pointer atFieldSub(unsigned Off) const { in atFieldSub()
166 return Pointer(asBlockPointer().Pointee, O, O); in atFieldSub()
169 /// Restricts the scope of an array element pointer.
170 [[nodiscard]] Pointer narrow() const { in narrow()
178 // Pointer to an array of base types - enter block. in narrow()
180 return Pointer(asBlockPointer().Pointee, sizeof(InlineDescriptor), in narrow()
183 // Pointer is one past end - magic offset marks that. in narrow()
185 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, in narrow()
189 // descriptors. If Offset != Base, then the pointer already points to in narrow()
190 // an element and there is nothing to do. Otherwise, the pointer is in narrow()
195 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, in narrow()
199 // Pointer is to a field or array element - enter it. in narrow()
201 return Pointer(asBlockPointer().Pointee, Offset, Offset); in narrow()
208 return Pointer(asBlockPointer().Pointee, NewBase, NewBase); in narrow()
211 /// Expands a pointer to the containing array, undoing narrowing.
212 [[nodiscard]] Pointer expand() const { in expand()
217 // Revert to an outer one-past-end pointer. in expand()
223 return Pointer(Pointee, asBlockPointer().Base, in expand()
233 return Pointer(Pointee, RootPtrMark, 0); in expand()
243 return Pointer(Pointee, Next, Offset); in expand()
246 /// Checks if the pointer is null.
253 /// Checks if the pointer is live.
278 /// Returns the expression or declaration the pointer has been created for.
287 /// Returns a pointer to the object of which this pointer is a field.
288 [[nodiscard]] Pointer getBase() const { in getBase()
291 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, 0); in getBase()
294 return Pointer(asBlockPointer().Pointee, NewBase, NewBase); in getBase()
297 [[nodiscard]] Pointer getArray() const { in getArray()
300 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, 0); in getArray()
303 return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, in getArray()
332 [[nodiscard]] Pointer getDeclPtr() const { in getDeclPtr()
333 return Pointer(asBlockPointer().Pointee); in getDeclPtr()
394 /// Checks if the pointer points to an array.
400 /// Pointer points directly to a block.
408 /// If this pointer has an InlineDescriptor we can use to initialize.
493 /// Checks if the pointer points to a dummy value.
571 /// Checks if the pointer points past the end of the object.
579 /// Checks if the pointer is an out-of-bounds element pointer.
582 /// Checks if the pointer is pointing to a zero-size array.
585 /// Dereferences the pointer, if it's live.
587 assert(isLive() && "Invalid pointer"); in deref()
629 ComparisonCategoryResult compare(const Pointer &Other) const { in compare()
642 static bool hasSameBase(const Pointer &A, const Pointer &B);
644 static bool hasSameArray(const Pointer &A, const Pointer &B);
646 /// Prints the pointer.
657 Pointer(Block *Pointee, unsigned Base, uint64_t Offset);
668 assert(Offset != 0 && "Not a nested pointer"); in getDescriptor()
687 /// Previous link in the pointer chain.
688 Pointer *Prev = nullptr;
689 /// Next link in the pointer chain.
690 Pointer *Next = nullptr;
699 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P) {